Commit | Line | Data |
---|---|---|
3cc828fd MD |
1 | /* |
2 | * Lager board support | |
3 | * | |
5d5a87a5 | 4 | * Copyright (C) 2013-2014 Renesas Solutions Corp. |
3cc828fd | 5 | * Copyright (C) 2013 Magnus Damm |
5d5a87a5 | 6 | * Copyright (C) 2014 Cogent Embedded, Inc. |
3cc828fd 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. | |
3cc828fd MD |
16 | */ |
17 | ||
c3842e4f SH |
18 | #include <linux/gpio.h> |
19 | #include <linux/gpio_keys.h> | |
d58922ce | 20 | #include <linux/i2c.h> |
c3842e4f | 21 | #include <linux/input.h> |
3cc828fd | 22 | #include <linux/interrupt.h> |
5812b8b2 | 23 | #include <linux/irq.h> |
3cc828fd | 24 | #include <linux/kernel.h> |
1034f4ee | 25 | #include <linux/leds.h> |
40e6a51e | 26 | #include <linux/mfd/tmio.h> |
63d0539e GL |
27 | #include <linux/mmc/host.h> |
28 | #include <linux/mmc/sh_mmcif.h> | |
40e6a51e | 29 | #include <linux/mmc/sh_mobile_sdhi.h> |
fccae893 GU |
30 | #include <linux/mtd/partitions.h> |
31 | #include <linux/mtd/mtd.h> | |
e3a28ac2 | 32 | #include <linux/pinctrl/machine.h> |
094a804a | 33 | #include <linux/platform_data/camera-rcar.h> |
1034f4ee | 34 | #include <linux/platform_data/gpio-rcar.h> |
1eabe028 | 35 | #include <linux/platform_data/usb-rcar-gen2-phy.h> |
3cc828fd | 36 | #include <linux/platform_device.h> |
48c8b96f | 37 | #include <linux/phy.h> |
be0647d5 | 38 | #include <linux/regulator/driver.h> |
63d0539e | 39 | #include <linux/regulator/fixed.h> |
be0647d5 | 40 | #include <linux/regulator/gpio-regulator.h> |
63d0539e | 41 | #include <linux/regulator/machine.h> |
4901e136 | 42 | #include <linux/sh_eth.h> |
fccae893 GU |
43 | #include <linux/spi/flash.h> |
44 | #include <linux/spi/rspi.h> | |
45 | #include <linux/spi/spi.h> | |
1eabe028 VB |
46 | #include <linux/usb/phy.h> |
47 | #include <linux/usb/renesas_usbhs.h> | |
fccae893 | 48 | |
094a804a | 49 | #include <media/soc_camera.h> |
3cc828fd MD |
50 | #include <asm/mach-types.h> |
51 | #include <asm/mach/arch.h> | |
d58922ce KM |
52 | #include <sound/rcar_snd.h> |
53 | #include <sound/simple_card.h> | |
54 | ||
fd44aa5e | 55 | #include "common.h" |
b6bab126 | 56 | #include "irqs.h" |
fccae893 | 57 | #include "r8a7790.h" |
62872989 | 58 | #include "rcar-gen2.h" |
d58922ce KM |
59 | |
60 | /* | |
61 | * SSI-AK4643 | |
62 | * | |
63 | * SW1: 1: AK4643 | |
64 | * 2: CN22 | |
65 | * 3: ADV7511 | |
66 | * | |
67 | * this command is required when playback. | |
68 | * | |
69 | * # amixer set "LINEOUT Mixer DACL" on | |
70 | */ | |
3cc828fd | 71 | |
40e6a51e KM |
72 | /* |
73 | * SDHI0 (CN8) | |
74 | * | |
75 | * JP3: pin1 | |
76 | * SW20: pin1 | |
77 | ||
78 | * GP5_24: 1: VDD 3.3V (defult) | |
79 | * 0: VDD 0.0V | |
80 | * GP5_29: 1: VccQ 3.3V (defult) | |
81 | * 0: VccQ 1.8V | |
82 | * | |
83 | */ | |
84 | ||
1034f4ee SH |
85 | /* LEDS */ |
86 | static struct gpio_led lager_leds[] = { | |
87 | { | |
88 | .name = "led8", | |
89 | .gpio = RCAR_GP_PIN(5, 17), | |
90 | .default_state = LEDS_GPIO_DEFSTATE_ON, | |
91 | }, { | |
92 | .name = "led7", | |
93 | .gpio = RCAR_GP_PIN(4, 23), | |
94 | .default_state = LEDS_GPIO_DEFSTATE_ON, | |
95 | }, { | |
96 | .name = "led6", | |
97 | .gpio = RCAR_GP_PIN(4, 22), | |
98 | .default_state = LEDS_GPIO_DEFSTATE_ON, | |
99 | }, | |
100 | }; | |
101 | ||
27113d63 | 102 | static const struct gpio_led_platform_data lager_leds_pdata __initconst = { |
1034f4ee SH |
103 | .leds = lager_leds, |
104 | .num_leds = ARRAY_SIZE(lager_leds), | |
105 | }; | |
106 | ||
c3842e4f SH |
107 | /* GPIO KEY */ |
108 | #define GPIO_KEY(c, g, d, ...) \ | |
c9fd77d4 | 109 | { .code = c, .gpio = g, .desc = d, .active_low = 1, \ |
e0554d90 | 110 | .wakeup = 1, .debounce_interval = 20 } |
c3842e4f | 111 | |
a6014693 | 112 | static struct gpio_keys_button gpio_buttons[] = { |
c3842e4f SH |
113 | GPIO_KEY(KEY_4, RCAR_GP_PIN(1, 28), "SW2-pin4"), |
114 | GPIO_KEY(KEY_3, RCAR_GP_PIN(1, 26), "SW2-pin3"), | |
115 | GPIO_KEY(KEY_2, RCAR_GP_PIN(1, 24), "SW2-pin2"), | |
116 | GPIO_KEY(KEY_1, RCAR_GP_PIN(1, 14), "SW2-pin1"), | |
117 | }; | |
118 | ||
27113d63 | 119 | static const struct gpio_keys_platform_data lager_keys_pdata __initconst = { |
c3842e4f SH |
120 | .buttons = gpio_buttons, |
121 | .nbuttons = ARRAY_SIZE(gpio_buttons), | |
122 | }; | |
123 | ||
63d0539e GL |
124 | /* Fixed 3.3V regulator to be used by MMCIF */ |
125 | static struct regulator_consumer_supply fixed3v3_power_consumers[] = | |
126 | { | |
127 | REGULATOR_SUPPLY("vmmc", "sh_mmcif.1"), | |
128 | }; | |
129 | ||
be0647d5 KM |
130 | /* |
131 | * SDHI regulator macro | |
132 | * | |
133 | ** FIXME** | |
134 | * Lager board vqmmc is provided via DA9063 PMIC chip, | |
135 | * and we should use ${LINK}/drivers/mfd/da9063-* driver for it. | |
136 | * but, it doesn't have regulator support at this point. | |
137 | * It uses gpio-regulator for vqmmc as quick-hack. | |
138 | */ | |
139 | #define SDHI_REGULATOR(idx, vdd_pin, vccq_pin) \ | |
140 | static struct regulator_consumer_supply vcc_sdhi##idx##_consumer = \ | |
141 | REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi." #idx); \ | |
142 | \ | |
143 | static struct regulator_init_data vcc_sdhi##idx##_init_data = { \ | |
144 | .constraints = { \ | |
145 | .valid_ops_mask = REGULATOR_CHANGE_STATUS, \ | |
146 | }, \ | |
147 | .consumer_supplies = &vcc_sdhi##idx##_consumer, \ | |
148 | .num_consumer_supplies = 1, \ | |
149 | }; \ | |
150 | \ | |
151 | static const struct fixed_voltage_config vcc_sdhi##idx##_info __initconst = {\ | |
152 | .supply_name = "SDHI" #idx "Vcc", \ | |
153 | .microvolts = 3300000, \ | |
154 | .gpio = vdd_pin, \ | |
155 | .enable_high = 1, \ | |
156 | .init_data = &vcc_sdhi##idx##_init_data, \ | |
157 | }; \ | |
158 | \ | |
159 | static struct regulator_consumer_supply vccq_sdhi##idx##_consumer = \ | |
160 | REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi." #idx); \ | |
161 | \ | |
162 | static struct regulator_init_data vccq_sdhi##idx##_init_data = { \ | |
163 | .constraints = { \ | |
164 | .input_uV = 3300000, \ | |
165 | .min_uV = 1800000, \ | |
166 | .max_uV = 3300000, \ | |
167 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | \ | |
168 | REGULATOR_CHANGE_STATUS, \ | |
169 | }, \ | |
170 | .consumer_supplies = &vccq_sdhi##idx##_consumer, \ | |
171 | .num_consumer_supplies = 1, \ | |
172 | }; \ | |
173 | \ | |
174 | static struct gpio vccq_sdhi##idx##_gpio = \ | |
175 | { vccq_pin, GPIOF_OUT_INIT_HIGH, "vccq-sdhi" #idx }; \ | |
176 | \ | |
177 | static struct gpio_regulator_state vccq_sdhi##idx##_states[] = { \ | |
178 | { .value = 1800000, .gpios = 0 }, \ | |
179 | { .value = 3300000, .gpios = 1 }, \ | |
180 | }; \ | |
181 | \ | |
182 | static const struct gpio_regulator_config vccq_sdhi##idx##_info __initconst = {\ | |
183 | .supply_name = "vqmmc", \ | |
184 | .gpios = &vccq_sdhi##idx##_gpio, \ | |
185 | .nr_gpios = 1, \ | |
186 | .states = vccq_sdhi##idx##_states, \ | |
187 | .nr_states = ARRAY_SIZE(vccq_sdhi##idx##_states), \ | |
188 | .type = REGULATOR_VOLTAGE, \ | |
189 | .init_data = &vccq_sdhi##idx##_init_data, \ | |
190 | }; | |
191 | ||
192 | SDHI_REGULATOR(0, RCAR_GP_PIN(5, 24), RCAR_GP_PIN(5, 29)); | |
193 | SDHI_REGULATOR(2, RCAR_GP_PIN(5, 25), RCAR_GP_PIN(5, 30)); | |
194 | ||
63d0539e | 195 | /* MMCIF */ |
27113d63 | 196 | static const struct sh_mmcif_plat_data mmcif1_pdata __initconst = { |
63d0539e | 197 | .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE, |
b77c6bce GL |
198 | .clk_ctrl2_present = true, |
199 | .ccs_unsupported = true, | |
63d0539e GL |
200 | }; |
201 | ||
27113d63 | 202 | static const struct resource mmcif1_resources[] __initconst = { |
b7b42df6 | 203 | DEFINE_RES_MEM(0xee220000, 0x80), |
63d0539e GL |
204 | DEFINE_RES_IRQ(gic_spi(170)), |
205 | }; | |
206 | ||
4901e136 | 207 | /* Ether */ |
27113d63 | 208 | static const struct sh_eth_plat_data ether_pdata __initconst = { |
4901e136 | 209 | .phy = 0x1, |
5812b8b2 | 210 | .phy_irq = irq_pin(0), |
4901e136 | 211 | .edmac_endian = EDMAC_LITTLE_ENDIAN, |
4901e136 SH |
212 | .phy_interface = PHY_INTERFACE_MODE_RMII, |
213 | .ether_link_active_low = 1, | |
214 | }; | |
215 | ||
27113d63 | 216 | static const struct resource ether_resources[] __initconst = { |
4901e136 SH |
217 | DEFINE_RES_MEM(0xee700000, 0x400), |
218 | DEFINE_RES_IRQ(gic_spi(162)), | |
219 | }; | |
220 | ||
5d5a87a5 | 221 | static const struct platform_device_info ether_info __initconst = { |
5d5a87a5 SS |
222 | .name = "r8a7790-ether", |
223 | .id = -1, | |
224 | .res = ether_resources, | |
225 | .num_res = ARRAY_SIZE(ether_resources), | |
226 | .data = ðer_pdata, | |
227 | .size_data = sizeof(ether_pdata), | |
228 | .dma_mask = DMA_BIT_MASK(32), | |
229 | }; | |
230 | ||
24cf82f4 HCM |
231 | /* SPI Flash memory (Spansion S25FL512SAGMFIG11 64Mb) */ |
232 | static struct mtd_partition spi_flash_part[] = { | |
233 | /* Reserved for user loader program, read-only */ | |
234 | { | |
235 | .name = "loader", | |
236 | .offset = 0, | |
237 | .size = SZ_256K, | |
238 | .mask_flags = MTD_WRITEABLE, | |
239 | }, | |
240 | /* Reserved for user program, read-only */ | |
241 | { | |
242 | .name = "user", | |
243 | .offset = MTDPART_OFS_APPEND, | |
244 | .size = SZ_4M, | |
245 | .mask_flags = MTD_WRITEABLE, | |
246 | }, | |
247 | /* All else is writable (e.g. JFFS2) */ | |
248 | { | |
249 | .name = "flash", | |
250 | .offset = MTDPART_OFS_APPEND, | |
251 | .size = MTDPART_SIZ_FULL, | |
252 | .mask_flags = 0, | |
253 | }, | |
254 | }; | |
255 | ||
d422c451 | 256 | static const struct flash_platform_data spi_flash_data = { |
24cf82f4 HCM |
257 | .name = "m25p80", |
258 | .parts = spi_flash_part, | |
259 | .nr_parts = ARRAY_SIZE(spi_flash_part), | |
260 | .type = "s25fl512s", | |
261 | }; | |
262 | ||
263 | static const struct rspi_plat_data qspi_pdata __initconst = { | |
264 | .num_chipselect = 1, | |
265 | }; | |
266 | ||
267 | static const struct spi_board_info spi_info[] __initconst = { | |
268 | { | |
a09b2f0b GU |
269 | .modalias = "m25p80", |
270 | .platform_data = &spi_flash_data, | |
271 | .mode = SPI_MODE_0 | SPI_TX_QUAD | SPI_RX_QUAD, | |
272 | .max_speed_hz = 30000000, | |
273 | .bus_num = 0, | |
274 | .chip_select = 0, | |
24cf82f4 HCM |
275 | }, |
276 | }; | |
277 | ||
278 | /* QSPI resource */ | |
279 | static const struct resource qspi_resources[] __initconst = { | |
280 | DEFINE_RES_MEM(0xe6b10000, 0x1000), | |
a70eda7e | 281 | DEFINE_RES_IRQ_NAMED(gic_spi(184), "mux"), |
24cf82f4 HCM |
282 | }; |
283 | ||
094a804a VB |
284 | /* VIN */ |
285 | static const struct resource vin_resources[] __initconst = { | |
286 | /* VIN0 */ | |
287 | DEFINE_RES_MEM(0xe6ef0000, 0x1000), | |
288 | DEFINE_RES_IRQ(gic_spi(188)), | |
289 | /* VIN1 */ | |
290 | DEFINE_RES_MEM(0xe6ef1000, 0x1000), | |
291 | DEFINE_RES_IRQ(gic_spi(189)), | |
292 | }; | |
293 | ||
294 | static void __init lager_add_vin_device(unsigned idx, | |
295 | struct rcar_vin_platform_data *pdata) | |
296 | { | |
297 | struct platform_device_info vin_info = { | |
094a804a VB |
298 | .name = "r8a7790-vin", |
299 | .id = idx, | |
300 | .res = &vin_resources[idx * 2], | |
301 | .num_res = 2, | |
302 | .dma_mask = DMA_BIT_MASK(32), | |
303 | .data = pdata, | |
304 | .size_data = sizeof(*pdata), | |
305 | }; | |
306 | ||
307 | BUG_ON(idx > 1); | |
308 | ||
309 | platform_device_register_full(&vin_info); | |
310 | } | |
311 | ||
312 | #define LAGER_CAMERA(idx, name, addr, pdata, flag) \ | |
313 | static struct i2c_board_info i2c_cam##idx##_device = { \ | |
314 | I2C_BOARD_INFO(name, addr), \ | |
315 | }; \ | |
316 | \ | |
317 | static struct rcar_vin_platform_data vin##idx##_pdata = { \ | |
318 | .flags = flag, \ | |
319 | }; \ | |
320 | \ | |
321 | static struct soc_camera_link cam##idx##_link = { \ | |
322 | .bus_id = idx, \ | |
323 | .board_info = &i2c_cam##idx##_device, \ | |
324 | .i2c_adapter_id = 2, \ | |
325 | .module_name = name, \ | |
326 | .priv = pdata, \ | |
327 | } | |
328 | ||
329 | /* Camera 0 is not currently supported due to adv7612 support missing */ | |
330 | LAGER_CAMERA(1, "adv7180", 0x20, NULL, RCAR_VIN_BT656); | |
331 | ||
332 | static void __init lager_add_camera1_device(void) | |
333 | { | |
d2168146 | 334 | platform_device_register_data(NULL, "soc-camera-pdrv", 1, |
094a804a VB |
335 | &cam1_link, sizeof(cam1_link)); |
336 | lager_add_vin_device(1, &vin1_pdata); | |
337 | } | |
338 | ||
1e0d2c49 VB |
339 | /* SATA1 */ |
340 | static const struct resource sata1_resources[] __initconst = { | |
341 | DEFINE_RES_MEM(0xee500000, 0x2000), | |
342 | DEFINE_RES_IRQ(gic_spi(106)), | |
343 | }; | |
344 | ||
345 | static const struct platform_device_info sata1_info __initconst = { | |
1e0d2c49 VB |
346 | .name = "sata-r8a7790", |
347 | .id = 1, | |
348 | .res = sata1_resources, | |
349 | .num_res = ARRAY_SIZE(sata1_resources), | |
350 | .dma_mask = DMA_BIT_MASK(32), | |
351 | }; | |
352 | ||
1eabe028 | 353 | /* USBHS */ |
1eabe028 VB |
354 | static const struct resource usbhs_resources[] __initconst = { |
355 | DEFINE_RES_MEM(0xe6590000, 0x100), | |
356 | DEFINE_RES_IRQ(gic_spi(107)), | |
357 | }; | |
358 | ||
359 | struct usbhs_private { | |
360 | struct renesas_usbhs_platform_info info; | |
361 | struct usb_phy *phy; | |
362 | }; | |
363 | ||
364 | #define usbhs_get_priv(pdev) \ | |
365 | container_of(renesas_usbhs_get_info(pdev), struct usbhs_private, info) | |
366 | ||
367 | static int usbhs_power_ctrl(struct platform_device *pdev, | |
368 | void __iomem *base, int enable) | |
369 | { | |
370 | struct usbhs_private *priv = usbhs_get_priv(pdev); | |
371 | ||
372 | if (!priv->phy) | |
373 | return -ENODEV; | |
374 | ||
375 | if (enable) { | |
376 | int retval = usb_phy_init(priv->phy); | |
377 | ||
378 | if (!retval) | |
379 | retval = usb_phy_set_suspend(priv->phy, 0); | |
380 | return retval; | |
381 | } | |
382 | ||
383 | usb_phy_set_suspend(priv->phy, 1); | |
384 | usb_phy_shutdown(priv->phy); | |
385 | return 0; | |
386 | } | |
387 | ||
388 | static int usbhs_hardware_init(struct platform_device *pdev) | |
389 | { | |
390 | struct usbhs_private *priv = usbhs_get_priv(pdev); | |
391 | struct usb_phy *phy; | |
36be7686 MD |
392 | int ret; |
393 | ||
394 | /* USB0 Function - use PWEN as GPIO input to detect DIP Switch SW5 | |
395 | * setting to avoid VBUS short circuit due to wrong cable. | |
396 | * PWEN should be pulled up high if USB Function is selected by SW5 | |
397 | */ | |
398 | gpio_request_one(RCAR_GP_PIN(5, 18), GPIOF_IN, NULL); /* USB0_PWEN */ | |
399 | if (!gpio_get_value(RCAR_GP_PIN(5, 18))) { | |
400 | pr_warn("Error: USB Function not selected - check SW5 + SW6\n"); | |
401 | ret = -ENOTSUPP; | |
402 | goto error; | |
403 | } | |
1eabe028 VB |
404 | |
405 | phy = usb_get_phy_dev(&pdev->dev, 0); | |
36be7686 MD |
406 | if (IS_ERR(phy)) { |
407 | ret = PTR_ERR(phy); | |
408 | goto error; | |
409 | } | |
1eabe028 VB |
410 | |
411 | priv->phy = phy; | |
412 | return 0; | |
36be7686 MD |
413 | error: |
414 | gpio_free(RCAR_GP_PIN(5, 18)); | |
415 | return ret; | |
1eabe028 VB |
416 | } |
417 | ||
418 | static int usbhs_hardware_exit(struct platform_device *pdev) | |
419 | { | |
420 | struct usbhs_private *priv = usbhs_get_priv(pdev); | |
421 | ||
422 | if (!priv->phy) | |
423 | return 0; | |
424 | ||
425 | usb_put_phy(priv->phy); | |
426 | priv->phy = NULL; | |
36be7686 MD |
427 | |
428 | gpio_free(RCAR_GP_PIN(5, 18)); | |
1eabe028 VB |
429 | return 0; |
430 | } | |
431 | ||
432 | static int usbhs_get_id(struct platform_device *pdev) | |
433 | { | |
434 | return USBHS_GADGET; | |
435 | } | |
436 | ||
437 | static u32 lager_usbhs_pipe_type[] = { | |
438 | USB_ENDPOINT_XFER_CONTROL, | |
439 | USB_ENDPOINT_XFER_ISOC, | |
440 | USB_ENDPOINT_XFER_ISOC, | |
441 | USB_ENDPOINT_XFER_BULK, | |
442 | USB_ENDPOINT_XFER_BULK, | |
443 | USB_ENDPOINT_XFER_BULK, | |
444 | USB_ENDPOINT_XFER_INT, | |
445 | USB_ENDPOINT_XFER_INT, | |
446 | USB_ENDPOINT_XFER_INT, | |
447 | USB_ENDPOINT_XFER_BULK, | |
448 | USB_ENDPOINT_XFER_BULK, | |
449 | USB_ENDPOINT_XFER_BULK, | |
450 | USB_ENDPOINT_XFER_BULK, | |
451 | USB_ENDPOINT_XFER_BULK, | |
452 | USB_ENDPOINT_XFER_BULK, | |
453 | USB_ENDPOINT_XFER_BULK, | |
454 | }; | |
455 | ||
456 | static struct usbhs_private usbhs_priv __initdata = { | |
457 | .info = { | |
458 | .platform_callback = { | |
459 | .power_ctrl = usbhs_power_ctrl, | |
460 | .hardware_init = usbhs_hardware_init, | |
461 | .hardware_exit = usbhs_hardware_exit, | |
462 | .get_id = usbhs_get_id, | |
463 | }, | |
464 | .driver_param = { | |
465 | .buswait_bwait = 4, | |
466 | .pipe_type = lager_usbhs_pipe_type, | |
467 | .pipe_size = ARRAY_SIZE(lager_usbhs_pipe_type), | |
468 | }, | |
469 | } | |
470 | }; | |
471 | ||
472 | static void __init lager_register_usbhs(void) | |
473 | { | |
474 | usb_bind_phy("renesas_usbhs", 0, "usb_phy_rcar_gen2"); | |
d2168146 | 475 | platform_device_register_resndata(NULL, |
1eabe028 VB |
476 | "renesas_usbhs", -1, |
477 | usbhs_resources, | |
478 | ARRAY_SIZE(usbhs_resources), | |
479 | &usbhs_priv.info, | |
480 | sizeof(usbhs_priv.info)); | |
481 | } | |
1eabe028 VB |
482 | |
483 | /* USBHS PHY */ | |
484 | static const struct rcar_gen2_phy_platform_data usbhs_phy_pdata __initconst = { | |
485 | .chan0_pci = 0, /* Channel 0 is USBHS */ | |
486 | .chan2_pci = 1, /* Channel 2 is PCI USB */ | |
487 | }; | |
488 | ||
489 | static const struct resource usbhs_phy_resources[] __initconst = { | |
490 | DEFINE_RES_MEM(0xe6590100, 0x100), | |
491 | }; | |
492 | ||
d58922ce KM |
493 | /* I2C */ |
494 | static struct i2c_board_info i2c2_devices[] = { | |
495 | { | |
496 | I2C_BOARD_INFO("ak4643", 0x12), | |
497 | } | |
498 | }; | |
499 | ||
500 | /* Sound */ | |
501 | static struct resource rsnd_resources[] __initdata = { | |
502 | [RSND_GEN2_SCU] = DEFINE_RES_MEM(0xec500000, 0x1000), | |
503 | [RSND_GEN2_ADG] = DEFINE_RES_MEM(0xec5a0000, 0x100), | |
504 | [RSND_GEN2_SSIU] = DEFINE_RES_MEM(0xec540000, 0x1000), | |
505 | [RSND_GEN2_SSI] = DEFINE_RES_MEM(0xec541000, 0x1280), | |
506 | }; | |
507 | ||
508 | static struct rsnd_ssi_platform_info rsnd_ssi[] = { | |
50f359d7 KM |
509 | RSND_SSI(0, gic_spi(370), 0), |
510 | RSND_SSI(0, gic_spi(371), RSND_SSI_CLK_PIN_SHARE), | |
d58922ce KM |
511 | }; |
512 | ||
50f359d7 | 513 | static struct rsnd_src_platform_info rsnd_src[2] = { |
d58922ce KM |
514 | /* no member at this point */ |
515 | }; | |
516 | ||
50f359d7 KM |
517 | static struct rsnd_dai_platform_info rsnd_dai = { |
518 | .playback = { .ssi = &rsnd_ssi[0], }, | |
519 | .capture = { .ssi = &rsnd_ssi[1], }, | |
520 | }; | |
521 | ||
d58922ce KM |
522 | static struct rcar_snd_info rsnd_info = { |
523 | .flags = RSND_GEN2, | |
524 | .ssi_info = rsnd_ssi, | |
525 | .ssi_info_nr = ARRAY_SIZE(rsnd_ssi), | |
50f359d7 KM |
526 | .src_info = rsnd_src, |
527 | .src_info_nr = ARRAY_SIZE(rsnd_src), | |
528 | .dai_info = &rsnd_dai, | |
529 | .dai_info_nr = 1, | |
d58922ce KM |
530 | }; |
531 | ||
532 | static struct asoc_simple_card_info rsnd_card_info = { | |
533 | .name = "AK4643", | |
534 | .card = "SSI01-AK4643", | |
535 | .codec = "ak4642-codec.2-0012", | |
536 | .platform = "rcar_sound", | |
9f85ff84 | 537 | .daifmt = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_CBM_CFM, |
d58922ce KM |
538 | .cpu_dai = { |
539 | .name = "rcar_sound", | |
d58922ce KM |
540 | }, |
541 | .codec_dai = { | |
542 | .name = "ak4642-hifi", | |
d58922ce KM |
543 | .sysclk = 11289600, |
544 | }, | |
545 | }; | |
546 | ||
547 | static void __init lager_add_rsnd_device(void) | |
548 | { | |
549 | struct platform_device_info cardinfo = { | |
d58922ce KM |
550 | .name = "asoc-simple-card", |
551 | .id = -1, | |
552 | .data = &rsnd_card_info, | |
553 | .size_data = sizeof(struct asoc_simple_card_info), | |
554 | .dma_mask = DMA_BIT_MASK(32), | |
555 | }; | |
556 | ||
557 | i2c_register_board_info(2, i2c2_devices, | |
558 | ARRAY_SIZE(i2c2_devices)); | |
559 | ||
560 | platform_device_register_resndata( | |
d2168146 | 561 | NULL, "rcar_sound", -1, |
d58922ce KM |
562 | rsnd_resources, ARRAY_SIZE(rsnd_resources), |
563 | &rsnd_info, sizeof(rsnd_info)); | |
564 | ||
565 | platform_device_register_full(&cardinfo); | |
566 | } | |
567 | ||
40e6a51e KM |
568 | /* SDHI0 */ |
569 | static struct sh_mobile_sdhi_info sdhi0_info __initdata = { | |
570 | .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ | | |
571 | MMC_CAP_POWER_OFF_CARD, | |
40e6a51e KM |
572 | .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | |
573 | TMIO_MMC_WRPROTECT_DISABLE, | |
574 | }; | |
575 | ||
576 | static struct resource sdhi0_resources[] __initdata = { | |
577 | DEFINE_RES_MEM(0xee100000, 0x200), | |
578 | DEFINE_RES_IRQ(gic_spi(165)), | |
579 | }; | |
580 | ||
581 | /* SDHI2 */ | |
582 | static struct sh_mobile_sdhi_info sdhi2_info __initdata = { | |
583 | .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ | | |
584 | MMC_CAP_POWER_OFF_CARD, | |
40e6a51e KM |
585 | .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | |
586 | TMIO_MMC_WRPROTECT_DISABLE, | |
587 | }; | |
588 | ||
589 | static struct resource sdhi2_resources[] __initdata = { | |
590 | DEFINE_RES_MEM(0xee140000, 0x100), | |
591 | DEFINE_RES_IRQ(gic_spi(167)), | |
592 | }; | |
593 | ||
849f7b6c VB |
594 | /* Internal PCI1 */ |
595 | static const struct resource pci1_resources[] __initconst = { | |
596 | DEFINE_RES_MEM(0xee0b0000, 0x10000), /* CFG */ | |
597 | DEFINE_RES_MEM(0xee0a0000, 0x10000), /* MEM */ | |
598 | DEFINE_RES_IRQ(gic_spi(112)), | |
599 | }; | |
600 | ||
601 | static const struct platform_device_info pci1_info __initconst = { | |
849f7b6c VB |
602 | .name = "pci-rcar-gen2", |
603 | .id = 1, | |
604 | .res = pci1_resources, | |
605 | .num_res = ARRAY_SIZE(pci1_resources), | |
606 | .dma_mask = DMA_BIT_MASK(32), | |
607 | }; | |
608 | ||
609 | static void __init lager_add_usb1_device(void) | |
610 | { | |
611 | platform_device_register_full(&pci1_info); | |
612 | } | |
613 | ||
614 | /* Internal PCI2 */ | |
615 | static const struct resource pci2_resources[] __initconst = { | |
616 | DEFINE_RES_MEM(0xee0d0000, 0x10000), /* CFG */ | |
617 | DEFINE_RES_MEM(0xee0c0000, 0x10000), /* MEM */ | |
618 | DEFINE_RES_IRQ(gic_spi(113)), | |
619 | }; | |
620 | ||
621 | static const struct platform_device_info pci2_info __initconst = { | |
849f7b6c VB |
622 | .name = "pci-rcar-gen2", |
623 | .id = 2, | |
624 | .res = pci2_resources, | |
625 | .num_res = ARRAY_SIZE(pci2_resources), | |
626 | .dma_mask = DMA_BIT_MASK(32), | |
627 | }; | |
628 | ||
629 | static void __init lager_add_usb2_device(void) | |
630 | { | |
631 | platform_device_register_full(&pci2_info); | |
632 | } | |
633 | ||
e3a28ac2 | 634 | static const struct pinctrl_map lager_pinctrl_map[] = { |
c75a5afa LP |
635 | /* DU (CN10: ARGB0, CN13: LVDS) */ |
636 | PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7790", "pfc-r8a7790", | |
637 | "du_rgb666", "du"), | |
638 | PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7790", "pfc-r8a7790", | |
639 | "du_sync_1", "du"), | |
640 | PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7790", "pfc-r8a7790", | |
641 | "du_clk_out_0", "du"), | |
d58922ce KM |
642 | /* I2C2 */ |
643 | PIN_MAP_MUX_GROUP_DEFAULT("i2c-rcar.2", "pfc-r8a7790", | |
644 | "i2c2", "i2c2"), | |
248deabb GU |
645 | /* QSPI */ |
646 | PIN_MAP_MUX_GROUP_DEFAULT("qspi.0", "pfc-r8a7790", | |
647 | "qspi_ctrl", "qspi"), | |
648 | PIN_MAP_MUX_GROUP_DEFAULT("qspi.0", "pfc-r8a7790", | |
649 | "qspi_data4", "qspi"), | |
e3a28ac2 LP |
650 | /* SCIF0 (CN19: DEBUG SERIAL0) */ |
651 | PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.6", "pfc-r8a7790", | |
652 | "scif0_data", "scif0"), | |
653 | /* SCIF1 (CN20: DEBUG SERIAL1) */ | |
654 | PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.7", "pfc-r8a7790", | |
655 | "scif1_data", "scif1"), | |
40e6a51e KM |
656 | /* SDHI0 */ |
657 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7790", | |
658 | "sdhi0_data4", "sdhi0"), | |
659 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7790", | |
660 | "sdhi0_ctrl", "sdhi0"), | |
661 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7790", | |
662 | "sdhi0_cd", "sdhi0"), | |
663 | /* SDHI2 */ | |
664 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-r8a7790", | |
665 | "sdhi2_data4", "sdhi2"), | |
666 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-r8a7790", | |
667 | "sdhi2_ctrl", "sdhi2"), | |
668 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-r8a7790", | |
669 | "sdhi2_cd", "sdhi2"), | |
d58922ce KM |
670 | /* SSI (CN17: sound) */ |
671 | PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7790", | |
672 | "ssi0129_ctrl", "ssi"), | |
673 | PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7790", | |
674 | "ssi0_data", "ssi"), | |
675 | PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7790", | |
676 | "ssi1_data", "ssi"), | |
677 | PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7790", | |
678 | "audio_clk_a", "audio_clk"), | |
63d0539e GL |
679 | /* MMCIF1 */ |
680 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.1", "pfc-r8a7790", | |
681 | "mmc1_data8", "mmc1"), | |
682 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.1", "pfc-r8a7790", | |
683 | "mmc1_ctrl", "mmc1"), | |
4901e136 SH |
684 | /* Ether */ |
685 | PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-ether", "pfc-r8a7790", | |
686 | "eth_link", "eth"), | |
687 | PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-ether", "pfc-r8a7790", | |
688 | "eth_mdio", "eth"), | |
689 | PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-ether", "pfc-r8a7790", | |
690 | "eth_rmii", "eth"), | |
691 | PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-ether", "pfc-r8a7790", | |
692 | "intc_irq0", "intc"), | |
094a804a VB |
693 | /* VIN0 */ |
694 | PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.0", "pfc-r8a7790", | |
695 | "vin0_data24", "vin0"), | |
696 | PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.0", "pfc-r8a7790", | |
697 | "vin0_sync", "vin0"), | |
698 | PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.0", "pfc-r8a7790", | |
699 | "vin0_field", "vin0"), | |
700 | PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.0", "pfc-r8a7790", | |
701 | "vin0_clkenb", "vin0"), | |
702 | PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.0", "pfc-r8a7790", | |
703 | "vin0_clk", "vin0"), | |
704 | /* VIN1 */ | |
705 | PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.1", "pfc-r8a7790", | |
706 | "vin1_data8", "vin1"), | |
707 | PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.1", "pfc-r8a7790", | |
708 | "vin1_clk", "vin1"), | |
1eabe028 VB |
709 | /* USB0 */ |
710 | PIN_MAP_MUX_GROUP_DEFAULT("renesas_usbhs", "pfc-r8a7790", | |
36be7686 | 711 | "usb0_ovc_vbus", "usb0"), |
849f7b6c VB |
712 | /* USB1 */ |
713 | PIN_MAP_MUX_GROUP_DEFAULT("pci-rcar-gen2.1", "pfc-r8a7790", | |
714 | "usb1", "usb1"), | |
715 | /* USB2 */ | |
716 | PIN_MAP_MUX_GROUP_DEFAULT("pci-rcar-gen2.2", "pfc-r8a7790", | |
717 | "usb2", "usb2"), | |
e3a28ac2 LP |
718 | }; |
719 | ||
3cc828fd MD |
720 | static void __init lager_add_standard_devices(void) |
721 | { | |
be0647d5 KM |
722 | int fixed_regulator_idx = 0; |
723 | int gpio_regulator_idx = 0; | |
724 | ||
3cc828fd | 725 | r8a7790_clock_init(); |
e3a28ac2 LP |
726 | |
727 | pinctrl_register_mappings(lager_pinctrl_map, | |
728 | ARRAY_SIZE(lager_pinctrl_map)); | |
729 | r8a7790_pinmux_init(); | |
730 | ||
3cc828fd | 731 | r8a7790_add_standard_devices(); |
d2168146 | 732 | platform_device_register_data(NULL, "leds-gpio", -1, |
1034f4ee SH |
733 | &lager_leds_pdata, |
734 | sizeof(lager_leds_pdata)); | |
d2168146 | 735 | platform_device_register_data(NULL, "gpio-keys", -1, |
c3842e4f SH |
736 | &lager_keys_pdata, |
737 | sizeof(lager_keys_pdata)); | |
be0647d5 KM |
738 | regulator_register_always_on(fixed_regulator_idx++, |
739 | "fixed-3.3V", fixed3v3_power_consumers, | |
63d0539e | 740 | ARRAY_SIZE(fixed3v3_power_consumers), 3300000); |
d2168146 | 741 | platform_device_register_resndata(NULL, "sh_mmcif", 1, |
63d0539e GL |
742 | mmcif1_resources, ARRAY_SIZE(mmcif1_resources), |
743 | &mmcif1_pdata, sizeof(mmcif1_pdata)); | |
4901e136 | 744 | |
5d5a87a5 | 745 | platform_device_register_full(ðer_info); |
c75a5afa | 746 | |
d2168146 | 747 | platform_device_register_resndata(NULL, "qspi", 0, |
24cf82f4 HCM |
748 | qspi_resources, |
749 | ARRAY_SIZE(qspi_resources), | |
750 | &qspi_pdata, sizeof(qspi_pdata)); | |
751 | spi_register_board_info(spi_info, ARRAY_SIZE(spi_info)); | |
be0647d5 | 752 | |
d2168146 | 753 | platform_device_register_data(NULL, "reg-fixed-voltage", fixed_regulator_idx++, |
be0647d5 | 754 | &vcc_sdhi0_info, sizeof(struct fixed_voltage_config)); |
d2168146 | 755 | platform_device_register_data(NULL, "reg-fixed-voltage", fixed_regulator_idx++, |
be0647d5 KM |
756 | &vcc_sdhi2_info, sizeof(struct fixed_voltage_config)); |
757 | ||
d2168146 | 758 | platform_device_register_data(NULL, "gpio-regulator", gpio_regulator_idx++, |
be0647d5 | 759 | &vccq_sdhi0_info, sizeof(struct gpio_regulator_config)); |
d2168146 | 760 | platform_device_register_data(NULL, "gpio-regulator", gpio_regulator_idx++, |
be0647d5 | 761 | &vccq_sdhi2_info, sizeof(struct gpio_regulator_config)); |
094a804a VB |
762 | |
763 | lager_add_camera1_device(); | |
1e0d2c49 VB |
764 | |
765 | platform_device_register_full(&sata1_info); | |
1eabe028 | 766 | |
d2168146 | 767 | platform_device_register_resndata(NULL, "usb_phy_rcar_gen2", |
1eabe028 VB |
768 | -1, usbhs_phy_resources, |
769 | ARRAY_SIZE(usbhs_phy_resources), | |
770 | &usbhs_phy_pdata, | |
771 | sizeof(usbhs_phy_pdata)); | |
772 | lager_register_usbhs(); | |
849f7b6c VB |
773 | lager_add_usb1_device(); |
774 | lager_add_usb2_device(); | |
d58922ce KM |
775 | |
776 | lager_add_rsnd_device(); | |
40e6a51e | 777 | |
d2168146 | 778 | platform_device_register_resndata(NULL, "sh_mobile_sdhi", 0, |
40e6a51e KM |
779 | sdhi0_resources, ARRAY_SIZE(sdhi0_resources), |
780 | &sdhi0_info, sizeof(struct sh_mobile_sdhi_info)); | |
d2168146 | 781 | platform_device_register_resndata(NULL, "sh_mobile_sdhi", 2, |
40e6a51e KM |
782 | sdhi2_resources, ARRAY_SIZE(sdhi2_resources), |
783 | &sdhi2_info, sizeof(struct sh_mobile_sdhi_info)); | |
3cc828fd MD |
784 | } |
785 | ||
48c8b96f SS |
786 | /* |
787 | * Ether LEDs on the Lager board are named LINK and ACTIVE which corresponds | |
788 | * to non-default 01 setting of the Micrel KSZ8041 PHY control register 1 bits | |
789 | * 14-15. We have to set them back to 01 from the default 00 value each time | |
790 | * the PHY is reset. It's also important because the PHY's LED0 signal is | |
791 | * connected to SoC's ETH_LINK signal and in the PHY's default mode it will | |
792 | * bounce on and off after each packet, which we apparently want to avoid. | |
793 | */ | |
794 | static int lager_ksz8041_fixup(struct phy_device *phydev) | |
795 | { | |
796 | u16 phyctrl1 = phy_read(phydev, 0x1e); | |
797 | ||
798 | phyctrl1 &= ~0xc000; | |
799 | phyctrl1 |= 0x4000; | |
800 | return phy_write(phydev, 0x1e, phyctrl1); | |
801 | } | |
802 | ||
803 | static void __init lager_init(void) | |
804 | { | |
805 | lager_add_standard_devices(); | |
806 | ||
5812b8b2 SS |
807 | irq_set_irq_type(irq_pin(0), IRQ_TYPE_LEVEL_LOW); |
808 | ||
6802cdc5 SH |
809 | if (IS_ENABLED(CONFIG_PHYLIB)) |
810 | phy_register_fixup_for_id("r8a7790-ether-ff:01", | |
811 | lager_ksz8041_fixup); | |
48c8b96f SS |
812 | } |
813 | ||
27113d63 | 814 | static const char * const lager_boards_compat_dt[] __initconst = { |
3cc828fd MD |
815 | "renesas,lager", |
816 | NULL, | |
817 | }; | |
818 | ||
819 | DT_MACHINE_START(LAGER_DT, "lager") | |
ad09cb83 | 820 | .smp = smp_ops(r8a7790_smp_ops), |
a5d62681 | 821 | .init_early = shmobile_init_delay, |
50c517d9 | 822 | .init_time = rcar_gen2_timer_init, |
48c8b96f | 823 | .init_machine = lager_init, |
3fbbcbdf | 824 | .init_late = shmobile_init_late, |
5f65c5bd | 825 | .reserve = rcar_gen2_reserve, |
3cc828fd MD |
826 | .dt_compat = lager_boards_compat_dt, |
827 | MACHINE_END |