setup.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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. 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. &heartbeat_device,
  164. #ifndef CONFIG_SH_R7780RP
  165. &cf_ide_device,
  166. &ax88796_device,
  167. #endif
  168. };
  169. static int __init r7780rp_devices_setup(void)
  170. {
  171. return platform_add_devices(r7780rp_devices,
  172. ARRAY_SIZE(r7780rp_devices));
  173. }
  174. device_initcall(r7780rp_devices_setup);
  175. /*
  176. * Platform specific clocks
  177. */
  178. static void ivdr_clk_enable(struct clk *clk)
  179. {
  180. ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << IVDR_CK_ON), PA_IVDRCTL);
  181. }
  182. static void ivdr_clk_disable(struct clk *clk)
  183. {
  184. ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL);
  185. }
  186. static struct clk_ops ivdr_clk_ops = {
  187. .enable = ivdr_clk_enable,
  188. .disable = ivdr_clk_disable,
  189. };
  190. static struct clk ivdr_clk = {
  191. .name = "ivdr_clk",
  192. .ops = &ivdr_clk_ops,
  193. };
  194. static struct clk *r7780rp_clocks[] = {
  195. &ivdr_clk,
  196. };
  197. static void r7780rp_power_off(void)
  198. {
  199. if (mach_is_r7780mp() || mach_is_r7785rp())
  200. ctrl_outw(0x0001, PA_POFF);
  201. }
  202. static inline unsigned char is_ide_ioaddr(unsigned long addr)
  203. {
  204. return ((cf_ide_resources[0].start <= addr &&
  205. addr <= cf_ide_resources[0].end) ||
  206. (cf_ide_resources[1].start <= addr &&
  207. addr <= cf_ide_resources[1].end));
  208. }
  209. void highlander_writeb(u8 b, void __iomem *addr)
  210. {
  211. unsigned long tmp = (unsigned long __force)addr;
  212. if (is_ide_ioaddr(tmp))
  213. ctrl_outw((u16)b, tmp);
  214. else
  215. ctrl_outb(b, tmp);
  216. }
  217. u8 highlander_readb(void __iomem *addr)
  218. {
  219. unsigned long tmp = (unsigned long __force)addr;
  220. if (is_ide_ioaddr(tmp))
  221. return ctrl_inw(tmp) & 0xff;
  222. else
  223. return ctrl_inb(tmp);
  224. }
  225. /*
  226. * Initialize the board
  227. */
  228. static void __init highlander_setup(char **cmdline_p)
  229. {
  230. u16 ver = ctrl_inw(PA_VERREG);
  231. int i;
  232. printk(KERN_INFO "Renesas Solutions Highlander %s support.\n",
  233. mach_is_r7780rp() ? "R7780RP-1" :
  234. mach_is_r7780mp() ? "R7780MP" :
  235. "R7785RP");
  236. printk(KERN_INFO "Board version: %d (revision %d), "
  237. "FPGA version: %d (revision %d)\n",
  238. (ver >> 12) & 0xf, (ver >> 8) & 0xf,
  239. (ver >> 4) & 0xf, ver & 0xf);
  240. /*
  241. * Enable the important clocks right away..
  242. */
  243. for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
  244. struct clk *clk = r7780rp_clocks[i];
  245. clk_register(clk);
  246. clk_enable(clk);
  247. }
  248. ctrl_outw(0x0000, PA_OBLED); /* Clear LED. */
  249. if (mach_is_r7780rp())
  250. ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */
  251. ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */
  252. pm_power_off = r7780rp_power_off;
  253. }
  254. static unsigned char irl2irq[HL_NR_IRL];
  255. int highlander_irq_demux(int irq)
  256. {
  257. if (irq >= HL_NR_IRL || !irl2irq[irq])
  258. return irq;
  259. return irl2irq[irq];
  260. }
  261. void __init highlander_init_irq(void)
  262. {
  263. unsigned char *ucp = NULL;
  264. do {
  265. #ifdef CONFIG_SH_R7780MP
  266. ucp = highlander_init_irq_r7780mp();
  267. if (ucp)
  268. break;
  269. #endif
  270. #ifdef CONFIG_SH_R7785RP
  271. ucp = highlander_init_irq_r7785rp();
  272. if (ucp)
  273. break;
  274. #endif
  275. #ifdef CONFIG_SH_R7780RP
  276. ucp = highlander_init_irq_r7780rp();
  277. if (ucp)
  278. break;
  279. #endif
  280. } while (0);
  281. if (ucp) {
  282. plat_irq_setup_pins(IRQ_MODE_IRL3210);
  283. memcpy(irl2irq, ucp, HL_NR_IRL);
  284. }
  285. }
  286. /*
  287. * The Machine Vector
  288. */
  289. static struct sh_machine_vector mv_highlander __initmv = {
  290. .mv_name = "Highlander",
  291. .mv_setup = highlander_setup,
  292. .mv_init_irq = highlander_init_irq,
  293. .mv_irq_demux = highlander_irq_demux,
  294. .mv_readb = highlander_readb,
  295. .mv_writeb = highlander_writeb,
  296. };