blob: 1657eac5dde2c1bfee1a3a4bd799e47a884d0c76 [file] [log] [blame]
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001/*
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 */
Kuninori Morimoto12c43092011-01-06 02:44:09 +000024#include <linux/delay.h>
Kuninori Morimoto920adc72010-11-29 02:21:21 +000025#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>
Kuninori Morimoto1a44d722010-12-01 00:31:46 +000033#include <linux/i2c.h>
Kuninori Morimotod44deb32010-11-30 06:52:18 +000034#include <linux/leds.h>
Yusuke Goda6dff7da2010-12-14 14:18:03 +090035#include <linux/mfd/sh_mobile_sdhi.h>
36#include <linux/mfd/tmio.h>
37#include <linux/mmc/host.h>
Yusuke Goda41491b92010-12-15 08:31:04 +000038#include <linux/mmc/sh_mmcif.h>
Kuninori Morimoto920adc72010-11-29 02:21:21 +000039#include <linux/mtd/mtd.h>
40#include <linux/mtd/partitions.h>
41#include <linux/mtd/physmap.h>
Kuninori Morimoto2264c152010-11-29 02:21:37 +000042#include <linux/smsc911x.h>
Kuninori Morimoto1a44d722010-12-01 00:31:46 +000043#include <linux/sh_intc.h>
Tony SIMcd8ab002010-12-09 01:55:55 +000044#include <linux/tca6416_keypad.h>
Kuninori Morimoto25338f22010-11-30 04:37:33 +000045#include <linux/usb/r8a66597.h>
Kuninori Morimoto920adc72010-11-29 02:21:21 +000046
Kuninori Morimoto12c43092011-01-06 02:44:09 +000047#include <video/sh_mobile_hdmi.h>
Kuninori Morimoto11fee462010-11-29 02:21:43 +000048#include <video/sh_mobile_lcdc.h>
Magnus Dammae37c8d2010-12-22 14:47:40 +000049#include <media/sh_mobile_ceu.h>
50#include <media/soc_camera.h>
51#include <media/soc_camera_platform.h>
Kuninori Morimoto1a44d722010-12-01 00:31:46 +000052#include <sound/sh_fsi.h>
53
Kuninori Morimoto920adc72010-11-29 02:21:21 +000054#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
Kuninori Morimoto4b82b682010-11-29 02:21:48 +000075/*
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
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000132 */
Kuninori Morimoto4b82b682010-11-29 02:21:48 +0000133
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000134/*
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 */
Kuninori Morimoto4b82b682010-11-29 02:21:48 +0000148
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000149/*
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900150 * 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
Yusuke Goda41491b92010-12-15 08:31:04 +0000161 * J22 : select power voltage *1
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900162 * 1-2 pin : 1.8v
163 * 2-3 pin : 3.3v
164 *
Yusuke Goda41491b92010-12-15 08:31:04 +0000165 * *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 *
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900169 * SW1 | SW33
170 * | bit1 | bit2 | bit3 | bit4
171 * -------------+------+------+------+-------
Simon Horman2150dac2011-01-07 22:26:15 +0000172 * MMC0 OFF | OFF | X | ON | X (Use MMCIF)
173 * SDHI1 OFF | ON | X | OFF | X (Use MFD_SH_MOBILE_SDHI)
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900174 *
175 */
176
177/*
178 * SDHI2 (CN23)
179 *
180 * microSD card sloct
181 *
182 */
183
184/*
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000185 * FIXME !!
186 *
187 * gpio_no_direction
188 * are quick_hack.
189 *
190 * current gpio frame work doesn't have
191 * the method to control only pull up/down/free.
192 * this function should be replaced by correct gpio function
193 */
194static void __init gpio_no_direction(u32 addr)
195{
196 __raw_writeb(0x00, addr);
197}
198
Kuninori Morimoto920adc72010-11-29 02:21:21 +0000199/* MTD */
200static struct mtd_partition nor_flash_partitions[] = {
201 {
202 .name = "loader",
203 .offset = 0x00000000,
204 .size = 512 * 1024,
205 .mask_flags = MTD_WRITEABLE,
206 },
207 {
208 .name = "bootenv",
209 .offset = MTDPART_OFS_APPEND,
210 .size = 512 * 1024,
211 .mask_flags = MTD_WRITEABLE,
212 },
213 {
214 .name = "kernel_ro",
215 .offset = MTDPART_OFS_APPEND,
216 .size = 8 * 1024 * 1024,
217 .mask_flags = MTD_WRITEABLE,
218 },
219 {
220 .name = "kernel",
221 .offset = MTDPART_OFS_APPEND,
222 .size = 8 * 1024 * 1024,
223 },
224 {
225 .name = "data",
226 .offset = MTDPART_OFS_APPEND,
227 .size = MTDPART_SIZ_FULL,
228 },
229};
230
231static struct physmap_flash_data nor_flash_data = {
232 .width = 2,
233 .parts = nor_flash_partitions,
234 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
235};
236
237static struct resource nor_flash_resources[] = {
238 [0] = {
239 .start = 0x00000000,
240 .end = 0x08000000 - 1,
241 .flags = IORESOURCE_MEM,
242 }
243};
244
245static struct platform_device nor_flash_device = {
246 .name = "physmap-flash",
247 .dev = {
248 .platform_data = &nor_flash_data,
249 },
250 .num_resources = ARRAY_SIZE(nor_flash_resources),
251 .resource = nor_flash_resources,
252};
253
Kuninori Morimoto2264c152010-11-29 02:21:37 +0000254/* SMSC */
255static struct resource smc911x_resources[] = {
256 {
257 .start = 0x14000000,
258 .end = 0x16000000 - 1,
259 .flags = IORESOURCE_MEM,
260 }, {
261 .start = evt2irq(0x02c0) /* IRQ6A */,
262 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
263 },
264};
265
266static struct smsc911x_platform_config smsc911x_info = {
267 .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
268 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
269 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
270};
271
272static struct platform_device smc911x_device = {
273 .name = "smsc911x",
274 .id = -1,
275 .num_resources = ARRAY_SIZE(smc911x_resources),
276 .resource = smc911x_resources,
277 .dev = {
278 .platform_data = &smsc911x_info,
279 },
280};
281
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000282/* LCDC */
283static struct fb_videomode mackerel_lcdc_modes[] = {
284 {
285 .name = "WVGA Panel",
286 .xres = 800,
287 .yres = 480,
288 .left_margin = 220,
289 .right_margin = 110,
290 .hsync_len = 70,
291 .upper_margin = 20,
292 .lower_margin = 5,
293 .vsync_len = 5,
294 .sync = 0,
295 },
296};
297
298static struct sh_mobile_lcdc_info lcdc_info = {
299 .clock_source = LCDC_CLK_BUS,
300 .ch[0] = {
301 .chan = LCDC_CHAN_MAINLCD,
302 .bpp = 16,
303 .lcd_cfg = mackerel_lcdc_modes,
304 .num_cfg = ARRAY_SIZE(mackerel_lcdc_modes),
305 .interface_type = RGB24,
Kuninori Morimoto2c34e932011-03-02 09:05:21 +0000306 .clock_divider = 3,
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000307 .flags = 0,
308 .lcd_size_cfg.width = 152,
309 .lcd_size_cfg.height = 91,
310 }
311};
312
313static struct resource lcdc_resources[] = {
314 [0] = {
315 .name = "LCDC",
316 .start = 0xfe940000,
317 .end = 0xfe943fff,
318 .flags = IORESOURCE_MEM,
319 },
320 [1] = {
321 .start = intcs_evt2irq(0x580),
322 .flags = IORESOURCE_IRQ,
323 },
324};
325
326static struct platform_device lcdc_device = {
327 .name = "sh_mobile_lcdc_fb",
328 .num_resources = ARRAY_SIZE(lcdc_resources),
329 .resource = lcdc_resources,
330 .dev = {
331 .platform_data = &lcdc_info,
332 .coherent_dma_mask = ~0,
333 },
334};
335
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000336/* HDMI */
337static struct sh_mobile_lcdc_info hdmi_lcdc_info = {
338 .clock_source = LCDC_CLK_EXTERNAL,
339 .ch[0] = {
340 .chan = LCDC_CHAN_MAINLCD,
341 .bpp = 16,
342 .interface_type = RGB24,
343 .clock_divider = 1,
344 .flags = LCDC_FLAGS_DWPOL,
345 }
346};
347
348static struct resource hdmi_lcdc_resources[] = {
349 [0] = {
350 .name = "LCDC1",
351 .start = 0xfe944000,
352 .end = 0xfe947fff,
353 .flags = IORESOURCE_MEM,
354 },
355 [1] = {
356 .start = intcs_evt2irq(0x1780),
357 .flags = IORESOURCE_IRQ,
358 },
359};
360
361static struct platform_device hdmi_lcdc_device = {
362 .name = "sh_mobile_lcdc_fb",
363 .num_resources = ARRAY_SIZE(hdmi_lcdc_resources),
364 .resource = hdmi_lcdc_resources,
365 .id = 1,
366 .dev = {
367 .platform_data = &hdmi_lcdc_info,
368 .coherent_dma_mask = ~0,
369 },
370};
371
372static struct sh_mobile_hdmi_info hdmi_info = {
373 .lcd_chan = &hdmi_lcdc_info.ch[0],
374 .lcd_dev = &hdmi_lcdc_device.dev,
Kuninori Morimoto98d27b82011-01-06 02:44:15 +0000375 .flags = HDMI_SND_SRC_SPDIF,
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000376};
377
378static struct resource hdmi_resources[] = {
379 [0] = {
380 .name = "HDMI",
381 .start = 0xe6be0000,
382 .end = 0xe6be00ff,
383 .flags = IORESOURCE_MEM,
384 },
385 [1] = {
386 /* There's also an HDMI interrupt on INTCS @ 0x18e0 */
387 .start = evt2irq(0x17e0),
388 .flags = IORESOURCE_IRQ,
389 },
390};
391
392static struct platform_device hdmi_device = {
393 .name = "sh-mobile-hdmi",
394 .num_resources = ARRAY_SIZE(hdmi_resources),
395 .resource = hdmi_resources,
396 .id = -1,
397 .dev = {
398 .platform_data = &hdmi_info,
399 },
400};
401
402static int __init hdmi_init_pm_clock(void)
403{
404 struct clk *hdmi_ick = clk_get(&hdmi_device.dev, "ick");
405 int ret;
406 long rate;
407
408 if (IS_ERR(hdmi_ick)) {
409 ret = PTR_ERR(hdmi_ick);
410 pr_err("Cannot get HDMI ICK: %d\n", ret);
411 goto out;
412 }
413
414 ret = clk_set_parent(&sh7372_pllc2_clk, &sh7372_dv_clki_div2_clk);
415 if (ret < 0) {
416 pr_err("Cannot set PLLC2 parent: %d, %d users\n",
417 ret, sh7372_pllc2_clk.usecount);
418 goto out;
419 }
420
421 pr_debug("PLLC2 initial frequency %lu\n",
422 clk_get_rate(&sh7372_pllc2_clk));
423
424 rate = clk_round_rate(&sh7372_pllc2_clk, 594000000);
425 if (rate < 0) {
426 pr_err("Cannot get suitable rate: %ld\n", rate);
427 ret = rate;
428 goto out;
429 }
430
431 ret = clk_set_rate(&sh7372_pllc2_clk, rate);
432 if (ret < 0) {
433 pr_err("Cannot set rate %ld: %d\n", rate, ret);
434 goto out;
435 }
436
437 ret = clk_enable(&sh7372_pllc2_clk);
438 if (ret < 0) {
439 pr_err("Cannot enable pllc2 clock\n");
440 goto out;
441 }
442
443 pr_debug("PLLC2 set frequency %lu\n", rate);
444
445 ret = clk_set_parent(hdmi_ick, &sh7372_pllc2_clk);
446 if (ret < 0) {
447 pr_err("Cannot set HDMI parent: %d\n", ret);
448 goto out;
449 }
450
451out:
452 if (!IS_ERR(hdmi_ick))
453 clk_put(hdmi_ick);
454 return ret;
455}
456device_initcall(hdmi_init_pm_clock);
457
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000458/* USB1 (Host) */
459static void usb1_host_port_power(int port, int power)
460{
461 if (!power) /* only power-on is supported for now */
462 return;
463
464 /* set VBOUT/PWEN and EXTLP1 in DVSTCTR */
465 __raw_writew(__raw_readw(0xE68B0008) | 0x600, 0xE68B0008);
466}
467
468static struct r8a66597_platdata usb1_host_data = {
469 .on_chip = 1,
470 .port_power = usb1_host_port_power,
471};
472
473static struct resource usb1_host_resources[] = {
474 [0] = {
475 .name = "USBHS",
476 .start = 0xE68B0000,
477 .end = 0xE68B00E6 - 1,
478 .flags = IORESOURCE_MEM,
479 },
480 [1] = {
481 .start = evt2irq(0x1ce0) /* USB1_USB1I0 */,
482 .flags = IORESOURCE_IRQ,
483 },
484};
485
486static struct platform_device usb1_host_device = {
487 .name = "r8a66597_hcd",
488 .id = 1,
489 .dev = {
490 .dma_mask = NULL, /* not use dma */
491 .coherent_dma_mask = 0xffffffff,
492 .platform_data = &usb1_host_data,
493 },
494 .num_resources = ARRAY_SIZE(usb1_host_resources),
495 .resource = usb1_host_resources,
496};
497
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000498/* LED */
499static struct gpio_led mackerel_leds[] = {
500 {
501 .name = "led0",
502 .gpio = GPIO_PORT0,
503 .default_state = LEDS_GPIO_DEFSTATE_ON,
504 },
505 {
506 .name = "led1",
507 .gpio = GPIO_PORT1,
508 .default_state = LEDS_GPIO_DEFSTATE_ON,
509 },
510 {
511 .name = "led2",
512 .gpio = GPIO_PORT2,
513 .default_state = LEDS_GPIO_DEFSTATE_ON,
514 },
515 {
516 .name = "led3",
517 .gpio = GPIO_PORT159,
518 .default_state = LEDS_GPIO_DEFSTATE_ON,
519 }
520};
521
522static struct gpio_led_platform_data mackerel_leds_pdata = {
523 .leds = mackerel_leds,
524 .num_leds = ARRAY_SIZE(mackerel_leds),
525};
526
527static struct platform_device leds_device = {
528 .name = "leds-gpio",
529 .id = 0,
530 .dev = {
531 .platform_data = &mackerel_leds_pdata,
532 },
533};
534
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000535/* FSI */
536#define IRQ_FSI evt2irq(0x1840)
Kuninori Morimoto98d27b82011-01-06 02:44:15 +0000537static int __fsi_set_round_rate(struct clk *clk, long rate, int enable)
538{
539 int ret;
540
541 if (rate <= 0)
542 return 0;
543
544 if (!enable) {
545 clk_disable(clk);
546 return 0;
547 }
548
549 ret = clk_set_rate(clk, clk_round_rate(clk, rate));
550 if (ret < 0)
551 return ret;
552
553 return clk_enable(clk);
554}
555
556static int fsi_set_rate(struct device *dev, int is_porta, int rate, int enable)
557{
558 struct clk *fsib_clk;
559 struct clk *fdiv_clk = &sh7372_fsidivb_clk;
560 long fsib_rate = 0;
561 long fdiv_rate = 0;
562 int ackmd_bpfmd;
563 int ret;
564
565 /* FSIA is slave mode. nothing to do here */
566 if (is_porta)
567 return 0;
568
569 /* clock start */
570 switch (rate) {
571 case 44100:
572 fsib_rate = rate * 256;
573 ackmd_bpfmd = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
574 break;
575 case 48000:
576 fsib_rate = 85428000; /* around 48kHz x 256 x 7 */
577 fdiv_rate = rate * 256;
578 ackmd_bpfmd = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
579 break;
580 default:
581 pr_err("unsupported rate in FSI2 port B\n");
582 return -EINVAL;
583 }
584
585 /* FSI B setting */
586 fsib_clk = clk_get(dev, "ickb");
587 if (IS_ERR(fsib_clk))
588 return -EIO;
589
590 /* fsib */
591 ret = __fsi_set_round_rate(fsib_clk, fsib_rate, enable);
592 if (ret < 0)
593 goto fsi_set_rate_end;
594
595 /* FSI DIV */
596 ret = __fsi_set_round_rate(fdiv_clk, fdiv_rate, enable);
597 if (ret < 0) {
598 /* disable FSI B */
599 if (enable)
600 __fsi_set_round_rate(fsib_clk, fsib_rate, 0);
601 goto fsi_set_rate_end;
602 }
603
604 ret = ackmd_bpfmd;
605
606fsi_set_rate_end:
607 clk_put(fsib_clk);
608 return ret;
609}
610
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000611static struct sh_fsi_platform_info fsi_info = {
612 .porta_flags = SH_FSI_BRS_INV |
613 SH_FSI_OUT_SLAVE_MODE |
614 SH_FSI_IN_SLAVE_MODE |
615 SH_FSI_OFMT(PCM) |
616 SH_FSI_IFMT(PCM),
Kuninori Morimoto98d27b82011-01-06 02:44:15 +0000617
618 .portb_flags = SH_FSI_BRS_INV |
619 SH_FSI_BRM_INV |
620 SH_FSI_LRS_INV |
621 SH_FSI_OFMT(SPDIF),
622
623 .set_rate = fsi_set_rate,
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000624};
625
626static struct resource fsi_resources[] = {
627 [0] = {
628 .name = "FSI",
629 .start = 0xFE3C0000,
630 .end = 0xFE3C0400 - 1,
631 .flags = IORESOURCE_MEM,
632 },
633 [1] = {
634 .start = IRQ_FSI,
635 .flags = IORESOURCE_IRQ,
636 },
637};
638
639static struct platform_device fsi_device = {
640 .name = "sh_fsi2",
641 .id = -1,
642 .num_resources = ARRAY_SIZE(fsi_resources),
643 .resource = fsi_resources,
644 .dev = {
645 .platform_data = &fsi_info,
646 },
647};
648
649static struct platform_device fsi_ak4643_device = {
650 .name = "sh_fsi2_a_ak4643",
651};
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000652
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900653/*
654 * The card detect pin of the top SD/MMC slot (CN7) is active low and is
655 * connected to GPIO A22 of SH7372 (GPIO_PORT41).
656 */
657static int slot_cn7_get_cd(struct platform_device *pdev)
658{
Magnus Dammceb50f32011-01-12 10:43:07 +0000659 return !gpio_get_value(GPIO_PORT41);
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900660}
661
662/* SDHI0 */
663static struct sh_mobile_sdhi_info sdhi0_info = {
664 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
665 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
Magnus Dammda97da72011-01-06 10:55:41 +0000666 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900667};
668
669static struct resource sdhi0_resources[] = {
670 [0] = {
671 .name = "SDHI0",
672 .start = 0xe6850000,
673 .end = 0xe68501ff,
674 .flags = IORESOURCE_MEM,
675 },
676 [1] = {
677 .start = evt2irq(0x0e00) /* SDHI0 */,
678 .flags = IORESOURCE_IRQ,
679 },
680};
681
682static struct platform_device sdhi0_device = {
683 .name = "sh_mobile_sdhi",
684 .num_resources = ARRAY_SIZE(sdhi0_resources),
685 .resource = sdhi0_resources,
686 .id = 0,
687 .dev = {
688 .platform_data = &sdhi0_info,
689 },
690};
691
Yusuke Goda41491b92010-12-15 08:31:04 +0000692#if !defined(CONFIG_MMC_SH_MMCIF)
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900693/* SDHI1 */
694static struct sh_mobile_sdhi_info sdhi1_info = {
695 .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
696 .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
697 .tmio_ocr_mask = MMC_VDD_165_195,
698 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
Magnus Dammda97da72011-01-06 10:55:41 +0000699 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900700 MMC_CAP_NEEDS_POLL,
701 .get_cd = slot_cn7_get_cd,
702};
703
704static struct resource sdhi1_resources[] = {
705 [0] = {
706 .name = "SDHI1",
707 .start = 0xe6860000,
708 .end = 0xe68601ff,
709 .flags = IORESOURCE_MEM,
710 },
711 [1] = {
712 .start = evt2irq(0x0e80),
713 .flags = IORESOURCE_IRQ,
714 },
715};
716
717static struct platform_device sdhi1_device = {
718 .name = "sh_mobile_sdhi",
719 .num_resources = ARRAY_SIZE(sdhi1_resources),
720 .resource = sdhi1_resources,
721 .id = 1,
722 .dev = {
723 .platform_data = &sdhi1_info,
724 },
725};
Yusuke Goda41491b92010-12-15 08:31:04 +0000726#endif
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900727
Yusuke Godada5d1f42011-01-07 09:48:36 +0000728/*
729 * The card detect pin of the top SD/MMC slot (CN23) is active low and is
730 * connected to GPIO SCIFB_SCK of SH7372 (GPIO_PORT162).
731 */
732static int slot_cn23_get_cd(struct platform_device *pdev)
733{
734 return !gpio_get_value(GPIO_PORT162);
735}
736
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900737/* SDHI2 */
738static struct sh_mobile_sdhi_info sdhi2_info = {
739 .dma_slave_tx = SHDMA_SLAVE_SDHI2_TX,
740 .dma_slave_rx = SHDMA_SLAVE_SDHI2_RX,
741 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
Magnus Dammda97da72011-01-06 10:55:41 +0000742 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900743 MMC_CAP_NEEDS_POLL,
Yusuke Godada5d1f42011-01-07 09:48:36 +0000744 .get_cd = slot_cn23_get_cd,
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900745};
746
747static struct resource sdhi2_resources[] = {
748 [0] = {
749 .name = "SDHI2",
750 .start = 0xe6870000,
751 .end = 0xe68701ff,
752 .flags = IORESOURCE_MEM,
753 },
754 [1] = {
755 .start = evt2irq(0x1200),
756 .flags = IORESOURCE_IRQ,
757 },
758};
759
760static struct platform_device sdhi2_device = {
761 .name = "sh_mobile_sdhi",
762 .num_resources = ARRAY_SIZE(sdhi2_resources),
763 .resource = sdhi2_resources,
764 .id = 2,
765 .dev = {
766 .platform_data = &sdhi2_info,
767 },
768};
769
Yusuke Goda41491b92010-12-15 08:31:04 +0000770/* SH_MMCIF */
771static struct resource sh_mmcif_resources[] = {
772 [0] = {
773 .name = "MMCIF",
774 .start = 0xE6BD0000,
775 .end = 0xE6BD00FF,
776 .flags = IORESOURCE_MEM,
777 },
778 [1] = {
779 /* MMC ERR */
780 .start = evt2irq(0x1ac0),
781 .flags = IORESOURCE_IRQ,
782 },
783 [2] = {
784 /* MMC NOR */
785 .start = evt2irq(0x1ae0),
786 .flags = IORESOURCE_IRQ,
787 },
788};
789
790static struct sh_mmcif_plat_data sh_mmcif_plat = {
791 .sup_pclk = 0,
792 .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
793 .caps = MMC_CAP_4_BIT_DATA |
794 MMC_CAP_8_BIT_DATA |
795 MMC_CAP_NEEDS_POLL,
796 .get_cd = slot_cn7_get_cd,
797};
798
799static struct platform_device sh_mmcif_device = {
800 .name = "sh_mmcif",
801 .id = 0,
802 .dev = {
803 .dma_mask = NULL,
804 .coherent_dma_mask = 0xffffffff,
805 .platform_data = &sh_mmcif_plat,
806 },
807 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
808 .resource = sh_mmcif_resources,
809};
810
Magnus Dammae37c8d2010-12-22 14:47:40 +0000811
812static int mackerel_camera_add(struct soc_camera_link *icl, struct device *dev);
813static void mackerel_camera_del(struct soc_camera_link *icl);
814
815static int camera_set_capture(struct soc_camera_platform_info *info,
816 int enable)
817{
818 return 0; /* camera sensor always enabled */
819}
820
821static struct soc_camera_platform_info camera_info = {
822 .format_name = "UYVY",
823 .format_depth = 16,
824 .format = {
825 .code = V4L2_MBUS_FMT_UYVY8_2X8,
826 .colorspace = V4L2_COLORSPACE_SMPTE170M,
827 .field = V4L2_FIELD_NONE,
828 .width = 640,
829 .height = 480,
830 },
831 .bus_param = SOCAM_PCLK_SAMPLE_RISING | SOCAM_HSYNC_ACTIVE_HIGH |
832 SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_MASTER | SOCAM_DATAWIDTH_8 |
833 SOCAM_DATA_ACTIVE_HIGH,
834 .set_capture = camera_set_capture,
835};
836
837static struct soc_camera_link camera_link = {
838 .bus_id = 0,
839 .add_device = mackerel_camera_add,
840 .del_device = mackerel_camera_del,
841 .module_name = "soc_camera_platform",
842 .priv = &camera_info,
843};
844
845static void dummy_release(struct device *dev)
846{
847}
848
849static struct platform_device camera_device = {
850 .name = "soc_camera_platform",
851 .dev = {
852 .platform_data = &camera_info,
853 .release = dummy_release,
854 },
855};
856
857static int mackerel_camera_add(struct soc_camera_link *icl,
858 struct device *dev)
859{
860 if (icl != &camera_link)
861 return -ENODEV;
862
863 camera_info.dev = dev;
864
865 return platform_device_register(&camera_device);
866}
867
868static void mackerel_camera_del(struct soc_camera_link *icl)
869{
870 if (icl != &camera_link)
871 return;
872
873 platform_device_unregister(&camera_device);
874 memset(&camera_device.dev.kobj, 0,
875 sizeof(camera_device.dev.kobj));
876}
877
878static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
879 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
880};
881
882static struct resource ceu_resources[] = {
883 [0] = {
884 .name = "CEU",
885 .start = 0xfe910000,
886 .end = 0xfe91009f,
887 .flags = IORESOURCE_MEM,
888 },
889 [1] = {
890 .start = intcs_evt2irq(0x880),
891 .flags = IORESOURCE_IRQ,
892 },
893 [2] = {
894 /* place holder for contiguous memory */
895 },
896};
897
898static struct platform_device ceu_device = {
899 .name = "sh_mobile_ceu",
900 .id = 0, /* "ceu0" clock */
901 .num_resources = ARRAY_SIZE(ceu_resources),
902 .resource = ceu_resources,
903 .dev = {
904 .platform_data = &sh_mobile_ceu_info,
905 },
906};
907
908static struct platform_device mackerel_camera = {
909 .name = "soc-camera-pdrv",
910 .id = 0,
911 .dev = {
912 .platform_data = &camera_link,
913 },
914};
915
Kuninori Morimoto920adc72010-11-29 02:21:21 +0000916static struct platform_device *mackerel_devices[] __initdata = {
917 &nor_flash_device,
Kuninori Morimoto2264c152010-11-29 02:21:37 +0000918 &smc911x_device,
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000919 &lcdc_device,
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000920 &usb1_host_device,
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000921 &leds_device,
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000922 &fsi_device,
923 &fsi_ak4643_device,
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900924 &sdhi0_device,
Yusuke Goda41491b92010-12-15 08:31:04 +0000925#if !defined(CONFIG_MMC_SH_MMCIF)
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900926 &sdhi1_device,
Yusuke Goda41491b92010-12-15 08:31:04 +0000927#endif
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900928 &sdhi2_device,
Yusuke Goda41491b92010-12-15 08:31:04 +0000929 &sh_mmcif_device,
Magnus Dammae37c8d2010-12-22 14:47:40 +0000930 &ceu_device,
931 &mackerel_camera,
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000932 &hdmi_lcdc_device,
933 &hdmi_device,
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000934};
935
Tony SIMcd8ab002010-12-09 01:55:55 +0000936/* Keypad Initialization */
937#define KEYPAD_BUTTON(ev_type, ev_code, act_low) \
938{ \
939 .type = ev_type, \
940 .code = ev_code, \
941 .active_low = act_low, \
942}
943
944#define KEYPAD_BUTTON_LOW(event_code) KEYPAD_BUTTON(EV_KEY, event_code, 1)
945
946static struct tca6416_button mackerel_gpio_keys[] = {
947 KEYPAD_BUTTON_LOW(KEY_HOME),
948 KEYPAD_BUTTON_LOW(KEY_MENU),
949 KEYPAD_BUTTON_LOW(KEY_BACK),
950 KEYPAD_BUTTON_LOW(KEY_POWER),
951};
952
953static struct tca6416_keys_platform_data mackerel_tca6416_keys_info = {
954 .buttons = mackerel_gpio_keys,
955 .nbuttons = ARRAY_SIZE(mackerel_gpio_keys),
956 .rep = 1,
957 .use_polling = 0,
958 .pinmask = 0x000F,
959};
960
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000961/* I2C */
Tony SIM6ae1e192011-01-11 09:47:59 +0900962#define IRQ7 evt2irq(0x02e0)
Tony SIMcd8ab002010-12-09 01:55:55 +0000963#define IRQ9 evt2irq(0x0320)
964
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000965static struct i2c_board_info i2c0_devices[] = {
966 {
967 I2C_BOARD_INFO("ak4643", 0x13),
968 },
Tony SIMcd8ab002010-12-09 01:55:55 +0000969 /* Keypad */
970 {
971 I2C_BOARD_INFO("tca6408-keys", 0x20),
972 .platform_data = &mackerel_tca6416_keys_info,
973 .irq = IRQ9,
974 },
Tony SIM6ae1e192011-01-11 09:47:59 +0900975 /* Touchscreen */
976 {
977 I2C_BOARD_INFO("st1232-ts", 0x55),
978 .irq = IRQ7,
979 },
Kuninori Morimoto920adc72010-11-29 02:21:21 +0000980};
981
Tony SIM80f1dc72010-12-07 09:12:14 +0000982#define IRQ21 evt2irq(0x32a0)
983
984static struct i2c_board_info i2c1_devices[] = {
985 /* Accelerometer */
986 {
987 I2C_BOARD_INFO("adxl34x", 0x53),
988 .irq = IRQ21,
989 },
990};
991
Kuninori Morimoto920adc72010-11-29 02:21:21 +0000992static struct map_desc mackerel_io_desc[] __initdata = {
993 /* create a 1:1 entity map for 0xe6xxxxxx
994 * used by CPGA, INTC and PFC.
995 */
996 {
997 .virtual = 0xe6000000,
998 .pfn = __phys_to_pfn(0xe6000000),
999 .length = 256 << 20,
1000 .type = MT_DEVICE_NONSHARED
1001 },
1002};
1003
1004static void __init mackerel_map_io(void)
1005{
1006 iotable_init(mackerel_io_desc, ARRAY_SIZE(mackerel_io_desc));
1007
1008 /* setup early devices and console here as well */
1009 sh7372_add_early_devices();
1010 shmobile_setup_console();
1011}
1012
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001013#define GPIO_PORT9CR 0xE6051009
1014#define GPIO_PORT10CR 0xE605100A
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001015#define SRCR4 0xe61580bc
Kuninori Morimoto98d27b82011-01-06 02:44:15 +00001016#define USCCR1 0xE6058144
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001017static void __init mackerel_init(void)
1018{
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001019 u32 srcr4;
Kuninori Morimoto98d27b82011-01-06 02:44:15 +00001020 struct clk *clk;
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001021
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001022 sh7372_pinmux_init();
1023
1024 /* enable SCIFA0 */
1025 gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
1026 gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
1027
Kuninori Morimoto2264c152010-11-29 02:21:37 +00001028 /* enable SMSC911X */
1029 gpio_request(GPIO_FN_CS5A, NULL);
1030 gpio_request(GPIO_FN_IRQ6_39, NULL);
1031
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001032 /* LCDC */
Kuninori Morimotoeb87e672010-11-29 06:19:52 +00001033 gpio_request(GPIO_FN_LCDD23, NULL);
1034 gpio_request(GPIO_FN_LCDD22, NULL);
1035 gpio_request(GPIO_FN_LCDD21, NULL);
1036 gpio_request(GPIO_FN_LCDD20, NULL);
1037 gpio_request(GPIO_FN_LCDD19, NULL);
1038 gpio_request(GPIO_FN_LCDD18, NULL);
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001039 gpio_request(GPIO_FN_LCDD17, NULL);
1040 gpio_request(GPIO_FN_LCDD16, NULL);
1041 gpio_request(GPIO_FN_LCDD15, NULL);
1042 gpio_request(GPIO_FN_LCDD14, NULL);
1043 gpio_request(GPIO_FN_LCDD13, NULL);
1044 gpio_request(GPIO_FN_LCDD12, NULL);
1045 gpio_request(GPIO_FN_LCDD11, NULL);
1046 gpio_request(GPIO_FN_LCDD10, NULL);
1047 gpio_request(GPIO_FN_LCDD9, NULL);
1048 gpio_request(GPIO_FN_LCDD8, NULL);
1049 gpio_request(GPIO_FN_LCDD7, NULL);
1050 gpio_request(GPIO_FN_LCDD6, NULL);
1051 gpio_request(GPIO_FN_LCDD5, NULL);
1052 gpio_request(GPIO_FN_LCDD4, NULL);
1053 gpio_request(GPIO_FN_LCDD3, NULL);
1054 gpio_request(GPIO_FN_LCDD2, NULL);
1055 gpio_request(GPIO_FN_LCDD1, NULL);
1056 gpio_request(GPIO_FN_LCDD0, NULL);
1057 gpio_request(GPIO_FN_LCDDISP, NULL);
1058 gpio_request(GPIO_FN_LCDDCK, NULL);
1059
1060 gpio_request(GPIO_PORT31, NULL); /* backlight */
1061 gpio_direction_output(GPIO_PORT31, 1);
1062
1063 gpio_request(GPIO_PORT151, NULL); /* LCDDON */
1064 gpio_direction_output(GPIO_PORT151, 1);
1065
Kuninori Morimoto25338f22010-11-30 04:37:33 +00001066 /* USB enable */
1067 gpio_request(GPIO_FN_VBUS0_1, NULL);
1068 gpio_request(GPIO_FN_IDIN_1_18, NULL);
1069 gpio_request(GPIO_FN_PWEN_1_115, NULL);
1070 gpio_request(GPIO_FN_OVCN_1_114, NULL);
1071 gpio_request(GPIO_FN_EXTLP_1, NULL);
1072 gpio_request(GPIO_FN_OVCN2_1, NULL);
1073
1074 /* setup USB phy */
Kuninori Morimotod0fb0c42010-12-28 05:54:53 +00001075 __raw_writew(0x8a0a, 0xE6058130); /* USBCR4 */
Kuninori Morimoto25338f22010-11-30 04:37:33 +00001076
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001077 /* enable FSI2 port A (ak4643) */
1078 gpio_request(GPIO_FN_FSIAIBT, NULL);
1079 gpio_request(GPIO_FN_FSIAILR, NULL);
1080 gpio_request(GPIO_FN_FSIAISLD, NULL);
1081 gpio_request(GPIO_FN_FSIAOSLD, NULL);
1082 gpio_request(GPIO_PORT161, NULL);
1083 gpio_direction_output(GPIO_PORT161, 0); /* slave */
1084
1085 gpio_request(GPIO_PORT9, NULL);
1086 gpio_request(GPIO_PORT10, NULL);
1087 gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */
1088 gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */
1089
1090 intc_set_priority(IRQ_FSI, 3); /* irq priority FSI(3) > SMSC911X(2) */
1091
Kuninori Morimoto98d27b82011-01-06 02:44:15 +00001092 /* setup FSI2 port B (HDMI) */
1093 gpio_request(GPIO_FN_FSIBCK, NULL);
1094 __raw_writew(__raw_readw(USCCR1) & ~(1 << 6), USCCR1); /* use SPDIF */
1095
1096 /* set SPU2 clock to 119.6 MHz */
1097 clk = clk_get(NULL, "spu_clk");
1098 if (!IS_ERR(clk)) {
1099 clk_set_rate(clk, clk_round_rate(clk, 119600000));
1100 clk_put(clk);
1101 }
1102
Tony SIMcd8ab002010-12-09 01:55:55 +00001103 /* enable Keypad */
1104 gpio_request(GPIO_FN_IRQ9_42, NULL);
1105 set_irq_type(IRQ9, IRQ_TYPE_LEVEL_HIGH);
1106
Tony SIM6ae1e192011-01-11 09:47:59 +09001107 /* enable Touchscreen */
1108 gpio_request(GPIO_FN_IRQ7_40, NULL);
1109 set_irq_type(IRQ7, IRQ_TYPE_LEVEL_LOW);
1110
Tony SIM80f1dc72010-12-07 09:12:14 +00001111 /* enable Accelerometer */
1112 gpio_request(GPIO_FN_IRQ21, NULL);
1113 set_irq_type(IRQ21, IRQ_TYPE_LEVEL_HIGH);
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001114
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001115 /* enable SDHI0 */
1116 gpio_request(GPIO_FN_SDHICD0, NULL);
1117 gpio_request(GPIO_FN_SDHIWP0, NULL);
1118 gpio_request(GPIO_FN_SDHICMD0, NULL);
1119 gpio_request(GPIO_FN_SDHICLK0, NULL);
1120 gpio_request(GPIO_FN_SDHID0_3, NULL);
1121 gpio_request(GPIO_FN_SDHID0_2, NULL);
1122 gpio_request(GPIO_FN_SDHID0_1, NULL);
1123 gpio_request(GPIO_FN_SDHID0_0, NULL);
1124
Yusuke Goda41491b92010-12-15 08:31:04 +00001125#if !defined(CONFIG_MMC_SH_MMCIF)
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001126 /* enable SDHI1 */
1127 gpio_request(GPIO_FN_SDHICMD1, NULL);
1128 gpio_request(GPIO_FN_SDHICLK1, NULL);
1129 gpio_request(GPIO_FN_SDHID1_3, NULL);
1130 gpio_request(GPIO_FN_SDHID1_2, NULL);
1131 gpio_request(GPIO_FN_SDHID1_1, NULL);
1132 gpio_request(GPIO_FN_SDHID1_0, NULL);
Yusuke Goda41491b92010-12-15 08:31:04 +00001133#endif
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001134 /* card detect pin for MMC slot (CN7) */
1135 gpio_request(GPIO_PORT41, NULL);
1136 gpio_direction_input(GPIO_PORT41);
1137
1138 /* enable SDHI2 */
1139 gpio_request(GPIO_FN_SDHICMD2, NULL);
1140 gpio_request(GPIO_FN_SDHICLK2, NULL);
1141 gpio_request(GPIO_FN_SDHID2_3, NULL);
1142 gpio_request(GPIO_FN_SDHID2_2, NULL);
1143 gpio_request(GPIO_FN_SDHID2_1, NULL);
1144 gpio_request(GPIO_FN_SDHID2_0, NULL);
1145
Yusuke Godada5d1f42011-01-07 09:48:36 +00001146 /* card detect pin for microSD slot (CN23) */
1147 gpio_request(GPIO_PORT162, NULL);
1148 gpio_direction_input(GPIO_PORT162);
1149
Yusuke Goda41491b92010-12-15 08:31:04 +00001150 /* MMCIF */
1151 gpio_request(GPIO_FN_MMCD0_0, NULL);
1152 gpio_request(GPIO_FN_MMCD0_1, NULL);
1153 gpio_request(GPIO_FN_MMCD0_2, NULL);
1154 gpio_request(GPIO_FN_MMCD0_3, NULL);
1155 gpio_request(GPIO_FN_MMCD0_4, NULL);
1156 gpio_request(GPIO_FN_MMCD0_5, NULL);
1157 gpio_request(GPIO_FN_MMCD0_6, NULL);
1158 gpio_request(GPIO_FN_MMCD0_7, NULL);
1159 gpio_request(GPIO_FN_MMCCMD0, NULL);
1160 gpio_request(GPIO_FN_MMCCLK0, NULL);
1161
Yusuke Goda56e78da2010-12-20 01:06:04 +00001162 /* enable GPS module (GT-720F) */
1163 gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
1164 gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
1165
Magnus Dammae37c8d2010-12-22 14:47:40 +00001166 /* CEU */
1167 gpio_request(GPIO_FN_VIO_CLK, NULL);
1168 gpio_request(GPIO_FN_VIO_VD, NULL);
1169 gpio_request(GPIO_FN_VIO_HD, NULL);
1170 gpio_request(GPIO_FN_VIO_FIELD, NULL);
1171 gpio_request(GPIO_FN_VIO_CKO, NULL);
1172 gpio_request(GPIO_FN_VIO_D7, NULL);
1173 gpio_request(GPIO_FN_VIO_D6, NULL);
1174 gpio_request(GPIO_FN_VIO_D5, NULL);
1175 gpio_request(GPIO_FN_VIO_D4, NULL);
1176 gpio_request(GPIO_FN_VIO_D3, NULL);
1177 gpio_request(GPIO_FN_VIO_D2, NULL);
1178 gpio_request(GPIO_FN_VIO_D1, NULL);
1179 gpio_request(GPIO_FN_VIO_D0, NULL);
1180
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001181 /* HDMI */
1182 gpio_request(GPIO_FN_HDMI_HPD, NULL);
1183 gpio_request(GPIO_FN_HDMI_CEC, NULL);
1184
1185 /* Reset HDMI, must be held at least one EXTALR (32768Hz) period */
1186 srcr4 = __raw_readl(SRCR4);
1187 __raw_writel(srcr4 | (1 << 13), SRCR4);
1188 udelay(50);
1189 __raw_writel(srcr4 & ~(1 << 13), SRCR4);
1190
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001191 i2c_register_board_info(0, i2c0_devices,
1192 ARRAY_SIZE(i2c0_devices));
Tony SIM80f1dc72010-12-07 09:12:14 +00001193 i2c_register_board_info(1, i2c1_devices,
1194 ARRAY_SIZE(i2c1_devices));
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001195
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001196 sh7372_add_standard_devices();
1197
1198 platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices));
1199}
1200
1201static void __init mackerel_timer_init(void)
1202{
1203 sh7372_clock_init();
1204 shmobile_timer.init();
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001205
1206 /* External clock source */
1207 clk_set_rate(&sh7372_dv_clki_clk, 27000000);
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001208}
1209
1210static struct sys_timer mackerel_timer = {
1211 .init = mackerel_timer_init,
1212};
1213
1214MACHINE_START(MACKEREL, "mackerel")
1215 .map_io = mackerel_map_io,
1216 .init_irq = sh7372_init_irq,
Magnus Damm863b1712010-12-28 08:27:01 +00001217 .handle_irq = shmobile_handle_irq_intc,
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001218 .init_machine = mackerel_init,
1219 .timer = &mackerel_timer,
1220MACHINE_END