board-marzen.c 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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. #include <linux/kernel.h>
  18. #include <linux/init.h>
  19. #include <linux/interrupt.h>
  20. #include <linux/irq.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/delay.h>
  23. #include <linux/io.h>
  24. #include <linux/leds.h>
  25. #include <linux/dma-mapping.h>
  26. #include <linux/pinctrl/machine.h>
  27. #include <linux/platform_data/camera-rcar.h>
  28. #include <linux/platform_data/gpio-rcar.h>
  29. #include <linux/platform_data/usb-rcar-phy.h>
  30. #include <linux/regulator/fixed.h>
  31. #include <linux/regulator/machine.h>
  32. #include <linux/smsc911x.h>
  33. #include <linux/spi/spi.h>
  34. #include <linux/spi/sh_hspi.h>
  35. #include <linux/mmc/host.h>
  36. #include <linux/mmc/sh_mobile_sdhi.h>
  37. #include <linux/mfd/tmio.h>
  38. #include <media/soc_camera.h>
  39. #include <asm/mach-types.h>
  40. #include <asm/mach/arch.h>
  41. #include <asm/traps.h>
  42. #include "common.h"
  43. #include "irqs.h"
  44. #include "r8a7779.h"
  45. /* Fixed 3.3V regulator to be used by SDHI0 */
  46. static struct regulator_consumer_supply fixed3v3_power_consumers[] = {
  47. REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
  48. REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
  49. };
  50. /* Dummy supplies, where voltage doesn't matter */
  51. static struct regulator_consumer_supply dummy_supplies[] = {
  52. REGULATOR_SUPPLY("vddvario", "smsc911x"),
  53. REGULATOR_SUPPLY("vdd33a", "smsc911x"),
  54. };
  55. /* USB PHY */
  56. static struct resource usb_phy_resources[] = {
  57. [0] = {
  58. .start = 0xffe70800,
  59. .end = 0xffe70900 - 1,
  60. .flags = IORESOURCE_MEM,
  61. },
  62. };
  63. static struct rcar_phy_platform_data usb_phy_platform_data;
  64. static struct platform_device usb_phy = {
  65. .name = "rcar_usb_phy",
  66. .id = -1,
  67. .dev = {
  68. .platform_data = &usb_phy_platform_data,
  69. },
  70. .resource = usb_phy_resources,
  71. .num_resources = ARRAY_SIZE(usb_phy_resources),
  72. };
  73. /* SMSC LAN89218 */
  74. static struct resource smsc911x_resources[] = {
  75. [0] = {
  76. .start = 0x18000000, /* ExCS0 */
  77. .end = 0x180000ff, /* A1->A7 */
  78. .flags = IORESOURCE_MEM,
  79. },
  80. [1] = {
  81. .start = irq_pin(1), /* IRQ 1 */
  82. .flags = IORESOURCE_IRQ,
  83. },
  84. };
  85. static struct smsc911x_platform_config smsc911x_platdata = {
  86. .flags = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */
  87. .phy_interface = PHY_INTERFACE_MODE_MII,
  88. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  89. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  90. };
  91. static struct platform_device eth_device = {
  92. .name = "smsc911x",
  93. .id = -1,
  94. .dev = {
  95. .platform_data = &smsc911x_platdata,
  96. },
  97. .resource = smsc911x_resources,
  98. .num_resources = ARRAY_SIZE(smsc911x_resources),
  99. };
  100. static struct resource sdhi0_resources[] = {
  101. [0] = {
  102. .name = "sdhi0",
  103. .start = 0xffe4c000,
  104. .end = 0xffe4c0ff,
  105. .flags = IORESOURCE_MEM,
  106. },
  107. [1] = {
  108. .start = gic_iid(0x88),
  109. .flags = IORESOURCE_IRQ,
  110. },
  111. };
  112. static struct tmio_mmc_data sdhi0_platform_data = {
  113. .chan_priv_tx = (void *)HPBDMA_SLAVE_SDHI0_TX,
  114. .chan_priv_rx = (void *)HPBDMA_SLAVE_SDHI0_RX,
  115. .flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
  116. .capabilities = MMC_CAP_SD_HIGHSPEED,
  117. };
  118. static struct platform_device sdhi0_device = {
  119. .name = "sh_mobile_sdhi",
  120. .num_resources = ARRAY_SIZE(sdhi0_resources),
  121. .resource = sdhi0_resources,
  122. .id = 0,
  123. .dev = {
  124. .platform_data = &sdhi0_platform_data,
  125. }
  126. };
  127. /* Thermal */
  128. static struct resource thermal_resources[] = {
  129. [0] = {
  130. .start = 0xFFC48000,
  131. .end = 0xFFC48038 - 1,
  132. .flags = IORESOURCE_MEM,
  133. },
  134. };
  135. static struct platform_device thermal_device = {
  136. .name = "rcar_thermal",
  137. .resource = thermal_resources,
  138. .num_resources = ARRAY_SIZE(thermal_resources),
  139. };
  140. /* HSPI */
  141. static struct resource hspi_resources[] = {
  142. [0] = {
  143. .start = 0xFFFC7000,
  144. .end = 0xFFFC7018 - 1,
  145. .flags = IORESOURCE_MEM,
  146. },
  147. };
  148. static struct platform_device hspi_device = {
  149. .name = "sh-hspi",
  150. .id = 0,
  151. .resource = hspi_resources,
  152. .num_resources = ARRAY_SIZE(hspi_resources),
  153. };
  154. /* LEDS */
  155. static struct gpio_led marzen_leds[] = {
  156. {
  157. .name = "led2",
  158. .gpio = RCAR_GP_PIN(4, 29),
  159. .default_state = LEDS_GPIO_DEFSTATE_ON,
  160. }, {
  161. .name = "led3",
  162. .gpio = RCAR_GP_PIN(4, 30),
  163. .default_state = LEDS_GPIO_DEFSTATE_ON,
  164. }, {
  165. .name = "led4",
  166. .gpio = RCAR_GP_PIN(4, 31),
  167. .default_state = LEDS_GPIO_DEFSTATE_ON,
  168. },
  169. };
  170. static struct gpio_led_platform_data marzen_leds_pdata = {
  171. .leds = marzen_leds,
  172. .num_leds = ARRAY_SIZE(marzen_leds),
  173. };
  174. static struct platform_device leds_device = {
  175. .name = "leds-gpio",
  176. .id = 0,
  177. .dev = {
  178. .platform_data = &marzen_leds_pdata,
  179. },
  180. };
  181. /* VIN */
  182. static struct rcar_vin_platform_data vin_platform_data __initdata = {
  183. .flags = RCAR_VIN_BT656,
  184. };
  185. #define MARZEN_VIN(idx) \
  186. static struct resource vin##idx##_resources[] __initdata = { \
  187. DEFINE_RES_MEM(0xffc50000 + 0x1000 * (idx), 0x1000), \
  188. DEFINE_RES_IRQ(gic_iid(0x5f + (idx))), \
  189. }; \
  190. \
  191. static struct platform_device_info vin##idx##_info __initdata = { \
  192. .name = "r8a7779-vin", \
  193. .id = idx, \
  194. .res = vin##idx##_resources, \
  195. .num_res = ARRAY_SIZE(vin##idx##_resources), \
  196. .dma_mask = DMA_BIT_MASK(32), \
  197. .data = &vin_platform_data, \
  198. .size_data = sizeof(vin_platform_data), \
  199. }
  200. MARZEN_VIN(1);
  201. MARZEN_VIN(3);
  202. #define MARZEN_CAMERA(idx) \
  203. static struct i2c_board_info camera##idx##_info = { \
  204. I2C_BOARD_INFO("adv7180", 0x20 + (idx)), \
  205. }; \
  206. \
  207. static struct soc_camera_link iclink##idx##_adv7180 = { \
  208. .bus_id = 1 + 2 * (idx), \
  209. .i2c_adapter_id = 0, \
  210. .board_info = &camera##idx##_info, \
  211. }; \
  212. \
  213. static struct platform_device camera##idx##_device = { \
  214. .name = "soc-camera-pdrv", \
  215. .id = idx, \
  216. .dev = { \
  217. .platform_data = &iclink##idx##_adv7180, \
  218. }, \
  219. };
  220. MARZEN_CAMERA(0);
  221. MARZEN_CAMERA(1);
  222. static struct platform_device *marzen_devices[] __initdata = {
  223. &eth_device,
  224. &sdhi0_device,
  225. &thermal_device,
  226. &hspi_device,
  227. &leds_device,
  228. &usb_phy,
  229. &camera0_device,
  230. &camera1_device,
  231. };
  232. static const struct pinctrl_map marzen_pinctrl_map[] = {
  233. /* DU (CN10: ARGB0, CN13: LVDS) */
  234. PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7779", "pfc-r8a7779",
  235. "du0_rgb888", "du0"),
  236. PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7779", "pfc-r8a7779",
  237. "du0_sync_1", "du0"),
  238. PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7779", "pfc-r8a7779",
  239. "du0_clk_out_0", "du0"),
  240. PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7779", "pfc-r8a7779",
  241. "du1_rgb666", "du1"),
  242. PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7779", "pfc-r8a7779",
  243. "du1_sync_1", "du1"),
  244. PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7779", "pfc-r8a7779",
  245. "du1_clk_out", "du1"),
  246. /* HSPI0 */
  247. PIN_MAP_MUX_GROUP_DEFAULT("sh-hspi.0", "pfc-r8a7779",
  248. "hspi0", "hspi0"),
  249. /* SCIF2 (CN18: DEBUG0) */
  250. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.2", "pfc-r8a7779",
  251. "scif2_data_c", "scif2"),
  252. /* SCIF4 (CN19: DEBUG1) */
  253. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "pfc-r8a7779",
  254. "scif4_data", "scif4"),
  255. /* SDHI0 */
  256. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
  257. "sdhi0_data4", "sdhi0"),
  258. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
  259. "sdhi0_ctrl", "sdhi0"),
  260. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
  261. "sdhi0_cd", "sdhi0"),
  262. /* SMSC */
  263. PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-r8a7779",
  264. "intc_irq1_b", "intc"),
  265. PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-r8a7779",
  266. "lbsc_ex_cs0", "lbsc"),
  267. /* USB0 */
  268. PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.0", "pfc-r8a7779",
  269. "usb0", "usb0"),
  270. /* USB1 */
  271. PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.0", "pfc-r8a7779",
  272. "usb1", "usb1"),
  273. /* USB2 */
  274. PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.1", "pfc-r8a7779",
  275. "usb2", "usb2"),
  276. /* VIN1 */
  277. PIN_MAP_MUX_GROUP_DEFAULT("r8a7779-vin.1", "pfc-r8a7779",
  278. "vin1_clk", "vin1"),
  279. PIN_MAP_MUX_GROUP_DEFAULT("r8a7779-vin.1", "pfc-r8a7779",
  280. "vin1_data8", "vin1"),
  281. /* VIN3 */
  282. PIN_MAP_MUX_GROUP_DEFAULT("r8a7779-vin.3", "pfc-r8a7779",
  283. "vin3_clk", "vin3"),
  284. PIN_MAP_MUX_GROUP_DEFAULT("r8a7779-vin.3", "pfc-r8a7779",
  285. "vin3_data8", "vin3"),
  286. };
  287. static void __init marzen_init(void)
  288. {
  289. regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
  290. ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
  291. regulator_register_fixed(1, dummy_supplies,
  292. ARRAY_SIZE(dummy_supplies));
  293. pinctrl_register_mappings(marzen_pinctrl_map,
  294. ARRAY_SIZE(marzen_pinctrl_map));
  295. r8a7779_pinmux_init();
  296. r8a7779_init_irq_extpin(1); /* IRQ1 as individual interrupt */
  297. r8a7779_add_standard_devices();
  298. platform_device_register_full(&vin1_info);
  299. platform_device_register_full(&vin3_info);
  300. platform_add_devices(marzen_devices, ARRAY_SIZE(marzen_devices));
  301. }
  302. static const char *marzen_boards_compat_dt[] __initdata = {
  303. "renesas,marzen",
  304. NULL,
  305. };
  306. DT_MACHINE_START(MARZEN, "marzen")
  307. .smp = smp_ops(r8a7779_smp_ops),
  308. .map_io = r8a7779_map_io,
  309. .init_early = r8a7779_add_early_devices,
  310. .init_irq = r8a7779_init_irq_dt,
  311. .init_machine = marzen_init,
  312. .init_late = r8a7779_init_late,
  313. .dt_compat = marzen_boards_compat_dt,
  314. .init_time = r8a7779_earlytimer_init,
  315. MACHINE_END