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> |
Phil Edworthy | 894cda1 | 2012-08-06 13:31:05 +0100 | [diff] [blame] | 33 | #include <linux/mmc/sh_mobile_sdhi.h> |
| 34 | #include <linux/mfd/tmio.h> |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 35 | #include <mach/hardware.h> |
| 36 | #include <mach/r8a7779.h> |
| 37 | #include <mach/common.h> |
Rob Herring | 250a272 | 2012-01-03 16:57:33 -0600 | [diff] [blame] | 38 | #include <mach/irqs.h> |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 39 | #include <asm/mach-types.h> |
| 40 | #include <asm/mach/arch.h> |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 41 | #include <asm/hardware/gic.h> |
| 42 | #include <asm/traps.h> |
| 43 | |
Phil Edworthy | 894cda1 | 2012-08-06 13:31:05 +0100 | [diff] [blame] | 44 | /* Fixed 3.3V regulator to be used by SDHI0 */ |
| 45 | static struct regulator_consumer_supply fixed3v3_power_consumers[] = { |
| 46 | REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"), |
| 47 | REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"), |
| 48 | }; |
| 49 | |
Guennadi Liakhovetski | b354e22 | 2012-06-27 00:32:32 +0200 | [diff] [blame] | 50 | /* Dummy supplies, where voltage doesn't matter */ |
| 51 | static struct regulator_consumer_supply dummy_supplies[] = { |
| 52 | REGULATOR_SUPPLY("vddvario", "smsc911x"), |
| 53 | REGULATOR_SUPPLY("vdd33a", "smsc911x"), |
| 54 | }; |
| 55 | |
Magnus Damm | db5eb99 | 2011-12-14 01:36:51 +0900 | [diff] [blame] | 56 | /* SMSC LAN89218 */ |
| 57 | static struct resource smsc911x_resources[] = { |
| 58 | [0] = { |
| 59 | .start = 0x18000000, /* ExCS0 */ |
| 60 | .end = 0x180000ff, /* A1->A7 */ |
| 61 | .flags = IORESOURCE_MEM, |
| 62 | }, |
| 63 | [1] = { |
| 64 | .start = gic_spi(28), /* IRQ 1 */ |
| 65 | .flags = IORESOURCE_IRQ, |
| 66 | }, |
| 67 | }; |
| 68 | |
| 69 | static struct smsc911x_platform_config smsc911x_platdata = { |
| 70 | .flags = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */ |
| 71 | .phy_interface = PHY_INTERFACE_MODE_MII, |
| 72 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, |
| 73 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, |
| 74 | }; |
| 75 | |
| 76 | static struct platform_device eth_device = { |
| 77 | .name = "smsc911x", |
| 78 | .id = 0, |
| 79 | .dev = { |
| 80 | .platform_data = &smsc911x_platdata, |
| 81 | }, |
| 82 | .resource = smsc911x_resources, |
| 83 | .num_resources = ARRAY_SIZE(smsc911x_resources), |
| 84 | }; |
| 85 | |
Phil Edworthy | 894cda1 | 2012-08-06 13:31:05 +0100 | [diff] [blame] | 86 | static struct resource sdhi0_resources[] = { |
| 87 | [0] = { |
| 88 | .name = "sdhi0", |
| 89 | .start = 0xffe4c000, |
| 90 | .end = 0xffe4c0ff, |
| 91 | .flags = IORESOURCE_MEM, |
| 92 | }, |
| 93 | [1] = { |
| 94 | .start = gic_spi(104), |
| 95 | .flags = IORESOURCE_IRQ, |
| 96 | }, |
| 97 | }; |
| 98 | |
| 99 | static struct sh_mobile_sdhi_info sdhi0_platform_data = { |
| 100 | .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT, |
| 101 | .tmio_caps = MMC_CAP_SD_HIGHSPEED, |
| 102 | }; |
| 103 | |
| 104 | static struct platform_device sdhi0_device = { |
| 105 | .name = "sh_mobile_sdhi", |
| 106 | .num_resources = ARRAY_SIZE(sdhi0_resources), |
| 107 | .resource = sdhi0_resources, |
| 108 | .id = 0, |
| 109 | .dev = { |
| 110 | .platform_data = &sdhi0_platform_data, |
| 111 | } |
| 112 | }; |
| 113 | |
Kuninori Morimoto | eb8ca94 | 2012-08-27 19:00:15 -0700 | [diff] [blame^] | 114 | /* Thermal */ |
| 115 | static struct resource thermal_resources[] = { |
| 116 | [0] = { |
| 117 | .start = 0xFFC48000, |
| 118 | .end = 0xFFC48038 - 1, |
| 119 | .flags = IORESOURCE_MEM, |
| 120 | }, |
| 121 | }; |
| 122 | |
| 123 | static struct platform_device thermal_device = { |
| 124 | .name = "rcar_thermal", |
| 125 | .resource = thermal_resources, |
| 126 | .num_resources = ARRAY_SIZE(thermal_resources), |
| 127 | }; |
| 128 | |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 129 | static struct platform_device *marzen_devices[] __initdata = { |
Magnus Damm | db5eb99 | 2011-12-14 01:36:51 +0900 | [diff] [blame] | 130 | ð_device, |
Phil Edworthy | 894cda1 | 2012-08-06 13:31:05 +0100 | [diff] [blame] | 131 | &sdhi0_device, |
Kuninori Morimoto | eb8ca94 | 2012-08-27 19:00:15 -0700 | [diff] [blame^] | 132 | &thermal_device, |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 133 | }; |
| 134 | |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 135 | static void __init marzen_init(void) |
| 136 | { |
Phil Edworthy | 894cda1 | 2012-08-06 13:31:05 +0100 | [diff] [blame] | 137 | regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers, |
| 138 | ARRAY_SIZE(fixed3v3_power_consumers), 3300000); |
Kuninori Morimoto | 90b85af | 2012-08-29 18:58:15 -0700 | [diff] [blame] | 139 | regulator_register_fixed(1, dummy_supplies, |
Phil Edworthy | 894cda1 | 2012-08-06 13:31:05 +0100 | [diff] [blame] | 140 | ARRAY_SIZE(dummy_supplies)); |
Guennadi Liakhovetski | b354e22 | 2012-06-27 00:32:32 +0200 | [diff] [blame] | 141 | |
Magnus Damm | 19c43fc | 2011-12-14 01:36:22 +0900 | [diff] [blame] | 142 | r8a7779_pinmux_init(); |
| 143 | |
Magnus Damm | 14f691c | 2011-12-14 01:36:42 +0900 | [diff] [blame] | 144 | /* SCIF2 (CN18: DEBUG0) */ |
| 145 | gpio_request(GPIO_FN_TX2_C, NULL); |
| 146 | gpio_request(GPIO_FN_RX2_C, NULL); |
| 147 | |
| 148 | /* SCIF4 (CN19: DEBUG1) */ |
| 149 | gpio_request(GPIO_FN_TX4, NULL); |
| 150 | gpio_request(GPIO_FN_RX4, NULL); |
| 151 | |
Magnus Damm | db5eb99 | 2011-12-14 01:36:51 +0900 | [diff] [blame] | 152 | /* LAN89218 */ |
| 153 | gpio_request(GPIO_FN_EX_CS0, NULL); /* nCS */ |
| 154 | gpio_request(GPIO_FN_IRQ1_B, NULL); /* IRQ + PME */ |
| 155 | |
Phil Edworthy | 894cda1 | 2012-08-06 13:31:05 +0100 | [diff] [blame] | 156 | /* SD0 (CN20) */ |
| 157 | gpio_request(GPIO_FN_SD0_CLK, NULL); |
| 158 | gpio_request(GPIO_FN_SD0_CMD, NULL); |
| 159 | gpio_request(GPIO_FN_SD0_DAT0, NULL); |
| 160 | gpio_request(GPIO_FN_SD0_DAT1, NULL); |
| 161 | gpio_request(GPIO_FN_SD0_DAT2, NULL); |
| 162 | gpio_request(GPIO_FN_SD0_DAT3, NULL); |
| 163 | gpio_request(GPIO_FN_SD0_CD, NULL); |
| 164 | gpio_request(GPIO_FN_SD0_WP, NULL); |
| 165 | |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 166 | r8a7779_add_standard_devices(); |
| 167 | platform_add_devices(marzen_devices, ARRAY_SIZE(marzen_devices)); |
| 168 | } |
| 169 | |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 170 | MACHINE_START(MARZEN, "marzen") |
Magnus Damm | 3e353b87 | 2012-02-29 21:37:43 +0900 | [diff] [blame] | 171 | .map_io = r8a7779_map_io, |
| 172 | .init_early = r8a7779_add_early_devices, |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 173 | .nr_irqs = NR_IRQS_LEGACY, |
| 174 | .init_irq = r8a7779_init_irq, |
Paul Mundt | 77761b6 | 2012-01-10 13:33:23 +0900 | [diff] [blame] | 175 | .handle_irq = gic_handle_irq, |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 176 | .init_machine = marzen_init, |
Shawn Guo | 21cc1b7 | 2012-04-26 21:58:41 +0800 | [diff] [blame] | 177 | .init_late = shmobile_init_late, |
Magnus Damm | df27a2d | 2012-03-06 17:37:01 +0900 | [diff] [blame] | 178 | .timer = &shmobile_timer, |
Magnus Damm | f411fad | 2011-12-14 01:36:12 +0900 | [diff] [blame] | 179 | MACHINE_END |