board-marzen.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  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. .dma_slave_tx = HPBDMA_SLAVE_SDHI0_TX,
  118. .dma_slave_rx = HPBDMA_SLAVE_SDHI0_RX,
  119. .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
  120. .tmio_caps = MMC_CAP_SD_HIGHSPEED,
  121. };
  122. static struct platform_device sdhi0_device = {
  123. .name = "sh_mobile_sdhi",
  124. .num_resources = ARRAY_SIZE(sdhi0_resources),
  125. .resource = sdhi0_resources,
  126. .id = 0,
  127. .dev = {
  128. .platform_data = &sdhi0_platform_data,
  129. }
  130. };
  131. /* Thermal */
  132. static struct resource thermal_resources[] = {
  133. [0] = {
  134. .start = 0xFFC48000,
  135. .end = 0xFFC48038 - 1,
  136. .flags = IORESOURCE_MEM,
  137. },
  138. };
  139. static struct platform_device thermal_device = {
  140. .name = "rcar_thermal",
  141. .resource = thermal_resources,
  142. .num_resources = ARRAY_SIZE(thermal_resources),
  143. };
  144. /* HSPI */
  145. static struct resource hspi_resources[] = {
  146. [0] = {
  147. .start = 0xFFFC7000,
  148. .end = 0xFFFC7018 - 1,
  149. .flags = IORESOURCE_MEM,
  150. },
  151. };
  152. static struct platform_device hspi_device = {
  153. .name = "sh-hspi",
  154. .id = 0,
  155. .resource = hspi_resources,
  156. .num_resources = ARRAY_SIZE(hspi_resources),
  157. };
  158. /*
  159. * DU
  160. *
  161. * The panel only specifies the [hv]display and [hv]total values. The position
  162. * and width of the sync pulses don't matter, they're copied from VESA timings.
  163. */
  164. static struct rcar_du_encoder_data du_encoders[] = {
  165. {
  166. .type = RCAR_DU_ENCODER_VGA,
  167. .output = RCAR_DU_OUTPUT_DPAD0,
  168. }, {
  169. .type = RCAR_DU_ENCODER_LVDS,
  170. .output = RCAR_DU_OUTPUT_DPAD1,
  171. .connector.lvds.panel = {
  172. .width_mm = 210,
  173. .height_mm = 158,
  174. .mode = {
  175. .clock = 65000,
  176. .hdisplay = 1024,
  177. .hsync_start = 1048,
  178. .hsync_end = 1184,
  179. .htotal = 1344,
  180. .vdisplay = 768,
  181. .vsync_start = 771,
  182. .vsync_end = 777,
  183. .vtotal = 806,
  184. .flags = 0,
  185. },
  186. },
  187. },
  188. };
  189. static const struct rcar_du_platform_data du_pdata __initconst = {
  190. .encoders = du_encoders,
  191. .num_encoders = ARRAY_SIZE(du_encoders),
  192. };
  193. static const struct resource du_resources[] __initconst = {
  194. DEFINE_RES_MEM(0xfff80000, 0x40000),
  195. DEFINE_RES_IRQ(gic_iid(0x3f)),
  196. };
  197. static void __init marzen_add_du_device(void)
  198. {
  199. struct platform_device_info info = {
  200. .name = "rcar-du-r8a7779",
  201. .id = -1,
  202. .res = du_resources,
  203. .num_res = ARRAY_SIZE(du_resources),
  204. .data = &du_pdata,
  205. .size_data = sizeof(du_pdata),
  206. .dma_mask = DMA_BIT_MASK(32),
  207. };
  208. platform_device_register_full(&info);
  209. }
  210. /* LEDS */
  211. static struct gpio_led marzen_leds[] = {
  212. {
  213. .name = "led2",
  214. .gpio = RCAR_GP_PIN(4, 29),
  215. .default_state = LEDS_GPIO_DEFSTATE_ON,
  216. }, {
  217. .name = "led3",
  218. .gpio = RCAR_GP_PIN(4, 30),
  219. .default_state = LEDS_GPIO_DEFSTATE_ON,
  220. }, {
  221. .name = "led4",
  222. .gpio = RCAR_GP_PIN(4, 31),
  223. .default_state = LEDS_GPIO_DEFSTATE_ON,
  224. },
  225. };
  226. static struct gpio_led_platform_data marzen_leds_pdata = {
  227. .leds = marzen_leds,
  228. .num_leds = ARRAY_SIZE(marzen_leds),
  229. };
  230. static struct platform_device leds_device = {
  231. .name = "leds-gpio",
  232. .id = 0,
  233. .dev = {
  234. .platform_data = &marzen_leds_pdata,
  235. },
  236. };
  237. static struct rcar_vin_platform_data vin_platform_data __initdata = {
  238. .flags = RCAR_VIN_BT656,
  239. };
  240. #define MARZEN_CAMERA(idx) \
  241. static struct i2c_board_info camera##idx##_info = { \
  242. I2C_BOARD_INFO("adv7180", 0x20 + (idx)), \
  243. }; \
  244. \
  245. static struct soc_camera_link iclink##idx##_adv7180 = { \
  246. .bus_id = 1 + 2 * (idx), \
  247. .i2c_adapter_id = 0, \
  248. .board_info = &camera##idx##_info, \
  249. }; \
  250. \
  251. static struct platform_device camera##idx##_device = { \
  252. .name = "soc-camera-pdrv", \
  253. .id = idx, \
  254. .dev = { \
  255. .platform_data = &iclink##idx##_adv7180, \
  256. }, \
  257. };
  258. MARZEN_CAMERA(0);
  259. MARZEN_CAMERA(1);
  260. static struct platform_device *marzen_devices[] __initdata = {
  261. &eth_device,
  262. &sdhi0_device,
  263. &thermal_device,
  264. &hspi_device,
  265. &leds_device,
  266. &usb_phy,
  267. &camera0_device,
  268. &camera1_device,
  269. };
  270. static const struct pinctrl_map marzen_pinctrl_map[] = {
  271. /* DU (CN10: ARGB0, CN13: LVDS) */
  272. PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7779", "pfc-r8a7779",
  273. "du0_rgb888", "du0"),
  274. PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7779", "pfc-r8a7779",
  275. "du0_sync_1", "du0"),
  276. PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7779", "pfc-r8a7779",
  277. "du0_clk_out_0", "du0"),
  278. PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7779", "pfc-r8a7779",
  279. "du1_rgb666", "du1"),
  280. PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7779", "pfc-r8a7779",
  281. "du1_sync_1", "du1"),
  282. PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7779", "pfc-r8a7779",
  283. "du1_clk_out", "du1"),
  284. /* HSPI0 */
  285. PIN_MAP_MUX_GROUP_DEFAULT("sh-hspi.0", "pfc-r8a7779",
  286. "hspi0", "hspi0"),
  287. /* SCIF2 (CN18: DEBUG0) */
  288. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.2", "pfc-r8a7779",
  289. "scif2_data_c", "scif2"),
  290. /* SCIF4 (CN19: DEBUG1) */
  291. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "pfc-r8a7779",
  292. "scif4_data", "scif4"),
  293. /* SDHI0 */
  294. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
  295. "sdhi0_data4", "sdhi0"),
  296. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
  297. "sdhi0_ctrl", "sdhi0"),
  298. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
  299. "sdhi0_cd", "sdhi0"),
  300. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
  301. "sdhi0_wp", "sdhi0"),
  302. /* SMSC */
  303. PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-r8a7779",
  304. "intc_irq1_b", "intc"),
  305. PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-r8a7779",
  306. "lbsc_ex_cs0", "lbsc"),
  307. /* USB0 */
  308. PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.0", "pfc-r8a7779",
  309. "usb0", "usb0"),
  310. /* USB1 */
  311. PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.0", "pfc-r8a7779",
  312. "usb1", "usb1"),
  313. /* USB2 */
  314. PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.1", "pfc-r8a7779",
  315. "usb2", "usb2"),
  316. /* VIN1 */
  317. PIN_MAP_MUX_GROUP_DEFAULT("r8a7779-vin.1", "pfc-r8a7779",
  318. "vin1_clk", "vin1"),
  319. PIN_MAP_MUX_GROUP_DEFAULT("r8a7779-vin.1", "pfc-r8a7779",
  320. "vin1_data8", "vin1"),
  321. /* VIN3 */
  322. PIN_MAP_MUX_GROUP_DEFAULT("r8a7779-vin.3", "pfc-r8a7779",
  323. "vin3_clk", "vin3"),
  324. PIN_MAP_MUX_GROUP_DEFAULT("r8a7779-vin.3", "pfc-r8a7779",
  325. "vin3_data8", "vin3"),
  326. };
  327. static void __init marzen_init(void)
  328. {
  329. regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
  330. ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
  331. regulator_register_fixed(1, dummy_supplies,
  332. ARRAY_SIZE(dummy_supplies));
  333. pinctrl_register_mappings(marzen_pinctrl_map,
  334. ARRAY_SIZE(marzen_pinctrl_map));
  335. r8a7779_pinmux_init();
  336. r8a7779_init_irq_extpin(1); /* IRQ1 as individual interrupt */
  337. r8a7779_add_standard_devices();
  338. r8a7779_add_vin_device(1, &vin_platform_data);
  339. r8a7779_add_vin_device(3, &vin_platform_data);
  340. platform_add_devices(marzen_devices, ARRAY_SIZE(marzen_devices));
  341. marzen_add_du_device();
  342. }
  343. static const char *marzen_boards_compat_dt[] __initdata = {
  344. "renesas,marzen",
  345. NULL,
  346. };
  347. DT_MACHINE_START(MARZEN, "marzen")
  348. .smp = smp_ops(r8a7779_smp_ops),
  349. .map_io = r8a7779_map_io,
  350. .init_early = r8a7779_add_early_devices,
  351. .init_irq = r8a7779_init_irq_dt,
  352. .init_machine = marzen_init,
  353. .init_late = r8a7779_init_late,
  354. .dt_compat = marzen_boards_compat_dt,
  355. .init_time = r8a7779_earlytimer_init,
  356. MACHINE_END