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