board-lager.c 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /*
  2. * Lager board support
  3. *
  4. * Copyright (C) 2013 Renesas Solutions Corp.
  5. * Copyright (C) 2013 Magnus Damm
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <linux/gpio.h>
  21. #include <linux/gpio_keys.h>
  22. #include <linux/input.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/kernel.h>
  25. #include <linux/leds.h>
  26. #include <linux/mmc/host.h>
  27. #include <linux/mmc/sh_mmcif.h>
  28. #include <linux/pinctrl/machine.h>
  29. #include <linux/platform_data/gpio-rcar.h>
  30. #include <linux/platform_data/rcar-du.h>
  31. #include <linux/platform_device.h>
  32. #include <linux/regulator/fixed.h>
  33. #include <linux/regulator/machine.h>
  34. #include <linux/sh_eth.h>
  35. #include <mach/common.h>
  36. #include <mach/irqs.h>
  37. #include <mach/r8a7790.h>
  38. #include <asm/mach-types.h>
  39. #include <asm/mach/arch.h>
  40. /* DU */
  41. static struct rcar_du_encoder_data lager_du_encoders[] = {
  42. {
  43. .type = RCAR_DU_ENCODER_VGA,
  44. .output = RCAR_DU_OUTPUT_DPAD0,
  45. }, {
  46. .type = RCAR_DU_ENCODER_NONE,
  47. .output = RCAR_DU_OUTPUT_LVDS1,
  48. .connector.lvds.panel = {
  49. .width_mm = 210,
  50. .height_mm = 158,
  51. .mode = {
  52. .clock = 65000,
  53. .hdisplay = 1024,
  54. .hsync_start = 1048,
  55. .hsync_end = 1184,
  56. .htotal = 1344,
  57. .vdisplay = 768,
  58. .vsync_start = 771,
  59. .vsync_end = 777,
  60. .vtotal = 806,
  61. .flags = 0,
  62. },
  63. },
  64. },
  65. };
  66. static const struct rcar_du_platform_data lager_du_pdata __initconst = {
  67. .encoders = lager_du_encoders,
  68. .num_encoders = ARRAY_SIZE(lager_du_encoders),
  69. };
  70. static const struct resource du_resources[] __initconst = {
  71. DEFINE_RES_MEM(0xfeb00000, 0x70000),
  72. DEFINE_RES_MEM_NAMED(0xfeb90000, 0x1c, "lvds.0"),
  73. DEFINE_RES_MEM_NAMED(0xfeb94000, 0x1c, "lvds.1"),
  74. DEFINE_RES_IRQ(gic_spi(256)),
  75. DEFINE_RES_IRQ(gic_spi(268)),
  76. DEFINE_RES_IRQ(gic_spi(269)),
  77. };
  78. static void __init lager_add_du_device(void)
  79. {
  80. struct platform_device_info info = {
  81. .name = "rcar-du-r8a7790",
  82. .id = -1,
  83. .res = du_resources,
  84. .num_res = ARRAY_SIZE(du_resources),
  85. .data = &lager_du_pdata,
  86. .size_data = sizeof(lager_du_pdata),
  87. .dma_mask = DMA_BIT_MASK(32),
  88. };
  89. platform_device_register_full(&info);
  90. }
  91. /* LEDS */
  92. static struct gpio_led lager_leds[] = {
  93. {
  94. .name = "led8",
  95. .gpio = RCAR_GP_PIN(5, 17),
  96. .default_state = LEDS_GPIO_DEFSTATE_ON,
  97. }, {
  98. .name = "led7",
  99. .gpio = RCAR_GP_PIN(4, 23),
  100. .default_state = LEDS_GPIO_DEFSTATE_ON,
  101. }, {
  102. .name = "led6",
  103. .gpio = RCAR_GP_PIN(4, 22),
  104. .default_state = LEDS_GPIO_DEFSTATE_ON,
  105. },
  106. };
  107. static __initdata struct gpio_led_platform_data lager_leds_pdata = {
  108. .leds = lager_leds,
  109. .num_leds = ARRAY_SIZE(lager_leds),
  110. };
  111. /* GPIO KEY */
  112. #define GPIO_KEY(c, g, d, ...) \
  113. { .code = c, .gpio = g, .desc = d, .active_low = 1 }
  114. static struct gpio_keys_button gpio_buttons[] = {
  115. GPIO_KEY(KEY_4, RCAR_GP_PIN(1, 28), "SW2-pin4"),
  116. GPIO_KEY(KEY_3, RCAR_GP_PIN(1, 26), "SW2-pin3"),
  117. GPIO_KEY(KEY_2, RCAR_GP_PIN(1, 24), "SW2-pin2"),
  118. GPIO_KEY(KEY_1, RCAR_GP_PIN(1, 14), "SW2-pin1"),
  119. };
  120. static __initdata struct gpio_keys_platform_data lager_keys_pdata = {
  121. .buttons = gpio_buttons,
  122. .nbuttons = ARRAY_SIZE(gpio_buttons),
  123. };
  124. /* Fixed 3.3V regulator to be used by MMCIF */
  125. static struct regulator_consumer_supply fixed3v3_power_consumers[] =
  126. {
  127. REGULATOR_SUPPLY("vmmc", "sh_mmcif.1"),
  128. };
  129. /* MMCIF */
  130. static struct sh_mmcif_plat_data mmcif1_pdata __initdata = {
  131. .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
  132. };
  133. static struct resource mmcif1_resources[] __initdata = {
  134. DEFINE_RES_MEM_NAMED(0xee220000, 0x80, "MMCIF1"),
  135. DEFINE_RES_IRQ(gic_spi(170)),
  136. };
  137. /* Ether */
  138. static struct sh_eth_plat_data ether_pdata __initdata = {
  139. .phy = 0x1,
  140. .edmac_endian = EDMAC_LITTLE_ENDIAN,
  141. .phy_interface = PHY_INTERFACE_MODE_RMII,
  142. .ether_link_active_low = 1,
  143. };
  144. static struct resource ether_resources[] __initdata = {
  145. DEFINE_RES_MEM(0xee700000, 0x400),
  146. DEFINE_RES_IRQ(gic_spi(162)),
  147. };
  148. static const struct pinctrl_map lager_pinctrl_map[] = {
  149. /* DU (CN10: ARGB0, CN13: LVDS) */
  150. PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7790", "pfc-r8a7790",
  151. "du_rgb666", "du"),
  152. PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7790", "pfc-r8a7790",
  153. "du_sync_1", "du"),
  154. PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7790", "pfc-r8a7790",
  155. "du_clk_out_0", "du"),
  156. /* SCIF0 (CN19: DEBUG SERIAL0) */
  157. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.6", "pfc-r8a7790",
  158. "scif0_data", "scif0"),
  159. /* SCIF1 (CN20: DEBUG SERIAL1) */
  160. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.7", "pfc-r8a7790",
  161. "scif1_data", "scif1"),
  162. /* MMCIF1 */
  163. PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.1", "pfc-r8a7790",
  164. "mmc1_data8", "mmc1"),
  165. PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.1", "pfc-r8a7790",
  166. "mmc1_ctrl", "mmc1"),
  167. /* Ether */
  168. PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-ether", "pfc-r8a7790",
  169. "eth_link", "eth"),
  170. PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-ether", "pfc-r8a7790",
  171. "eth_mdio", "eth"),
  172. PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-ether", "pfc-r8a7790",
  173. "eth_rmii", "eth"),
  174. PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-ether", "pfc-r8a7790",
  175. "intc_irq0", "intc"),
  176. };
  177. static void __init lager_add_standard_devices(void)
  178. {
  179. r8a7790_clock_init();
  180. pinctrl_register_mappings(lager_pinctrl_map,
  181. ARRAY_SIZE(lager_pinctrl_map));
  182. r8a7790_pinmux_init();
  183. r8a7790_add_standard_devices();
  184. platform_device_register_data(&platform_bus, "leds-gpio", -1,
  185. &lager_leds_pdata,
  186. sizeof(lager_leds_pdata));
  187. platform_device_register_data(&platform_bus, "gpio-keys", -1,
  188. &lager_keys_pdata,
  189. sizeof(lager_keys_pdata));
  190. regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
  191. ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
  192. platform_device_register_resndata(&platform_bus, "sh_mmcif", 1,
  193. mmcif1_resources, ARRAY_SIZE(mmcif1_resources),
  194. &mmcif1_pdata, sizeof(mmcif1_pdata));
  195. platform_device_register_resndata(&platform_bus, "r8a7790-ether", -1,
  196. ether_resources,
  197. ARRAY_SIZE(ether_resources),
  198. &ether_pdata, sizeof(ether_pdata));
  199. lager_add_du_device();
  200. }
  201. static const char *lager_boards_compat_dt[] __initdata = {
  202. "renesas,lager",
  203. NULL,
  204. };
  205. DT_MACHINE_START(LAGER_DT, "lager")
  206. .init_early = r8a7790_init_delay,
  207. .init_time = r8a7790_timer_init,
  208. .init_machine = lager_add_standard_devices,
  209. .dt_compat = lager_boards_compat_dt,
  210. MACHINE_END