Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 1 | /* |
| 2 | * arch/sh/boards/renesas/r7780rp/setup.c |
| 3 | * |
Paul Mundt | 32351a2 | 2007-03-12 14:38:59 +0900 | [diff] [blame] | 4 | * Renesas Solutions Highlander Support. |
| 5 | * |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 6 | * Copyright (C) 2002 Atom Create Engineering Co., Ltd. |
Paul Mundt | c293396 | 2008-03-25 16:49:30 +0900 | [diff] [blame] | 7 | * Copyright (C) 2005 - 2008 Paul Mundt |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 8 | * |
Paul Mundt | 32351a2 | 2007-03-12 14:38:59 +0900 | [diff] [blame] | 9 | * This contains support for the R7780RP-1, R7780MP, and R7785RP |
| 10 | * Highlander modules. |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 11 | * |
| 12 | * This file is subject to the terms and conditions of the GNU General Public |
| 13 | * License. See the file "COPYING" in the main directory of this archive |
| 14 | * for more details. |
| 15 | */ |
| 16 | #include <linux/init.h> |
Magnus Damm | 67bbabb | 2010-05-11 09:37:05 +0000 | [diff] [blame] | 17 | #include <linux/io.h> |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 18 | #include <linux/platform_device.h> |
Jeff Garzik | 0a87e3e | 2008-02-01 18:02:30 -0500 | [diff] [blame] | 19 | #include <linux/ata_platform.h> |
Paul Mundt | b5751e2 | 2007-11-02 14:17:19 +0900 | [diff] [blame] | 20 | #include <linux/types.h> |
Nobuhiro Iwamatsu | 15ba400 | 2009-06-16 07:42:20 +0000 | [diff] [blame] | 21 | #include <linux/mtd/physmap.h> |
Paul Mundt | c293396 | 2008-03-25 16:49:30 +0900 | [diff] [blame] | 22 | #include <linux/i2c.h> |
Paul Mundt | 604437f | 2009-01-09 15:11:58 +0900 | [diff] [blame] | 23 | #include <linux/irq.h> |
Yoshihiro Shimoda | 6239b20 | 2009-05-26 09:33:05 +0000 | [diff] [blame] | 24 | #include <linux/interrupt.h> |
| 25 | #include <linux/usb/r8a66597.h> |
Magnus Damm | 2c59b0b | 2009-07-22 14:41:35 +0000 | [diff] [blame] | 26 | #include <linux/usb/m66592.h> |
Jean-Christop PLAGNIOL-VILLARD | 6d803ba | 2010-11-17 10:04:33 +0100 | [diff] [blame] | 27 | #include <linux/clkdev.h> |
Magnus Damm | c6f93a3 | 2007-10-15 10:36:45 +0900 | [diff] [blame] | 28 | #include <net/ax88796.h> |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 29 | #include <asm/machvec.h> |
Paul Mundt | 7639a45 | 2008-10-20 13:02:48 +0900 | [diff] [blame] | 30 | #include <mach/highlander.h> |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 31 | #include <asm/clock.h> |
Paul Mundt | 8786c95 | 2007-08-20 13:03:41 +0900 | [diff] [blame] | 32 | #include <asm/heartbeat.h> |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 33 | #include <asm/io.h> |
Magnus Damm | c1a34e4 | 2008-02-07 20:23:53 +0900 | [diff] [blame] | 34 | #include <asm/io_trapped.h> |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 35 | |
Yoshihiro Shimoda | 6239b20 | 2009-05-26 09:33:05 +0000 | [diff] [blame] | 36 | static struct r8a66597_platdata r8a66597_data = { |
| 37 | .xtal = R8A66597_PLATDATA_XTAL_12MHZ, |
| 38 | .vif = 1, |
| 39 | }; |
| 40 | |
Yoshihiro Shimoda | e6c972f | 2007-07-17 13:38:54 +0900 | [diff] [blame] | 41 | static struct resource r8a66597_usb_host_resources[] = { |
| 42 | [0] = { |
Yoshihiro Shimoda | e6c972f | 2007-07-17 13:38:54 +0900 | [diff] [blame] | 43 | .start = 0xA4200000, |
| 44 | .end = 0xA42000FF, |
| 45 | .flags = IORESOURCE_MEM, |
| 46 | }, |
| 47 | [1] = { |
Magnus Damm | 897cfcd8 | 2007-09-10 12:06:03 +0900 | [diff] [blame] | 48 | .start = IRQ_EXT1, /* irq number */ |
| 49 | .end = IRQ_EXT1, |
Yoshihiro Shimoda | 6239b20 | 2009-05-26 09:33:05 +0000 | [diff] [blame] | 50 | .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW, |
Yoshihiro Shimoda | e6c972f | 2007-07-17 13:38:54 +0900 | [diff] [blame] | 51 | }, |
| 52 | }; |
| 53 | |
| 54 | static struct platform_device r8a66597_usb_host_device = { |
| 55 | .name = "r8a66597_hcd", |
| 56 | .id = -1, |
| 57 | .dev = { |
| 58 | .dma_mask = NULL, /* don't use dma */ |
| 59 | .coherent_dma_mask = 0xffffffff, |
Yoshihiro Shimoda | 6239b20 | 2009-05-26 09:33:05 +0000 | [diff] [blame] | 60 | .platform_data = &r8a66597_data, |
Yoshihiro Shimoda | e6c972f | 2007-07-17 13:38:54 +0900 | [diff] [blame] | 61 | }, |
| 62 | .num_resources = ARRAY_SIZE(r8a66597_usb_host_resources), |
| 63 | .resource = r8a66597_usb_host_resources, |
| 64 | }; |
| 65 | |
Magnus Damm | 2c59b0b | 2009-07-22 14:41:35 +0000 | [diff] [blame] | 66 | static struct m66592_platdata usbf_platdata = { |
| 67 | .xtal = M66592_PLATDATA_XTAL_24MHZ, |
| 68 | .vif = 1, |
| 69 | }; |
| 70 | |
Yoshihiro Shimoda | e6c972f | 2007-07-17 13:38:54 +0900 | [diff] [blame] | 71 | static struct resource m66592_usb_peripheral_resources[] = { |
| 72 | [0] = { |
| 73 | .name = "m66592_udc", |
| 74 | .start = 0xb0000000, |
| 75 | .end = 0xb00000FF, |
| 76 | .flags = IORESOURCE_MEM, |
| 77 | }, |
| 78 | [1] = { |
| 79 | .name = "m66592_udc", |
Magnus Damm | 897cfcd8 | 2007-09-10 12:06:03 +0900 | [diff] [blame] | 80 | .start = IRQ_EXT4, /* irq number */ |
| 81 | .end = IRQ_EXT4, |
Yoshihiro Shimoda | e6c972f | 2007-07-17 13:38:54 +0900 | [diff] [blame] | 82 | .flags = IORESOURCE_IRQ, |
| 83 | }, |
| 84 | }; |
| 85 | |
| 86 | static struct platform_device m66592_usb_peripheral_device = { |
| 87 | .name = "m66592_udc", |
| 88 | .id = -1, |
| 89 | .dev = { |
| 90 | .dma_mask = NULL, /* don't use dma */ |
| 91 | .coherent_dma_mask = 0xffffffff, |
Magnus Damm | 2c59b0b | 2009-07-22 14:41:35 +0000 | [diff] [blame] | 92 | .platform_data = &usbf_platdata, |
Yoshihiro Shimoda | e6c972f | 2007-07-17 13:38:54 +0900 | [diff] [blame] | 93 | }, |
| 94 | .num_resources = ARRAY_SIZE(m66592_usb_peripheral_resources), |
| 95 | .resource = m66592_usb_peripheral_resources, |
| 96 | }; |
| 97 | |
Paul Mundt | 0c020e3 | 2006-12-06 10:43:44 +0900 | [diff] [blame] | 98 | static struct resource cf_ide_resources[] = { |
| 99 | [0] = { |
Paul Mundt | 71074d3 | 2007-02-14 14:49:04 +0900 | [diff] [blame] | 100 | .start = PA_AREA5_IO + 0x1000, |
| 101 | .end = PA_AREA5_IO + 0x1000 + 0x08 - 1, |
| 102 | .flags = IORESOURCE_MEM, |
Paul Mundt | 0c020e3 | 2006-12-06 10:43:44 +0900 | [diff] [blame] | 103 | }, |
| 104 | [1] = { |
Paul Mundt | 71074d3 | 2007-02-14 14:49:04 +0900 | [diff] [blame] | 105 | .start = PA_AREA5_IO + 0x80c, |
| 106 | .end = PA_AREA5_IO + 0x80c + 0x16 - 1, |
| 107 | .flags = IORESOURCE_MEM, |
Paul Mundt | 0c020e3 | 2006-12-06 10:43:44 +0900 | [diff] [blame] | 108 | }, |
| 109 | [2] = { |
Magnus Damm | 897cfcd8 | 2007-09-10 12:06:03 +0900 | [diff] [blame] | 110 | .start = IRQ_CF, |
Paul Mundt | 0c020e3 | 2006-12-06 10:43:44 +0900 | [diff] [blame] | 111 | .flags = IORESOURCE_IRQ, |
| 112 | }, |
| 113 | }; |
| 114 | |
Paul Mundt | 71074d3 | 2007-02-14 14:49:04 +0900 | [diff] [blame] | 115 | static struct pata_platform_info pata_info = { |
| 116 | .ioport_shift = 1, |
| 117 | }; |
| 118 | |
Paul Mundt | 0c020e3 | 2006-12-06 10:43:44 +0900 | [diff] [blame] | 119 | static struct platform_device cf_ide_device = { |
| 120 | .name = "pata_platform", |
| 121 | .id = -1, |
| 122 | .num_resources = ARRAY_SIZE(cf_ide_resources), |
| 123 | .resource = cf_ide_resources, |
Paul Mundt | 71074d3 | 2007-02-14 14:49:04 +0900 | [diff] [blame] | 124 | .dev = { |
| 125 | .platform_data = &pata_info, |
| 126 | }, |
Paul Mundt | 0c020e3 | 2006-12-06 10:43:44 +0900 | [diff] [blame] | 127 | }; |
| 128 | |
Paul Mundt | 3b4d953 | 2007-02-13 15:42:28 +0900 | [diff] [blame] | 129 | static struct resource heartbeat_resources[] = { |
| 130 | [0] = { |
| 131 | .start = PA_OBLED, |
Paul Mundt | a1fd306 | 2007-08-23 15:11:44 +0900 | [diff] [blame] | 132 | .end = PA_OBLED, |
Paul Mundt | 3b4d953 | 2007-02-13 15:42:28 +0900 | [diff] [blame] | 133 | .flags = IORESOURCE_MEM, |
| 134 | }, |
| 135 | }; |
| 136 | |
Paul Mundt | 8786c95 | 2007-08-20 13:03:41 +0900 | [diff] [blame] | 137 | #ifndef CONFIG_SH_R7785RP |
| 138 | static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 }; |
| 139 | |
| 140 | static struct heartbeat_data heartbeat_data = { |
| 141 | .bit_pos = heartbeat_bit_pos, |
| 142 | .nr_bits = ARRAY_SIZE(heartbeat_bit_pos), |
| 143 | }; |
| 144 | #endif |
| 145 | |
Paul Mundt | 3b4d953 | 2007-02-13 15:42:28 +0900 | [diff] [blame] | 146 | static struct platform_device heartbeat_device = { |
| 147 | .name = "heartbeat", |
| 148 | .id = -1, |
Paul Mundt | 32351a2 | 2007-03-12 14:38:59 +0900 | [diff] [blame] | 149 | |
| 150 | /* R7785RP has a slightly more sensible FPGA.. */ |
| 151 | #ifndef CONFIG_SH_R7785RP |
Paul Mundt | 3b4d953 | 2007-02-13 15:42:28 +0900 | [diff] [blame] | 152 | .dev = { |
Paul Mundt | a1fd306 | 2007-08-23 15:11:44 +0900 | [diff] [blame] | 153 | .platform_data = &heartbeat_data, |
Paul Mundt | 3b4d953 | 2007-02-13 15:42:28 +0900 | [diff] [blame] | 154 | }, |
Paul Mundt | 32351a2 | 2007-03-12 14:38:59 +0900 | [diff] [blame] | 155 | #endif |
Paul Mundt | 3b4d953 | 2007-02-13 15:42:28 +0900 | [diff] [blame] | 156 | .num_resources = ARRAY_SIZE(heartbeat_resources), |
| 157 | .resource = heartbeat_resources, |
| 158 | }; |
| 159 | |
Magnus Damm | c6f93a3 | 2007-10-15 10:36:45 +0900 | [diff] [blame] | 160 | static struct ax_plat_data ax88796_platdata = { |
| 161 | .flags = AXFLG_HAS_93CX6, |
| 162 | .wordlength = 2, |
| 163 | .dcr_val = 0x1, |
| 164 | .rcr_val = 0x40, |
| 165 | }; |
| 166 | |
| 167 | static struct resource ax88796_resources[] = { |
| 168 | { |
| 169 | #ifdef CONFIG_SH_R7780RP |
| 170 | .start = 0xa5800400, |
| 171 | .end = 0xa5800400 + (0x20 * 0x2) - 1, |
| 172 | #else |
| 173 | .start = 0xa4100400, |
| 174 | .end = 0xa4100400 + (0x20 * 0x2) - 1, |
| 175 | #endif |
| 176 | .flags = IORESOURCE_MEM, |
| 177 | }, |
| 178 | { |
| 179 | .start = IRQ_AX88796, |
| 180 | .end = IRQ_AX88796, |
| 181 | .flags = IORESOURCE_IRQ, |
| 182 | }, |
| 183 | }; |
| 184 | |
| 185 | static struct platform_device ax88796_device = { |
| 186 | .name = "ax88796", |
| 187 | .id = 0, |
| 188 | |
| 189 | .dev = { |
| 190 | .platform_data = &ax88796_platdata, |
| 191 | }, |
| 192 | |
| 193 | .num_resources = ARRAY_SIZE(ax88796_resources), |
| 194 | .resource = ax88796_resources, |
| 195 | }; |
| 196 | |
Nobuhiro Iwamatsu | 15ba400 | 2009-06-16 07:42:20 +0000 | [diff] [blame] | 197 | static struct mtd_partition nor_flash_partitions[] = { |
| 198 | { |
| 199 | .name = "loader", |
| 200 | .offset = 0x00000000, |
| 201 | .size = 512 * 1024, |
| 202 | }, |
| 203 | { |
| 204 | .name = "bootenv", |
| 205 | .offset = MTDPART_OFS_APPEND, |
| 206 | .size = 512 * 1024, |
| 207 | }, |
| 208 | { |
| 209 | .name = "kernel", |
| 210 | .offset = MTDPART_OFS_APPEND, |
| 211 | .size = 4 * 1024 * 1024, |
| 212 | }, |
| 213 | { |
| 214 | .name = "data", |
| 215 | .offset = MTDPART_OFS_APPEND, |
| 216 | .size = MTDPART_SIZ_FULL, |
| 217 | }, |
| 218 | }; |
| 219 | |
| 220 | static struct physmap_flash_data nor_flash_data = { |
| 221 | .width = 4, |
| 222 | .parts = nor_flash_partitions, |
| 223 | .nr_parts = ARRAY_SIZE(nor_flash_partitions), |
| 224 | }; |
| 225 | |
| 226 | /* This config is flash board for mass production. */ |
| 227 | static struct resource nor_flash_resources[] = { |
| 228 | [0] = { |
| 229 | .start = PA_NORFLASH_ADDR, |
| 230 | .end = PA_NORFLASH_ADDR + PA_NORFLASH_SIZE - 1, |
| 231 | .flags = IORESOURCE_MEM, |
| 232 | } |
| 233 | }; |
| 234 | |
| 235 | static struct platform_device nor_flash_device = { |
| 236 | .name = "physmap-flash", |
| 237 | .dev = { |
| 238 | .platform_data = &nor_flash_data, |
| 239 | }, |
| 240 | .num_resources = ARRAY_SIZE(nor_flash_resources), |
| 241 | .resource = nor_flash_resources, |
| 242 | }; |
| 243 | |
Paul Mundt | c293396 | 2008-03-25 16:49:30 +0900 | [diff] [blame] | 244 | static struct resource smbus_resources[] = { |
| 245 | [0] = { |
| 246 | .start = PA_SMCR, |
| 247 | .end = PA_SMCR + 0x100 - 1, |
| 248 | .flags = IORESOURCE_MEM, |
| 249 | }, |
| 250 | [1] = { |
| 251 | .start = IRQ_SMBUS, |
| 252 | .end = IRQ_SMBUS, |
| 253 | .flags = IORESOURCE_IRQ, |
| 254 | }, |
| 255 | }; |
| 256 | |
| 257 | static struct platform_device smbus_device = { |
| 258 | .name = "i2c-highlander", |
| 259 | .id = 0, |
| 260 | .num_resources = ARRAY_SIZE(smbus_resources), |
| 261 | .resource = smbus_resources, |
| 262 | }; |
| 263 | |
| 264 | static struct i2c_board_info __initdata highlander_i2c_devices[] = { |
| 265 | { |
Jean Delvare | 3760f73 | 2008-04-29 23:11:40 +0200 | [diff] [blame] | 266 | I2C_BOARD_INFO("r2025sd", 0x32), |
Paul Mundt | c293396 | 2008-03-25 16:49:30 +0900 | [diff] [blame] | 267 | }, |
| 268 | }; |
Magnus Damm | c6f93a3 | 2007-10-15 10:36:45 +0900 | [diff] [blame] | 269 | |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 270 | static struct platform_device *r7780rp_devices[] __initdata = { |
Yoshihiro Shimoda | e6c972f | 2007-07-17 13:38:54 +0900 | [diff] [blame] | 271 | &r8a66597_usb_host_device, |
| 272 | &m66592_usb_peripheral_device, |
Paul Mundt | 3b4d953 | 2007-02-13 15:42:28 +0900 | [diff] [blame] | 273 | &heartbeat_device, |
Paul Mundt | c293396 | 2008-03-25 16:49:30 +0900 | [diff] [blame] | 274 | &smbus_device, |
Nobuhiro Iwamatsu | 15ba400 | 2009-06-16 07:42:20 +0000 | [diff] [blame] | 275 | &nor_flash_device, |
Magnus Damm | da2d7f4 | 2008-01-25 16:04:29 +0900 | [diff] [blame] | 276 | #ifndef CONFIG_SH_R7780RP |
Magnus Damm | c6f93a3 | 2007-10-15 10:36:45 +0900 | [diff] [blame] | 277 | &ax88796_device, |
Magnus Damm | da2d7f4 | 2008-01-25 16:04:29 +0900 | [diff] [blame] | 278 | #endif |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 279 | }; |
| 280 | |
Magnus Damm | c1a34e4 | 2008-02-07 20:23:53 +0900 | [diff] [blame] | 281 | /* |
| 282 | * The CF is connected using a 16-bit bus where 8-bit operations are |
| 283 | * unsupported. The linux ata driver is however using 8-bit operations, so |
| 284 | * insert a trapped io filter to convert 8-bit operations into 16-bit. |
| 285 | */ |
| 286 | static struct trapped_io cf_trapped_io = { |
| 287 | .resource = cf_ide_resources, |
| 288 | .num_resources = 2, |
| 289 | .minimum_bus_width = 16, |
| 290 | }; |
| 291 | |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 292 | static int __init r7780rp_devices_setup(void) |
| 293 | { |
Paul Mundt | c293396 | 2008-03-25 16:49:30 +0900 | [diff] [blame] | 294 | int ret = 0; |
| 295 | |
Magnus Damm | c1a34e4 | 2008-02-07 20:23:53 +0900 | [diff] [blame] | 296 | #ifndef CONFIG_SH_R7780RP |
| 297 | if (register_trapped_io(&cf_trapped_io) == 0) |
Paul Mundt | c293396 | 2008-03-25 16:49:30 +0900 | [diff] [blame] | 298 | ret |= platform_device_register(&cf_ide_device); |
Magnus Damm | c1a34e4 | 2008-02-07 20:23:53 +0900 | [diff] [blame] | 299 | #endif |
Paul Mundt | c293396 | 2008-03-25 16:49:30 +0900 | [diff] [blame] | 300 | |
| 301 | ret |= platform_add_devices(r7780rp_devices, |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 302 | ARRAY_SIZE(r7780rp_devices)); |
Paul Mundt | c293396 | 2008-03-25 16:49:30 +0900 | [diff] [blame] | 303 | |
| 304 | ret |= i2c_register_board_info(0, highlander_i2c_devices, |
| 305 | ARRAY_SIZE(highlander_i2c_devices)); |
| 306 | |
| 307 | return ret; |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 308 | } |
Paul Mundt | 32351a2 | 2007-03-12 14:38:59 +0900 | [diff] [blame] | 309 | device_initcall(r7780rp_devices_setup); |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 310 | |
| 311 | /* |
| 312 | * Platform specific clocks |
| 313 | */ |
Nobuhiro Iwamatsu | 39f4490c | 2009-06-16 07:44:10 +0000 | [diff] [blame] | 314 | static int ivdr_clk_enable(struct clk *clk) |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 315 | { |
Paul Mundt | 9d56dd3 | 2010-01-26 12:58:40 +0900 | [diff] [blame] | 316 | __raw_writew(__raw_readw(PA_IVDRCTL) | (1 << IVDR_CK_ON), PA_IVDRCTL); |
Nobuhiro Iwamatsu | 39f4490c | 2009-06-16 07:44:10 +0000 | [diff] [blame] | 317 | return 0; |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | static void ivdr_clk_disable(struct clk *clk) |
| 321 | { |
Paul Mundt | 9d56dd3 | 2010-01-26 12:58:40 +0900 | [diff] [blame] | 322 | __raw_writew(__raw_readw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL); |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | static struct clk_ops ivdr_clk_ops = { |
| 326 | .enable = ivdr_clk_enable, |
| 327 | .disable = ivdr_clk_disable, |
| 328 | }; |
| 329 | |
| 330 | static struct clk ivdr_clk = { |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 331 | .ops = &ivdr_clk_ops, |
| 332 | }; |
| 333 | |
| 334 | static struct clk *r7780rp_clocks[] = { |
| 335 | &ivdr_clk, |
| 336 | }; |
| 337 | |
Magnus Damm | 67bbabb | 2010-05-11 09:37:05 +0000 | [diff] [blame] | 338 | static struct clk_lookup lookups[] = { |
| 339 | /* main clocks */ |
| 340 | CLKDEV_CON_ID("ivdr_clk", &ivdr_clk), |
| 341 | }; |
| 342 | |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 343 | static void r7780rp_power_off(void) |
| 344 | { |
Paul Mundt | 32351a2 | 2007-03-12 14:38:59 +0900 | [diff] [blame] | 345 | if (mach_is_r7780mp() || mach_is_r7785rp()) |
Paul Mundt | 9d56dd3 | 2010-01-26 12:58:40 +0900 | [diff] [blame] | 346 | __raw_writew(0x0001, PA_POFF); |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | /* |
| 350 | * Initialize the board |
| 351 | */ |
Paul Mundt | 32351a2 | 2007-03-12 14:38:59 +0900 | [diff] [blame] | 352 | static void __init highlander_setup(char **cmdline_p) |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 353 | { |
Paul Mundt | 9d56dd3 | 2010-01-26 12:58:40 +0900 | [diff] [blame] | 354 | u16 ver = __raw_readw(PA_VERREG); |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 355 | int i; |
| 356 | |
Paul Mundt | 32351a2 | 2007-03-12 14:38:59 +0900 | [diff] [blame] | 357 | printk(KERN_INFO "Renesas Solutions Highlander %s support.\n", |
| 358 | mach_is_r7780rp() ? "R7780RP-1" : |
| 359 | mach_is_r7780mp() ? "R7780MP" : |
| 360 | "R7785RP"); |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 361 | |
| 362 | printk(KERN_INFO "Board version: %d (revision %d), " |
| 363 | "FPGA version: %d (revision %d)\n", |
| 364 | (ver >> 12) & 0xf, (ver >> 8) & 0xf, |
| 365 | (ver >> 4) & 0xf, ver & 0xf); |
| 366 | |
Paul Mundt | 61dc6eae | 2008-10-23 12:35:43 +0900 | [diff] [blame] | 367 | highlander_plat_pinmux_setup(); |
| 368 | |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 369 | /* |
| 370 | * Enable the important clocks right away.. |
| 371 | */ |
| 372 | for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) { |
| 373 | struct clk *clk = r7780rp_clocks[i]; |
| 374 | |
| 375 | clk_register(clk); |
| 376 | clk_enable(clk); |
| 377 | } |
| 378 | |
Magnus Damm | 67bbabb | 2010-05-11 09:37:05 +0000 | [diff] [blame] | 379 | clkdev_add_table(lookups, ARRAY_SIZE(lookups)); |
| 380 | |
Paul Mundt | 9d56dd3 | 2010-01-26 12:58:40 +0900 | [diff] [blame] | 381 | __raw_writew(0x0000, PA_OBLED); /* Clear LED. */ |
Paul Mundt | 32351a2 | 2007-03-12 14:38:59 +0900 | [diff] [blame] | 382 | |
| 383 | if (mach_is_r7780rp()) |
Paul Mundt | 9d56dd3 | 2010-01-26 12:58:40 +0900 | [diff] [blame] | 384 | __raw_writew(0x0001, PA_SDPOW); /* SD Power ON */ |
Paul Mundt | 32351a2 | 2007-03-12 14:38:59 +0900 | [diff] [blame] | 385 | |
Paul Mundt | 9d56dd3 | 2010-01-26 12:58:40 +0900 | [diff] [blame] | 386 | __raw_writew(__raw_readw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */ |
Paul Mundt | 5283ecb | 2006-09-27 15:59:17 +0900 | [diff] [blame] | 387 | |
| 388 | pm_power_off = r7780rp_power_off; |
| 389 | } |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 390 | |
Magnus Damm | 897cfcd8 | 2007-09-10 12:06:03 +0900 | [diff] [blame] | 391 | static unsigned char irl2irq[HL_NR_IRL]; |
| 392 | |
Paul Mundt | ae8a534 | 2008-04-25 17:58:21 +0900 | [diff] [blame] | 393 | static int highlander_irq_demux(int irq) |
Magnus Damm | 897cfcd8 | 2007-09-10 12:06:03 +0900 | [diff] [blame] | 394 | { |
Roel Kluin | 9016332 | 2009-11-02 16:14:42 +0000 | [diff] [blame] | 395 | if (irq >= HL_NR_IRL || irq < 0 || !irl2irq[irq]) |
Magnus Damm | 897cfcd8 | 2007-09-10 12:06:03 +0900 | [diff] [blame] | 396 | return irq; |
| 397 | |
| 398 | return irl2irq[irq]; |
| 399 | } |
| 400 | |
Paul Mundt | ae8a534 | 2008-04-25 17:58:21 +0900 | [diff] [blame] | 401 | static void __init highlander_init_irq(void) |
Magnus Damm | 897cfcd8 | 2007-09-10 12:06:03 +0900 | [diff] [blame] | 402 | { |
Paul Mundt | ae8a534 | 2008-04-25 17:58:21 +0900 | [diff] [blame] | 403 | unsigned char *ucp = highlander_plat_irq_setup(); |
Magnus Damm | 897cfcd8 | 2007-09-10 12:06:03 +0900 | [diff] [blame] | 404 | |
| 405 | if (ucp) { |
| 406 | plat_irq_setup_pins(IRQ_MODE_IRL3210); |
| 407 | memcpy(irl2irq, ucp, HL_NR_IRL); |
| 408 | } |
| 409 | } |
| 410 | |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 411 | /* |
| 412 | * The Machine Vector |
| 413 | */ |
Paul Mundt | 82f81f4 | 2007-05-15 15:19:34 +0900 | [diff] [blame] | 414 | static struct sh_machine_vector mv_highlander __initmv = { |
Paul Mundt | 32351a2 | 2007-03-12 14:38:59 +0900 | [diff] [blame] | 415 | .mv_name = "Highlander", |
Paul Mundt | 32351a2 | 2007-03-12 14:38:59 +0900 | [diff] [blame] | 416 | .mv_setup = highlander_setup, |
| 417 | .mv_init_irq = highlander_init_irq, |
Magnus Damm | 897cfcd8 | 2007-09-10 12:06:03 +0900 | [diff] [blame] | 418 | .mv_irq_demux = highlander_irq_demux, |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 419 | }; |