Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Nobuhiro Iwamatsu | aa4a5db | 2006-12-29 01:50:35 +0900 | [diff] [blame] | 2 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * linux/arch/sh/boards/se/770x/setup.c |
| 4 | * |
| 5 | * Copyright (C) 2000 Kazumoto Kojima |
| 6 | * |
| 7 | * Hitachi SolutionEngine Support. |
| 8 | * |
| 9 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <linux/init.h> |
Paul Mundt | 3b4d953 | 2007-02-13 15:42:28 +0900 | [diff] [blame] | 11 | #include <linux/platform_device.h> |
Sergei Shtylyov | 195e2ad | 2018-01-06 21:53:26 +0300 | [diff] [blame] | 12 | #include <linux/sh_eth.h> |
Paul Mundt | 939a24a | 2008-07-29 21:41:37 +0900 | [diff] [blame] | 13 | #include <mach-se/mach/se.h> |
Paul Mundt | 073da9c | 2008-12-17 14:41:54 +0900 | [diff] [blame] | 14 | #include <mach-se/mach/mrshpc.h> |
| 15 | #include <asm/machvec.h> |
Paul Mundt | 711fa80 | 2006-10-03 13:14:04 +0900 | [diff] [blame] | 16 | #include <asm/io.h> |
| 17 | #include <asm/smc37c93x.h> |
Paul Mundt | 8786c95 | 2007-08-20 13:03:41 +0900 | [diff] [blame] | 18 | #include <asm/heartbeat.h> |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 19 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | /* |
| 21 | * Configure the Super I/O chip |
| 22 | */ |
| 23 | static void __init smsc_config(int index, int data) |
| 24 | { |
| 25 | outb_p(index, INDEX_PORT); |
| 26 | outb_p(data, DATA_PORT); |
| 27 | } |
| 28 | |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 29 | /* XXX: Another candidate for a more generic cchip machine vector */ |
| 30 | static void __init smsc_setup(char **cmdline_p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | { |
| 32 | outb_p(CONFIG_ENTER, CONFIG_PORT); |
| 33 | outb_p(CONFIG_ENTER, CONFIG_PORT); |
| 34 | |
| 35 | /* FDC */ |
| 36 | smsc_config(CURRENT_LDN_INDEX, LDN_FDC); |
| 37 | smsc_config(ACTIVATE_INDEX, 0x01); |
| 38 | smsc_config(IRQ_SELECT_INDEX, 6); /* IRQ6 */ |
| 39 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | /* AUXIO (GPIO): to use IDE1 */ |
| 41 | smsc_config(CURRENT_LDN_INDEX, LDN_AUXIO); |
| 42 | smsc_config(GPIO46_INDEX, 0x00); /* nIOROP */ |
| 43 | smsc_config(GPIO47_INDEX, 0x00); /* nIOWOP */ |
| 44 | |
| 45 | /* COM1 */ |
| 46 | smsc_config(CURRENT_LDN_INDEX, LDN_COM1); |
| 47 | smsc_config(ACTIVATE_INDEX, 0x01); |
| 48 | smsc_config(IO_BASE_HI_INDEX, 0x03); |
| 49 | smsc_config(IO_BASE_LO_INDEX, 0xf8); |
| 50 | smsc_config(IRQ_SELECT_INDEX, 4); /* IRQ4 */ |
| 51 | |
| 52 | /* COM2 */ |
| 53 | smsc_config(CURRENT_LDN_INDEX, LDN_COM2); |
| 54 | smsc_config(ACTIVATE_INDEX, 0x01); |
| 55 | smsc_config(IO_BASE_HI_INDEX, 0x02); |
| 56 | smsc_config(IO_BASE_LO_INDEX, 0xf8); |
| 57 | smsc_config(IRQ_SELECT_INDEX, 3); /* IRQ3 */ |
| 58 | |
| 59 | /* RTC */ |
| 60 | smsc_config(CURRENT_LDN_INDEX, LDN_RTC); |
| 61 | smsc_config(ACTIVATE_INDEX, 0x01); |
| 62 | smsc_config(IRQ_SELECT_INDEX, 8); /* IRQ8 */ |
| 63 | |
| 64 | /* XXX: PARPORT, KBD, and MOUSE will come here... */ |
| 65 | outb_p(CONFIG_EXIT, CONFIG_PORT); |
| 66 | } |
| 67 | |
Nobuhiro Iwamatsu | f987fc8 | 2007-03-12 15:12:27 +0900 | [diff] [blame] | 68 | |
| 69 | static struct resource cf_ide_resources[] = { |
| 70 | [0] = { |
| 71 | .start = PA_MRSHPC_IO + 0x1f0, |
| 72 | .end = PA_MRSHPC_IO + 0x1f0 + 8, |
| 73 | .flags = IORESOURCE_MEM, |
| 74 | }, |
| 75 | [1] = { |
| 76 | .start = PA_MRSHPC_IO + 0x1f0 + 0x206, |
Nobuhiro Iwamatsu | 787d9d7 | 2008-06-18 18:32:03 +0900 | [diff] [blame] | 77 | .end = PA_MRSHPC_IO + 0x1f0 + 8 + 0x206 + 8, |
Nobuhiro Iwamatsu | f987fc8 | 2007-03-12 15:12:27 +0900 | [diff] [blame] | 78 | .flags = IORESOURCE_MEM, |
| 79 | }, |
| 80 | [2] = { |
Nobuhiro Iwamatsu | 2a8ff45 | 2007-04-26 11:51:00 +0900 | [diff] [blame] | 81 | .start = IRQ_CFCARD, |
Nobuhiro Iwamatsu | f987fc8 | 2007-03-12 15:12:27 +0900 | [diff] [blame] | 82 | .flags = IORESOURCE_IRQ, |
| 83 | }, |
| 84 | }; |
| 85 | |
| 86 | static struct platform_device cf_ide_device = { |
| 87 | .name = "pata_platform", |
| 88 | .id = -1, |
| 89 | .num_resources = ARRAY_SIZE(cf_ide_resources), |
| 90 | .resource = cf_ide_resources, |
| 91 | }; |
| 92 | |
Paul Mundt | 3b4d953 | 2007-02-13 15:42:28 +0900 | [diff] [blame] | 93 | static unsigned char heartbeat_bit_pos[] = { 8, 9, 10, 11, 12, 13, 14, 15 }; |
| 94 | |
Paul Mundt | 8786c95 | 2007-08-20 13:03:41 +0900 | [diff] [blame] | 95 | static struct heartbeat_data heartbeat_data = { |
| 96 | .bit_pos = heartbeat_bit_pos, |
| 97 | .nr_bits = ARRAY_SIZE(heartbeat_bit_pos), |
| 98 | }; |
| 99 | |
Paul Mundt | a09d283 | 2010-01-15 12:24:34 +0900 | [diff] [blame] | 100 | static struct resource heartbeat_resource = { |
| 101 | .start = PA_LED, |
| 102 | .end = PA_LED, |
| 103 | .flags = IORESOURCE_MEM | IORESOURCE_MEM_16BIT, |
Paul Mundt | 3b4d953 | 2007-02-13 15:42:28 +0900 | [diff] [blame] | 104 | }; |
| 105 | |
| 106 | static struct platform_device heartbeat_device = { |
| 107 | .name = "heartbeat", |
| 108 | .id = -1, |
| 109 | .dev = { |
Paul Mundt | a1fd306 | 2007-08-23 15:11:44 +0900 | [diff] [blame] | 110 | .platform_data = &heartbeat_data, |
Paul Mundt | 3b4d953 | 2007-02-13 15:42:28 +0900 | [diff] [blame] | 111 | }, |
Paul Mundt | a09d283 | 2010-01-15 12:24:34 +0900 | [diff] [blame] | 112 | .num_resources = 1, |
| 113 | .resource = &heartbeat_resource, |
Paul Mundt | 3b4d953 | 2007-02-13 15:42:28 +0900 | [diff] [blame] | 114 | }; |
| 115 | |
Nobuhiro Iwamatsu | 4864841 | 2008-07-29 14:37:25 +0900 | [diff] [blame] | 116 | #if defined(CONFIG_CPU_SUBTYPE_SH7710) ||\ |
| 117 | defined(CONFIG_CPU_SUBTYPE_SH7712) |
Nobuhiro Iwamatsu | ffb91ad | 2008-06-18 18:29:06 +0900 | [diff] [blame] | 118 | /* SH771X Ethernet driver */ |
Sergei Shtylyov | 195e2ad | 2018-01-06 21:53:26 +0300 | [diff] [blame] | 119 | static struct sh_eth_plat_data sh_eth_plat = { |
| 120 | .phy = PHY_ID, |
| 121 | .phy_interface = PHY_INTERFACE_MODE_MII, |
| 122 | }; |
| 123 | |
Nobuhiro Iwamatsu | ffb91ad | 2008-06-18 18:29:06 +0900 | [diff] [blame] | 124 | static struct resource sh_eth0_resources[] = { |
| 125 | [0] = { |
| 126 | .start = SH_ETH0_BASE, |
Sergei Shtylyov | f9a531d | 2018-01-06 21:53:27 +0300 | [diff] [blame] | 127 | .end = SH_ETH0_BASE + 0x1B8 - 1, |
Nobuhiro Iwamatsu | ffb91ad | 2008-06-18 18:29:06 +0900 | [diff] [blame] | 128 | .flags = IORESOURCE_MEM, |
| 129 | }, |
| 130 | [1] = { |
Sergei Shtylyov | f9a531d | 2018-01-06 21:53:27 +0300 | [diff] [blame] | 131 | .start = SH_TSU_BASE, |
| 132 | .end = SH_TSU_BASE + 0x200 - 1, |
| 133 | .flags = IORESOURCE_MEM, |
| 134 | }, |
| 135 | [2] = { |
Nobuhiro Iwamatsu | ffb91ad | 2008-06-18 18:29:06 +0900 | [diff] [blame] | 136 | .start = SH_ETH0_IRQ, |
| 137 | .end = SH_ETH0_IRQ, |
| 138 | .flags = IORESOURCE_IRQ, |
| 139 | }, |
| 140 | }; |
| 141 | |
| 142 | static struct platform_device sh_eth0_device = { |
Sergei Shtylyov | 7bbe150 | 2013-06-07 13:55:08 +0000 | [diff] [blame] | 143 | .name = "sh771x-ether", |
| 144 | .id = 0, |
Nobuhiro Iwamatsu | ffb91ad | 2008-06-18 18:29:06 +0900 | [diff] [blame] | 145 | .dev = { |
Sergei Shtylyov | 195e2ad | 2018-01-06 21:53:26 +0300 | [diff] [blame] | 146 | .platform_data = &sh_eth_plat, |
Nobuhiro Iwamatsu | ffb91ad | 2008-06-18 18:29:06 +0900 | [diff] [blame] | 147 | }, |
| 148 | .num_resources = ARRAY_SIZE(sh_eth0_resources), |
| 149 | .resource = sh_eth0_resources, |
| 150 | }; |
| 151 | |
| 152 | static struct resource sh_eth1_resources[] = { |
| 153 | [0] = { |
| 154 | .start = SH_ETH1_BASE, |
Sergei Shtylyov | f9a531d | 2018-01-06 21:53:27 +0300 | [diff] [blame] | 155 | .end = SH_ETH1_BASE + 0x1B8 - 1, |
Nobuhiro Iwamatsu | ffb91ad | 2008-06-18 18:29:06 +0900 | [diff] [blame] | 156 | .flags = IORESOURCE_MEM, |
| 157 | }, |
| 158 | [1] = { |
Sergei Shtylyov | f9a531d | 2018-01-06 21:53:27 +0300 | [diff] [blame] | 159 | .start = SH_TSU_BASE, |
| 160 | .end = SH_TSU_BASE + 0x200 - 1, |
| 161 | .flags = IORESOURCE_MEM, |
| 162 | }, |
| 163 | [2] = { |
Nobuhiro Iwamatsu | ffb91ad | 2008-06-18 18:29:06 +0900 | [diff] [blame] | 164 | .start = SH_ETH1_IRQ, |
| 165 | .end = SH_ETH1_IRQ, |
| 166 | .flags = IORESOURCE_IRQ, |
| 167 | }, |
| 168 | }; |
| 169 | |
| 170 | static struct platform_device sh_eth1_device = { |
Sergei Shtylyov | 7bbe150 | 2013-06-07 13:55:08 +0000 | [diff] [blame] | 171 | .name = "sh771x-ether", |
| 172 | .id = 1, |
Nobuhiro Iwamatsu | ffb91ad | 2008-06-18 18:29:06 +0900 | [diff] [blame] | 173 | .dev = { |
Sergei Shtylyov | 195e2ad | 2018-01-06 21:53:26 +0300 | [diff] [blame] | 174 | .platform_data = &sh_eth_plat, |
Nobuhiro Iwamatsu | ffb91ad | 2008-06-18 18:29:06 +0900 | [diff] [blame] | 175 | }, |
| 176 | .num_resources = ARRAY_SIZE(sh_eth1_resources), |
| 177 | .resource = sh_eth1_resources, |
| 178 | }; |
Nobuhiro Iwamatsu | 4864841 | 2008-07-29 14:37:25 +0900 | [diff] [blame] | 179 | #endif |
Nobuhiro Iwamatsu | ffb91ad | 2008-06-18 18:29:06 +0900 | [diff] [blame] | 180 | |
Paul Mundt | 3b4d953 | 2007-02-13 15:42:28 +0900 | [diff] [blame] | 181 | static struct platform_device *se_devices[] __initdata = { |
| 182 | &heartbeat_device, |
Nobuhiro Iwamatsu | f987fc8 | 2007-03-12 15:12:27 +0900 | [diff] [blame] | 183 | &cf_ide_device, |
Nobuhiro Iwamatsu | 4864841 | 2008-07-29 14:37:25 +0900 | [diff] [blame] | 184 | #if defined(CONFIG_CPU_SUBTYPE_SH7710) ||\ |
| 185 | defined(CONFIG_CPU_SUBTYPE_SH7712) |
Nobuhiro Iwamatsu | ffb91ad | 2008-06-18 18:29:06 +0900 | [diff] [blame] | 186 | &sh_eth0_device, |
| 187 | &sh_eth1_device, |
Nobuhiro Iwamatsu | 4864841 | 2008-07-29 14:37:25 +0900 | [diff] [blame] | 188 | #endif |
Paul Mundt | 3b4d953 | 2007-02-13 15:42:28 +0900 | [diff] [blame] | 189 | }; |
| 190 | |
| 191 | static int __init se_devices_setup(void) |
| 192 | { |
Paul Mundt | 073da9c | 2008-12-17 14:41:54 +0900 | [diff] [blame] | 193 | mrshpc_setup_windows(); |
Paul Mundt | 3b4d953 | 2007-02-13 15:42:28 +0900 | [diff] [blame] | 194 | return platform_add_devices(se_devices, ARRAY_SIZE(se_devices)); |
| 195 | } |
Nobuhiro Iwamatsu | 9465a54 | 2007-03-27 18:13:51 +0900 | [diff] [blame] | 196 | device_initcall(se_devices_setup); |
Paul Mundt | 3b4d953 | 2007-02-13 15:42:28 +0900 | [diff] [blame] | 197 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | /* |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 199 | * The Machine Vector |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | */ |
Paul Mundt | 82f81f4 | 2007-05-15 15:19:34 +0900 | [diff] [blame] | 201 | static struct sh_machine_vector mv_se __initmv = { |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 202 | .mv_name = "SolutionEngine", |
| 203 | .mv_setup = smsc_setup, |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 204 | .mv_init_irq = init_se_IRQ, |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 205 | }; |