board-lager.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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_device.h>
  31. #include <linux/regulator/fixed.h>
  32. #include <linux/regulator/machine.h>
  33. #include <mach/common.h>
  34. #include <mach/irqs.h>
  35. #include <mach/r8a7790.h>
  36. #include <asm/mach-types.h>
  37. #include <asm/mach/arch.h>
  38. /* LEDS */
  39. static struct gpio_led lager_leds[] = {
  40. {
  41. .name = "led8",
  42. .gpio = RCAR_GP_PIN(5, 17),
  43. .default_state = LEDS_GPIO_DEFSTATE_ON,
  44. }, {
  45. .name = "led7",
  46. .gpio = RCAR_GP_PIN(4, 23),
  47. .default_state = LEDS_GPIO_DEFSTATE_ON,
  48. }, {
  49. .name = "led6",
  50. .gpio = RCAR_GP_PIN(4, 22),
  51. .default_state = LEDS_GPIO_DEFSTATE_ON,
  52. },
  53. };
  54. static __initdata struct gpio_led_platform_data lager_leds_pdata = {
  55. .leds = lager_leds,
  56. .num_leds = ARRAY_SIZE(lager_leds),
  57. };
  58. /* GPIO KEY */
  59. #define GPIO_KEY(c, g, d, ...) \
  60. { .code = c, .gpio = g, .desc = d, .active_low = 1 }
  61. static __initdata struct gpio_keys_button gpio_buttons[] = {
  62. GPIO_KEY(KEY_4, RCAR_GP_PIN(1, 28), "SW2-pin4"),
  63. GPIO_KEY(KEY_3, RCAR_GP_PIN(1, 26), "SW2-pin3"),
  64. GPIO_KEY(KEY_2, RCAR_GP_PIN(1, 24), "SW2-pin2"),
  65. GPIO_KEY(KEY_1, RCAR_GP_PIN(1, 14), "SW2-pin1"),
  66. };
  67. static __initdata struct gpio_keys_platform_data lager_keys_pdata = {
  68. .buttons = gpio_buttons,
  69. .nbuttons = ARRAY_SIZE(gpio_buttons),
  70. };
  71. /* Fixed 3.3V regulator to be used by MMCIF */
  72. static struct regulator_consumer_supply fixed3v3_power_consumers[] =
  73. {
  74. REGULATOR_SUPPLY("vmmc", "sh_mmcif.1"),
  75. };
  76. /* MMCIF */
  77. static struct sh_mmcif_plat_data mmcif1_pdata = {
  78. .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
  79. };
  80. static struct resource mmcif1_resources[] = {
  81. DEFINE_RES_MEM_NAMED(0xee220000, 0x80, "MMCIF1"),
  82. DEFINE_RES_IRQ(gic_spi(170)),
  83. };
  84. static const struct pinctrl_map lager_pinctrl_map[] = {
  85. /* SCIF0 (CN19: DEBUG SERIAL0) */
  86. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.6", "pfc-r8a7790",
  87. "scif0_data", "scif0"),
  88. /* SCIF1 (CN20: DEBUG SERIAL1) */
  89. PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.7", "pfc-r8a7790",
  90. "scif1_data", "scif1"),
  91. /* MMCIF1 */
  92. PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.1", "pfc-r8a7790",
  93. "mmc1_data8", "mmc1"),
  94. PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.1", "pfc-r8a7790",
  95. "mmc1_ctrl", "mmc1"),
  96. };
  97. static void __init lager_add_standard_devices(void)
  98. {
  99. r8a7790_clock_init();
  100. pinctrl_register_mappings(lager_pinctrl_map,
  101. ARRAY_SIZE(lager_pinctrl_map));
  102. r8a7790_pinmux_init();
  103. r8a7790_add_standard_devices();
  104. platform_device_register_data(&platform_bus, "leds-gpio", -1,
  105. &lager_leds_pdata,
  106. sizeof(lager_leds_pdata));
  107. platform_device_register_data(&platform_bus, "gpio-keys", -1,
  108. &lager_keys_pdata,
  109. sizeof(lager_keys_pdata));
  110. regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
  111. ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
  112. platform_device_register_resndata(&platform_bus, "sh_mmcif", 1,
  113. mmcif1_resources, ARRAY_SIZE(mmcif1_resources),
  114. &mmcif1_pdata, sizeof(mmcif1_pdata));
  115. }
  116. static const char *lager_boards_compat_dt[] __initdata = {
  117. "renesas,lager",
  118. NULL,
  119. };
  120. DT_MACHINE_START(LAGER_DT, "lager")
  121. .init_early = r8a7790_init_delay,
  122. .init_time = r8a7790_timer_init,
  123. .init_machine = lager_add_standard_devices,
  124. .dt_compat = lager_boards_compat_dt,
  125. MACHINE_END