setup.c 7.4 KB

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