setup.c 7.7 KB

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