Commit | Line | Data |
---|---|---|
1f52c659 HN |
1 | /* |
2 | * Koelsch board support | |
3 | * | |
4 | * Copyright (C) 2013 Renesas Electronics Corporation | |
379bfd71 | 5 | * Copyright (C) 2013-2014 Renesas Solutions Corp. |
1f52c659 | 6 | * Copyright (C) 2013 Magnus Damm |
379bfd71 | 7 | * Copyright (C) 2014 Cogent Embedded, Inc. |
1f52c659 HN |
8 | * |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; version 2 of the License. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program; if not, write to the Free Software | |
20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
21 | */ | |
22 | ||
784c33a0 | 23 | #include <linux/dma-mapping.h> |
721319d1 MD |
24 | #include <linux/gpio.h> |
25 | #include <linux/gpio_keys.h> | |
26 | #include <linux/input.h> | |
29d9f010 | 27 | #include <linux/irq.h> |
1f52c659 | 28 | #include <linux/kernel.h> |
87a2934e | 29 | #include <linux/leds.h> |
d12e699f MD |
30 | #include <linux/mfd/tmio.h> |
31 | #include <linux/mmc/host.h> | |
32 | #include <linux/mmc/sh_mobile_sdhi.h> | |
bcca4e8e GU |
33 | #include <linux/mtd/mtd.h> |
34 | #include <linux/mtd/partitions.h> | |
974faba7 | 35 | #include <linux/phy.h> |
85ef14da | 36 | #include <linux/pinctrl/machine.h> |
87a2934e | 37 | #include <linux/platform_data/gpio-rcar.h> |
784c33a0 | 38 | #include <linux/platform_data/rcar-du.h> |
1f52c659 | 39 | #include <linux/platform_device.h> |
d12e699f MD |
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> | |
974faba7 | 44 | #include <linux/sh_eth.h> |
bcca4e8e GU |
45 | #include <linux/spi/flash.h> |
46 | #include <linux/spi/rspi.h> | |
47 | #include <linux/spi/spi.h> | |
5201b5a7 | 48 | |
1f52c659 HN |
49 | #include <asm/mach-types.h> |
50 | #include <asm/mach/arch.h> | |
5201b5a7 | 51 | |
fd44aa5e | 52 | #include "common.h" |
b6bab126 | 53 | #include "irqs.h" |
5201b5a7 | 54 | #include "r8a7791.h" |
62872989 | 55 | #include "rcar-gen2.h" |
1f52c659 | 56 | |
784c33a0 LP |
57 | /* DU */ |
58 | static struct rcar_du_encoder_data koelsch_du_encoders[] = { | |
59 | { | |
60 | .type = RCAR_DU_ENCODER_NONE, | |
61 | .output = RCAR_DU_OUTPUT_LVDS0, | |
62 | .connector.lvds.panel = { | |
63 | .width_mm = 210, | |
64 | .height_mm = 158, | |
65 | .mode = { | |
66 | .clock = 65000, | |
67 | .hdisplay = 1024, | |
68 | .hsync_start = 1048, | |
69 | .hsync_end = 1184, | |
70 | .htotal = 1344, | |
71 | .vdisplay = 768, | |
72 | .vsync_start = 771, | |
73 | .vsync_end = 777, | |
74 | .vtotal = 806, | |
75 | .flags = 0, | |
76 | }, | |
77 | }, | |
78 | }, | |
79 | }; | |
80 | ||
81 | static const struct rcar_du_platform_data koelsch_du_pdata __initconst = { | |
82 | .encoders = koelsch_du_encoders, | |
83 | .num_encoders = ARRAY_SIZE(koelsch_du_encoders), | |
84 | }; | |
85 | ||
86 | static const struct resource du_resources[] __initconst = { | |
87 | DEFINE_RES_MEM(0xfeb00000, 0x40000), | |
88 | DEFINE_RES_MEM_NAMED(0xfeb90000, 0x1c, "lvds.0"), | |
89 | DEFINE_RES_IRQ(gic_spi(256)), | |
90 | DEFINE_RES_IRQ(gic_spi(268)), | |
91 | }; | |
92 | ||
93 | static void __init koelsch_add_du_device(void) | |
94 | { | |
95 | struct platform_device_info info = { | |
96 | .name = "rcar-du-r8a7791", | |
97 | .id = -1, | |
98 | .res = du_resources, | |
99 | .num_res = ARRAY_SIZE(du_resources), | |
100 | .data = &koelsch_du_pdata, | |
101 | .size_data = sizeof(koelsch_du_pdata), | |
102 | .dma_mask = DMA_BIT_MASK(32), | |
103 | }; | |
104 | ||
105 | platform_device_register_full(&info); | |
106 | } | |
107 | ||
974faba7 SS |
108 | /* Ether */ |
109 | static const struct sh_eth_plat_data ether_pdata __initconst = { | |
110 | .phy = 0x1, | |
29d9f010 | 111 | .phy_irq = irq_pin(0), |
974faba7 SS |
112 | .edmac_endian = EDMAC_LITTLE_ENDIAN, |
113 | .phy_interface = PHY_INTERFACE_MODE_RMII, | |
114 | .ether_link_active_low = 1, | |
115 | }; | |
116 | ||
117 | static const struct resource ether_resources[] __initconst = { | |
118 | DEFINE_RES_MEM(0xee700000, 0x400), | |
119 | DEFINE_RES_IRQ(gic_spi(162)), | |
120 | }; | |
121 | ||
379bfd71 | 122 | static const struct platform_device_info ether_info __initconst = { |
379bfd71 SS |
123 | .name = "r8a7791-ether", |
124 | .id = -1, | |
125 | .res = ether_resources, | |
126 | .num_res = ARRAY_SIZE(ether_resources), | |
127 | .data = ðer_pdata, | |
128 | .size_data = sizeof(ether_pdata), | |
129 | .dma_mask = DMA_BIT_MASK(32), | |
130 | }; | |
131 | ||
87a2934e MD |
132 | /* LEDS */ |
133 | static struct gpio_led koelsch_leds[] = { | |
134 | { | |
135 | .name = "led8", | |
136 | .gpio = RCAR_GP_PIN(2, 21), | |
137 | .default_state = LEDS_GPIO_DEFSTATE_ON, | |
138 | }, { | |
139 | .name = "led7", | |
140 | .gpio = RCAR_GP_PIN(2, 20), | |
141 | .default_state = LEDS_GPIO_DEFSTATE_ON, | |
142 | }, { | |
143 | .name = "led6", | |
144 | .gpio = RCAR_GP_PIN(2, 19), | |
145 | .default_state = LEDS_GPIO_DEFSTATE_ON, | |
146 | }, | |
147 | }; | |
148 | ||
149 | static const struct gpio_led_platform_data koelsch_leds_pdata __initconst = { | |
150 | .leds = koelsch_leds, | |
151 | .num_leds = ARRAY_SIZE(koelsch_leds), | |
152 | }; | |
153 | ||
721319d1 MD |
154 | /* GPIO KEY */ |
155 | #define GPIO_KEY(c, g, d, ...) \ | |
478e2f9c | 156 | { .code = c, .gpio = g, .desc = d, .active_low = 1, \ |
e209456e | 157 | .wakeup = 1, .debounce_interval = 20 } |
721319d1 MD |
158 | |
159 | static struct gpio_keys_button gpio_buttons[] = { | |
160 | GPIO_KEY(KEY_4, RCAR_GP_PIN(5, 3), "SW2-pin4"), | |
161 | GPIO_KEY(KEY_3, RCAR_GP_PIN(5, 2), "SW2-pin3"), | |
162 | GPIO_KEY(KEY_2, RCAR_GP_PIN(5, 1), "SW2-pin2"), | |
163 | GPIO_KEY(KEY_1, RCAR_GP_PIN(5, 0), "SW2-pin1"), | |
159a282d MD |
164 | GPIO_KEY(KEY_G, RCAR_GP_PIN(7, 6), "SW36"), |
165 | GPIO_KEY(KEY_F, RCAR_GP_PIN(7, 5), "SW35"), | |
166 | GPIO_KEY(KEY_E, RCAR_GP_PIN(7, 4), "SW34"), | |
167 | GPIO_KEY(KEY_D, RCAR_GP_PIN(7, 3), "SW33"), | |
168 | GPIO_KEY(KEY_C, RCAR_GP_PIN(7, 2), "SW32"), | |
169 | GPIO_KEY(KEY_B, RCAR_GP_PIN(7, 1), "SW31"), | |
170 | GPIO_KEY(KEY_A, RCAR_GP_PIN(7, 0), "SW30"), | |
721319d1 MD |
171 | }; |
172 | ||
173 | static const struct gpio_keys_platform_data koelsch_keys_pdata __initconst = { | |
174 | .buttons = gpio_buttons, | |
175 | .nbuttons = ARRAY_SIZE(gpio_buttons), | |
176 | }; | |
177 | ||
bcca4e8e GU |
178 | /* QSPI */ |
179 | static const struct resource qspi_resources[] __initconst = { | |
180 | DEFINE_RES_MEM(0xe6b10000, 0x1000), | |
181 | DEFINE_RES_IRQ_NAMED(gic_spi(184), "mux"), | |
182 | }; | |
183 | ||
184 | static const struct rspi_plat_data qspi_pdata __initconst = { | |
185 | .num_chipselect = 1, | |
186 | }; | |
187 | ||
188 | /* SPI Flash memory (Spansion S25FL512SAGMFIG11 64 MiB) */ | |
189 | static struct mtd_partition spi_flash_part[] = { | |
190 | { | |
191 | .name = "loader", | |
192 | .offset = 0x00000000, | |
193 | .size = 512 * 1024, | |
194 | .mask_flags = MTD_WRITEABLE, | |
195 | }, | |
196 | { | |
197 | .name = "bootenv", | |
198 | .offset = MTDPART_OFS_APPEND, | |
199 | .size = 512 * 1024, | |
200 | .mask_flags = MTD_WRITEABLE, | |
201 | }, | |
202 | { | |
203 | .name = "data", | |
204 | .offset = MTDPART_OFS_APPEND, | |
205 | .size = MTDPART_SIZ_FULL, | |
206 | }, | |
207 | }; | |
208 | ||
209 | static const struct flash_platform_data spi_flash_data = { | |
210 | .name = "m25p80", | |
211 | .parts = spi_flash_part, | |
212 | .nr_parts = ARRAY_SIZE(spi_flash_part), | |
213 | .type = "s25fl512s", | |
214 | }; | |
215 | ||
216 | static const struct spi_board_info spi_info[] __initconst = { | |
217 | { | |
218 | .modalias = "m25p80", | |
219 | .platform_data = &spi_flash_data, | |
4d4a0ff3 | 220 | .mode = SPI_MODE_0 | SPI_TX_QUAD | SPI_RX_QUAD, |
bcca4e8e GU |
221 | .max_speed_hz = 30000000, |
222 | .bus_num = 0, | |
223 | .chip_select = 0, | |
224 | }, | |
225 | }; | |
226 | ||
4fc0a0b9 VB |
227 | /* SATA0 */ |
228 | static const struct resource sata0_resources[] __initconst = { | |
229 | DEFINE_RES_MEM(0xee300000, 0x2000), | |
230 | DEFINE_RES_IRQ(gic_spi(105)), | |
231 | }; | |
232 | ||
233 | static const struct platform_device_info sata0_info __initconst = { | |
4fc0a0b9 VB |
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 | ||
12c1d5a5 VB |
241 | /* I2C */ |
242 | static 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 | ||
263 | static 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 | ||
d12e699f MD |
273 | #define SDHI_REGULATOR(idx, vdd_pin, vccq_pin) \ |
274 | static struct regulator_consumer_supply vcc_sdhi##idx##_consumer = \ | |
275 | REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi." #idx); \ | |
276 | \ | |
277 | static 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 | \ | |
285 | static 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 | \ | |
293 | static struct regulator_consumer_supply vccq_sdhi##idx##_consumer = \ | |
294 | REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi." #idx); \ | |
295 | \ | |
296 | static 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 | \ | |
308 | static struct gpio vccq_sdhi##idx##_gpio = \ | |
309 | { vccq_pin, GPIOF_OUT_INIT_HIGH, "vccq-sdhi" #idx }; \ | |
310 | \ | |
311 | static struct gpio_regulator_state vccq_sdhi##idx##_states[] = { \ | |
312 | { .value = 1800000, .gpios = 0 }, \ | |
313 | { .value = 3300000, .gpios = 1 }, \ | |
314 | }; \ | |
315 | \ | |
316 | static 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 | ||
326 | SDHI_REGULATOR(0, RCAR_GP_PIN(7, 17), RCAR_GP_PIN(2, 12)); | |
327 | SDHI_REGULATOR(1, RCAR_GP_PIN(7, 18), RCAR_GP_PIN(2, 13)); | |
328 | SDHI_REGULATOR(2, RCAR_GP_PIN(7, 19), RCAR_GP_PIN(2, 26)); | |
329 | ||
330 | /* SDHI0 */ | |
331 | static 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, | |
d12e699f MD |
334 | .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT, |
335 | }; | |
336 | ||
337 | static struct resource sdhi0_resources[] __initdata = { | |
338 | DEFINE_RES_MEM(0xee100000, 0x200), | |
339 | DEFINE_RES_IRQ(gic_spi(165)), | |
340 | }; | |
341 | ||
342 | /* SDHI1 */ | |
343 | static struct sh_mobile_sdhi_info sdhi1_info __initdata = { | |
344 | .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ | | |
345 | MMC_CAP_POWER_OFF_CARD, | |
d12e699f MD |
346 | .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT, |
347 | }; | |
348 | ||
349 | static struct resource sdhi1_resources[] __initdata = { | |
350 | DEFINE_RES_MEM(0xee140000, 0x100), | |
351 | DEFINE_RES_IRQ(gic_spi(167)), | |
352 | }; | |
353 | ||
354 | /* SDHI2 */ | |
355 | static struct sh_mobile_sdhi_info sdhi2_info __initdata = { | |
356 | .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ | | |
357 | MMC_CAP_POWER_OFF_CARD, | |
d12e699f MD |
358 | .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | |
359 | TMIO_MMC_WRPROTECT_DISABLE, | |
360 | }; | |
361 | ||
362 | static struct resource sdhi2_resources[] __initdata = { | |
363 | DEFINE_RES_MEM(0xee160000, 0x100), | |
364 | DEFINE_RES_IRQ(gic_spi(168)), | |
365 | }; | |
366 | ||
85ef14da | 367 | static const struct pinctrl_map koelsch_pinctrl_map[] = { |
784c33a0 LP |
368 | /* DU */ |
369 | PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7791", "pfc-r8a7791", | |
370 | "du_rgb666", "du"), | |
371 | PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7791", "pfc-r8a7791", | |
372 | "du_sync", "du"), | |
373 | PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7791", "pfc-r8a7791", | |
374 | "du_clk_out_0", "du"), | |
974faba7 SS |
375 | /* Ether */ |
376 | PIN_MAP_MUX_GROUP_DEFAULT("r8a7791-ether", "pfc-r8a7791", | |
377 | "eth_link", "eth"), | |
378 | PIN_MAP_MUX_GROUP_DEFAULT("r8a7791-ether", "pfc-r8a7791", | |
379 | "eth_mdio", "eth"), | |
380 | PIN_MAP_MUX_GROUP_DEFAULT("r8a7791-ether", "pfc-r8a7791", | |
381 | "eth_rmii", "eth"), | |
382 | PIN_MAP_MUX_GROUP_DEFAULT("r8a7791-ether", "pfc-r8a7791", | |
383 | "intc_irq0", "intc"), | |
bcca4e8e GU |
384 | /* QSPI */ |
385 | PIN_MAP_MUX_GROUP_DEFAULT("qspi.0", "pfc-r8a7791", | |
386 | "qspi_ctrl", "qspi"), | |
387 | PIN_MAP_MUX_GROUP_DEFAULT("qspi.0", "pfc-r8a7791", | |
388 | "qspi_data4", "qspi"), | |
85ef14da MD |
389 | /* SCIF0 (CN19: DEBUG SERIAL0) */ |
390 | PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.6", "pfc-r8a7791", | |
391 | "scif0_data_d", "scif0"), | |
392 | /* SCIF1 (CN20: DEBUG SERIAL1) */ | |
393 | PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.7", "pfc-r8a7791", | |
394 | "scif1_data_d", "scif1"), | |
12c1d5a5 VB |
395 | /* I2C1 */ |
396 | PIN_MAP_MUX_GROUP_DEFAULT("i2c-rcar_gen2.1", "pfc-r8a7791", | |
397 | "i2c1_e", "i2c1"), | |
398 | /* I2C2 */ | |
399 | PIN_MAP_MUX_GROUP_DEFAULT("i2c-rcar_gen2.2", "pfc-r8a7791", | |
400 | "i2c2", "i2c2"), | |
401 | /* I2C4 */ | |
402 | PIN_MAP_MUX_GROUP_DEFAULT("i2c-rcar_gen2.4", "pfc-r8a7791", | |
403 | "i2c4_c", "i2c4"), | |
d12e699f MD |
404 | /* SDHI0 */ |
405 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7791", | |
406 | "sdhi0_data4", "sdhi0"), | |
407 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7791", | |
408 | "sdhi0_ctrl", "sdhi0"), | |
409 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7791", | |
410 | "sdhi0_cd", "sdhi0"), | |
411 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7791", | |
412 | "sdhi0_wp", "sdhi0"), | |
413 | /* SDHI2 */ | |
414 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7791", | |
415 | "sdhi1_data4", "sdhi1"), | |
416 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7791", | |
417 | "sdhi1_ctrl", "sdhi1"), | |
418 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7791", | |
419 | "sdhi1_cd", "sdhi1"), | |
420 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7791", | |
421 | "sdhi1_wp", "sdhi1"), | |
422 | /* SDHI2 */ | |
423 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-r8a7791", | |
424 | "sdhi2_data4", "sdhi2"), | |
425 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-r8a7791", | |
426 | "sdhi2_ctrl", "sdhi2"), | |
427 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-r8a7791", | |
428 | "sdhi2_cd", "sdhi2"), | |
85ef14da MD |
429 | }; |
430 | ||
1f52c659 HN |
431 | static void __init koelsch_add_standard_devices(void) |
432 | { | |
433 | r8a7791_clock_init(); | |
85ef14da MD |
434 | pinctrl_register_mappings(koelsch_pinctrl_map, |
435 | ARRAY_SIZE(koelsch_pinctrl_map)); | |
1a534ece | 436 | r8a7791_pinmux_init(); |
0749bead | 437 | r8a7791_add_standard_devices(); |
379bfd71 | 438 | platform_device_register_full(ðer_info); |
d2168146 | 439 | platform_device_register_data(NULL, "leds-gpio", -1, |
87a2934e MD |
440 | &koelsch_leds_pdata, |
441 | sizeof(koelsch_leds_pdata)); | |
d2168146 | 442 | platform_device_register_data(NULL, "gpio-keys", -1, |
721319d1 MD |
443 | &koelsch_keys_pdata, |
444 | sizeof(koelsch_keys_pdata)); | |
d2168146 | 445 | platform_device_register_resndata(NULL, "qspi", 0, |
bcca4e8e GU |
446 | qspi_resources, |
447 | ARRAY_SIZE(qspi_resources), | |
448 | &qspi_pdata, sizeof(qspi_pdata)); | |
449 | spi_register_board_info(spi_info, ARRAY_SIZE(spi_info)); | |
784c33a0 LP |
450 | |
451 | koelsch_add_du_device(); | |
4fc0a0b9 VB |
452 | |
453 | platform_device_register_full(&sata0_info); | |
12c1d5a5 VB |
454 | |
455 | koelsch_add_i2c(1); | |
456 | koelsch_add_i2c(2); | |
457 | koelsch_add_i2c(4); | |
458 | koelsch_add_i2c(5); | |
d12e699f | 459 | |
d2168146 | 460 | platform_device_register_data(NULL, "reg-fixed-voltage", 0, |
d12e699f | 461 | &vcc_sdhi0_info, sizeof(struct fixed_voltage_config)); |
d2168146 | 462 | platform_device_register_data(NULL, "reg-fixed-voltage", 1, |
d12e699f | 463 | &vcc_sdhi1_info, sizeof(struct fixed_voltage_config)); |
d2168146 | 464 | platform_device_register_data(NULL, "reg-fixed-voltage", 2, |
d12e699f | 465 | &vcc_sdhi2_info, sizeof(struct fixed_voltage_config)); |
d2168146 | 466 | platform_device_register_data(NULL, "gpio-regulator", 0, |
d12e699f | 467 | &vccq_sdhi0_info, sizeof(struct gpio_regulator_config)); |
d2168146 | 468 | platform_device_register_data(NULL, "gpio-regulator", 1, |
d12e699f | 469 | &vccq_sdhi1_info, sizeof(struct gpio_regulator_config)); |
d2168146 | 470 | platform_device_register_data(NULL, "gpio-regulator", 2, |
d12e699f MD |
471 | &vccq_sdhi2_info, sizeof(struct gpio_regulator_config)); |
472 | ||
d2168146 | 473 | platform_device_register_resndata(NULL, "sh_mobile_sdhi", 0, |
d12e699f MD |
474 | sdhi0_resources, ARRAY_SIZE(sdhi0_resources), |
475 | &sdhi0_info, sizeof(struct sh_mobile_sdhi_info)); | |
476 | ||
d2168146 | 477 | platform_device_register_resndata(NULL, "sh_mobile_sdhi", 1, |
d12e699f MD |
478 | sdhi1_resources, ARRAY_SIZE(sdhi1_resources), |
479 | &sdhi1_info, sizeof(struct sh_mobile_sdhi_info)); | |
480 | ||
d2168146 | 481 | platform_device_register_resndata(NULL, "sh_mobile_sdhi", 2, |
d12e699f MD |
482 | sdhi2_resources, ARRAY_SIZE(sdhi2_resources), |
483 | &sdhi2_info, sizeof(struct sh_mobile_sdhi_info)); | |
484 | ||
1f52c659 HN |
485 | } |
486 | ||
974faba7 SS |
487 | /* |
488 | * Ether LEDs on the Koelsch board are named LINK and ACTIVE which corresponds | |
489 | * to non-default 01 setting of the Micrel KSZ8041 PHY control register 1 bits | |
490 | * 14-15. We have to set them back to 01 from the default 00 value each time | |
491 | * the PHY is reset. It's also important because the PHY's LED0 signal is | |
492 | * connected to SoC's ETH_LINK signal and in the PHY's default mode it will | |
493 | * bounce on and off after each packet, which we apparently want to avoid. | |
494 | */ | |
495 | static int koelsch_ksz8041_fixup(struct phy_device *phydev) | |
496 | { | |
497 | u16 phyctrl1 = phy_read(phydev, 0x1e); | |
498 | ||
499 | phyctrl1 &= ~0xc000; | |
500 | phyctrl1 |= 0x4000; | |
501 | return phy_write(phydev, 0x1e, phyctrl1); | |
502 | } | |
503 | ||
504 | static void __init koelsch_init(void) | |
505 | { | |
506 | koelsch_add_standard_devices(); | |
507 | ||
29d9f010 SS |
508 | irq_set_irq_type(irq_pin(0), IRQ_TYPE_LEVEL_LOW); |
509 | ||
974faba7 SS |
510 | if (IS_ENABLED(CONFIG_PHYLIB)) |
511 | phy_register_fixup_for_id("r8a7791-ether-ff:01", | |
512 | koelsch_ksz8041_fixup); | |
513 | } | |
514 | ||
1f52c659 HN |
515 | static const char * const koelsch_boards_compat_dt[] __initconst = { |
516 | "renesas,koelsch", | |
517 | NULL, | |
518 | }; | |
519 | ||
520 | DT_MACHINE_START(KOELSCH_DT, "koelsch") | |
b6d5a1b1 | 521 | .smp = smp_ops(r8a7791_smp_ops), |
7e99497c | 522 | .init_early = shmobile_init_delay, |
f9c9eb7e | 523 | .init_time = rcar_gen2_timer_init, |
974faba7 | 524 | .init_machine = koelsch_init, |
6dc00ab9 | 525 | .init_late = shmobile_init_late, |
5f65c5bd | 526 | .reserve = rcar_gen2_reserve, |
1f52c659 HN |
527 | .dt_compat = koelsch_boards_compat_dt, |
528 | MACHINE_END |