blob: 69f7f464eff84bb4446e76500e627d5e03e12d78 [file] [log] [blame]
Magnus Dammf411fad2011-12-14 01:36:12 +09001/*
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 Damm14f691c2011-12-14 01:36:42 +090028#include <linux/gpio.h>
Magnus Dammf411fad2011-12-14 01:36:12 +090029#include <linux/dma-mapping.h>
Guennadi Liakhovetskib354e222012-06-27 00:32:32 +020030#include <linux/regulator/fixed.h>
31#include <linux/regulator/machine.h>
Magnus Dammdb5eb992011-12-14 01:36:51 +090032#include <linux/smsc911x.h>
Kuninori Morimotob82573e2012-10-10 19:57:02 -070033#include <linux/spi/spi.h>
34#include <linux/spi/sh_hspi.h>
Phil Edworthy894cda12012-08-06 13:31:05 +010035#include <linux/mmc/sh_mobile_sdhi.h>
36#include <linux/mfd/tmio.h>
Magnus Dammf411fad2011-12-14 01:36:12 +090037#include <mach/hardware.h>
38#include <mach/r8a7779.h>
39#include <mach/common.h>
Rob Herring250a2722012-01-03 16:57:33 -060040#include <mach/irqs.h>
Magnus Dammf411fad2011-12-14 01:36:12 +090041#include <asm/mach-types.h>
42#include <asm/mach/arch.h>
Magnus Dammf411fad2011-12-14 01:36:12 +090043#include <asm/hardware/gic.h>
44#include <asm/traps.h>
45
Phil Edworthy894cda12012-08-06 13:31:05 +010046/* Fixed 3.3V regulator to be used by SDHI0 */
47static 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 Liakhovetskib354e222012-06-27 00:32:32 +020052/* Dummy supplies, where voltage doesn't matter */
53static struct regulator_consumer_supply dummy_supplies[] = {
54 REGULATOR_SUPPLY("vddvario", "smsc911x"),
55 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
56};
57
Magnus Dammdb5eb992011-12-14 01:36:51 +090058/* SMSC LAN89218 */
59static 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
71static 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
78static struct platform_device eth_device = {
79 .name = "smsc911x",
Kuninori Morimoto497dcf62012-08-29 18:58:01 -070080 .id = -1,
Magnus Dammdb5eb992011-12-14 01:36:51 +090081 .dev = {
82 .platform_data = &smsc911x_platdata,
83 },
84 .resource = smsc911x_resources,
85 .num_resources = ARRAY_SIZE(smsc911x_resources),
86};
87
Phil Edworthy894cda12012-08-06 13:31:05 +010088static 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
101static 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
106static 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 Morimotoeb8ca942012-08-27 19:00:15 -0700116/* Thermal */
117static struct resource thermal_resources[] = {
118 [0] = {
119 .start = 0xFFC48000,
120 .end = 0xFFC48038 - 1,
121 .flags = IORESOURCE_MEM,
122 },
123};
124
125static struct platform_device thermal_device = {
126 .name = "rcar_thermal",
127 .resource = thermal_resources,
128 .num_resources = ARRAY_SIZE(thermal_resources),
129};
130
Kuninori Morimotob82573e2012-10-10 19:57:02 -0700131/* HSPI */
132static struct resource hspi_resources[] = {
133 [0] = {
134 .start = 0xFFFC7000,
135 .end = 0xFFFC7018 - 1,
136 .flags = IORESOURCE_MEM,
137 },
138};
139
140static 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
Magnus Dammf411fad2011-12-14 01:36:12 +0900147static struct platform_device *marzen_devices[] __initdata = {
Magnus Dammdb5eb992011-12-14 01:36:51 +0900148 &eth_device,
Phil Edworthy894cda12012-08-06 13:31:05 +0100149 &sdhi0_device,
Kuninori Morimotoeb8ca942012-08-27 19:00:15 -0700150 &thermal_device,
Kuninori Morimotob82573e2012-10-10 19:57:02 -0700151 &hspi_device,
Magnus Dammf411fad2011-12-14 01:36:12 +0900152};
153
Magnus Dammf411fad2011-12-14 01:36:12 +0900154static void __init marzen_init(void)
155{
Phil Edworthy894cda12012-08-06 13:31:05 +0100156 regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
157 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
Kuninori Morimoto90b85af2012-08-29 18:58:15 -0700158 regulator_register_fixed(1, dummy_supplies,
Phil Edworthy894cda12012-08-06 13:31:05 +0100159 ARRAY_SIZE(dummy_supplies));
Guennadi Liakhovetskib354e222012-06-27 00:32:32 +0200160
Magnus Damm19c43fc2011-12-14 01:36:22 +0900161 r8a7779_pinmux_init();
162
Magnus Damm14f691c2011-12-14 01:36:42 +0900163 /* SCIF2 (CN18: DEBUG0) */
164 gpio_request(GPIO_FN_TX2_C, NULL);
165 gpio_request(GPIO_FN_RX2_C, NULL);
166
167 /* SCIF4 (CN19: DEBUG1) */
168 gpio_request(GPIO_FN_TX4, NULL);
169 gpio_request(GPIO_FN_RX4, NULL);
170
Magnus Dammdb5eb992011-12-14 01:36:51 +0900171 /* LAN89218 */
172 gpio_request(GPIO_FN_EX_CS0, NULL); /* nCS */
173 gpio_request(GPIO_FN_IRQ1_B, NULL); /* IRQ + PME */
174
Phil Edworthy894cda12012-08-06 13:31:05 +0100175 /* SD0 (CN20) */
176 gpio_request(GPIO_FN_SD0_CLK, NULL);
177 gpio_request(GPIO_FN_SD0_CMD, NULL);
178 gpio_request(GPIO_FN_SD0_DAT0, NULL);
179 gpio_request(GPIO_FN_SD0_DAT1, NULL);
180 gpio_request(GPIO_FN_SD0_DAT2, NULL);
181 gpio_request(GPIO_FN_SD0_DAT3, NULL);
182 gpio_request(GPIO_FN_SD0_CD, NULL);
183 gpio_request(GPIO_FN_SD0_WP, NULL);
184
Kuninori Morimotob82573e2012-10-10 19:57:02 -0700185 /* HSPI 0 */
186 gpio_request(GPIO_FN_HSPI_CLK0, NULL);
187 gpio_request(GPIO_FN_HSPI_CS0, NULL);
188 gpio_request(GPIO_FN_HSPI_TX0, NULL);
189 gpio_request(GPIO_FN_HSPI_RX0, NULL);
190
Magnus Dammf411fad2011-12-14 01:36:12 +0900191 r8a7779_add_standard_devices();
192 platform_add_devices(marzen_devices, ARRAY_SIZE(marzen_devices));
193}
194
Magnus Dammf411fad2011-12-14 01:36:12 +0900195MACHINE_START(MARZEN, "marzen")
Marc Zyngiera62580e2011-09-08 13:15:22 +0100196 .smp = smp_ops(r8a7779_smp_ops),
Magnus Damm3e353b872012-02-29 21:37:43 +0900197 .map_io = r8a7779_map_io,
198 .init_early = r8a7779_add_early_devices,
Magnus Dammf411fad2011-12-14 01:36:12 +0900199 .nr_irqs = NR_IRQS_LEGACY,
200 .init_irq = r8a7779_init_irq,
Paul Mundt77761b62012-01-10 13:33:23 +0900201 .handle_irq = gic_handle_irq,
Magnus Dammf411fad2011-12-14 01:36:12 +0900202 .init_machine = marzen_init,
Shawn Guo21cc1b72012-04-26 21:58:41 +0800203 .init_late = shmobile_init_late,
Magnus Dammdf27a2d2012-03-06 17:37:01 +0900204 .timer = &shmobile_timer,
Magnus Dammf411fad2011-12-14 01:36:12 +0900205MACHINE_END