setup.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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 = 11, /* irq number */
  34. .end = 11,
  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 = 9, /* irq number */
  58. .end = 9,
  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. #ifdef CONFIG_SH_R7780RP
  85. .start = 4,
  86. #else
  87. .start = 1,
  88. #endif
  89. .flags = IORESOURCE_IRQ,
  90. },
  91. };
  92. static struct pata_platform_info pata_info = {
  93. .ioport_shift = 1,
  94. };
  95. static struct platform_device cf_ide_device = {
  96. .name = "pata_platform",
  97. .id = -1,
  98. .num_resources = ARRAY_SIZE(cf_ide_resources),
  99. .resource = cf_ide_resources,
  100. .dev = {
  101. .platform_data = &pata_info,
  102. },
  103. };
  104. static struct resource heartbeat_resources[] = {
  105. [0] = {
  106. .start = PA_OBLED,
  107. .end = PA_OBLED,
  108. .flags = IORESOURCE_MEM,
  109. },
  110. };
  111. #ifndef CONFIG_SH_R7785RP
  112. static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
  113. static struct heartbeat_data heartbeat_data = {
  114. .bit_pos = heartbeat_bit_pos,
  115. .nr_bits = ARRAY_SIZE(heartbeat_bit_pos),
  116. };
  117. #endif
  118. static struct platform_device heartbeat_device = {
  119. .name = "heartbeat",
  120. .id = -1,
  121. /* R7785RP has a slightly more sensible FPGA.. */
  122. #ifndef CONFIG_SH_R7785RP
  123. .dev = {
  124. .platform_data = &heartbeat_data,
  125. },
  126. #endif
  127. .num_resources = ARRAY_SIZE(heartbeat_resources),
  128. .resource = heartbeat_resources,
  129. };
  130. static struct platform_device *r7780rp_devices[] __initdata = {
  131. &r8a66597_usb_host_device,
  132. &m66592_usb_peripheral_device,
  133. &cf_ide_device,
  134. &heartbeat_device,
  135. };
  136. static int __init r7780rp_devices_setup(void)
  137. {
  138. return platform_add_devices(r7780rp_devices,
  139. ARRAY_SIZE(r7780rp_devices));
  140. }
  141. device_initcall(r7780rp_devices_setup);
  142. /*
  143. * Platform specific clocks
  144. */
  145. static void ivdr_clk_enable(struct clk *clk)
  146. {
  147. ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << IVDR_CK_ON), PA_IVDRCTL);
  148. }
  149. static void ivdr_clk_disable(struct clk *clk)
  150. {
  151. ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL);
  152. }
  153. static struct clk_ops ivdr_clk_ops = {
  154. .enable = ivdr_clk_enable,
  155. .disable = ivdr_clk_disable,
  156. };
  157. static struct clk ivdr_clk = {
  158. .name = "ivdr_clk",
  159. .ops = &ivdr_clk_ops,
  160. };
  161. static struct clk *r7780rp_clocks[] = {
  162. &ivdr_clk,
  163. };
  164. static void r7780rp_power_off(void)
  165. {
  166. if (mach_is_r7780mp() || mach_is_r7785rp())
  167. ctrl_outw(0x0001, PA_POFF);
  168. }
  169. /*
  170. * Initialize the board
  171. */
  172. static void __init highlander_setup(char **cmdline_p)
  173. {
  174. u16 ver = ctrl_inw(PA_VERREG);
  175. int i;
  176. printk(KERN_INFO "Renesas Solutions Highlander %s support.\n",
  177. mach_is_r7780rp() ? "R7780RP-1" :
  178. mach_is_r7780mp() ? "R7780MP" :
  179. "R7785RP");
  180. printk(KERN_INFO "Board version: %d (revision %d), "
  181. "FPGA version: %d (revision %d)\n",
  182. (ver >> 12) & 0xf, (ver >> 8) & 0xf,
  183. (ver >> 4) & 0xf, ver & 0xf);
  184. /*
  185. * Enable the important clocks right away..
  186. */
  187. for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
  188. struct clk *clk = r7780rp_clocks[i];
  189. clk_register(clk);
  190. clk_enable(clk);
  191. }
  192. ctrl_outw(0x0000, PA_OBLED); /* Clear LED. */
  193. if (mach_is_r7780rp())
  194. ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */
  195. ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */
  196. pm_power_off = r7780rp_power_off;
  197. }
  198. /*
  199. * The Machine Vector
  200. */
  201. static struct sh_machine_vector mv_highlander __initmv = {
  202. .mv_name = "Highlander",
  203. .mv_nr_irqs = 109,
  204. .mv_setup = highlander_setup,
  205. .mv_init_irq = highlander_init_irq,
  206. };