setup.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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/io.h>
  23. static struct resource r8a66597_usb_host_resources[] = {
  24. [0] = {
  25. .name = "r8a66597_hcd",
  26. .start = 0xA4200000,
  27. .end = 0xA42000FF,
  28. .flags = IORESOURCE_MEM,
  29. },
  30. [1] = {
  31. .name = "r8a66597_hcd",
  32. .start = 11, /* irq number */
  33. .end = 11,
  34. .flags = IORESOURCE_IRQ,
  35. },
  36. };
  37. static struct platform_device r8a66597_usb_host_device = {
  38. .name = "r8a66597_hcd",
  39. .id = -1,
  40. .dev = {
  41. .dma_mask = NULL, /* don't use dma */
  42. .coherent_dma_mask = 0xffffffff,
  43. },
  44. .num_resources = ARRAY_SIZE(r8a66597_usb_host_resources),
  45. .resource = r8a66597_usb_host_resources,
  46. };
  47. static struct resource m66592_usb_peripheral_resources[] = {
  48. [0] = {
  49. .name = "m66592_udc",
  50. .start = 0xb0000000,
  51. .end = 0xb00000FF,
  52. .flags = IORESOURCE_MEM,
  53. },
  54. [1] = {
  55. .name = "m66592_udc",
  56. .start = 9, /* irq number */
  57. .end = 9,
  58. .flags = IORESOURCE_IRQ,
  59. },
  60. };
  61. static struct platform_device m66592_usb_peripheral_device = {
  62. .name = "m66592_udc",
  63. .id = -1,
  64. .dev = {
  65. .dma_mask = NULL, /* don't use dma */
  66. .coherent_dma_mask = 0xffffffff,
  67. },
  68. .num_resources = ARRAY_SIZE(m66592_usb_peripheral_resources),
  69. .resource = m66592_usb_peripheral_resources,
  70. };
  71. static struct resource cf_ide_resources[] = {
  72. [0] = {
  73. .start = PA_AREA5_IO + 0x1000,
  74. .end = PA_AREA5_IO + 0x1000 + 0x08 - 1,
  75. .flags = IORESOURCE_MEM,
  76. },
  77. [1] = {
  78. .start = PA_AREA5_IO + 0x80c,
  79. .end = PA_AREA5_IO + 0x80c + 0x16 - 1,
  80. .flags = IORESOURCE_MEM,
  81. },
  82. [2] = {
  83. #ifdef CONFIG_SH_R7780RP
  84. .start = 4,
  85. #else
  86. .start = 1,
  87. #endif
  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 unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
  104. static struct resource heartbeat_resources[] = {
  105. [0] = {
  106. .start = PA_OBLED,
  107. .end = PA_OBLED + ARRAY_SIZE(heartbeat_bit_pos) - 1,
  108. .flags = IORESOURCE_MEM,
  109. },
  110. };
  111. static struct platform_device heartbeat_device = {
  112. .name = "heartbeat",
  113. .id = -1,
  114. /* R7785RP has a slightly more sensible FPGA.. */
  115. #ifndef CONFIG_SH_R7785RP
  116. .dev = {
  117. .platform_data = heartbeat_bit_pos,
  118. },
  119. #endif
  120. .num_resources = ARRAY_SIZE(heartbeat_resources),
  121. .resource = heartbeat_resources,
  122. };
  123. static struct platform_device *r7780rp_devices[] __initdata = {
  124. &r8a66597_usb_host_device,
  125. &m66592_usb_peripheral_device,
  126. &cf_ide_device,
  127. &heartbeat_device,
  128. };
  129. static int __init r7780rp_devices_setup(void)
  130. {
  131. return platform_add_devices(r7780rp_devices,
  132. ARRAY_SIZE(r7780rp_devices));
  133. }
  134. device_initcall(r7780rp_devices_setup);
  135. /*
  136. * Platform specific clocks
  137. */
  138. static void ivdr_clk_enable(struct clk *clk)
  139. {
  140. ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << IVDR_CK_ON), PA_IVDRCTL);
  141. }
  142. static void ivdr_clk_disable(struct clk *clk)
  143. {
  144. ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL);
  145. }
  146. static struct clk_ops ivdr_clk_ops = {
  147. .enable = ivdr_clk_enable,
  148. .disable = ivdr_clk_disable,
  149. };
  150. static struct clk ivdr_clk = {
  151. .name = "ivdr_clk",
  152. .ops = &ivdr_clk_ops,
  153. };
  154. static struct clk *r7780rp_clocks[] = {
  155. &ivdr_clk,
  156. };
  157. static void r7780rp_power_off(void)
  158. {
  159. if (mach_is_r7780mp() || mach_is_r7785rp())
  160. ctrl_outw(0x0001, PA_POFF);
  161. }
  162. /*
  163. * Initialize the board
  164. */
  165. static void __init highlander_setup(char **cmdline_p)
  166. {
  167. u16 ver = ctrl_inw(PA_VERREG);
  168. int i;
  169. printk(KERN_INFO "Renesas Solutions Highlander %s support.\n",
  170. mach_is_r7780rp() ? "R7780RP-1" :
  171. mach_is_r7780mp() ? "R7780MP" :
  172. "R7785RP");
  173. printk(KERN_INFO "Board version: %d (revision %d), "
  174. "FPGA version: %d (revision %d)\n",
  175. (ver >> 12) & 0xf, (ver >> 8) & 0xf,
  176. (ver >> 4) & 0xf, ver & 0xf);
  177. /*
  178. * Enable the important clocks right away..
  179. */
  180. for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
  181. struct clk *clk = r7780rp_clocks[i];
  182. clk_register(clk);
  183. clk_enable(clk);
  184. }
  185. ctrl_outw(0x0000, PA_OBLED); /* Clear LED. */
  186. if (mach_is_r7780rp())
  187. ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */
  188. ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */
  189. pm_power_off = r7780rp_power_off;
  190. }
  191. /*
  192. * The Machine Vector
  193. */
  194. static struct sh_machine_vector mv_highlander __initmv = {
  195. .mv_name = "Highlander",
  196. .mv_nr_irqs = 109,
  197. .mv_setup = highlander_setup,
  198. .mv_init_irq = highlander_init_irq,
  199. };