aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-shmobile/board-koelsch.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-shmobile/board-koelsch.c')
-rw-r--r--arch/arm/mach-shmobile/board-koelsch.c305
1 files changed, 300 insertions, 5 deletions
diff --git a/arch/arm/mach-shmobile/board-koelsch.c b/arch/arm/mach-shmobile/board-koelsch.c
index de7cc64b1f37..5a034ff405d0 100644
--- a/arch/arm/mach-shmobile/board-koelsch.c
+++ b/arch/arm/mach-shmobile/board-koelsch.c
@@ -2,8 +2,9 @@
2 * Koelsch board support 2 * Koelsch board support
3 * 3 *
4 * Copyright (C) 2013 Renesas Electronics Corporation 4 * Copyright (C) 2013 Renesas Electronics Corporation
5 * Copyright (C) 2013 Renesas Solutions Corp. 5 * Copyright (C) 2013-2014 Renesas Solutions Corp.
6 * Copyright (C) 2013 Magnus Damm 6 * Copyright (C) 2013 Magnus Damm
7 * Copyright (C) 2014 Cogent Embedded, Inc.
7 * 8 *
8 * This program is free software; you can redistribute it and/or modify 9 * 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 * it under the terms of the GNU General Public License as published by
@@ -23,14 +24,27 @@
23#include <linux/gpio.h> 24#include <linux/gpio.h>
24#include <linux/gpio_keys.h> 25#include <linux/gpio_keys.h>
25#include <linux/input.h> 26#include <linux/input.h>
27#include <linux/irq.h>
26#include <linux/kernel.h> 28#include <linux/kernel.h>
27#include <linux/leds.h> 29#include <linux/leds.h>
30#include <linux/mfd/tmio.h>
31#include <linux/mmc/host.h>
32#include <linux/mmc/sh_mobile_sdhi.h>
33#include <linux/mtd/mtd.h>
34#include <linux/mtd/partitions.h>
28#include <linux/phy.h> 35#include <linux/phy.h>
29#include <linux/pinctrl/machine.h> 36#include <linux/pinctrl/machine.h>
30#include <linux/platform_data/gpio-rcar.h> 37#include <linux/platform_data/gpio-rcar.h>
31#include <linux/platform_data/rcar-du.h> 38#include <linux/platform_data/rcar-du.h>
32#include <linux/platform_device.h> 39#include <linux/platform_device.h>
40#include <linux/regulator/driver.h>
41#include <linux/regulator/fixed.h>
42#include <linux/regulator/gpio-regulator.h>
43#include <linux/regulator/machine.h>
33#include <linux/sh_eth.h> 44#include <linux/sh_eth.h>
45#include <linux/spi/flash.h>
46#include <linux/spi/rspi.h>
47#include <linux/spi/spi.h>
34#include <mach/common.h> 48#include <mach/common.h>
35#include <mach/irqs.h> 49#include <mach/irqs.h>
36#include <mach/r8a7791.h> 50#include <mach/r8a7791.h>
@@ -92,6 +106,7 @@ static void __init koelsch_add_du_device(void)
92/* Ether */ 106/* Ether */
93static const struct sh_eth_plat_data ether_pdata __initconst = { 107static const struct sh_eth_plat_data ether_pdata __initconst = {
94 .phy = 0x1, 108 .phy = 0x1,
109 .phy_irq = irq_pin(0),
95 .edmac_endian = EDMAC_LITTLE_ENDIAN, 110 .edmac_endian = EDMAC_LITTLE_ENDIAN,
96 .phy_interface = PHY_INTERFACE_MODE_RMII, 111 .phy_interface = PHY_INTERFACE_MODE_RMII,
97 .ether_link_active_low = 1, 112 .ether_link_active_low = 1,
@@ -102,6 +117,17 @@ static const struct resource ether_resources[] __initconst = {
102 DEFINE_RES_IRQ(gic_spi(162)), 117 DEFINE_RES_IRQ(gic_spi(162)),
103}; 118};
104 119
120static const struct platform_device_info ether_info __initconst = {
121 .parent = &platform_bus,
122 .name = "r8a7791-ether",
123 .id = -1,
124 .res = ether_resources,
125 .num_res = ARRAY_SIZE(ether_resources),
126 .data = &ether_pdata,
127 .size_data = sizeof(ether_pdata),
128 .dma_mask = DMA_BIT_MASK(32),
129};
130
105/* LEDS */ 131/* LEDS */
106static struct gpio_led koelsch_leds[] = { 132static struct gpio_led koelsch_leds[] = {
107 { 133 {
@@ -148,6 +174,199 @@ static const struct gpio_keys_platform_data koelsch_keys_pdata __initconst = {
148 .nbuttons = ARRAY_SIZE(gpio_buttons), 174 .nbuttons = ARRAY_SIZE(gpio_buttons),
149}; 175};
150 176
177/* QSPI */
178static const struct resource qspi_resources[] __initconst = {
179 DEFINE_RES_MEM(0xe6b10000, 0x1000),
180 DEFINE_RES_IRQ_NAMED(gic_spi(184), "mux"),
181};
182
183static const struct rspi_plat_data qspi_pdata __initconst = {
184 .num_chipselect = 1,
185};
186
187/* SPI Flash memory (Spansion S25FL512SAGMFIG11 64 MiB) */
188static struct mtd_partition spi_flash_part[] = {
189 {
190 .name = "loader",
191 .offset = 0x00000000,
192 .size = 512 * 1024,
193 .mask_flags = MTD_WRITEABLE,
194 },
195 {
196 .name = "bootenv",
197 .offset = MTDPART_OFS_APPEND,
198 .size = 512 * 1024,
199 .mask_flags = MTD_WRITEABLE,
200 },
201 {
202 .name = "data",
203 .offset = MTDPART_OFS_APPEND,
204 .size = MTDPART_SIZ_FULL,
205 },
206};
207
208static const struct flash_platform_data spi_flash_data = {
209 .name = "m25p80",
210 .parts = spi_flash_part,
211 .nr_parts = ARRAY_SIZE(spi_flash_part),
212 .type = "s25fl512s",
213};
214
215static const struct spi_board_info spi_info[] __initconst = {
216 {
217 .modalias = "m25p80",
218 .platform_data = &spi_flash_data,
219 .mode = SPI_MODE_0,
220 .max_speed_hz = 30000000,
221 .bus_num = 0,
222 .chip_select = 0,
223 },
224};
225
226/* SATA0 */
227static const struct resource sata0_resources[] __initconst = {
228 DEFINE_RES_MEM(0xee300000, 0x2000),
229 DEFINE_RES_IRQ(gic_spi(105)),
230};
231
232static const struct platform_device_info sata0_info __initconst = {
233 .parent = &platform_bus,
234 .name = "sata-r8a7791",
235 .id = 0,
236 .res = sata0_resources,
237 .num_res = ARRAY_SIZE(sata0_resources),
238 .dma_mask = DMA_BIT_MASK(32),
239};
240
241/* I2C */
242static const struct resource i2c_resources[] __initconst = {
243 /* I2C0 */
244 DEFINE_RES_MEM(0xE6508000, 0x40),
245 DEFINE_RES_IRQ(gic_spi(287)),
246 /* I2C1 */
247 DEFINE_RES_MEM(0xE6518000, 0x40),
248 DEFINE_RES_IRQ(gic_spi(288)),
249 /* I2C2 */
250 DEFINE_RES_MEM(0xE6530000, 0x40),
251 DEFINE_RES_IRQ(gic_spi(286)),
252 /* I2C3 */
253 DEFINE_RES_MEM(0xE6540000, 0x40),
254 DEFINE_RES_IRQ(gic_spi(290)),
255 /* I2C4 */
256 DEFINE_RES_MEM(0xE6520000, 0x40),
257 DEFINE_RES_IRQ(gic_spi(19)),
258 /* I2C5 */
259 DEFINE_RES_MEM(0xE6528000, 0x40),
260 DEFINE_RES_IRQ(gic_spi(20)),
261};
262
263static void __init koelsch_add_i2c(unsigned idx)
264{
265 unsigned res_idx = idx * 2;
266
267 BUG_ON(res_idx >= ARRAY_SIZE(i2c_resources));
268
269 platform_device_register_simple("i2c-rcar_gen2", idx,
270 i2c_resources + res_idx, 2);
271}
272
273#define SDHI_REGULATOR(idx, vdd_pin, vccq_pin) \
274static struct regulator_consumer_supply vcc_sdhi##idx##_consumer = \
275 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi." #idx); \
276 \
277static struct regulator_init_data vcc_sdhi##idx##_init_data = { \
278 .constraints = { \
279 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
280 }, \
281 .consumer_supplies = &vcc_sdhi##idx##_consumer, \
282 .num_consumer_supplies = 1, \
283}; \
284 \
285static const struct fixed_voltage_config vcc_sdhi##idx##_info __initconst = {\
286 .supply_name = "SDHI" #idx "Vcc", \
287 .microvolts = 3300000, \
288 .gpio = vdd_pin, \
289 .enable_high = 1, \
290 .init_data = &vcc_sdhi##idx##_init_data, \
291}; \
292 \
293static struct regulator_consumer_supply vccq_sdhi##idx##_consumer = \
294 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi." #idx); \
295 \
296static struct regulator_init_data vccq_sdhi##idx##_init_data = { \
297 .constraints = { \
298 .input_uV = 3300000, \
299 .min_uV = 1800000, \
300 .max_uV = 3300000, \
301 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | \
302 REGULATOR_CHANGE_STATUS, \
303 }, \
304 .consumer_supplies = &vccq_sdhi##idx##_consumer, \
305 .num_consumer_supplies = 1, \
306}; \
307 \
308static struct gpio vccq_sdhi##idx##_gpio = \
309 { vccq_pin, GPIOF_OUT_INIT_HIGH, "vccq-sdhi" #idx }; \
310 \
311static struct gpio_regulator_state vccq_sdhi##idx##_states[] = { \
312 { .value = 1800000, .gpios = 0 }, \
313 { .value = 3300000, .gpios = 1 }, \
314}; \
315 \
316static const struct gpio_regulator_config vccq_sdhi##idx##_info __initconst = {\
317 .supply_name = "vqmmc", \
318 .gpios = &vccq_sdhi##idx##_gpio, \
319 .nr_gpios = 1, \
320 .states = vccq_sdhi##idx##_states, \
321 .nr_states = ARRAY_SIZE(vccq_sdhi##idx##_states), \
322 .type = REGULATOR_VOLTAGE, \
323 .init_data = &vccq_sdhi##idx##_init_data, \
324};
325
326SDHI_REGULATOR(0, RCAR_GP_PIN(7, 17), RCAR_GP_PIN(2, 12));
327SDHI_REGULATOR(1, RCAR_GP_PIN(7, 18), RCAR_GP_PIN(2, 13));
328SDHI_REGULATOR(2, RCAR_GP_PIN(7, 19), RCAR_GP_PIN(2, 26));
329
330/* SDHI0 */
331static struct sh_mobile_sdhi_info sdhi0_info __initdata = {
332 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
333 MMC_CAP_POWER_OFF_CARD,
334 .tmio_caps2 = MMC_CAP2_NO_MULTI_READ,
335 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
336};
337
338static struct resource sdhi0_resources[] __initdata = {
339 DEFINE_RES_MEM(0xee100000, 0x200),
340 DEFINE_RES_IRQ(gic_spi(165)),
341};
342
343/* SDHI1 */
344static struct sh_mobile_sdhi_info sdhi1_info __initdata = {
345 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
346 MMC_CAP_POWER_OFF_CARD,
347 .tmio_caps2 = MMC_CAP2_NO_MULTI_READ,
348 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
349};
350
351static struct resource sdhi1_resources[] __initdata = {
352 DEFINE_RES_MEM(0xee140000, 0x100),
353 DEFINE_RES_IRQ(gic_spi(167)),
354};
355
356/* SDHI2 */
357static struct sh_mobile_sdhi_info sdhi2_info __initdata = {
358 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
359 MMC_CAP_POWER_OFF_CARD,
360 .tmio_caps2 = MMC_CAP2_NO_MULTI_READ,
361 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT |
362 TMIO_MMC_WRPROTECT_DISABLE,
363};
364
365static struct resource sdhi2_resources[] __initdata = {
366 DEFINE_RES_MEM(0xee160000, 0x100),
367 DEFINE_RES_IRQ(gic_spi(168)),
368};
369
151static const struct pinctrl_map koelsch_pinctrl_map[] = { 370static const struct pinctrl_map koelsch_pinctrl_map[] = {
152 /* DU */ 371 /* DU */
153 PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7791", "pfc-r8a7791", 372 PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7791", "pfc-r8a7791",
@@ -165,12 +384,51 @@ static const struct pinctrl_map koelsch_pinctrl_map[] = {
165 "eth_rmii", "eth"), 384 "eth_rmii", "eth"),
166 PIN_MAP_MUX_GROUP_DEFAULT("r8a7791-ether", "pfc-r8a7791", 385 PIN_MAP_MUX_GROUP_DEFAULT("r8a7791-ether", "pfc-r8a7791",
167 "intc_irq0", "intc"), 386 "intc_irq0", "intc"),
387 /* QSPI */
388 PIN_MAP_MUX_GROUP_DEFAULT("qspi.0", "pfc-r8a7791",
389 "qspi_ctrl", "qspi"),
390 PIN_MAP_MUX_GROUP_DEFAULT("qspi.0", "pfc-r8a7791",
391 "qspi_data4", "qspi"),
168 /* SCIF0 (CN19: DEBUG SERIAL0) */ 392 /* SCIF0 (CN19: DEBUG SERIAL0) */
169 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.6", "pfc-r8a7791", 393 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.6", "pfc-r8a7791",
170 "scif0_data_d", "scif0"), 394 "scif0_data_d", "scif0"),
171 /* SCIF1 (CN20: DEBUG SERIAL1) */ 395 /* SCIF1 (CN20: DEBUG SERIAL1) */
172 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.7", "pfc-r8a7791", 396 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.7", "pfc-r8a7791",
173 "scif1_data_d", "scif1"), 397 "scif1_data_d", "scif1"),
398 /* I2C1 */
399 PIN_MAP_MUX_GROUP_DEFAULT("i2c-rcar_gen2.1", "pfc-r8a7791",
400 "i2c1_e", "i2c1"),
401 /* I2C2 */
402 PIN_MAP_MUX_GROUP_DEFAULT("i2c-rcar_gen2.2", "pfc-r8a7791",
403 "i2c2", "i2c2"),
404 /* I2C4 */
405 PIN_MAP_MUX_GROUP_DEFAULT("i2c-rcar_gen2.4", "pfc-r8a7791",
406 "i2c4_c", "i2c4"),
407 /* SDHI0 */
408 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7791",
409 "sdhi0_data4", "sdhi0"),
410 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7791",
411 "sdhi0_ctrl", "sdhi0"),
412 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7791",
413 "sdhi0_cd", "sdhi0"),
414 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7791",
415 "sdhi0_wp", "sdhi0"),
416 /* SDHI2 */
417 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7791",
418 "sdhi1_data4", "sdhi1"),
419 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7791",
420 "sdhi1_ctrl", "sdhi1"),
421 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7791",
422 "sdhi1_cd", "sdhi1"),
423 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7791",
424 "sdhi1_wp", "sdhi1"),
425 /* SDHI2 */
426 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-r8a7791",
427 "sdhi2_data4", "sdhi2"),
428 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-r8a7791",
429 "sdhi2_ctrl", "sdhi2"),
430 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-r8a7791",
431 "sdhi2_cd", "sdhi2"),
174}; 432};
175 433
176static void __init koelsch_add_standard_devices(void) 434static void __init koelsch_add_standard_devices(void)
@@ -180,18 +438,53 @@ static void __init koelsch_add_standard_devices(void)
180 ARRAY_SIZE(koelsch_pinctrl_map)); 438 ARRAY_SIZE(koelsch_pinctrl_map));
181 r8a7791_pinmux_init(); 439 r8a7791_pinmux_init();
182 r8a7791_add_standard_devices(); 440 r8a7791_add_standard_devices();
183 platform_device_register_resndata(&platform_bus, "r8a7791-ether", -1, 441 platform_device_register_full(&ether_info);
184 ether_resources,
185 ARRAY_SIZE(ether_resources),
186 &ether_pdata, sizeof(ether_pdata));
187 platform_device_register_data(&platform_bus, "leds-gpio", -1, 442 platform_device_register_data(&platform_bus, "leds-gpio", -1,
188 &koelsch_leds_pdata, 443 &koelsch_leds_pdata,
189 sizeof(koelsch_leds_pdata)); 444 sizeof(koelsch_leds_pdata));
190 platform_device_register_data(&platform_bus, "gpio-keys", -1, 445 platform_device_register_data(&platform_bus, "gpio-keys", -1,
191 &koelsch_keys_pdata, 446 &koelsch_keys_pdata,
192 sizeof(koelsch_keys_pdata)); 447 sizeof(koelsch_keys_pdata));
448 platform_device_register_resndata(&platform_bus, "qspi", 0,
449 qspi_resources,
450 ARRAY_SIZE(qspi_resources),
451 &qspi_pdata, sizeof(qspi_pdata));
452 spi_register_board_info(spi_info, ARRAY_SIZE(spi_info));
193 453
194 koelsch_add_du_device(); 454 koelsch_add_du_device();
455
456 platform_device_register_full(&sata0_info);
457
458 koelsch_add_i2c(1);
459 koelsch_add_i2c(2);
460 koelsch_add_i2c(4);
461 koelsch_add_i2c(5);
462
463 platform_device_register_data(&platform_bus, "reg-fixed-voltage", 0,
464 &vcc_sdhi0_info, sizeof(struct fixed_voltage_config));
465 platform_device_register_data(&platform_bus, "reg-fixed-voltage", 1,
466 &vcc_sdhi1_info, sizeof(struct fixed_voltage_config));
467 platform_device_register_data(&platform_bus, "reg-fixed-voltage", 2,
468 &vcc_sdhi2_info, sizeof(struct fixed_voltage_config));
469 platform_device_register_data(&platform_bus, "gpio-regulator", 0,
470 &vccq_sdhi0_info, sizeof(struct gpio_regulator_config));
471 platform_device_register_data(&platform_bus, "gpio-regulator", 1,
472 &vccq_sdhi1_info, sizeof(struct gpio_regulator_config));
473 platform_device_register_data(&platform_bus, "gpio-regulator", 2,
474 &vccq_sdhi2_info, sizeof(struct gpio_regulator_config));
475
476 platform_device_register_resndata(&platform_bus, "sh_mobile_sdhi", 0,
477 sdhi0_resources, ARRAY_SIZE(sdhi0_resources),
478 &sdhi0_info, sizeof(struct sh_mobile_sdhi_info));
479
480 platform_device_register_resndata(&platform_bus, "sh_mobile_sdhi", 1,
481 sdhi1_resources, ARRAY_SIZE(sdhi1_resources),
482 &sdhi1_info, sizeof(struct sh_mobile_sdhi_info));
483
484 platform_device_register_resndata(&platform_bus, "sh_mobile_sdhi", 2,
485 sdhi2_resources, ARRAY_SIZE(sdhi2_resources),
486 &sdhi2_info, sizeof(struct sh_mobile_sdhi_info));
487
195} 488}
196 489
197/* 490/*
@@ -215,6 +508,8 @@ static void __init koelsch_init(void)
215{ 508{
216 koelsch_add_standard_devices(); 509 koelsch_add_standard_devices();
217 510
511 irq_set_irq_type(irq_pin(0), IRQ_TYPE_LEVEL_LOW);
512
218 if (IS_ENABLED(CONFIG_PHYLIB)) 513 if (IS_ENABLED(CONFIG_PHYLIB))
219 phy_register_fixup_for_id("r8a7791-ether-ff:01", 514 phy_register_fixup_for_id("r8a7791-ether-ff:01",
220 koelsch_ksz8041_fixup); 515 koelsch_ksz8041_fixup);