setup.c 7.0 KB

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