ARM: shmobile: Move r8a7779.h
[deliverable/linux.git] / arch / arm / mach-shmobile / board-marzen.c
CommitLineData
f411fade
MD
1/*
2 * marzen board support
3 *
7cef5e7f 4 * Copyright (C) 2011, 2013 Renesas Solutions Corp.
f411fade 5 * Copyright (C) 2011 Magnus Damm
7cef5e7f 6 * Copyright (C) 2013 Cogent Embedded, Inc.
f411fade
MD
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include <linux/kernel.h>
23#include <linux/init.h>
24#include <linux/interrupt.h>
25#include <linux/irq.h>
26#include <linux/platform_device.h>
27#include <linux/delay.h>
28#include <linux/io.h>
48b1e3e8 29#include <linux/leds.h>
f411fade 30#include <linux/dma-mapping.h>
4a655ecd 31#include <linux/pinctrl/machine.h>
2f3927e8 32#include <linux/platform_data/camera-rcar.h>
5fcf4a3c 33#include <linux/platform_data/gpio-rcar.h>
df83d907 34#include <linux/platform_data/rcar-du.h>
fee529df 35#include <linux/platform_data/usb-rcar-phy.h>
b354e227
GL
36#include <linux/regulator/fixed.h>
37#include <linux/regulator/machine.h>
db5eb994 38#include <linux/smsc911x.h>
b82573e1
KM
39#include <linux/spi/spi.h>
40#include <linux/spi/sh_hspi.h>
44e9ac45 41#include <linux/mmc/host.h>
894cda18
PE
42#include <linux/mmc/sh_mobile_sdhi.h>
43#include <linux/mfd/tmio.h>
1b55353c 44
7cef5e7f 45#include <media/soc_camera.h>
f411fade
MD
46#include <asm/mach-types.h>
47#include <asm/mach/arch.h>
f411fade 48#include <asm/traps.h>
1b55353c 49
fd44aa5e 50#include "common.h"
b6bab126 51#include "irqs.h"
1b55353c 52#include "r8a7779.h"
f411fade 53
894cda18
PE
54/* Fixed 3.3V regulator to be used by SDHI0 */
55static struct regulator_consumer_supply fixed3v3_power_consumers[] = {
56 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
57 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
58};
59
b354e227
GL
60/* Dummy supplies, where voltage doesn't matter */
61static struct regulator_consumer_supply dummy_supplies[] = {
62 REGULATOR_SUPPLY("vddvario", "smsc911x"),
63 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
64};
65
fee529df
KM
66/* USB PHY */
67static struct resource usb_phy_resources[] = {
68 [0] = {
69 .start = 0xffe70800,
70 .end = 0xffe70900 - 1,
71 .flags = IORESOURCE_MEM,
72 },
73};
74
75static struct rcar_phy_platform_data usb_phy_platform_data;
76
77static struct platform_device usb_phy = {
78 .name = "rcar_usb_phy",
79 .id = -1,
80 .dev = {
81 .platform_data = &usb_phy_platform_data,
82 },
83 .resource = usb_phy_resources,
84 .num_resources = ARRAY_SIZE(usb_phy_resources),
85};
2437b27c 86
db5eb994
MD
87/* SMSC LAN89218 */
88static struct resource smsc911x_resources[] = {
89 [0] = {
90 .start = 0x18000000, /* ExCS0 */
91 .end = 0x180000ff, /* A1->A7 */
92 .flags = IORESOURCE_MEM,
93 },
94 [1] = {
6e267030 95 .start = irq_pin(1), /* IRQ 1 */
db5eb994
MD
96 .flags = IORESOURCE_IRQ,
97 },
98};
99
100static struct smsc911x_platform_config smsc911x_platdata = {
101 .flags = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */
102 .phy_interface = PHY_INTERFACE_MODE_MII,
103 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
104 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
105};
106
107static struct platform_device eth_device = {
108 .name = "smsc911x",
497dcf6f 109 .id = -1,
db5eb994
MD
110 .dev = {
111 .platform_data = &smsc911x_platdata,
112 },
113 .resource = smsc911x_resources,
114 .num_resources = ARRAY_SIZE(smsc911x_resources),
115};
116
894cda18
PE
117static struct resource sdhi0_resources[] = {
118 [0] = {
119 .name = "sdhi0",
120 .start = 0xffe4c000,
121 .end = 0xffe4c0ff,
122 .flags = IORESOURCE_MEM,
123 },
124 [1] = {
0b6794ef 125 .start = gic_iid(0x88),
894cda18
PE
126 .flags = IORESOURCE_IRQ,
127 },
128};
129
130static struct sh_mobile_sdhi_info sdhi0_platform_data = {
e6a8b11b
MF
131 .dma_slave_tx = HPBDMA_SLAVE_SDHI0_TX,
132 .dma_slave_rx = HPBDMA_SLAVE_SDHI0_RX,
894cda18
PE
133 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
134 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
135};
136
137static struct platform_device sdhi0_device = {
138 .name = "sh_mobile_sdhi",
139 .num_resources = ARRAY_SIZE(sdhi0_resources),
140 .resource = sdhi0_resources,
141 .id = 0,
142 .dev = {
143 .platform_data = &sdhi0_platform_data,
144 }
145};
146
eb8ca943
KM
147/* Thermal */
148static struct resource thermal_resources[] = {
149 [0] = {
150 .start = 0xFFC48000,
151 .end = 0xFFC48038 - 1,
152 .flags = IORESOURCE_MEM,
153 },
154};
155
156static struct platform_device thermal_device = {
157 .name = "rcar_thermal",
158 .resource = thermal_resources,
159 .num_resources = ARRAY_SIZE(thermal_resources),
160};
161
b82573e1
KM
162/* HSPI */
163static struct resource hspi_resources[] = {
164 [0] = {
165 .start = 0xFFFC7000,
166 .end = 0xFFFC7018 - 1,
167 .flags = IORESOURCE_MEM,
168 },
169};
170
171static struct platform_device hspi_device = {
172 .name = "sh-hspi",
173 .id = 0,
174 .resource = hspi_resources,
175 .num_resources = ARRAY_SIZE(hspi_resources),
176};
177
df83d907
LP
178/*
179 * DU
180 *
181 * The panel only specifies the [hv]display and [hv]total values. The position
182 * and width of the sync pulses don't matter, they're copied from VESA timings.
183 */
184static struct rcar_du_encoder_data du_encoders[] = {
185 {
186 .type = RCAR_DU_ENCODER_VGA,
187 .output = RCAR_DU_OUTPUT_DPAD0,
188 }, {
189 .type = RCAR_DU_ENCODER_LVDS,
190 .output = RCAR_DU_OUTPUT_DPAD1,
191 .connector.lvds.panel = {
192 .width_mm = 210,
193 .height_mm = 158,
194 .mode = {
195 .clock = 65000,
196 .hdisplay = 1024,
197 .hsync_start = 1048,
198 .hsync_end = 1184,
199 .htotal = 1344,
200 .vdisplay = 768,
201 .vsync_start = 771,
202 .vsync_end = 777,
203 .vtotal = 806,
204 .flags = 0,
205 },
206 },
207 },
208};
209
210static const struct rcar_du_platform_data du_pdata __initconst = {
211 .encoders = du_encoders,
212 .num_encoders = ARRAY_SIZE(du_encoders),
213};
214
215static const struct resource du_resources[] __initconst = {
216 DEFINE_RES_MEM(0xfff80000, 0x40000),
217 DEFINE_RES_IRQ(gic_iid(0x3f)),
218};
219
220static void __init marzen_add_du_device(void)
221{
222 struct platform_device_info info = {
223 .name = "rcar-du-r8a7779",
224 .id = -1,
225 .res = du_resources,
226 .num_res = ARRAY_SIZE(du_resources),
227 .data = &du_pdata,
228 .size_data = sizeof(du_pdata),
229 .dma_mask = DMA_BIT_MASK(32),
230 };
231
232 platform_device_register_full(&info);
233}
234
48b1e3e8
LP
235/* LEDS */
236static struct gpio_led marzen_leds[] = {
237 {
238 .name = "led2",
5fcf4a3c 239 .gpio = RCAR_GP_PIN(4, 29),
48b1e3e8
LP
240 .default_state = LEDS_GPIO_DEFSTATE_ON,
241 }, {
242 .name = "led3",
5fcf4a3c 243 .gpio = RCAR_GP_PIN(4, 30),
48b1e3e8
LP
244 .default_state = LEDS_GPIO_DEFSTATE_ON,
245 }, {
246 .name = "led4",
5fcf4a3c 247 .gpio = RCAR_GP_PIN(4, 31),
48b1e3e8
LP
248 .default_state = LEDS_GPIO_DEFSTATE_ON,
249 },
250};
251
252static struct gpio_led_platform_data marzen_leds_pdata = {
253 .leds = marzen_leds,
254 .num_leds = ARRAY_SIZE(marzen_leds),
255};
256
257static struct platform_device leds_device = {
258 .name = "leds-gpio",
259 .id = 0,
260 .dev = {
261 .platform_data = &marzen_leds_pdata,
262 },
263};
264
4bd4c5b3 265/* VIN */
7cef5e7f
VB
266static struct rcar_vin_platform_data vin_platform_data __initdata = {
267 .flags = RCAR_VIN_BT656,
268};
269
4bd4c5b3
KM
270#define MARZEN_VIN(idx) \
271static struct resource vin##idx##_resources[] __initdata = { \
272 DEFINE_RES_MEM(0xffc50000 + 0x1000 * (idx), 0x1000), \
273 DEFINE_RES_IRQ(gic_iid(0x5f + (idx))), \
274}; \
275 \
276static struct platform_device_info vin##idx##_info __initdata = { \
277 .parent = &platform_bus, \
278 .name = "r8a7779-vin", \
279 .id = idx, \
280 .res = vin##idx##_resources, \
281 .num_res = ARRAY_SIZE(vin##idx##_resources), \
282 .dma_mask = DMA_BIT_MASK(32), \
283 .data = &vin_platform_data, \
284 .size_data = sizeof(vin_platform_data), \
285}
286MARZEN_VIN(1);
287MARZEN_VIN(3);
288
7cef5e7f
VB
289#define MARZEN_CAMERA(idx) \
290static struct i2c_board_info camera##idx##_info = { \
291 I2C_BOARD_INFO("adv7180", 0x20 + (idx)), \
292}; \
293 \
294static struct soc_camera_link iclink##idx##_adv7180 = { \
295 .bus_id = 1 + 2 * (idx), \
296 .i2c_adapter_id = 0, \
297 .board_info = &camera##idx##_info, \
298}; \
299 \
300static struct platform_device camera##idx##_device = { \
301 .name = "soc-camera-pdrv", \
302 .id = idx, \
303 .dev = { \
304 .platform_data = &iclink##idx##_adv7180, \
305 }, \
306};
307
308MARZEN_CAMERA(0);
309MARZEN_CAMERA(1);
310
f411fade 311static struct platform_device *marzen_devices[] __initdata = {
db5eb994 312 &eth_device,
894cda18 313 &sdhi0_device,
eb8ca943 314 &thermal_device,
b82573e1 315 &hspi_device,
48b1e3e8 316 &leds_device,
fee529df 317 &usb_phy,
7cef5e7f
VB
318 &camera0_device,
319 &camera1_device,
f411fade
MD
320};
321
4a655ecd 322static const struct pinctrl_map marzen_pinctrl_map[] = {
df83d907
LP
323 /* DU (CN10: ARGB0, CN13: LVDS) */
324 PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7779", "pfc-r8a7779",
325 "du0_rgb888", "du0"),
326 PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7779", "pfc-r8a7779",
327 "du0_sync_1", "du0"),
328 PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7779", "pfc-r8a7779",
329 "du0_clk_out_0", "du0"),
330 PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7779", "pfc-r8a7779",
331 "du1_rgb666", "du1"),
332 PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7779", "pfc-r8a7779",
333 "du1_sync_1", "du1"),
334 PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7779", "pfc-r8a7779",
335 "du1_clk_out", "du1"),
a3217471
LP
336 /* HSPI0 */
337 PIN_MAP_MUX_GROUP_DEFAULT("sh-hspi.0", "pfc-r8a7779",
338 "hspi0", "hspi0"),
e9cd49fa
LP
339 /* SCIF2 (CN18: DEBUG0) */
340 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.2", "pfc-r8a7779",
341 "scif2_data_c", "scif2"),
342 /* SCIF4 (CN19: DEBUG1) */
343 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "pfc-r8a7779",
344 "scif4_data", "scif4"),
4a655ecd
LP
345 /* SDHI0 */
346 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
347 "sdhi0_data4", "sdhi0"),
348 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
349 "sdhi0_ctrl", "sdhi0"),
350 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7779",
351 "sdhi0_cd", "sdhi0"),
f423df8e 352 /* SMSC */
ee097e66
LP
353 PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-r8a7779",
354 "intc_irq1_b", "intc"),
f423df8e
LP
355 PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-r8a7779",
356 "lbsc_ex_cs0", "lbsc"),
a00f6e57
LP
357 /* USB0 */
358 PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.0", "pfc-r8a7779",
359 "usb0", "usb0"),
360 /* USB1 */
361 PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.0", "pfc-r8a7779",
362 "usb1", "usb1"),
363 /* USB2 */
364 PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform.1", "pfc-r8a7779",
365 "usb2", "usb2"),
7cef5e7f
VB
366 /* VIN1 */
367 PIN_MAP_MUX_GROUP_DEFAULT("r8a7779-vin.1", "pfc-r8a7779",
368 "vin1_clk", "vin1"),
369 PIN_MAP_MUX_GROUP_DEFAULT("r8a7779-vin.1", "pfc-r8a7779",
370 "vin1_data8", "vin1"),
371 /* VIN3 */
372 PIN_MAP_MUX_GROUP_DEFAULT("r8a7779-vin.3", "pfc-r8a7779",
373 "vin3_clk", "vin3"),
374 PIN_MAP_MUX_GROUP_DEFAULT("r8a7779-vin.3", "pfc-r8a7779",
375 "vin3_data8", "vin3"),
4a655ecd
LP
376};
377
f411fade
MD
378static void __init marzen_init(void)
379{
894cda18
PE
380 regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
381 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
90b85afc 382 regulator_register_fixed(1, dummy_supplies,
894cda18 383 ARRAY_SIZE(dummy_supplies));
b354e227 384
4a655ecd
LP
385 pinctrl_register_mappings(marzen_pinctrl_map,
386 ARRAY_SIZE(marzen_pinctrl_map));
19c43fc5 387 r8a7779_pinmux_init();
6e267030 388 r8a7779_init_irq_extpin(1); /* IRQ1 as individual interrupt */
19c43fc5 389
f411fade 390 r8a7779_add_standard_devices();
4bd4c5b3
KM
391 platform_device_register_full(&vin1_info);
392 platform_device_register_full(&vin3_info);
f411fade 393 platform_add_devices(marzen_devices, ARRAY_SIZE(marzen_devices));
df83d907 394 marzen_add_du_device();
f411fade
MD
395}
396
7ebbb4ae
MD
397static const char *marzen_boards_compat_dt[] __initdata = {
398 "renesas,marzen",
399 NULL,
400};
401
402DT_MACHINE_START(MARZEN, "marzen")
a62580e5 403 .smp = smp_ops(r8a7779_smp_ops),
3e353b87
MD
404 .map_io = r8a7779_map_io,
405 .init_early = r8a7779_add_early_devices,
693ac41d 406 .init_irq = r8a7779_init_irq_dt,
f411fade 407 .init_machine = marzen_init,
2c8788bf 408 .init_late = r8a7779_init_late,
7ebbb4ae 409 .dt_compat = marzen_boards_compat_dt,
6bb27d73 410 .init_time = r8a7779_earlytimer_init,
f411fade 411MACHINE_END
This page took 0.133177 seconds and 5 git commands to generate.