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/sh_mobile_sdhi.h> |
36 | #include <linux/mfd/tmio.h> | |
37 | #include <linux/mmc/host.h> | |
41491b9a | 38 | #include <linux/mmc/sh_mmcif.h> |
920adc75 KM |
39 | #include <linux/mtd/mtd.h> |
40 | #include <linux/mtd/partitions.h> | |
41 | #include <linux/mtd/physmap.h> | |
2264c151 | 42 | #include <linux/smsc911x.h> |
1a44d72a | 43 | #include <linux/sh_intc.h> |
cd8ab004 | 44 | #include <linux/tca6416_keypad.h> |
25338f2e | 45 | #include <linux/usb/r8a66597.h> |
920adc75 | 46 | |
12c4309b | 47 | #include <video/sh_mobile_hdmi.h> |
11fee467 | 48 | #include <video/sh_mobile_lcdc.h> |
ae37c8de MD |
49 | #include <media/sh_mobile_ceu.h> |
50 | #include <media/soc_camera.h> | |
51 | #include <media/soc_camera_platform.h> | |
1a44d72a KM |
52 | #include <sound/sh_fsi.h> |
53 | ||
920adc75 KM |
54 | #include <mach/common.h> |
55 | #include <mach/sh7372.h> | |
56 | ||
57 | #include <asm/mach/arch.h> | |
58 | #include <asm/mach/time.h> | |
59 | #include <asm/mach/map.h> | |
60 | #include <asm/mach-types.h> | |
61 | ||
62 | /* | |
63 | * Address Interface BusWidth note | |
64 | * ------------------------------------------------------------------ | |
65 | * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON | |
66 | * 0x0800_0000 user area - | |
67 | * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF | |
68 | * 0x1400_0000 Ether (LAN9220) 16bit | |
69 | * 0x1600_0000 user area - cannot use with NAND | |
70 | * 0x1800_0000 user area - | |
71 | * 0x1A00_0000 - | |
72 | * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit | |
73 | */ | |
74 | ||
4b82b689 KM |
75 | /* |
76 | * CPU mode | |
77 | * | |
78 | * SW4 | Boot Area| Master | Remarks | |
79 | * 1 | 2 | 3 | 4 | 5 | 6 | 8 | | Processor| | |
80 | * ----+-----+-----+-----+-----+-----+-----+----------+----------+-------------- | |
81 | * ON | ON | OFF | ON | ON | OFF | OFF | External | System | External ROM | |
82 | * ON | ON | ON | ON | ON | OFF | OFF | External | System | ROM Debug | |
83 | * ON | ON | X | ON | OFF | OFF | OFF | Built-in | System | ROM Debug | |
84 | * X | OFF | X | X | X | X | OFF | Built-in | System | MaskROM | |
85 | * OFF | X | X | X | X | X | OFF | Built-in | System | MaskROM | |
86 | * X | X | X | OFF | X | X | OFF | Built-in | System | MaskROM | |
87 | * OFF | ON | OFF | X | X | OFF | ON | External | System | Standalone | |
88 | * ON | OFF | OFF | X | X | OFF | ON | External | Realtime | Standalone | |
89 | */ | |
90 | ||
91 | /* | |
92 | * NOR Flash ROM | |
93 | * | |
94 | * SW1 | SW2 | SW7 | NOR Flash ROM | |
95 | * bit1 | bit1 bit2 | bit1 | Memory allocation | |
96 | * ------+------------+------+------------------ | |
97 | * OFF | ON OFF | ON | Area 0 | |
98 | * OFF | ON OFF | OFF | Area 4 | |
99 | */ | |
100 | ||
101 | /* | |
102 | * SMSC 9220 | |
103 | * | |
104 | * SW1 SMSC 9220 | |
105 | * ----------------------- | |
106 | * ON access disable | |
107 | * OFF access enable | |
108 | */ | |
109 | ||
110 | /* | |
111 | * NAND Flash ROM | |
112 | * | |
113 | * SW1 | SW2 | SW7 | NAND Flash ROM | |
114 | * bit1 | bit1 bit2 | bit2 | Memory allocation | |
115 | * ------+------------+------+------------------ | |
116 | * OFF | ON OFF | ON | FCE 0 | |
117 | * OFF | ON OFF | OFF | FCE 1 | |
118 | */ | |
119 | ||
120 | /* | |
121 | * External interrupt pin settings | |
122 | * | |
123 | * IRQX | pin setting | device | level | |
124 | * ------+--------------------+--------------------+------- | |
125 | * IRQ0 | ICR1A.IRQ0SA=0010 | SDHI2 card detect | Low | |
126 | * IRQ6 | ICR1A.IRQ6SA=0011 | Ether(LAN9220) | High | |
127 | * IRQ7 | ICR1A.IRQ7SA=0010 | LCD Tuch Panel | Low | |
128 | * IRQ8 | ICR2A.IRQ8SA=0010 | MMC/SD card detect | Low | |
129 | * IRQ9 | ICR2A.IRQ9SA=0010 | KEY(TCA6408) | Low | |
130 | * IRQ21 | ICR4A.IRQ21SA=0011 | Sensor(ADXL345) | High | |
131 | * IRQ22 | ICR4A.IRQ22SA=0011 | Sensor(AK8975) | High | |
25338f2e | 132 | */ |
4b82b689 | 133 | |
25338f2e KM |
134 | /* |
135 | * USB | |
136 | * | |
137 | * USB0 : CN22 : Function | |
138 | * USB1 : CN31 : Function/Host *1 | |
139 | * | |
140 | * J30 (for CN31) *1 | |
141 | * ----------+---------------+------------- | |
142 | * 1-2 short | VBUS 5V | Host | |
143 | * open | external VBUS | Function | |
144 | * | |
145 | * *1 | |
146 | * CN31 is used as Host in Linux. | |
147 | */ | |
4b82b689 | 148 | |
6dff7da2 YG |
149 | /* |
150 | * SDHI0 (CN12) | |
151 | * | |
152 | * SW56 : OFF | |
153 | * | |
154 | */ | |
155 | ||
156 | /* MMC /SDHI1 (CN7) | |
157 | * | |
158 | * I/O voltage : 1.8v | |
159 | * | |
160 | * Power voltage : 1.8v or 3.3v | |
41491b9a | 161 | * J22 : select power voltage *1 |
6dff7da2 YG |
162 | * 1-2 pin : 1.8v |
163 | * 2-3 pin : 3.3v | |
164 | * | |
41491b9a YG |
165 | * *1 |
166 | * Please change J22 depends the card to be used. | |
167 | * MMC's OCR field set to support either voltage for the card inserted. | |
168 | * | |
6dff7da2 YG |
169 | * SW1 | SW33 |
170 | * | bit1 | bit2 | bit3 | bit4 | |
171 | * -------------+------+------+------+------- | |
172 | * MMC0 OFF | OFF | ON | ON | X | |
173 | * MMC1 ON | OFF | ON | X | ON | |
174 | * SDHI1 OFF | ON | X | OFF | ON | |
175 | * | |
176 | */ | |
177 | ||
178 | /* | |
179 | * SDHI2 (CN23) | |
180 | * | |
181 | * microSD card sloct | |
182 | * | |
183 | */ | |
184 | ||
1a44d72a KM |
185 | /* |
186 | * FIXME !! | |
187 | * | |
188 | * gpio_no_direction | |
189 | * are quick_hack. | |
190 | * | |
191 | * current gpio frame work doesn't have | |
192 | * the method to control only pull up/down/free. | |
193 | * this function should be replaced by correct gpio function | |
194 | */ | |
195 | static void __init gpio_no_direction(u32 addr) | |
196 | { | |
197 | __raw_writeb(0x00, addr); | |
198 | } | |
199 | ||
920adc75 KM |
200 | /* MTD */ |
201 | static struct mtd_partition nor_flash_partitions[] = { | |
202 | { | |
203 | .name = "loader", | |
204 | .offset = 0x00000000, | |
205 | .size = 512 * 1024, | |
206 | .mask_flags = MTD_WRITEABLE, | |
207 | }, | |
208 | { | |
209 | .name = "bootenv", | |
210 | .offset = MTDPART_OFS_APPEND, | |
211 | .size = 512 * 1024, | |
212 | .mask_flags = MTD_WRITEABLE, | |
213 | }, | |
214 | { | |
215 | .name = "kernel_ro", | |
216 | .offset = MTDPART_OFS_APPEND, | |
217 | .size = 8 * 1024 * 1024, | |
218 | .mask_flags = MTD_WRITEABLE, | |
219 | }, | |
220 | { | |
221 | .name = "kernel", | |
222 | .offset = MTDPART_OFS_APPEND, | |
223 | .size = 8 * 1024 * 1024, | |
224 | }, | |
225 | { | |
226 | .name = "data", | |
227 | .offset = MTDPART_OFS_APPEND, | |
228 | .size = MTDPART_SIZ_FULL, | |
229 | }, | |
230 | }; | |
231 | ||
232 | static struct physmap_flash_data nor_flash_data = { | |
233 | .width = 2, | |
234 | .parts = nor_flash_partitions, | |
235 | .nr_parts = ARRAY_SIZE(nor_flash_partitions), | |
236 | }; | |
237 | ||
238 | static struct resource nor_flash_resources[] = { | |
239 | [0] = { | |
240 | .start = 0x00000000, | |
241 | .end = 0x08000000 - 1, | |
242 | .flags = IORESOURCE_MEM, | |
243 | } | |
244 | }; | |
245 | ||
246 | static struct platform_device nor_flash_device = { | |
247 | .name = "physmap-flash", | |
248 | .dev = { | |
249 | .platform_data = &nor_flash_data, | |
250 | }, | |
251 | .num_resources = ARRAY_SIZE(nor_flash_resources), | |
252 | .resource = nor_flash_resources, | |
253 | }; | |
254 | ||
2264c151 KM |
255 | /* SMSC */ |
256 | static struct resource smc911x_resources[] = { | |
257 | { | |
258 | .start = 0x14000000, | |
259 | .end = 0x16000000 - 1, | |
260 | .flags = IORESOURCE_MEM, | |
261 | }, { | |
262 | .start = evt2irq(0x02c0) /* IRQ6A */, | |
263 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL, | |
264 | }, | |
265 | }; | |
266 | ||
267 | static struct smsc911x_platform_config smsc911x_info = { | |
268 | .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS, | |
269 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, | |
270 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, | |
271 | }; | |
272 | ||
273 | static struct platform_device smc911x_device = { | |
274 | .name = "smsc911x", | |
275 | .id = -1, | |
276 | .num_resources = ARRAY_SIZE(smc911x_resources), | |
277 | .resource = smc911x_resources, | |
278 | .dev = { | |
279 | .platform_data = &smsc911x_info, | |
280 | }, | |
281 | }; | |
282 | ||
11fee467 KM |
283 | /* LCDC */ |
284 | static struct fb_videomode mackerel_lcdc_modes[] = { | |
285 | { | |
286 | .name = "WVGA Panel", | |
287 | .xres = 800, | |
288 | .yres = 480, | |
289 | .left_margin = 220, | |
290 | .right_margin = 110, | |
291 | .hsync_len = 70, | |
292 | .upper_margin = 20, | |
293 | .lower_margin = 5, | |
294 | .vsync_len = 5, | |
295 | .sync = 0, | |
296 | }, | |
297 | }; | |
298 | ||
299 | static struct sh_mobile_lcdc_info lcdc_info = { | |
300 | .clock_source = LCDC_CLK_BUS, | |
301 | .ch[0] = { | |
302 | .chan = LCDC_CHAN_MAINLCD, | |
303 | .bpp = 16, | |
304 | .lcd_cfg = mackerel_lcdc_modes, | |
305 | .num_cfg = ARRAY_SIZE(mackerel_lcdc_modes), | |
306 | .interface_type = RGB24, | |
307 | .clock_divider = 2, | |
308 | .flags = 0, | |
309 | .lcd_size_cfg.width = 152, | |
310 | .lcd_size_cfg.height = 91, | |
311 | } | |
312 | }; | |
313 | ||
314 | static struct resource lcdc_resources[] = { | |
315 | [0] = { | |
316 | .name = "LCDC", | |
317 | .start = 0xfe940000, | |
318 | .end = 0xfe943fff, | |
319 | .flags = IORESOURCE_MEM, | |
320 | }, | |
321 | [1] = { | |
322 | .start = intcs_evt2irq(0x580), | |
323 | .flags = IORESOURCE_IRQ, | |
324 | }, | |
325 | }; | |
326 | ||
327 | static struct platform_device lcdc_device = { | |
328 | .name = "sh_mobile_lcdc_fb", | |
329 | .num_resources = ARRAY_SIZE(lcdc_resources), | |
330 | .resource = lcdc_resources, | |
331 | .dev = { | |
332 | .platform_data = &lcdc_info, | |
333 | .coherent_dma_mask = ~0, | |
334 | }, | |
335 | }; | |
336 | ||
12c4309b KM |
337 | /* HDMI */ |
338 | static struct sh_mobile_lcdc_info hdmi_lcdc_info = { | |
339 | .clock_source = LCDC_CLK_EXTERNAL, | |
340 | .ch[0] = { | |
341 | .chan = LCDC_CHAN_MAINLCD, | |
342 | .bpp = 16, | |
343 | .interface_type = RGB24, | |
344 | .clock_divider = 1, | |
345 | .flags = LCDC_FLAGS_DWPOL, | |
346 | } | |
347 | }; | |
348 | ||
349 | static struct resource hdmi_lcdc_resources[] = { | |
350 | [0] = { | |
351 | .name = "LCDC1", | |
352 | .start = 0xfe944000, | |
353 | .end = 0xfe947fff, | |
354 | .flags = IORESOURCE_MEM, | |
355 | }, | |
356 | [1] = { | |
357 | .start = intcs_evt2irq(0x1780), | |
358 | .flags = IORESOURCE_IRQ, | |
359 | }, | |
360 | }; | |
361 | ||
362 | static struct platform_device hdmi_lcdc_device = { | |
363 | .name = "sh_mobile_lcdc_fb", | |
364 | .num_resources = ARRAY_SIZE(hdmi_lcdc_resources), | |
365 | .resource = hdmi_lcdc_resources, | |
366 | .id = 1, | |
367 | .dev = { | |
368 | .platform_data = &hdmi_lcdc_info, | |
369 | .coherent_dma_mask = ~0, | |
370 | }, | |
371 | }; | |
372 | ||
373 | static struct sh_mobile_hdmi_info hdmi_info = { | |
374 | .lcd_chan = &hdmi_lcdc_info.ch[0], | |
375 | .lcd_dev = &hdmi_lcdc_device.dev, | |
98d27b8a | 376 | .flags = HDMI_SND_SRC_SPDIF, |
12c4309b KM |
377 | }; |
378 | ||
379 | static struct resource hdmi_resources[] = { | |
380 | [0] = { | |
381 | .name = "HDMI", | |
382 | .start = 0xe6be0000, | |
383 | .end = 0xe6be00ff, | |
384 | .flags = IORESOURCE_MEM, | |
385 | }, | |
386 | [1] = { | |
387 | /* There's also an HDMI interrupt on INTCS @ 0x18e0 */ | |
388 | .start = evt2irq(0x17e0), | |
389 | .flags = IORESOURCE_IRQ, | |
390 | }, | |
391 | }; | |
392 | ||
393 | static struct platform_device hdmi_device = { | |
394 | .name = "sh-mobile-hdmi", | |
395 | .num_resources = ARRAY_SIZE(hdmi_resources), | |
396 | .resource = hdmi_resources, | |
397 | .id = -1, | |
398 | .dev = { | |
399 | .platform_data = &hdmi_info, | |
400 | }, | |
401 | }; | |
402 | ||
3f25c9cc KM |
403 | static struct platform_device fsi_hdmi_device = { |
404 | .name = "sh_fsi2_b_hdmi", | |
405 | }; | |
406 | ||
12c4309b KM |
407 | static int __init hdmi_init_pm_clock(void) |
408 | { | |
409 | struct clk *hdmi_ick = clk_get(&hdmi_device.dev, "ick"); | |
410 | int ret; | |
411 | long rate; | |
412 | ||
413 | if (IS_ERR(hdmi_ick)) { | |
414 | ret = PTR_ERR(hdmi_ick); | |
415 | pr_err("Cannot get HDMI ICK: %d\n", ret); | |
416 | goto out; | |
417 | } | |
418 | ||
419 | ret = clk_set_parent(&sh7372_pllc2_clk, &sh7372_dv_clki_div2_clk); | |
420 | if (ret < 0) { | |
421 | pr_err("Cannot set PLLC2 parent: %d, %d users\n", | |
422 | ret, sh7372_pllc2_clk.usecount); | |
423 | goto out; | |
424 | } | |
425 | ||
426 | pr_debug("PLLC2 initial frequency %lu\n", | |
427 | clk_get_rate(&sh7372_pllc2_clk)); | |
428 | ||
429 | rate = clk_round_rate(&sh7372_pllc2_clk, 594000000); | |
430 | if (rate < 0) { | |
431 | pr_err("Cannot get suitable rate: %ld\n", rate); | |
432 | ret = rate; | |
433 | goto out; | |
434 | } | |
435 | ||
436 | ret = clk_set_rate(&sh7372_pllc2_clk, rate); | |
437 | if (ret < 0) { | |
438 | pr_err("Cannot set rate %ld: %d\n", rate, ret); | |
439 | goto out; | |
440 | } | |
441 | ||
442 | ret = clk_enable(&sh7372_pllc2_clk); | |
443 | if (ret < 0) { | |
444 | pr_err("Cannot enable pllc2 clock\n"); | |
445 | goto out; | |
446 | } | |
447 | ||
448 | pr_debug("PLLC2 set frequency %lu\n", rate); | |
449 | ||
450 | ret = clk_set_parent(hdmi_ick, &sh7372_pllc2_clk); | |
451 | if (ret < 0) { | |
452 | pr_err("Cannot set HDMI parent: %d\n", ret); | |
453 | goto out; | |
454 | } | |
455 | ||
456 | out: | |
457 | if (!IS_ERR(hdmi_ick)) | |
458 | clk_put(hdmi_ick); | |
459 | return ret; | |
460 | } | |
461 | device_initcall(hdmi_init_pm_clock); | |
462 | ||
25338f2e KM |
463 | /* USB1 (Host) */ |
464 | static void usb1_host_port_power(int port, int power) | |
465 | { | |
466 | if (!power) /* only power-on is supported for now */ | |
467 | return; | |
468 | ||
469 | /* set VBOUT/PWEN and EXTLP1 in DVSTCTR */ | |
470 | __raw_writew(__raw_readw(0xE68B0008) | 0x600, 0xE68B0008); | |
471 | } | |
472 | ||
473 | static struct r8a66597_platdata usb1_host_data = { | |
474 | .on_chip = 1, | |
475 | .port_power = usb1_host_port_power, | |
476 | }; | |
477 | ||
478 | static struct resource usb1_host_resources[] = { | |
479 | [0] = { | |
480 | .name = "USBHS", | |
481 | .start = 0xE68B0000, | |
482 | .end = 0xE68B00E6 - 1, | |
483 | .flags = IORESOURCE_MEM, | |
484 | }, | |
485 | [1] = { | |
486 | .start = evt2irq(0x1ce0) /* USB1_USB1I0 */, | |
487 | .flags = IORESOURCE_IRQ, | |
488 | }, | |
489 | }; | |
490 | ||
491 | static struct platform_device usb1_host_device = { | |
492 | .name = "r8a66597_hcd", | |
493 | .id = 1, | |
494 | .dev = { | |
495 | .dma_mask = NULL, /* not use dma */ | |
496 | .coherent_dma_mask = 0xffffffff, | |
497 | .platform_data = &usb1_host_data, | |
498 | }, | |
499 | .num_resources = ARRAY_SIZE(usb1_host_resources), | |
500 | .resource = usb1_host_resources, | |
501 | }; | |
502 | ||
d44deb35 KM |
503 | /* LED */ |
504 | static struct gpio_led mackerel_leds[] = { | |
505 | { | |
506 | .name = "led0", | |
507 | .gpio = GPIO_PORT0, | |
508 | .default_state = LEDS_GPIO_DEFSTATE_ON, | |
509 | }, | |
510 | { | |
511 | .name = "led1", | |
512 | .gpio = GPIO_PORT1, | |
513 | .default_state = LEDS_GPIO_DEFSTATE_ON, | |
514 | }, | |
515 | { | |
516 | .name = "led2", | |
517 | .gpio = GPIO_PORT2, | |
518 | .default_state = LEDS_GPIO_DEFSTATE_ON, | |
519 | }, | |
520 | { | |
521 | .name = "led3", | |
522 | .gpio = GPIO_PORT159, | |
523 | .default_state = LEDS_GPIO_DEFSTATE_ON, | |
524 | } | |
525 | }; | |
526 | ||
527 | static struct gpio_led_platform_data mackerel_leds_pdata = { | |
528 | .leds = mackerel_leds, | |
529 | .num_leds = ARRAY_SIZE(mackerel_leds), | |
530 | }; | |
531 | ||
532 | static struct platform_device leds_device = { | |
533 | .name = "leds-gpio", | |
534 | .id = 0, | |
535 | .dev = { | |
536 | .platform_data = &mackerel_leds_pdata, | |
537 | }, | |
538 | }; | |
539 | ||
1a44d72a KM |
540 | /* FSI */ |
541 | #define IRQ_FSI evt2irq(0x1840) | |
98d27b8a KM |
542 | static int __fsi_set_round_rate(struct clk *clk, long rate, int enable) |
543 | { | |
544 | int ret; | |
545 | ||
546 | if (rate <= 0) | |
547 | return 0; | |
548 | ||
549 | if (!enable) { | |
550 | clk_disable(clk); | |
551 | return 0; | |
552 | } | |
553 | ||
554 | ret = clk_set_rate(clk, clk_round_rate(clk, rate)); | |
555 | if (ret < 0) | |
556 | return ret; | |
557 | ||
558 | return clk_enable(clk); | |
559 | } | |
560 | ||
561 | static int fsi_set_rate(struct device *dev, int is_porta, int rate, int enable) | |
562 | { | |
563 | struct clk *fsib_clk; | |
564 | struct clk *fdiv_clk = &sh7372_fsidivb_clk; | |
565 | long fsib_rate = 0; | |
566 | long fdiv_rate = 0; | |
567 | int ackmd_bpfmd; | |
568 | int ret; | |
569 | ||
570 | /* FSIA is slave mode. nothing to do here */ | |
571 | if (is_porta) | |
572 | return 0; | |
573 | ||
574 | /* clock start */ | |
575 | switch (rate) { | |
576 | case 44100: | |
577 | fsib_rate = rate * 256; | |
578 | ackmd_bpfmd = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64; | |
579 | break; | |
580 | case 48000: | |
581 | fsib_rate = 85428000; /* around 48kHz x 256 x 7 */ | |
582 | fdiv_rate = rate * 256; | |
583 | ackmd_bpfmd = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64; | |
584 | break; | |
585 | default: | |
586 | pr_err("unsupported rate in FSI2 port B\n"); | |
587 | return -EINVAL; | |
588 | } | |
589 | ||
590 | /* FSI B setting */ | |
591 | fsib_clk = clk_get(dev, "ickb"); | |
592 | if (IS_ERR(fsib_clk)) | |
593 | return -EIO; | |
594 | ||
595 | /* fsib */ | |
596 | ret = __fsi_set_round_rate(fsib_clk, fsib_rate, enable); | |
597 | if (ret < 0) | |
598 | goto fsi_set_rate_end; | |
599 | ||
600 | /* FSI DIV */ | |
601 | ret = __fsi_set_round_rate(fdiv_clk, fdiv_rate, enable); | |
602 | if (ret < 0) { | |
603 | /* disable FSI B */ | |
604 | if (enable) | |
605 | __fsi_set_round_rate(fsib_clk, fsib_rate, 0); | |
606 | goto fsi_set_rate_end; | |
607 | } | |
608 | ||
609 | ret = ackmd_bpfmd; | |
610 | ||
611 | fsi_set_rate_end: | |
612 | clk_put(fsib_clk); | |
613 | return ret; | |
614 | } | |
615 | ||
1a44d72a | 616 | static struct sh_fsi_platform_info fsi_info = { |
f17c13ca | 617 | .porta_flags = SH_FSI_BRS_INV, |
98d27b8a KM |
618 | |
619 | .portb_flags = SH_FSI_BRS_INV | | |
620 | SH_FSI_BRM_INV | | |
621 | SH_FSI_LRS_INV | | |
f17c13ca | 622 | SH_FSI_FMT_SPDIF, |
98d27b8a KM |
623 | |
624 | .set_rate = fsi_set_rate, | |
1a44d72a KM |
625 | }; |
626 | ||
627 | static struct resource fsi_resources[] = { | |
628 | [0] = { | |
629 | .name = "FSI", | |
630 | .start = 0xFE3C0000, | |
631 | .end = 0xFE3C0400 - 1, | |
632 | .flags = IORESOURCE_MEM, | |
633 | }, | |
634 | [1] = { | |
635 | .start = IRQ_FSI, | |
636 | .flags = IORESOURCE_IRQ, | |
637 | }, | |
638 | }; | |
639 | ||
640 | static struct platform_device fsi_device = { | |
641 | .name = "sh_fsi2", | |
642 | .id = -1, | |
643 | .num_resources = ARRAY_SIZE(fsi_resources), | |
644 | .resource = fsi_resources, | |
645 | .dev = { | |
646 | .platform_data = &fsi_info, | |
647 | }, | |
648 | }; | |
649 | ||
650 | static struct platform_device fsi_ak4643_device = { | |
651 | .name = "sh_fsi2_a_ak4643", | |
652 | }; | |
d44deb35 | 653 | |
6dff7da2 YG |
654 | /* |
655 | * The card detect pin of the top SD/MMC slot (CN7) is active low and is | |
656 | * connected to GPIO A22 of SH7372 (GPIO_PORT41). | |
657 | */ | |
658 | static int slot_cn7_get_cd(struct platform_device *pdev) | |
659 | { | |
ceb50f33 | 660 | return !gpio_get_value(GPIO_PORT41); |
6dff7da2 YG |
661 | } |
662 | ||
663 | /* SDHI0 */ | |
664 | static struct sh_mobile_sdhi_info sdhi0_info = { | |
665 | .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX, | |
666 | .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX, | |
da97da73 | 667 | .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ, |
6dff7da2 YG |
668 | }; |
669 | ||
670 | static struct resource sdhi0_resources[] = { | |
671 | [0] = { | |
672 | .name = "SDHI0", | |
673 | .start = 0xe6850000, | |
674 | .end = 0xe68501ff, | |
675 | .flags = IORESOURCE_MEM, | |
676 | }, | |
677 | [1] = { | |
678 | .start = evt2irq(0x0e00) /* SDHI0 */, | |
679 | .flags = IORESOURCE_IRQ, | |
680 | }, | |
681 | }; | |
682 | ||
683 | static struct platform_device sdhi0_device = { | |
684 | .name = "sh_mobile_sdhi", | |
685 | .num_resources = ARRAY_SIZE(sdhi0_resources), | |
686 | .resource = sdhi0_resources, | |
687 | .id = 0, | |
688 | .dev = { | |
689 | .platform_data = &sdhi0_info, | |
690 | }, | |
691 | }; | |
692 | ||
41491b9a | 693 | #if !defined(CONFIG_MMC_SH_MMCIF) |
6dff7da2 YG |
694 | /* SDHI1 */ |
695 | static struct sh_mobile_sdhi_info sdhi1_info = { | |
696 | .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX, | |
697 | .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX, | |
698 | .tmio_ocr_mask = MMC_VDD_165_195, | |
699 | .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE, | |
da97da73 | 700 | .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ | |
6dff7da2 YG |
701 | MMC_CAP_NEEDS_POLL, |
702 | .get_cd = slot_cn7_get_cd, | |
703 | }; | |
704 | ||
705 | static struct resource sdhi1_resources[] = { | |
706 | [0] = { | |
707 | .name = "SDHI1", | |
708 | .start = 0xe6860000, | |
709 | .end = 0xe68601ff, | |
710 | .flags = IORESOURCE_MEM, | |
711 | }, | |
712 | [1] = { | |
713 | .start = evt2irq(0x0e80), | |
714 | .flags = IORESOURCE_IRQ, | |
715 | }, | |
716 | }; | |
717 | ||
718 | static struct platform_device sdhi1_device = { | |
719 | .name = "sh_mobile_sdhi", | |
720 | .num_resources = ARRAY_SIZE(sdhi1_resources), | |
721 | .resource = sdhi1_resources, | |
722 | .id = 1, | |
723 | .dev = { | |
724 | .platform_data = &sdhi1_info, | |
725 | }, | |
726 | }; | |
41491b9a | 727 | #endif |
6dff7da2 | 728 | |
da5d1f4c YG |
729 | /* |
730 | * The card detect pin of the top SD/MMC slot (CN23) is active low and is | |
731 | * connected to GPIO SCIFB_SCK of SH7372 (GPIO_PORT162). | |
732 | */ | |
733 | static int slot_cn23_get_cd(struct platform_device *pdev) | |
734 | { | |
735 | return !gpio_get_value(GPIO_PORT162); | |
736 | } | |
737 | ||
6dff7da2 YG |
738 | /* SDHI2 */ |
739 | static struct sh_mobile_sdhi_info sdhi2_info = { | |
740 | .dma_slave_tx = SHDMA_SLAVE_SDHI2_TX, | |
741 | .dma_slave_rx = SHDMA_SLAVE_SDHI2_RX, | |
742 | .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE, | |
da97da73 | 743 | .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ | |
6dff7da2 | 744 | MMC_CAP_NEEDS_POLL, |
da5d1f4c | 745 | .get_cd = slot_cn23_get_cd, |
6dff7da2 YG |
746 | }; |
747 | ||
748 | static struct resource sdhi2_resources[] = { | |
749 | [0] = { | |
750 | .name = "SDHI2", | |
751 | .start = 0xe6870000, | |
752 | .end = 0xe68701ff, | |
753 | .flags = IORESOURCE_MEM, | |
754 | }, | |
755 | [1] = { | |
756 | .start = evt2irq(0x1200), | |
757 | .flags = IORESOURCE_IRQ, | |
758 | }, | |
759 | }; | |
760 | ||
761 | static struct platform_device sdhi2_device = { | |
762 | .name = "sh_mobile_sdhi", | |
763 | .num_resources = ARRAY_SIZE(sdhi2_resources), | |
764 | .resource = sdhi2_resources, | |
765 | .id = 2, | |
766 | .dev = { | |
767 | .platform_data = &sdhi2_info, | |
768 | }, | |
769 | }; | |
770 | ||
41491b9a YG |
771 | /* SH_MMCIF */ |
772 | static struct resource sh_mmcif_resources[] = { | |
773 | [0] = { | |
774 | .name = "MMCIF", | |
775 | .start = 0xE6BD0000, | |
776 | .end = 0xE6BD00FF, | |
777 | .flags = IORESOURCE_MEM, | |
778 | }, | |
779 | [1] = { | |
780 | /* MMC ERR */ | |
781 | .start = evt2irq(0x1ac0), | |
782 | .flags = IORESOURCE_IRQ, | |
783 | }, | |
784 | [2] = { | |
785 | /* MMC NOR */ | |
786 | .start = evt2irq(0x1ae0), | |
787 | .flags = IORESOURCE_IRQ, | |
788 | }, | |
789 | }; | |
790 | ||
791 | static struct sh_mmcif_plat_data sh_mmcif_plat = { | |
792 | .sup_pclk = 0, | |
793 | .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34, | |
794 | .caps = MMC_CAP_4_BIT_DATA | | |
795 | MMC_CAP_8_BIT_DATA | | |
796 | MMC_CAP_NEEDS_POLL, | |
797 | .get_cd = slot_cn7_get_cd, | |
798 | }; | |
799 | ||
800 | static struct platform_device sh_mmcif_device = { | |
801 | .name = "sh_mmcif", | |
802 | .id = 0, | |
803 | .dev = { | |
804 | .dma_mask = NULL, | |
805 | .coherent_dma_mask = 0xffffffff, | |
806 | .platform_data = &sh_mmcif_plat, | |
807 | }, | |
808 | .num_resources = ARRAY_SIZE(sh_mmcif_resources), | |
809 | .resource = sh_mmcif_resources, | |
810 | }; | |
811 | ||
ae37c8de MD |
812 | |
813 | static int mackerel_camera_add(struct soc_camera_link *icl, struct device *dev); | |
814 | static void mackerel_camera_del(struct soc_camera_link *icl); | |
815 | ||
816 | static int camera_set_capture(struct soc_camera_platform_info *info, | |
817 | int enable) | |
818 | { | |
819 | return 0; /* camera sensor always enabled */ | |
820 | } | |
821 | ||
822 | static struct soc_camera_platform_info camera_info = { | |
823 | .format_name = "UYVY", | |
824 | .format_depth = 16, | |
825 | .format = { | |
826 | .code = V4L2_MBUS_FMT_UYVY8_2X8, | |
827 | .colorspace = V4L2_COLORSPACE_SMPTE170M, | |
828 | .field = V4L2_FIELD_NONE, | |
829 | .width = 640, | |
830 | .height = 480, | |
831 | }, | |
832 | .bus_param = SOCAM_PCLK_SAMPLE_RISING | SOCAM_HSYNC_ACTIVE_HIGH | | |
833 | SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_MASTER | SOCAM_DATAWIDTH_8 | | |
834 | SOCAM_DATA_ACTIVE_HIGH, | |
835 | .set_capture = camera_set_capture, | |
836 | }; | |
837 | ||
838 | static struct soc_camera_link camera_link = { | |
839 | .bus_id = 0, | |
840 | .add_device = mackerel_camera_add, | |
841 | .del_device = mackerel_camera_del, | |
842 | .module_name = "soc_camera_platform", | |
843 | .priv = &camera_info, | |
844 | }; | |
845 | ||
846 | static void dummy_release(struct device *dev) | |
847 | { | |
848 | } | |
849 | ||
850 | static struct platform_device camera_device = { | |
851 | .name = "soc_camera_platform", | |
852 | .dev = { | |
853 | .platform_data = &camera_info, | |
854 | .release = dummy_release, | |
855 | }, | |
856 | }; | |
857 | ||
858 | static int mackerel_camera_add(struct soc_camera_link *icl, | |
859 | struct device *dev) | |
860 | { | |
861 | if (icl != &camera_link) | |
862 | return -ENODEV; | |
863 | ||
864 | camera_info.dev = dev; | |
865 | ||
866 | return platform_device_register(&camera_device); | |
867 | } | |
868 | ||
869 | static void mackerel_camera_del(struct soc_camera_link *icl) | |
870 | { | |
871 | if (icl != &camera_link) | |
872 | return; | |
873 | ||
874 | platform_device_unregister(&camera_device); | |
875 | memset(&camera_device.dev.kobj, 0, | |
876 | sizeof(camera_device.dev.kobj)); | |
877 | } | |
878 | ||
879 | static struct sh_mobile_ceu_info sh_mobile_ceu_info = { | |
880 | .flags = SH_CEU_FLAG_USE_8BIT_BUS, | |
881 | }; | |
882 | ||
883 | static struct resource ceu_resources[] = { | |
884 | [0] = { | |
885 | .name = "CEU", | |
886 | .start = 0xfe910000, | |
887 | .end = 0xfe91009f, | |
888 | .flags = IORESOURCE_MEM, | |
889 | }, | |
890 | [1] = { | |
891 | .start = intcs_evt2irq(0x880), | |
892 | .flags = IORESOURCE_IRQ, | |
893 | }, | |
894 | [2] = { | |
895 | /* place holder for contiguous memory */ | |
896 | }, | |
897 | }; | |
898 | ||
899 | static struct platform_device ceu_device = { | |
900 | .name = "sh_mobile_ceu", | |
901 | .id = 0, /* "ceu0" clock */ | |
902 | .num_resources = ARRAY_SIZE(ceu_resources), | |
903 | .resource = ceu_resources, | |
904 | .dev = { | |
905 | .platform_data = &sh_mobile_ceu_info, | |
906 | }, | |
907 | }; | |
908 | ||
909 | static struct platform_device mackerel_camera = { | |
910 | .name = "soc-camera-pdrv", | |
911 | .id = 0, | |
912 | .dev = { | |
913 | .platform_data = &camera_link, | |
914 | }, | |
915 | }; | |
916 | ||
920adc75 KM |
917 | static struct platform_device *mackerel_devices[] __initdata = { |
918 | &nor_flash_device, | |
2264c151 | 919 | &smc911x_device, |
11fee467 | 920 | &lcdc_device, |
25338f2e | 921 | &usb1_host_device, |
d44deb35 | 922 | &leds_device, |
1a44d72a KM |
923 | &fsi_device, |
924 | &fsi_ak4643_device, | |
3f25c9cc | 925 | &fsi_hdmi_device, |
6dff7da2 | 926 | &sdhi0_device, |
41491b9a | 927 | #if !defined(CONFIG_MMC_SH_MMCIF) |
6dff7da2 | 928 | &sdhi1_device, |
41491b9a | 929 | #endif |
6dff7da2 | 930 | &sdhi2_device, |
41491b9a | 931 | &sh_mmcif_device, |
ae37c8de MD |
932 | &ceu_device, |
933 | &mackerel_camera, | |
12c4309b KM |
934 | &hdmi_lcdc_device, |
935 | &hdmi_device, | |
1a44d72a KM |
936 | }; |
937 | ||
cd8ab004 TS |
938 | /* Keypad Initialization */ |
939 | #define KEYPAD_BUTTON(ev_type, ev_code, act_low) \ | |
940 | { \ | |
941 | .type = ev_type, \ | |
942 | .code = ev_code, \ | |
943 | .active_low = act_low, \ | |
944 | } | |
945 | ||
946 | #define KEYPAD_BUTTON_LOW(event_code) KEYPAD_BUTTON(EV_KEY, event_code, 1) | |
947 | ||
948 | static struct tca6416_button mackerel_gpio_keys[] = { | |
949 | KEYPAD_BUTTON_LOW(KEY_HOME), | |
950 | KEYPAD_BUTTON_LOW(KEY_MENU), | |
951 | KEYPAD_BUTTON_LOW(KEY_BACK), | |
952 | KEYPAD_BUTTON_LOW(KEY_POWER), | |
953 | }; | |
954 | ||
955 | static struct tca6416_keys_platform_data mackerel_tca6416_keys_info = { | |
956 | .buttons = mackerel_gpio_keys, | |
957 | .nbuttons = ARRAY_SIZE(mackerel_gpio_keys), | |
958 | .rep = 1, | |
959 | .use_polling = 0, | |
960 | .pinmask = 0x000F, | |
961 | }; | |
962 | ||
1a44d72a | 963 | /* I2C */ |
6ae1e19d | 964 | #define IRQ7 evt2irq(0x02e0) |
cd8ab004 TS |
965 | #define IRQ9 evt2irq(0x0320) |
966 | ||
1a44d72a KM |
967 | static struct i2c_board_info i2c0_devices[] = { |
968 | { | |
969 | I2C_BOARD_INFO("ak4643", 0x13), | |
970 | }, | |
cd8ab004 TS |
971 | /* Keypad */ |
972 | { | |
973 | I2C_BOARD_INFO("tca6408-keys", 0x20), | |
974 | .platform_data = &mackerel_tca6416_keys_info, | |
975 | .irq = IRQ9, | |
976 | }, | |
6ae1e19d TS |
977 | /* Touchscreen */ |
978 | { | |
979 | I2C_BOARD_INFO("st1232-ts", 0x55), | |
980 | .irq = IRQ7, | |
981 | }, | |
920adc75 KM |
982 | }; |
983 | ||
80f1dc7c TS |
984 | #define IRQ21 evt2irq(0x32a0) |
985 | ||
986 | static struct i2c_board_info i2c1_devices[] = { | |
987 | /* Accelerometer */ | |
988 | { | |
989 | I2C_BOARD_INFO("adxl34x", 0x53), | |
990 | .irq = IRQ21, | |
991 | }, | |
992 | }; | |
993 | ||
920adc75 KM |
994 | static struct map_desc mackerel_io_desc[] __initdata = { |
995 | /* create a 1:1 entity map for 0xe6xxxxxx | |
996 | * used by CPGA, INTC and PFC. | |
997 | */ | |
998 | { | |
999 | .virtual = 0xe6000000, | |
1000 | .pfn = __phys_to_pfn(0xe6000000), | |
1001 | .length = 256 << 20, | |
1002 | .type = MT_DEVICE_NONSHARED | |
1003 | }, | |
1004 | }; | |
1005 | ||
1006 | static void __init mackerel_map_io(void) | |
1007 | { | |
1008 | iotable_init(mackerel_io_desc, ARRAY_SIZE(mackerel_io_desc)); | |
1009 | ||
1010 | /* setup early devices and console here as well */ | |
1011 | sh7372_add_early_devices(); | |
1012 | shmobile_setup_console(); | |
1013 | } | |
1014 | ||
1a44d72a KM |
1015 | #define GPIO_PORT9CR 0xE6051009 |
1016 | #define GPIO_PORT10CR 0xE605100A | |
12c4309b | 1017 | #define SRCR4 0xe61580bc |
98d27b8a | 1018 | #define USCCR1 0xE6058144 |
920adc75 KM |
1019 | static void __init mackerel_init(void) |
1020 | { | |
12c4309b | 1021 | u32 srcr4; |
98d27b8a | 1022 | struct clk *clk; |
12c4309b | 1023 | |
920adc75 KM |
1024 | sh7372_pinmux_init(); |
1025 | ||
1026 | /* enable SCIFA0 */ | |
1027 | gpio_request(GPIO_FN_SCIFA0_TXD, NULL); | |
1028 | gpio_request(GPIO_FN_SCIFA0_RXD, NULL); | |
1029 | ||
2264c151 KM |
1030 | /* enable SMSC911X */ |
1031 | gpio_request(GPIO_FN_CS5A, NULL); | |
1032 | gpio_request(GPIO_FN_IRQ6_39, NULL); | |
1033 | ||
11fee467 | 1034 | /* LCDC */ |
eb87e677 KM |
1035 | gpio_request(GPIO_FN_LCDD23, NULL); |
1036 | gpio_request(GPIO_FN_LCDD22, NULL); | |
1037 | gpio_request(GPIO_FN_LCDD21, NULL); | |
1038 | gpio_request(GPIO_FN_LCDD20, NULL); | |
1039 | gpio_request(GPIO_FN_LCDD19, NULL); | |
1040 | gpio_request(GPIO_FN_LCDD18, NULL); | |
11fee467 KM |
1041 | gpio_request(GPIO_FN_LCDD17, NULL); |
1042 | gpio_request(GPIO_FN_LCDD16, NULL); | |
1043 | gpio_request(GPIO_FN_LCDD15, NULL); | |
1044 | gpio_request(GPIO_FN_LCDD14, NULL); | |
1045 | gpio_request(GPIO_FN_LCDD13, NULL); | |
1046 | gpio_request(GPIO_FN_LCDD12, NULL); | |
1047 | gpio_request(GPIO_FN_LCDD11, NULL); | |
1048 | gpio_request(GPIO_FN_LCDD10, NULL); | |
1049 | gpio_request(GPIO_FN_LCDD9, NULL); | |
1050 | gpio_request(GPIO_FN_LCDD8, NULL); | |
1051 | gpio_request(GPIO_FN_LCDD7, NULL); | |
1052 | gpio_request(GPIO_FN_LCDD6, NULL); | |
1053 | gpio_request(GPIO_FN_LCDD5, NULL); | |
1054 | gpio_request(GPIO_FN_LCDD4, NULL); | |
1055 | gpio_request(GPIO_FN_LCDD3, NULL); | |
1056 | gpio_request(GPIO_FN_LCDD2, NULL); | |
1057 | gpio_request(GPIO_FN_LCDD1, NULL); | |
1058 | gpio_request(GPIO_FN_LCDD0, NULL); | |
1059 | gpio_request(GPIO_FN_LCDDISP, NULL); | |
1060 | gpio_request(GPIO_FN_LCDDCK, NULL); | |
1061 | ||
1062 | gpio_request(GPIO_PORT31, NULL); /* backlight */ | |
1063 | gpio_direction_output(GPIO_PORT31, 1); | |
1064 | ||
1065 | gpio_request(GPIO_PORT151, NULL); /* LCDDON */ | |
1066 | gpio_direction_output(GPIO_PORT151, 1); | |
1067 | ||
25338f2e KM |
1068 | /* USB enable */ |
1069 | gpio_request(GPIO_FN_VBUS0_1, NULL); | |
1070 | gpio_request(GPIO_FN_IDIN_1_18, NULL); | |
1071 | gpio_request(GPIO_FN_PWEN_1_115, NULL); | |
1072 | gpio_request(GPIO_FN_OVCN_1_114, NULL); | |
1073 | gpio_request(GPIO_FN_EXTLP_1, NULL); | |
1074 | gpio_request(GPIO_FN_OVCN2_1, NULL); | |
1075 | ||
1076 | /* setup USB phy */ | |
d0fb0c4b | 1077 | __raw_writew(0x8a0a, 0xE6058130); /* USBCR4 */ |
25338f2e | 1078 | |
1a44d72a KM |
1079 | /* enable FSI2 port A (ak4643) */ |
1080 | gpio_request(GPIO_FN_FSIAIBT, NULL); | |
1081 | gpio_request(GPIO_FN_FSIAILR, NULL); | |
1082 | gpio_request(GPIO_FN_FSIAISLD, NULL); | |
1083 | gpio_request(GPIO_FN_FSIAOSLD, NULL); | |
1084 | gpio_request(GPIO_PORT161, NULL); | |
1085 | gpio_direction_output(GPIO_PORT161, 0); /* slave */ | |
1086 | ||
1087 | gpio_request(GPIO_PORT9, NULL); | |
1088 | gpio_request(GPIO_PORT10, NULL); | |
1089 | gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */ | |
1090 | gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */ | |
1091 | ||
1092 | intc_set_priority(IRQ_FSI, 3); /* irq priority FSI(3) > SMSC911X(2) */ | |
1093 | ||
98d27b8a KM |
1094 | /* setup FSI2 port B (HDMI) */ |
1095 | gpio_request(GPIO_FN_FSIBCK, NULL); | |
1096 | __raw_writew(__raw_readw(USCCR1) & ~(1 << 6), USCCR1); /* use SPDIF */ | |
1097 | ||
1098 | /* set SPU2 clock to 119.6 MHz */ | |
1099 | clk = clk_get(NULL, "spu_clk"); | |
1100 | if (!IS_ERR(clk)) { | |
1101 | clk_set_rate(clk, clk_round_rate(clk, 119600000)); | |
1102 | clk_put(clk); | |
1103 | } | |
1104 | ||
cd8ab004 TS |
1105 | /* enable Keypad */ |
1106 | gpio_request(GPIO_FN_IRQ9_42, NULL); | |
1107 | set_irq_type(IRQ9, IRQ_TYPE_LEVEL_HIGH); | |
1108 | ||
6ae1e19d TS |
1109 | /* enable Touchscreen */ |
1110 | gpio_request(GPIO_FN_IRQ7_40, NULL); | |
1111 | set_irq_type(IRQ7, IRQ_TYPE_LEVEL_LOW); | |
1112 | ||
80f1dc7c TS |
1113 | /* enable Accelerometer */ |
1114 | gpio_request(GPIO_FN_IRQ21, NULL); | |
1115 | set_irq_type(IRQ21, IRQ_TYPE_LEVEL_HIGH); | |
1a44d72a | 1116 | |
6dff7da2 YG |
1117 | /* enable SDHI0 */ |
1118 | gpio_request(GPIO_FN_SDHICD0, NULL); | |
1119 | gpio_request(GPIO_FN_SDHIWP0, NULL); | |
1120 | gpio_request(GPIO_FN_SDHICMD0, NULL); | |
1121 | gpio_request(GPIO_FN_SDHICLK0, NULL); | |
1122 | gpio_request(GPIO_FN_SDHID0_3, NULL); | |
1123 | gpio_request(GPIO_FN_SDHID0_2, NULL); | |
1124 | gpio_request(GPIO_FN_SDHID0_1, NULL); | |
1125 | gpio_request(GPIO_FN_SDHID0_0, NULL); | |
1126 | ||
41491b9a | 1127 | #if !defined(CONFIG_MMC_SH_MMCIF) |
6dff7da2 YG |
1128 | /* enable SDHI1 */ |
1129 | gpio_request(GPIO_FN_SDHICMD1, NULL); | |
1130 | gpio_request(GPIO_FN_SDHICLK1, NULL); | |
1131 | gpio_request(GPIO_FN_SDHID1_3, NULL); | |
1132 | gpio_request(GPIO_FN_SDHID1_2, NULL); | |
1133 | gpio_request(GPIO_FN_SDHID1_1, NULL); | |
1134 | gpio_request(GPIO_FN_SDHID1_0, NULL); | |
41491b9a | 1135 | #endif |
6dff7da2 YG |
1136 | /* card detect pin for MMC slot (CN7) */ |
1137 | gpio_request(GPIO_PORT41, NULL); | |
1138 | gpio_direction_input(GPIO_PORT41); | |
1139 | ||
1140 | /* enable SDHI2 */ | |
1141 | gpio_request(GPIO_FN_SDHICMD2, NULL); | |
1142 | gpio_request(GPIO_FN_SDHICLK2, NULL); | |
1143 | gpio_request(GPIO_FN_SDHID2_3, NULL); | |
1144 | gpio_request(GPIO_FN_SDHID2_2, NULL); | |
1145 | gpio_request(GPIO_FN_SDHID2_1, NULL); | |
1146 | gpio_request(GPIO_FN_SDHID2_0, NULL); | |
1147 | ||
da5d1f4c YG |
1148 | /* card detect pin for microSD slot (CN23) */ |
1149 | gpio_request(GPIO_PORT162, NULL); | |
1150 | gpio_direction_input(GPIO_PORT162); | |
1151 | ||
41491b9a YG |
1152 | /* MMCIF */ |
1153 | gpio_request(GPIO_FN_MMCD0_0, NULL); | |
1154 | gpio_request(GPIO_FN_MMCD0_1, NULL); | |
1155 | gpio_request(GPIO_FN_MMCD0_2, NULL); | |
1156 | gpio_request(GPIO_FN_MMCD0_3, NULL); | |
1157 | gpio_request(GPIO_FN_MMCD0_4, NULL); | |
1158 | gpio_request(GPIO_FN_MMCD0_5, NULL); | |
1159 | gpio_request(GPIO_FN_MMCD0_6, NULL); | |
1160 | gpio_request(GPIO_FN_MMCD0_7, NULL); | |
1161 | gpio_request(GPIO_FN_MMCCMD0, NULL); | |
1162 | gpio_request(GPIO_FN_MMCCLK0, NULL); | |
1163 | ||
56e78daf YG |
1164 | /* enable GPS module (GT-720F) */ |
1165 | gpio_request(GPIO_FN_SCIFA2_TXD1, NULL); | |
1166 | gpio_request(GPIO_FN_SCIFA2_RXD1, NULL); | |
1167 | ||
ae37c8de MD |
1168 | /* CEU */ |
1169 | gpio_request(GPIO_FN_VIO_CLK, NULL); | |
1170 | gpio_request(GPIO_FN_VIO_VD, NULL); | |
1171 | gpio_request(GPIO_FN_VIO_HD, NULL); | |
1172 | gpio_request(GPIO_FN_VIO_FIELD, NULL); | |
1173 | gpio_request(GPIO_FN_VIO_CKO, NULL); | |
1174 | gpio_request(GPIO_FN_VIO_D7, NULL); | |
1175 | gpio_request(GPIO_FN_VIO_D6, NULL); | |
1176 | gpio_request(GPIO_FN_VIO_D5, NULL); | |
1177 | gpio_request(GPIO_FN_VIO_D4, NULL); | |
1178 | gpio_request(GPIO_FN_VIO_D3, NULL); | |
1179 | gpio_request(GPIO_FN_VIO_D2, NULL); | |
1180 | gpio_request(GPIO_FN_VIO_D1, NULL); | |
1181 | gpio_request(GPIO_FN_VIO_D0, NULL); | |
1182 | ||
12c4309b KM |
1183 | /* HDMI */ |
1184 | gpio_request(GPIO_FN_HDMI_HPD, NULL); | |
1185 | gpio_request(GPIO_FN_HDMI_CEC, NULL); | |
1186 | ||
1187 | /* Reset HDMI, must be held at least one EXTALR (32768Hz) period */ | |
1188 | srcr4 = __raw_readl(SRCR4); | |
1189 | __raw_writel(srcr4 | (1 << 13), SRCR4); | |
1190 | udelay(50); | |
1191 | __raw_writel(srcr4 & ~(1 << 13), SRCR4); | |
1192 | ||
1a44d72a KM |
1193 | i2c_register_board_info(0, i2c0_devices, |
1194 | ARRAY_SIZE(i2c0_devices)); | |
80f1dc7c TS |
1195 | i2c_register_board_info(1, i2c1_devices, |
1196 | ARRAY_SIZE(i2c1_devices)); | |
11fee467 | 1197 | |
920adc75 KM |
1198 | sh7372_add_standard_devices(); |
1199 | ||
1200 | platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices)); | |
1201 | } | |
1202 | ||
1203 | static void __init mackerel_timer_init(void) | |
1204 | { | |
1205 | sh7372_clock_init(); | |
1206 | shmobile_timer.init(); | |
12c4309b KM |
1207 | |
1208 | /* External clock source */ | |
1209 | clk_set_rate(&sh7372_dv_clki_clk, 27000000); | |
920adc75 KM |
1210 | } |
1211 | ||
1212 | static struct sys_timer mackerel_timer = { | |
1213 | .init = mackerel_timer_init, | |
1214 | }; | |
1215 | ||
1216 | MACHINE_START(MACKEREL, "mackerel") | |
1217 | .map_io = mackerel_map_io, | |
1218 | .init_irq = sh7372_init_irq, | |
863b1719 | 1219 | .handle_irq = shmobile_handle_irq_intc, |
920adc75 KM |
1220 | .init_machine = mackerel_init, |
1221 | .timer = &mackerel_timer, | |
1222 | MACHINE_END |