blob: a165a9e70eea0416336c50f5591f76cbc0c75301 [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/tmio.h>
36#include <linux/mmc/host.h>
Yusuke Goda41491b92010-12-15 08:31:04 +000037#include <linux/mmc/sh_mmcif.h>
Guennadi Liakhovetski17e75d82011-03-09 11:27:56 +010038#include <linux/mmc/sh_mobile_sdhi.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
Damian1c7fcbe2011-05-24 07:01:22 +0000282/* MERAM */
283static struct sh_mobile_meram_info mackerel_meram_info = {
284 .addr_mode = SH_MOBILE_MERAM_MODE1,
285};
286
287static struct resource meram_resources[] = {
288 [0] = {
289 .name = "MERAM",
290 .start = 0xe8000000,
291 .end = 0xe81fffff,
292 .flags = IORESOURCE_MEM,
293 },
294};
295
296static struct platform_device meram_device = {
297 .name = "sh_mobile_meram",
298 .id = 0,
299 .num_resources = ARRAY_SIZE(meram_resources),
300 .resource = meram_resources,
301 .dev = {
302 .platform_data = &mackerel_meram_info,
303 },
304};
305
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000306/* LCDC */
307static struct fb_videomode mackerel_lcdc_modes[] = {
308 {
309 .name = "WVGA Panel",
310 .xres = 800,
311 .yres = 480,
312 .left_margin = 220,
313 .right_margin = 110,
314 .hsync_len = 70,
315 .upper_margin = 20,
316 .lower_margin = 5,
317 .vsync_len = 5,
318 .sync = 0,
319 },
320};
321
Magnus Damm1fbdfcd2011-03-21 07:49:45 +0000322static int mackerel_set_brightness(void *board_data, int brightness)
323{
324 gpio_set_value(GPIO_PORT31, brightness);
325
326 return 0;
327}
328
329static int mackerel_get_brightness(void *board_data)
330{
331 return gpio_get_value(GPIO_PORT31);
332}
333
Damian1c7fcbe2011-05-24 07:01:22 +0000334static struct sh_mobile_meram_cfg lcd_meram_cfg = {
335 .icb[0] = {
336 .marker_icb = 28,
337 .cache_icb = 24,
338 .meram_offset = 0x0,
339 .meram_size = 0x40,
340 },
341 .icb[1] = {
342 .marker_icb = 29,
343 .cache_icb = 25,
344 .meram_offset = 0x40,
345 .meram_size = 0x40,
346 },
347};
348
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000349static struct sh_mobile_lcdc_info lcdc_info = {
Damian1c7fcbe2011-05-24 07:01:22 +0000350 .meram_dev = &mackerel_meram_info,
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000351 .clock_source = LCDC_CLK_BUS,
352 .ch[0] = {
353 .chan = LCDC_CHAN_MAINLCD,
354 .bpp = 16,
355 .lcd_cfg = mackerel_lcdc_modes,
356 .num_cfg = ARRAY_SIZE(mackerel_lcdc_modes),
357 .interface_type = RGB24,
Kuninori Morimoto2c34e932011-03-02 09:05:21 +0000358 .clock_divider = 3,
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000359 .flags = 0,
360 .lcd_size_cfg.width = 152,
361 .lcd_size_cfg.height = 91,
Magnus Damm1fbdfcd2011-03-21 07:49:45 +0000362 .board_cfg = {
363 .set_brightness = mackerel_set_brightness,
364 .get_brightness = mackerel_get_brightness,
365 },
366 .bl_info = {
367 .name = "sh_mobile_lcdc_bl",
368 .max_brightness = 1,
369 },
Damian1c7fcbe2011-05-24 07:01:22 +0000370 .meram_cfg = &lcd_meram_cfg,
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000371 }
372};
373
374static struct resource lcdc_resources[] = {
375 [0] = {
376 .name = "LCDC",
377 .start = 0xfe940000,
378 .end = 0xfe943fff,
379 .flags = IORESOURCE_MEM,
380 },
381 [1] = {
382 .start = intcs_evt2irq(0x580),
383 .flags = IORESOURCE_IRQ,
384 },
385};
386
387static struct platform_device lcdc_device = {
388 .name = "sh_mobile_lcdc_fb",
389 .num_resources = ARRAY_SIZE(lcdc_resources),
390 .resource = lcdc_resources,
391 .dev = {
392 .platform_data = &lcdc_info,
393 .coherent_dma_mask = ~0,
394 },
395};
396
Damian1c7fcbe2011-05-24 07:01:22 +0000397static struct sh_mobile_meram_cfg hdmi_meram_cfg = {
398 .icb[0] = {
399 .marker_icb = 30,
400 .cache_icb = 26,
401 .meram_offset = 0x80,
402 .meram_size = 0x100,
403 },
404 .icb[1] = {
405 .marker_icb = 31,
406 .cache_icb = 27,
407 .meram_offset = 0x180,
408 .meram_size = 0x100,
409 },
410};
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000411/* HDMI */
412static struct sh_mobile_lcdc_info hdmi_lcdc_info = {
Damian1c7fcbe2011-05-24 07:01:22 +0000413 .meram_dev = &mackerel_meram_info,
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000414 .clock_source = LCDC_CLK_EXTERNAL,
415 .ch[0] = {
416 .chan = LCDC_CHAN_MAINLCD,
417 .bpp = 16,
418 .interface_type = RGB24,
419 .clock_divider = 1,
420 .flags = LCDC_FLAGS_DWPOL,
Damian1c7fcbe2011-05-24 07:01:22 +0000421 .meram_cfg = &hdmi_meram_cfg,
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000422 }
423};
424
425static struct resource hdmi_lcdc_resources[] = {
426 [0] = {
427 .name = "LCDC1",
428 .start = 0xfe944000,
429 .end = 0xfe947fff,
430 .flags = IORESOURCE_MEM,
431 },
432 [1] = {
433 .start = intcs_evt2irq(0x1780),
434 .flags = IORESOURCE_IRQ,
435 },
436};
437
438static struct platform_device hdmi_lcdc_device = {
439 .name = "sh_mobile_lcdc_fb",
440 .num_resources = ARRAY_SIZE(hdmi_lcdc_resources),
441 .resource = hdmi_lcdc_resources,
442 .id = 1,
443 .dev = {
444 .platform_data = &hdmi_lcdc_info,
445 .coherent_dma_mask = ~0,
446 },
447};
448
449static struct sh_mobile_hdmi_info hdmi_info = {
450 .lcd_chan = &hdmi_lcdc_info.ch[0],
451 .lcd_dev = &hdmi_lcdc_device.dev,
Kuninori Morimoto98d27b82011-01-06 02:44:15 +0000452 .flags = HDMI_SND_SRC_SPDIF,
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000453};
454
455static struct resource hdmi_resources[] = {
456 [0] = {
457 .name = "HDMI",
458 .start = 0xe6be0000,
459 .end = 0xe6be00ff,
460 .flags = IORESOURCE_MEM,
461 },
462 [1] = {
463 /* There's also an HDMI interrupt on INTCS @ 0x18e0 */
464 .start = evt2irq(0x17e0),
465 .flags = IORESOURCE_IRQ,
466 },
467};
468
469static struct platform_device hdmi_device = {
470 .name = "sh-mobile-hdmi",
471 .num_resources = ARRAY_SIZE(hdmi_resources),
472 .resource = hdmi_resources,
473 .id = -1,
474 .dev = {
475 .platform_data = &hdmi_info,
476 },
477};
478
Kuninori Morimoto3f25c9c2011-01-24 10:09:02 +0900479static struct platform_device fsi_hdmi_device = {
480 .name = "sh_fsi2_b_hdmi",
481};
482
Guennadi Liakhovetski2ce51f82011-04-04 17:08:05 +0200483static void __init hdmi_init_pm_clock(void)
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000484{
485 struct clk *hdmi_ick = clk_get(&hdmi_device.dev, "ick");
486 int ret;
487 long rate;
488
489 if (IS_ERR(hdmi_ick)) {
490 ret = PTR_ERR(hdmi_ick);
491 pr_err("Cannot get HDMI ICK: %d\n", ret);
492 goto out;
493 }
494
495 ret = clk_set_parent(&sh7372_pllc2_clk, &sh7372_dv_clki_div2_clk);
496 if (ret < 0) {
497 pr_err("Cannot set PLLC2 parent: %d, %d users\n",
498 ret, sh7372_pllc2_clk.usecount);
499 goto out;
500 }
501
502 pr_debug("PLLC2 initial frequency %lu\n",
503 clk_get_rate(&sh7372_pllc2_clk));
504
505 rate = clk_round_rate(&sh7372_pllc2_clk, 594000000);
506 if (rate < 0) {
507 pr_err("Cannot get suitable rate: %ld\n", rate);
508 ret = rate;
509 goto out;
510 }
511
512 ret = clk_set_rate(&sh7372_pllc2_clk, rate);
513 if (ret < 0) {
514 pr_err("Cannot set rate %ld: %d\n", rate, ret);
515 goto out;
516 }
517
518 ret = clk_enable(&sh7372_pllc2_clk);
519 if (ret < 0) {
520 pr_err("Cannot enable pllc2 clock\n");
521 goto out;
522 }
523
524 pr_debug("PLLC2 set frequency %lu\n", rate);
525
526 ret = clk_set_parent(hdmi_ick, &sh7372_pllc2_clk);
Guennadi Liakhovetski2ce51f82011-04-04 17:08:05 +0200527 if (ret < 0)
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000528 pr_err("Cannot set HDMI parent: %d\n", ret);
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000529
530out:
531 if (!IS_ERR(hdmi_ick))
532 clk_put(hdmi_ick);
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000533}
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000534
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000535/* USB1 (Host) */
536static void usb1_host_port_power(int port, int power)
537{
538 if (!power) /* only power-on is supported for now */
539 return;
540
541 /* set VBOUT/PWEN and EXTLP1 in DVSTCTR */
542 __raw_writew(__raw_readw(0xE68B0008) | 0x600, 0xE68B0008);
543}
544
545static struct r8a66597_platdata usb1_host_data = {
546 .on_chip = 1,
547 .port_power = usb1_host_port_power,
548};
549
550static struct resource usb1_host_resources[] = {
551 [0] = {
552 .name = "USBHS",
553 .start = 0xE68B0000,
554 .end = 0xE68B00E6 - 1,
555 .flags = IORESOURCE_MEM,
556 },
557 [1] = {
558 .start = evt2irq(0x1ce0) /* USB1_USB1I0 */,
559 .flags = IORESOURCE_IRQ,
560 },
561};
562
563static struct platform_device usb1_host_device = {
564 .name = "r8a66597_hcd",
565 .id = 1,
566 .dev = {
567 .dma_mask = NULL, /* not use dma */
568 .coherent_dma_mask = 0xffffffff,
569 .platform_data = &usb1_host_data,
570 },
571 .num_resources = ARRAY_SIZE(usb1_host_resources),
572 .resource = usb1_host_resources,
573};
574
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000575/* LED */
576static struct gpio_led mackerel_leds[] = {
577 {
578 .name = "led0",
579 .gpio = GPIO_PORT0,
580 .default_state = LEDS_GPIO_DEFSTATE_ON,
581 },
582 {
583 .name = "led1",
584 .gpio = GPIO_PORT1,
585 .default_state = LEDS_GPIO_DEFSTATE_ON,
586 },
587 {
588 .name = "led2",
589 .gpio = GPIO_PORT2,
590 .default_state = LEDS_GPIO_DEFSTATE_ON,
591 },
592 {
593 .name = "led3",
594 .gpio = GPIO_PORT159,
595 .default_state = LEDS_GPIO_DEFSTATE_ON,
596 }
597};
598
599static struct gpio_led_platform_data mackerel_leds_pdata = {
600 .leds = mackerel_leds,
601 .num_leds = ARRAY_SIZE(mackerel_leds),
602};
603
604static struct platform_device leds_device = {
605 .name = "leds-gpio",
606 .id = 0,
607 .dev = {
608 .platform_data = &mackerel_leds_pdata,
609 },
610};
611
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000612/* FSI */
613#define IRQ_FSI evt2irq(0x1840)
Kuninori Morimoto98d27b82011-01-06 02:44:15 +0000614static int __fsi_set_round_rate(struct clk *clk, long rate, int enable)
615{
616 int ret;
617
618 if (rate <= 0)
619 return 0;
620
621 if (!enable) {
622 clk_disable(clk);
623 return 0;
624 }
625
626 ret = clk_set_rate(clk, clk_round_rate(clk, rate));
627 if (ret < 0)
628 return ret;
629
630 return clk_enable(clk);
631}
632
633static int fsi_set_rate(struct device *dev, int is_porta, int rate, int enable)
634{
635 struct clk *fsib_clk;
636 struct clk *fdiv_clk = &sh7372_fsidivb_clk;
637 long fsib_rate = 0;
638 long fdiv_rate = 0;
639 int ackmd_bpfmd;
640 int ret;
641
642 /* FSIA is slave mode. nothing to do here */
643 if (is_porta)
644 return 0;
645
646 /* clock start */
647 switch (rate) {
648 case 44100:
649 fsib_rate = rate * 256;
650 ackmd_bpfmd = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
651 break;
652 case 48000:
653 fsib_rate = 85428000; /* around 48kHz x 256 x 7 */
654 fdiv_rate = rate * 256;
655 ackmd_bpfmd = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
656 break;
657 default:
658 pr_err("unsupported rate in FSI2 port B\n");
659 return -EINVAL;
660 }
661
662 /* FSI B setting */
663 fsib_clk = clk_get(dev, "ickb");
664 if (IS_ERR(fsib_clk))
665 return -EIO;
666
667 /* fsib */
668 ret = __fsi_set_round_rate(fsib_clk, fsib_rate, enable);
669 if (ret < 0)
670 goto fsi_set_rate_end;
671
672 /* FSI DIV */
673 ret = __fsi_set_round_rate(fdiv_clk, fdiv_rate, enable);
674 if (ret < 0) {
675 /* disable FSI B */
676 if (enable)
677 __fsi_set_round_rate(fsib_clk, fsib_rate, 0);
678 goto fsi_set_rate_end;
679 }
680
681 ret = ackmd_bpfmd;
682
683fsi_set_rate_end:
684 clk_put(fsib_clk);
685 return ret;
686}
687
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000688static struct sh_fsi_platform_info fsi_info = {
Kuninori Morimotof17c13c2011-01-24 10:43:19 +0900689 .porta_flags = SH_FSI_BRS_INV,
Kuninori Morimoto98d27b82011-01-06 02:44:15 +0000690
691 .portb_flags = SH_FSI_BRS_INV |
692 SH_FSI_BRM_INV |
693 SH_FSI_LRS_INV |
Kuninori Morimotof17c13c2011-01-24 10:43:19 +0900694 SH_FSI_FMT_SPDIF,
Kuninori Morimoto98d27b82011-01-06 02:44:15 +0000695
696 .set_rate = fsi_set_rate,
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000697};
698
699static struct resource fsi_resources[] = {
700 [0] = {
701 .name = "FSI",
702 .start = 0xFE3C0000,
703 .end = 0xFE3C0400 - 1,
704 .flags = IORESOURCE_MEM,
705 },
706 [1] = {
707 .start = IRQ_FSI,
708 .flags = IORESOURCE_IRQ,
709 },
710};
711
712static struct platform_device fsi_device = {
713 .name = "sh_fsi2",
714 .id = -1,
715 .num_resources = ARRAY_SIZE(fsi_resources),
716 .resource = fsi_resources,
717 .dev = {
718 .platform_data = &fsi_info,
719 },
720};
721
722static struct platform_device fsi_ak4643_device = {
723 .name = "sh_fsi2_a_ak4643",
724};
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000725
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900726/*
727 * The card detect pin of the top SD/MMC slot (CN7) is active low and is
728 * connected to GPIO A22 of SH7372 (GPIO_PORT41).
729 */
730static int slot_cn7_get_cd(struct platform_device *pdev)
731{
Magnus Dammceb50f32011-01-12 10:43:07 +0000732 return !gpio_get_value(GPIO_PORT41);
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900733}
734
735/* SDHI0 */
736static struct sh_mobile_sdhi_info sdhi0_info = {
737 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
738 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
Magnus Dammda97da72011-01-06 10:55:41 +0000739 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900740};
741
742static struct resource sdhi0_resources[] = {
743 [0] = {
744 .name = "SDHI0",
745 .start = 0xe6850000,
Guennadi Liakhovetski31d31fe72011-03-09 13:09:27 +0100746 .end = 0xe68500ff,
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900747 .flags = IORESOURCE_MEM,
748 },
749 [1] = {
750 .start = evt2irq(0x0e00) /* SDHI0 */,
751 .flags = IORESOURCE_IRQ,
752 },
753};
754
755static struct platform_device sdhi0_device = {
756 .name = "sh_mobile_sdhi",
757 .num_resources = ARRAY_SIZE(sdhi0_resources),
758 .resource = sdhi0_resources,
759 .id = 0,
760 .dev = {
761 .platform_data = &sdhi0_info,
762 },
763};
764
Yusuke Goda41491b92010-12-15 08:31:04 +0000765#if !defined(CONFIG_MMC_SH_MMCIF)
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900766/* SDHI1 */
767static struct sh_mobile_sdhi_info sdhi1_info = {
768 .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
769 .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
770 .tmio_ocr_mask = MMC_VDD_165_195,
771 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
Magnus Dammda97da72011-01-06 10:55:41 +0000772 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900773 MMC_CAP_NEEDS_POLL,
774 .get_cd = slot_cn7_get_cd,
775};
776
777static struct resource sdhi1_resources[] = {
778 [0] = {
779 .name = "SDHI1",
780 .start = 0xe6860000,
Guennadi Liakhovetski31d31fe72011-03-09 13:09:27 +0100781 .end = 0xe68600ff,
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900782 .flags = IORESOURCE_MEM,
783 },
784 [1] = {
785 .start = evt2irq(0x0e80),
786 .flags = IORESOURCE_IRQ,
787 },
788};
789
790static struct platform_device sdhi1_device = {
791 .name = "sh_mobile_sdhi",
792 .num_resources = ARRAY_SIZE(sdhi1_resources),
793 .resource = sdhi1_resources,
794 .id = 1,
795 .dev = {
796 .platform_data = &sdhi1_info,
797 },
798};
Yusuke Goda41491b92010-12-15 08:31:04 +0000799#endif
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900800
Yusuke Godada5d1f42011-01-07 09:48:36 +0000801/*
802 * The card detect pin of the top SD/MMC slot (CN23) is active low and is
803 * connected to GPIO SCIFB_SCK of SH7372 (GPIO_PORT162).
804 */
805static int slot_cn23_get_cd(struct platform_device *pdev)
806{
807 return !gpio_get_value(GPIO_PORT162);
808}
809
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900810/* SDHI2 */
811static struct sh_mobile_sdhi_info sdhi2_info = {
812 .dma_slave_tx = SHDMA_SLAVE_SDHI2_TX,
813 .dma_slave_rx = SHDMA_SLAVE_SDHI2_RX,
814 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
Magnus Dammda97da72011-01-06 10:55:41 +0000815 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900816 MMC_CAP_NEEDS_POLL,
Yusuke Godada5d1f42011-01-07 09:48:36 +0000817 .get_cd = slot_cn23_get_cd,
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900818};
819
820static struct resource sdhi2_resources[] = {
821 [0] = {
822 .name = "SDHI2",
823 .start = 0xe6870000,
Guennadi Liakhovetski31d31fe72011-03-09 13:09:27 +0100824 .end = 0xe68700ff,
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900825 .flags = IORESOURCE_MEM,
826 },
827 [1] = {
828 .start = evt2irq(0x1200),
829 .flags = IORESOURCE_IRQ,
830 },
831};
832
833static struct platform_device sdhi2_device = {
834 .name = "sh_mobile_sdhi",
835 .num_resources = ARRAY_SIZE(sdhi2_resources),
836 .resource = sdhi2_resources,
837 .id = 2,
838 .dev = {
839 .platform_data = &sdhi2_info,
840 },
841};
842
Yusuke Goda41491b92010-12-15 08:31:04 +0000843/* SH_MMCIF */
844static struct resource sh_mmcif_resources[] = {
845 [0] = {
846 .name = "MMCIF",
847 .start = 0xE6BD0000,
848 .end = 0xE6BD00FF,
849 .flags = IORESOURCE_MEM,
850 },
851 [1] = {
852 /* MMC ERR */
853 .start = evt2irq(0x1ac0),
854 .flags = IORESOURCE_IRQ,
855 },
856 [2] = {
857 /* MMC NOR */
858 .start = evt2irq(0x1ae0),
859 .flags = IORESOURCE_IRQ,
860 },
861};
862
863static struct sh_mmcif_plat_data sh_mmcif_plat = {
864 .sup_pclk = 0,
865 .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
866 .caps = MMC_CAP_4_BIT_DATA |
867 MMC_CAP_8_BIT_DATA |
868 MMC_CAP_NEEDS_POLL,
869 .get_cd = slot_cn7_get_cd,
870};
871
872static struct platform_device sh_mmcif_device = {
873 .name = "sh_mmcif",
874 .id = 0,
875 .dev = {
876 .dma_mask = NULL,
877 .coherent_dma_mask = 0xffffffff,
878 .platform_data = &sh_mmcif_plat,
879 },
880 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
881 .resource = sh_mmcif_resources,
882};
883
Magnus Dammae37c8d2010-12-22 14:47:40 +0000884
885static int mackerel_camera_add(struct soc_camera_link *icl, struct device *dev);
886static void mackerel_camera_del(struct soc_camera_link *icl);
887
888static int camera_set_capture(struct soc_camera_platform_info *info,
889 int enable)
890{
891 return 0; /* camera sensor always enabled */
892}
893
894static struct soc_camera_platform_info camera_info = {
895 .format_name = "UYVY",
896 .format_depth = 16,
897 .format = {
898 .code = V4L2_MBUS_FMT_UYVY8_2X8,
899 .colorspace = V4L2_COLORSPACE_SMPTE170M,
900 .field = V4L2_FIELD_NONE,
901 .width = 640,
902 .height = 480,
903 },
904 .bus_param = SOCAM_PCLK_SAMPLE_RISING | SOCAM_HSYNC_ACTIVE_HIGH |
905 SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_MASTER | SOCAM_DATAWIDTH_8 |
906 SOCAM_DATA_ACTIVE_HIGH,
907 .set_capture = camera_set_capture,
908};
909
910static struct soc_camera_link camera_link = {
911 .bus_id = 0,
912 .add_device = mackerel_camera_add,
913 .del_device = mackerel_camera_del,
914 .module_name = "soc_camera_platform",
915 .priv = &camera_info,
916};
917
918static void dummy_release(struct device *dev)
919{
920}
921
922static struct platform_device camera_device = {
923 .name = "soc_camera_platform",
924 .dev = {
925 .platform_data = &camera_info,
926 .release = dummy_release,
927 },
928};
929
930static int mackerel_camera_add(struct soc_camera_link *icl,
931 struct device *dev)
932{
933 if (icl != &camera_link)
934 return -ENODEV;
935
936 camera_info.dev = dev;
937
938 return platform_device_register(&camera_device);
939}
940
941static void mackerel_camera_del(struct soc_camera_link *icl)
942{
943 if (icl != &camera_link)
944 return;
945
946 platform_device_unregister(&camera_device);
947 memset(&camera_device.dev.kobj, 0,
948 sizeof(camera_device.dev.kobj));
949}
950
951static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
952 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
953};
954
955static struct resource ceu_resources[] = {
956 [0] = {
957 .name = "CEU",
958 .start = 0xfe910000,
959 .end = 0xfe91009f,
960 .flags = IORESOURCE_MEM,
961 },
962 [1] = {
963 .start = intcs_evt2irq(0x880),
964 .flags = IORESOURCE_IRQ,
965 },
966 [2] = {
967 /* place holder for contiguous memory */
968 },
969};
970
971static struct platform_device ceu_device = {
972 .name = "sh_mobile_ceu",
973 .id = 0, /* "ceu0" clock */
974 .num_resources = ARRAY_SIZE(ceu_resources),
975 .resource = ceu_resources,
976 .dev = {
Guennadi Liakhovetski05a5f012011-03-23 09:29:16 +0000977 .platform_data = &sh_mobile_ceu_info,
978 .coherent_dma_mask = 0xffffffff,
Magnus Dammae37c8d2010-12-22 14:47:40 +0000979 },
980};
981
982static struct platform_device mackerel_camera = {
983 .name = "soc-camera-pdrv",
984 .id = 0,
985 .dev = {
986 .platform_data = &camera_link,
987 },
988};
989
Kuninori Morimoto920adc72010-11-29 02:21:21 +0000990static struct platform_device *mackerel_devices[] __initdata = {
991 &nor_flash_device,
Kuninori Morimoto2264c152010-11-29 02:21:37 +0000992 &smc911x_device,
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000993 &lcdc_device,
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000994 &usb1_host_device,
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000995 &leds_device,
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000996 &fsi_device,
997 &fsi_ak4643_device,
Kuninori Morimoto3f25c9c2011-01-24 10:09:02 +0900998 &fsi_hdmi_device,
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900999 &sdhi0_device,
Yusuke Goda41491b92010-12-15 08:31:04 +00001000#if !defined(CONFIG_MMC_SH_MMCIF)
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001001 &sdhi1_device,
Yusuke Goda41491b92010-12-15 08:31:04 +00001002#endif
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001003 &sdhi2_device,
Yusuke Goda41491b92010-12-15 08:31:04 +00001004 &sh_mmcif_device,
Magnus Dammae37c8d2010-12-22 14:47:40 +00001005 &ceu_device,
1006 &mackerel_camera,
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001007 &hdmi_lcdc_device,
1008 &hdmi_device,
Damian1c7fcbe2011-05-24 07:01:22 +00001009 &meram_device,
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001010};
1011
Tony SIMcd8ab002010-12-09 01:55:55 +00001012/* Keypad Initialization */
1013#define KEYPAD_BUTTON(ev_type, ev_code, act_low) \
1014{ \
1015 .type = ev_type, \
1016 .code = ev_code, \
1017 .active_low = act_low, \
1018}
1019
1020#define KEYPAD_BUTTON_LOW(event_code) KEYPAD_BUTTON(EV_KEY, event_code, 1)
1021
1022static struct tca6416_button mackerel_gpio_keys[] = {
1023 KEYPAD_BUTTON_LOW(KEY_HOME),
1024 KEYPAD_BUTTON_LOW(KEY_MENU),
1025 KEYPAD_BUTTON_LOW(KEY_BACK),
1026 KEYPAD_BUTTON_LOW(KEY_POWER),
1027};
1028
1029static struct tca6416_keys_platform_data mackerel_tca6416_keys_info = {
1030 .buttons = mackerel_gpio_keys,
1031 .nbuttons = ARRAY_SIZE(mackerel_gpio_keys),
1032 .rep = 1,
1033 .use_polling = 0,
1034 .pinmask = 0x000F,
1035};
1036
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001037/* I2C */
Tony SIM6ae1e192011-01-11 09:47:59 +09001038#define IRQ7 evt2irq(0x02e0)
Tony SIMcd8ab002010-12-09 01:55:55 +00001039#define IRQ9 evt2irq(0x0320)
1040
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001041static struct i2c_board_info i2c0_devices[] = {
1042 {
1043 I2C_BOARD_INFO("ak4643", 0x13),
1044 },
Tony SIMcd8ab002010-12-09 01:55:55 +00001045 /* Keypad */
1046 {
1047 I2C_BOARD_INFO("tca6408-keys", 0x20),
1048 .platform_data = &mackerel_tca6416_keys_info,
1049 .irq = IRQ9,
1050 },
Tony SIM6ae1e192011-01-11 09:47:59 +09001051 /* Touchscreen */
1052 {
1053 I2C_BOARD_INFO("st1232-ts", 0x55),
1054 .irq = IRQ7,
1055 },
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001056};
1057
Tony SIM80f1dc72010-12-07 09:12:14 +00001058#define IRQ21 evt2irq(0x32a0)
1059
1060static struct i2c_board_info i2c1_devices[] = {
1061 /* Accelerometer */
1062 {
1063 I2C_BOARD_INFO("adxl34x", 0x53),
1064 .irq = IRQ21,
1065 },
1066};
1067
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001068static struct map_desc mackerel_io_desc[] __initdata = {
1069 /* create a 1:1 entity map for 0xe6xxxxxx
1070 * used by CPGA, INTC and PFC.
1071 */
1072 {
1073 .virtual = 0xe6000000,
1074 .pfn = __phys_to_pfn(0xe6000000),
1075 .length = 256 << 20,
1076 .type = MT_DEVICE_NONSHARED
1077 },
1078};
1079
1080static void __init mackerel_map_io(void)
1081{
1082 iotable_init(mackerel_io_desc, ARRAY_SIZE(mackerel_io_desc));
1083
1084 /* setup early devices and console here as well */
1085 sh7372_add_early_devices();
1086 shmobile_setup_console();
1087}
1088
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001089#define GPIO_PORT9CR 0xE6051009
1090#define GPIO_PORT10CR 0xE605100A
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001091#define SRCR4 0xe61580bc
Kuninori Morimoto98d27b82011-01-06 02:44:15 +00001092#define USCCR1 0xE6058144
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001093static void __init mackerel_init(void)
1094{
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001095 u32 srcr4;
Kuninori Morimoto98d27b82011-01-06 02:44:15 +00001096 struct clk *clk;
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001097
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001098 sh7372_pinmux_init();
1099
1100 /* enable SCIFA0 */
1101 gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
1102 gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
1103
Kuninori Morimoto2264c152010-11-29 02:21:37 +00001104 /* enable SMSC911X */
1105 gpio_request(GPIO_FN_CS5A, NULL);
1106 gpio_request(GPIO_FN_IRQ6_39, NULL);
1107
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001108 /* LCDC */
Kuninori Morimotoeb87e672010-11-29 06:19:52 +00001109 gpio_request(GPIO_FN_LCDD23, NULL);
1110 gpio_request(GPIO_FN_LCDD22, NULL);
1111 gpio_request(GPIO_FN_LCDD21, NULL);
1112 gpio_request(GPIO_FN_LCDD20, NULL);
1113 gpio_request(GPIO_FN_LCDD19, NULL);
1114 gpio_request(GPIO_FN_LCDD18, NULL);
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001115 gpio_request(GPIO_FN_LCDD17, NULL);
1116 gpio_request(GPIO_FN_LCDD16, NULL);
1117 gpio_request(GPIO_FN_LCDD15, NULL);
1118 gpio_request(GPIO_FN_LCDD14, NULL);
1119 gpio_request(GPIO_FN_LCDD13, NULL);
1120 gpio_request(GPIO_FN_LCDD12, NULL);
1121 gpio_request(GPIO_FN_LCDD11, NULL);
1122 gpio_request(GPIO_FN_LCDD10, NULL);
1123 gpio_request(GPIO_FN_LCDD9, NULL);
1124 gpio_request(GPIO_FN_LCDD8, NULL);
1125 gpio_request(GPIO_FN_LCDD7, NULL);
1126 gpio_request(GPIO_FN_LCDD6, NULL);
1127 gpio_request(GPIO_FN_LCDD5, NULL);
1128 gpio_request(GPIO_FN_LCDD4, NULL);
1129 gpio_request(GPIO_FN_LCDD3, NULL);
1130 gpio_request(GPIO_FN_LCDD2, NULL);
1131 gpio_request(GPIO_FN_LCDD1, NULL);
1132 gpio_request(GPIO_FN_LCDD0, NULL);
1133 gpio_request(GPIO_FN_LCDDISP, NULL);
1134 gpio_request(GPIO_FN_LCDDCK, NULL);
1135
1136 gpio_request(GPIO_PORT31, NULL); /* backlight */
Magnus Damm1fbdfcd2011-03-21 07:49:45 +00001137 gpio_direction_output(GPIO_PORT31, 0); /* off by default */
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001138
1139 gpio_request(GPIO_PORT151, NULL); /* LCDDON */
1140 gpio_direction_output(GPIO_PORT151, 1);
1141
Kuninori Morimoto25338f22010-11-30 04:37:33 +00001142 /* USB enable */
1143 gpio_request(GPIO_FN_VBUS0_1, NULL);
1144 gpio_request(GPIO_FN_IDIN_1_18, NULL);
1145 gpio_request(GPIO_FN_PWEN_1_115, NULL);
1146 gpio_request(GPIO_FN_OVCN_1_114, NULL);
1147 gpio_request(GPIO_FN_EXTLP_1, NULL);
1148 gpio_request(GPIO_FN_OVCN2_1, NULL);
1149
1150 /* setup USB phy */
Kuninori Morimotod0fb0c42010-12-28 05:54:53 +00001151 __raw_writew(0x8a0a, 0xE6058130); /* USBCR4 */
Kuninori Morimoto25338f22010-11-30 04:37:33 +00001152
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001153 /* enable FSI2 port A (ak4643) */
1154 gpio_request(GPIO_FN_FSIAIBT, NULL);
1155 gpio_request(GPIO_FN_FSIAILR, NULL);
1156 gpio_request(GPIO_FN_FSIAISLD, NULL);
1157 gpio_request(GPIO_FN_FSIAOSLD, NULL);
1158 gpio_request(GPIO_PORT161, NULL);
1159 gpio_direction_output(GPIO_PORT161, 0); /* slave */
1160
1161 gpio_request(GPIO_PORT9, NULL);
1162 gpio_request(GPIO_PORT10, NULL);
1163 gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */
1164 gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */
1165
1166 intc_set_priority(IRQ_FSI, 3); /* irq priority FSI(3) > SMSC911X(2) */
1167
Kuninori Morimoto98d27b82011-01-06 02:44:15 +00001168 /* setup FSI2 port B (HDMI) */
1169 gpio_request(GPIO_FN_FSIBCK, NULL);
1170 __raw_writew(__raw_readw(USCCR1) & ~(1 << 6), USCCR1); /* use SPDIF */
1171
1172 /* set SPU2 clock to 119.6 MHz */
1173 clk = clk_get(NULL, "spu_clk");
1174 if (!IS_ERR(clk)) {
1175 clk_set_rate(clk, clk_round_rate(clk, 119600000));
1176 clk_put(clk);
1177 }
1178
Tony SIMcd8ab002010-12-09 01:55:55 +00001179 /* enable Keypad */
1180 gpio_request(GPIO_FN_IRQ9_42, NULL);
Thomas Gleixner6845664a2011-03-24 13:25:22 +01001181 irq_set_irq_type(IRQ9, IRQ_TYPE_LEVEL_HIGH);
Tony SIMcd8ab002010-12-09 01:55:55 +00001182
Tony SIM6ae1e192011-01-11 09:47:59 +09001183 /* enable Touchscreen */
1184 gpio_request(GPIO_FN_IRQ7_40, NULL);
Thomas Gleixner6845664a2011-03-24 13:25:22 +01001185 irq_set_irq_type(IRQ7, IRQ_TYPE_LEVEL_LOW);
Tony SIM6ae1e192011-01-11 09:47:59 +09001186
Tony SIM80f1dc72010-12-07 09:12:14 +00001187 /* enable Accelerometer */
1188 gpio_request(GPIO_FN_IRQ21, NULL);
Thomas Gleixner6845664a2011-03-24 13:25:22 +01001189 irq_set_irq_type(IRQ21, IRQ_TYPE_LEVEL_HIGH);
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001190
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001191 /* enable SDHI0 */
1192 gpio_request(GPIO_FN_SDHICD0, NULL);
1193 gpio_request(GPIO_FN_SDHIWP0, NULL);
1194 gpio_request(GPIO_FN_SDHICMD0, NULL);
1195 gpio_request(GPIO_FN_SDHICLK0, NULL);
1196 gpio_request(GPIO_FN_SDHID0_3, NULL);
1197 gpio_request(GPIO_FN_SDHID0_2, NULL);
1198 gpio_request(GPIO_FN_SDHID0_1, NULL);
1199 gpio_request(GPIO_FN_SDHID0_0, NULL);
1200
Yusuke Goda41491b92010-12-15 08:31:04 +00001201#if !defined(CONFIG_MMC_SH_MMCIF)
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001202 /* enable SDHI1 */
1203 gpio_request(GPIO_FN_SDHICMD1, NULL);
1204 gpio_request(GPIO_FN_SDHICLK1, NULL);
1205 gpio_request(GPIO_FN_SDHID1_3, NULL);
1206 gpio_request(GPIO_FN_SDHID1_2, NULL);
1207 gpio_request(GPIO_FN_SDHID1_1, NULL);
1208 gpio_request(GPIO_FN_SDHID1_0, NULL);
Yusuke Goda41491b92010-12-15 08:31:04 +00001209#endif
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001210 /* card detect pin for MMC slot (CN7) */
1211 gpio_request(GPIO_PORT41, NULL);
1212 gpio_direction_input(GPIO_PORT41);
1213
1214 /* enable SDHI2 */
1215 gpio_request(GPIO_FN_SDHICMD2, NULL);
1216 gpio_request(GPIO_FN_SDHICLK2, NULL);
1217 gpio_request(GPIO_FN_SDHID2_3, NULL);
1218 gpio_request(GPIO_FN_SDHID2_2, NULL);
1219 gpio_request(GPIO_FN_SDHID2_1, NULL);
1220 gpio_request(GPIO_FN_SDHID2_0, NULL);
1221
Yusuke Godada5d1f42011-01-07 09:48:36 +00001222 /* card detect pin for microSD slot (CN23) */
1223 gpio_request(GPIO_PORT162, NULL);
1224 gpio_direction_input(GPIO_PORT162);
1225
Yusuke Goda41491b92010-12-15 08:31:04 +00001226 /* MMCIF */
1227 gpio_request(GPIO_FN_MMCD0_0, NULL);
1228 gpio_request(GPIO_FN_MMCD0_1, NULL);
1229 gpio_request(GPIO_FN_MMCD0_2, NULL);
1230 gpio_request(GPIO_FN_MMCD0_3, NULL);
1231 gpio_request(GPIO_FN_MMCD0_4, NULL);
1232 gpio_request(GPIO_FN_MMCD0_5, NULL);
1233 gpio_request(GPIO_FN_MMCD0_6, NULL);
1234 gpio_request(GPIO_FN_MMCD0_7, NULL);
1235 gpio_request(GPIO_FN_MMCCMD0, NULL);
1236 gpio_request(GPIO_FN_MMCCLK0, NULL);
1237
Yusuke Goda56e78da2010-12-20 01:06:04 +00001238 /* enable GPS module (GT-720F) */
1239 gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
1240 gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
1241
Magnus Dammae37c8d2010-12-22 14:47:40 +00001242 /* CEU */
1243 gpio_request(GPIO_FN_VIO_CLK, NULL);
1244 gpio_request(GPIO_FN_VIO_VD, NULL);
1245 gpio_request(GPIO_FN_VIO_HD, NULL);
1246 gpio_request(GPIO_FN_VIO_FIELD, NULL);
1247 gpio_request(GPIO_FN_VIO_CKO, NULL);
1248 gpio_request(GPIO_FN_VIO_D7, NULL);
1249 gpio_request(GPIO_FN_VIO_D6, NULL);
1250 gpio_request(GPIO_FN_VIO_D5, NULL);
1251 gpio_request(GPIO_FN_VIO_D4, NULL);
1252 gpio_request(GPIO_FN_VIO_D3, NULL);
1253 gpio_request(GPIO_FN_VIO_D2, NULL);
1254 gpio_request(GPIO_FN_VIO_D1, NULL);
1255 gpio_request(GPIO_FN_VIO_D0, NULL);
1256
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001257 /* HDMI */
1258 gpio_request(GPIO_FN_HDMI_HPD, NULL);
1259 gpio_request(GPIO_FN_HDMI_CEC, NULL);
1260
1261 /* Reset HDMI, must be held at least one EXTALR (32768Hz) period */
1262 srcr4 = __raw_readl(SRCR4);
1263 __raw_writel(srcr4 | (1 << 13), SRCR4);
1264 udelay(50);
1265 __raw_writel(srcr4 & ~(1 << 13), SRCR4);
1266
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001267 i2c_register_board_info(0, i2c0_devices,
1268 ARRAY_SIZE(i2c0_devices));
Tony SIM80f1dc72010-12-07 09:12:14 +00001269 i2c_register_board_info(1, i2c1_devices,
1270 ARRAY_SIZE(i2c1_devices));
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001271
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001272 sh7372_add_standard_devices();
1273
1274 platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices));
Guennadi Liakhovetski2ce51f82011-04-04 17:08:05 +02001275
1276 hdmi_init_pm_clock();
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001277}
1278
1279static void __init mackerel_timer_init(void)
1280{
1281 sh7372_clock_init();
1282 shmobile_timer.init();
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001283
1284 /* External clock source */
1285 clk_set_rate(&sh7372_dv_clki_clk, 27000000);
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001286}
1287
1288static struct sys_timer mackerel_timer = {
1289 .init = mackerel_timer_init,
1290};
1291
1292MACHINE_START(MACKEREL, "mackerel")
1293 .map_io = mackerel_map_io,
1294 .init_irq = sh7372_init_irq,
Magnus Damm863b1712010-12-28 08:27:01 +00001295 .handle_irq = shmobile_handle_irq_intc,
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001296 .init_machine = mackerel_init,
1297 .timer = &mackerel_timer,
1298MACHINE_END