setup.c 7.2 KB

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