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> |
Magnus Damm | 14f691c | 2011-12-14 01:36:42 +0900 | [diff] [blame] | 28 | #include <linux/gpio.h> |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 29 | #include <linux/dma-mapping.h> |
Guennadi Liakhovetski | b354e22 | 2012-06-27 00:32:32 +0200 | [diff] [blame] | 30 | #include <linux/regulator/fixed.h> |
| 31 | #include <linux/regulator/machine.h> |
Magnus Damm | db5eb99 | 2011-12-14 01:36:51 +0900 | [diff] [blame] | 32 | #include <linux/smsc911x.h> |
Kuninori Morimoto | b82573e | 2012-10-10 19:57:02 -0700 | [diff] [blame] | 33 | #include <linux/spi/spi.h> |
| 34 | #include <linux/spi/sh_hspi.h> |
Phil Edworthy | 894cda1 | 2012-08-06 13:31:05 +0100 | [diff] [blame] | 35 | #include <linux/mmc/sh_mobile_sdhi.h> |
| 36 | #include <linux/mfd/tmio.h> |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 37 | #include <mach/hardware.h> |
| 38 | #include <mach/r8a7779.h> |
| 39 | #include <mach/common.h> |
Rob Herring | 250a272 | 2012-01-03 16:57:33 -0600 | [diff] [blame] | 40 | #include <mach/irqs.h> |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 41 | #include <asm/mach-types.h> |
| 42 | #include <asm/mach/arch.h> |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 43 | #include <asm/hardware/gic.h> |
| 44 | #include <asm/traps.h> |
| 45 | |
Phil Edworthy | 894cda1 | 2012-08-06 13:31:05 +0100 | [diff] [blame] | 46 | /* Fixed 3.3V regulator to be used by SDHI0 */ |
| 47 | static struct regulator_consumer_supply fixed3v3_power_consumers[] = { |
| 48 | REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"), |
| 49 | REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"), |
| 50 | }; |
| 51 | |
Guennadi Liakhovetski | b354e22 | 2012-06-27 00:32:32 +0200 | [diff] [blame] | 52 | /* Dummy supplies, where voltage doesn't matter */ |
| 53 | static struct regulator_consumer_supply dummy_supplies[] = { |
| 54 | REGULATOR_SUPPLY("vddvario", "smsc911x"), |
| 55 | REGULATOR_SUPPLY("vdd33a", "smsc911x"), |
| 56 | }; |
| 57 | |
Magnus Damm | db5eb99 | 2011-12-14 01:36:51 +0900 | [diff] [blame] | 58 | /* SMSC LAN89218 */ |
| 59 | static struct resource smsc911x_resources[] = { |
| 60 | [0] = { |
| 61 | .start = 0x18000000, /* ExCS0 */ |
| 62 | .end = 0x180000ff, /* A1->A7 */ |
| 63 | .flags = IORESOURCE_MEM, |
| 64 | }, |
| 65 | [1] = { |
| 66 | .start = gic_spi(28), /* IRQ 1 */ |
| 67 | .flags = IORESOURCE_IRQ, |
| 68 | }, |
| 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 | |
| 78 | static struct platform_device eth_device = { |
| 79 | .name = "smsc911x", |
Kuninori Morimoto | 497dcf6 | 2012-08-29 18:58:01 -0700 | [diff] [blame] | 80 | .id = -1, |
Magnus Damm | db5eb99 | 2011-12-14 01:36:51 +0900 | [diff] [blame] | 81 | .dev = { |
| 82 | .platform_data = &smsc911x_platdata, |
| 83 | }, |
| 84 | .resource = smsc911x_resources, |
| 85 | .num_resources = ARRAY_SIZE(smsc911x_resources), |
| 86 | }; |
| 87 | |
Phil Edworthy | 894cda1 | 2012-08-06 13:31:05 +0100 | [diff] [blame] | 88 | static struct resource sdhi0_resources[] = { |
| 89 | [0] = { |
| 90 | .name = "sdhi0", |
| 91 | .start = 0xffe4c000, |
| 92 | .end = 0xffe4c0ff, |
| 93 | .flags = IORESOURCE_MEM, |
| 94 | }, |
| 95 | [1] = { |
| 96 | .start = gic_spi(104), |
| 97 | .flags = IORESOURCE_IRQ, |
| 98 | }, |
| 99 | }; |
| 100 | |
| 101 | static struct sh_mobile_sdhi_info sdhi0_platform_data = { |
| 102 | .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT, |
| 103 | .tmio_caps = MMC_CAP_SD_HIGHSPEED, |
| 104 | }; |
| 105 | |
| 106 | static struct platform_device sdhi0_device = { |
| 107 | .name = "sh_mobile_sdhi", |
| 108 | .num_resources = ARRAY_SIZE(sdhi0_resources), |
| 109 | .resource = sdhi0_resources, |
| 110 | .id = 0, |
| 111 | .dev = { |
| 112 | .platform_data = &sdhi0_platform_data, |
| 113 | } |
| 114 | }; |
| 115 | |
Kuninori Morimoto | eb8ca94 | 2012-08-27 19:00:15 -0700 | [diff] [blame] | 116 | /* Thermal */ |
| 117 | static struct resource thermal_resources[] = { |
| 118 | [0] = { |
| 119 | .start = 0xFFC48000, |
| 120 | .end = 0xFFC48038 - 1, |
| 121 | .flags = IORESOURCE_MEM, |
| 122 | }, |
| 123 | }; |
| 124 | |
| 125 | static struct platform_device thermal_device = { |
| 126 | .name = "rcar_thermal", |
| 127 | .resource = thermal_resources, |
| 128 | .num_resources = ARRAY_SIZE(thermal_resources), |
| 129 | }; |
| 130 | |
Kuninori Morimoto | b82573e | 2012-10-10 19:57:02 -0700 | [diff] [blame] | 131 | /* HSPI */ |
| 132 | static struct resource hspi_resources[] = { |
| 133 | [0] = { |
| 134 | .start = 0xFFFC7000, |
| 135 | .end = 0xFFFC7018 - 1, |
| 136 | .flags = IORESOURCE_MEM, |
| 137 | }, |
| 138 | }; |
| 139 | |
| 140 | static struct platform_device hspi_device = { |
| 141 | .name = "sh-hspi", |
| 142 | .id = 0, |
| 143 | .resource = hspi_resources, |
| 144 | .num_resources = ARRAY_SIZE(hspi_resources), |
| 145 | }; |
| 146 | |
Kuninori Morimoto | b5ce635 | 2012-10-29 01:15:25 -0700 | [diff] [blame^] | 147 | /* USB PHY */ |
| 148 | static struct resource usb_phy_resources[] = { |
| 149 | [0] = { |
| 150 | .start = 0xffe70000, |
| 151 | .end = 0xffe70900 - 1, |
| 152 | .flags = IORESOURCE_MEM, |
| 153 | }, |
| 154 | [1] = { |
| 155 | .start = 0xfff70000, |
| 156 | .end = 0xfff70900 - 1, |
| 157 | .flags = IORESOURCE_MEM, |
| 158 | }, |
| 159 | }; |
| 160 | |
| 161 | static struct platform_device usb_phy_device = { |
| 162 | .name = "rcar_usb_phy", |
| 163 | .resource = usb_phy_resources, |
| 164 | .num_resources = ARRAY_SIZE(usb_phy_resources), |
| 165 | }; |
| 166 | |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 167 | static struct platform_device *marzen_devices[] __initdata = { |
Magnus Damm | db5eb99 | 2011-12-14 01:36:51 +0900 | [diff] [blame] | 168 | ð_device, |
Phil Edworthy | 894cda1 | 2012-08-06 13:31:05 +0100 | [diff] [blame] | 169 | &sdhi0_device, |
Kuninori Morimoto | eb8ca94 | 2012-08-27 19:00:15 -0700 | [diff] [blame] | 170 | &thermal_device, |
Kuninori Morimoto | b82573e | 2012-10-10 19:57:02 -0700 | [diff] [blame] | 171 | &hspi_device, |
Kuninori Morimoto | b5ce635 | 2012-10-29 01:15:25 -0700 | [diff] [blame^] | 172 | &usb_phy_device, |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 173 | }; |
| 174 | |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 175 | static void __init marzen_init(void) |
| 176 | { |
Phil Edworthy | 894cda1 | 2012-08-06 13:31:05 +0100 | [diff] [blame] | 177 | regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers, |
| 178 | ARRAY_SIZE(fixed3v3_power_consumers), 3300000); |
Kuninori Morimoto | 90b85af | 2012-08-29 18:58:15 -0700 | [diff] [blame] | 179 | regulator_register_fixed(1, dummy_supplies, |
Phil Edworthy | 894cda1 | 2012-08-06 13:31:05 +0100 | [diff] [blame] | 180 | ARRAY_SIZE(dummy_supplies)); |
Guennadi Liakhovetski | b354e22 | 2012-06-27 00:32:32 +0200 | [diff] [blame] | 181 | |
Magnus Damm | 19c43fc | 2011-12-14 01:36:22 +0900 | [diff] [blame] | 182 | r8a7779_pinmux_init(); |
| 183 | |
Magnus Damm | 14f691c | 2011-12-14 01:36:42 +0900 | [diff] [blame] | 184 | /* SCIF2 (CN18: DEBUG0) */ |
| 185 | gpio_request(GPIO_FN_TX2_C, NULL); |
| 186 | gpio_request(GPIO_FN_RX2_C, NULL); |
| 187 | |
| 188 | /* SCIF4 (CN19: DEBUG1) */ |
| 189 | gpio_request(GPIO_FN_TX4, NULL); |
| 190 | gpio_request(GPIO_FN_RX4, NULL); |
| 191 | |
Magnus Damm | db5eb99 | 2011-12-14 01:36:51 +0900 | [diff] [blame] | 192 | /* LAN89218 */ |
| 193 | gpio_request(GPIO_FN_EX_CS0, NULL); /* nCS */ |
| 194 | gpio_request(GPIO_FN_IRQ1_B, NULL); /* IRQ + PME */ |
| 195 | |
Phil Edworthy | 894cda1 | 2012-08-06 13:31:05 +0100 | [diff] [blame] | 196 | /* SD0 (CN20) */ |
| 197 | gpio_request(GPIO_FN_SD0_CLK, NULL); |
| 198 | gpio_request(GPIO_FN_SD0_CMD, NULL); |
| 199 | gpio_request(GPIO_FN_SD0_DAT0, NULL); |
| 200 | gpio_request(GPIO_FN_SD0_DAT1, NULL); |
| 201 | gpio_request(GPIO_FN_SD0_DAT2, NULL); |
| 202 | gpio_request(GPIO_FN_SD0_DAT3, NULL); |
| 203 | gpio_request(GPIO_FN_SD0_CD, NULL); |
| 204 | gpio_request(GPIO_FN_SD0_WP, NULL); |
| 205 | |
Kuninori Morimoto | b82573e | 2012-10-10 19:57:02 -0700 | [diff] [blame] | 206 | /* HSPI 0 */ |
| 207 | gpio_request(GPIO_FN_HSPI_CLK0, NULL); |
| 208 | gpio_request(GPIO_FN_HSPI_CS0, NULL); |
| 209 | gpio_request(GPIO_FN_HSPI_TX0, NULL); |
| 210 | gpio_request(GPIO_FN_HSPI_RX0, NULL); |
| 211 | |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 212 | r8a7779_add_standard_devices(); |
| 213 | platform_add_devices(marzen_devices, ARRAY_SIZE(marzen_devices)); |
| 214 | } |
| 215 | |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 216 | MACHINE_START(MARZEN, "marzen") |
Marc Zyngier | a62580e | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 217 | .smp = smp_ops(r8a7779_smp_ops), |
Magnus Damm | 3e353b87 | 2012-02-29 21:37:43 +0900 | [diff] [blame] | 218 | .map_io = r8a7779_map_io, |
| 219 | .init_early = r8a7779_add_early_devices, |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 220 | .nr_irqs = NR_IRQS_LEGACY, |
| 221 | .init_irq = r8a7779_init_irq, |
Paul Mundt | 77761b6 | 2012-01-10 13:33:23 +0900 | [diff] [blame] | 222 | .handle_irq = gic_handle_irq, |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 223 | .init_machine = marzen_init, |
Shawn Guo | 21cc1b7 | 2012-04-26 21:58:41 +0800 | [diff] [blame] | 224 | .init_late = shmobile_init_late, |
Magnus Damm | df27a2d | 2012-03-06 17:37:01 +0900 | [diff] [blame] | 225 | .timer = &shmobile_timer, |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 226 | MACHINE_END |