board-marzen.c 10 KB

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