board-marzen.c 11 KB

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