setup.c 8.5 KB

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