setup.c 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. /*
  2. * arch/sh/boards/renesas/r7780rp/setup.c
  3. *
  4. * Renesas Solutions Highlander Support.
  5. *
  6. * Copyright (C) 2002 Atom Create Engineering Co., Ltd.
  7. * Copyright (C) 2005 - 2008 Paul Mundt
  8. *
  9. * This contains support for the R7780RP-1, R7780MP, and R7785RP
  10. * Highlander modules.
  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>
  17. #include <linux/platform_device.h>
  18. #include <linux/ata_platform.h>
  19. #include <linux/types.h>
  20. #include <linux/mtd/physmap.h>
  21. #include <linux/i2c.h>
  22. #include <linux/irq.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/usb/r8a66597.h>
  25. #include <linux/usb/m66592.h>
  26. #include <net/ax88796.h>
  27. #include <asm/machvec.h>
  28. #include <mach/highlander.h>
  29. #include <asm/clock.h>
  30. #include <asm/heartbeat.h>
  31. #include <asm/io.h>
  32. #include <asm/io_trapped.h>
  33. static struct r8a66597_platdata r8a66597_data = {
  34. .xtal = R8A66597_PLATDATA_XTAL_12MHZ,
  35. .vif = 1,
  36. };
  37. static struct resource r8a66597_usb_host_resources[] = {
  38. [0] = {
  39. .start = 0xA4200000,
  40. .end = 0xA42000FF,
  41. .flags = IORESOURCE_MEM,
  42. },
  43. [1] = {
  44. .start = IRQ_EXT1, /* irq number */
  45. .end = IRQ_EXT1,
  46. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
  47. },
  48. };
  49. static struct platform_device r8a66597_usb_host_device = {
  50. .name = "r8a66597_hcd",
  51. .id = -1,
  52. .dev = {
  53. .dma_mask = NULL, /* don't use dma */
  54. .coherent_dma_mask = 0xffffffff,
  55. .platform_data = &r8a66597_data,
  56. },
  57. .num_resources = ARRAY_SIZE(r8a66597_usb_host_resources),
  58. .resource = r8a66597_usb_host_resources,
  59. };
  60. static struct m66592_platdata usbf_platdata = {
  61. .xtal = M66592_PLATDATA_XTAL_24MHZ,
  62. .vif = 1,
  63. };
  64. static struct resource m66592_usb_peripheral_resources[] = {
  65. [0] = {
  66. .name = "m66592_udc",
  67. .start = 0xb0000000,
  68. .end = 0xb00000FF,
  69. .flags = IORESOURCE_MEM,
  70. },
  71. [1] = {
  72. .name = "m66592_udc",
  73. .start = IRQ_EXT4, /* irq number */
  74. .end = IRQ_EXT4,
  75. .flags = IORESOURCE_IRQ,
  76. },
  77. };
  78. static struct platform_device m66592_usb_peripheral_device = {
  79. .name = "m66592_udc",
  80. .id = -1,
  81. .dev = {
  82. .dma_mask = NULL, /* don't use dma */
  83. .coherent_dma_mask = 0xffffffff,
  84. .platform_data = &usbf_platdata,
  85. },
  86. .num_resources = ARRAY_SIZE(m66592_usb_peripheral_resources),
  87. .resource = m66592_usb_peripheral_resources,
  88. };
  89. static struct resource cf_ide_resources[] = {
  90. [0] = {
  91. .start = PA_AREA5_IO + 0x1000,
  92. .end = PA_AREA5_IO + 0x1000 + 0x08 - 1,
  93. .flags = IORESOURCE_MEM,
  94. },
  95. [1] = {
  96. .start = PA_AREA5_IO + 0x80c,
  97. .end = PA_AREA5_IO + 0x80c + 0x16 - 1,
  98. .flags = IORESOURCE_MEM,
  99. },
  100. [2] = {
  101. .start = IRQ_CF,
  102. .flags = IORESOURCE_IRQ,
  103. },
  104. };
  105. static struct pata_platform_info pata_info = {
  106. .ioport_shift = 1,
  107. };
  108. static struct platform_device cf_ide_device = {
  109. .name = "pata_platform",
  110. .id = -1,
  111. .num_resources = ARRAY_SIZE(cf_ide_resources),
  112. .resource = cf_ide_resources,
  113. .dev = {
  114. .platform_data = &pata_info,
  115. },
  116. };
  117. static struct resource heartbeat_resources[] = {
  118. [0] = {
  119. .start = PA_OBLED,
  120. .end = PA_OBLED,
  121. .flags = IORESOURCE_MEM,
  122. },
  123. };
  124. #ifndef CONFIG_SH_R7785RP
  125. static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
  126. static struct heartbeat_data heartbeat_data = {
  127. .bit_pos = heartbeat_bit_pos,
  128. .nr_bits = ARRAY_SIZE(heartbeat_bit_pos),
  129. };
  130. #endif
  131. static struct platform_device heartbeat_device = {
  132. .name = "heartbeat",
  133. .id = -1,
  134. /* R7785RP has a slightly more sensible FPGA.. */
  135. #ifndef CONFIG_SH_R7785RP
  136. .dev = {
  137. .platform_data = &heartbeat_data,
  138. },
  139. #endif
  140. .num_resources = ARRAY_SIZE(heartbeat_resources),
  141. .resource = heartbeat_resources,
  142. };
  143. static struct ax_plat_data ax88796_platdata = {
  144. .flags = AXFLG_HAS_93CX6,
  145. .wordlength = 2,
  146. .dcr_val = 0x1,
  147. .rcr_val = 0x40,
  148. };
  149. static struct resource ax88796_resources[] = {
  150. {
  151. #ifdef CONFIG_SH_R7780RP
  152. .start = 0xa5800400,
  153. .end = 0xa5800400 + (0x20 * 0x2) - 1,
  154. #else
  155. .start = 0xa4100400,
  156. .end = 0xa4100400 + (0x20 * 0x2) - 1,
  157. #endif
  158. .flags = IORESOURCE_MEM,
  159. },
  160. {
  161. .start = IRQ_AX88796,
  162. .end = IRQ_AX88796,
  163. .flags = IORESOURCE_IRQ,
  164. },
  165. };
  166. static struct platform_device ax88796_device = {
  167. .name = "ax88796",
  168. .id = 0,
  169. .dev = {
  170. .platform_data = &ax88796_platdata,
  171. },
  172. .num_resources = ARRAY_SIZE(ax88796_resources),
  173. .resource = ax88796_resources,
  174. };
  175. static struct mtd_partition nor_flash_partitions[] = {
  176. {
  177. .name = "loader",
  178. .offset = 0x00000000,
  179. .size = 512 * 1024,
  180. },
  181. {
  182. .name = "bootenv",
  183. .offset = MTDPART_OFS_APPEND,
  184. .size = 512 * 1024,
  185. },
  186. {
  187. .name = "kernel",
  188. .offset = MTDPART_OFS_APPEND,
  189. .size = 4 * 1024 * 1024,
  190. },
  191. {
  192. .name = "data",
  193. .offset = MTDPART_OFS_APPEND,
  194. .size = MTDPART_SIZ_FULL,
  195. },
  196. };
  197. static struct physmap_flash_data nor_flash_data = {
  198. .width = 4,
  199. .parts = nor_flash_partitions,
  200. .nr_parts = ARRAY_SIZE(nor_flash_partitions),
  201. };
  202. /* This config is flash board for mass production. */
  203. static struct resource nor_flash_resources[] = {
  204. [0] = {
  205. .start = PA_NORFLASH_ADDR,
  206. .end = PA_NORFLASH_ADDR + PA_NORFLASH_SIZE - 1,
  207. .flags = IORESOURCE_MEM,
  208. }
  209. };
  210. static struct platform_device nor_flash_device = {
  211. .name = "physmap-flash",
  212. .dev = {
  213. .platform_data = &nor_flash_data,
  214. },
  215. .num_resources = ARRAY_SIZE(nor_flash_resources),
  216. .resource = nor_flash_resources,
  217. };
  218. static struct resource smbus_resources[] = {
  219. [0] = {
  220. .start = PA_SMCR,
  221. .end = PA_SMCR + 0x100 - 1,
  222. .flags = IORESOURCE_MEM,
  223. },
  224. [1] = {
  225. .start = IRQ_SMBUS,
  226. .end = IRQ_SMBUS,
  227. .flags = IORESOURCE_IRQ,
  228. },
  229. };
  230. static struct platform_device smbus_device = {
  231. .name = "i2c-highlander",
  232. .id = 0,
  233. .num_resources = ARRAY_SIZE(smbus_resources),
  234. .resource = smbus_resources,
  235. };
  236. static struct i2c_board_info __initdata highlander_i2c_devices[] = {
  237. {
  238. I2C_BOARD_INFO("r2025sd", 0x32),
  239. },
  240. };
  241. static struct platform_device *r7780rp_devices[] __initdata = {
  242. &r8a66597_usb_host_device,
  243. &m66592_usb_peripheral_device,
  244. &heartbeat_device,
  245. &smbus_device,
  246. &nor_flash_device,
  247. #ifndef CONFIG_SH_R7780RP
  248. &ax88796_device,
  249. #endif
  250. };
  251. /*
  252. * The CF is connected using a 16-bit bus where 8-bit operations are
  253. * unsupported. The linux ata driver is however using 8-bit operations, so
  254. * insert a trapped io filter to convert 8-bit operations into 16-bit.
  255. */
  256. static struct trapped_io cf_trapped_io = {
  257. .resource = cf_ide_resources,
  258. .num_resources = 2,
  259. .minimum_bus_width = 16,
  260. };
  261. static int __init r7780rp_devices_setup(void)
  262. {
  263. int ret = 0;
  264. #ifndef CONFIG_SH_R7780RP
  265. if (register_trapped_io(&cf_trapped_io) == 0)
  266. ret |= platform_device_register(&cf_ide_device);
  267. #endif
  268. ret |= platform_add_devices(r7780rp_devices,
  269. ARRAY_SIZE(r7780rp_devices));
  270. ret |= i2c_register_board_info(0, highlander_i2c_devices,
  271. ARRAY_SIZE(highlander_i2c_devices));
  272. return ret;
  273. }
  274. device_initcall(r7780rp_devices_setup);
  275. /*
  276. * Platform specific clocks
  277. */
  278. static int ivdr_clk_enable(struct clk *clk)
  279. {
  280. ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << IVDR_CK_ON), PA_IVDRCTL);
  281. return 0;
  282. }
  283. static void ivdr_clk_disable(struct clk *clk)
  284. {
  285. ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL);
  286. }
  287. static struct clk_ops ivdr_clk_ops = {
  288. .enable = ivdr_clk_enable,
  289. .disable = ivdr_clk_disable,
  290. };
  291. static struct clk ivdr_clk = {
  292. .name = "ivdr_clk",
  293. .ops = &ivdr_clk_ops,
  294. };
  295. static struct clk *r7780rp_clocks[] = {
  296. &ivdr_clk,
  297. };
  298. static void r7780rp_power_off(void)
  299. {
  300. if (mach_is_r7780mp() || mach_is_r7785rp())
  301. ctrl_outw(0x0001, PA_POFF);
  302. }
  303. /*
  304. * Initialize the board
  305. */
  306. static void __init highlander_setup(char **cmdline_p)
  307. {
  308. u16 ver = ctrl_inw(PA_VERREG);
  309. int i;
  310. printk(KERN_INFO "Renesas Solutions Highlander %s support.\n",
  311. mach_is_r7780rp() ? "R7780RP-1" :
  312. mach_is_r7780mp() ? "R7780MP" :
  313. "R7785RP");
  314. printk(KERN_INFO "Board version: %d (revision %d), "
  315. "FPGA version: %d (revision %d)\n",
  316. (ver >> 12) & 0xf, (ver >> 8) & 0xf,
  317. (ver >> 4) & 0xf, ver & 0xf);
  318. highlander_plat_pinmux_setup();
  319. /*
  320. * Enable the important clocks right away..
  321. */
  322. for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
  323. struct clk *clk = r7780rp_clocks[i];
  324. clk_register(clk);
  325. clk_enable(clk);
  326. }
  327. ctrl_outw(0x0000, PA_OBLED); /* Clear LED. */
  328. if (mach_is_r7780rp())
  329. ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */
  330. ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */
  331. pm_power_off = r7780rp_power_off;
  332. }
  333. static unsigned char irl2irq[HL_NR_IRL];
  334. static int highlander_irq_demux(int irq)
  335. {
  336. if (irq >= HL_NR_IRL || !irl2irq[irq])
  337. return irq;
  338. return irl2irq[irq];
  339. }
  340. static void __init highlander_init_irq(void)
  341. {
  342. unsigned char *ucp = highlander_plat_irq_setup();
  343. if (ucp) {
  344. plat_irq_setup_pins(IRQ_MODE_IRL3210);
  345. memcpy(irl2irq, ucp, HL_NR_IRL);
  346. }
  347. }
  348. /*
  349. * The Machine Vector
  350. */
  351. static struct sh_machine_vector mv_highlander __initmv = {
  352. .mv_name = "Highlander",
  353. .mv_setup = highlander_setup,
  354. .mv_init_irq = highlander_init_irq,
  355. .mv_irq_demux = highlander_irq_demux,
  356. };