board-marzen.c 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. /*
  2. * marzen board support
  3. *
  4. * Copyright (C) 2011, 2013 Renesas Solutions Corp.
  5. * Copyright (C) 2011 Magnus Damm
  6. * Copyright (C) 2013 Cogent Embedded, Inc.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; version 2 of the License.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include <linux/kernel.h>
  22. #include <linux/init.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/irq.h>
  25. #include <linux/platform_device.h>
  26. #include <linux/delay.h>
  27. #include <linux/io.h>
  28. #include <linux/leds.h>
  29. #include <linux/dma-mapping.h>
  30. #include <linux/pinctrl/machine.h>
  31. #include <linux/platform_data/gpio-rcar.h>
  32. #include <linux/platform_data/usb-rcar-phy.h>
  33. #include <linux/regulator/fixed.h>
  34. #include <linux/regulator/machine.h>
  35. #include <linux/smsc911x.h>
  36. #include <linux/spi/spi.h>
  37. #include <linux/spi/sh_hspi.h>
  38. #include <linux/mmc/host.h>
  39. #include <linux/mmc/sh_mobile_sdhi.h>
  40. #include <linux/mfd/tmio.h>
  41. #include <media/soc_camera.h>
  42. #include <mach/r8a7779.h>
  43. #include <mach/common.h>
  44. #include <mach/irqs.h>
  45. #include <asm/mach-types.h>
  46. #include <asm/mach/arch.h>
  47. #include <asm/traps.h>
  48. /* Fixed 3.3V regulator to be used by SDHI0 */
  49. static struct regulator_consumer_supply fixed3v3_power_consumers[] = {
  50. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
  51. REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
  52. };
  53. /* Dummy supplies, where voltage doesn't matter */
  54. static struct regulator_consumer_supply dummy_supplies[] = {
  55. REGULATOR_SUPPLY("vddvario", "smsc911x"),
  56. REGULATOR_SUPPLY("vdd33a", "smsc911x"),
  57. };
  58. /* USB PHY */
  59. static struct resource usb_phy_resources[] = {
  60. [0] = {
  61. .start = 0xffe70800,
  62. .end = 0xffe70900 - 1,
  63. .flags = IORESOURCE_MEM,
  64. },
  65. };
  66. static struct rcar_phy_platform_data usb_phy_platform_data;
  67. static struct platform_device usb_phy = {
  68. .name = "rcar_usb_phy",
  69. .id = -1,
  70. .dev = {
  71. .platform_data = &usb_phy_platform_data,
  72. },
  73. .resource = usb_phy_resources,
  74. .num_resources = ARRAY_SIZE(usb_phy_resources),
  75. };
  76. /* SMSC LAN89218 */
  77. static struct resource smsc911x_resources[] = {
  78. [0] = {
  79. .start = 0x18000000, /* ExCS0 */
  80. .end = 0x180000ff, /* A1->A7 */
  81. .flags = IORESOURCE_MEM,
  82. },
  83. [1] = {
  84. .start = irq_pin(1), /* IRQ 1 */
  85. .flags = IORESOURCE_IRQ,
  86. },
  87. };
  88. static struct smsc911x_platform_config smsc911x_platdata = {
  89. .flags = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */
  90. .phy_interface = PHY_INTERFACE_MODE_MII,
  91. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  92. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  93. };
  94. static struct platform_device eth_device = {
  95. .name = "smsc911x",
  96. .id = -1,
  97. .dev = {
  98. .platform_data = &smsc911x_platdata,
  99. },
  100. .resource = smsc911x_resources,
  101. .num_resources = ARRAY_SIZE(smsc911x_resources),
  102. };
  103. static struct resource sdhi0_resources[] = {
  104. [0] = {
  105. .name = "sdhi0",
  106. .start = 0xffe4c000,
  107. .end = 0xffe4c0ff,
  108. .flags = IORESOURCE_MEM,
  109. },
  110. [1] = {
  111. .start = gic_iid(0x88),
  112. .flags = IORESOURCE_IRQ,
  113. },
  114. };
  115. static struct sh_mobile_sdhi_info sdhi0_platform_data = {
  116. .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
  117. .tmio_caps = MMC_CAP_SD_HIGHSPEED,
  118. };
  119. static struct platform_device sdhi0_device = {
  120. .name = "sh_mobile_sdhi",
  121. .num_resources = ARRAY_SIZE(sdhi0_resources),
  122. .resource = sdhi0_resources,
  123. .id = 0,
  124. .dev = {
  125. .platform_data = &sdhi0_platform_data,
  126. }
  127. };
  128. /* Thermal */
  129. static struct resource thermal_resources[] = {
  130. [0] = {
  131. .start = 0xFFC48000,
  132. .end = 0xFFC48038 - 1,
  133. .flags = IORESOURCE_MEM,
  134. },
  135. };
  136. static struct platform_device thermal_device = {
  137. .name = "rcar_thermal",
  138. .resource = thermal_resources,
  139. .num_resources = ARRAY_SIZE(thermal_resources),
  140. };
  141. /* HSPI */
  142. static struct resource hspi_resources[] = {
  143. [0] = {
  144. .start = 0xFFFC7000,
  145. .end = 0xFFFC7018 - 1,
  146. .flags = IORESOURCE_MEM,
  147. },
  148. };
  149. static struct platform_device hspi_device = {
  150. .name = "sh-hspi",
  151. .id = 0,
  152. .resource = hspi_resources,
  153. .num_resources = ARRAY_SIZE(hspi_resources),
  154. };
  155. /* LEDS */
  156. static struct gpio_led marzen_leds[] = {
  157. {
  158. .name = "led2",
  159. .gpio = RCAR_GP_PIN(4, 29),
  160. .default_state = LEDS_GPIO_DEFSTATE_ON,
  161. }, {
  162. .name = "led3",
  163. .gpio = RCAR_GP_PIN(4, 30),
  164. .default_state = LEDS_GPIO_DEFSTATE_ON,
  165. }, {
  166. .name = "led4",
  167. .gpio = RCAR_GP_PIN(4, 31),
  168. .default_state = LEDS_GPIO_DEFSTATE_ON,
  169. },
  170. };
  171. static struct gpio_led_platform_data marzen_leds_pdata = {
  172. .leds = marzen_leds,
  173. .num_leds = ARRAY_SIZE(marzen_leds),
  174. };
  175. static struct platform_device leds_device = {
  176. .name = "leds-gpio",
  177. .id = 0,
  178. .dev = {
  179. .platform_data = &marzen_leds_pdata,
  180. },
  181. };
  182. static struct rcar_vin_platform_data vin_platform_data __initdata = {
  183. .flags = RCAR_VIN_BT656,
  184. };
  185. #define MARZEN_CAMERA(idx) \
  186. static struct i2c_board_info camera##idx##_info = { \
  187. I2C_BOARD_INFO("adv7180", 0x20 + (idx)), \
  188. }; \
  189. \
  190. static struct soc_camera_link iclink##idx##_adv7180 = { \
  191. .bus_id = 1 + 2 * (idx), \
  192. .i2c_adapter_id = 0, \
  193. .board_info = &camera##idx##_info, \
  194. }; \
  195. \
  196. static struct platform_device camera##idx##_device = { \
  197. .name = "soc-camera-pdrv", \
  198. .id = idx, \
  199. .dev = { \
  200. .platform_data = &iclink##idx##_adv7180, \
  201. }, \
  202. };
  203. MARZEN_CAMERA(0);
  204. MARZEN_CAMERA(1);
  205. static struct platform_device *marzen_devices[] __initdata = {
  206. &eth_device,
  207. &sdhi0_device,
  208. &thermal_device,
  209. &hspi_device,
  210. &leds_device,
  211. &usb_phy,
  212. &camera0_device,
  213. &camera1_device,
  214. };
  215. static const struct pinctrl_map marzen_pinctrl_map[] = {
  216. /* HSPI0 */
  217. PIN_MAP_MUX_GROUP_DEFAULT("sh-hspi.0", "pfc-r8a7779",
  218. "hspi0", "hspi0"),
  219. /* SCIF2 (CN18: DEBUG0) */
  220. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.2", "pfc-r8a7779",
  221. "scif2_data_c", "scif2"),
  222. /* SCIF4 (CN19: DEBUG1) */
  223. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "pfc-r8a7779",
  224. "scif4_data", "scif4"),
  225. /* SDHI0 */
  226. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
  227. "sdhi0_data4", "sdhi0"),
  228. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
  229. "sdhi0_ctrl", "sdhi0"),
  230. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
  231. "sdhi0_cd", "sdhi0"),
  232. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
  233. "sdhi0_wp", "sdhi0"),
  234. /* SMSC */
  235. PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-r8a7779",
  236. "intc_irq1_b", "intc"),
  237. PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-r8a7779",
  238. "lbsc_ex_cs0", "lbsc"),
  239. /* USB0 */
  240. PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.0", "pfc-r8a7779",
  241. "usb0", "usb0"),
  242. /* USB1 */
  243. PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.0", "pfc-r8a7779",
  244. "usb1", "usb1"),
  245. /* USB2 */
  246. PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.1", "pfc-r8a7779",
  247. "usb2", "usb2"),
  248. /* VIN1 */
  249. PIN_MAP_MUX_GROUP_DEFAULT("r8a7779-vin.1", "pfc-r8a7779",
  250. "vin1_clk", "vin1"),
  251. PIN_MAP_MUX_GROUP_DEFAULT("r8a7779-vin.1", "pfc-r8a7779",
  252. "vin1_data8", "vin1"),
  253. /* VIN3 */
  254. PIN_MAP_MUX_GROUP_DEFAULT("r8a7779-vin.3", "pfc-r8a7779",
  255. "vin3_clk", "vin3"),
  256. PIN_MAP_MUX_GROUP_DEFAULT("r8a7779-vin.3", "pfc-r8a7779",
  257. "vin3_data8", "vin3"),
  258. };
  259. static void __init marzen_init(void)
  260. {
  261. regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
  262. ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
  263. regulator_register_fixed(1, dummy_supplies,
  264. ARRAY_SIZE(dummy_supplies));
  265. pinctrl_register_mappings(marzen_pinctrl_map,
  266. ARRAY_SIZE(marzen_pinctrl_map));
  267. r8a7779_pinmux_init();
  268. r8a7779_init_irq_extpin(1); /* IRQ1 as individual interrupt */
  269. r8a7779_add_standard_devices();
  270. r8a7779_add_vin_device(1, &vin_platform_data);
  271. r8a7779_add_vin_device(3, &vin_platform_data);
  272. platform_add_devices(marzen_devices, ARRAY_SIZE(marzen_devices));
  273. }
  274. static const char *marzen_boards_compat_dt[] __initdata = {
  275. "renesas,marzen",
  276. NULL,
  277. };
  278. DT_MACHINE_START(MARZEN, "marzen")
  279. .smp = smp_ops(r8a7779_smp_ops),
  280. .map_io = r8a7779_map_io,
  281. .init_early = r8a7779_add_early_devices,
  282. .init_irq = r8a7779_init_irq_dt,
  283. .init_machine = marzen_init,
  284. .init_late = r8a7779_init_late,
  285. .dt_compat = marzen_boards_compat_dt,
  286. .init_time = r8a7779_earlytimer_init,
  287. MACHINE_END