setup.c 5.7 KB

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