Magnus Damm | 3cc828f | 2013-03-29 17:49:37 +0900 | [diff] [blame] | 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 | |
Simon Horman | c3842e4 | 2013-05-13 16:04:31 +0900 | [diff] [blame] | 21 | #include <linux/gpio.h> |
| 22 | #include <linux/gpio_keys.h> |
| 23 | #include <linux/input.h> |
Magnus Damm | 3cc828f | 2013-03-29 17:49:37 +0900 | [diff] [blame] | 24 | #include <linux/interrupt.h> |
Magnus Damm | 3cc828f | 2013-03-29 17:49:37 +0900 | [diff] [blame] | 25 | #include <linux/kernel.h> |
Simon Horman | 1034f4e | 2013-04-23 02:37:05 +0000 | [diff] [blame] | 26 | #include <linux/leds.h> |
Guennadi Liakhovetski | 63d0539 | 2013-07-08 17:54:43 +0200 | [diff] [blame] | 27 | #include <linux/mmc/host.h> |
| 28 | #include <linux/mmc/sh_mmcif.h> |
Laurent Pinchart | e3a28ac | 2013-04-08 11:36:22 +0200 | [diff] [blame] | 29 | #include <linux/pinctrl/machine.h> |
Simon Horman | 1034f4e | 2013-04-23 02:37:05 +0000 | [diff] [blame] | 30 | #include <linux/platform_data/gpio-rcar.h> |
Magnus Damm | 3cc828f | 2013-03-29 17:49:37 +0900 | [diff] [blame] | 31 | #include <linux/platform_device.h> |
Guennadi Liakhovetski | 63d0539 | 2013-07-08 17:54:43 +0200 | [diff] [blame] | 32 | #include <linux/regulator/fixed.h> |
| 33 | #include <linux/regulator/machine.h> |
Simon Horman | 4901e13 | 2013-08-06 16:50:10 +0900 | [diff] [blame] | 34 | #include <linux/sh_eth.h> |
Magnus Damm | 3cc828f | 2013-03-29 17:49:37 +0900 | [diff] [blame] | 35 | #include <mach/common.h> |
Guennadi Liakhovetski | 63d0539 | 2013-07-08 17:54:43 +0200 | [diff] [blame] | 36 | #include <mach/irqs.h> |
Magnus Damm | 3cc828f | 2013-03-29 17:49:37 +0900 | [diff] [blame] | 37 | #include <mach/r8a7790.h> |
| 38 | #include <asm/mach-types.h> |
| 39 | #include <asm/mach/arch.h> |
| 40 | |
Simon Horman | 1034f4e | 2013-04-23 02:37:05 +0000 | [diff] [blame] | 41 | /* LEDS */ |
| 42 | static struct gpio_led lager_leds[] = { |
| 43 | { |
| 44 | .name = "led8", |
| 45 | .gpio = RCAR_GP_PIN(5, 17), |
| 46 | .default_state = LEDS_GPIO_DEFSTATE_ON, |
| 47 | }, { |
| 48 | .name = "led7", |
| 49 | .gpio = RCAR_GP_PIN(4, 23), |
| 50 | .default_state = LEDS_GPIO_DEFSTATE_ON, |
| 51 | }, { |
| 52 | .name = "led6", |
| 53 | .gpio = RCAR_GP_PIN(4, 22), |
| 54 | .default_state = LEDS_GPIO_DEFSTATE_ON, |
| 55 | }, |
| 56 | }; |
| 57 | |
Simon Horman | c3842e4 | 2013-05-13 16:04:31 +0900 | [diff] [blame] | 58 | static __initdata struct gpio_led_platform_data lager_leds_pdata = { |
Simon Horman | 1034f4e | 2013-04-23 02:37:05 +0000 | [diff] [blame] | 59 | .leds = lager_leds, |
| 60 | .num_leds = ARRAY_SIZE(lager_leds), |
| 61 | }; |
| 62 | |
Simon Horman | c3842e4 | 2013-05-13 16:04:31 +0900 | [diff] [blame] | 63 | /* GPIO KEY */ |
| 64 | #define GPIO_KEY(c, g, d, ...) \ |
| 65 | { .code = c, .gpio = g, .desc = d, .active_low = 1 } |
| 66 | |
Simon Horman | a601469 | 2013-07-26 17:53:42 +0900 | [diff] [blame] | 67 | static struct gpio_keys_button gpio_buttons[] = { |
Simon Horman | c3842e4 | 2013-05-13 16:04:31 +0900 | [diff] [blame] | 68 | GPIO_KEY(KEY_4, RCAR_GP_PIN(1, 28), "SW2-pin4"), |
| 69 | GPIO_KEY(KEY_3, RCAR_GP_PIN(1, 26), "SW2-pin3"), |
| 70 | GPIO_KEY(KEY_2, RCAR_GP_PIN(1, 24), "SW2-pin2"), |
| 71 | GPIO_KEY(KEY_1, RCAR_GP_PIN(1, 14), "SW2-pin1"), |
| 72 | }; |
| 73 | |
| 74 | static __initdata struct gpio_keys_platform_data lager_keys_pdata = { |
| 75 | .buttons = gpio_buttons, |
| 76 | .nbuttons = ARRAY_SIZE(gpio_buttons), |
| 77 | }; |
| 78 | |
Guennadi Liakhovetski | 63d0539 | 2013-07-08 17:54:43 +0200 | [diff] [blame] | 79 | /* Fixed 3.3V regulator to be used by MMCIF */ |
| 80 | static struct regulator_consumer_supply fixed3v3_power_consumers[] = |
| 81 | { |
| 82 | REGULATOR_SUPPLY("vmmc", "sh_mmcif.1"), |
| 83 | }; |
| 84 | |
| 85 | /* MMCIF */ |
Kuninori Morimoto | 8c8881b | 2013-08-01 18:34:37 -0700 | [diff] [blame] | 86 | static struct sh_mmcif_plat_data mmcif1_pdata __initdata = { |
Guennadi Liakhovetski | 63d0539 | 2013-07-08 17:54:43 +0200 | [diff] [blame] | 87 | .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE, |
| 88 | }; |
| 89 | |
Kuninori Morimoto | 8c8881b | 2013-08-01 18:34:37 -0700 | [diff] [blame] | 90 | static struct resource mmcif1_resources[] __initdata = { |
Guennadi Liakhovetski | 63d0539 | 2013-07-08 17:54:43 +0200 | [diff] [blame] | 91 | DEFINE_RES_MEM_NAMED(0xee220000, 0x80, "MMCIF1"), |
| 92 | DEFINE_RES_IRQ(gic_spi(170)), |
| 93 | }; |
| 94 | |
Simon Horman | 4901e13 | 2013-08-06 16:50:10 +0900 | [diff] [blame] | 95 | /* Ether */ |
| 96 | static struct sh_eth_plat_data ether_pdata __initdata = { |
| 97 | .phy = 0x1, |
| 98 | .edmac_endian = EDMAC_LITTLE_ENDIAN, |
Simon Horman | 4901e13 | 2013-08-06 16:50:10 +0900 | [diff] [blame] | 99 | .phy_interface = PHY_INTERFACE_MODE_RMII, |
| 100 | .ether_link_active_low = 1, |
| 101 | }; |
| 102 | |
| 103 | static struct resource ether_resources[] __initdata = { |
| 104 | DEFINE_RES_MEM(0xee700000, 0x400), |
| 105 | DEFINE_RES_IRQ(gic_spi(162)), |
| 106 | }; |
| 107 | |
Laurent Pinchart | e3a28ac | 2013-04-08 11:36:22 +0200 | [diff] [blame] | 108 | static const struct pinctrl_map lager_pinctrl_map[] = { |
| 109 | /* SCIF0 (CN19: DEBUG SERIAL0) */ |
| 110 | PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.6", "pfc-r8a7790", |
| 111 | "scif0_data", "scif0"), |
| 112 | /* SCIF1 (CN20: DEBUG SERIAL1) */ |
| 113 | PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.7", "pfc-r8a7790", |
| 114 | "scif1_data", "scif1"), |
Guennadi Liakhovetski | 63d0539 | 2013-07-08 17:54:43 +0200 | [diff] [blame] | 115 | /* MMCIF1 */ |
| 116 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.1", "pfc-r8a7790", |
| 117 | "mmc1_data8", "mmc1"), |
| 118 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.1", "pfc-r8a7790", |
| 119 | "mmc1_ctrl", "mmc1"), |
Simon Horman | 4901e13 | 2013-08-06 16:50:10 +0900 | [diff] [blame] | 120 | /* Ether */ |
| 121 | PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-ether", "pfc-r8a7790", |
| 122 | "eth_link", "eth"), |
| 123 | PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-ether", "pfc-r8a7790", |
| 124 | "eth_mdio", "eth"), |
| 125 | PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-ether", "pfc-r8a7790", |
| 126 | "eth_rmii", "eth"), |
| 127 | PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-ether", "pfc-r8a7790", |
| 128 | "intc_irq0", "intc"), |
Laurent Pinchart | e3a28ac | 2013-04-08 11:36:22 +0200 | [diff] [blame] | 129 | }; |
| 130 | |
Magnus Damm | 3cc828f | 2013-03-29 17:49:37 +0900 | [diff] [blame] | 131 | static void __init lager_add_standard_devices(void) |
| 132 | { |
| 133 | r8a7790_clock_init(); |
Laurent Pinchart | e3a28ac | 2013-04-08 11:36:22 +0200 | [diff] [blame] | 134 | |
| 135 | pinctrl_register_mappings(lager_pinctrl_map, |
| 136 | ARRAY_SIZE(lager_pinctrl_map)); |
| 137 | r8a7790_pinmux_init(); |
| 138 | |
Magnus Damm | 3cc828f | 2013-03-29 17:49:37 +0900 | [diff] [blame] | 139 | r8a7790_add_standard_devices(); |
Simon Horman | 1034f4e | 2013-04-23 02:37:05 +0000 | [diff] [blame] | 140 | platform_device_register_data(&platform_bus, "leds-gpio", -1, |
| 141 | &lager_leds_pdata, |
| 142 | sizeof(lager_leds_pdata)); |
Simon Horman | c3842e4 | 2013-05-13 16:04:31 +0900 | [diff] [blame] | 143 | platform_device_register_data(&platform_bus, "gpio-keys", -1, |
| 144 | &lager_keys_pdata, |
| 145 | sizeof(lager_keys_pdata)); |
Guennadi Liakhovetski | 63d0539 | 2013-07-08 17:54:43 +0200 | [diff] [blame] | 146 | regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers, |
| 147 | ARRAY_SIZE(fixed3v3_power_consumers), 3300000); |
| 148 | platform_device_register_resndata(&platform_bus, "sh_mmcif", 1, |
| 149 | mmcif1_resources, ARRAY_SIZE(mmcif1_resources), |
| 150 | &mmcif1_pdata, sizeof(mmcif1_pdata)); |
Simon Horman | 4901e13 | 2013-08-06 16:50:10 +0900 | [diff] [blame] | 151 | |
| 152 | platform_device_register_resndata(&platform_bus, "r8a7790-ether", -1, |
| 153 | ether_resources, |
| 154 | ARRAY_SIZE(ether_resources), |
| 155 | ðer_pdata, sizeof(ether_pdata)); |
Magnus Damm | 3cc828f | 2013-03-29 17:49:37 +0900 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | static const char *lager_boards_compat_dt[] __initdata = { |
| 159 | "renesas,lager", |
| 160 | NULL, |
| 161 | }; |
| 162 | |
| 163 | DT_MACHINE_START(LAGER_DT, "lager") |
Magnus Damm | 8333d8c | 2013-06-28 20:27:13 +0900 | [diff] [blame] | 164 | .init_early = r8a7790_init_delay, |
Magnus Damm | 65be2de | 2013-04-08 10:23:37 +0900 | [diff] [blame] | 165 | .init_time = r8a7790_timer_init, |
Magnus Damm | 3cc828f | 2013-03-29 17:49:37 +0900 | [diff] [blame] | 166 | .init_machine = lager_add_standard_devices, |
| 167 | .dt_compat = lager_boards_compat_dt, |
| 168 | MACHINE_END |