setup.c 5.7 KB

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