blob: 008bd7f7883fab34646f2c53695d6e6477fce361 [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
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
Magnus Damm1fbdfcd2011-03-21 07:49:45 +0000298static int mackerel_set_brightness(void *board_data, int brightness)
299{
300 gpio_set_value(GPIO_PORT31, brightness);
301
302 return 0;
303}
304
305static int mackerel_get_brightness(void *board_data)
306{
307 return gpio_get_value(GPIO_PORT31);
308}
309
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000310static struct sh_mobile_lcdc_info lcdc_info = {
311 .clock_source = LCDC_CLK_BUS,
312 .ch[0] = {
313 .chan = LCDC_CHAN_MAINLCD,
314 .bpp = 16,
315 .lcd_cfg = mackerel_lcdc_modes,
316 .num_cfg = ARRAY_SIZE(mackerel_lcdc_modes),
317 .interface_type = RGB24,
Kuninori Morimoto2c34e932011-03-02 09:05:21 +0000318 .clock_divider = 3,
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000319 .flags = 0,
320 .lcd_size_cfg.width = 152,
321 .lcd_size_cfg.height = 91,
Magnus Damm1fbdfcd2011-03-21 07:49:45 +0000322 .board_cfg = {
323 .set_brightness = mackerel_set_brightness,
324 .get_brightness = mackerel_get_brightness,
325 },
326 .bl_info = {
327 .name = "sh_mobile_lcdc_bl",
328 .max_brightness = 1,
329 },
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000330 }
331};
332
333static struct resource lcdc_resources[] = {
334 [0] = {
335 .name = "LCDC",
336 .start = 0xfe940000,
337 .end = 0xfe943fff,
338 .flags = IORESOURCE_MEM,
339 },
340 [1] = {
341 .start = intcs_evt2irq(0x580),
342 .flags = IORESOURCE_IRQ,
343 },
344};
345
346static struct platform_device lcdc_device = {
347 .name = "sh_mobile_lcdc_fb",
348 .num_resources = ARRAY_SIZE(lcdc_resources),
349 .resource = lcdc_resources,
350 .dev = {
351 .platform_data = &lcdc_info,
352 .coherent_dma_mask = ~0,
353 },
354};
355
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000356/* HDMI */
357static struct sh_mobile_lcdc_info hdmi_lcdc_info = {
358 .clock_source = LCDC_CLK_EXTERNAL,
359 .ch[0] = {
360 .chan = LCDC_CHAN_MAINLCD,
361 .bpp = 16,
362 .interface_type = RGB24,
363 .clock_divider = 1,
364 .flags = LCDC_FLAGS_DWPOL,
365 }
366};
367
368static struct resource hdmi_lcdc_resources[] = {
369 [0] = {
370 .name = "LCDC1",
371 .start = 0xfe944000,
372 .end = 0xfe947fff,
373 .flags = IORESOURCE_MEM,
374 },
375 [1] = {
376 .start = intcs_evt2irq(0x1780),
377 .flags = IORESOURCE_IRQ,
378 },
379};
380
381static struct platform_device hdmi_lcdc_device = {
382 .name = "sh_mobile_lcdc_fb",
383 .num_resources = ARRAY_SIZE(hdmi_lcdc_resources),
384 .resource = hdmi_lcdc_resources,
385 .id = 1,
386 .dev = {
387 .platform_data = &hdmi_lcdc_info,
388 .coherent_dma_mask = ~0,
389 },
390};
391
392static struct sh_mobile_hdmi_info hdmi_info = {
393 .lcd_chan = &hdmi_lcdc_info.ch[0],
394 .lcd_dev = &hdmi_lcdc_device.dev,
Kuninori Morimoto98d27b82011-01-06 02:44:15 +0000395 .flags = HDMI_SND_SRC_SPDIF,
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000396};
397
398static struct resource hdmi_resources[] = {
399 [0] = {
400 .name = "HDMI",
401 .start = 0xe6be0000,
402 .end = 0xe6be00ff,
403 .flags = IORESOURCE_MEM,
404 },
405 [1] = {
406 /* There's also an HDMI interrupt on INTCS @ 0x18e0 */
407 .start = evt2irq(0x17e0),
408 .flags = IORESOURCE_IRQ,
409 },
410};
411
412static struct platform_device hdmi_device = {
413 .name = "sh-mobile-hdmi",
414 .num_resources = ARRAY_SIZE(hdmi_resources),
415 .resource = hdmi_resources,
416 .id = -1,
417 .dev = {
418 .platform_data = &hdmi_info,
419 },
420};
421
Kuninori Morimoto3f25c9c2011-01-24 10:09:02 +0900422static struct platform_device fsi_hdmi_device = {
423 .name = "sh_fsi2_b_hdmi",
424};
425
Guennadi Liakhovetski2ce51f82011-04-04 17:08:05 +0200426static void __init hdmi_init_pm_clock(void)
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000427{
428 struct clk *hdmi_ick = clk_get(&hdmi_device.dev, "ick");
429 int ret;
430 long rate;
431
432 if (IS_ERR(hdmi_ick)) {
433 ret = PTR_ERR(hdmi_ick);
434 pr_err("Cannot get HDMI ICK: %d\n", ret);
435 goto out;
436 }
437
438 ret = clk_set_parent(&sh7372_pllc2_clk, &sh7372_dv_clki_div2_clk);
439 if (ret < 0) {
440 pr_err("Cannot set PLLC2 parent: %d, %d users\n",
441 ret, sh7372_pllc2_clk.usecount);
442 goto out;
443 }
444
445 pr_debug("PLLC2 initial frequency %lu\n",
446 clk_get_rate(&sh7372_pllc2_clk));
447
448 rate = clk_round_rate(&sh7372_pllc2_clk, 594000000);
449 if (rate < 0) {
450 pr_err("Cannot get suitable rate: %ld\n", rate);
451 ret = rate;
452 goto out;
453 }
454
455 ret = clk_set_rate(&sh7372_pllc2_clk, rate);
456 if (ret < 0) {
457 pr_err("Cannot set rate %ld: %d\n", rate, ret);
458 goto out;
459 }
460
461 ret = clk_enable(&sh7372_pllc2_clk);
462 if (ret < 0) {
463 pr_err("Cannot enable pllc2 clock\n");
464 goto out;
465 }
466
467 pr_debug("PLLC2 set frequency %lu\n", rate);
468
469 ret = clk_set_parent(hdmi_ick, &sh7372_pllc2_clk);
Guennadi Liakhovetski2ce51f82011-04-04 17:08:05 +0200470 if (ret < 0)
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000471 pr_err("Cannot set HDMI parent: %d\n", ret);
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000472
473out:
474 if (!IS_ERR(hdmi_ick))
475 clk_put(hdmi_ick);
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000476}
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000477
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000478/* USB1 (Host) */
479static void usb1_host_port_power(int port, int power)
480{
481 if (!power) /* only power-on is supported for now */
482 return;
483
484 /* set VBOUT/PWEN and EXTLP1 in DVSTCTR */
485 __raw_writew(__raw_readw(0xE68B0008) | 0x600, 0xE68B0008);
486}
487
488static struct r8a66597_platdata usb1_host_data = {
489 .on_chip = 1,
490 .port_power = usb1_host_port_power,
491};
492
493static struct resource usb1_host_resources[] = {
494 [0] = {
495 .name = "USBHS",
496 .start = 0xE68B0000,
497 .end = 0xE68B00E6 - 1,
498 .flags = IORESOURCE_MEM,
499 },
500 [1] = {
501 .start = evt2irq(0x1ce0) /* USB1_USB1I0 */,
502 .flags = IORESOURCE_IRQ,
503 },
504};
505
506static struct platform_device usb1_host_device = {
507 .name = "r8a66597_hcd",
508 .id = 1,
509 .dev = {
510 .dma_mask = NULL, /* not use dma */
511 .coherent_dma_mask = 0xffffffff,
512 .platform_data = &usb1_host_data,
513 },
514 .num_resources = ARRAY_SIZE(usb1_host_resources),
515 .resource = usb1_host_resources,
516};
517
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000518/* LED */
519static struct gpio_led mackerel_leds[] = {
520 {
521 .name = "led0",
522 .gpio = GPIO_PORT0,
523 .default_state = LEDS_GPIO_DEFSTATE_ON,
524 },
525 {
526 .name = "led1",
527 .gpio = GPIO_PORT1,
528 .default_state = LEDS_GPIO_DEFSTATE_ON,
529 },
530 {
531 .name = "led2",
532 .gpio = GPIO_PORT2,
533 .default_state = LEDS_GPIO_DEFSTATE_ON,
534 },
535 {
536 .name = "led3",
537 .gpio = GPIO_PORT159,
538 .default_state = LEDS_GPIO_DEFSTATE_ON,
539 }
540};
541
542static struct gpio_led_platform_data mackerel_leds_pdata = {
543 .leds = mackerel_leds,
544 .num_leds = ARRAY_SIZE(mackerel_leds),
545};
546
547static struct platform_device leds_device = {
548 .name = "leds-gpio",
549 .id = 0,
550 .dev = {
551 .platform_data = &mackerel_leds_pdata,
552 },
553};
554
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000555/* FSI */
556#define IRQ_FSI evt2irq(0x1840)
Kuninori Morimoto98d27b82011-01-06 02:44:15 +0000557static int __fsi_set_round_rate(struct clk *clk, long rate, int enable)
558{
559 int ret;
560
561 if (rate <= 0)
562 return 0;
563
564 if (!enable) {
565 clk_disable(clk);
566 return 0;
567 }
568
569 ret = clk_set_rate(clk, clk_round_rate(clk, rate));
570 if (ret < 0)
571 return ret;
572
573 return clk_enable(clk);
574}
575
576static int fsi_set_rate(struct device *dev, int is_porta, int rate, int enable)
577{
578 struct clk *fsib_clk;
579 struct clk *fdiv_clk = &sh7372_fsidivb_clk;
580 long fsib_rate = 0;
581 long fdiv_rate = 0;
582 int ackmd_bpfmd;
583 int ret;
584
585 /* FSIA is slave mode. nothing to do here */
586 if (is_porta)
587 return 0;
588
589 /* clock start */
590 switch (rate) {
591 case 44100:
592 fsib_rate = rate * 256;
593 ackmd_bpfmd = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
594 break;
595 case 48000:
596 fsib_rate = 85428000; /* around 48kHz x 256 x 7 */
597 fdiv_rate = rate * 256;
598 ackmd_bpfmd = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
599 break;
600 default:
601 pr_err("unsupported rate in FSI2 port B\n");
602 return -EINVAL;
603 }
604
605 /* FSI B setting */
606 fsib_clk = clk_get(dev, "ickb");
607 if (IS_ERR(fsib_clk))
608 return -EIO;
609
610 /* fsib */
611 ret = __fsi_set_round_rate(fsib_clk, fsib_rate, enable);
612 if (ret < 0)
613 goto fsi_set_rate_end;
614
615 /* FSI DIV */
616 ret = __fsi_set_round_rate(fdiv_clk, fdiv_rate, enable);
617 if (ret < 0) {
618 /* disable FSI B */
619 if (enable)
620 __fsi_set_round_rate(fsib_clk, fsib_rate, 0);
621 goto fsi_set_rate_end;
622 }
623
624 ret = ackmd_bpfmd;
625
626fsi_set_rate_end:
627 clk_put(fsib_clk);
628 return ret;
629}
630
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000631static struct sh_fsi_platform_info fsi_info = {
Kuninori Morimotof17c13c2011-01-24 10:43:19 +0900632 .porta_flags = SH_FSI_BRS_INV,
Kuninori Morimoto98d27b82011-01-06 02:44:15 +0000633
634 .portb_flags = SH_FSI_BRS_INV |
635 SH_FSI_BRM_INV |
636 SH_FSI_LRS_INV |
Kuninori Morimotof17c13c2011-01-24 10:43:19 +0900637 SH_FSI_FMT_SPDIF,
Kuninori Morimoto98d27b82011-01-06 02:44:15 +0000638
639 .set_rate = fsi_set_rate,
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000640};
641
642static struct resource fsi_resources[] = {
643 [0] = {
644 .name = "FSI",
645 .start = 0xFE3C0000,
646 .end = 0xFE3C0400 - 1,
647 .flags = IORESOURCE_MEM,
648 },
649 [1] = {
650 .start = IRQ_FSI,
651 .flags = IORESOURCE_IRQ,
652 },
653};
654
655static struct platform_device fsi_device = {
656 .name = "sh_fsi2",
657 .id = -1,
658 .num_resources = ARRAY_SIZE(fsi_resources),
659 .resource = fsi_resources,
660 .dev = {
661 .platform_data = &fsi_info,
662 },
663};
664
665static struct platform_device fsi_ak4643_device = {
666 .name = "sh_fsi2_a_ak4643",
667};
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000668
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900669/*
670 * The card detect pin of the top SD/MMC slot (CN7) is active low and is
671 * connected to GPIO A22 of SH7372 (GPIO_PORT41).
672 */
673static int slot_cn7_get_cd(struct platform_device *pdev)
674{
Magnus Dammceb50f32011-01-12 10:43:07 +0000675 return !gpio_get_value(GPIO_PORT41);
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900676}
677
678/* SDHI0 */
679static struct sh_mobile_sdhi_info sdhi0_info = {
680 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
681 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
Magnus Dammda97da72011-01-06 10:55:41 +0000682 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900683};
684
685static struct resource sdhi0_resources[] = {
686 [0] = {
687 .name = "SDHI0",
688 .start = 0xe6850000,
Guennadi Liakhovetski31d31fe72011-03-09 13:09:27 +0100689 .end = 0xe68500ff,
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900690 .flags = IORESOURCE_MEM,
691 },
692 [1] = {
693 .start = evt2irq(0x0e00) /* SDHI0 */,
694 .flags = IORESOURCE_IRQ,
695 },
696};
697
698static struct platform_device sdhi0_device = {
699 .name = "sh_mobile_sdhi",
700 .num_resources = ARRAY_SIZE(sdhi0_resources),
701 .resource = sdhi0_resources,
702 .id = 0,
703 .dev = {
704 .platform_data = &sdhi0_info,
705 },
706};
707
Guennadi Liakhovetski5bcd7512011-05-05 15:56:27 +0000708#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900709/* SDHI1 */
710static struct sh_mobile_sdhi_info sdhi1_info = {
711 .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
712 .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
713 .tmio_ocr_mask = MMC_VDD_165_195,
714 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
Magnus Dammda97da72011-01-06 10:55:41 +0000715 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900716 MMC_CAP_NEEDS_POLL,
717 .get_cd = slot_cn7_get_cd,
718};
719
720static struct resource sdhi1_resources[] = {
721 [0] = {
722 .name = "SDHI1",
723 .start = 0xe6860000,
Guennadi Liakhovetski31d31fe72011-03-09 13:09:27 +0100724 .end = 0xe68600ff,
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900725 .flags = IORESOURCE_MEM,
726 },
727 [1] = {
728 .start = evt2irq(0x0e80),
729 .flags = IORESOURCE_IRQ,
730 },
731};
732
733static struct platform_device sdhi1_device = {
734 .name = "sh_mobile_sdhi",
735 .num_resources = ARRAY_SIZE(sdhi1_resources),
736 .resource = sdhi1_resources,
737 .id = 1,
738 .dev = {
739 .platform_data = &sdhi1_info,
740 },
741};
Yusuke Goda41491b92010-12-15 08:31:04 +0000742#endif
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900743
Yusuke Godada5d1f42011-01-07 09:48:36 +0000744/*
745 * The card detect pin of the top SD/MMC slot (CN23) is active low and is
746 * connected to GPIO SCIFB_SCK of SH7372 (GPIO_PORT162).
747 */
748static int slot_cn23_get_cd(struct platform_device *pdev)
749{
750 return !gpio_get_value(GPIO_PORT162);
751}
752
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900753/* SDHI2 */
754static struct sh_mobile_sdhi_info sdhi2_info = {
755 .dma_slave_tx = SHDMA_SLAVE_SDHI2_TX,
756 .dma_slave_rx = SHDMA_SLAVE_SDHI2_RX,
757 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
Magnus Dammda97da72011-01-06 10:55:41 +0000758 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900759 MMC_CAP_NEEDS_POLL,
Yusuke Godada5d1f42011-01-07 09:48:36 +0000760 .get_cd = slot_cn23_get_cd,
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900761};
762
763static struct resource sdhi2_resources[] = {
764 [0] = {
765 .name = "SDHI2",
766 .start = 0xe6870000,
Guennadi Liakhovetski31d31fe72011-03-09 13:09:27 +0100767 .end = 0xe68700ff,
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900768 .flags = IORESOURCE_MEM,
769 },
770 [1] = {
771 .start = evt2irq(0x1200),
772 .flags = IORESOURCE_IRQ,
773 },
774};
775
776static struct platform_device sdhi2_device = {
777 .name = "sh_mobile_sdhi",
778 .num_resources = ARRAY_SIZE(sdhi2_resources),
779 .resource = sdhi2_resources,
780 .id = 2,
781 .dev = {
782 .platform_data = &sdhi2_info,
783 },
784};
785
Yusuke Goda41491b92010-12-15 08:31:04 +0000786/* SH_MMCIF */
787static struct resource sh_mmcif_resources[] = {
788 [0] = {
789 .name = "MMCIF",
790 .start = 0xE6BD0000,
791 .end = 0xE6BD00FF,
792 .flags = IORESOURCE_MEM,
793 },
794 [1] = {
795 /* MMC ERR */
796 .start = evt2irq(0x1ac0),
797 .flags = IORESOURCE_IRQ,
798 },
799 [2] = {
800 /* MMC NOR */
801 .start = evt2irq(0x1ae0),
802 .flags = IORESOURCE_IRQ,
803 },
804};
805
Guennadi Liakhovetskife78e682011-05-05 15:56:31 +0000806static struct sh_mmcif_dma sh_mmcif_dma = {
807 .chan_priv_rx = {
808 .slave_id = SHDMA_SLAVE_MMCIF_RX,
809 },
810 .chan_priv_tx = {
811 .slave_id = SHDMA_SLAVE_MMCIF_TX,
812 },
813};
814
Yusuke Goda41491b92010-12-15 08:31:04 +0000815static struct sh_mmcif_plat_data sh_mmcif_plat = {
816 .sup_pclk = 0,
817 .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
818 .caps = MMC_CAP_4_BIT_DATA |
819 MMC_CAP_8_BIT_DATA |
820 MMC_CAP_NEEDS_POLL,
821 .get_cd = slot_cn7_get_cd,
Guennadi Liakhovetskife78e682011-05-05 15:56:31 +0000822 .dma = &sh_mmcif_dma,
Yusuke Goda41491b92010-12-15 08:31:04 +0000823};
824
825static struct platform_device sh_mmcif_device = {
826 .name = "sh_mmcif",
827 .id = 0,
828 .dev = {
829 .dma_mask = NULL,
830 .coherent_dma_mask = 0xffffffff,
831 .platform_data = &sh_mmcif_plat,
832 },
833 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
834 .resource = sh_mmcif_resources,
835};
836
Magnus Dammae37c8d2010-12-22 14:47:40 +0000837
838static int mackerel_camera_add(struct soc_camera_link *icl, struct device *dev);
839static void mackerel_camera_del(struct soc_camera_link *icl);
840
841static int camera_set_capture(struct soc_camera_platform_info *info,
842 int enable)
843{
844 return 0; /* camera sensor always enabled */
845}
846
847static struct soc_camera_platform_info camera_info = {
848 .format_name = "UYVY",
849 .format_depth = 16,
850 .format = {
851 .code = V4L2_MBUS_FMT_UYVY8_2X8,
852 .colorspace = V4L2_COLORSPACE_SMPTE170M,
853 .field = V4L2_FIELD_NONE,
854 .width = 640,
855 .height = 480,
856 },
857 .bus_param = SOCAM_PCLK_SAMPLE_RISING | SOCAM_HSYNC_ACTIVE_HIGH |
858 SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_MASTER | SOCAM_DATAWIDTH_8 |
859 SOCAM_DATA_ACTIVE_HIGH,
860 .set_capture = camera_set_capture,
861};
862
863static struct soc_camera_link camera_link = {
864 .bus_id = 0,
865 .add_device = mackerel_camera_add,
866 .del_device = mackerel_camera_del,
867 .module_name = "soc_camera_platform",
868 .priv = &camera_info,
869};
870
871static void dummy_release(struct device *dev)
872{
873}
874
875static struct platform_device camera_device = {
876 .name = "soc_camera_platform",
877 .dev = {
878 .platform_data = &camera_info,
879 .release = dummy_release,
880 },
881};
882
883static int mackerel_camera_add(struct soc_camera_link *icl,
884 struct device *dev)
885{
886 if (icl != &camera_link)
887 return -ENODEV;
888
889 camera_info.dev = dev;
890
891 return platform_device_register(&camera_device);
892}
893
894static void mackerel_camera_del(struct soc_camera_link *icl)
895{
896 if (icl != &camera_link)
897 return;
898
899 platform_device_unregister(&camera_device);
900 memset(&camera_device.dev.kobj, 0,
901 sizeof(camera_device.dev.kobj));
902}
903
904static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
905 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
906};
907
908static struct resource ceu_resources[] = {
909 [0] = {
910 .name = "CEU",
911 .start = 0xfe910000,
912 .end = 0xfe91009f,
913 .flags = IORESOURCE_MEM,
914 },
915 [1] = {
916 .start = intcs_evt2irq(0x880),
917 .flags = IORESOURCE_IRQ,
918 },
919 [2] = {
920 /* place holder for contiguous memory */
921 },
922};
923
924static struct platform_device ceu_device = {
925 .name = "sh_mobile_ceu",
926 .id = 0, /* "ceu0" clock */
927 .num_resources = ARRAY_SIZE(ceu_resources),
928 .resource = ceu_resources,
929 .dev = {
Guennadi Liakhovetski05a5f012011-03-23 09:29:16 +0000930 .platform_data = &sh_mobile_ceu_info,
931 .coherent_dma_mask = 0xffffffff,
Magnus Dammae37c8d2010-12-22 14:47:40 +0000932 },
933};
934
935static struct platform_device mackerel_camera = {
936 .name = "soc-camera-pdrv",
937 .id = 0,
938 .dev = {
939 .platform_data = &camera_link,
940 },
941};
942
Kuninori Morimoto920adc72010-11-29 02:21:21 +0000943static struct platform_device *mackerel_devices[] __initdata = {
944 &nor_flash_device,
Kuninori Morimoto2264c152010-11-29 02:21:37 +0000945 &smc911x_device,
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000946 &lcdc_device,
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000947 &usb1_host_device,
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000948 &leds_device,
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000949 &fsi_device,
950 &fsi_ak4643_device,
Kuninori Morimoto3f25c9c2011-01-24 10:09:02 +0900951 &fsi_hdmi_device,
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900952 &sdhi0_device,
Guennadi Liakhovetski5bcd7512011-05-05 15:56:27 +0000953#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900954 &sdhi1_device,
Yusuke Goda41491b92010-12-15 08:31:04 +0000955#endif
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900956 &sdhi2_device,
Yusuke Goda41491b92010-12-15 08:31:04 +0000957 &sh_mmcif_device,
Magnus Dammae37c8d2010-12-22 14:47:40 +0000958 &ceu_device,
959 &mackerel_camera,
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000960 &hdmi_lcdc_device,
961 &hdmi_device,
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000962};
963
Tony SIMcd8ab002010-12-09 01:55:55 +0000964/* Keypad Initialization */
965#define KEYPAD_BUTTON(ev_type, ev_code, act_low) \
966{ \
967 .type = ev_type, \
968 .code = ev_code, \
969 .active_low = act_low, \
970}
971
972#define KEYPAD_BUTTON_LOW(event_code) KEYPAD_BUTTON(EV_KEY, event_code, 1)
973
974static struct tca6416_button mackerel_gpio_keys[] = {
975 KEYPAD_BUTTON_LOW(KEY_HOME),
976 KEYPAD_BUTTON_LOW(KEY_MENU),
977 KEYPAD_BUTTON_LOW(KEY_BACK),
978 KEYPAD_BUTTON_LOW(KEY_POWER),
979};
980
981static struct tca6416_keys_platform_data mackerel_tca6416_keys_info = {
982 .buttons = mackerel_gpio_keys,
983 .nbuttons = ARRAY_SIZE(mackerel_gpio_keys),
984 .rep = 1,
985 .use_polling = 0,
986 .pinmask = 0x000F,
987};
988
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000989/* I2C */
Tony SIM6ae1e192011-01-11 09:47:59 +0900990#define IRQ7 evt2irq(0x02e0)
Tony SIMcd8ab002010-12-09 01:55:55 +0000991#define IRQ9 evt2irq(0x0320)
992
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000993static struct i2c_board_info i2c0_devices[] = {
994 {
995 I2C_BOARD_INFO("ak4643", 0x13),
996 },
Tony SIMcd8ab002010-12-09 01:55:55 +0000997 /* Keypad */
998 {
999 I2C_BOARD_INFO("tca6408-keys", 0x20),
1000 .platform_data = &mackerel_tca6416_keys_info,
1001 .irq = IRQ9,
1002 },
Tony SIM6ae1e192011-01-11 09:47:59 +09001003 /* Touchscreen */
1004 {
1005 I2C_BOARD_INFO("st1232-ts", 0x55),
1006 .irq = IRQ7,
1007 },
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001008};
1009
Tony SIM80f1dc72010-12-07 09:12:14 +00001010#define IRQ21 evt2irq(0x32a0)
1011
1012static struct i2c_board_info i2c1_devices[] = {
1013 /* Accelerometer */
1014 {
1015 I2C_BOARD_INFO("adxl34x", 0x53),
1016 .irq = IRQ21,
1017 },
1018};
1019
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001020static struct map_desc mackerel_io_desc[] __initdata = {
1021 /* create a 1:1 entity map for 0xe6xxxxxx
1022 * used by CPGA, INTC and PFC.
1023 */
1024 {
1025 .virtual = 0xe6000000,
1026 .pfn = __phys_to_pfn(0xe6000000),
1027 .length = 256 << 20,
1028 .type = MT_DEVICE_NONSHARED
1029 },
1030};
1031
1032static void __init mackerel_map_io(void)
1033{
1034 iotable_init(mackerel_io_desc, ARRAY_SIZE(mackerel_io_desc));
1035
1036 /* setup early devices and console here as well */
1037 sh7372_add_early_devices();
1038 shmobile_setup_console();
1039}
1040
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001041#define GPIO_PORT9CR 0xE6051009
1042#define GPIO_PORT10CR 0xE605100A
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001043#define SRCR4 0xe61580bc
Kuninori Morimoto98d27b82011-01-06 02:44:15 +00001044#define USCCR1 0xE6058144
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001045static void __init mackerel_init(void)
1046{
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001047 u32 srcr4;
Kuninori Morimoto98d27b82011-01-06 02:44:15 +00001048 struct clk *clk;
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001049
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001050 sh7372_pinmux_init();
1051
1052 /* enable SCIFA0 */
1053 gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
1054 gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
1055
Kuninori Morimoto2264c152010-11-29 02:21:37 +00001056 /* enable SMSC911X */
1057 gpio_request(GPIO_FN_CS5A, NULL);
1058 gpio_request(GPIO_FN_IRQ6_39, NULL);
1059
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001060 /* LCDC */
Kuninori Morimotoeb87e672010-11-29 06:19:52 +00001061 gpio_request(GPIO_FN_LCDD23, NULL);
1062 gpio_request(GPIO_FN_LCDD22, NULL);
1063 gpio_request(GPIO_FN_LCDD21, NULL);
1064 gpio_request(GPIO_FN_LCDD20, NULL);
1065 gpio_request(GPIO_FN_LCDD19, NULL);
1066 gpio_request(GPIO_FN_LCDD18, NULL);
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001067 gpio_request(GPIO_FN_LCDD17, NULL);
1068 gpio_request(GPIO_FN_LCDD16, NULL);
1069 gpio_request(GPIO_FN_LCDD15, NULL);
1070 gpio_request(GPIO_FN_LCDD14, NULL);
1071 gpio_request(GPIO_FN_LCDD13, NULL);
1072 gpio_request(GPIO_FN_LCDD12, NULL);
1073 gpio_request(GPIO_FN_LCDD11, NULL);
1074 gpio_request(GPIO_FN_LCDD10, NULL);
1075 gpio_request(GPIO_FN_LCDD9, NULL);
1076 gpio_request(GPIO_FN_LCDD8, NULL);
1077 gpio_request(GPIO_FN_LCDD7, NULL);
1078 gpio_request(GPIO_FN_LCDD6, NULL);
1079 gpio_request(GPIO_FN_LCDD5, NULL);
1080 gpio_request(GPIO_FN_LCDD4, NULL);
1081 gpio_request(GPIO_FN_LCDD3, NULL);
1082 gpio_request(GPIO_FN_LCDD2, NULL);
1083 gpio_request(GPIO_FN_LCDD1, NULL);
1084 gpio_request(GPIO_FN_LCDD0, NULL);
1085 gpio_request(GPIO_FN_LCDDISP, NULL);
1086 gpio_request(GPIO_FN_LCDDCK, NULL);
1087
1088 gpio_request(GPIO_PORT31, NULL); /* backlight */
Magnus Damm1fbdfcd2011-03-21 07:49:45 +00001089 gpio_direction_output(GPIO_PORT31, 0); /* off by default */
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001090
1091 gpio_request(GPIO_PORT151, NULL); /* LCDDON */
1092 gpio_direction_output(GPIO_PORT151, 1);
1093
Kuninori Morimoto25338f22010-11-30 04:37:33 +00001094 /* USB enable */
1095 gpio_request(GPIO_FN_VBUS0_1, NULL);
1096 gpio_request(GPIO_FN_IDIN_1_18, NULL);
1097 gpio_request(GPIO_FN_PWEN_1_115, NULL);
1098 gpio_request(GPIO_FN_OVCN_1_114, NULL);
1099 gpio_request(GPIO_FN_EXTLP_1, NULL);
1100 gpio_request(GPIO_FN_OVCN2_1, NULL);
1101
1102 /* setup USB phy */
Kuninori Morimotod0fb0c42010-12-28 05:54:53 +00001103 __raw_writew(0x8a0a, 0xE6058130); /* USBCR4 */
Kuninori Morimoto25338f22010-11-30 04:37:33 +00001104
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001105 /* enable FSI2 port A (ak4643) */
1106 gpio_request(GPIO_FN_FSIAIBT, NULL);
1107 gpio_request(GPIO_FN_FSIAILR, NULL);
1108 gpio_request(GPIO_FN_FSIAISLD, NULL);
1109 gpio_request(GPIO_FN_FSIAOSLD, NULL);
1110 gpio_request(GPIO_PORT161, NULL);
1111 gpio_direction_output(GPIO_PORT161, 0); /* slave */
1112
1113 gpio_request(GPIO_PORT9, NULL);
1114 gpio_request(GPIO_PORT10, NULL);
1115 gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */
1116 gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */
1117
1118 intc_set_priority(IRQ_FSI, 3); /* irq priority FSI(3) > SMSC911X(2) */
1119
Kuninori Morimoto98d27b82011-01-06 02:44:15 +00001120 /* setup FSI2 port B (HDMI) */
1121 gpio_request(GPIO_FN_FSIBCK, NULL);
1122 __raw_writew(__raw_readw(USCCR1) & ~(1 << 6), USCCR1); /* use SPDIF */
1123
1124 /* set SPU2 clock to 119.6 MHz */
1125 clk = clk_get(NULL, "spu_clk");
1126 if (!IS_ERR(clk)) {
1127 clk_set_rate(clk, clk_round_rate(clk, 119600000));
1128 clk_put(clk);
1129 }
1130
Tony SIMcd8ab002010-12-09 01:55:55 +00001131 /* enable Keypad */
1132 gpio_request(GPIO_FN_IRQ9_42, NULL);
Thomas Gleixner6845664a2011-03-24 13:25:22 +01001133 irq_set_irq_type(IRQ9, IRQ_TYPE_LEVEL_HIGH);
Tony SIMcd8ab002010-12-09 01:55:55 +00001134
Tony SIM6ae1e192011-01-11 09:47:59 +09001135 /* enable Touchscreen */
1136 gpio_request(GPIO_FN_IRQ7_40, NULL);
Thomas Gleixner6845664a2011-03-24 13:25:22 +01001137 irq_set_irq_type(IRQ7, IRQ_TYPE_LEVEL_LOW);
Tony SIM6ae1e192011-01-11 09:47:59 +09001138
Tony SIM80f1dc72010-12-07 09:12:14 +00001139 /* enable Accelerometer */
1140 gpio_request(GPIO_FN_IRQ21, NULL);
Thomas Gleixner6845664a2011-03-24 13:25:22 +01001141 irq_set_irq_type(IRQ21, IRQ_TYPE_LEVEL_HIGH);
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001142
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001143 /* enable SDHI0 */
1144 gpio_request(GPIO_FN_SDHICD0, NULL);
1145 gpio_request(GPIO_FN_SDHIWP0, NULL);
1146 gpio_request(GPIO_FN_SDHICMD0, NULL);
1147 gpio_request(GPIO_FN_SDHICLK0, NULL);
1148 gpio_request(GPIO_FN_SDHID0_3, NULL);
1149 gpio_request(GPIO_FN_SDHID0_2, NULL);
1150 gpio_request(GPIO_FN_SDHID0_1, NULL);
1151 gpio_request(GPIO_FN_SDHID0_0, NULL);
1152
Guennadi Liakhovetski5bcd7512011-05-05 15:56:27 +00001153#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001154 /* enable SDHI1 */
1155 gpio_request(GPIO_FN_SDHICMD1, NULL);
1156 gpio_request(GPIO_FN_SDHICLK1, NULL);
1157 gpio_request(GPIO_FN_SDHID1_3, NULL);
1158 gpio_request(GPIO_FN_SDHID1_2, NULL);
1159 gpio_request(GPIO_FN_SDHID1_1, NULL);
1160 gpio_request(GPIO_FN_SDHID1_0, NULL);
Yusuke Goda41491b92010-12-15 08:31:04 +00001161#endif
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001162 /* card detect pin for MMC slot (CN7) */
1163 gpio_request(GPIO_PORT41, NULL);
1164 gpio_direction_input(GPIO_PORT41);
1165
1166 /* enable SDHI2 */
1167 gpio_request(GPIO_FN_SDHICMD2, NULL);
1168 gpio_request(GPIO_FN_SDHICLK2, NULL);
1169 gpio_request(GPIO_FN_SDHID2_3, NULL);
1170 gpio_request(GPIO_FN_SDHID2_2, NULL);
1171 gpio_request(GPIO_FN_SDHID2_1, NULL);
1172 gpio_request(GPIO_FN_SDHID2_0, NULL);
1173
Yusuke Godada5d1f42011-01-07 09:48:36 +00001174 /* card detect pin for microSD slot (CN23) */
1175 gpio_request(GPIO_PORT162, NULL);
1176 gpio_direction_input(GPIO_PORT162);
1177
Yusuke Goda41491b92010-12-15 08:31:04 +00001178 /* MMCIF */
1179 gpio_request(GPIO_FN_MMCD0_0, NULL);
1180 gpio_request(GPIO_FN_MMCD0_1, NULL);
1181 gpio_request(GPIO_FN_MMCD0_2, NULL);
1182 gpio_request(GPIO_FN_MMCD0_3, NULL);
1183 gpio_request(GPIO_FN_MMCD0_4, NULL);
1184 gpio_request(GPIO_FN_MMCD0_5, NULL);
1185 gpio_request(GPIO_FN_MMCD0_6, NULL);
1186 gpio_request(GPIO_FN_MMCD0_7, NULL);
1187 gpio_request(GPIO_FN_MMCCMD0, NULL);
1188 gpio_request(GPIO_FN_MMCCLK0, NULL);
1189
Yusuke Goda56e78da2010-12-20 01:06:04 +00001190 /* enable GPS module (GT-720F) */
1191 gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
1192 gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
1193
Magnus Dammae37c8d2010-12-22 14:47:40 +00001194 /* CEU */
1195 gpio_request(GPIO_FN_VIO_CLK, NULL);
1196 gpio_request(GPIO_FN_VIO_VD, NULL);
1197 gpio_request(GPIO_FN_VIO_HD, NULL);
1198 gpio_request(GPIO_FN_VIO_FIELD, NULL);
1199 gpio_request(GPIO_FN_VIO_CKO, NULL);
1200 gpio_request(GPIO_FN_VIO_D7, NULL);
1201 gpio_request(GPIO_FN_VIO_D6, NULL);
1202 gpio_request(GPIO_FN_VIO_D5, NULL);
1203 gpio_request(GPIO_FN_VIO_D4, NULL);
1204 gpio_request(GPIO_FN_VIO_D3, NULL);
1205 gpio_request(GPIO_FN_VIO_D2, NULL);
1206 gpio_request(GPIO_FN_VIO_D1, NULL);
1207 gpio_request(GPIO_FN_VIO_D0, NULL);
1208
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001209 /* HDMI */
1210 gpio_request(GPIO_FN_HDMI_HPD, NULL);
1211 gpio_request(GPIO_FN_HDMI_CEC, NULL);
1212
1213 /* Reset HDMI, must be held at least one EXTALR (32768Hz) period */
1214 srcr4 = __raw_readl(SRCR4);
1215 __raw_writel(srcr4 | (1 << 13), SRCR4);
1216 udelay(50);
1217 __raw_writel(srcr4 & ~(1 << 13), SRCR4);
1218
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001219 i2c_register_board_info(0, i2c0_devices,
1220 ARRAY_SIZE(i2c0_devices));
Tony SIM80f1dc72010-12-07 09:12:14 +00001221 i2c_register_board_info(1, i2c1_devices,
1222 ARRAY_SIZE(i2c1_devices));
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001223
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001224 sh7372_add_standard_devices();
1225
1226 platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices));
Guennadi Liakhovetski2ce51f82011-04-04 17:08:05 +02001227
1228 hdmi_init_pm_clock();
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001229}
1230
1231static void __init mackerel_timer_init(void)
1232{
1233 sh7372_clock_init();
1234 shmobile_timer.init();
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001235
1236 /* External clock source */
1237 clk_set_rate(&sh7372_dv_clki_clk, 27000000);
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001238}
1239
1240static struct sys_timer mackerel_timer = {
1241 .init = mackerel_timer_init,
1242};
1243
1244MACHINE_START(MACKEREL, "mackerel")
1245 .map_io = mackerel_map_io,
1246 .init_irq = sh7372_init_irq,
Magnus Damm863b1712010-12-28 08:27:01 +00001247 .handle_irq = shmobile_handle_irq_intc,
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001248 .init_machine = mackerel_init,
1249 .timer = &mackerel_timer,
1250MACHINE_END