board-marzen.c 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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/regulator/fixed.h>
  33. #include <linux/regulator/machine.h>
  34. #include <linux/smsc911x.h>
  35. #include <linux/spi/spi.h>
  36. #include <linux/spi/sh_hspi.h>
  37. #include <linux/mmc/host.h>
  38. #include <linux/mmc/sh_mobile_sdhi.h>
  39. #include <linux/mfd/tmio.h>
  40. #include <media/soc_camera.h>
  41. #include <mach/hardware.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. static struct rcar_phy_platform_data usb_phy_platform_data __initdata;
  59. /* SMSC LAN89218 */
  60. static struct resource smsc911x_resources[] = {
  61. [0] = {
  62. .start = 0x18000000, /* ExCS0 */
  63. .end = 0x180000ff, /* A1->A7 */
  64. .flags = IORESOURCE_MEM,
  65. },
  66. [1] = {
  67. .start = irq_pin(1), /* IRQ 1 */
  68. .flags = IORESOURCE_IRQ,
  69. },
  70. };
  71. static struct smsc911x_platform_config smsc911x_platdata = {
  72. .flags = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */
  73. .phy_interface = PHY_INTERFACE_MODE_MII,
  74. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  75. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  76. };
  77. static struct platform_device eth_device = {
  78. .name = "smsc911x",
  79. .id = -1,
  80. .dev = {
  81. .platform_data = &smsc911x_platdata,
  82. },
  83. .resource = smsc911x_resources,
  84. .num_resources = ARRAY_SIZE(smsc911x_resources),
  85. };
  86. static struct resource sdhi0_resources[] = {
  87. [0] = {
  88. .name = "sdhi0",
  89. .start = 0xffe4c000,
  90. .end = 0xffe4c0ff,
  91. .flags = IORESOURCE_MEM,
  92. },
  93. [1] = {
  94. .start = gic_iid(0x88),
  95. .flags = IORESOURCE_IRQ,
  96. },
  97. };
  98. static struct sh_mobile_sdhi_info sdhi0_platform_data = {
  99. .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
  100. .tmio_caps = MMC_CAP_SD_HIGHSPEED,
  101. };
  102. static struct platform_device sdhi0_device = {
  103. .name = "sh_mobile_sdhi",
  104. .num_resources = ARRAY_SIZE(sdhi0_resources),
  105. .resource = sdhi0_resources,
  106. .id = 0,
  107. .dev = {
  108. .platform_data = &sdhi0_platform_data,
  109. }
  110. };
  111. /* Thermal */
  112. static struct resource thermal_resources[] = {
  113. [0] = {
  114. .start = 0xFFC48000,
  115. .end = 0xFFC48038 - 1,
  116. .flags = IORESOURCE_MEM,
  117. },
  118. };
  119. static struct platform_device thermal_device = {
  120. .name = "rcar_thermal",
  121. .resource = thermal_resources,
  122. .num_resources = ARRAY_SIZE(thermal_resources),
  123. };
  124. /* HSPI */
  125. static struct resource hspi_resources[] = {
  126. [0] = {
  127. .start = 0xFFFC7000,
  128. .end = 0xFFFC7018 - 1,
  129. .flags = IORESOURCE_MEM,
  130. },
  131. };
  132. static struct platform_device hspi_device = {
  133. .name = "sh-hspi",
  134. .id = 0,
  135. .resource = hspi_resources,
  136. .num_resources = ARRAY_SIZE(hspi_resources),
  137. };
  138. /* LEDS */
  139. static struct gpio_led marzen_leds[] = {
  140. {
  141. .name = "led2",
  142. .gpio = RCAR_GP_PIN(4, 29),
  143. .default_state = LEDS_GPIO_DEFSTATE_ON,
  144. }, {
  145. .name = "led3",
  146. .gpio = RCAR_GP_PIN(4, 30),
  147. .default_state = LEDS_GPIO_DEFSTATE_ON,
  148. }, {
  149. .name = "led4",
  150. .gpio = RCAR_GP_PIN(4, 31),
  151. .default_state = LEDS_GPIO_DEFSTATE_ON,
  152. },
  153. };
  154. static struct gpio_led_platform_data marzen_leds_pdata = {
  155. .leds = marzen_leds,
  156. .num_leds = ARRAY_SIZE(marzen_leds),
  157. };
  158. static struct platform_device leds_device = {
  159. .name = "leds-gpio",
  160. .id = 0,
  161. .dev = {
  162. .platform_data = &marzen_leds_pdata,
  163. },
  164. };
  165. static struct rcar_vin_platform_data vin_platform_data __initdata = {
  166. .flags = RCAR_VIN_BT656,
  167. };
  168. #define MARZEN_CAMERA(idx) \
  169. static struct i2c_board_info camera##idx##_info = { \
  170. I2C_BOARD_INFO("adv7180", 0x20 + (idx)), \
  171. }; \
  172. \
  173. static struct soc_camera_link iclink##idx##_adv7180 = { \
  174. .bus_id = 1 + 2 * (idx), \
  175. .i2c_adapter_id = 0, \
  176. .board_info = &camera##idx##_info, \
  177. }; \
  178. \
  179. static struct platform_device camera##idx##_device = { \
  180. .name = "soc-camera-pdrv", \
  181. .id = idx, \
  182. .dev = { \
  183. .platform_data = &iclink##idx##_adv7180, \
  184. }, \
  185. };
  186. MARZEN_CAMERA(0);
  187. MARZEN_CAMERA(1);
  188. static struct platform_device *marzen_devices[] __initdata = {
  189. &eth_device,
  190. &sdhi0_device,
  191. &thermal_device,
  192. &hspi_device,
  193. &leds_device,
  194. &camera0_device,
  195. &camera1_device,
  196. };
  197. static const struct pinctrl_map marzen_pinctrl_map[] = {
  198. /* HSPI0 */
  199. PIN_MAP_MUX_GROUP_DEFAULT("sh-hspi.0", "pfc-r8a7779",
  200. "hspi0", "hspi0"),
  201. /* SCIF2 (CN18: DEBUG0) */
  202. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.2", "pfc-r8a7779",
  203. "scif2_data_c", "scif2"),
  204. /* SCIF4 (CN19: DEBUG1) */
  205. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "pfc-r8a7779",
  206. "scif4_data", "scif4"),
  207. /* SDHI0 */
  208. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
  209. "sdhi0_data4", "sdhi0"),
  210. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
  211. "sdhi0_ctrl", "sdhi0"),
  212. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
  213. "sdhi0_cd", "sdhi0"),
  214. PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
  215. "sdhi0_wp", "sdhi0"),
  216. /* SMSC */
  217. PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-r8a7779",
  218. "intc_irq1_b", "intc"),
  219. PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-r8a7779",
  220. "lbsc_ex_cs0", "lbsc"),
  221. /* USB0 */
  222. PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.0", "pfc-r8a7779",
  223. "usb0", "usb0"),
  224. /* USB1 */
  225. PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.0", "pfc-r8a7779",
  226. "usb1", "usb1"),
  227. /* USB2 */
  228. PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.1", "pfc-r8a7779",
  229. "usb2", "usb2"),
  230. /* VIN1 */
  231. PIN_MAP_MUX_GROUP_DEFAULT("r8a7779-vin.1", "pfc-r8a7779",
  232. "vin1_clk", "vin1"),
  233. PIN_MAP_MUX_GROUP_DEFAULT("r8a7779-vin.1", "pfc-r8a7779",
  234. "vin1_data8", "vin1"),
  235. /* VIN3 */
  236. PIN_MAP_MUX_GROUP_DEFAULT("r8a7779-vin.3", "pfc-r8a7779",
  237. "vin3_clk", "vin3"),
  238. PIN_MAP_MUX_GROUP_DEFAULT("r8a7779-vin.3", "pfc-r8a7779",
  239. "vin3_data8", "vin3"),
  240. };
  241. static void __init marzen_init(void)
  242. {
  243. regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
  244. ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
  245. regulator_register_fixed(1, dummy_supplies,
  246. ARRAY_SIZE(dummy_supplies));
  247. pinctrl_register_mappings(marzen_pinctrl_map,
  248. ARRAY_SIZE(marzen_pinctrl_map));
  249. r8a7779_pinmux_init();
  250. r8a7779_init_irq_extpin(1); /* IRQ1 as individual interrupt */
  251. r8a7779_add_standard_devices();
  252. r8a7779_add_usb_phy_device(&usb_phy_platform_data);
  253. r8a7779_add_vin_device(1, &vin_platform_data);
  254. r8a7779_add_vin_device(3, &vin_platform_data);
  255. platform_add_devices(marzen_devices, ARRAY_SIZE(marzen_devices));
  256. }
  257. MACHINE_START(MARZEN, "marzen")
  258. .smp = smp_ops(r8a7779_smp_ops),
  259. .map_io = r8a7779_map_io,
  260. .init_early = r8a7779_add_early_devices,
  261. .nr_irqs = NR_IRQS_LEGACY,
  262. .init_irq = r8a7779_init_irq,
  263. .init_machine = marzen_init,
  264. .init_late = r8a7779_init_late,
  265. .init_time = r8a7779_earlytimer_init,
  266. MACHINE_END