Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 1 | /* |
| 2 | * marzen board support |
| 3 | * |
| 4 | * Copyright (C) 2011 Renesas Solutions Corp. |
| 5 | * Copyright (C) 2011 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 | |
| 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> |
Laurent Pinchart | 48b1e3e | 2013-03-10 03:43:32 +0100 | [diff] [blame] | 28 | #include <linux/leds.h> |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 29 | #include <linux/dma-mapping.h> |
Laurent Pinchart | 4a655ec | 2013-03-06 14:22:11 +0100 | [diff] [blame] | 30 | #include <linux/pinctrl/machine.h> |
Laurent Pinchart | 5fcf4a3 | 2013-04-08 12:05:32 +0200 | [diff] [blame] | 31 | #include <linux/platform_data/gpio-rcar.h> |
Guennadi Liakhovetski | b354e22 | 2012-06-27 00:32:32 +0200 | [diff] [blame] | 32 | #include <linux/regulator/fixed.h> |
| 33 | #include <linux/regulator/machine.h> |
Magnus Damm | db5eb99 | 2011-12-14 01:36:51 +0900 | [diff] [blame] | 34 | #include <linux/smsc911x.h> |
Kuninori Morimoto | b82573e | 2012-10-10 19:57:02 -0700 | [diff] [blame] | 35 | #include <linux/spi/spi.h> |
| 36 | #include <linux/spi/sh_hspi.h> |
Simon Horman | 44e9ac4 | 2013-02-13 09:45:50 +0000 | [diff] [blame] | 37 | #include <linux/mmc/host.h> |
Phil Edworthy | 894cda1 | 2012-08-06 13:31:05 +0100 | [diff] [blame] | 38 | #include <linux/mmc/sh_mobile_sdhi.h> |
| 39 | #include <linux/mfd/tmio.h> |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 40 | #include <mach/hardware.h> |
| 41 | #include <mach/r8a7779.h> |
| 42 | #include <mach/common.h> |
Rob Herring | 250a272 | 2012-01-03 16:57:33 -0600 | [diff] [blame] | 43 | #include <mach/irqs.h> |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 44 | #include <asm/mach-types.h> |
| 45 | #include <asm/mach/arch.h> |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 46 | #include <asm/traps.h> |
| 47 | |
Phil Edworthy | 894cda1 | 2012-08-06 13:31:05 +0100 | [diff] [blame] | 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 | |
Guennadi Liakhovetski | b354e22 | 2012-06-27 00:32:32 +0200 | [diff] [blame] | 54 | /* Dummy supplies, where voltage doesn't matter */ |
| 55 | static struct regulator_consumer_supply dummy_supplies[] = { |
| 56 | REGULATOR_SUPPLY("vddvario", "smsc911x"), |
| 57 | REGULATOR_SUPPLY("vdd33a", "smsc911x"), |
| 58 | }; |
| 59 | |
Magnus Damm | db5eb99 | 2011-12-14 01:36:51 +0900 | [diff] [blame] | 60 | /* SMSC LAN89218 */ |
| 61 | static struct resource smsc911x_resources[] = { |
| 62 | [0] = { |
| 63 | .start = 0x18000000, /* ExCS0 */ |
| 64 | .end = 0x180000ff, /* A1->A7 */ |
| 65 | .flags = IORESOURCE_MEM, |
| 66 | }, |
| 67 | [1] = { |
Kuninori Morimoto | 0b6794e | 2013-02-25 01:39:44 -0800 | [diff] [blame] | 68 | .start = gic_iid(0x3c), /* IRQ 1 */ |
Magnus Damm | db5eb99 | 2011-12-14 01:36:51 +0900 | [diff] [blame] | 69 | .flags = IORESOURCE_IRQ, |
| 70 | }, |
| 71 | }; |
| 72 | |
| 73 | static struct smsc911x_platform_config smsc911x_platdata = { |
| 74 | .flags = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */ |
| 75 | .phy_interface = PHY_INTERFACE_MODE_MII, |
| 76 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, |
| 77 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, |
| 78 | }; |
| 79 | |
| 80 | static struct platform_device eth_device = { |
| 81 | .name = "smsc911x", |
Kuninori Morimoto | 497dcf6 | 2012-08-29 18:58:01 -0700 | [diff] [blame] | 82 | .id = -1, |
Magnus Damm | db5eb99 | 2011-12-14 01:36:51 +0900 | [diff] [blame] | 83 | .dev = { |
| 84 | .platform_data = &smsc911x_platdata, |
| 85 | }, |
| 86 | .resource = smsc911x_resources, |
| 87 | .num_resources = ARRAY_SIZE(smsc911x_resources), |
| 88 | }; |
| 89 | |
Phil Edworthy | 894cda1 | 2012-08-06 13:31:05 +0100 | [diff] [blame] | 90 | static struct resource sdhi0_resources[] = { |
| 91 | [0] = { |
| 92 | .name = "sdhi0", |
| 93 | .start = 0xffe4c000, |
| 94 | .end = 0xffe4c0ff, |
| 95 | .flags = IORESOURCE_MEM, |
| 96 | }, |
| 97 | [1] = { |
Kuninori Morimoto | 0b6794e | 2013-02-25 01:39:44 -0800 | [diff] [blame] | 98 | .start = gic_iid(0x88), |
Phil Edworthy | 894cda1 | 2012-08-06 13:31:05 +0100 | [diff] [blame] | 99 | .flags = IORESOURCE_IRQ, |
| 100 | }, |
| 101 | }; |
| 102 | |
| 103 | static struct sh_mobile_sdhi_info sdhi0_platform_data = { |
| 104 | .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT, |
| 105 | .tmio_caps = MMC_CAP_SD_HIGHSPEED, |
| 106 | }; |
| 107 | |
| 108 | static struct platform_device sdhi0_device = { |
| 109 | .name = "sh_mobile_sdhi", |
| 110 | .num_resources = ARRAY_SIZE(sdhi0_resources), |
| 111 | .resource = sdhi0_resources, |
| 112 | .id = 0, |
| 113 | .dev = { |
| 114 | .platform_data = &sdhi0_platform_data, |
| 115 | } |
| 116 | }; |
| 117 | |
Kuninori Morimoto | eb8ca94 | 2012-08-27 19:00:15 -0700 | [diff] [blame] | 118 | /* Thermal */ |
| 119 | static struct resource thermal_resources[] = { |
| 120 | [0] = { |
| 121 | .start = 0xFFC48000, |
| 122 | .end = 0xFFC48038 - 1, |
| 123 | .flags = IORESOURCE_MEM, |
| 124 | }, |
| 125 | }; |
| 126 | |
| 127 | static struct platform_device thermal_device = { |
| 128 | .name = "rcar_thermal", |
| 129 | .resource = thermal_resources, |
| 130 | .num_resources = ARRAY_SIZE(thermal_resources), |
| 131 | }; |
| 132 | |
Kuninori Morimoto | b82573e | 2012-10-10 19:57:02 -0700 | [diff] [blame] | 133 | /* HSPI */ |
| 134 | static struct resource hspi_resources[] = { |
| 135 | [0] = { |
| 136 | .start = 0xFFFC7000, |
| 137 | .end = 0xFFFC7018 - 1, |
| 138 | .flags = IORESOURCE_MEM, |
| 139 | }, |
| 140 | }; |
| 141 | |
| 142 | static struct platform_device hspi_device = { |
| 143 | .name = "sh-hspi", |
| 144 | .id = 0, |
| 145 | .resource = hspi_resources, |
| 146 | .num_resources = ARRAY_SIZE(hspi_resources), |
| 147 | }; |
| 148 | |
Laurent Pinchart | 48b1e3e | 2013-03-10 03:43:32 +0100 | [diff] [blame] | 149 | /* LEDS */ |
| 150 | static struct gpio_led marzen_leds[] = { |
| 151 | { |
| 152 | .name = "led2", |
Laurent Pinchart | 5fcf4a3 | 2013-04-08 12:05:32 +0200 | [diff] [blame] | 153 | .gpio = RCAR_GP_PIN(4, 29), |
Laurent Pinchart | 48b1e3e | 2013-03-10 03:43:32 +0100 | [diff] [blame] | 154 | .default_state = LEDS_GPIO_DEFSTATE_ON, |
| 155 | }, { |
| 156 | .name = "led3", |
Laurent Pinchart | 5fcf4a3 | 2013-04-08 12:05:32 +0200 | [diff] [blame] | 157 | .gpio = RCAR_GP_PIN(4, 30), |
Laurent Pinchart | 48b1e3e | 2013-03-10 03:43:32 +0100 | [diff] [blame] | 158 | .default_state = LEDS_GPIO_DEFSTATE_ON, |
| 159 | }, { |
| 160 | .name = "led4", |
Laurent Pinchart | 5fcf4a3 | 2013-04-08 12:05:32 +0200 | [diff] [blame] | 161 | .gpio = RCAR_GP_PIN(4, 31), |
Laurent Pinchart | 48b1e3e | 2013-03-10 03:43:32 +0100 | [diff] [blame] | 162 | .default_state = LEDS_GPIO_DEFSTATE_ON, |
| 163 | }, |
| 164 | }; |
| 165 | |
| 166 | static struct gpio_led_platform_data marzen_leds_pdata = { |
| 167 | .leds = marzen_leds, |
| 168 | .num_leds = ARRAY_SIZE(marzen_leds), |
| 169 | }; |
| 170 | |
| 171 | static struct platform_device leds_device = { |
| 172 | .name = "leds-gpio", |
| 173 | .id = 0, |
| 174 | .dev = { |
| 175 | .platform_data = &marzen_leds_pdata, |
| 176 | }, |
| 177 | }; |
| 178 | |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 179 | static struct platform_device *marzen_devices[] __initdata = { |
Magnus Damm | db5eb99 | 2011-12-14 01:36:51 +0900 | [diff] [blame] | 180 | ð_device, |
Phil Edworthy | 894cda1 | 2012-08-06 13:31:05 +0100 | [diff] [blame] | 181 | &sdhi0_device, |
Kuninori Morimoto | eb8ca94 | 2012-08-27 19:00:15 -0700 | [diff] [blame] | 182 | &thermal_device, |
Kuninori Morimoto | b82573e | 2012-10-10 19:57:02 -0700 | [diff] [blame] | 183 | &hspi_device, |
Laurent Pinchart | 48b1e3e | 2013-03-10 03:43:32 +0100 | [diff] [blame] | 184 | &leds_device, |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 185 | }; |
| 186 | |
Laurent Pinchart | 4a655ec | 2013-03-06 14:22:11 +0100 | [diff] [blame] | 187 | static const struct pinctrl_map marzen_pinctrl_map[] = { |
Laurent Pinchart | a321747 | 2013-03-06 14:22:11 +0100 | [diff] [blame] | 188 | /* HSPI0 */ |
| 189 | PIN_MAP_MUX_GROUP_DEFAULT("sh-hspi.0", "pfc-r8a7779", |
| 190 | "hspi0", "hspi0"), |
Laurent Pinchart | e9cd49f | 2013-03-06 14:22:11 +0100 | [diff] [blame] | 191 | /* SCIF2 (CN18: DEBUG0) */ |
| 192 | PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.2", "pfc-r8a7779", |
| 193 | "scif2_data_c", "scif2"), |
| 194 | /* SCIF4 (CN19: DEBUG1) */ |
| 195 | PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "pfc-r8a7779", |
| 196 | "scif4_data", "scif4"), |
Laurent Pinchart | 4a655ec | 2013-03-06 14:22:11 +0100 | [diff] [blame] | 197 | /* SDHI0 */ |
| 198 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779", |
| 199 | "sdhi0_data4", "sdhi0"), |
| 200 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779", |
| 201 | "sdhi0_ctrl", "sdhi0"), |
| 202 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779", |
| 203 | "sdhi0_cd", "sdhi0"), |
| 204 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779", |
| 205 | "sdhi0_wp", "sdhi0"), |
Laurent Pinchart | f423df8 | 2013-03-07 13:46:02 +0100 | [diff] [blame] | 206 | /* SMSC */ |
| 207 | PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-r8a7779", |
Laurent Pinchart | ee097e6 | 2013-03-07 13:46:02 +0100 | [diff] [blame] | 208 | "intc_irq1_b", "intc"), |
| 209 | PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-r8a7779", |
Laurent Pinchart | f423df8 | 2013-03-07 13:46:02 +0100 | [diff] [blame] | 210 | "lbsc_ex_cs0", "lbsc"), |
Laurent Pinchart | a00f6e5 | 2013-03-07 13:46:02 +0100 | [diff] [blame] | 211 | /* USB0 */ |
| 212 | PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.0", "pfc-r8a7779", |
| 213 | "usb0", "usb0"), |
| 214 | /* USB1 */ |
| 215 | PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.0", "pfc-r8a7779", |
| 216 | "usb1", "usb1"), |
| 217 | /* USB2 */ |
| 218 | PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.1", "pfc-r8a7779", |
| 219 | "usb2", "usb2"), |
Laurent Pinchart | 4a655ec | 2013-03-06 14:22:11 +0100 | [diff] [blame] | 220 | }; |
| 221 | |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 222 | static void __init marzen_init(void) |
| 223 | { |
Phil Edworthy | 894cda1 | 2012-08-06 13:31:05 +0100 | [diff] [blame] | 224 | regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers, |
| 225 | ARRAY_SIZE(fixed3v3_power_consumers), 3300000); |
Kuninori Morimoto | 90b85af | 2012-08-29 18:58:15 -0700 | [diff] [blame] | 226 | regulator_register_fixed(1, dummy_supplies, |
Phil Edworthy | 894cda1 | 2012-08-06 13:31:05 +0100 | [diff] [blame] | 227 | ARRAY_SIZE(dummy_supplies)); |
Guennadi Liakhovetski | b354e22 | 2012-06-27 00:32:32 +0200 | [diff] [blame] | 228 | |
Laurent Pinchart | 4a655ec | 2013-03-06 14:22:11 +0100 | [diff] [blame] | 229 | pinctrl_register_mappings(marzen_pinctrl_map, |
| 230 | ARRAY_SIZE(marzen_pinctrl_map)); |
Magnus Damm | 19c43fc | 2011-12-14 01:36:22 +0900 | [diff] [blame] | 231 | r8a7779_pinmux_init(); |
| 232 | |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 233 | r8a7779_add_standard_devices(); |
| 234 | platform_add_devices(marzen_devices, ARRAY_SIZE(marzen_devices)); |
| 235 | } |
| 236 | |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 237 | MACHINE_START(MARZEN, "marzen") |
Marc Zyngier | a62580e | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 238 | .smp = smp_ops(r8a7779_smp_ops), |
Magnus Damm | 3e353b87 | 2012-02-29 21:37:43 +0900 | [diff] [blame] | 239 | .map_io = r8a7779_map_io, |
| 240 | .init_early = r8a7779_add_early_devices, |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 241 | .nr_irqs = NR_IRQS_LEGACY, |
| 242 | .init_irq = r8a7779_init_irq, |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 243 | .init_machine = marzen_init, |
Sergei Shtylyov | 2c8788b | 2013-06-02 01:30:15 +0400 | [diff] [blame^] | 244 | .init_late = r8a7779_init_late, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 245 | .init_time = r8a7779_earlytimer_init, |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 246 | MACHINE_END |