Merge branch 'dt2' into cleanup3-base
[linux-2.6.git] / arch / arm / mach-shmobile / board-marzen.c
blob3551b5480b47b38fe6ab1b729a2deb3d63d8dce0
1 /*
2 * marzen board support
4 * Copyright (C) 2011 Renesas Solutions Corp.
5 * Copyright (C) 2011 Magnus Damm
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.
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.
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
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>
28 #include <linux/leds.h>
29 #include <linux/dma-mapping.h>
30 #include <linux/pinctrl/machine.h>
31 #include <linux/platform_data/gpio-rcar.h>
32 #include <linux/platform_data/usb-rcar-phy.h>
33 #include <linux/regulator/fixed.h>
34 #include <linux/regulator/machine.h>
35 #include <linux/smsc911x.h>
36 #include <linux/spi/spi.h>
37 #include <linux/spi/sh_hspi.h>
38 #include <linux/mmc/host.h>
39 #include <linux/mmc/sh_mobile_sdhi.h>
40 #include <linux/mfd/tmio.h>
41 #include <mach/r8a7779.h>
42 #include <mach/common.h>
43 #include <mach/irqs.h>
44 #include <asm/mach-types.h>
45 #include <asm/mach/arch.h>
46 #include <asm/traps.h>
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"),
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"),
60 /* USB PHY */
61 static struct resource usb_phy_resources[] = {
62 [0] = {
63 .start = 0xffe70800,
64 .end = 0xffe70900 - 1,
65 .flags = IORESOURCE_MEM,
69 static struct rcar_phy_platform_data usb_phy_platform_data;
71 static struct platform_device usb_phy = {
72 .name = "rcar_usb_phy",
73 .id = -1,
74 .dev = {
75 .platform_data = &usb_phy_platform_data,
77 .resource = usb_phy_resources,
78 .num_resources = ARRAY_SIZE(usb_phy_resources),
81 /* SMSC LAN89218 */
82 static struct resource smsc911x_resources[] = {
83 [0] = {
84 .start = 0x18000000, /* ExCS0 */
85 .end = 0x180000ff, /* A1->A7 */
86 .flags = IORESOURCE_MEM,
88 [1] = {
89 .start = irq_pin(1), /* IRQ 1 */
90 .flags = IORESOURCE_IRQ,
94 static struct smsc911x_platform_config smsc911x_platdata = {
95 .flags = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */
96 .phy_interface = PHY_INTERFACE_MODE_MII,
97 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
98 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
101 static struct platform_device eth_device = {
102 .name = "smsc911x",
103 .id = -1,
104 .dev = {
105 .platform_data = &smsc911x_platdata,
107 .resource = smsc911x_resources,
108 .num_resources = ARRAY_SIZE(smsc911x_resources),
111 static struct resource sdhi0_resources[] = {
112 [0] = {
113 .name = "sdhi0",
114 .start = 0xffe4c000,
115 .end = 0xffe4c0ff,
116 .flags = IORESOURCE_MEM,
118 [1] = {
119 .start = gic_iid(0x88),
120 .flags = IORESOURCE_IRQ,
124 static struct sh_mobile_sdhi_info sdhi0_platform_data = {
125 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
126 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
129 static struct platform_device sdhi0_device = {
130 .name = "sh_mobile_sdhi",
131 .num_resources = ARRAY_SIZE(sdhi0_resources),
132 .resource = sdhi0_resources,
133 .id = 0,
134 .dev = {
135 .platform_data = &sdhi0_platform_data,
139 /* Thermal */
140 static struct resource thermal_resources[] = {
141 [0] = {
142 .start = 0xFFC48000,
143 .end = 0xFFC48038 - 1,
144 .flags = IORESOURCE_MEM,
148 static struct platform_device thermal_device = {
149 .name = "rcar_thermal",
150 .resource = thermal_resources,
151 .num_resources = ARRAY_SIZE(thermal_resources),
154 /* HSPI */
155 static struct resource hspi_resources[] = {
156 [0] = {
157 .start = 0xFFFC7000,
158 .end = 0xFFFC7018 - 1,
159 .flags = IORESOURCE_MEM,
163 static struct platform_device hspi_device = {
164 .name = "sh-hspi",
165 .id = 0,
166 .resource = hspi_resources,
167 .num_resources = ARRAY_SIZE(hspi_resources),
170 /* LEDS */
171 static struct gpio_led marzen_leds[] = {
173 .name = "led2",
174 .gpio = RCAR_GP_PIN(4, 29),
175 .default_state = LEDS_GPIO_DEFSTATE_ON,
176 }, {
177 .name = "led3",
178 .gpio = RCAR_GP_PIN(4, 30),
179 .default_state = LEDS_GPIO_DEFSTATE_ON,
180 }, {
181 .name = "led4",
182 .gpio = RCAR_GP_PIN(4, 31),
183 .default_state = LEDS_GPIO_DEFSTATE_ON,
187 static struct gpio_led_platform_data marzen_leds_pdata = {
188 .leds = marzen_leds,
189 .num_leds = ARRAY_SIZE(marzen_leds),
192 static struct platform_device leds_device = {
193 .name = "leds-gpio",
194 .id = 0,
195 .dev = {
196 .platform_data = &marzen_leds_pdata,
200 static struct platform_device *marzen_devices[] __initdata = {
201 &eth_device,
202 &sdhi0_device,
203 &thermal_device,
204 &hspi_device,
205 &leds_device,
206 &usb_phy,
209 static const struct pinctrl_map marzen_pinctrl_map[] = {
210 /* HSPI0 */
211 PIN_MAP_MUX_GROUP_DEFAULT("sh-hspi.0", "pfc-r8a7779",
212 "hspi0", "hspi0"),
213 /* SCIF2 (CN18: DEBUG0) */
214 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.2", "pfc-r8a7779",
215 "scif2_data_c", "scif2"),
216 /* SCIF4 (CN19: DEBUG1) */
217 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "pfc-r8a7779",
218 "scif4_data", "scif4"),
219 /* SDHI0 */
220 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
221 "sdhi0_data4", "sdhi0"),
222 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
223 "sdhi0_ctrl", "sdhi0"),
224 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
225 "sdhi0_cd", "sdhi0"),
226 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
227 "sdhi0_wp", "sdhi0"),
228 /* SMSC */
229 PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-r8a7779",
230 "intc_irq1_b", "intc"),
231 PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-r8a7779",
232 "lbsc_ex_cs0", "lbsc"),
233 /* USB0 */
234 PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.0", "pfc-r8a7779",
235 "usb0", "usb0"),
236 /* USB1 */
237 PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.0", "pfc-r8a7779",
238 "usb1", "usb1"),
239 /* USB2 */
240 PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.1", "pfc-r8a7779",
241 "usb2", "usb2"),
244 static void __init marzen_init(void)
246 regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
247 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
248 regulator_register_fixed(1, dummy_supplies,
249 ARRAY_SIZE(dummy_supplies));
251 pinctrl_register_mappings(marzen_pinctrl_map,
252 ARRAY_SIZE(marzen_pinctrl_map));
253 r8a7779_pinmux_init();
254 r8a7779_init_irq_extpin(1); /* IRQ1 as individual interrupt */
256 r8a7779_add_standard_devices();
257 platform_add_devices(marzen_devices, ARRAY_SIZE(marzen_devices));
260 static const char *marzen_boards_compat_dt[] __initdata = {
261 "renesas,marzen",
262 NULL,
265 DT_MACHINE_START(MARZEN, "marzen")
266 .smp = smp_ops(r8a7779_smp_ops),
267 .map_io = r8a7779_map_io,
268 .init_early = r8a7779_add_early_devices,
269 .init_irq = r8a7779_init_irq_dt,
270 .init_machine = marzen_init,
271 .init_late = r8a7779_init_late,
272 .dt_compat = marzen_boards_compat_dt,
273 .init_time = r8a7779_earlytimer_init,
274 MACHINE_END