setup.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. /*
  2. * arch/sh/boards/mach-x3proto/setup.c
  3. *
  4. * Renesas SH-X3 Prototype Board Support.
  5. *
  6. * Copyright (C) 2007 - 2010 Paul Mundt
  7. *
  8. * This file is subject to the terms and conditions of the GNU General Public
  9. * License. See the file "COPYING" in the main directory of this archive
  10. * for more details.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/kernel.h>
  15. #include <linux/io.h>
  16. #include <linux/smc91x.h>
  17. #include <linux/irq.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/input.h>
  20. #include <linux/usb/r8a66597.h>
  21. #include <linux/usb/m66592.h>
  22. #include <linux/gpio.h>
  23. #include <linux/gpio_keys.h>
  24. #include <mach/ilsel.h>
  25. #include <mach/hardware.h>
  26. #include <asm/smp-ops.h>
  27. static struct resource heartbeat_resources[] = {
  28. [0] = {
  29. .start = 0xb8140020,
  30. .end = 0xb8140020,
  31. .flags = IORESOURCE_MEM,
  32. },
  33. };
  34. static struct platform_device heartbeat_device = {
  35. .name = "heartbeat",
  36. .id = -1,
  37. .num_resources = ARRAY_SIZE(heartbeat_resources),
  38. .resource = heartbeat_resources,
  39. };
  40. static struct smc91x_platdata smc91x_info = {
  41. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  42. };
  43. static struct resource smc91x_resources[] = {
  44. [0] = {
  45. .start = 0x18000300,
  46. .end = 0x18000300 + 0x10 - 1,
  47. .flags = IORESOURCE_MEM,
  48. },
  49. [1] = {
  50. /* Filled in by ilsel */
  51. .flags = IORESOURCE_IRQ,
  52. },
  53. };
  54. static struct platform_device smc91x_device = {
  55. .name = "smc91x",
  56. .id = -1,
  57. .resource = smc91x_resources,
  58. .num_resources = ARRAY_SIZE(smc91x_resources),
  59. .dev = {
  60. .platform_data = &smc91x_info,
  61. },
  62. };
  63. static struct r8a66597_platdata r8a66597_data = {
  64. .xtal = R8A66597_PLATDATA_XTAL_12MHZ,
  65. .vif = 1,
  66. };
  67. static struct resource r8a66597_usb_host_resources[] = {
  68. [0] = {
  69. .start = 0x18040000,
  70. .end = 0x18080000 - 1,
  71. .flags = IORESOURCE_MEM,
  72. },
  73. [1] = {
  74. /* Filled in by ilsel */
  75. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
  76. },
  77. };
  78. static struct platform_device r8a66597_usb_host_device = {
  79. .name = "r8a66597_hcd",
  80. .id = -1,
  81. .dev = {
  82. .dma_mask = NULL, /* don't use dma */
  83. .coherent_dma_mask = 0xffffffff,
  84. .platform_data = &r8a66597_data,
  85. },
  86. .num_resources = ARRAY_SIZE(r8a66597_usb_host_resources),
  87. .resource = r8a66597_usb_host_resources,
  88. };
  89. static struct m66592_platdata usbf_platdata = {
  90. .xtal = M66592_PLATDATA_XTAL_24MHZ,
  91. .vif = 1,
  92. };
  93. static struct resource m66592_usb_peripheral_resources[] = {
  94. [0] = {
  95. .name = "m66592_udc",
  96. .start = 0x18080000,
  97. .end = 0x180c0000 - 1,
  98. .flags = IORESOURCE_MEM,
  99. },
  100. [1] = {
  101. .name = "m66592_udc",
  102. /* Filled in by ilsel */
  103. .flags = IORESOURCE_IRQ,
  104. },
  105. };
  106. static struct platform_device m66592_usb_peripheral_device = {
  107. .name = "m66592_udc",
  108. .id = -1,
  109. .dev = {
  110. .dma_mask = NULL, /* don't use dma */
  111. .coherent_dma_mask = 0xffffffff,
  112. .platform_data = &usbf_platdata,
  113. },
  114. .num_resources = ARRAY_SIZE(m66592_usb_peripheral_resources),
  115. .resource = m66592_usb_peripheral_resources,
  116. };
  117. static struct gpio_keys_button baseboard_buttons[NR_BASEBOARD_GPIOS] = {
  118. {
  119. .desc = "key44",
  120. .code = KEY_POWER,
  121. .active_low = 1,
  122. .wakeup = 1,
  123. }, {
  124. .desc = "key43",
  125. .code = KEY_SUSPEND,
  126. .active_low = 1,
  127. .wakeup = 1,
  128. }, {
  129. .desc = "key42",
  130. .code = KEY_KATAKANAHIRAGANA,
  131. .active_low = 1,
  132. }, {
  133. .desc = "key41",
  134. .code = KEY_SWITCHVIDEOMODE,
  135. .active_low = 1,
  136. }, {
  137. .desc = "key34",
  138. .code = KEY_F12,
  139. .active_low = 1,
  140. }, {
  141. .desc = "key33",
  142. .code = KEY_F11,
  143. .active_low = 1,
  144. }, {
  145. .desc = "key32",
  146. .code = KEY_F10,
  147. .active_low = 1,
  148. }, {
  149. .desc = "key31",
  150. .code = KEY_F9,
  151. .active_low = 1,
  152. }, {
  153. .desc = "key24",
  154. .code = KEY_F8,
  155. .active_low = 1,
  156. }, {
  157. .desc = "key23",
  158. .code = KEY_F7,
  159. .active_low = 1,
  160. }, {
  161. .desc = "key22",
  162. .code = KEY_F6,
  163. .active_low = 1,
  164. }, {
  165. .desc = "key21",
  166. .code = KEY_F5,
  167. .active_low = 1,
  168. }, {
  169. .desc = "key14",
  170. .code = KEY_F4,
  171. .active_low = 1,
  172. }, {
  173. .desc = "key13",
  174. .code = KEY_F3,
  175. .active_low = 1,
  176. }, {
  177. .desc = "key12",
  178. .code = KEY_F2,
  179. .active_low = 1,
  180. }, {
  181. .desc = "key11",
  182. .code = KEY_F1,
  183. .active_low = 1,
  184. },
  185. };
  186. static struct gpio_keys_platform_data baseboard_buttons_data = {
  187. .buttons = baseboard_buttons,
  188. .nbuttons = ARRAY_SIZE(baseboard_buttons),
  189. };
  190. static struct platform_device baseboard_buttons_device = {
  191. .name = "gpio-keys",
  192. .id = -1,
  193. .dev = {
  194. .platform_data = &baseboard_buttons_data,
  195. },
  196. };
  197. static struct platform_device *x3proto_devices[] __initdata = {
  198. &heartbeat_device,
  199. &smc91x_device,
  200. &r8a66597_usb_host_device,
  201. &m66592_usb_peripheral_device,
  202. &baseboard_buttons_device,
  203. };
  204. static void __init x3proto_init_irq(void)
  205. {
  206. plat_irq_setup_pins(IRQ_MODE_IRL3210);
  207. /* Set ICR0.LVLMODE */
  208. __raw_writel(__raw_readl(0xfe410000) | (1 << 21), 0xfe410000);
  209. }
  210. static int __init x3proto_devices_setup(void)
  211. {
  212. int ret, i;
  213. /*
  214. * IRLs are only needed for ILSEL mappings, so flip over the INTC
  215. * pins at a later point to enable the GPIOs to settle.
  216. */
  217. x3proto_init_irq();
  218. /*
  219. * Now that ILSELs are available, set up the baseboard GPIOs.
  220. */
  221. ret = x3proto_gpio_setup();
  222. if (unlikely(ret))
  223. return ret;
  224. /*
  225. * Propagate dynamic GPIOs for the baseboard button device.
  226. */
  227. for (i = 0; i < ARRAY_SIZE(baseboard_buttons); i++)
  228. baseboard_buttons[i].gpio = x3proto_gpio_chip.base + i;
  229. r8a66597_usb_host_resources[1].start =
  230. r8a66597_usb_host_resources[1].end = ilsel_enable(ILSEL_USBH_I);
  231. m66592_usb_peripheral_resources[1].start =
  232. m66592_usb_peripheral_resources[1].end = ilsel_enable(ILSEL_USBP_I);
  233. smc91x_resources[1].start =
  234. smc91x_resources[1].end = ilsel_enable(ILSEL_LAN);
  235. return platform_add_devices(x3proto_devices,
  236. ARRAY_SIZE(x3proto_devices));
  237. }
  238. device_initcall(x3proto_devices_setup);
  239. static void __init x3proto_setup(char **cmdline_p)
  240. {
  241. register_smp_ops(&shx3_smp_ops);
  242. }
  243. static struct sh_machine_vector mv_x3proto __initmv = {
  244. .mv_name = "x3proto",
  245. .mv_setup = x3proto_setup,
  246. };