]>
Commit | Line | Data |
---|---|---|
920adc75 KM |
1 | /* |
2 | * mackerel board support | |
3 | * | |
4 | * Copyright (C) 2010 Renesas Solutions Corp. | |
5 | * Kuninori Morimoto <[email protected]> | |
6 | * | |
7 | * based on ap4evb | |
8 | * Copyright (C) 2010 Magnus Damm | |
9 | * Copyright (C) 2008 Yoshihiro Shimoda | |
10 | * | |
11 | * This program is free software; you can redistribute it and/or modify | |
12 | * it under the terms of the GNU General Public License as published by | |
13 | * the Free Software Foundation; version 2 of the License. | |
14 | * | |
15 | * This program is distributed in the hope that it will be useful, | |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | * GNU General Public License for more details. | |
19 | * | |
20 | * You should have received a copy of the GNU General Public License | |
21 | * along with this program; if not, write to the Free Software | |
22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
23 | */ | |
12c4309b | 24 | #include <linux/delay.h> |
920adc75 KM |
25 | #include <linux/kernel.h> |
26 | #include <linux/init.h> | |
27 | #include <linux/interrupt.h> | |
28 | #include <linux/irq.h> | |
29 | #include <linux/platform_device.h> | |
30 | #include <linux/gpio.h> | |
31 | #include <linux/input.h> | |
32 | #include <linux/io.h> | |
1a44d72a | 33 | #include <linux/i2c.h> |
d44deb35 | 34 | #include <linux/leds.h> |
6dff7da2 YG |
35 | #include <linux/mfd/tmio.h> |
36 | #include <linux/mmc/host.h> | |
41491b9a | 37 | #include <linux/mmc/sh_mmcif.h> |
17e75d82 | 38 | #include <linux/mmc/sh_mobile_sdhi.h> |
920adc75 KM |
39 | #include <linux/mtd/mtd.h> |
40 | #include <linux/mtd/partitions.h> | |
41 | #include <linux/mtd/physmap.h> | |
2aab52e8 | 42 | #include <linux/mtd/sh_flctl.h> |
26e19bd4 | 43 | #include <linux/pinctrl/machine.h> |
3a8067f7 | 44 | #include <linux/pinctrl/pinconf-generic.h> |
14bd03e0 | 45 | #include <linux/platform_data/gpio_backlight.h> |
b5e8d269 | 46 | #include <linux/pm_clock.h> |
70ccb28d GL |
47 | #include <linux/regulator/fixed.h> |
48 | #include <linux/regulator/machine.h> | |
2264c151 | 49 | #include <linux/smsc911x.h> |
6b8b0cb4 | 50 | #include <linux/sh_clk.h> |
cd8ab004 | 51 | #include <linux/tca6416_keypad.h> |
66ee3bef | 52 | #include <linux/usb/renesas_usbhs.h> |
9b742024 | 53 | #include <linux/dma-mapping.h> |
113522ee | 54 | |
12c4309b | 55 | #include <video/sh_mobile_hdmi.h> |
11fee467 | 56 | #include <video/sh_mobile_lcdc.h> |
ae37c8de MD |
57 | #include <media/sh_mobile_ceu.h> |
58 | #include <media/soc_camera.h> | |
59 | #include <media/soc_camera_platform.h> | |
1a44d72a | 60 | #include <sound/sh_fsi.h> |
af8a2fe1 | 61 | #include <sound/simple_card.h> |
920adc75 | 62 | #include <asm/mach/arch.h> |
920adc75 KM |
63 | #include <asm/mach-types.h> |
64 | ||
fd44aa5e | 65 | #include "common.h" |
86155b35 | 66 | #include "intc.h" |
b6bab126 | 67 | #include "irqs.h" |
6b8b0cb4 | 68 | #include "pm-rmobile.h" |
66791859 | 69 | #include "sh-gpio.h" |
113522ee | 70 | #include "sh7372.h" |
66791859 | 71 | |
920adc75 KM |
72 | /* |
73 | * Address Interface BusWidth note | |
74 | * ------------------------------------------------------------------ | |
75 | * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON | |
76 | * 0x0800_0000 user area - | |
77 | * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF | |
78 | * 0x1400_0000 Ether (LAN9220) 16bit | |
79 | * 0x1600_0000 user area - cannot use with NAND | |
80 | * 0x1800_0000 user area - | |
81 | * 0x1A00_0000 - | |
82 | * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit | |
83 | */ | |
84 | ||
4b82b689 KM |
85 | /* |
86 | * CPU mode | |
87 | * | |
88 | * SW4 | Boot Area| Master | Remarks | |
89 | * 1 | 2 | 3 | 4 | 5 | 6 | 8 | | Processor| | |
90 | * ----+-----+-----+-----+-----+-----+-----+----------+----------+-------------- | |
91 | * ON | ON | OFF | ON | ON | OFF | OFF | External | System | External ROM | |
92 | * ON | ON | ON | ON | ON | OFF | OFF | External | System | ROM Debug | |
93 | * ON | ON | X | ON | OFF | OFF | OFF | Built-in | System | ROM Debug | |
94 | * X | OFF | X | X | X | X | OFF | Built-in | System | MaskROM | |
95 | * OFF | X | X | X | X | X | OFF | Built-in | System | MaskROM | |
96 | * X | X | X | OFF | X | X | OFF | Built-in | System | MaskROM | |
97 | * OFF | ON | OFF | X | X | OFF | ON | External | System | Standalone | |
98 | * ON | OFF | OFF | X | X | OFF | ON | External | Realtime | Standalone | |
99 | */ | |
100 | ||
101 | /* | |
102 | * NOR Flash ROM | |
103 | * | |
104 | * SW1 | SW2 | SW7 | NOR Flash ROM | |
105 | * bit1 | bit1 bit2 | bit1 | Memory allocation | |
106 | * ------+------------+------+------------------ | |
107 | * OFF | ON OFF | ON | Area 0 | |
108 | * OFF | ON OFF | OFF | Area 4 | |
109 | */ | |
110 | ||
111 | /* | |
112 | * SMSC 9220 | |
113 | * | |
114 | * SW1 SMSC 9220 | |
115 | * ----------------------- | |
116 | * ON access disable | |
117 | * OFF access enable | |
118 | */ | |
119 | ||
120 | /* | |
121 | * NAND Flash ROM | |
122 | * | |
123 | * SW1 | SW2 | SW7 | NAND Flash ROM | |
124 | * bit1 | bit1 bit2 | bit2 | Memory allocation | |
125 | * ------+------------+------+------------------ | |
126 | * OFF | ON OFF | ON | FCE 0 | |
127 | * OFF | ON OFF | OFF | FCE 1 | |
128 | */ | |
129 | ||
130 | /* | |
131 | * External interrupt pin settings | |
132 | * | |
133 | * IRQX | pin setting | device | level | |
134 | * ------+--------------------+--------------------+------- | |
135 | * IRQ0 | ICR1A.IRQ0SA=0010 | SDHI2 card detect | Low | |
136 | * IRQ6 | ICR1A.IRQ6SA=0011 | Ether(LAN9220) | High | |
e2a53b7c | 137 | * IRQ7 | ICR1A.IRQ7SA=0010 | LCD Touch Panel | Low |
4b82b689 KM |
138 | * IRQ8 | ICR2A.IRQ8SA=0010 | MMC/SD card detect | Low |
139 | * IRQ9 | ICR2A.IRQ9SA=0010 | KEY(TCA6408) | Low | |
140 | * IRQ21 | ICR4A.IRQ21SA=0011 | Sensor(ADXL345) | High | |
141 | * IRQ22 | ICR4A.IRQ22SA=0011 | Sensor(AK8975) | High | |
25338f2e | 142 | */ |
4b82b689 | 143 | |
25338f2e KM |
144 | /* |
145 | * USB | |
146 | * | |
147 | * USB0 : CN22 : Function | |
148 | * USB1 : CN31 : Function/Host *1 | |
149 | * | |
150 | * J30 (for CN31) *1 | |
151 | * ----------+---------------+------------- | |
152 | * 1-2 short | VBUS 5V | Host | |
153 | * open | external VBUS | Function | |
154 | * | |
66ee3bef KM |
155 | * CAUTION |
156 | * | |
157 | * renesas_usbhs driver can use external interrupt mode | |
158 | * (which come from USB-PHY) or autonomy mode (it use own interrupt) | |
159 | * for detecting connection/disconnection when Function. | |
160 | * USB will be power OFF while it has been disconnecting | |
161 | * if external interrupt mode, and it is always power ON if autonomy mode, | |
162 | * | |
163 | * mackerel can not use external interrupt (IRQ7-PORT167) mode on "USB0", | |
164 | * because Touchscreen is using IRQ7-PORT40. | |
165 | * It is impossible to use IRQ7 demux on this board. | |
25338f2e | 166 | */ |
4b82b689 | 167 | |
6dff7da2 YG |
168 | /* |
169 | * SDHI0 (CN12) | |
170 | * | |
171 | * SW56 : OFF | |
172 | * | |
173 | */ | |
174 | ||
175 | /* MMC /SDHI1 (CN7) | |
176 | * | |
177 | * I/O voltage : 1.8v | |
178 | * | |
179 | * Power voltage : 1.8v or 3.3v | |
41491b9a | 180 | * J22 : select power voltage *1 |
6dff7da2 YG |
181 | * 1-2 pin : 1.8v |
182 | * 2-3 pin : 3.3v | |
183 | * | |
41491b9a YG |
184 | * *1 |
185 | * Please change J22 depends the card to be used. | |
186 | * MMC's OCR field set to support either voltage for the card inserted. | |
187 | * | |
6dff7da2 YG |
188 | * SW1 | SW33 |
189 | * | bit1 | bit2 | bit3 | bit4 | |
190 | * -------------+------+------+------+------- | |
2150dace SH |
191 | * MMC0 OFF | OFF | X | ON | X (Use MMCIF) |
192 | * SDHI1 OFF | ON | X | OFF | X (Use MFD_SH_MOBILE_SDHI) | |
6dff7da2 YG |
193 | * |
194 | */ | |
195 | ||
196 | /* | |
197 | * SDHI2 (CN23) | |
198 | * | |
199 | * microSD card sloct | |
200 | * | |
201 | */ | |
202 | ||
6d9b7dd0 KM |
203 | /* |
204 | * FSI - AK4642 | |
205 | * | |
206 | * it needs amixer settings for playing | |
207 | * | |
ffdfe2d5 | 208 | * amixer set "Headphone Enable" on |
6d9b7dd0 KM |
209 | */ |
210 | ||
70ccb28d GL |
211 | /* Fixed 3.3V and 1.8V regulators to be used by multiple devices */ |
212 | static struct regulator_consumer_supply fixed1v8_power_consumers[] = | |
1a44d72a | 213 | { |
70ccb28d GL |
214 | /* |
215 | * J22 on mackerel switches mmcif.0 and sdhi.1 between 1.8V and 3.3V | |
216 | * Since we cannot support both voltages, we support the default 1.8V | |
217 | */ | |
218 | REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"), | |
219 | REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"), | |
220 | REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"), | |
221 | REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"), | |
222 | }; | |
1a44d72a | 223 | |
70ccb28d | 224 | static struct regulator_consumer_supply fixed3v3_power_consumers[] = |
66ee3bef | 225 | { |
70ccb28d GL |
226 | REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"), |
227 | REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"), | |
228 | REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.2"), | |
229 | REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.2"), | |
230 | }; | |
66ee3bef | 231 | |
70ccb28d GL |
232 | /* Dummy supplies, where voltage doesn't matter */ |
233 | static struct regulator_consumer_supply dummy_supplies[] = { | |
234 | REGULATOR_SUPPLY("vddvario", "smsc911x"), | |
235 | REGULATOR_SUPPLY("vdd33a", "smsc911x"), | |
236 | }; | |
66ee3bef | 237 | |
920adc75 KM |
238 | /* MTD */ |
239 | static struct mtd_partition nor_flash_partitions[] = { | |
240 | { | |
241 | .name = "loader", | |
242 | .offset = 0x00000000, | |
243 | .size = 512 * 1024, | |
244 | .mask_flags = MTD_WRITEABLE, | |
245 | }, | |
246 | { | |
247 | .name = "bootenv", | |
248 | .offset = MTDPART_OFS_APPEND, | |
249 | .size = 512 * 1024, | |
250 | .mask_flags = MTD_WRITEABLE, | |
251 | }, | |
252 | { | |
253 | .name = "kernel_ro", | |
254 | .offset = MTDPART_OFS_APPEND, | |
255 | .size = 8 * 1024 * 1024, | |
256 | .mask_flags = MTD_WRITEABLE, | |
257 | }, | |
258 | { | |
259 | .name = "kernel", | |
260 | .offset = MTDPART_OFS_APPEND, | |
261 | .size = 8 * 1024 * 1024, | |
262 | }, | |
263 | { | |
264 | .name = "data", | |
265 | .offset = MTDPART_OFS_APPEND, | |
266 | .size = MTDPART_SIZ_FULL, | |
267 | }, | |
268 | }; | |
269 | ||
270 | static struct physmap_flash_data nor_flash_data = { | |
271 | .width = 2, | |
272 | .parts = nor_flash_partitions, | |
273 | .nr_parts = ARRAY_SIZE(nor_flash_partitions), | |
274 | }; | |
275 | ||
276 | static struct resource nor_flash_resources[] = { | |
277 | [0] = { | |
487881c0 MD |
278 | .start = 0x20000000, /* CS0 shadow instead of regular CS0 */ |
279 | .end = 0x28000000 - 1, /* needed by USB MASK ROM boot */ | |
920adc75 KM |
280 | .flags = IORESOURCE_MEM, |
281 | } | |
282 | }; | |
283 | ||
284 | static struct platform_device nor_flash_device = { | |
285 | .name = "physmap-flash", | |
286 | .dev = { | |
287 | .platform_data = &nor_flash_data, | |
288 | }, | |
289 | .num_resources = ARRAY_SIZE(nor_flash_resources), | |
290 | .resource = nor_flash_resources, | |
291 | }; | |
292 | ||
2264c151 KM |
293 | /* SMSC */ |
294 | static struct resource smc911x_resources[] = { | |
295 | { | |
296 | .start = 0x14000000, | |
297 | .end = 0x16000000 - 1, | |
298 | .flags = IORESOURCE_MEM, | |
299 | }, { | |
300 | .start = evt2irq(0x02c0) /* IRQ6A */, | |
301 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL, | |
302 | }, | |
303 | }; | |
304 | ||
305 | static struct smsc911x_platform_config smsc911x_info = { | |
306 | .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS, | |
307 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, | |
308 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, | |
309 | }; | |
310 | ||
311 | static struct platform_device smc911x_device = { | |
312 | .name = "smsc911x", | |
313 | .id = -1, | |
314 | .num_resources = ARRAY_SIZE(smc911x_resources), | |
315 | .resource = smc911x_resources, | |
316 | .dev = { | |
317 | .platform_data = &smsc911x_info, | |
318 | }, | |
319 | }; | |
320 | ||
1c7fcbed DHG |
321 | /* MERAM */ |
322 | static struct sh_mobile_meram_info mackerel_meram_info = { | |
323 | .addr_mode = SH_MOBILE_MERAM_MODE1, | |
324 | }; | |
325 | ||
326 | static struct resource meram_resources[] = { | |
327 | [0] = { | |
e71504d5 | 328 | .name = "regs", |
1c7fcbed | 329 | .start = 0xe8000000, |
e71504d5 LP |
330 | .end = 0xe807ffff, |
331 | .flags = IORESOURCE_MEM, | |
332 | }, | |
333 | [1] = { | |
334 | .name = "meram", | |
335 | .start = 0xe8080000, | |
1c7fcbed DHG |
336 | .end = 0xe81fffff, |
337 | .flags = IORESOURCE_MEM, | |
338 | }, | |
339 | }; | |
340 | ||
341 | static struct platform_device meram_device = { | |
342 | .name = "sh_mobile_meram", | |
343 | .id = 0, | |
344 | .num_resources = ARRAY_SIZE(meram_resources), | |
345 | .resource = meram_resources, | |
346 | .dev = { | |
347 | .platform_data = &mackerel_meram_info, | |
348 | }, | |
349 | }; | |
350 | ||
14bd03e0 | 351 | /* LCDC and backlight */ |
11fee467 KM |
352 | static struct fb_videomode mackerel_lcdc_modes[] = { |
353 | { | |
354 | .name = "WVGA Panel", | |
355 | .xres = 800, | |
356 | .yres = 480, | |
357 | .left_margin = 220, | |
358 | .right_margin = 110, | |
359 | .hsync_len = 70, | |
360 | .upper_margin = 20, | |
361 | .lower_margin = 5, | |
362 | .vsync_len = 5, | |
363 | .sync = 0, | |
364 | }, | |
365 | }; | |
366 | ||
c241a0e0 | 367 | static const struct sh_mobile_meram_cfg lcd_meram_cfg = { |
1c7fcbed | 368 | .icb[0] = { |
1c7fcbed DHG |
369 | .meram_size = 0x40, |
370 | }, | |
371 | .icb[1] = { | |
1c7fcbed DHG |
372 | .meram_size = 0x40, |
373 | }, | |
374 | }; | |
375 | ||
11fee467 | 376 | static struct sh_mobile_lcdc_info lcdc_info = { |
1c7fcbed | 377 | .meram_dev = &mackerel_meram_info, |
11fee467 KM |
378 | .clock_source = LCDC_CLK_BUS, |
379 | .ch[0] = { | |
380 | .chan = LCDC_CHAN_MAINLCD, | |
edd153a3 | 381 | .fourcc = V4L2_PIX_FMT_RGB565, |
93ff2598 LP |
382 | .lcd_modes = mackerel_lcdc_modes, |
383 | .num_modes = ARRAY_SIZE(mackerel_lcdc_modes), | |
11fee467 | 384 | .interface_type = RGB24, |
2c34e939 | 385 | .clock_divider = 3, |
11fee467 | 386 | .flags = 0, |
afaad83b LP |
387 | .panel_cfg = { |
388 | .width = 152, | |
389 | .height = 91, | |
1fbdfcde | 390 | }, |
1c7fcbed | 391 | .meram_cfg = &lcd_meram_cfg, |
11fee467 KM |
392 | } |
393 | }; | |
394 | ||
395 | static struct resource lcdc_resources[] = { | |
396 | [0] = { | |
397 | .name = "LCDC", | |
398 | .start = 0xfe940000, | |
399 | .end = 0xfe943fff, | |
400 | .flags = IORESOURCE_MEM, | |
401 | }, | |
402 | [1] = { | |
403 | .start = intcs_evt2irq(0x580), | |
404 | .flags = IORESOURCE_IRQ, | |
405 | }, | |
406 | }; | |
407 | ||
408 | static struct platform_device lcdc_device = { | |
409 | .name = "sh_mobile_lcdc_fb", | |
410 | .num_resources = ARRAY_SIZE(lcdc_resources), | |
411 | .resource = lcdc_resources, | |
412 | .dev = { | |
413 | .platform_data = &lcdc_info, | |
b6328a6b | 414 | .coherent_dma_mask = DMA_BIT_MASK(32), |
11fee467 KM |
415 | }, |
416 | }; | |
417 | ||
14bd03e0 LP |
418 | static struct gpio_backlight_platform_data gpio_backlight_data = { |
419 | .fbdev = &lcdc_device.dev, | |
420 | .gpio = 31, | |
421 | .def_value = 1, | |
422 | .name = "backlight", | |
423 | }; | |
424 | ||
425 | static struct platform_device gpio_backlight_device = { | |
426 | .name = "gpio-backlight", | |
427 | .dev = { | |
428 | .platform_data = &gpio_backlight_data, | |
429 | }, | |
430 | }; | |
431 | ||
a1022adb | 432 | /* HDMI */ |
a1022adb | 433 | static struct sh_mobile_hdmi_info hdmi_info = { |
a1022adb LP |
434 | .flags = HDMI_SND_SRC_SPDIF, |
435 | }; | |
436 | ||
437 | static struct resource hdmi_resources[] = { | |
438 | [0] = { | |
439 | .name = "HDMI", | |
440 | .start = 0xe6be0000, | |
441 | .end = 0xe6be00ff, | |
442 | .flags = IORESOURCE_MEM, | |
443 | }, | |
444 | [1] = { | |
445 | /* There's also an HDMI interrupt on INTCS @ 0x18e0 */ | |
446 | .start = evt2irq(0x17e0), | |
447 | .flags = IORESOURCE_IRQ, | |
448 | }, | |
449 | }; | |
450 | ||
451 | static struct platform_device hdmi_device = { | |
452 | .name = "sh-mobile-hdmi", | |
453 | .num_resources = ARRAY_SIZE(hdmi_resources), | |
454 | .resource = hdmi_resources, | |
455 | .id = -1, | |
456 | .dev = { | |
457 | .platform_data = &hdmi_info, | |
458 | }, | |
459 | }; | |
460 | ||
c241a0e0 | 461 | static const struct sh_mobile_meram_cfg hdmi_meram_cfg = { |
1c7fcbed | 462 | .icb[0] = { |
1c7fcbed DHG |
463 | .meram_size = 0x100, |
464 | }, | |
465 | .icb[1] = { | |
1c7fcbed DHG |
466 | .meram_size = 0x100, |
467 | }, | |
468 | }; | |
a1022adb | 469 | |
12c4309b | 470 | static struct sh_mobile_lcdc_info hdmi_lcdc_info = { |
1c7fcbed | 471 | .meram_dev = &mackerel_meram_info, |
12c4309b KM |
472 | .clock_source = LCDC_CLK_EXTERNAL, |
473 | .ch[0] = { | |
474 | .chan = LCDC_CHAN_MAINLCD, | |
edd153a3 | 475 | .fourcc = V4L2_PIX_FMT_RGB565, |
12c4309b KM |
476 | .interface_type = RGB24, |
477 | .clock_divider = 1, | |
478 | .flags = LCDC_FLAGS_DWPOL, | |
1c7fcbed | 479 | .meram_cfg = &hdmi_meram_cfg, |
a1022adb | 480 | .tx_dev = &hdmi_device, |
12c4309b KM |
481 | } |
482 | }; | |
483 | ||
484 | static struct resource hdmi_lcdc_resources[] = { | |
485 | [0] = { | |
486 | .name = "LCDC1", | |
487 | .start = 0xfe944000, | |
488 | .end = 0xfe947fff, | |
489 | .flags = IORESOURCE_MEM, | |
490 | }, | |
491 | [1] = { | |
492 | .start = intcs_evt2irq(0x1780), | |
493 | .flags = IORESOURCE_IRQ, | |
494 | }, | |
495 | }; | |
496 | ||
497 | static struct platform_device hdmi_lcdc_device = { | |
498 | .name = "sh_mobile_lcdc_fb", | |
499 | .num_resources = ARRAY_SIZE(hdmi_lcdc_resources), | |
500 | .resource = hdmi_lcdc_resources, | |
501 | .id = 1, | |
502 | .dev = { | |
503 | .platform_data = &hdmi_lcdc_info, | |
b6328a6b | 504 | .coherent_dma_mask = DMA_BIT_MASK(32), |
12c4309b KM |
505 | }, |
506 | }; | |
507 | ||
fa063b48 KM |
508 | static struct asoc_simple_card_info fsi2_hdmi_info = { |
509 | .name = "HDMI", | |
510 | .card = "FSI2B-HDMI", | |
fa063b48 KM |
511 | .codec = "sh-mobile-hdmi", |
512 | .platform = "sh_fsi2", | |
313c84b2 | 513 | .daifmt = SND_SOC_DAIFMT_CBS_CFS, |
a4a2992c KM |
514 | .cpu_dai = { |
515 | .name = "fsib-dai", | |
a4a2992c KM |
516 | }, |
517 | .codec_dai = { | |
518 | .name = "sh_mobile_hdmi-hifi", | |
519 | }, | |
fa063b48 KM |
520 | }; |
521 | ||
3f25c9cc | 522 | static struct platform_device fsi_hdmi_device = { |
fa063b48 KM |
523 | .name = "asoc-simple-card", |
524 | .id = 1, | |
525 | .dev = { | |
526 | .platform_data = &fsi2_hdmi_info, | |
ffb83e8c KM |
527 | .coherent_dma_mask = DMA_BIT_MASK(32), |
528 | .dma_mask = &fsi_hdmi_device.dev.coherent_dma_mask, | |
fa063b48 | 529 | }, |
3f25c9cc KM |
530 | }; |
531 | ||
2ce51f8b | 532 | static void __init hdmi_init_pm_clock(void) |
12c4309b KM |
533 | { |
534 | struct clk *hdmi_ick = clk_get(&hdmi_device.dev, "ick"); | |
535 | int ret; | |
536 | long rate; | |
537 | ||
538 | if (IS_ERR(hdmi_ick)) { | |
539 | ret = PTR_ERR(hdmi_ick); | |
540 | pr_err("Cannot get HDMI ICK: %d\n", ret); | |
541 | goto out; | |
542 | } | |
543 | ||
544 | ret = clk_set_parent(&sh7372_pllc2_clk, &sh7372_dv_clki_div2_clk); | |
545 | if (ret < 0) { | |
546 | pr_err("Cannot set PLLC2 parent: %d, %d users\n", | |
547 | ret, sh7372_pllc2_clk.usecount); | |
548 | goto out; | |
549 | } | |
550 | ||
551 | pr_debug("PLLC2 initial frequency %lu\n", | |
552 | clk_get_rate(&sh7372_pllc2_clk)); | |
553 | ||
554 | rate = clk_round_rate(&sh7372_pllc2_clk, 594000000); | |
90d423fa | 555 | if (rate <= 0) { |
12c4309b | 556 | pr_err("Cannot get suitable rate: %ld\n", rate); |
90d423fa | 557 | ret = -EINVAL; |
12c4309b KM |
558 | goto out; |
559 | } | |
560 | ||
561 | ret = clk_set_rate(&sh7372_pllc2_clk, rate); | |
562 | if (ret < 0) { | |
563 | pr_err("Cannot set rate %ld: %d\n", rate, ret); | |
564 | goto out; | |
565 | } | |
566 | ||
12c4309b KM |
567 | pr_debug("PLLC2 set frequency %lu\n", rate); |
568 | ||
569 | ret = clk_set_parent(hdmi_ick, &sh7372_pllc2_clk); | |
2ce51f8b | 570 | if (ret < 0) |
12c4309b | 571 | pr_err("Cannot set HDMI parent: %d\n", ret); |
12c4309b KM |
572 | |
573 | out: | |
574 | if (!IS_ERR(hdmi_ick)) | |
575 | clk_put(hdmi_ick); | |
12c4309b | 576 | } |
12c4309b | 577 | |
e2a53b7c MD |
578 | /* USBHS0 is connected to CN22 which takes a USB Mini-B plug |
579 | * | |
580 | * The sh7372 SoC has IRQ7 set aside for USBHS0 hotplug, | |
581 | * but on this particular board IRQ7 is already used by | |
582 | * the touch screen. This leaves us with software polling. | |
583 | */ | |
584 | #define USBHS0_POLL_INTERVAL (HZ * 5) | |
585 | ||
586 | struct usbhs_private { | |
0a4b04dc AB |
587 | void __iomem *usbphyaddr; |
588 | void __iomem *usbcrcaddr; | |
e2a53b7c MD |
589 | struct renesas_usbhs_platform_info info; |
590 | struct delayed_work work; | |
591 | struct platform_device *pdev; | |
592 | }; | |
593 | ||
594 | #define usbhs_get_priv(pdev) \ | |
595 | container_of(renesas_usbhs_get_info(pdev), \ | |
596 | struct usbhs_private, info) | |
597 | ||
598 | #define usbhs_is_connected(priv) \ | |
599 | (!((1 << 7) & __raw_readw(priv->usbcrcaddr))) | |
600 | ||
601 | static int usbhs_get_vbus(struct platform_device *pdev) | |
602 | { | |
603 | return usbhs_is_connected(usbhs_get_priv(pdev)); | |
604 | } | |
605 | ||
225da3e3 | 606 | static int usbhs_phy_reset(struct platform_device *pdev) |
e2a53b7c MD |
607 | { |
608 | struct usbhs_private *priv = usbhs_get_priv(pdev); | |
609 | ||
610 | /* init phy */ | |
611 | __raw_writew(0x8a0a, priv->usbcrcaddr); | |
225da3e3 KM |
612 | |
613 | return 0; | |
e2a53b7c MD |
614 | } |
615 | ||
616 | static int usbhs0_get_id(struct platform_device *pdev) | |
617 | { | |
618 | return USBHS_GADGET; | |
619 | } | |
620 | ||
621 | static void usbhs0_work_function(struct work_struct *work) | |
622 | { | |
623 | struct usbhs_private *priv = container_of(work, struct usbhs_private, | |
624 | work.work); | |
625 | ||
626 | renesas_usbhs_call_notify_hotplug(priv->pdev); | |
627 | schedule_delayed_work(&priv->work, USBHS0_POLL_INTERVAL); | |
628 | } | |
629 | ||
630 | static int usbhs0_hardware_init(struct platform_device *pdev) | |
631 | { | |
632 | struct usbhs_private *priv = usbhs_get_priv(pdev); | |
633 | ||
634 | priv->pdev = pdev; | |
635 | INIT_DELAYED_WORK(&priv->work, usbhs0_work_function); | |
636 | schedule_delayed_work(&priv->work, USBHS0_POLL_INTERVAL); | |
637 | return 0; | |
638 | } | |
639 | ||
225da3e3 | 640 | static int usbhs0_hardware_exit(struct platform_device *pdev) |
e2a53b7c MD |
641 | { |
642 | struct usbhs_private *priv = usbhs_get_priv(pdev); | |
643 | ||
644 | cancel_delayed_work_sync(&priv->work); | |
225da3e3 KM |
645 | |
646 | return 0; | |
e2a53b7c MD |
647 | } |
648 | ||
e2a53b7c | 649 | static struct usbhs_private usbhs0_private = { |
0a4b04dc | 650 | .usbcrcaddr = IOMEM(0xe605810c), /* USBCR2 */ |
e2a53b7c MD |
651 | .info = { |
652 | .platform_callback = { | |
653 | .hardware_init = usbhs0_hardware_init, | |
654 | .hardware_exit = usbhs0_hardware_exit, | |
655 | .phy_reset = usbhs_phy_reset, | |
656 | .get_id = usbhs0_get_id, | |
657 | .get_vbus = usbhs_get_vbus, | |
658 | }, | |
659 | .driver_param = { | |
660 | .buswait_bwait = 4, | |
fe437561 KM |
661 | .d0_tx_id = SHDMA_SLAVE_USB0_TX, |
662 | .d1_rx_id = SHDMA_SLAVE_USB0_RX, | |
e2a53b7c MD |
663 | }, |
664 | }, | |
665 | }; | |
666 | ||
667 | static struct resource usbhs0_resources[] = { | |
668 | [0] = { | |
669 | .name = "USBHS0", | |
670 | .start = 0xe6890000, | |
671 | .end = 0xe68900e6 - 1, | |
672 | .flags = IORESOURCE_MEM, | |
673 | }, | |
674 | [1] = { | |
675 | .start = evt2irq(0x1ca0) /* USB0_USB0I0 */, | |
676 | .flags = IORESOURCE_IRQ, | |
677 | }, | |
678 | }; | |
679 | ||
680 | static struct platform_device usbhs0_device = { | |
681 | .name = "renesas_usbhs", | |
682 | .id = 0, | |
683 | .dev = { | |
684 | .platform_data = &usbhs0_private.info, | |
685 | }, | |
686 | .num_resources = ARRAY_SIZE(usbhs0_resources), | |
687 | .resource = usbhs0_resources, | |
688 | }; | |
689 | ||
690 | /* USBHS1 is connected to CN31 which takes a USB Mini-AB plug | |
691 | * | |
692 | * Use J30 to select between Host and Function. This setting | |
693 | * can however not be detected by software. Hotplug of USBHS1 | |
694 | * is provided via IRQ8. | |
0ada2da5 KM |
695 | * |
696 | * Current USB1 works as "USB Host". | |
697 | * - set J30 "short" | |
698 | * | |
699 | * If you want to use it as "USB gadget", | |
700 | * - J30 "open" | |
701 | * - modify usbhs1_get_id() USBHS_HOST -> USBHS_GADGET | |
702 | * - add .get_vbus = usbhs_get_vbus in usbhs1_private | |
e26a6038 | 703 | * - check usbhs0_device(pio)/usbhs1_device(irq) order in mackerel_devices. |
e2a53b7c MD |
704 | */ |
705 | #define IRQ8 evt2irq(0x0300) | |
66ee3bef KM |
706 | #define USB_PHY_MODE (1 << 4) |
707 | #define USB_PHY_INT_EN ((1 << 3) | (1 << 2)) | |
708 | #define USB_PHY_ON (1 << 1) | |
709 | #define USB_PHY_OFF (1 << 0) | |
710 | #define USB_PHY_INT_CLR (USB_PHY_ON | USB_PHY_OFF) | |
711 | ||
66ee3bef KM |
712 | static irqreturn_t usbhs1_interrupt(int irq, void *data) |
713 | { | |
714 | struct platform_device *pdev = data; | |
715 | struct usbhs_private *priv = usbhs_get_priv(pdev); | |
716 | ||
717 | dev_dbg(&pdev->dev, "%s\n", __func__); | |
718 | ||
719 | renesas_usbhs_call_notify_hotplug(pdev); | |
720 | ||
721 | /* clear status */ | |
722 | __raw_writew(__raw_readw(priv->usbphyaddr) | USB_PHY_INT_CLR, | |
723 | priv->usbphyaddr); | |
724 | ||
725 | return IRQ_HANDLED; | |
726 | } | |
727 | ||
728 | static int usbhs1_hardware_init(struct platform_device *pdev) | |
729 | { | |
730 | struct usbhs_private *priv = usbhs_get_priv(pdev); | |
731 | int ret; | |
732 | ||
66ee3bef KM |
733 | /* clear interrupt status */ |
734 | __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->usbphyaddr); | |
735 | ||
e2a53b7c | 736 | ret = request_irq(IRQ8, usbhs1_interrupt, IRQF_TRIGGER_HIGH, |
66ee3bef KM |
737 | dev_name(&pdev->dev), pdev); |
738 | if (ret) { | |
739 | dev_err(&pdev->dev, "request_irq err\n"); | |
740 | return ret; | |
741 | } | |
742 | ||
743 | /* enable USB phy interrupt */ | |
744 | __raw_writew(USB_PHY_MODE | USB_PHY_INT_EN, priv->usbphyaddr); | |
745 | ||
746 | return 0; | |
747 | } | |
748 | ||
225da3e3 | 749 | static int usbhs1_hardware_exit(struct platform_device *pdev) |
66ee3bef KM |
750 | { |
751 | struct usbhs_private *priv = usbhs_get_priv(pdev); | |
752 | ||
753 | /* clear interrupt status */ | |
754 | __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->usbphyaddr); | |
755 | ||
e2a53b7c | 756 | free_irq(IRQ8, pdev); |
225da3e3 KM |
757 | |
758 | return 0; | |
66ee3bef KM |
759 | } |
760 | ||
05a7929f KM |
761 | static int usbhs1_get_id(struct platform_device *pdev) |
762 | { | |
0ada2da5 | 763 | return USBHS_HOST; |
05a7929f KM |
764 | } |
765 | ||
66ee3bef KM |
766 | static u32 usbhs1_pipe_cfg[] = { |
767 | USB_ENDPOINT_XFER_CONTROL, | |
768 | USB_ENDPOINT_XFER_ISOC, | |
769 | USB_ENDPOINT_XFER_ISOC, | |
770 | USB_ENDPOINT_XFER_BULK, | |
771 | USB_ENDPOINT_XFER_BULK, | |
772 | USB_ENDPOINT_XFER_BULK, | |
773 | USB_ENDPOINT_XFER_INT, | |
774 | USB_ENDPOINT_XFER_INT, | |
775 | USB_ENDPOINT_XFER_INT, | |
776 | USB_ENDPOINT_XFER_BULK, | |
777 | USB_ENDPOINT_XFER_BULK, | |
778 | USB_ENDPOINT_XFER_BULK, | |
779 | USB_ENDPOINT_XFER_BULK, | |
780 | USB_ENDPOINT_XFER_BULK, | |
781 | USB_ENDPOINT_XFER_BULK, | |
782 | USB_ENDPOINT_XFER_BULK, | |
783 | }; | |
784 | ||
785 | static struct usbhs_private usbhs1_private = { | |
0a4b04dc AB |
786 | .usbphyaddr = IOMEM(0xe60581e2), /* USBPHY1INTAP */ |
787 | .usbcrcaddr = IOMEM(0xe6058130), /* USBCR4 */ | |
66ee3bef KM |
788 | .info = { |
789 | .platform_callback = { | |
790 | .hardware_init = usbhs1_hardware_init, | |
791 | .hardware_exit = usbhs1_hardware_exit, | |
05a7929f | 792 | .get_id = usbhs1_get_id, |
e2a53b7c | 793 | .phy_reset = usbhs_phy_reset, |
66ee3bef KM |
794 | }, |
795 | .driver_param = { | |
796 | .buswait_bwait = 4, | |
f427eb64 | 797 | .has_otg = 1, |
66ee3bef KM |
798 | .pipe_type = usbhs1_pipe_cfg, |
799 | .pipe_size = ARRAY_SIZE(usbhs1_pipe_cfg), | |
fe437561 KM |
800 | .d0_tx_id = SHDMA_SLAVE_USB1_TX, |
801 | .d1_rx_id = SHDMA_SLAVE_USB1_RX, | |
66ee3bef KM |
802 | }, |
803 | }, | |
804 | }; | |
805 | ||
806 | static struct resource usbhs1_resources[] = { | |
807 | [0] = { | |
e2a53b7c MD |
808 | .name = "USBHS1", |
809 | .start = 0xe68b0000, | |
810 | .end = 0xe68b00e6 - 1, | |
66ee3bef KM |
811 | .flags = IORESOURCE_MEM, |
812 | }, | |
813 | [1] = { | |
814 | .start = evt2irq(0x1ce0) /* USB1_USB1I0 */, | |
815 | .flags = IORESOURCE_IRQ, | |
816 | }, | |
817 | }; | |
818 | ||
819 | static struct platform_device usbhs1_device = { | |
820 | .name = "renesas_usbhs", | |
821 | .id = 1, | |
822 | .dev = { | |
823 | .platform_data = &usbhs1_private.info, | |
c8c3243c KM |
824 | .dma_mask = &usbhs1_device.dev.coherent_dma_mask, |
825 | .coherent_dma_mask = DMA_BIT_MASK(32), | |
66ee3bef KM |
826 | }, |
827 | .num_resources = ARRAY_SIZE(usbhs1_resources), | |
828 | .resource = usbhs1_resources, | |
829 | }; | |
830 | ||
d44deb35 KM |
831 | /* LED */ |
832 | static struct gpio_led mackerel_leds[] = { | |
833 | { | |
834 | .name = "led0", | |
6d170aa0 | 835 | .gpio = 0, |
d44deb35 KM |
836 | .default_state = LEDS_GPIO_DEFSTATE_ON, |
837 | }, | |
838 | { | |
839 | .name = "led1", | |
6d170aa0 | 840 | .gpio = 1, |
d44deb35 KM |
841 | .default_state = LEDS_GPIO_DEFSTATE_ON, |
842 | }, | |
843 | { | |
844 | .name = "led2", | |
6d170aa0 | 845 | .gpio = 2, |
d44deb35 KM |
846 | .default_state = LEDS_GPIO_DEFSTATE_ON, |
847 | }, | |
848 | { | |
849 | .name = "led3", | |
6d170aa0 | 850 | .gpio = 159, |
d44deb35 KM |
851 | .default_state = LEDS_GPIO_DEFSTATE_ON, |
852 | } | |
853 | }; | |
854 | ||
855 | static struct gpio_led_platform_data mackerel_leds_pdata = { | |
856 | .leds = mackerel_leds, | |
857 | .num_leds = ARRAY_SIZE(mackerel_leds), | |
858 | }; | |
859 | ||
860 | static struct platform_device leds_device = { | |
861 | .name = "leds-gpio", | |
862 | .id = 0, | |
863 | .dev = { | |
864 | .platform_data = &mackerel_leds_pdata, | |
865 | }, | |
866 | }; | |
867 | ||
1a44d72a KM |
868 | /* FSI */ |
869 | #define IRQ_FSI evt2irq(0x1840) | |
870 | static struct sh_fsi_platform_info fsi_info = { | |
fec691e7 | 871 | .port_a = { |
c650a1f4 KM |
872 | .tx_id = SHDMA_SLAVE_FSIA_TX, |
873 | .rx_id = SHDMA_SLAVE_FSIA_RX, | |
fec691e7 KM |
874 | }, |
875 | .port_b = { | |
abca7581 KM |
876 | .flags = SH_FSI_CLK_CPG | |
877 | SH_FSI_FMT_SPDIF, | |
fec691e7 | 878 | } |
1a44d72a KM |
879 | }; |
880 | ||
881 | static struct resource fsi_resources[] = { | |
882 | [0] = { | |
c650a1f4 KM |
883 | /* we need 0xFE1F0000 to access DMA |
884 | * instead of 0xFE3C0000 */ | |
1a44d72a | 885 | .name = "FSI", |
c650a1f4 KM |
886 | .start = 0xFE1F0000, |
887 | .end = 0xFE1F0400 - 1, | |
1a44d72a KM |
888 | .flags = IORESOURCE_MEM, |
889 | }, | |
890 | [1] = { | |
891 | .start = IRQ_FSI, | |
892 | .flags = IORESOURCE_IRQ, | |
893 | }, | |
894 | }; | |
895 | ||
896 | static struct platform_device fsi_device = { | |
897 | .name = "sh_fsi2", | |
898 | .id = -1, | |
899 | .num_resources = ARRAY_SIZE(fsi_resources), | |
900 | .resource = fsi_resources, | |
901 | .dev = { | |
902 | .platform_data = &fsi_info, | |
903 | }, | |
904 | }; | |
905 | ||
af8a2fe1 | 906 | static struct asoc_simple_card_info fsi2_ak4643_info = { |
45f31216 KM |
907 | .name = "AK4643", |
908 | .card = "FSI2A-AK4643", | |
45f31216 KM |
909 | .codec = "ak4642-codec.0-0013", |
910 | .platform = "sh_fsi2", | |
c7a507ee | 911 | .daifmt = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_CBM_CFM, |
a4a2992c KM |
912 | .cpu_dai = { |
913 | .name = "fsia-dai", | |
a4a2992c KM |
914 | }, |
915 | .codec_dai = { | |
916 | .name = "ak4642-hifi", | |
a4a2992c KM |
917 | .sysclk = 11289600, |
918 | }, | |
45f31216 KM |
919 | }; |
920 | ||
1a44d72a | 921 | static struct platform_device fsi_ak4643_device = { |
af8a2fe1 | 922 | .name = "asoc-simple-card", |
45f31216 KM |
923 | .dev = { |
924 | .platform_data = &fsi2_ak4643_info, | |
ffb83e8c KM |
925 | .coherent_dma_mask = DMA_BIT_MASK(32), |
926 | .dma_mask = &fsi_ak4643_device.dev.coherent_dma_mask, | |
45f31216 | 927 | }, |
1a44d72a | 928 | }; |
d44deb35 | 929 | |
2aab52e8 BH |
930 | /* FLCTL */ |
931 | static struct mtd_partition nand_partition_info[] = { | |
932 | { | |
933 | .name = "system", | |
934 | .offset = 0, | |
935 | .size = 128 * 1024 * 1024, | |
936 | }, | |
937 | { | |
938 | .name = "userdata", | |
939 | .offset = MTDPART_OFS_APPEND, | |
940 | .size = 256 * 1024 * 1024, | |
941 | }, | |
942 | { | |
943 | .name = "cache", | |
944 | .offset = MTDPART_OFS_APPEND, | |
945 | .size = 128 * 1024 * 1024, | |
946 | }, | |
947 | }; | |
948 | ||
949 | static struct resource nand_flash_resources[] = { | |
950 | [0] = { | |
951 | .start = 0xe6a30000, | |
952 | .end = 0xe6a3009b, | |
953 | .flags = IORESOURCE_MEM, | |
3042ac57 BH |
954 | }, |
955 | [1] = { | |
956 | .start = evt2irq(0x0d80), /* flstei: status error irq */ | |
957 | .flags = IORESOURCE_IRQ, | |
958 | }, | |
2aab52e8 BH |
959 | }; |
960 | ||
961 | static struct sh_flctl_platform_data nand_flash_data = { | |
962 | .parts = nand_partition_info, | |
963 | .nr_parts = ARRAY_SIZE(nand_partition_info), | |
964 | .flcmncr_val = CLK_16B_12L_4H | TYPESEL_SET | |
965 | | SHBUSSEL | SEL_16BIT | SNAND_E, | |
966 | .use_holden = 1, | |
967 | }; | |
968 | ||
969 | static struct platform_device nand_flash_device = { | |
970 | .name = "sh_flctl", | |
971 | .resource = nand_flash_resources, | |
972 | .num_resources = ARRAY_SIZE(nand_flash_resources), | |
973 | .dev = { | |
974 | .platform_data = &nand_flash_data, | |
975 | }, | |
976 | }; | |
977 | ||
6dff7da2 YG |
978 | /* SDHI0 */ |
979 | static struct sh_mobile_sdhi_info sdhi0_info = { | |
980 | .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX, | |
981 | .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX, | |
2b3e38c4 | 982 | .tmio_flags = TMIO_MMC_USE_GPIO_CD, |
da97da73 | 983 | .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ, |
6d170aa0 | 984 | .cd_gpio = 172, |
6dff7da2 YG |
985 | }; |
986 | ||
987 | static struct resource sdhi0_resources[] = { | |
fb7a89c4 | 988 | { |
6dff7da2 YG |
989 | .name = "SDHI0", |
990 | .start = 0xe6850000, | |
31d31fe7 | 991 | .end = 0xe68500ff, |
6dff7da2 | 992 | .flags = IORESOURCE_MEM, |
fb7a89c4 | 993 | }, { |
757688c8 | 994 | .name = SH_MOBILE_SDHI_IRQ_SDCARD, |
2007aea1 SH |
995 | .start = evt2irq(0x0e20) /* SDHI0_SDHI0I1 */, |
996 | .flags = IORESOURCE_IRQ, | |
fb7a89c4 | 997 | }, { |
757688c8 | 998 | .name = SH_MOBILE_SDHI_IRQ_SDIO, |
2007aea1 | 999 | .start = evt2irq(0x0e40) /* SDHI0_SDHI0I2 */, |
6dff7da2 YG |
1000 | .flags = IORESOURCE_IRQ, |
1001 | }, | |
1002 | }; | |
1003 | ||
1004 | static struct platform_device sdhi0_device = { | |
1005 | .name = "sh_mobile_sdhi", | |
1006 | .num_resources = ARRAY_SIZE(sdhi0_resources), | |
1007 | .resource = sdhi0_resources, | |
1008 | .id = 0, | |
1009 | .dev = { | |
1010 | .platform_data = &sdhi0_info, | |
1011 | }, | |
1012 | }; | |
1013 | ||
00ae962f | 1014 | #if !IS_ENABLED(CONFIG_MMC_SH_MMCIF) |
6dff7da2 | 1015 | /* SDHI1 */ |
fe0a1441 GL |
1016 | |
1017 | /* GPIO 41 can trigger IRQ8, but it is used by USBHS1, we have to poll */ | |
6dff7da2 YG |
1018 | static struct sh_mobile_sdhi_info sdhi1_info = { |
1019 | .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX, | |
1020 | .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX, | |
fe0a1441 | 1021 | .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_USE_GPIO_CD, |
da97da73 | 1022 | .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ | |
6dff7da2 | 1023 | MMC_CAP_NEEDS_POLL, |
fe0a1441 | 1024 | .cd_gpio = 41, |
6dff7da2 YG |
1025 | }; |
1026 | ||
1027 | static struct resource sdhi1_resources[] = { | |
fb7a89c4 | 1028 | { |
6dff7da2 YG |
1029 | .name = "SDHI1", |
1030 | .start = 0xe6860000, | |
31d31fe7 | 1031 | .end = 0xe68600ff, |
6dff7da2 | 1032 | .flags = IORESOURCE_MEM, |
fb7a89c4 | 1033 | }, { |
cb2ccc32 | 1034 | .name = SH_MOBILE_SDHI_IRQ_SDCARD, |
2007aea1 SH |
1035 | .start = evt2irq(0x0ea0), /* SDHI1_SDHI1I1 */ |
1036 | .flags = IORESOURCE_IRQ, | |
fb7a89c4 | 1037 | }, { |
cb2ccc32 | 1038 | .name = SH_MOBILE_SDHI_IRQ_SDIO, |
2007aea1 | 1039 | .start = evt2irq(0x0ec0), /* SDHI1_SDHI1I2 */ |
6dff7da2 YG |
1040 | .flags = IORESOURCE_IRQ, |
1041 | }, | |
1042 | }; | |
1043 | ||
1044 | static struct platform_device sdhi1_device = { | |
1045 | .name = "sh_mobile_sdhi", | |
1046 | .num_resources = ARRAY_SIZE(sdhi1_resources), | |
1047 | .resource = sdhi1_resources, | |
1048 | .id = 1, | |
1049 | .dev = { | |
1050 | .platform_data = &sdhi1_info, | |
1051 | }, | |
1052 | }; | |
41491b9a | 1053 | #endif |
6dff7da2 | 1054 | |
fe0a1441 GL |
1055 | /* SDHI2 */ |
1056 | ||
da5d1f4c YG |
1057 | /* |
1058 | * The card detect pin of the top SD/MMC slot (CN23) is active low and is | |
fe0a1441 | 1059 | * connected to GPIO SCIFB_SCK of SH7372 (GPIO 162). |
da5d1f4c | 1060 | */ |
6dff7da2 YG |
1061 | static struct sh_mobile_sdhi_info sdhi2_info = { |
1062 | .dma_slave_tx = SHDMA_SLAVE_SDHI2_TX, | |
1063 | .dma_slave_rx = SHDMA_SLAVE_SDHI2_RX, | |
fe0a1441 | 1064 | .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_USE_GPIO_CD, |
da97da73 | 1065 | .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ | |
6dff7da2 | 1066 | MMC_CAP_NEEDS_POLL, |
fe0a1441 | 1067 | .cd_gpio = 162, |
6dff7da2 YG |
1068 | }; |
1069 | ||
1070 | static struct resource sdhi2_resources[] = { | |
fb7a89c4 | 1071 | { |
6dff7da2 YG |
1072 | .name = "SDHI2", |
1073 | .start = 0xe6870000, | |
31d31fe7 | 1074 | .end = 0xe68700ff, |
6dff7da2 | 1075 | .flags = IORESOURCE_MEM, |
fb7a89c4 | 1076 | }, { |
cb2ccc32 | 1077 | .name = SH_MOBILE_SDHI_IRQ_SDCARD, |
2007aea1 SH |
1078 | .start = evt2irq(0x1220), /* SDHI2_SDHI2I1 */ |
1079 | .flags = IORESOURCE_IRQ, | |
fb7a89c4 | 1080 | }, { |
cb2ccc32 | 1081 | .name = SH_MOBILE_SDHI_IRQ_SDIO, |
2007aea1 | 1082 | .start = evt2irq(0x1240), /* SDHI2_SDHI2I2 */ |
6dff7da2 YG |
1083 | .flags = IORESOURCE_IRQ, |
1084 | }, | |
1085 | }; | |
1086 | ||
1087 | static struct platform_device sdhi2_device = { | |
1088 | .name = "sh_mobile_sdhi", | |
1089 | .num_resources = ARRAY_SIZE(sdhi2_resources), | |
1090 | .resource = sdhi2_resources, | |
1091 | .id = 2, | |
1092 | .dev = { | |
1093 | .platform_data = &sdhi2_info, | |
1094 | }, | |
1095 | }; | |
1096 | ||
41491b9a | 1097 | /* SH_MMCIF */ |
00ae962f | 1098 | #if IS_ENABLED(CONFIG_MMC_SH_MMCIF) |
41491b9a YG |
1099 | static struct resource sh_mmcif_resources[] = { |
1100 | [0] = { | |
1101 | .name = "MMCIF", | |
1102 | .start = 0xE6BD0000, | |
1103 | .end = 0xE6BD00FF, | |
1104 | .flags = IORESOURCE_MEM, | |
1105 | }, | |
1106 | [1] = { | |
1107 | /* MMC ERR */ | |
1108 | .start = evt2irq(0x1ac0), | |
1109 | .flags = IORESOURCE_IRQ, | |
1110 | }, | |
1111 | [2] = { | |
1112 | /* MMC NOR */ | |
1113 | .start = evt2irq(0x1ae0), | |
1114 | .flags = IORESOURCE_IRQ, | |
1115 | }, | |
1116 | }; | |
1117 | ||
1118 | static struct sh_mmcif_plat_data sh_mmcif_plat = { | |
1119 | .sup_pclk = 0, | |
41491b9a YG |
1120 | .caps = MMC_CAP_4_BIT_DATA | |
1121 | MMC_CAP_8_BIT_DATA | | |
1122 | MMC_CAP_NEEDS_POLL, | |
fe0a1441 GL |
1123 | .use_cd_gpio = true, |
1124 | /* card detect pin for SD/MMC slot (CN7) */ | |
1125 | .cd_gpio = 41, | |
d5bb386d GL |
1126 | .slave_id_tx = SHDMA_SLAVE_MMCIF_TX, |
1127 | .slave_id_rx = SHDMA_SLAVE_MMCIF_RX, | |
41491b9a YG |
1128 | }; |
1129 | ||
00ae962f | 1130 | static struct platform_device sh_mmcif_device = { |
41491b9a YG |
1131 | .name = "sh_mmcif", |
1132 | .id = 0, | |
1133 | .dev = { | |
1134 | .dma_mask = NULL, | |
1135 | .coherent_dma_mask = 0xffffffff, | |
1136 | .platform_data = &sh_mmcif_plat, | |
1137 | }, | |
1138 | .num_resources = ARRAY_SIZE(sh_mmcif_resources), | |
1139 | .resource = sh_mmcif_resources, | |
1140 | }; | |
00ae962f | 1141 | #endif |
ae37c8de | 1142 | |
7dfff953 GL |
1143 | static int mackerel_camera_add(struct soc_camera_device *icd); |
1144 | static void mackerel_camera_del(struct soc_camera_device *icd); | |
ae37c8de MD |
1145 | |
1146 | static int camera_set_capture(struct soc_camera_platform_info *info, | |
1147 | int enable) | |
1148 | { | |
1149 | return 0; /* camera sensor always enabled */ | |
1150 | } | |
1151 | ||
1152 | static struct soc_camera_platform_info camera_info = { | |
1153 | .format_name = "UYVY", | |
1154 | .format_depth = 16, | |
1155 | .format = { | |
1156 | .code = V4L2_MBUS_FMT_UYVY8_2X8, | |
1157 | .colorspace = V4L2_COLORSPACE_SMPTE170M, | |
1158 | .field = V4L2_FIELD_NONE, | |
1159 | .width = 640, | |
1160 | .height = 480, | |
1161 | }, | |
d1e87ed7 GL |
1162 | .mbus_param = V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_MASTER | |
1163 | V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_HSYNC_ACTIVE_HIGH | | |
1164 | V4L2_MBUS_DATA_ACTIVE_HIGH, | |
1165 | .mbus_type = V4L2_MBUS_PARALLEL, | |
ae37c8de MD |
1166 | .set_capture = camera_set_capture, |
1167 | }; | |
1168 | ||
1169 | static struct soc_camera_link camera_link = { | |
1170 | .bus_id = 0, | |
1171 | .add_device = mackerel_camera_add, | |
1172 | .del_device = mackerel_camera_del, | |
1173 | .module_name = "soc_camera_platform", | |
1174 | .priv = &camera_info, | |
1175 | }; | |
1176 | ||
86a73144 GL |
1177 | static struct platform_device *camera_device; |
1178 | ||
1179 | static void mackerel_camera_release(struct device *dev) | |
ae37c8de | 1180 | { |
86a73144 | 1181 | soc_camera_platform_release(&camera_device); |
ae37c8de MD |
1182 | } |
1183 | ||
7dfff953 | 1184 | static int mackerel_camera_add(struct soc_camera_device *icd) |
ae37c8de | 1185 | { |
7dfff953 | 1186 | return soc_camera_platform_add(icd, &camera_device, &camera_link, |
86a73144 | 1187 | mackerel_camera_release, 0); |
ae37c8de MD |
1188 | } |
1189 | ||
7dfff953 | 1190 | static void mackerel_camera_del(struct soc_camera_device *icd) |
ae37c8de | 1191 | { |
7dfff953 | 1192 | soc_camera_platform_del(icd, camera_device, &camera_link); |
ae37c8de MD |
1193 | } |
1194 | ||
1195 | static struct sh_mobile_ceu_info sh_mobile_ceu_info = { | |
1196 | .flags = SH_CEU_FLAG_USE_8BIT_BUS, | |
ef8f41ff GL |
1197 | .max_width = 8188, |
1198 | .max_height = 8188, | |
ae37c8de MD |
1199 | }; |
1200 | ||
1201 | static struct resource ceu_resources[] = { | |
1202 | [0] = { | |
1203 | .name = "CEU", | |
1204 | .start = 0xfe910000, | |
1205 | .end = 0xfe91009f, | |
1206 | .flags = IORESOURCE_MEM, | |
1207 | }, | |
1208 | [1] = { | |
1209 | .start = intcs_evt2irq(0x880), | |
1210 | .flags = IORESOURCE_IRQ, | |
1211 | }, | |
1212 | [2] = { | |
1213 | /* place holder for contiguous memory */ | |
1214 | }, | |
1215 | }; | |
1216 | ||
1217 | static struct platform_device ceu_device = { | |
1218 | .name = "sh_mobile_ceu", | |
1219 | .id = 0, /* "ceu0" clock */ | |
1220 | .num_resources = ARRAY_SIZE(ceu_resources), | |
1221 | .resource = ceu_resources, | |
1222 | .dev = { | |
05a5f01c GL |
1223 | .platform_data = &sh_mobile_ceu_info, |
1224 | .coherent_dma_mask = 0xffffffff, | |
ae37c8de MD |
1225 | }, |
1226 | }; | |
1227 | ||
1228 | static struct platform_device mackerel_camera = { | |
1229 | .name = "soc-camera-pdrv", | |
1230 | .id = 0, | |
1231 | .dev = { | |
1232 | .platform_data = &camera_link, | |
1233 | }, | |
1234 | }; | |
1235 | ||
920adc75 KM |
1236 | static struct platform_device *mackerel_devices[] __initdata = { |
1237 | &nor_flash_device, | |
2264c151 | 1238 | &smc911x_device, |
11fee467 | 1239 | &lcdc_device, |
14bd03e0 | 1240 | &gpio_backlight_device, |
5a568552 | 1241 | &usbhs0_device, |
e26a6038 | 1242 | &usbhs1_device, |
d44deb35 | 1243 | &leds_device, |
1a44d72a KM |
1244 | &fsi_device, |
1245 | &fsi_ak4643_device, | |
3f25c9cc | 1246 | &fsi_hdmi_device, |
2aab52e8 | 1247 | &nand_flash_device, |
6dff7da2 | 1248 | &sdhi0_device, |
00ae962f | 1249 | #if !IS_ENABLED(CONFIG_MMC_SH_MMCIF) |
6dff7da2 | 1250 | &sdhi1_device, |
00ae962f GL |
1251 | #else |
1252 | &sh_mmcif_device, | |
41491b9a | 1253 | #endif |
6dff7da2 | 1254 | &sdhi2_device, |
ae37c8de MD |
1255 | &ceu_device, |
1256 | &mackerel_camera, | |
12c4309b | 1257 | &hdmi_device, |
a1022adb | 1258 | &hdmi_lcdc_device, |
1c7fcbed | 1259 | &meram_device, |
1a44d72a KM |
1260 | }; |
1261 | ||
cd8ab004 TS |
1262 | /* Keypad Initialization */ |
1263 | #define KEYPAD_BUTTON(ev_type, ev_code, act_low) \ | |
1264 | { \ | |
1265 | .type = ev_type, \ | |
1266 | .code = ev_code, \ | |
1267 | .active_low = act_low, \ | |
1268 | } | |
1269 | ||
1270 | #define KEYPAD_BUTTON_LOW(event_code) KEYPAD_BUTTON(EV_KEY, event_code, 1) | |
1271 | ||
1272 | static struct tca6416_button mackerel_gpio_keys[] = { | |
1273 | KEYPAD_BUTTON_LOW(KEY_HOME), | |
1274 | KEYPAD_BUTTON_LOW(KEY_MENU), | |
1275 | KEYPAD_BUTTON_LOW(KEY_BACK), | |
1276 | KEYPAD_BUTTON_LOW(KEY_POWER), | |
1277 | }; | |
1278 | ||
1279 | static struct tca6416_keys_platform_data mackerel_tca6416_keys_info = { | |
1280 | .buttons = mackerel_gpio_keys, | |
1281 | .nbuttons = ARRAY_SIZE(mackerel_gpio_keys), | |
1282 | .rep = 1, | |
1283 | .use_polling = 0, | |
1284 | .pinmask = 0x000F, | |
1285 | }; | |
1286 | ||
1a44d72a | 1287 | /* I2C */ |
6ae1e19d | 1288 | #define IRQ7 evt2irq(0x02e0) |
cd8ab004 TS |
1289 | #define IRQ9 evt2irq(0x0320) |
1290 | ||
1a44d72a KM |
1291 | static struct i2c_board_info i2c0_devices[] = { |
1292 | { | |
1293 | I2C_BOARD_INFO("ak4643", 0x13), | |
1294 | }, | |
cd8ab004 TS |
1295 | /* Keypad */ |
1296 | { | |
1297 | I2C_BOARD_INFO("tca6408-keys", 0x20), | |
1298 | .platform_data = &mackerel_tca6416_keys_info, | |
1299 | .irq = IRQ9, | |
1300 | }, | |
6ae1e19d TS |
1301 | /* Touchscreen */ |
1302 | { | |
1303 | I2C_BOARD_INFO("st1232-ts", 0x55), | |
1304 | .irq = IRQ7, | |
1305 | }, | |
920adc75 KM |
1306 | }; |
1307 | ||
80f1dc7c TS |
1308 | #define IRQ21 evt2irq(0x32a0) |
1309 | ||
1310 | static struct i2c_board_info i2c1_devices[] = { | |
1311 | /* Accelerometer */ | |
1312 | { | |
1313 | I2C_BOARD_INFO("adxl34x", 0x53), | |
1314 | .irq = IRQ21, | |
1315 | }, | |
1316 | }; | |
1317 | ||
3a8067f7 LP |
1318 | static unsigned long pin_pulldown_conf[] = { |
1319 | PIN_CONF_PACKED(PIN_CONFIG_BIAS_PULL_DOWN, 0), | |
1320 | }; | |
1321 | ||
26e19bd4 | 1322 | static const struct pinctrl_map mackerel_pinctrl_map[] = { |
cd87d903 LP |
1323 | /* ADXL34X */ |
1324 | PIN_MAP_MUX_GROUP_DEFAULT("1-0053", "pfc-sh7372", | |
1325 | "intc_irq21", "intc"), | |
0acbc34c LP |
1326 | /* CEU */ |
1327 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_ceu.0", "pfc-sh7372", | |
1328 | "ceu_data_0_7", "ceu"), | |
1329 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_ceu.0", "pfc-sh7372", | |
1330 | "ceu_clk_0", "ceu"), | |
1331 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_ceu.0", "pfc-sh7372", | |
1332 | "ceu_sync", "ceu"), | |
1333 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_ceu.0", "pfc-sh7372", | |
1334 | "ceu_field", "ceu"), | |
7e4f07d7 LP |
1335 | /* FLCTL */ |
1336 | PIN_MAP_MUX_GROUP_DEFAULT("sh_flctl.0", "pfc-sh7372", | |
1337 | "flctl_data", "flctl"), | |
1338 | PIN_MAP_MUX_GROUP_DEFAULT("sh_flctl.0", "pfc-sh7372", | |
1339 | "flctl_ce0", "flctl"), | |
1340 | PIN_MAP_MUX_GROUP_DEFAULT("sh_flctl.0", "pfc-sh7372", | |
1341 | "flctl_ctrl", "flctl"), | |
d39a1579 LP |
1342 | /* FSIA (AK4643) */ |
1343 | PIN_MAP_MUX_GROUP_DEFAULT("asoc-simple-card.0", "pfc-sh7372", | |
1344 | "fsia_sclk_in", "fsia"), | |
1345 | PIN_MAP_MUX_GROUP_DEFAULT("asoc-simple-card.0", "pfc-sh7372", | |
1346 | "fsia_data_in", "fsia"), | |
1347 | PIN_MAP_MUX_GROUP_DEFAULT("asoc-simple-card.0", "pfc-sh7372", | |
1348 | "fsia_data_out", "fsia"), | |
1349 | /* FSIB (HDMI) */ | |
1350 | PIN_MAP_MUX_GROUP_DEFAULT("asoc-simple-card.1", "pfc-sh7372", | |
1351 | "fsib_mclk_in", "fsib"), | |
cfced2c8 LP |
1352 | /* HDMI */ |
1353 | PIN_MAP_MUX_GROUP_DEFAULT("sh-mobile-hdmi", "pfc-sh7372", | |
1354 | "hdmi", "hdmi"), | |
845a802c LP |
1355 | /* LCDC */ |
1356 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-sh7372", | |
1357 | "lcd_data24", "lcd"), | |
1358 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-sh7372", | |
1359 | "lcd_sync", "lcd"), | |
0dcea785 LP |
1360 | /* SCIFA0 */ |
1361 | PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.0", "pfc-sh7372", | |
1362 | "scifa0_data", "scifa0"), | |
1363 | /* SCIFA2 (GT-720F GPS module) */ | |
1364 | PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.2", "pfc-sh7372", | |
1365 | "scifa2_data", "scifa2"), | |
26e19bd4 LP |
1366 | /* SDHI0 */ |
1367 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh7372", | |
1368 | "sdhi0_data4", "sdhi0"), | |
1369 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh7372", | |
1370 | "sdhi0_ctrl", "sdhi0"), | |
1371 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh7372", | |
1372 | "sdhi0_wp", "sdhi0"), | |
886c5353 LP |
1373 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh7372", |
1374 | "intc_irq26_1", "intc"), | |
26e19bd4 | 1375 | /* SDHI1 */ |
00ae962f | 1376 | #if !IS_ENABLED(CONFIG_MMC_SH_MMCIF) |
26e19bd4 LP |
1377 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-sh7372", |
1378 | "sdhi1_data4", "sdhi1"), | |
1379 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-sh7372", | |
1380 | "sdhi1_ctrl", "sdhi1"), | |
00ae962f GL |
1381 | #else |
1382 | /* MMCIF */ | |
1383 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-sh7372", | |
1384 | "mmc0_data8_0", "mmc0"), | |
1385 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-sh7372", | |
1386 | "mmc0_ctrl_0", "mmc0"), | |
26e19bd4 LP |
1387 | #endif |
1388 | /* SDHI2 */ | |
1389 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-sh7372", | |
1390 | "sdhi2_data4", "sdhi2"), | |
1391 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-sh7372", | |
1392 | "sdhi2_ctrl", "sdhi2"), | |
98f2d364 LP |
1393 | /* SMSC911X */ |
1394 | PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-sh7372", | |
1395 | "bsc_cs5a", "bsc"), | |
1396 | PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-sh7372", | |
1397 | "intc_irq6_0", "intc"), | |
a4bb4887 LP |
1398 | /* ST1232 */ |
1399 | PIN_MAP_MUX_GROUP_DEFAULT("0-0055", "pfc-sh7372", | |
1400 | "intc_irq7_0", "intc"), | |
47f90289 LP |
1401 | /* TCA6416 */ |
1402 | PIN_MAP_MUX_GROUP_DEFAULT("0-0020", "pfc-sh7372", | |
1403 | "intc_irq9_0", "intc"), | |
c135190d LP |
1404 | /* USBHS0 */ |
1405 | PIN_MAP_MUX_GROUP_DEFAULT("renesas_usbhs.0", "pfc-sh7372", | |
1406 | "usb0_vbus", "usb0"), | |
3a8067f7 LP |
1407 | PIN_MAP_CONFIGS_GROUP_DEFAULT("renesas_usbhs.0", "pfc-sh7372", |
1408 | "usb0_vbus", pin_pulldown_conf), | |
c135190d LP |
1409 | /* USBHS1 */ |
1410 | PIN_MAP_MUX_GROUP_DEFAULT("renesas_usbhs.1", "pfc-sh7372", | |
1411 | "usb1_vbus", "usb1"), | |
b58c8e7b | 1412 | PIN_MAP_CONFIGS_GROUP_DEFAULT("renesas_usbhs.1", "pfc-sh7372", |
3a8067f7 | 1413 | "usb1_vbus", pin_pulldown_conf), |
c135190d LP |
1414 | PIN_MAP_MUX_GROUP_DEFAULT("renesas_usbhs.1", "pfc-sh7372", |
1415 | "usb1_otg_id_0", "usb1"), | |
26e19bd4 LP |
1416 | }; |
1417 | ||
0a4b04dc AB |
1418 | #define GPIO_PORT9CR IOMEM(0xE6051009) |
1419 | #define GPIO_PORT10CR IOMEM(0xE605100A) | |
0a4b04dc AB |
1420 | #define SRCR4 IOMEM(0xe61580bc) |
1421 | #define USCCR1 IOMEM(0xE6058144) | |
920adc75 KM |
1422 | static void __init mackerel_init(void) |
1423 | { | |
d6dc6ed8 | 1424 | static struct pm_domain_device domain_devices[] __initdata = { |
ac18e02d RW |
1425 | { "A4LC", &lcdc_device, }, |
1426 | { "A4LC", &hdmi_lcdc_device, }, | |
1427 | { "A4LC", &meram_device, }, | |
1428 | { "A4MP", &fsi_device, }, | |
1429 | { "A3SP", &usbhs0_device, }, | |
1430 | { "A3SP", &usbhs1_device, }, | |
1431 | { "A3SP", &nand_flash_device, }, | |
ac18e02d | 1432 | { "A3SP", &sdhi0_device, }, |
00ae962f | 1433 | #if !IS_ENABLED(CONFIG_MMC_SH_MMCIF) |
ac18e02d | 1434 | { "A3SP", &sdhi1_device, }, |
00ae962f GL |
1435 | #else |
1436 | { "A3SP", &sh_mmcif_device, }, | |
ac18e02d RW |
1437 | #endif |
1438 | { "A3SP", &sdhi2_device, }, | |
1439 | { "A4R", &ceu_device, }, | |
b42879e2 | 1440 | }; |
12c4309b | 1441 | u32 srcr4; |
98d27b8a | 1442 | struct clk *clk; |
12c4309b | 1443 | |
70ccb28d GL |
1444 | regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers, |
1445 | ARRAY_SIZE(fixed1v8_power_consumers), 1800000); | |
1446 | regulator_register_always_on(1, "fixed-3.3V", fixed3v3_power_consumers, | |
1447 | ARRAY_SIZE(fixed3v3_power_consumers), 3300000); | |
1448 | regulator_register_fixed(2, dummy_supplies, ARRAY_SIZE(dummy_supplies)); | |
1449 | ||
12bb16d2 MD |
1450 | /* External clock source */ |
1451 | clk_set_rate(&sh7372_dv_clki_clk, 27000000); | |
1452 | ||
26e19bd4 LP |
1453 | pinctrl_register_mappings(mackerel_pinctrl_map, |
1454 | ARRAY_SIZE(mackerel_pinctrl_map)); | |
920adc75 KM |
1455 | sh7372_pinmux_init(); |
1456 | ||
6d170aa0 | 1457 | gpio_request_one(151, GPIOF_OUT_INIT_HIGH, NULL); /* LCDDON */ |
11fee467 | 1458 | |
d39a1579 | 1459 | /* FSI2 port A (ak4643) */ |
6d170aa0 | 1460 | gpio_request_one(161, GPIOF_OUT_INIT_LOW, NULL); /* slave */ |
1a44d72a | 1461 | |
6d170aa0 LP |
1462 | gpio_request(9, NULL); |
1463 | gpio_request(10, NULL); | |
c721e0cb KM |
1464 | gpio_direction_none(GPIO_PORT9CR); /* FSIAOBT needs no direction */ |
1465 | gpio_direction_none(GPIO_PORT10CR); /* FSIAOLR needs no direction */ | |
1a44d72a KM |
1466 | |
1467 | intc_set_priority(IRQ_FSI, 3); /* irq priority FSI(3) > SMSC911X(2) */ | |
1468 | ||
d39a1579 | 1469 | /* FSI2 port B (HDMI) */ |
98d27b8a KM |
1470 | __raw_writew(__raw_readw(USCCR1) & ~(1 << 6), USCCR1); /* use SPDIF */ |
1471 | ||
1472 | /* set SPU2 clock to 119.6 MHz */ | |
1473 | clk = clk_get(NULL, "spu_clk"); | |
1474 | if (!IS_ERR(clk)) { | |
1475 | clk_set_rate(clk, clk_round_rate(clk, 119600000)); | |
1476 | clk_put(clk); | |
1477 | } | |
1478 | ||
47f90289 | 1479 | /* Keypad */ |
6845664a | 1480 | irq_set_irq_type(IRQ9, IRQ_TYPE_LEVEL_HIGH); |
cd8ab004 | 1481 | |
a4bb4887 | 1482 | /* Touchscreen */ |
6845664a | 1483 | irq_set_irq_type(IRQ7, IRQ_TYPE_LEVEL_LOW); |
6ae1e19d | 1484 | |
cd87d903 | 1485 | /* Accelerometer */ |
6845664a | 1486 | irq_set_irq_type(IRQ21, IRQ_TYPE_LEVEL_HIGH); |
1a44d72a | 1487 | |
12c4309b KM |
1488 | /* Reset HDMI, must be held at least one EXTALR (32768Hz) period */ |
1489 | srcr4 = __raw_readl(SRCR4); | |
1490 | __raw_writel(srcr4 | (1 << 13), SRCR4); | |
1491 | udelay(50); | |
1492 | __raw_writel(srcr4 & ~(1 << 13), SRCR4); | |
1493 | ||
1a44d72a KM |
1494 | i2c_register_board_info(0, i2c0_devices, |
1495 | ARRAY_SIZE(i2c0_devices)); | |
80f1dc7c TS |
1496 | i2c_register_board_info(1, i2c1_devices, |
1497 | ARRAY_SIZE(i2c1_devices)); | |
11fee467 | 1498 | |
920adc75 KM |
1499 | sh7372_add_standard_devices(); |
1500 | ||
1501 | platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices)); | |
2ce51f8b | 1502 | |
ac18e02d RW |
1503 | rmobile_add_devices_to_domains(domain_devices, |
1504 | ARRAY_SIZE(domain_devices)); | |
e3e01091 | 1505 | |
2ce51f8b | 1506 | hdmi_init_pm_clock(); |
97991657 | 1507 | sh7372_pm_init(); |
a41b6466 | 1508 | pm_clk_add(&fsi_device.dev, "spu2"); |
5c3f96b2 | 1509 | pm_clk_add(&hdmi_lcdc_device.dev, "hdmi"); |
920adc75 KM |
1510 | } |
1511 | ||
0ce53cdc NI |
1512 | static const char *mackerel_boards_compat_dt[] __initdata = { |
1513 | "renesas,mackerel", | |
1514 | NULL, | |
1515 | }; | |
1516 | ||
1517 | DT_MACHINE_START(MACKEREL_DT, "mackerel") | |
426f1af9 | 1518 | .map_io = sh7372_map_io, |
5d7220ec | 1519 | .init_early = sh7372_add_early_devices, |
920adc75 | 1520 | .init_irq = sh7372_init_irq, |
863b1719 | 1521 | .handle_irq = shmobile_handle_irq_intc, |
920adc75 | 1522 | .init_machine = mackerel_init, |
caaca999 | 1523 | .init_late = sh7372_pm_init_late, |
6bb27d73 | 1524 | .init_time = sh7372_earlytimer_init, |
0ce53cdc | 1525 | .dt_compat = mackerel_boards_compat_dt, |
920adc75 | 1526 | MACHINE_END |