setup.c 7.5 KB

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