blob: de51c07b8686a264385725f936feb43d2634dcf0 [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 Morimoto66ee3be2011-05-25 07:56:25 +000046#include <linux/usb/renesas_usbhs.h>
Jon Medhurst9b742022011-08-04 17:05:21 +010047#include <linux/dma-mapping.h>
Kuninori Morimoto920adc72010-11-29 02:21:21 +000048
Kuninori Morimoto12c43092011-01-06 02:44:09 +000049#include <video/sh_mobile_hdmi.h>
Kuninori Morimoto11fee462010-11-29 02:21:43 +000050#include <video/sh_mobile_lcdc.h>
Magnus Dammae37c8d2010-12-22 14:47:40 +000051#include <media/sh_mobile_ceu.h>
52#include <media/soc_camera.h>
53#include <media/soc_camera_platform.h>
Kuninori Morimoto1a44d722010-12-01 00:31:46 +000054#include <sound/sh_fsi.h>
55
Kuninori Morimoto920adc72010-11-29 02:21:21 +000056#include <mach/common.h>
57#include <mach/sh7372.h>
58
59#include <asm/mach/arch.h>
60#include <asm/mach/time.h>
Kuninori Morimoto920adc72010-11-29 02:21:21 +000061#include <asm/mach-types.h>
62
63/*
64 * Address Interface BusWidth note
65 * ------------------------------------------------------------------
66 * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON
67 * 0x0800_0000 user area -
68 * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF
69 * 0x1400_0000 Ether (LAN9220) 16bit
70 * 0x1600_0000 user area - cannot use with NAND
71 * 0x1800_0000 user area -
72 * 0x1A00_0000 -
73 * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit
74 */
75
Kuninori Morimoto4b82b682010-11-29 02:21:48 +000076/*
77 * CPU mode
78 *
79 * SW4 | Boot Area| Master | Remarks
80 * 1 | 2 | 3 | 4 | 5 | 6 | 8 | | Processor|
81 * ----+-----+-----+-----+-----+-----+-----+----------+----------+--------------
82 * ON | ON | OFF | ON | ON | OFF | OFF | External | System | External ROM
83 * ON | ON | ON | ON | ON | OFF | OFF | External | System | ROM Debug
84 * ON | ON | X | ON | OFF | OFF | OFF | Built-in | System | ROM Debug
85 * X | OFF | X | X | X | X | OFF | Built-in | System | MaskROM
86 * OFF | X | X | X | X | X | OFF | Built-in | System | MaskROM
87 * X | X | X | OFF | X | X | OFF | Built-in | System | MaskROM
88 * OFF | ON | OFF | X | X | OFF | ON | External | System | Standalone
89 * ON | OFF | OFF | X | X | OFF | ON | External | Realtime | Standalone
90*/
91
92/*
93 * NOR Flash ROM
94 *
95 * SW1 | SW2 | SW7 | NOR Flash ROM
96 * bit1 | bit1 bit2 | bit1 | Memory allocation
97 * ------+------------+------+------------------
98 * OFF | ON OFF | ON | Area 0
99 * OFF | ON OFF | OFF | Area 4
100 */
101
102/*
103 * SMSC 9220
104 *
105 * SW1 SMSC 9220
106 * -----------------------
107 * ON access disable
108 * OFF access enable
109 */
110
111/*
112 * NAND Flash ROM
113 *
114 * SW1 | SW2 | SW7 | NAND Flash ROM
115 * bit1 | bit1 bit2 | bit2 | Memory allocation
116 * ------+------------+------+------------------
117 * OFF | ON OFF | ON | FCE 0
118 * OFF | ON OFF | OFF | FCE 1
119 */
120
121/*
122 * External interrupt pin settings
123 *
124 * IRQX | pin setting | device | level
125 * ------+--------------------+--------------------+-------
126 * IRQ0 | ICR1A.IRQ0SA=0010 | SDHI2 card detect | Low
127 * IRQ6 | ICR1A.IRQ6SA=0011 | Ether(LAN9220) | High
Magnus Damme2a53b72011-06-09 07:03:37 +0000128 * IRQ7 | ICR1A.IRQ7SA=0010 | LCD Touch Panel | Low
Kuninori Morimoto4b82b682010-11-29 02:21:48 +0000129 * IRQ8 | ICR2A.IRQ8SA=0010 | MMC/SD card detect | Low
130 * IRQ9 | ICR2A.IRQ9SA=0010 | KEY(TCA6408) | Low
131 * IRQ21 | ICR4A.IRQ21SA=0011 | Sensor(ADXL345) | High
132 * IRQ22 | ICR4A.IRQ22SA=0011 | Sensor(AK8975) | High
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000133 */
Kuninori Morimoto4b82b682010-11-29 02:21:48 +0000134
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000135/*
136 * USB
137 *
138 * USB0 : CN22 : Function
139 * USB1 : CN31 : Function/Host *1
140 *
141 * J30 (for CN31) *1
142 * ----------+---------------+-------------
143 * 1-2 short | VBUS 5V | Host
144 * open | external VBUS | Function
145 *
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000146 * CAUTION
147 *
148 * renesas_usbhs driver can use external interrupt mode
149 * (which come from USB-PHY) or autonomy mode (it use own interrupt)
150 * for detecting connection/disconnection when Function.
151 * USB will be power OFF while it has been disconnecting
152 * if external interrupt mode, and it is always power ON if autonomy mode,
153 *
154 * mackerel can not use external interrupt (IRQ7-PORT167) mode on "USB0",
155 * because Touchscreen is using IRQ7-PORT40.
156 * It is impossible to use IRQ7 demux on this board.
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000157 */
Kuninori Morimoto4b82b682010-11-29 02:21:48 +0000158
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000159/*
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900160 * SDHI0 (CN12)
161 *
162 * SW56 : OFF
163 *
164 */
165
166/* MMC /SDHI1 (CN7)
167 *
168 * I/O voltage : 1.8v
169 *
170 * Power voltage : 1.8v or 3.3v
Yusuke Goda41491b92010-12-15 08:31:04 +0000171 * J22 : select power voltage *1
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900172 * 1-2 pin : 1.8v
173 * 2-3 pin : 3.3v
174 *
Yusuke Goda41491b92010-12-15 08:31:04 +0000175 * *1
176 * Please change J22 depends the card to be used.
177 * MMC's OCR field set to support either voltage for the card inserted.
178 *
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900179 * SW1 | SW33
180 * | bit1 | bit2 | bit3 | bit4
181 * -------------+------+------+------+-------
Simon Horman2150dac2011-01-07 22:26:15 +0000182 * MMC0 OFF | OFF | X | ON | X (Use MMCIF)
183 * SDHI1 OFF | ON | X | OFF | X (Use MFD_SH_MOBILE_SDHI)
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900184 *
185 */
186
187/*
188 * SDHI2 (CN23)
189 *
190 * microSD card sloct
191 *
192 */
193
194/*
Kuninori Morimoto6d9b7dd2012-01-18 16:37:07 -0800195 * FSI - AK4642
196 *
197 * it needs amixer settings for playing
198 *
199 * amixer set "Headphone" on
200 * amixer set "HPOUTL Mixer DACH" on
201 * amixer set "HPOUTR Mixer DACH" on
202 */
203
204/*
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000205 * FIXME !!
206 *
207 * gpio_no_direction
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000208 * gpio_pull_down
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000209 * are quick_hack.
210 *
211 * current gpio frame work doesn't have
212 * the method to control only pull up/down/free.
213 * this function should be replaced by correct gpio function
214 */
215static void __init gpio_no_direction(u32 addr)
216{
217 __raw_writeb(0x00, addr);
218}
219
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000220static void __init gpio_pull_down(u32 addr)
221{
222 u8 data = __raw_readb(addr);
223
224 data &= 0x0F;
225 data |= 0xA0;
226
227 __raw_writeb(data, addr);
228}
229
Kuninori Morimoto920adc72010-11-29 02:21:21 +0000230/* MTD */
231static struct mtd_partition nor_flash_partitions[] = {
232 {
233 .name = "loader",
234 .offset = 0x00000000,
235 .size = 512 * 1024,
236 .mask_flags = MTD_WRITEABLE,
237 },
238 {
239 .name = "bootenv",
240 .offset = MTDPART_OFS_APPEND,
241 .size = 512 * 1024,
242 .mask_flags = MTD_WRITEABLE,
243 },
244 {
245 .name = "kernel_ro",
246 .offset = MTDPART_OFS_APPEND,
247 .size = 8 * 1024 * 1024,
248 .mask_flags = MTD_WRITEABLE,
249 },
250 {
251 .name = "kernel",
252 .offset = MTDPART_OFS_APPEND,
253 .size = 8 * 1024 * 1024,
254 },
255 {
256 .name = "data",
257 .offset = MTDPART_OFS_APPEND,
258 .size = MTDPART_SIZ_FULL,
259 },
260};
261
262static struct physmap_flash_data nor_flash_data = {
263 .width = 2,
264 .parts = nor_flash_partitions,
265 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
266};
267
268static struct resource nor_flash_resources[] = {
269 [0] = {
Magnus Damm487881c2011-09-27 18:29:31 +0900270 .start = 0x20000000, /* CS0 shadow instead of regular CS0 */
271 .end = 0x28000000 - 1, /* needed by USB MASK ROM boot */
Kuninori Morimoto920adc72010-11-29 02:21:21 +0000272 .flags = IORESOURCE_MEM,
273 }
274};
275
276static struct platform_device nor_flash_device = {
277 .name = "physmap-flash",
278 .dev = {
279 .platform_data = &nor_flash_data,
280 },
281 .num_resources = ARRAY_SIZE(nor_flash_resources),
282 .resource = nor_flash_resources,
283};
284
Kuninori Morimoto2264c152010-11-29 02:21:37 +0000285/* SMSC */
286static struct resource smc911x_resources[] = {
287 {
288 .start = 0x14000000,
289 .end = 0x16000000 - 1,
290 .flags = IORESOURCE_MEM,
291 }, {
292 .start = evt2irq(0x02c0) /* IRQ6A */,
293 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
294 },
295};
296
297static struct smsc911x_platform_config smsc911x_info = {
298 .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
299 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
300 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
301};
302
303static struct platform_device smc911x_device = {
304 .name = "smsc911x",
305 .id = -1,
306 .num_resources = ARRAY_SIZE(smc911x_resources),
307 .resource = smc911x_resources,
308 .dev = {
309 .platform_data = &smsc911x_info,
310 },
311};
312
Damian1c7fcbe2011-05-24 07:01:22 +0000313/* MERAM */
314static struct sh_mobile_meram_info mackerel_meram_info = {
315 .addr_mode = SH_MOBILE_MERAM_MODE1,
316};
317
318static struct resource meram_resources[] = {
319 [0] = {
320 .name = "MERAM",
321 .start = 0xe8000000,
322 .end = 0xe81fffff,
323 .flags = IORESOURCE_MEM,
324 },
325};
326
327static struct platform_device meram_device = {
328 .name = "sh_mobile_meram",
329 .id = 0,
330 .num_resources = ARRAY_SIZE(meram_resources),
331 .resource = meram_resources,
332 .dev = {
333 .platform_data = &mackerel_meram_info,
334 },
335};
336
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000337/* LCDC */
338static struct fb_videomode mackerel_lcdc_modes[] = {
339 {
340 .name = "WVGA Panel",
341 .xres = 800,
342 .yres = 480,
343 .left_margin = 220,
344 .right_margin = 110,
345 .hsync_len = 70,
346 .upper_margin = 20,
347 .lower_margin = 5,
348 .vsync_len = 5,
349 .sync = 0,
350 },
351};
352
Magnus Damm1fbdfcd2011-03-21 07:49:45 +0000353static int mackerel_set_brightness(void *board_data, int brightness)
354{
355 gpio_set_value(GPIO_PORT31, brightness);
356
357 return 0;
358}
359
360static int mackerel_get_brightness(void *board_data)
361{
362 return gpio_get_value(GPIO_PORT31);
363}
364
Damian1c7fcbe2011-05-24 07:01:22 +0000365static struct sh_mobile_meram_cfg lcd_meram_cfg = {
366 .icb[0] = {
367 .marker_icb = 28,
368 .cache_icb = 24,
369 .meram_offset = 0x0,
370 .meram_size = 0x40,
371 },
372 .icb[1] = {
373 .marker_icb = 29,
374 .cache_icb = 25,
375 .meram_offset = 0x40,
376 .meram_size = 0x40,
377 },
378};
379
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000380static struct sh_mobile_lcdc_info lcdc_info = {
Damian1c7fcbe2011-05-24 07:01:22 +0000381 .meram_dev = &mackerel_meram_info,
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000382 .clock_source = LCDC_CLK_BUS,
383 .ch[0] = {
384 .chan = LCDC_CHAN_MAINLCD,
Laurent Pinchartedd153a2011-12-13 14:02:28 +0100385 .fourcc = V4L2_PIX_FMT_RGB565,
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000386 .lcd_cfg = mackerel_lcdc_modes,
387 .num_cfg = ARRAY_SIZE(mackerel_lcdc_modes),
388 .interface_type = RGB24,
Kuninori Morimoto2c34e932011-03-02 09:05:21 +0000389 .clock_divider = 3,
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000390 .flags = 0,
391 .lcd_size_cfg.width = 152,
392 .lcd_size_cfg.height = 91,
Magnus Damm1fbdfcd2011-03-21 07:49:45 +0000393 .board_cfg = {
394 .set_brightness = mackerel_set_brightness,
395 .get_brightness = mackerel_get_brightness,
396 },
397 .bl_info = {
398 .name = "sh_mobile_lcdc_bl",
399 .max_brightness = 1,
400 },
Damian1c7fcbe2011-05-24 07:01:22 +0000401 .meram_cfg = &lcd_meram_cfg,
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000402 }
403};
404
405static struct resource lcdc_resources[] = {
406 [0] = {
407 .name = "LCDC",
408 .start = 0xfe940000,
409 .end = 0xfe943fff,
410 .flags = IORESOURCE_MEM,
411 },
412 [1] = {
413 .start = intcs_evt2irq(0x580),
414 .flags = IORESOURCE_IRQ,
415 },
416};
417
418static struct platform_device lcdc_device = {
419 .name = "sh_mobile_lcdc_fb",
420 .num_resources = ARRAY_SIZE(lcdc_resources),
421 .resource = lcdc_resources,
422 .dev = {
423 .platform_data = &lcdc_info,
424 .coherent_dma_mask = ~0,
425 },
426};
427
Damian1c7fcbe2011-05-24 07:01:22 +0000428static struct sh_mobile_meram_cfg hdmi_meram_cfg = {
429 .icb[0] = {
430 .marker_icb = 30,
431 .cache_icb = 26,
432 .meram_offset = 0x80,
433 .meram_size = 0x100,
434 },
435 .icb[1] = {
436 .marker_icb = 31,
437 .cache_icb = 27,
438 .meram_offset = 0x180,
439 .meram_size = 0x100,
440 },
441};
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000442/* HDMI */
443static struct sh_mobile_lcdc_info hdmi_lcdc_info = {
Damian1c7fcbe2011-05-24 07:01:22 +0000444 .meram_dev = &mackerel_meram_info,
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000445 .clock_source = LCDC_CLK_EXTERNAL,
446 .ch[0] = {
447 .chan = LCDC_CHAN_MAINLCD,
Laurent Pinchartedd153a2011-12-13 14:02:28 +0100448 .fourcc = V4L2_PIX_FMT_RGB565,
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000449 .interface_type = RGB24,
450 .clock_divider = 1,
451 .flags = LCDC_FLAGS_DWPOL,
Damian1c7fcbe2011-05-24 07:01:22 +0000452 .meram_cfg = &hdmi_meram_cfg,
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000453 }
454};
455
456static struct resource hdmi_lcdc_resources[] = {
457 [0] = {
458 .name = "LCDC1",
459 .start = 0xfe944000,
460 .end = 0xfe947fff,
461 .flags = IORESOURCE_MEM,
462 },
463 [1] = {
464 .start = intcs_evt2irq(0x1780),
465 .flags = IORESOURCE_IRQ,
466 },
467};
468
469static struct platform_device hdmi_lcdc_device = {
470 .name = "sh_mobile_lcdc_fb",
471 .num_resources = ARRAY_SIZE(hdmi_lcdc_resources),
472 .resource = hdmi_lcdc_resources,
473 .id = 1,
474 .dev = {
475 .platform_data = &hdmi_lcdc_info,
476 .coherent_dma_mask = ~0,
477 },
478};
479
480static struct sh_mobile_hdmi_info hdmi_info = {
481 .lcd_chan = &hdmi_lcdc_info.ch[0],
482 .lcd_dev = &hdmi_lcdc_device.dev,
Kuninori Morimoto98d27b82011-01-06 02:44:15 +0000483 .flags = HDMI_SND_SRC_SPDIF,
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000484};
485
486static struct resource hdmi_resources[] = {
487 [0] = {
488 .name = "HDMI",
489 .start = 0xe6be0000,
490 .end = 0xe6be00ff,
491 .flags = IORESOURCE_MEM,
492 },
493 [1] = {
494 /* There's also an HDMI interrupt on INTCS @ 0x18e0 */
495 .start = evt2irq(0x17e0),
496 .flags = IORESOURCE_IRQ,
497 },
498};
499
500static struct platform_device hdmi_device = {
501 .name = "sh-mobile-hdmi",
502 .num_resources = ARRAY_SIZE(hdmi_resources),
503 .resource = hdmi_resources,
504 .id = -1,
505 .dev = {
506 .platform_data = &hdmi_info,
507 },
508};
509
Kuninori Morimoto3f25c9c2011-01-24 10:09:02 +0900510static struct platform_device fsi_hdmi_device = {
511 .name = "sh_fsi2_b_hdmi",
512};
513
Guennadi Liakhovetski2ce51f82011-04-04 17:08:05 +0200514static void __init hdmi_init_pm_clock(void)
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000515{
516 struct clk *hdmi_ick = clk_get(&hdmi_device.dev, "ick");
517 int ret;
518 long rate;
519
520 if (IS_ERR(hdmi_ick)) {
521 ret = PTR_ERR(hdmi_ick);
522 pr_err("Cannot get HDMI ICK: %d\n", ret);
523 goto out;
524 }
525
526 ret = clk_set_parent(&sh7372_pllc2_clk, &sh7372_dv_clki_div2_clk);
527 if (ret < 0) {
528 pr_err("Cannot set PLLC2 parent: %d, %d users\n",
529 ret, sh7372_pllc2_clk.usecount);
530 goto out;
531 }
532
533 pr_debug("PLLC2 initial frequency %lu\n",
534 clk_get_rate(&sh7372_pllc2_clk));
535
536 rate = clk_round_rate(&sh7372_pllc2_clk, 594000000);
537 if (rate < 0) {
538 pr_err("Cannot get suitable rate: %ld\n", rate);
539 ret = rate;
540 goto out;
541 }
542
543 ret = clk_set_rate(&sh7372_pllc2_clk, rate);
544 if (ret < 0) {
545 pr_err("Cannot set rate %ld: %d\n", rate, ret);
546 goto out;
547 }
548
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000549 pr_debug("PLLC2 set frequency %lu\n", rate);
550
551 ret = clk_set_parent(hdmi_ick, &sh7372_pllc2_clk);
Guennadi Liakhovetski2ce51f82011-04-04 17:08:05 +0200552 if (ret < 0)
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000553 pr_err("Cannot set HDMI parent: %d\n", ret);
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000554
555out:
556 if (!IS_ERR(hdmi_ick))
557 clk_put(hdmi_ick);
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000558}
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000559
Magnus Damme2a53b72011-06-09 07:03:37 +0000560/* USBHS0 is connected to CN22 which takes a USB Mini-B plug
561 *
562 * The sh7372 SoC has IRQ7 set aside for USBHS0 hotplug,
563 * but on this particular board IRQ7 is already used by
564 * the touch screen. This leaves us with software polling.
565 */
566#define USBHS0_POLL_INTERVAL (HZ * 5)
567
568struct usbhs_private {
569 unsigned int usbphyaddr;
570 unsigned int usbcrcaddr;
571 struct renesas_usbhs_platform_info info;
572 struct delayed_work work;
573 struct platform_device *pdev;
574};
575
576#define usbhs_get_priv(pdev) \
577 container_of(renesas_usbhs_get_info(pdev), \
578 struct usbhs_private, info)
579
580#define usbhs_is_connected(priv) \
581 (!((1 << 7) & __raw_readw(priv->usbcrcaddr)))
582
583static int usbhs_get_vbus(struct platform_device *pdev)
584{
585 return usbhs_is_connected(usbhs_get_priv(pdev));
586}
587
588static void usbhs_phy_reset(struct platform_device *pdev)
589{
590 struct usbhs_private *priv = usbhs_get_priv(pdev);
591
592 /* init phy */
593 __raw_writew(0x8a0a, priv->usbcrcaddr);
594}
595
596static int usbhs0_get_id(struct platform_device *pdev)
597{
598 return USBHS_GADGET;
599}
600
601static void usbhs0_work_function(struct work_struct *work)
602{
603 struct usbhs_private *priv = container_of(work, struct usbhs_private,
604 work.work);
605
606 renesas_usbhs_call_notify_hotplug(priv->pdev);
607 schedule_delayed_work(&priv->work, USBHS0_POLL_INTERVAL);
608}
609
610static int usbhs0_hardware_init(struct platform_device *pdev)
611{
612 struct usbhs_private *priv = usbhs_get_priv(pdev);
613
614 priv->pdev = pdev;
615 INIT_DELAYED_WORK(&priv->work, usbhs0_work_function);
616 schedule_delayed_work(&priv->work, USBHS0_POLL_INTERVAL);
617 return 0;
618}
619
620static void usbhs0_hardware_exit(struct platform_device *pdev)
621{
622 struct usbhs_private *priv = usbhs_get_priv(pdev);
623
624 cancel_delayed_work_sync(&priv->work);
625}
626
Magnus Damme2a53b72011-06-09 07:03:37 +0000627static struct usbhs_private usbhs0_private = {
628 .usbcrcaddr = 0xe605810c, /* USBCR2 */
629 .info = {
630 .platform_callback = {
631 .hardware_init = usbhs0_hardware_init,
632 .hardware_exit = usbhs0_hardware_exit,
633 .phy_reset = usbhs_phy_reset,
634 .get_id = usbhs0_get_id,
635 .get_vbus = usbhs_get_vbus,
636 },
637 .driver_param = {
638 .buswait_bwait = 4,
Kuninori Morimotofe437562011-06-17 08:21:21 +0000639 .d0_tx_id = SHDMA_SLAVE_USB0_TX,
640 .d1_rx_id = SHDMA_SLAVE_USB0_RX,
Magnus Damme2a53b72011-06-09 07:03:37 +0000641 },
642 },
643};
644
645static struct resource usbhs0_resources[] = {
646 [0] = {
647 .name = "USBHS0",
648 .start = 0xe6890000,
649 .end = 0xe68900e6 - 1,
650 .flags = IORESOURCE_MEM,
651 },
652 [1] = {
653 .start = evt2irq(0x1ca0) /* USB0_USB0I0 */,
654 .flags = IORESOURCE_IRQ,
655 },
656};
657
658static struct platform_device usbhs0_device = {
659 .name = "renesas_usbhs",
660 .id = 0,
661 .dev = {
662 .platform_data = &usbhs0_private.info,
663 },
664 .num_resources = ARRAY_SIZE(usbhs0_resources),
665 .resource = usbhs0_resources,
666};
667
668/* USBHS1 is connected to CN31 which takes a USB Mini-AB plug
669 *
670 * Use J30 to select between Host and Function. This setting
671 * can however not be detected by software. Hotplug of USBHS1
672 * is provided via IRQ8.
Kuninori Morimoto0ada2da52012-01-18 17:32:05 -0800673 *
674 * Current USB1 works as "USB Host".
675 * - set J30 "short"
676 *
677 * If you want to use it as "USB gadget",
678 * - J30 "open"
679 * - modify usbhs1_get_id() USBHS_HOST -> USBHS_GADGET
680 * - add .get_vbus = usbhs_get_vbus in usbhs1_private
Magnus Damme2a53b72011-06-09 07:03:37 +0000681 */
682#define IRQ8 evt2irq(0x0300)
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000683#define USB_PHY_MODE (1 << 4)
684#define USB_PHY_INT_EN ((1 << 3) | (1 << 2))
685#define USB_PHY_ON (1 << 1)
686#define USB_PHY_OFF (1 << 0)
687#define USB_PHY_INT_CLR (USB_PHY_ON | USB_PHY_OFF)
688
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000689static irqreturn_t usbhs1_interrupt(int irq, void *data)
690{
691 struct platform_device *pdev = data;
692 struct usbhs_private *priv = usbhs_get_priv(pdev);
693
694 dev_dbg(&pdev->dev, "%s\n", __func__);
695
696 renesas_usbhs_call_notify_hotplug(pdev);
697
698 /* clear status */
699 __raw_writew(__raw_readw(priv->usbphyaddr) | USB_PHY_INT_CLR,
700 priv->usbphyaddr);
701
702 return IRQ_HANDLED;
703}
704
705static int usbhs1_hardware_init(struct platform_device *pdev)
706{
707 struct usbhs_private *priv = usbhs_get_priv(pdev);
708 int ret;
709
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000710 /* clear interrupt status */
711 __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->usbphyaddr);
712
Magnus Damme2a53b72011-06-09 07:03:37 +0000713 ret = request_irq(IRQ8, usbhs1_interrupt, IRQF_TRIGGER_HIGH,
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000714 dev_name(&pdev->dev), pdev);
715 if (ret) {
716 dev_err(&pdev->dev, "request_irq err\n");
717 return ret;
718 }
719
720 /* enable USB phy interrupt */
721 __raw_writew(USB_PHY_MODE | USB_PHY_INT_EN, priv->usbphyaddr);
722
723 return 0;
724}
725
726static void usbhs1_hardware_exit(struct platform_device *pdev)
727{
728 struct usbhs_private *priv = usbhs_get_priv(pdev);
729
730 /* clear interrupt status */
731 __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->usbphyaddr);
732
Magnus Damme2a53b72011-06-09 07:03:37 +0000733 free_irq(IRQ8, pdev);
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000734}
735
Kuninori Morimoto05a79292011-06-15 06:16:35 +0000736static int usbhs1_get_id(struct platform_device *pdev)
737{
Kuninori Morimoto0ada2da52012-01-18 17:32:05 -0800738 return USBHS_HOST;
Kuninori Morimoto05a79292011-06-15 06:16:35 +0000739}
740
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000741static u32 usbhs1_pipe_cfg[] = {
742 USB_ENDPOINT_XFER_CONTROL,
743 USB_ENDPOINT_XFER_ISOC,
744 USB_ENDPOINT_XFER_ISOC,
745 USB_ENDPOINT_XFER_BULK,
746 USB_ENDPOINT_XFER_BULK,
747 USB_ENDPOINT_XFER_BULK,
748 USB_ENDPOINT_XFER_INT,
749 USB_ENDPOINT_XFER_INT,
750 USB_ENDPOINT_XFER_INT,
751 USB_ENDPOINT_XFER_BULK,
752 USB_ENDPOINT_XFER_BULK,
753 USB_ENDPOINT_XFER_BULK,
754 USB_ENDPOINT_XFER_BULK,
755 USB_ENDPOINT_XFER_BULK,
756 USB_ENDPOINT_XFER_BULK,
757 USB_ENDPOINT_XFER_BULK,
758};
759
760static struct usbhs_private usbhs1_private = {
Magnus Damme2a53b72011-06-09 07:03:37 +0000761 .usbphyaddr = 0xe60581e2, /* USBPHY1INTAP */
762 .usbcrcaddr = 0xe6058130, /* USBCR4 */
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000763 .info = {
764 .platform_callback = {
765 .hardware_init = usbhs1_hardware_init,
766 .hardware_exit = usbhs1_hardware_exit,
Kuninori Morimoto05a79292011-06-15 06:16:35 +0000767 .get_id = usbhs1_get_id,
Magnus Damme2a53b72011-06-09 07:03:37 +0000768 .phy_reset = usbhs_phy_reset,
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000769 },
770 .driver_param = {
771 .buswait_bwait = 4,
Kuninori Morimotof427eb62011-10-10 22:06:12 -0700772 .has_otg = 1,
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000773 .pipe_type = usbhs1_pipe_cfg,
774 .pipe_size = ARRAY_SIZE(usbhs1_pipe_cfg),
Kuninori Morimotofe437562011-06-17 08:21:21 +0000775 .d0_tx_id = SHDMA_SLAVE_USB1_TX,
776 .d1_rx_id = SHDMA_SLAVE_USB1_RX,
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000777 },
778 },
779};
780
781static struct resource usbhs1_resources[] = {
782 [0] = {
Magnus Damme2a53b72011-06-09 07:03:37 +0000783 .name = "USBHS1",
784 .start = 0xe68b0000,
785 .end = 0xe68b00e6 - 1,
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000786 .flags = IORESOURCE_MEM,
787 },
788 [1] = {
789 .start = evt2irq(0x1ce0) /* USB1_USB1I0 */,
790 .flags = IORESOURCE_IRQ,
791 },
792};
793
794static struct platform_device usbhs1_device = {
795 .name = "renesas_usbhs",
796 .id = 1,
797 .dev = {
798 .platform_data = &usbhs1_private.info,
799 },
800 .num_resources = ARRAY_SIZE(usbhs1_resources),
801 .resource = usbhs1_resources,
802};
803
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000804/* LED */
805static struct gpio_led mackerel_leds[] = {
806 {
807 .name = "led0",
808 .gpio = GPIO_PORT0,
809 .default_state = LEDS_GPIO_DEFSTATE_ON,
810 },
811 {
812 .name = "led1",
813 .gpio = GPIO_PORT1,
814 .default_state = LEDS_GPIO_DEFSTATE_ON,
815 },
816 {
817 .name = "led2",
818 .gpio = GPIO_PORT2,
819 .default_state = LEDS_GPIO_DEFSTATE_ON,
820 },
821 {
822 .name = "led3",
823 .gpio = GPIO_PORT159,
824 .default_state = LEDS_GPIO_DEFSTATE_ON,
825 }
826};
827
828static struct gpio_led_platform_data mackerel_leds_pdata = {
829 .leds = mackerel_leds,
830 .num_leds = ARRAY_SIZE(mackerel_leds),
831};
832
833static struct platform_device leds_device = {
834 .name = "leds-gpio",
835 .id = 0,
836 .dev = {
837 .platform_data = &mackerel_leds_pdata,
838 },
839};
840
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000841/* FSI */
842#define IRQ_FSI evt2irq(0x1840)
Kuninori Morimoto98d27b82011-01-06 02:44:15 +0000843static int __fsi_set_round_rate(struct clk *clk, long rate, int enable)
844{
845 int ret;
846
847 if (rate <= 0)
848 return 0;
849
850 if (!enable) {
851 clk_disable(clk);
852 return 0;
853 }
854
855 ret = clk_set_rate(clk, clk_round_rate(clk, rate));
856 if (ret < 0)
857 return ret;
858
859 return clk_enable(clk);
860}
861
862static int fsi_set_rate(struct device *dev, int is_porta, int rate, int enable)
863{
864 struct clk *fsib_clk;
865 struct clk *fdiv_clk = &sh7372_fsidivb_clk;
866 long fsib_rate = 0;
867 long fdiv_rate = 0;
868 int ackmd_bpfmd;
869 int ret;
870
871 /* FSIA is slave mode. nothing to do here */
872 if (is_porta)
873 return 0;
874
875 /* clock start */
876 switch (rate) {
877 case 44100:
878 fsib_rate = rate * 256;
879 ackmd_bpfmd = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
880 break;
881 case 48000:
882 fsib_rate = 85428000; /* around 48kHz x 256 x 7 */
883 fdiv_rate = rate * 256;
884 ackmd_bpfmd = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
885 break;
886 default:
887 pr_err("unsupported rate in FSI2 port B\n");
888 return -EINVAL;
889 }
890
891 /* FSI B setting */
892 fsib_clk = clk_get(dev, "ickb");
893 if (IS_ERR(fsib_clk))
894 return -EIO;
895
896 /* fsib */
897 ret = __fsi_set_round_rate(fsib_clk, fsib_rate, enable);
898 if (ret < 0)
899 goto fsi_set_rate_end;
900
901 /* FSI DIV */
902 ret = __fsi_set_round_rate(fdiv_clk, fdiv_rate, enable);
903 if (ret < 0) {
904 /* disable FSI B */
905 if (enable)
906 __fsi_set_round_rate(fsib_clk, fsib_rate, 0);
907 goto fsi_set_rate_end;
908 }
909
910 ret = ackmd_bpfmd;
911
912fsi_set_rate_end:
913 clk_put(fsib_clk);
914 return ret;
915}
916
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000917static struct sh_fsi_platform_info fsi_info = {
Kuninori Morimotof17c13c2011-01-24 10:43:19 +0900918 .porta_flags = SH_FSI_BRS_INV,
Kuninori Morimoto98d27b82011-01-06 02:44:15 +0000919
920 .portb_flags = SH_FSI_BRS_INV |
921 SH_FSI_BRM_INV |
922 SH_FSI_LRS_INV |
Kuninori Morimotof17c13c2011-01-24 10:43:19 +0900923 SH_FSI_FMT_SPDIF,
Kuninori Morimoto98d27b82011-01-06 02:44:15 +0000924
925 .set_rate = fsi_set_rate,
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000926};
927
928static struct resource fsi_resources[] = {
929 [0] = {
930 .name = "FSI",
931 .start = 0xFE3C0000,
932 .end = 0xFE3C0400 - 1,
933 .flags = IORESOURCE_MEM,
934 },
935 [1] = {
936 .start = IRQ_FSI,
937 .flags = IORESOURCE_IRQ,
938 },
939};
940
941static struct platform_device fsi_device = {
942 .name = "sh_fsi2",
943 .id = -1,
944 .num_resources = ARRAY_SIZE(fsi_resources),
945 .resource = fsi_resources,
946 .dev = {
947 .platform_data = &fsi_info,
948 },
949};
950
Kuninori Morimoto45f31212011-11-23 16:55:34 -0800951static struct fsi_ak4642_info fsi2_ak4643_info = {
952 .name = "AK4643",
953 .card = "FSI2A-AK4643",
954 .cpu_dai = "fsia-dai",
955 .codec = "ak4642-codec.0-0013",
956 .platform = "sh_fsi2",
957 .id = FSI_PORT_A,
958};
959
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000960static struct platform_device fsi_ak4643_device = {
Kuninori Morimoto45f31212011-11-23 16:55:34 -0800961 .name = "fsi-ak4642-audio",
962 .dev = {
963 .platform_data = &fsi2_ak4643_info,
964 },
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000965};
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000966
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900967/*
968 * The card detect pin of the top SD/MMC slot (CN7) is active low and is
969 * connected to GPIO A22 of SH7372 (GPIO_PORT41).
970 */
971static int slot_cn7_get_cd(struct platform_device *pdev)
972{
Magnus Dammceb50f32011-01-12 10:43:07 +0000973 return !gpio_get_value(GPIO_PORT41);
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900974}
975
976/* SDHI0 */
Guennadi Liakhovetski4bff4a72011-05-11 16:51:20 +0000977static irqreturn_t mackerel_sdhi0_gpio_cd(int irq, void *arg)
978{
979 struct device *dev = arg;
980 struct sh_mobile_sdhi_info *info = dev->platform_data;
981 struct tmio_mmc_data *pdata = info->pdata;
982
983 tmio_mmc_cd_wakeup(pdata);
984
985 return IRQ_HANDLED;
986}
987
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900988static struct sh_mobile_sdhi_info sdhi0_info = {
989 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
990 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
Magnus Dammda97da72011-01-06 10:55:41 +0000991 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900992};
993
994static struct resource sdhi0_resources[] = {
995 [0] = {
996 .name = "SDHI0",
997 .start = 0xe6850000,
Guennadi Liakhovetski31d31fe72011-03-09 13:09:27 +0100998 .end = 0xe68500ff,
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900999 .flags = IORESOURCE_MEM,
1000 },
1001 [1] = {
Simon Horman2007aea2011-04-27 07:43:58 +00001002 .start = evt2irq(0x0e00) /* SDHI0_SDHI0I0 */,
1003 .flags = IORESOURCE_IRQ,
1004 },
1005 [2] = {
1006 .start = evt2irq(0x0e20) /* SDHI0_SDHI0I1 */,
1007 .flags = IORESOURCE_IRQ,
1008 },
1009 [3] = {
1010 .start = evt2irq(0x0e40) /* SDHI0_SDHI0I2 */,
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001011 .flags = IORESOURCE_IRQ,
1012 },
1013};
1014
1015static struct platform_device sdhi0_device = {
1016 .name = "sh_mobile_sdhi",
1017 .num_resources = ARRAY_SIZE(sdhi0_resources),
1018 .resource = sdhi0_resources,
1019 .id = 0,
1020 .dev = {
1021 .platform_data = &sdhi0_info,
1022 },
1023};
1024
Guennadi Liakhovetski5bcd7512011-05-05 15:56:27 +00001025#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001026/* SDHI1 */
1027static struct sh_mobile_sdhi_info sdhi1_info = {
1028 .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
1029 .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
1030 .tmio_ocr_mask = MMC_VDD_165_195,
1031 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
Magnus Dammda97da72011-01-06 10:55:41 +00001032 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001033 MMC_CAP_NEEDS_POLL,
1034 .get_cd = slot_cn7_get_cd,
1035};
1036
1037static struct resource sdhi1_resources[] = {
1038 [0] = {
1039 .name = "SDHI1",
1040 .start = 0xe6860000,
Guennadi Liakhovetski31d31fe72011-03-09 13:09:27 +01001041 .end = 0xe68600ff,
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001042 .flags = IORESOURCE_MEM,
1043 },
1044 [1] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +09001045 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
Simon Horman2007aea2011-04-27 07:43:58 +00001046 .start = evt2irq(0x0e80), /* SDHI1_SDHI1I0 */
1047 .flags = IORESOURCE_IRQ,
1048 },
1049 [2] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +09001050 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
Simon Horman2007aea2011-04-27 07:43:58 +00001051 .start = evt2irq(0x0ea0), /* SDHI1_SDHI1I1 */
1052 .flags = IORESOURCE_IRQ,
1053 },
1054 [3] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +09001055 .name = SH_MOBILE_SDHI_IRQ_SDIO,
Simon Horman2007aea2011-04-27 07:43:58 +00001056 .start = evt2irq(0x0ec0), /* SDHI1_SDHI1I2 */
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001057 .flags = IORESOURCE_IRQ,
1058 },
1059};
1060
1061static struct platform_device sdhi1_device = {
1062 .name = "sh_mobile_sdhi",
1063 .num_resources = ARRAY_SIZE(sdhi1_resources),
1064 .resource = sdhi1_resources,
1065 .id = 1,
1066 .dev = {
1067 .platform_data = &sdhi1_info,
1068 },
1069};
Yusuke Goda41491b92010-12-15 08:31:04 +00001070#endif
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001071
Yusuke Godada5d1f42011-01-07 09:48:36 +00001072/*
1073 * The card detect pin of the top SD/MMC slot (CN23) is active low and is
1074 * connected to GPIO SCIFB_SCK of SH7372 (GPIO_PORT162).
1075 */
1076static int slot_cn23_get_cd(struct platform_device *pdev)
1077{
1078 return !gpio_get_value(GPIO_PORT162);
1079}
1080
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001081/* SDHI2 */
1082static struct sh_mobile_sdhi_info sdhi2_info = {
1083 .dma_slave_tx = SHDMA_SLAVE_SDHI2_TX,
1084 .dma_slave_rx = SHDMA_SLAVE_SDHI2_RX,
1085 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
Magnus Dammda97da72011-01-06 10:55:41 +00001086 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001087 MMC_CAP_NEEDS_POLL,
Yusuke Godada5d1f42011-01-07 09:48:36 +00001088 .get_cd = slot_cn23_get_cd,
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001089};
1090
1091static struct resource sdhi2_resources[] = {
1092 [0] = {
1093 .name = "SDHI2",
1094 .start = 0xe6870000,
Guennadi Liakhovetski31d31fe72011-03-09 13:09:27 +01001095 .end = 0xe68700ff,
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001096 .flags = IORESOURCE_MEM,
1097 },
1098 [1] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +09001099 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
Simon Horman2007aea2011-04-27 07:43:58 +00001100 .start = evt2irq(0x1200), /* SDHI2_SDHI2I0 */
1101 .flags = IORESOURCE_IRQ,
1102 },
1103 [2] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +09001104 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
Simon Horman2007aea2011-04-27 07:43:58 +00001105 .start = evt2irq(0x1220), /* SDHI2_SDHI2I1 */
1106 .flags = IORESOURCE_IRQ,
1107 },
1108 [3] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +09001109 .name = SH_MOBILE_SDHI_IRQ_SDIO,
Simon Horman2007aea2011-04-27 07:43:58 +00001110 .start = evt2irq(0x1240), /* SDHI2_SDHI2I2 */
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001111 .flags = IORESOURCE_IRQ,
1112 },
1113};
1114
1115static struct platform_device sdhi2_device = {
1116 .name = "sh_mobile_sdhi",
1117 .num_resources = ARRAY_SIZE(sdhi2_resources),
1118 .resource = sdhi2_resources,
1119 .id = 2,
1120 .dev = {
1121 .platform_data = &sdhi2_info,
1122 },
1123};
1124
Yusuke Goda41491b92010-12-15 08:31:04 +00001125/* SH_MMCIF */
1126static struct resource sh_mmcif_resources[] = {
1127 [0] = {
1128 .name = "MMCIF",
1129 .start = 0xE6BD0000,
1130 .end = 0xE6BD00FF,
1131 .flags = IORESOURCE_MEM,
1132 },
1133 [1] = {
1134 /* MMC ERR */
1135 .start = evt2irq(0x1ac0),
1136 .flags = IORESOURCE_IRQ,
1137 },
1138 [2] = {
1139 /* MMC NOR */
1140 .start = evt2irq(0x1ae0),
1141 .flags = IORESOURCE_IRQ,
1142 },
1143};
1144
1145static struct sh_mmcif_plat_data sh_mmcif_plat = {
1146 .sup_pclk = 0,
1147 .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
1148 .caps = MMC_CAP_4_BIT_DATA |
1149 MMC_CAP_8_BIT_DATA |
1150 MMC_CAP_NEEDS_POLL,
1151 .get_cd = slot_cn7_get_cd,
Guennadi Liakhovetskid5bb3862011-08-30 18:26:44 +02001152 .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
1153 .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
Yusuke Goda41491b92010-12-15 08:31:04 +00001154};
1155
1156static struct platform_device sh_mmcif_device = {
1157 .name = "sh_mmcif",
1158 .id = 0,
1159 .dev = {
1160 .dma_mask = NULL,
1161 .coherent_dma_mask = 0xffffffff,
1162 .platform_data = &sh_mmcif_plat,
1163 },
1164 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
1165 .resource = sh_mmcif_resources,
1166};
1167
Magnus Dammae37c8d2010-12-22 14:47:40 +00001168
Guennadi Liakhovetski7dfff952011-07-15 20:03:38 -03001169static int mackerel_camera_add(struct soc_camera_device *icd);
1170static void mackerel_camera_del(struct soc_camera_device *icd);
Magnus Dammae37c8d2010-12-22 14:47:40 +00001171
1172static int camera_set_capture(struct soc_camera_platform_info *info,
1173 int enable)
1174{
1175 return 0; /* camera sensor always enabled */
1176}
1177
1178static struct soc_camera_platform_info camera_info = {
1179 .format_name = "UYVY",
1180 .format_depth = 16,
1181 .format = {
1182 .code = V4L2_MBUS_FMT_UYVY8_2X8,
1183 .colorspace = V4L2_COLORSPACE_SMPTE170M,
1184 .field = V4L2_FIELD_NONE,
1185 .width = 640,
1186 .height = 480,
1187 },
Guennadi Liakhovetskid1e87ed2011-07-27 10:48:40 -03001188 .mbus_param = V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_MASTER |
1189 V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_HSYNC_ACTIVE_HIGH |
1190 V4L2_MBUS_DATA_ACTIVE_HIGH,
1191 .mbus_type = V4L2_MBUS_PARALLEL,
Magnus Dammae37c8d2010-12-22 14:47:40 +00001192 .set_capture = camera_set_capture,
1193};
1194
1195static struct soc_camera_link camera_link = {
1196 .bus_id = 0,
1197 .add_device = mackerel_camera_add,
1198 .del_device = mackerel_camera_del,
1199 .module_name = "soc_camera_platform",
1200 .priv = &camera_info,
1201};
1202
Guennadi Liakhovetski86a73142011-02-22 09:57:49 +00001203static struct platform_device *camera_device;
Magnus Dammae37c8d2010-12-22 14:47:40 +00001204
Guennadi Liakhovetski86a73142011-02-22 09:57:49 +00001205static void mackerel_camera_release(struct device *dev)
1206{
1207 soc_camera_platform_release(&camera_device);
1208}
Magnus Dammae37c8d2010-12-22 14:47:40 +00001209
Guennadi Liakhovetski7dfff952011-07-15 20:03:38 -03001210static int mackerel_camera_add(struct soc_camera_device *icd)
Magnus Dammae37c8d2010-12-22 14:47:40 +00001211{
Guennadi Liakhovetski7dfff952011-07-15 20:03:38 -03001212 return soc_camera_platform_add(icd, &camera_device, &camera_link,
Guennadi Liakhovetski86a73142011-02-22 09:57:49 +00001213 mackerel_camera_release, 0);
Magnus Dammae37c8d2010-12-22 14:47:40 +00001214}
1215
Guennadi Liakhovetski7dfff952011-07-15 20:03:38 -03001216static void mackerel_camera_del(struct soc_camera_device *icd)
Magnus Dammae37c8d2010-12-22 14:47:40 +00001217{
Guennadi Liakhovetski7dfff952011-07-15 20:03:38 -03001218 soc_camera_platform_del(icd, camera_device, &camera_link);
Magnus Dammae37c8d2010-12-22 14:47:40 +00001219}
1220
1221static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
1222 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
1223};
1224
1225static struct resource ceu_resources[] = {
1226 [0] = {
1227 .name = "CEU",
1228 .start = 0xfe910000,
1229 .end = 0xfe91009f,
1230 .flags = IORESOURCE_MEM,
1231 },
1232 [1] = {
1233 .start = intcs_evt2irq(0x880),
1234 .flags = IORESOURCE_IRQ,
1235 },
1236 [2] = {
1237 /* place holder for contiguous memory */
1238 },
1239};
1240
1241static struct platform_device ceu_device = {
1242 .name = "sh_mobile_ceu",
1243 .id = 0, /* "ceu0" clock */
1244 .num_resources = ARRAY_SIZE(ceu_resources),
1245 .resource = ceu_resources,
1246 .dev = {
Guennadi Liakhovetski05a5f012011-03-23 09:29:16 +00001247 .platform_data = &sh_mobile_ceu_info,
1248 .coherent_dma_mask = 0xffffffff,
Magnus Dammae37c8d2010-12-22 14:47:40 +00001249 },
1250};
1251
1252static struct platform_device mackerel_camera = {
1253 .name = "soc-camera-pdrv",
1254 .id = 0,
1255 .dev = {
1256 .platform_data = &camera_link,
1257 },
1258};
1259
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001260static struct platform_device *mackerel_devices[] __initdata = {
1261 &nor_flash_device,
Kuninori Morimoto2264c152010-11-29 02:21:37 +00001262 &smc911x_device,
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001263 &lcdc_device,
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +00001264 &usbhs1_device,
Kuninori Morimoto5a568552011-06-17 04:33:13 +00001265 &usbhs0_device,
Kuninori Morimotod44deb32010-11-30 06:52:18 +00001266 &leds_device,
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001267 &fsi_device,
1268 &fsi_ak4643_device,
Kuninori Morimoto3f25c9c2011-01-24 10:09:02 +09001269 &fsi_hdmi_device,
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001270 &sdhi0_device,
Guennadi Liakhovetski5bcd7512011-05-05 15:56:27 +00001271#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001272 &sdhi1_device,
Yusuke Goda41491b92010-12-15 08:31:04 +00001273#endif
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001274 &sdhi2_device,
Yusuke Goda41491b92010-12-15 08:31:04 +00001275 &sh_mmcif_device,
Magnus Dammae37c8d2010-12-22 14:47:40 +00001276 &ceu_device,
1277 &mackerel_camera,
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001278 &hdmi_lcdc_device,
1279 &hdmi_device,
Damian1c7fcbe2011-05-24 07:01:22 +00001280 &meram_device,
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001281};
1282
Tony SIMcd8ab002010-12-09 01:55:55 +00001283/* Keypad Initialization */
1284#define KEYPAD_BUTTON(ev_type, ev_code, act_low) \
1285{ \
1286 .type = ev_type, \
1287 .code = ev_code, \
1288 .active_low = act_low, \
1289}
1290
1291#define KEYPAD_BUTTON_LOW(event_code) KEYPAD_BUTTON(EV_KEY, event_code, 1)
1292
1293static struct tca6416_button mackerel_gpio_keys[] = {
1294 KEYPAD_BUTTON_LOW(KEY_HOME),
1295 KEYPAD_BUTTON_LOW(KEY_MENU),
1296 KEYPAD_BUTTON_LOW(KEY_BACK),
1297 KEYPAD_BUTTON_LOW(KEY_POWER),
1298};
1299
1300static struct tca6416_keys_platform_data mackerel_tca6416_keys_info = {
1301 .buttons = mackerel_gpio_keys,
1302 .nbuttons = ARRAY_SIZE(mackerel_gpio_keys),
1303 .rep = 1,
1304 .use_polling = 0,
1305 .pinmask = 0x000F,
1306};
1307
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001308/* I2C */
Tony SIM6ae1e192011-01-11 09:47:59 +09001309#define IRQ7 evt2irq(0x02e0)
Tony SIMcd8ab002010-12-09 01:55:55 +00001310#define IRQ9 evt2irq(0x0320)
1311
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001312static struct i2c_board_info i2c0_devices[] = {
1313 {
1314 I2C_BOARD_INFO("ak4643", 0x13),
1315 },
Tony SIMcd8ab002010-12-09 01:55:55 +00001316 /* Keypad */
1317 {
1318 I2C_BOARD_INFO("tca6408-keys", 0x20),
1319 .platform_data = &mackerel_tca6416_keys_info,
1320 .irq = IRQ9,
1321 },
Tony SIM6ae1e192011-01-11 09:47:59 +09001322 /* Touchscreen */
1323 {
1324 I2C_BOARD_INFO("st1232-ts", 0x55),
1325 .irq = IRQ7,
1326 },
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001327};
1328
Tony SIM80f1dc72010-12-07 09:12:14 +00001329#define IRQ21 evt2irq(0x32a0)
1330
1331static struct i2c_board_info i2c1_devices[] = {
1332 /* Accelerometer */
1333 {
1334 I2C_BOARD_INFO("adxl34x", 0x53),
1335 .irq = IRQ21,
1336 },
1337};
1338
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001339#define GPIO_PORT9CR 0xE6051009
1340#define GPIO_PORT10CR 0xE605100A
Magnus Damme2a53b72011-06-09 07:03:37 +00001341#define GPIO_PORT167CR 0xE60520A7
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +00001342#define GPIO_PORT168CR 0xE60520A8
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001343#define SRCR4 0xe61580bc
Kuninori Morimoto98d27b82011-01-06 02:44:15 +00001344#define USCCR1 0xE6058144
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001345static void __init mackerel_init(void)
1346{
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001347 u32 srcr4;
Kuninori Morimoto98d27b82011-01-06 02:44:15 +00001348 struct clk *clk;
Guennadi Liakhovetski4bff4a72011-05-11 16:51:20 +00001349 int ret;
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001350
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001351 sh7372_pinmux_init();
1352
1353 /* enable SCIFA0 */
1354 gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
1355 gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
1356
Kuninori Morimoto2264c152010-11-29 02:21:37 +00001357 /* enable SMSC911X */
1358 gpio_request(GPIO_FN_CS5A, NULL);
1359 gpio_request(GPIO_FN_IRQ6_39, NULL);
1360
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001361 /* LCDC */
Kuninori Morimotoeb87e672010-11-29 06:19:52 +00001362 gpio_request(GPIO_FN_LCDD23, NULL);
1363 gpio_request(GPIO_FN_LCDD22, NULL);
1364 gpio_request(GPIO_FN_LCDD21, NULL);
1365 gpio_request(GPIO_FN_LCDD20, NULL);
1366 gpio_request(GPIO_FN_LCDD19, NULL);
1367 gpio_request(GPIO_FN_LCDD18, NULL);
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001368 gpio_request(GPIO_FN_LCDD17, NULL);
1369 gpio_request(GPIO_FN_LCDD16, NULL);
1370 gpio_request(GPIO_FN_LCDD15, NULL);
1371 gpio_request(GPIO_FN_LCDD14, NULL);
1372 gpio_request(GPIO_FN_LCDD13, NULL);
1373 gpio_request(GPIO_FN_LCDD12, NULL);
1374 gpio_request(GPIO_FN_LCDD11, NULL);
1375 gpio_request(GPIO_FN_LCDD10, NULL);
1376 gpio_request(GPIO_FN_LCDD9, NULL);
1377 gpio_request(GPIO_FN_LCDD8, NULL);
1378 gpio_request(GPIO_FN_LCDD7, NULL);
1379 gpio_request(GPIO_FN_LCDD6, NULL);
1380 gpio_request(GPIO_FN_LCDD5, NULL);
1381 gpio_request(GPIO_FN_LCDD4, NULL);
1382 gpio_request(GPIO_FN_LCDD3, NULL);
1383 gpio_request(GPIO_FN_LCDD2, NULL);
1384 gpio_request(GPIO_FN_LCDD1, NULL);
1385 gpio_request(GPIO_FN_LCDD0, NULL);
1386 gpio_request(GPIO_FN_LCDDISP, NULL);
1387 gpio_request(GPIO_FN_LCDDCK, NULL);
1388
1389 gpio_request(GPIO_PORT31, NULL); /* backlight */
Magnus Damm1fbdfcd2011-03-21 07:49:45 +00001390 gpio_direction_output(GPIO_PORT31, 0); /* off by default */
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001391
1392 gpio_request(GPIO_PORT151, NULL); /* LCDDON */
1393 gpio_direction_output(GPIO_PORT151, 1);
1394
Magnus Damme2a53b72011-06-09 07:03:37 +00001395 /* USBHS0 */
1396 gpio_request(GPIO_FN_VBUS0_0, NULL);
1397 gpio_pull_down(GPIO_PORT168CR); /* VBUS0_0 pull down */
Kuninori Morimoto25338f22010-11-30 04:37:33 +00001398
Magnus Damme2a53b72011-06-09 07:03:37 +00001399 /* USBHS1 */
1400 gpio_request(GPIO_FN_VBUS0_1, NULL);
1401 gpio_pull_down(GPIO_PORT167CR); /* VBUS0_1 pull down */
1402 gpio_request(GPIO_FN_IDIN_1_113, NULL);
1403
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001404 /* enable FSI2 port A (ak4643) */
1405 gpio_request(GPIO_FN_FSIAIBT, NULL);
1406 gpio_request(GPIO_FN_FSIAILR, NULL);
1407 gpio_request(GPIO_FN_FSIAISLD, NULL);
1408 gpio_request(GPIO_FN_FSIAOSLD, NULL);
1409 gpio_request(GPIO_PORT161, NULL);
1410 gpio_direction_output(GPIO_PORT161, 0); /* slave */
1411
1412 gpio_request(GPIO_PORT9, NULL);
1413 gpio_request(GPIO_PORT10, NULL);
1414 gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */
1415 gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */
1416
1417 intc_set_priority(IRQ_FSI, 3); /* irq priority FSI(3) > SMSC911X(2) */
1418
Kuninori Morimoto98d27b82011-01-06 02:44:15 +00001419 /* setup FSI2 port B (HDMI) */
1420 gpio_request(GPIO_FN_FSIBCK, NULL);
1421 __raw_writew(__raw_readw(USCCR1) & ~(1 << 6), USCCR1); /* use SPDIF */
1422
1423 /* set SPU2 clock to 119.6 MHz */
1424 clk = clk_get(NULL, "spu_clk");
1425 if (!IS_ERR(clk)) {
1426 clk_set_rate(clk, clk_round_rate(clk, 119600000));
1427 clk_put(clk);
1428 }
1429
Tony SIMcd8ab002010-12-09 01:55:55 +00001430 /* enable Keypad */
1431 gpio_request(GPIO_FN_IRQ9_42, NULL);
Thomas Gleixner6845664a2011-03-24 13:25:22 +01001432 irq_set_irq_type(IRQ9, IRQ_TYPE_LEVEL_HIGH);
Tony SIMcd8ab002010-12-09 01:55:55 +00001433
Tony SIM6ae1e192011-01-11 09:47:59 +09001434 /* enable Touchscreen */
1435 gpio_request(GPIO_FN_IRQ7_40, NULL);
Thomas Gleixner6845664a2011-03-24 13:25:22 +01001436 irq_set_irq_type(IRQ7, IRQ_TYPE_LEVEL_LOW);
Tony SIM6ae1e192011-01-11 09:47:59 +09001437
Tony SIM80f1dc72010-12-07 09:12:14 +00001438 /* enable Accelerometer */
1439 gpio_request(GPIO_FN_IRQ21, NULL);
Thomas Gleixner6845664a2011-03-24 13:25:22 +01001440 irq_set_irq_type(IRQ21, IRQ_TYPE_LEVEL_HIGH);
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001441
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001442 /* enable SDHI0 */
1443 gpio_request(GPIO_FN_SDHICD0, NULL);
1444 gpio_request(GPIO_FN_SDHIWP0, NULL);
1445 gpio_request(GPIO_FN_SDHICMD0, NULL);
1446 gpio_request(GPIO_FN_SDHICLK0, NULL);
1447 gpio_request(GPIO_FN_SDHID0_3, NULL);
1448 gpio_request(GPIO_FN_SDHID0_2, NULL);
1449 gpio_request(GPIO_FN_SDHID0_1, NULL);
1450 gpio_request(GPIO_FN_SDHID0_0, NULL);
1451
Guennadi Liakhovetski4bff4a72011-05-11 16:51:20 +00001452 ret = request_irq(evt2irq(0x3340), mackerel_sdhi0_gpio_cd,
1453 IRQF_TRIGGER_FALLING, "sdhi0 cd", &sdhi0_device.dev);
1454 if (!ret)
1455 sdhi0_info.tmio_flags |= TMIO_MMC_HAS_COLD_CD;
1456 else
1457 pr_err("Cannot get IRQ #%d: %d\n", evt2irq(0x3340), ret);
1458
Guennadi Liakhovetski5bcd7512011-05-05 15:56:27 +00001459#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001460 /* enable SDHI1 */
1461 gpio_request(GPIO_FN_SDHICMD1, NULL);
1462 gpio_request(GPIO_FN_SDHICLK1, NULL);
1463 gpio_request(GPIO_FN_SDHID1_3, NULL);
1464 gpio_request(GPIO_FN_SDHID1_2, NULL);
1465 gpio_request(GPIO_FN_SDHID1_1, NULL);
1466 gpio_request(GPIO_FN_SDHID1_0, NULL);
Yusuke Goda41491b92010-12-15 08:31:04 +00001467#endif
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001468 /* card detect pin for MMC slot (CN7) */
1469 gpio_request(GPIO_PORT41, NULL);
1470 gpio_direction_input(GPIO_PORT41);
1471
1472 /* enable SDHI2 */
1473 gpio_request(GPIO_FN_SDHICMD2, NULL);
1474 gpio_request(GPIO_FN_SDHICLK2, NULL);
1475 gpio_request(GPIO_FN_SDHID2_3, NULL);
1476 gpio_request(GPIO_FN_SDHID2_2, NULL);
1477 gpio_request(GPIO_FN_SDHID2_1, NULL);
1478 gpio_request(GPIO_FN_SDHID2_0, NULL);
1479
Yusuke Godada5d1f42011-01-07 09:48:36 +00001480 /* card detect pin for microSD slot (CN23) */
1481 gpio_request(GPIO_PORT162, NULL);
1482 gpio_direction_input(GPIO_PORT162);
1483
Yusuke Goda41491b92010-12-15 08:31:04 +00001484 /* MMCIF */
1485 gpio_request(GPIO_FN_MMCD0_0, NULL);
1486 gpio_request(GPIO_FN_MMCD0_1, NULL);
1487 gpio_request(GPIO_FN_MMCD0_2, NULL);
1488 gpio_request(GPIO_FN_MMCD0_3, NULL);
1489 gpio_request(GPIO_FN_MMCD0_4, NULL);
1490 gpio_request(GPIO_FN_MMCD0_5, NULL);
1491 gpio_request(GPIO_FN_MMCD0_6, NULL);
1492 gpio_request(GPIO_FN_MMCD0_7, NULL);
1493 gpio_request(GPIO_FN_MMCCMD0, NULL);
1494 gpio_request(GPIO_FN_MMCCLK0, NULL);
1495
Yusuke Goda56e78da2010-12-20 01:06:04 +00001496 /* enable GPS module (GT-720F) */
1497 gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
1498 gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
1499
Magnus Dammae37c8d2010-12-22 14:47:40 +00001500 /* CEU */
1501 gpio_request(GPIO_FN_VIO_CLK, NULL);
1502 gpio_request(GPIO_FN_VIO_VD, NULL);
1503 gpio_request(GPIO_FN_VIO_HD, NULL);
1504 gpio_request(GPIO_FN_VIO_FIELD, NULL);
1505 gpio_request(GPIO_FN_VIO_CKO, NULL);
1506 gpio_request(GPIO_FN_VIO_D7, NULL);
1507 gpio_request(GPIO_FN_VIO_D6, NULL);
1508 gpio_request(GPIO_FN_VIO_D5, NULL);
1509 gpio_request(GPIO_FN_VIO_D4, NULL);
1510 gpio_request(GPIO_FN_VIO_D3, NULL);
1511 gpio_request(GPIO_FN_VIO_D2, NULL);
1512 gpio_request(GPIO_FN_VIO_D1, NULL);
1513 gpio_request(GPIO_FN_VIO_D0, NULL);
1514
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001515 /* HDMI */
1516 gpio_request(GPIO_FN_HDMI_HPD, NULL);
1517 gpio_request(GPIO_FN_HDMI_CEC, NULL);
1518
1519 /* Reset HDMI, must be held at least one EXTALR (32768Hz) period */
1520 srcr4 = __raw_readl(SRCR4);
1521 __raw_writel(srcr4 | (1 << 13), SRCR4);
1522 udelay(50);
1523 __raw_writel(srcr4 & ~(1 << 13), SRCR4);
1524
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001525 i2c_register_board_info(0, i2c0_devices,
1526 ARRAY_SIZE(i2c0_devices));
Tony SIM80f1dc72010-12-07 09:12:14 +00001527 i2c_register_board_info(1, i2c1_devices,
1528 ARRAY_SIZE(i2c1_devices));
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001529
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001530 sh7372_add_standard_devices();
1531
1532 platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices));
Guennadi Liakhovetski2ce51f82011-04-04 17:08:05 +02001533
Rafael J. Wysockie3e01092011-07-01 22:13:56 +02001534 sh7372_add_device_to_domain(&sh7372_a4lc, &lcdc_device);
1535 sh7372_add_device_to_domain(&sh7372_a4lc, &hdmi_lcdc_device);
Damian91142bf2011-06-22 07:49:52 +00001536 sh7372_add_device_to_domain(&sh7372_a4lc, &meram_device);
Kuninori Morimotoc1ba5bb2011-07-10 10:12:08 +02001537 sh7372_add_device_to_domain(&sh7372_a4mp, &fsi_device);
Magnus Dammd93f5cd2011-10-19 23:52:41 +02001538 sh7372_add_device_to_domain(&sh7372_a3sp, &usbhs0_device);
1539 sh7372_add_device_to_domain(&sh7372_a3sp, &usbhs1_device);
1540 sh7372_add_device_to_domain(&sh7372_a3sp, &sh_mmcif_device);
1541 sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi0_device);
1542#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
1543 sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi1_device);
1544#endif
1545 sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi2_device);
Magnus Damm382414b2011-10-19 23:52:50 +02001546 sh7372_add_device_to_domain(&sh7372_a4r, &ceu_device);
Rafael J. Wysockie3e01092011-07-01 22:13:56 +02001547
Guennadi Liakhovetski2ce51f82011-04-04 17:08:05 +02001548 hdmi_init_pm_clock();
Magnus Damm97991652011-04-29 02:28:08 +09001549 sh7372_pm_init();
Kuninori Morimotoa41b6462011-07-10 10:11:57 +02001550 pm_clk_add(&fsi_device.dev, "spu2");
Magnus Damm5c3f96b2011-08-24 22:38:43 +02001551 pm_clk_add(&hdmi_lcdc_device.dev, "hdmi");
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001552}
1553
1554static void __init mackerel_timer_init(void)
1555{
1556 sh7372_clock_init();
1557 shmobile_timer.init();
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001558
1559 /* External clock source */
1560 clk_set_rate(&sh7372_dv_clki_clk, 27000000);
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001561}
1562
1563static struct sys_timer mackerel_timer = {
1564 .init = mackerel_timer_init,
1565};
1566
1567MACHINE_START(MACKEREL, "mackerel")
Magnus Damm5d7220ec2012-02-29 21:37:19 +09001568 .map_io = sh7372_map_io,
1569 .init_early = sh7372_add_early_devices,
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001570 .init_irq = sh7372_init_irq,
Magnus Damm863b1712010-12-28 08:27:01 +00001571 .handle_irq = shmobile_handle_irq_intc,
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001572 .init_machine = mackerel_init,
1573 .timer = &mackerel_timer,
1574MACHINE_END