blob: 73f00971d0da40a3bd6cc61366a6cc30c9c4ae5c [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>
Rafael J. Wysockib5e8d262011-08-25 15:34:19 +020042#include <linux/pm_clock.h>
Kuninori Morimoto2264c152010-11-29 02:21:37 +000043#include <linux/smsc911x.h>
Kuninori Morimoto1a44d722010-12-01 00:31:46 +000044#include <linux/sh_intc.h>
Tony SIMcd8ab002010-12-09 01:55:55 +000045#include <linux/tca6416_keypad.h>
Kuninori Morimoto25338f22010-11-30 04:37:33 +000046#include <linux/usb/r8a66597.h>
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +000047#include <linux/usb/renesas_usbhs.h>
Jon Medhurst9b742022011-08-04 17:05:21 +010048#include <linux/dma-mapping.h>
Kuninori Morimoto920adc72010-11-29 02:21:21 +000049
Kuninori Morimoto12c43092011-01-06 02:44:09 +000050#include <video/sh_mobile_hdmi.h>
Kuninori Morimoto11fee462010-11-29 02:21:43 +000051#include <video/sh_mobile_lcdc.h>
Magnus Dammae37c8d2010-12-22 14:47:40 +000052#include <media/sh_mobile_ceu.h>
53#include <media/soc_camera.h>
54#include <media/soc_camera_platform.h>
Kuninori Morimoto1a44d722010-12-01 00:31:46 +000055#include <sound/sh_fsi.h>
56
Kuninori Morimoto920adc72010-11-29 02:21:21 +000057#include <mach/common.h>
Rob Herring250a2722012-01-03 16:57:33 -060058#include <mach/irqs.h>
Kuninori Morimoto920adc72010-11-29 02:21:21 +000059#include <mach/sh7372.h>
60
61#include <asm/mach/arch.h>
62#include <asm/mach/time.h>
63#include <asm/mach/map.h>
64#include <asm/mach-types.h>
65
66/*
67 * Address Interface BusWidth note
68 * ------------------------------------------------------------------
69 * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON
70 * 0x0800_0000 user area -
71 * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF
72 * 0x1400_0000 Ether (LAN9220) 16bit
73 * 0x1600_0000 user area - cannot use with NAND
74 * 0x1800_0000 user area -
75 * 0x1A00_0000 -
76 * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit
77 */
78
Kuninori Morimoto4b82b682010-11-29 02:21:48 +000079/*
80 * CPU mode
81 *
82 * SW4 | Boot Area| Master | Remarks
83 * 1 | 2 | 3 | 4 | 5 | 6 | 8 | | Processor|
84 * ----+-----+-----+-----+-----+-----+-----+----------+----------+--------------
85 * ON | ON | OFF | ON | ON | OFF | OFF | External | System | External ROM
86 * ON | ON | ON | ON | ON | OFF | OFF | External | System | ROM Debug
87 * ON | ON | X | ON | OFF | OFF | OFF | Built-in | System | ROM Debug
88 * X | OFF | X | X | X | X | OFF | Built-in | System | MaskROM
89 * OFF | X | X | X | X | X | OFF | Built-in | System | MaskROM
90 * X | X | X | OFF | X | X | OFF | Built-in | System | MaskROM
91 * OFF | ON | OFF | X | X | OFF | ON | External | System | Standalone
92 * ON | OFF | OFF | X | X | OFF | ON | External | Realtime | Standalone
93*/
94
95/*
96 * NOR Flash ROM
97 *
98 * SW1 | SW2 | SW7 | NOR Flash ROM
99 * bit1 | bit1 bit2 | bit1 | Memory allocation
100 * ------+------------+------+------------------
101 * OFF | ON OFF | ON | Area 0
102 * OFF | ON OFF | OFF | Area 4
103 */
104
105/*
106 * SMSC 9220
107 *
108 * SW1 SMSC 9220
109 * -----------------------
110 * ON access disable
111 * OFF access enable
112 */
113
114/*
115 * NAND Flash ROM
116 *
117 * SW1 | SW2 | SW7 | NAND Flash ROM
118 * bit1 | bit1 bit2 | bit2 | Memory allocation
119 * ------+------------+------+------------------
120 * OFF | ON OFF | ON | FCE 0
121 * OFF | ON OFF | OFF | FCE 1
122 */
123
124/*
125 * External interrupt pin settings
126 *
127 * IRQX | pin setting | device | level
128 * ------+--------------------+--------------------+-------
129 * IRQ0 | ICR1A.IRQ0SA=0010 | SDHI2 card detect | Low
130 * IRQ6 | ICR1A.IRQ6SA=0011 | Ether(LAN9220) | High
Magnus Damme2a53b72011-06-09 07:03:37 +0000131 * IRQ7 | ICR1A.IRQ7SA=0010 | LCD Touch Panel | Low
Kuninori Morimoto4b82b682010-11-29 02:21:48 +0000132 * IRQ8 | ICR2A.IRQ8SA=0010 | MMC/SD card detect | Low
133 * IRQ9 | ICR2A.IRQ9SA=0010 | KEY(TCA6408) | Low
134 * IRQ21 | ICR4A.IRQ21SA=0011 | Sensor(ADXL345) | High
135 * IRQ22 | ICR4A.IRQ22SA=0011 | Sensor(AK8975) | High
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000136 */
Kuninori Morimoto4b82b682010-11-29 02:21:48 +0000137
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000138/*
139 * USB
140 *
141 * USB0 : CN22 : Function
142 * USB1 : CN31 : Function/Host *1
143 *
144 * J30 (for CN31) *1
145 * ----------+---------------+-------------
146 * 1-2 short | VBUS 5V | Host
147 * open | external VBUS | Function
148 *
149 * *1
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000150 * CN31 is used as
151 * CONFIG_USB_R8A66597_HCD Host
152 * CONFIG_USB_RENESAS_USBHS Function
153 *
154 * CAUTION
155 *
156 * renesas_usbhs driver can use external interrupt mode
157 * (which come from USB-PHY) or autonomy mode (it use own interrupt)
158 * for detecting connection/disconnection when Function.
159 * USB will be power OFF while it has been disconnecting
160 * if external interrupt mode, and it is always power ON if autonomy mode,
161 *
162 * mackerel can not use external interrupt (IRQ7-PORT167) mode on "USB0",
163 * because Touchscreen is using IRQ7-PORT40.
164 * It is impossible to use IRQ7 demux on this board.
165 *
166 * We can use external interrupt mode USB-Function on "USB1".
167 * USB1 can become Host by r8a66597, and become Function by renesas_usbhs.
168 * But don't select both drivers in same time.
169 * These uses same IRQ number for request_irq(), and aren't supporting
Magnus Damme2a53b72011-06-09 07:03:37 +0000170 * IRQF_SHARED / IORESOURCE_IRQ_SHAREABLE.
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000171 *
172 * Actually these are old/new version of USB driver.
Magnus Damme2a53b72011-06-09 07:03:37 +0000173 * This mean its register will be broken if it supports shared IRQ,
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000174 */
Kuninori Morimoto4b82b682010-11-29 02:21:48 +0000175
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000176/*
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900177 * SDHI0 (CN12)
178 *
179 * SW56 : OFF
180 *
181 */
182
183/* MMC /SDHI1 (CN7)
184 *
185 * I/O voltage : 1.8v
186 *
187 * Power voltage : 1.8v or 3.3v
Yusuke Goda41491b92010-12-15 08:31:04 +0000188 * J22 : select power voltage *1
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900189 * 1-2 pin : 1.8v
190 * 2-3 pin : 3.3v
191 *
Yusuke Goda41491b92010-12-15 08:31:04 +0000192 * *1
193 * Please change J22 depends the card to be used.
194 * MMC's OCR field set to support either voltage for the card inserted.
195 *
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900196 * SW1 | SW33
197 * | bit1 | bit2 | bit3 | bit4
198 * -------------+------+------+------+-------
Simon Horman2150dac2011-01-07 22:26:15 +0000199 * MMC0 OFF | OFF | X | ON | X (Use MMCIF)
200 * SDHI1 OFF | ON | X | OFF | X (Use MFD_SH_MOBILE_SDHI)
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900201 *
202 */
203
204/*
205 * SDHI2 (CN23)
206 *
207 * microSD card sloct
208 *
209 */
210
211/*
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000212 * FIXME !!
213 *
214 * gpio_no_direction
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000215 * gpio_pull_down
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000216 * are quick_hack.
217 *
218 * current gpio frame work doesn't have
219 * the method to control only pull up/down/free.
220 * this function should be replaced by correct gpio function
221 */
222static void __init gpio_no_direction(u32 addr)
223{
224 __raw_writeb(0x00, addr);
225}
226
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000227static void __init gpio_pull_down(u32 addr)
228{
229 u8 data = __raw_readb(addr);
230
231 data &= 0x0F;
232 data |= 0xA0;
233
234 __raw_writeb(data, addr);
235}
236
Kuninori Morimoto920adc72010-11-29 02:21:21 +0000237/* MTD */
238static struct mtd_partition nor_flash_partitions[] = {
239 {
240 .name = "loader",
241 .offset = 0x00000000,
242 .size = 512 * 1024,
243 .mask_flags = MTD_WRITEABLE,
244 },
245 {
246 .name = "bootenv",
247 .offset = MTDPART_OFS_APPEND,
248 .size = 512 * 1024,
249 .mask_flags = MTD_WRITEABLE,
250 },
251 {
252 .name = "kernel_ro",
253 .offset = MTDPART_OFS_APPEND,
254 .size = 8 * 1024 * 1024,
255 .mask_flags = MTD_WRITEABLE,
256 },
257 {
258 .name = "kernel",
259 .offset = MTDPART_OFS_APPEND,
260 .size = 8 * 1024 * 1024,
261 },
262 {
263 .name = "data",
264 .offset = MTDPART_OFS_APPEND,
265 .size = MTDPART_SIZ_FULL,
266 },
267};
268
269static struct physmap_flash_data nor_flash_data = {
270 .width = 2,
271 .parts = nor_flash_partitions,
272 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
273};
274
275static struct resource nor_flash_resources[] = {
276 [0] = {
Magnus Damm487881c2011-09-27 18:29:31 +0900277 .start = 0x20000000, /* CS0 shadow instead of regular CS0 */
278 .end = 0x28000000 - 1, /* needed by USB MASK ROM boot */
Kuninori Morimoto920adc72010-11-29 02:21:21 +0000279 .flags = IORESOURCE_MEM,
280 }
281};
282
283static struct platform_device nor_flash_device = {
284 .name = "physmap-flash",
285 .dev = {
286 .platform_data = &nor_flash_data,
287 },
288 .num_resources = ARRAY_SIZE(nor_flash_resources),
289 .resource = nor_flash_resources,
290};
291
Kuninori Morimoto2264c152010-11-29 02:21:37 +0000292/* SMSC */
293static struct resource smc911x_resources[] = {
294 {
295 .start = 0x14000000,
296 .end = 0x16000000 - 1,
297 .flags = IORESOURCE_MEM,
298 }, {
299 .start = evt2irq(0x02c0) /* IRQ6A */,
300 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
301 },
302};
303
304static struct smsc911x_platform_config smsc911x_info = {
305 .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
306 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
307 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
308};
309
310static struct platform_device smc911x_device = {
311 .name = "smsc911x",
312 .id = -1,
313 .num_resources = ARRAY_SIZE(smc911x_resources),
314 .resource = smc911x_resources,
315 .dev = {
316 .platform_data = &smsc911x_info,
317 },
318};
319
Damian1c7fcbe2011-05-24 07:01:22 +0000320/* MERAM */
321static struct sh_mobile_meram_info mackerel_meram_info = {
322 .addr_mode = SH_MOBILE_MERAM_MODE1,
323};
324
325static struct resource meram_resources[] = {
326 [0] = {
327 .name = "MERAM",
328 .start = 0xe8000000,
329 .end = 0xe81fffff,
330 .flags = IORESOURCE_MEM,
331 },
332};
333
334static struct platform_device meram_device = {
335 .name = "sh_mobile_meram",
336 .id = 0,
337 .num_resources = ARRAY_SIZE(meram_resources),
338 .resource = meram_resources,
339 .dev = {
340 .platform_data = &mackerel_meram_info,
341 },
342};
343
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000344/* LCDC */
345static struct fb_videomode mackerel_lcdc_modes[] = {
346 {
347 .name = "WVGA Panel",
348 .xres = 800,
349 .yres = 480,
350 .left_margin = 220,
351 .right_margin = 110,
352 .hsync_len = 70,
353 .upper_margin = 20,
354 .lower_margin = 5,
355 .vsync_len = 5,
356 .sync = 0,
357 },
358};
359
Magnus Damm1fbdfcd2011-03-21 07:49:45 +0000360static int mackerel_set_brightness(void *board_data, int brightness)
361{
362 gpio_set_value(GPIO_PORT31, brightness);
363
364 return 0;
365}
366
367static int mackerel_get_brightness(void *board_data)
368{
369 return gpio_get_value(GPIO_PORT31);
370}
371
Damian1c7fcbe2011-05-24 07:01:22 +0000372static struct sh_mobile_meram_cfg lcd_meram_cfg = {
373 .icb[0] = {
374 .marker_icb = 28,
375 .cache_icb = 24,
376 .meram_offset = 0x0,
377 .meram_size = 0x40,
378 },
379 .icb[1] = {
380 .marker_icb = 29,
381 .cache_icb = 25,
382 .meram_offset = 0x40,
383 .meram_size = 0x40,
384 },
385};
386
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000387static struct sh_mobile_lcdc_info lcdc_info = {
Damian1c7fcbe2011-05-24 07:01:22 +0000388 .meram_dev = &mackerel_meram_info,
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000389 .clock_source = LCDC_CLK_BUS,
390 .ch[0] = {
391 .chan = LCDC_CHAN_MAINLCD,
Laurent Pinchartedd153a2011-12-13 14:02:28 +0100392 .fourcc = V4L2_PIX_FMT_RGB565,
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000393 .lcd_cfg = mackerel_lcdc_modes,
394 .num_cfg = ARRAY_SIZE(mackerel_lcdc_modes),
395 .interface_type = RGB24,
Kuninori Morimoto2c34e932011-03-02 09:05:21 +0000396 .clock_divider = 3,
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000397 .flags = 0,
398 .lcd_size_cfg.width = 152,
399 .lcd_size_cfg.height = 91,
Magnus Damm1fbdfcd2011-03-21 07:49:45 +0000400 .board_cfg = {
401 .set_brightness = mackerel_set_brightness,
402 .get_brightness = mackerel_get_brightness,
403 },
404 .bl_info = {
405 .name = "sh_mobile_lcdc_bl",
406 .max_brightness = 1,
407 },
Damian1c7fcbe2011-05-24 07:01:22 +0000408 .meram_cfg = &lcd_meram_cfg,
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000409 }
410};
411
412static struct resource lcdc_resources[] = {
413 [0] = {
414 .name = "LCDC",
415 .start = 0xfe940000,
416 .end = 0xfe943fff,
417 .flags = IORESOURCE_MEM,
418 },
419 [1] = {
420 .start = intcs_evt2irq(0x580),
421 .flags = IORESOURCE_IRQ,
422 },
423};
424
425static struct platform_device lcdc_device = {
426 .name = "sh_mobile_lcdc_fb",
427 .num_resources = ARRAY_SIZE(lcdc_resources),
428 .resource = lcdc_resources,
429 .dev = {
430 .platform_data = &lcdc_info,
431 .coherent_dma_mask = ~0,
432 },
433};
434
Damian1c7fcbe2011-05-24 07:01:22 +0000435static struct sh_mobile_meram_cfg hdmi_meram_cfg = {
436 .icb[0] = {
437 .marker_icb = 30,
438 .cache_icb = 26,
439 .meram_offset = 0x80,
440 .meram_size = 0x100,
441 },
442 .icb[1] = {
443 .marker_icb = 31,
444 .cache_icb = 27,
445 .meram_offset = 0x180,
446 .meram_size = 0x100,
447 },
448};
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000449/* HDMI */
450static struct sh_mobile_lcdc_info hdmi_lcdc_info = {
Damian1c7fcbe2011-05-24 07:01:22 +0000451 .meram_dev = &mackerel_meram_info,
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000452 .clock_source = LCDC_CLK_EXTERNAL,
453 .ch[0] = {
454 .chan = LCDC_CHAN_MAINLCD,
Laurent Pinchartedd153a2011-12-13 14:02:28 +0100455 .fourcc = V4L2_PIX_FMT_RGB565,
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000456 .interface_type = RGB24,
457 .clock_divider = 1,
458 .flags = LCDC_FLAGS_DWPOL,
Damian1c7fcbe2011-05-24 07:01:22 +0000459 .meram_cfg = &hdmi_meram_cfg,
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000460 }
461};
462
463static struct resource hdmi_lcdc_resources[] = {
464 [0] = {
465 .name = "LCDC1",
466 .start = 0xfe944000,
467 .end = 0xfe947fff,
468 .flags = IORESOURCE_MEM,
469 },
470 [1] = {
471 .start = intcs_evt2irq(0x1780),
472 .flags = IORESOURCE_IRQ,
473 },
474};
475
476static struct platform_device hdmi_lcdc_device = {
477 .name = "sh_mobile_lcdc_fb",
478 .num_resources = ARRAY_SIZE(hdmi_lcdc_resources),
479 .resource = hdmi_lcdc_resources,
480 .id = 1,
481 .dev = {
482 .platform_data = &hdmi_lcdc_info,
483 .coherent_dma_mask = ~0,
484 },
485};
486
487static struct sh_mobile_hdmi_info hdmi_info = {
488 .lcd_chan = &hdmi_lcdc_info.ch[0],
489 .lcd_dev = &hdmi_lcdc_device.dev,
Kuninori Morimoto98d27b82011-01-06 02:44:15 +0000490 .flags = HDMI_SND_SRC_SPDIF,
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000491};
492
493static struct resource hdmi_resources[] = {
494 [0] = {
495 .name = "HDMI",
496 .start = 0xe6be0000,
497 .end = 0xe6be00ff,
498 .flags = IORESOURCE_MEM,
499 },
500 [1] = {
501 /* There's also an HDMI interrupt on INTCS @ 0x18e0 */
502 .start = evt2irq(0x17e0),
503 .flags = IORESOURCE_IRQ,
504 },
505};
506
507static struct platform_device hdmi_device = {
508 .name = "sh-mobile-hdmi",
509 .num_resources = ARRAY_SIZE(hdmi_resources),
510 .resource = hdmi_resources,
511 .id = -1,
512 .dev = {
513 .platform_data = &hdmi_info,
514 },
515};
516
Kuninori Morimoto3f25c9c2011-01-24 10:09:02 +0900517static struct platform_device fsi_hdmi_device = {
518 .name = "sh_fsi2_b_hdmi",
519};
520
Guennadi Liakhovetski2ce51f82011-04-04 17:08:05 +0200521static void __init hdmi_init_pm_clock(void)
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000522{
523 struct clk *hdmi_ick = clk_get(&hdmi_device.dev, "ick");
524 int ret;
525 long rate;
526
527 if (IS_ERR(hdmi_ick)) {
528 ret = PTR_ERR(hdmi_ick);
529 pr_err("Cannot get HDMI ICK: %d\n", ret);
530 goto out;
531 }
532
533 ret = clk_set_parent(&sh7372_pllc2_clk, &sh7372_dv_clki_div2_clk);
534 if (ret < 0) {
535 pr_err("Cannot set PLLC2 parent: %d, %d users\n",
536 ret, sh7372_pllc2_clk.usecount);
537 goto out;
538 }
539
540 pr_debug("PLLC2 initial frequency %lu\n",
541 clk_get_rate(&sh7372_pllc2_clk));
542
543 rate = clk_round_rate(&sh7372_pllc2_clk, 594000000);
544 if (rate < 0) {
545 pr_err("Cannot get suitable rate: %ld\n", rate);
546 ret = rate;
547 goto out;
548 }
549
550 ret = clk_set_rate(&sh7372_pllc2_clk, rate);
551 if (ret < 0) {
552 pr_err("Cannot set rate %ld: %d\n", rate, ret);
553 goto out;
554 }
555
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000556 pr_debug("PLLC2 set frequency %lu\n", rate);
557
558 ret = clk_set_parent(hdmi_ick, &sh7372_pllc2_clk);
Guennadi Liakhovetski2ce51f82011-04-04 17:08:05 +0200559 if (ret < 0)
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000560 pr_err("Cannot set HDMI parent: %d\n", ret);
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000561
562out:
563 if (!IS_ERR(hdmi_ick))
564 clk_put(hdmi_ick);
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000565}
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000566
Magnus Damme2a53b72011-06-09 07:03:37 +0000567/* USBHS0 is connected to CN22 which takes a USB Mini-B plug
568 *
569 * The sh7372 SoC has IRQ7 set aside for USBHS0 hotplug,
570 * but on this particular board IRQ7 is already used by
571 * the touch screen. This leaves us with software polling.
572 */
573#define USBHS0_POLL_INTERVAL (HZ * 5)
574
575struct usbhs_private {
576 unsigned int usbphyaddr;
577 unsigned int usbcrcaddr;
578 struct renesas_usbhs_platform_info info;
579 struct delayed_work work;
580 struct platform_device *pdev;
581};
582
583#define usbhs_get_priv(pdev) \
584 container_of(renesas_usbhs_get_info(pdev), \
585 struct usbhs_private, info)
586
587#define usbhs_is_connected(priv) \
588 (!((1 << 7) & __raw_readw(priv->usbcrcaddr)))
589
590static int usbhs_get_vbus(struct platform_device *pdev)
591{
592 return usbhs_is_connected(usbhs_get_priv(pdev));
593}
594
595static void usbhs_phy_reset(struct platform_device *pdev)
596{
597 struct usbhs_private *priv = usbhs_get_priv(pdev);
598
599 /* init phy */
600 __raw_writew(0x8a0a, priv->usbcrcaddr);
601}
602
603static int usbhs0_get_id(struct platform_device *pdev)
604{
605 return USBHS_GADGET;
606}
607
608static void usbhs0_work_function(struct work_struct *work)
609{
610 struct usbhs_private *priv = container_of(work, struct usbhs_private,
611 work.work);
612
613 renesas_usbhs_call_notify_hotplug(priv->pdev);
614 schedule_delayed_work(&priv->work, USBHS0_POLL_INTERVAL);
615}
616
617static int usbhs0_hardware_init(struct platform_device *pdev)
618{
619 struct usbhs_private *priv = usbhs_get_priv(pdev);
620
621 priv->pdev = pdev;
622 INIT_DELAYED_WORK(&priv->work, usbhs0_work_function);
623 schedule_delayed_work(&priv->work, USBHS0_POLL_INTERVAL);
624 return 0;
625}
626
627static void usbhs0_hardware_exit(struct platform_device *pdev)
628{
629 struct usbhs_private *priv = usbhs_get_priv(pdev);
630
631 cancel_delayed_work_sync(&priv->work);
632}
633
Magnus Damme2a53b72011-06-09 07:03:37 +0000634static struct usbhs_private usbhs0_private = {
635 .usbcrcaddr = 0xe605810c, /* USBCR2 */
636 .info = {
637 .platform_callback = {
638 .hardware_init = usbhs0_hardware_init,
639 .hardware_exit = usbhs0_hardware_exit,
640 .phy_reset = usbhs_phy_reset,
641 .get_id = usbhs0_get_id,
642 .get_vbus = usbhs_get_vbus,
643 },
644 .driver_param = {
645 .buswait_bwait = 4,
Kuninori Morimotofe437562011-06-17 08:21:21 +0000646 .d0_tx_id = SHDMA_SLAVE_USB0_TX,
647 .d1_rx_id = SHDMA_SLAVE_USB0_RX,
Magnus Damme2a53b72011-06-09 07:03:37 +0000648 },
649 },
650};
651
652static struct resource usbhs0_resources[] = {
653 [0] = {
654 .name = "USBHS0",
655 .start = 0xe6890000,
656 .end = 0xe68900e6 - 1,
657 .flags = IORESOURCE_MEM,
658 },
659 [1] = {
660 .start = evt2irq(0x1ca0) /* USB0_USB0I0 */,
661 .flags = IORESOURCE_IRQ,
662 },
663};
664
665static struct platform_device usbhs0_device = {
666 .name = "renesas_usbhs",
667 .id = 0,
668 .dev = {
669 .platform_data = &usbhs0_private.info,
670 },
671 .num_resources = ARRAY_SIZE(usbhs0_resources),
672 .resource = usbhs0_resources,
673};
674
675/* USBHS1 is connected to CN31 which takes a USB Mini-AB plug
676 *
677 * Use J30 to select between Host and Function. This setting
678 * can however not be detected by software. Hotplug of USBHS1
679 * is provided via IRQ8.
680 */
681#define IRQ8 evt2irq(0x0300)
682
683/* USBHS1 USB Host support via r8a66597_hcd */
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000684static void usb1_host_port_power(int port, int power)
685{
686 if (!power) /* only power-on is supported for now */
687 return;
688
689 /* set VBOUT/PWEN and EXTLP1 in DVSTCTR */
690 __raw_writew(__raw_readw(0xE68B0008) | 0x600, 0xE68B0008);
691}
692
693static struct r8a66597_platdata usb1_host_data = {
694 .on_chip = 1,
695 .port_power = usb1_host_port_power,
696};
697
698static struct resource usb1_host_resources[] = {
699 [0] = {
Magnus Damme2a53b72011-06-09 07:03:37 +0000700 .name = "USBHS1",
701 .start = 0xe68b0000,
702 .end = 0xe68b00e6 - 1,
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000703 .flags = IORESOURCE_MEM,
704 },
705 [1] = {
706 .start = evt2irq(0x1ce0) /* USB1_USB1I0 */,
707 .flags = IORESOURCE_IRQ,
708 },
709};
710
711static struct platform_device usb1_host_device = {
712 .name = "r8a66597_hcd",
713 .id = 1,
714 .dev = {
715 .dma_mask = NULL, /* not use dma */
716 .coherent_dma_mask = 0xffffffff,
717 .platform_data = &usb1_host_data,
718 },
719 .num_resources = ARRAY_SIZE(usb1_host_resources),
720 .resource = usb1_host_resources,
721};
722
Magnus Damme2a53b72011-06-09 07:03:37 +0000723/* USBHS1 USB Function support via renesas_usbhs */
724
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000725#define USB_PHY_MODE (1 << 4)
726#define USB_PHY_INT_EN ((1 << 3) | (1 << 2))
727#define USB_PHY_ON (1 << 1)
728#define USB_PHY_OFF (1 << 0)
729#define USB_PHY_INT_CLR (USB_PHY_ON | USB_PHY_OFF)
730
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000731static irqreturn_t usbhs1_interrupt(int irq, void *data)
732{
733 struct platform_device *pdev = data;
734 struct usbhs_private *priv = usbhs_get_priv(pdev);
735
736 dev_dbg(&pdev->dev, "%s\n", __func__);
737
738 renesas_usbhs_call_notify_hotplug(pdev);
739
740 /* clear status */
741 __raw_writew(__raw_readw(priv->usbphyaddr) | USB_PHY_INT_CLR,
742 priv->usbphyaddr);
743
744 return IRQ_HANDLED;
745}
746
747static int usbhs1_hardware_init(struct platform_device *pdev)
748{
749 struct usbhs_private *priv = usbhs_get_priv(pdev);
750 int ret;
751
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000752 /* clear interrupt status */
753 __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->usbphyaddr);
754
Magnus Damme2a53b72011-06-09 07:03:37 +0000755 ret = request_irq(IRQ8, usbhs1_interrupt, IRQF_TRIGGER_HIGH,
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000756 dev_name(&pdev->dev), pdev);
757 if (ret) {
758 dev_err(&pdev->dev, "request_irq err\n");
759 return ret;
760 }
761
762 /* enable USB phy interrupt */
763 __raw_writew(USB_PHY_MODE | USB_PHY_INT_EN, priv->usbphyaddr);
764
765 return 0;
766}
767
768static void usbhs1_hardware_exit(struct platform_device *pdev)
769{
770 struct usbhs_private *priv = usbhs_get_priv(pdev);
771
772 /* clear interrupt status */
773 __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->usbphyaddr);
774
Magnus Damme2a53b72011-06-09 07:03:37 +0000775 free_irq(IRQ8, pdev);
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000776}
777
Kuninori Morimoto05a79292011-06-15 06:16:35 +0000778static int usbhs1_get_id(struct platform_device *pdev)
779{
780 return USBHS_GADGET;
781}
782
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000783static u32 usbhs1_pipe_cfg[] = {
784 USB_ENDPOINT_XFER_CONTROL,
785 USB_ENDPOINT_XFER_ISOC,
786 USB_ENDPOINT_XFER_ISOC,
787 USB_ENDPOINT_XFER_BULK,
788 USB_ENDPOINT_XFER_BULK,
789 USB_ENDPOINT_XFER_BULK,
790 USB_ENDPOINT_XFER_INT,
791 USB_ENDPOINT_XFER_INT,
792 USB_ENDPOINT_XFER_INT,
793 USB_ENDPOINT_XFER_BULK,
794 USB_ENDPOINT_XFER_BULK,
795 USB_ENDPOINT_XFER_BULK,
796 USB_ENDPOINT_XFER_BULK,
797 USB_ENDPOINT_XFER_BULK,
798 USB_ENDPOINT_XFER_BULK,
799 USB_ENDPOINT_XFER_BULK,
800};
801
802static struct usbhs_private usbhs1_private = {
Magnus Damme2a53b72011-06-09 07:03:37 +0000803 .usbphyaddr = 0xe60581e2, /* USBPHY1INTAP */
804 .usbcrcaddr = 0xe6058130, /* USBCR4 */
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000805 .info = {
806 .platform_callback = {
807 .hardware_init = usbhs1_hardware_init,
808 .hardware_exit = usbhs1_hardware_exit,
Kuninori Morimoto05a79292011-06-15 06:16:35 +0000809 .get_id = usbhs1_get_id,
Magnus Damme2a53b72011-06-09 07:03:37 +0000810 .phy_reset = usbhs_phy_reset,
811 .get_vbus = usbhs_get_vbus,
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000812 },
813 .driver_param = {
814 .buswait_bwait = 4,
Kuninori Morimotof427eb62011-10-10 22:06:12 -0700815 .has_otg = 1,
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000816 .pipe_type = usbhs1_pipe_cfg,
817 .pipe_size = ARRAY_SIZE(usbhs1_pipe_cfg),
Kuninori Morimotofe437562011-06-17 08:21:21 +0000818 .d0_tx_id = SHDMA_SLAVE_USB1_TX,
819 .d1_rx_id = SHDMA_SLAVE_USB1_RX,
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000820 },
821 },
822};
823
824static struct resource usbhs1_resources[] = {
825 [0] = {
Magnus Damme2a53b72011-06-09 07:03:37 +0000826 .name = "USBHS1",
827 .start = 0xe68b0000,
828 .end = 0xe68b00e6 - 1,
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000829 .flags = IORESOURCE_MEM,
830 },
831 [1] = {
832 .start = evt2irq(0x1ce0) /* USB1_USB1I0 */,
833 .flags = IORESOURCE_IRQ,
834 },
835};
836
837static struct platform_device usbhs1_device = {
838 .name = "renesas_usbhs",
839 .id = 1,
840 .dev = {
841 .platform_data = &usbhs1_private.info,
842 },
843 .num_resources = ARRAY_SIZE(usbhs1_resources),
844 .resource = usbhs1_resources,
845};
846
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000847/* LED */
848static struct gpio_led mackerel_leds[] = {
849 {
850 .name = "led0",
851 .gpio = GPIO_PORT0,
852 .default_state = LEDS_GPIO_DEFSTATE_ON,
853 },
854 {
855 .name = "led1",
856 .gpio = GPIO_PORT1,
857 .default_state = LEDS_GPIO_DEFSTATE_ON,
858 },
859 {
860 .name = "led2",
861 .gpio = GPIO_PORT2,
862 .default_state = LEDS_GPIO_DEFSTATE_ON,
863 },
864 {
865 .name = "led3",
866 .gpio = GPIO_PORT159,
867 .default_state = LEDS_GPIO_DEFSTATE_ON,
868 }
869};
870
871static struct gpio_led_platform_data mackerel_leds_pdata = {
872 .leds = mackerel_leds,
873 .num_leds = ARRAY_SIZE(mackerel_leds),
874};
875
876static struct platform_device leds_device = {
877 .name = "leds-gpio",
878 .id = 0,
879 .dev = {
880 .platform_data = &mackerel_leds_pdata,
881 },
882};
883
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000884/* FSI */
885#define IRQ_FSI evt2irq(0x1840)
Kuninori Morimoto98d27b82011-01-06 02:44:15 +0000886static int __fsi_set_round_rate(struct clk *clk, long rate, int enable)
887{
888 int ret;
889
890 if (rate <= 0)
891 return 0;
892
893 if (!enable) {
894 clk_disable(clk);
895 return 0;
896 }
897
898 ret = clk_set_rate(clk, clk_round_rate(clk, rate));
899 if (ret < 0)
900 return ret;
901
902 return clk_enable(clk);
903}
904
905static int fsi_set_rate(struct device *dev, int is_porta, int rate, int enable)
906{
907 struct clk *fsib_clk;
908 struct clk *fdiv_clk = &sh7372_fsidivb_clk;
909 long fsib_rate = 0;
910 long fdiv_rate = 0;
911 int ackmd_bpfmd;
912 int ret;
913
914 /* FSIA is slave mode. nothing to do here */
915 if (is_porta)
916 return 0;
917
918 /* clock start */
919 switch (rate) {
920 case 44100:
921 fsib_rate = rate * 256;
922 ackmd_bpfmd = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
923 break;
924 case 48000:
925 fsib_rate = 85428000; /* around 48kHz x 256 x 7 */
926 fdiv_rate = rate * 256;
927 ackmd_bpfmd = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
928 break;
929 default:
930 pr_err("unsupported rate in FSI2 port B\n");
931 return -EINVAL;
932 }
933
934 /* FSI B setting */
935 fsib_clk = clk_get(dev, "ickb");
936 if (IS_ERR(fsib_clk))
937 return -EIO;
938
939 /* fsib */
940 ret = __fsi_set_round_rate(fsib_clk, fsib_rate, enable);
941 if (ret < 0)
942 goto fsi_set_rate_end;
943
944 /* FSI DIV */
945 ret = __fsi_set_round_rate(fdiv_clk, fdiv_rate, enable);
946 if (ret < 0) {
947 /* disable FSI B */
948 if (enable)
949 __fsi_set_round_rate(fsib_clk, fsib_rate, 0);
950 goto fsi_set_rate_end;
951 }
952
953 ret = ackmd_bpfmd;
954
955fsi_set_rate_end:
956 clk_put(fsib_clk);
957 return ret;
958}
959
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000960static struct sh_fsi_platform_info fsi_info = {
Kuninori Morimotof17c13c2011-01-24 10:43:19 +0900961 .porta_flags = SH_FSI_BRS_INV,
Kuninori Morimoto98d27b82011-01-06 02:44:15 +0000962
963 .portb_flags = SH_FSI_BRS_INV |
964 SH_FSI_BRM_INV |
965 SH_FSI_LRS_INV |
Kuninori Morimotof17c13c2011-01-24 10:43:19 +0900966 SH_FSI_FMT_SPDIF,
Kuninori Morimoto98d27b82011-01-06 02:44:15 +0000967
968 .set_rate = fsi_set_rate,
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000969};
970
971static struct resource fsi_resources[] = {
972 [0] = {
973 .name = "FSI",
974 .start = 0xFE3C0000,
975 .end = 0xFE3C0400 - 1,
976 .flags = IORESOURCE_MEM,
977 },
978 [1] = {
979 .start = IRQ_FSI,
980 .flags = IORESOURCE_IRQ,
981 },
982};
983
984static struct platform_device fsi_device = {
985 .name = "sh_fsi2",
986 .id = -1,
987 .num_resources = ARRAY_SIZE(fsi_resources),
988 .resource = fsi_resources,
989 .dev = {
990 .platform_data = &fsi_info,
991 },
992};
993
Kuninori Morimoto45f31212011-11-23 16:55:34 -0800994static struct fsi_ak4642_info fsi2_ak4643_info = {
995 .name = "AK4643",
996 .card = "FSI2A-AK4643",
997 .cpu_dai = "fsia-dai",
998 .codec = "ak4642-codec.0-0013",
999 .platform = "sh_fsi2",
1000 .id = FSI_PORT_A,
1001};
1002
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001003static struct platform_device fsi_ak4643_device = {
Kuninori Morimoto45f31212011-11-23 16:55:34 -08001004 .name = "fsi-ak4642-audio",
1005 .dev = {
1006 .platform_data = &fsi2_ak4643_info,
1007 },
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001008};
Kuninori Morimotod44deb32010-11-30 06:52:18 +00001009
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001010/*
1011 * The card detect pin of the top SD/MMC slot (CN7) is active low and is
1012 * connected to GPIO A22 of SH7372 (GPIO_PORT41).
1013 */
1014static int slot_cn7_get_cd(struct platform_device *pdev)
1015{
Magnus Dammceb50f32011-01-12 10:43:07 +00001016 return !gpio_get_value(GPIO_PORT41);
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001017}
1018
1019/* SDHI0 */
Guennadi Liakhovetski4bff4a72011-05-11 16:51:20 +00001020static irqreturn_t mackerel_sdhi0_gpio_cd(int irq, void *arg)
1021{
1022 struct device *dev = arg;
1023 struct sh_mobile_sdhi_info *info = dev->platform_data;
1024 struct tmio_mmc_data *pdata = info->pdata;
1025
1026 tmio_mmc_cd_wakeup(pdata);
1027
1028 return IRQ_HANDLED;
1029}
1030
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001031static struct sh_mobile_sdhi_info sdhi0_info = {
1032 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
1033 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
Magnus Dammda97da72011-01-06 10:55:41 +00001034 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001035};
1036
1037static struct resource sdhi0_resources[] = {
1038 [0] = {
1039 .name = "SDHI0",
1040 .start = 0xe6850000,
Guennadi Liakhovetski31d31fe72011-03-09 13:09:27 +01001041 .end = 0xe68500ff,
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001042 .flags = IORESOURCE_MEM,
1043 },
1044 [1] = {
Simon Horman2007aea2011-04-27 07:43:58 +00001045 .start = evt2irq(0x0e00) /* SDHI0_SDHI0I0 */,
1046 .flags = IORESOURCE_IRQ,
1047 },
1048 [2] = {
1049 .start = evt2irq(0x0e20) /* SDHI0_SDHI0I1 */,
1050 .flags = IORESOURCE_IRQ,
1051 },
1052 [3] = {
1053 .start = evt2irq(0x0e40) /* SDHI0_SDHI0I2 */,
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001054 .flags = IORESOURCE_IRQ,
1055 },
1056};
1057
1058static struct platform_device sdhi0_device = {
1059 .name = "sh_mobile_sdhi",
1060 .num_resources = ARRAY_SIZE(sdhi0_resources),
1061 .resource = sdhi0_resources,
1062 .id = 0,
1063 .dev = {
1064 .platform_data = &sdhi0_info,
1065 },
1066};
1067
Guennadi Liakhovetski5bcd7512011-05-05 15:56:27 +00001068#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001069/* SDHI1 */
1070static struct sh_mobile_sdhi_info sdhi1_info = {
1071 .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
1072 .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
1073 .tmio_ocr_mask = MMC_VDD_165_195,
1074 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
Magnus Dammda97da72011-01-06 10:55:41 +00001075 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001076 MMC_CAP_NEEDS_POLL,
1077 .get_cd = slot_cn7_get_cd,
1078};
1079
1080static struct resource sdhi1_resources[] = {
1081 [0] = {
1082 .name = "SDHI1",
1083 .start = 0xe6860000,
Guennadi Liakhovetski31d31fe72011-03-09 13:09:27 +01001084 .end = 0xe68600ff,
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001085 .flags = IORESOURCE_MEM,
1086 },
1087 [1] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +09001088 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
Simon Horman2007aea2011-04-27 07:43:58 +00001089 .start = evt2irq(0x0e80), /* SDHI1_SDHI1I0 */
1090 .flags = IORESOURCE_IRQ,
1091 },
1092 [2] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +09001093 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
Simon Horman2007aea2011-04-27 07:43:58 +00001094 .start = evt2irq(0x0ea0), /* SDHI1_SDHI1I1 */
1095 .flags = IORESOURCE_IRQ,
1096 },
1097 [3] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +09001098 .name = SH_MOBILE_SDHI_IRQ_SDIO,
Simon Horman2007aea2011-04-27 07:43:58 +00001099 .start = evt2irq(0x0ec0), /* SDHI1_SDHI1I2 */
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001100 .flags = IORESOURCE_IRQ,
1101 },
1102};
1103
1104static struct platform_device sdhi1_device = {
1105 .name = "sh_mobile_sdhi",
1106 .num_resources = ARRAY_SIZE(sdhi1_resources),
1107 .resource = sdhi1_resources,
1108 .id = 1,
1109 .dev = {
1110 .platform_data = &sdhi1_info,
1111 },
1112};
Yusuke Goda41491b92010-12-15 08:31:04 +00001113#endif
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001114
Yusuke Godada5d1f42011-01-07 09:48:36 +00001115/*
1116 * The card detect pin of the top SD/MMC slot (CN23) is active low and is
1117 * connected to GPIO SCIFB_SCK of SH7372 (GPIO_PORT162).
1118 */
1119static int slot_cn23_get_cd(struct platform_device *pdev)
1120{
1121 return !gpio_get_value(GPIO_PORT162);
1122}
1123
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001124/* SDHI2 */
1125static struct sh_mobile_sdhi_info sdhi2_info = {
1126 .dma_slave_tx = SHDMA_SLAVE_SDHI2_TX,
1127 .dma_slave_rx = SHDMA_SLAVE_SDHI2_RX,
1128 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
Magnus Dammda97da72011-01-06 10:55:41 +00001129 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001130 MMC_CAP_NEEDS_POLL,
Yusuke Godada5d1f42011-01-07 09:48:36 +00001131 .get_cd = slot_cn23_get_cd,
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001132};
1133
1134static struct resource sdhi2_resources[] = {
1135 [0] = {
1136 .name = "SDHI2",
1137 .start = 0xe6870000,
Guennadi Liakhovetski31d31fe72011-03-09 13:09:27 +01001138 .end = 0xe68700ff,
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001139 .flags = IORESOURCE_MEM,
1140 },
1141 [1] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +09001142 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
Simon Horman2007aea2011-04-27 07:43:58 +00001143 .start = evt2irq(0x1200), /* SDHI2_SDHI2I0 */
1144 .flags = IORESOURCE_IRQ,
1145 },
1146 [2] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +09001147 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
Simon Horman2007aea2011-04-27 07:43:58 +00001148 .start = evt2irq(0x1220), /* SDHI2_SDHI2I1 */
1149 .flags = IORESOURCE_IRQ,
1150 },
1151 [3] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +09001152 .name = SH_MOBILE_SDHI_IRQ_SDIO,
Simon Horman2007aea2011-04-27 07:43:58 +00001153 .start = evt2irq(0x1240), /* SDHI2_SDHI2I2 */
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001154 .flags = IORESOURCE_IRQ,
1155 },
1156};
1157
1158static struct platform_device sdhi2_device = {
1159 .name = "sh_mobile_sdhi",
1160 .num_resources = ARRAY_SIZE(sdhi2_resources),
1161 .resource = sdhi2_resources,
1162 .id = 2,
1163 .dev = {
1164 .platform_data = &sdhi2_info,
1165 },
1166};
1167
Yusuke Goda41491b92010-12-15 08:31:04 +00001168/* SH_MMCIF */
1169static struct resource sh_mmcif_resources[] = {
1170 [0] = {
1171 .name = "MMCIF",
1172 .start = 0xE6BD0000,
1173 .end = 0xE6BD00FF,
1174 .flags = IORESOURCE_MEM,
1175 },
1176 [1] = {
1177 /* MMC ERR */
1178 .start = evt2irq(0x1ac0),
1179 .flags = IORESOURCE_IRQ,
1180 },
1181 [2] = {
1182 /* MMC NOR */
1183 .start = evt2irq(0x1ae0),
1184 .flags = IORESOURCE_IRQ,
1185 },
1186};
1187
Guennadi Liakhovetskife78e682011-05-05 15:56:31 +00001188static struct sh_mmcif_dma sh_mmcif_dma = {
1189 .chan_priv_rx = {
1190 .slave_id = SHDMA_SLAVE_MMCIF_RX,
1191 },
1192 .chan_priv_tx = {
1193 .slave_id = SHDMA_SLAVE_MMCIF_TX,
1194 },
1195};
1196
Yusuke Goda41491b92010-12-15 08:31:04 +00001197static struct sh_mmcif_plat_data sh_mmcif_plat = {
1198 .sup_pclk = 0,
1199 .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
1200 .caps = MMC_CAP_4_BIT_DATA |
1201 MMC_CAP_8_BIT_DATA |
1202 MMC_CAP_NEEDS_POLL,
1203 .get_cd = slot_cn7_get_cd,
Guennadi Liakhovetskife78e682011-05-05 15:56:31 +00001204 .dma = &sh_mmcif_dma,
Yusuke Goda41491b92010-12-15 08:31:04 +00001205};
1206
1207static struct platform_device sh_mmcif_device = {
1208 .name = "sh_mmcif",
1209 .id = 0,
1210 .dev = {
1211 .dma_mask = NULL,
1212 .coherent_dma_mask = 0xffffffff,
1213 .platform_data = &sh_mmcif_plat,
1214 },
1215 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
1216 .resource = sh_mmcif_resources,
1217};
1218
Magnus Dammae37c8d2010-12-22 14:47:40 +00001219
Guennadi Liakhovetski7dfff952011-07-15 20:03:38 -03001220static int mackerel_camera_add(struct soc_camera_device *icd);
1221static void mackerel_camera_del(struct soc_camera_device *icd);
Magnus Dammae37c8d2010-12-22 14:47:40 +00001222
1223static int camera_set_capture(struct soc_camera_platform_info *info,
1224 int enable)
1225{
1226 return 0; /* camera sensor always enabled */
1227}
1228
1229static struct soc_camera_platform_info camera_info = {
1230 .format_name = "UYVY",
1231 .format_depth = 16,
1232 .format = {
1233 .code = V4L2_MBUS_FMT_UYVY8_2X8,
1234 .colorspace = V4L2_COLORSPACE_SMPTE170M,
1235 .field = V4L2_FIELD_NONE,
1236 .width = 640,
1237 .height = 480,
1238 },
Guennadi Liakhovetskid1e87ed2011-07-27 10:48:40 -03001239 .mbus_param = V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_MASTER |
1240 V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_HSYNC_ACTIVE_HIGH |
1241 V4L2_MBUS_DATA_ACTIVE_HIGH,
1242 .mbus_type = V4L2_MBUS_PARALLEL,
Magnus Dammae37c8d2010-12-22 14:47:40 +00001243 .set_capture = camera_set_capture,
1244};
1245
1246static struct soc_camera_link camera_link = {
1247 .bus_id = 0,
1248 .add_device = mackerel_camera_add,
1249 .del_device = mackerel_camera_del,
1250 .module_name = "soc_camera_platform",
1251 .priv = &camera_info,
1252};
1253
Guennadi Liakhovetski86a73142011-02-22 09:57:49 +00001254static struct platform_device *camera_device;
Magnus Dammae37c8d2010-12-22 14:47:40 +00001255
Guennadi Liakhovetski86a73142011-02-22 09:57:49 +00001256static void mackerel_camera_release(struct device *dev)
1257{
1258 soc_camera_platform_release(&camera_device);
1259}
Magnus Dammae37c8d2010-12-22 14:47:40 +00001260
Guennadi Liakhovetski7dfff952011-07-15 20:03:38 -03001261static int mackerel_camera_add(struct soc_camera_device *icd)
Magnus Dammae37c8d2010-12-22 14:47:40 +00001262{
Guennadi Liakhovetski7dfff952011-07-15 20:03:38 -03001263 return soc_camera_platform_add(icd, &camera_device, &camera_link,
Guennadi Liakhovetski86a73142011-02-22 09:57:49 +00001264 mackerel_camera_release, 0);
Magnus Dammae37c8d2010-12-22 14:47:40 +00001265}
1266
Guennadi Liakhovetski7dfff952011-07-15 20:03:38 -03001267static void mackerel_camera_del(struct soc_camera_device *icd)
Magnus Dammae37c8d2010-12-22 14:47:40 +00001268{
Guennadi Liakhovetski7dfff952011-07-15 20:03:38 -03001269 soc_camera_platform_del(icd, camera_device, &camera_link);
Magnus Dammae37c8d2010-12-22 14:47:40 +00001270}
1271
1272static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
1273 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
1274};
1275
1276static struct resource ceu_resources[] = {
1277 [0] = {
1278 .name = "CEU",
1279 .start = 0xfe910000,
1280 .end = 0xfe91009f,
1281 .flags = IORESOURCE_MEM,
1282 },
1283 [1] = {
1284 .start = intcs_evt2irq(0x880),
1285 .flags = IORESOURCE_IRQ,
1286 },
1287 [2] = {
1288 /* place holder for contiguous memory */
1289 },
1290};
1291
1292static struct platform_device ceu_device = {
1293 .name = "sh_mobile_ceu",
1294 .id = 0, /* "ceu0" clock */
1295 .num_resources = ARRAY_SIZE(ceu_resources),
1296 .resource = ceu_resources,
1297 .dev = {
Guennadi Liakhovetski05a5f012011-03-23 09:29:16 +00001298 .platform_data = &sh_mobile_ceu_info,
1299 .coherent_dma_mask = 0xffffffff,
Magnus Dammae37c8d2010-12-22 14:47:40 +00001300 },
1301};
1302
1303static struct platform_device mackerel_camera = {
1304 .name = "soc-camera-pdrv",
1305 .id = 0,
1306 .dev = {
1307 .platform_data = &camera_link,
1308 },
1309};
1310
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001311static struct platform_device *mackerel_devices[] __initdata = {
1312 &nor_flash_device,
Kuninori Morimoto2264c152010-11-29 02:21:37 +00001313 &smc911x_device,
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001314 &lcdc_device,
Kuninori Morimoto25338f22010-11-30 04:37:33 +00001315 &usb1_host_device,
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +00001316 &usbhs1_device,
Kuninori Morimoto5a568552011-06-17 04:33:13 +00001317 &usbhs0_device,
Kuninori Morimotod44deb32010-11-30 06:52:18 +00001318 &leds_device,
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001319 &fsi_device,
1320 &fsi_ak4643_device,
Kuninori Morimoto3f25c9c2011-01-24 10:09:02 +09001321 &fsi_hdmi_device,
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001322 &sdhi0_device,
Guennadi Liakhovetski5bcd7512011-05-05 15:56:27 +00001323#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001324 &sdhi1_device,
Yusuke Goda41491b92010-12-15 08:31:04 +00001325#endif
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001326 &sdhi2_device,
Yusuke Goda41491b92010-12-15 08:31:04 +00001327 &sh_mmcif_device,
Magnus Dammae37c8d2010-12-22 14:47:40 +00001328 &ceu_device,
1329 &mackerel_camera,
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001330 &hdmi_lcdc_device,
1331 &hdmi_device,
Damian1c7fcbe2011-05-24 07:01:22 +00001332 &meram_device,
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001333};
1334
Tony SIMcd8ab002010-12-09 01:55:55 +00001335/* Keypad Initialization */
1336#define KEYPAD_BUTTON(ev_type, ev_code, act_low) \
1337{ \
1338 .type = ev_type, \
1339 .code = ev_code, \
1340 .active_low = act_low, \
1341}
1342
1343#define KEYPAD_BUTTON_LOW(event_code) KEYPAD_BUTTON(EV_KEY, event_code, 1)
1344
1345static struct tca6416_button mackerel_gpio_keys[] = {
1346 KEYPAD_BUTTON_LOW(KEY_HOME),
1347 KEYPAD_BUTTON_LOW(KEY_MENU),
1348 KEYPAD_BUTTON_LOW(KEY_BACK),
1349 KEYPAD_BUTTON_LOW(KEY_POWER),
1350};
1351
1352static struct tca6416_keys_platform_data mackerel_tca6416_keys_info = {
1353 .buttons = mackerel_gpio_keys,
1354 .nbuttons = ARRAY_SIZE(mackerel_gpio_keys),
1355 .rep = 1,
1356 .use_polling = 0,
1357 .pinmask = 0x000F,
1358};
1359
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001360/* I2C */
Tony SIM6ae1e192011-01-11 09:47:59 +09001361#define IRQ7 evt2irq(0x02e0)
Tony SIMcd8ab002010-12-09 01:55:55 +00001362#define IRQ9 evt2irq(0x0320)
1363
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001364static struct i2c_board_info i2c0_devices[] = {
1365 {
1366 I2C_BOARD_INFO("ak4643", 0x13),
1367 },
Tony SIMcd8ab002010-12-09 01:55:55 +00001368 /* Keypad */
1369 {
1370 I2C_BOARD_INFO("tca6408-keys", 0x20),
1371 .platform_data = &mackerel_tca6416_keys_info,
1372 .irq = IRQ9,
1373 },
Tony SIM6ae1e192011-01-11 09:47:59 +09001374 /* Touchscreen */
1375 {
1376 I2C_BOARD_INFO("st1232-ts", 0x55),
1377 .irq = IRQ7,
1378 },
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001379};
1380
Tony SIM80f1dc7c2010-12-07 09:12:14 +00001381#define IRQ21 evt2irq(0x32a0)
1382
1383static struct i2c_board_info i2c1_devices[] = {
1384 /* Accelerometer */
1385 {
1386 I2C_BOARD_INFO("adxl34x", 0x53),
1387 .irq = IRQ21,
1388 },
1389};
1390
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001391static struct map_desc mackerel_io_desc[] __initdata = {
1392 /* create a 1:1 entity map for 0xe6xxxxxx
1393 * used by CPGA, INTC and PFC.
1394 */
1395 {
1396 .virtual = 0xe6000000,
1397 .pfn = __phys_to_pfn(0xe6000000),
1398 .length = 256 << 20,
1399 .type = MT_DEVICE_NONSHARED
1400 },
1401};
1402
1403static void __init mackerel_map_io(void)
1404{
1405 iotable_init(mackerel_io_desc, ARRAY_SIZE(mackerel_io_desc));
1406
1407 /* setup early devices and console here as well */
1408 sh7372_add_early_devices();
1409 shmobile_setup_console();
1410}
1411
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001412#define GPIO_PORT9CR 0xE6051009
1413#define GPIO_PORT10CR 0xE605100A
Magnus Damme2a53b72011-06-09 07:03:37 +00001414#define GPIO_PORT167CR 0xE60520A7
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +00001415#define GPIO_PORT168CR 0xE60520A8
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001416#define SRCR4 0xe61580bc
Kuninori Morimoto98d27b82011-01-06 02:44:15 +00001417#define USCCR1 0xE6058144
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001418static void __init mackerel_init(void)
1419{
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001420 u32 srcr4;
Kuninori Morimoto98d27b82011-01-06 02:44:15 +00001421 struct clk *clk;
Guennadi Liakhovetski4bff4a72011-05-11 16:51:20 +00001422 int ret;
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001423
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001424 sh7372_pinmux_init();
1425
1426 /* enable SCIFA0 */
1427 gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
1428 gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
1429
Kuninori Morimoto2264c152010-11-29 02:21:37 +00001430 /* enable SMSC911X */
1431 gpio_request(GPIO_FN_CS5A, NULL);
1432 gpio_request(GPIO_FN_IRQ6_39, NULL);
1433
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001434 /* LCDC */
Kuninori Morimotoeb87e672010-11-29 06:19:52 +00001435 gpio_request(GPIO_FN_LCDD23, NULL);
1436 gpio_request(GPIO_FN_LCDD22, NULL);
1437 gpio_request(GPIO_FN_LCDD21, NULL);
1438 gpio_request(GPIO_FN_LCDD20, NULL);
1439 gpio_request(GPIO_FN_LCDD19, NULL);
1440 gpio_request(GPIO_FN_LCDD18, NULL);
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001441 gpio_request(GPIO_FN_LCDD17, NULL);
1442 gpio_request(GPIO_FN_LCDD16, NULL);
1443 gpio_request(GPIO_FN_LCDD15, NULL);
1444 gpio_request(GPIO_FN_LCDD14, NULL);
1445 gpio_request(GPIO_FN_LCDD13, NULL);
1446 gpio_request(GPIO_FN_LCDD12, NULL);
1447 gpio_request(GPIO_FN_LCDD11, NULL);
1448 gpio_request(GPIO_FN_LCDD10, NULL);
1449 gpio_request(GPIO_FN_LCDD9, NULL);
1450 gpio_request(GPIO_FN_LCDD8, NULL);
1451 gpio_request(GPIO_FN_LCDD7, NULL);
1452 gpio_request(GPIO_FN_LCDD6, NULL);
1453 gpio_request(GPIO_FN_LCDD5, NULL);
1454 gpio_request(GPIO_FN_LCDD4, NULL);
1455 gpio_request(GPIO_FN_LCDD3, NULL);
1456 gpio_request(GPIO_FN_LCDD2, NULL);
1457 gpio_request(GPIO_FN_LCDD1, NULL);
1458 gpio_request(GPIO_FN_LCDD0, NULL);
1459 gpio_request(GPIO_FN_LCDDISP, NULL);
1460 gpio_request(GPIO_FN_LCDDCK, NULL);
1461
1462 gpio_request(GPIO_PORT31, NULL); /* backlight */
Magnus Damm1fbdfcd2011-03-21 07:49:45 +00001463 gpio_direction_output(GPIO_PORT31, 0); /* off by default */
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001464
1465 gpio_request(GPIO_PORT151, NULL); /* LCDDON */
1466 gpio_direction_output(GPIO_PORT151, 1);
1467
Magnus Damme2a53b72011-06-09 07:03:37 +00001468 /* USBHS0 */
1469 gpio_request(GPIO_FN_VBUS0_0, NULL);
1470 gpio_pull_down(GPIO_PORT168CR); /* VBUS0_0 pull down */
Kuninori Morimoto25338f22010-11-30 04:37:33 +00001471
Magnus Damme2a53b72011-06-09 07:03:37 +00001472 /* USBHS1 */
1473 gpio_request(GPIO_FN_VBUS0_1, NULL);
1474 gpio_pull_down(GPIO_PORT167CR); /* VBUS0_1 pull down */
1475 gpio_request(GPIO_FN_IDIN_1_113, NULL);
1476
1477 /* USB phy tweak to make the r8a66597_hcd host driver work */
1478 __raw_writew(0x8a0a, 0xe6058130); /* USBCR4 */
Kuninori Morimoto25338f22010-11-30 04:37:33 +00001479
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001480 /* enable FSI2 port A (ak4643) */
1481 gpio_request(GPIO_FN_FSIAIBT, NULL);
1482 gpio_request(GPIO_FN_FSIAILR, NULL);
1483 gpio_request(GPIO_FN_FSIAISLD, NULL);
1484 gpio_request(GPIO_FN_FSIAOSLD, NULL);
1485 gpio_request(GPIO_PORT161, NULL);
1486 gpio_direction_output(GPIO_PORT161, 0); /* slave */
1487
1488 gpio_request(GPIO_PORT9, NULL);
1489 gpio_request(GPIO_PORT10, NULL);
1490 gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */
1491 gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */
1492
1493 intc_set_priority(IRQ_FSI, 3); /* irq priority FSI(3) > SMSC911X(2) */
1494
Kuninori Morimoto98d27b82011-01-06 02:44:15 +00001495 /* setup FSI2 port B (HDMI) */
1496 gpio_request(GPIO_FN_FSIBCK, NULL);
1497 __raw_writew(__raw_readw(USCCR1) & ~(1 << 6), USCCR1); /* use SPDIF */
1498
1499 /* set SPU2 clock to 119.6 MHz */
1500 clk = clk_get(NULL, "spu_clk");
1501 if (!IS_ERR(clk)) {
1502 clk_set_rate(clk, clk_round_rate(clk, 119600000));
1503 clk_put(clk);
1504 }
1505
Tony SIMcd8ab002010-12-09 01:55:55 +00001506 /* enable Keypad */
1507 gpio_request(GPIO_FN_IRQ9_42, NULL);
Thomas Gleixner6845664a2011-03-24 13:25:22 +01001508 irq_set_irq_type(IRQ9, IRQ_TYPE_LEVEL_HIGH);
Tony SIMcd8ab002010-12-09 01:55:55 +00001509
Tony SIM6ae1e192011-01-11 09:47:59 +09001510 /* enable Touchscreen */
1511 gpio_request(GPIO_FN_IRQ7_40, NULL);
Thomas Gleixner6845664a2011-03-24 13:25:22 +01001512 irq_set_irq_type(IRQ7, IRQ_TYPE_LEVEL_LOW);
Tony SIM6ae1e192011-01-11 09:47:59 +09001513
Tony SIM80f1dc7c2010-12-07 09:12:14 +00001514 /* enable Accelerometer */
1515 gpio_request(GPIO_FN_IRQ21, NULL);
Thomas Gleixner6845664a2011-03-24 13:25:22 +01001516 irq_set_irq_type(IRQ21, IRQ_TYPE_LEVEL_HIGH);
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001517
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001518 /* enable SDHI0 */
1519 gpio_request(GPIO_FN_SDHICD0, NULL);
1520 gpio_request(GPIO_FN_SDHIWP0, NULL);
1521 gpio_request(GPIO_FN_SDHICMD0, NULL);
1522 gpio_request(GPIO_FN_SDHICLK0, NULL);
1523 gpio_request(GPIO_FN_SDHID0_3, NULL);
1524 gpio_request(GPIO_FN_SDHID0_2, NULL);
1525 gpio_request(GPIO_FN_SDHID0_1, NULL);
1526 gpio_request(GPIO_FN_SDHID0_0, NULL);
1527
Guennadi Liakhovetski4bff4a72011-05-11 16:51:20 +00001528 ret = request_irq(evt2irq(0x3340), mackerel_sdhi0_gpio_cd,
1529 IRQF_TRIGGER_FALLING, "sdhi0 cd", &sdhi0_device.dev);
1530 if (!ret)
1531 sdhi0_info.tmio_flags |= TMIO_MMC_HAS_COLD_CD;
1532 else
1533 pr_err("Cannot get IRQ #%d: %d\n", evt2irq(0x3340), ret);
1534
Guennadi Liakhovetski5bcd7512011-05-05 15:56:27 +00001535#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001536 /* enable SDHI1 */
1537 gpio_request(GPIO_FN_SDHICMD1, NULL);
1538 gpio_request(GPIO_FN_SDHICLK1, NULL);
1539 gpio_request(GPIO_FN_SDHID1_3, NULL);
1540 gpio_request(GPIO_FN_SDHID1_2, NULL);
1541 gpio_request(GPIO_FN_SDHID1_1, NULL);
1542 gpio_request(GPIO_FN_SDHID1_0, NULL);
Yusuke Goda41491b92010-12-15 08:31:04 +00001543#endif
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001544 /* card detect pin for MMC slot (CN7) */
1545 gpio_request(GPIO_PORT41, NULL);
1546 gpio_direction_input(GPIO_PORT41);
1547
1548 /* enable SDHI2 */
1549 gpio_request(GPIO_FN_SDHICMD2, NULL);
1550 gpio_request(GPIO_FN_SDHICLK2, NULL);
1551 gpio_request(GPIO_FN_SDHID2_3, NULL);
1552 gpio_request(GPIO_FN_SDHID2_2, NULL);
1553 gpio_request(GPIO_FN_SDHID2_1, NULL);
1554 gpio_request(GPIO_FN_SDHID2_0, NULL);
1555
Yusuke Godada5d1f42011-01-07 09:48:36 +00001556 /* card detect pin for microSD slot (CN23) */
1557 gpio_request(GPIO_PORT162, NULL);
1558 gpio_direction_input(GPIO_PORT162);
1559
Yusuke Goda41491b92010-12-15 08:31:04 +00001560 /* MMCIF */
1561 gpio_request(GPIO_FN_MMCD0_0, NULL);
1562 gpio_request(GPIO_FN_MMCD0_1, NULL);
1563 gpio_request(GPIO_FN_MMCD0_2, NULL);
1564 gpio_request(GPIO_FN_MMCD0_3, NULL);
1565 gpio_request(GPIO_FN_MMCD0_4, NULL);
1566 gpio_request(GPIO_FN_MMCD0_5, NULL);
1567 gpio_request(GPIO_FN_MMCD0_6, NULL);
1568 gpio_request(GPIO_FN_MMCD0_7, NULL);
1569 gpio_request(GPIO_FN_MMCCMD0, NULL);
1570 gpio_request(GPIO_FN_MMCCLK0, NULL);
1571
Yusuke Goda56e78da2010-12-20 01:06:04 +00001572 /* enable GPS module (GT-720F) */
1573 gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
1574 gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
1575
Magnus Dammae37c8d2010-12-22 14:47:40 +00001576 /* CEU */
1577 gpio_request(GPIO_FN_VIO_CLK, NULL);
1578 gpio_request(GPIO_FN_VIO_VD, NULL);
1579 gpio_request(GPIO_FN_VIO_HD, NULL);
1580 gpio_request(GPIO_FN_VIO_FIELD, NULL);
1581 gpio_request(GPIO_FN_VIO_CKO, NULL);
1582 gpio_request(GPIO_FN_VIO_D7, NULL);
1583 gpio_request(GPIO_FN_VIO_D6, NULL);
1584 gpio_request(GPIO_FN_VIO_D5, NULL);
1585 gpio_request(GPIO_FN_VIO_D4, NULL);
1586 gpio_request(GPIO_FN_VIO_D3, NULL);
1587 gpio_request(GPIO_FN_VIO_D2, NULL);
1588 gpio_request(GPIO_FN_VIO_D1, NULL);
1589 gpio_request(GPIO_FN_VIO_D0, NULL);
1590
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001591 /* HDMI */
1592 gpio_request(GPIO_FN_HDMI_HPD, NULL);
1593 gpio_request(GPIO_FN_HDMI_CEC, NULL);
1594
1595 /* Reset HDMI, must be held at least one EXTALR (32768Hz) period */
1596 srcr4 = __raw_readl(SRCR4);
1597 __raw_writel(srcr4 | (1 << 13), SRCR4);
1598 udelay(50);
1599 __raw_writel(srcr4 & ~(1 << 13), SRCR4);
1600
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001601 i2c_register_board_info(0, i2c0_devices,
1602 ARRAY_SIZE(i2c0_devices));
Tony SIM80f1dc7c2010-12-07 09:12:14 +00001603 i2c_register_board_info(1, i2c1_devices,
1604 ARRAY_SIZE(i2c1_devices));
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001605
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001606 sh7372_add_standard_devices();
1607
1608 platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices));
Guennadi Liakhovetski2ce51f82011-04-04 17:08:05 +02001609
Rafael J. Wysockie3e01092011-07-01 22:13:56 +02001610 sh7372_add_device_to_domain(&sh7372_a4lc, &lcdc_device);
1611 sh7372_add_device_to_domain(&sh7372_a4lc, &hdmi_lcdc_device);
Damian91142bf2011-06-22 07:49:52 +00001612 sh7372_add_device_to_domain(&sh7372_a4lc, &meram_device);
Kuninori Morimotoc1ba5bb2011-07-10 10:12:08 +02001613 sh7372_add_device_to_domain(&sh7372_a4mp, &fsi_device);
Magnus Dammd93f5cd2011-10-19 23:52:41 +02001614 sh7372_add_device_to_domain(&sh7372_a3sp, &usbhs0_device);
1615 sh7372_add_device_to_domain(&sh7372_a3sp, &usbhs1_device);
1616 sh7372_add_device_to_domain(&sh7372_a3sp, &sh_mmcif_device);
1617 sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi0_device);
1618#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
1619 sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi1_device);
1620#endif
1621 sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi2_device);
Magnus Damm382414b2011-10-19 23:52:50 +02001622 sh7372_add_device_to_domain(&sh7372_a4r, &ceu_device);
Rafael J. Wysockie3e01092011-07-01 22:13:56 +02001623
Guennadi Liakhovetski2ce51f82011-04-04 17:08:05 +02001624 hdmi_init_pm_clock();
Magnus Damm97991652011-04-29 02:28:08 +09001625 sh7372_pm_init();
Kuninori Morimotoa41b6462011-07-10 10:11:57 +02001626 pm_clk_add(&fsi_device.dev, "spu2");
Magnus Damm5c3f96b2011-08-24 22:38:43 +02001627 pm_clk_add(&hdmi_lcdc_device.dev, "hdmi");
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001628}
1629
1630static void __init mackerel_timer_init(void)
1631{
1632 sh7372_clock_init();
1633 shmobile_timer.init();
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001634
1635 /* External clock source */
1636 clk_set_rate(&sh7372_dv_clki_clk, 27000000);
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001637}
1638
1639static struct sys_timer mackerel_timer = {
1640 .init = mackerel_timer_init,
1641};
1642
1643MACHINE_START(MACKEREL, "mackerel")
1644 .map_io = mackerel_map_io,
1645 .init_irq = sh7372_init_irq,
Magnus Damm863b1712010-12-28 08:27:01 +00001646 .handle_irq = shmobile_handle_irq_intc,
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001647 .init_machine = mackerel_init,
1648 .timer = &mackerel_timer,
1649MACHINE_END