blob: e8a9d7990d344e79d247eba72c4ea6f8269720e5 [file] [log] [blame]
Magnus Damm2b7eda62010-02-05 11:14:58 +00001/*
2 * AP4EVB board support
3 *
4 * Copyright (C) 2010 Magnus Damm
5 * Copyright (C) 2008 Yoshihiro Shimoda
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
Guennadi Liakhovetski8eda2f22010-05-23 14:04:03 +000020#include <linux/clk.h>
Magnus Damm2b7eda62010-02-05 11:14:58 +000021#include <linux/kernel.h>
22#include <linux/init.h>
23#include <linux/interrupt.h>
24#include <linux/irq.h>
25#include <linux/platform_device.h>
26#include <linux/delay.h>
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +000027#include <linux/mfd/sh_mobile_sdhi.h>
Guennadi Liakhovetski341291a2010-05-23 14:12:46 +000028#include <linux/mmc/host.h>
Magnus Damm2b7eda62010-02-05 11:14:58 +000029#include <linux/mtd/mtd.h>
30#include <linux/mtd/partitions.h>
31#include <linux/mtd/physmap.h>
Kuninori Morimotoc8ee3d42010-05-13 01:08:21 +000032#include <linux/mmc/host.h>
33#include <linux/mmc/sh_mmcif.h>
Kuninori Morimoto91cf5082010-03-11 10:42:52 +000034#include <linux/i2c.h>
35#include <linux/i2c/tsc2007.h>
Magnus Damm2b7eda62010-02-05 11:14:58 +000036#include <linux/io.h>
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +000037#include <linux/smsc911x.h>
Kuninori Morimotocb9215e2010-05-24 06:50:44 +000038#include <linux/sh_intc.h>
39#include <linux/sh_clk.h>
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +000040#include <linux/gpio.h>
Kuninori Morimoto17ccb832010-02-23 07:07:01 +000041#include <linux/input.h>
42#include <linux/input/sh_keysc.h>
Kuninori Morimotofb54d262010-04-13 06:16:32 +000043#include <linux/usb/r8a66597.h>
Guennadi Liakhovetski8eda2f22010-05-23 14:04:03 +000044
Kuninori Morimotocb9215e2010-05-24 06:50:44 +000045#include <sound/sh_fsi.h>
46
Guennadi Liakhovetski8eda2f22010-05-23 14:04:03 +000047#include <video/sh_mobile_lcdc.h>
48#include <video/sh_mipi_dsi.h>
49
Magnus Damm2b7eda62010-02-05 11:14:58 +000050#include <mach/common.h>
Guennadi Liakhovetski8eda2f22010-05-23 14:04:03 +000051#include <mach/irqs.h>
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +000052#include <mach/sh7372.h>
Guennadi Liakhovetski8eda2f22010-05-23 14:04:03 +000053
Magnus Damm2b7eda62010-02-05 11:14:58 +000054#include <asm/mach-types.h>
55#include <asm/mach/arch.h>
56#include <asm/mach/map.h>
Magnus Damm495b3ce2010-05-12 14:21:34 +000057#include <asm/mach/time.h>
Magnus Damm2b7eda62010-02-05 11:14:58 +000058
Kuninori Morimoto02624a12010-02-18 17:58:19 +090059/*
60 * Address Interface BusWidth note
61 * ------------------------------------------------------------------
62 * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON
63 * 0x0800_0000 user area -
64 * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF
65 * 0x1400_0000 Ether (LAN9220) 16bit
66 * 0x1600_0000 user area - cannot use with NAND
67 * 0x1800_0000 user area -
68 * 0x1A00_0000 -
69 * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit
70 */
71
72/*
73 * NOR Flash ROM
74 *
75 * SW1 | SW2 | SW7 | NOR Flash ROM
76 * bit1 | bit1 bit2 | bit1 | Memory allocation
77 * ------+------------+------+------------------
78 * OFF | ON OFF | ON | Area 0
79 * OFF | ON OFF | OFF | Area 4
80 */
81
82/*
83 * NAND Flash ROM
84 *
85 * SW1 | SW2 | SW7 | NAND Flash ROM
86 * bit1 | bit1 bit2 | bit2 | Memory allocation
87 * ------+------------+------+------------------
88 * OFF | ON OFF | ON | FCE 0
89 * OFF | ON OFF | OFF | FCE 1
90 */
91
92/*
93 * SMSC 9220
94 *
95 * SW1 SMSC 9220
96 * -----------------------
97 * ON access disable
98 * OFF access enable
99 */
100
Kuninori Morimoto17ccb832010-02-23 07:07:01 +0000101/*
Kuninori Morimotodda128d2010-03-12 10:07:55 +0000102 * LCD / IRQ / KEYSC / IrDA
Kuninori Morimoto17ccb832010-02-23 07:07:01 +0000103 *
Kuninori Morimoto9fa1b7f2010-06-04 03:15:09 +0000104 * IRQ = IRQ26 (TS), IRQ27 (VIO), IRQ28 (QHD-TouchScreen)
105 * LCD = 2nd LCDC (WVGA)
Kuninori Morimotodda128d2010-03-12 10:07:55 +0000106 *
107 * | SW43 |
108 * SW3 | ON | OFF |
109 * -------------+-----------------------+---------------+
110 * ON | KEY / IrDA | LCD |
111 * OFF | KEY / IrDA / IRQ | IRQ |
Kuninori Morimoto9fa1b7f2010-06-04 03:15:09 +0000112 *
113 *
114 * QHD / WVGA display
115 *
116 * You can choice display type on menuconfig.
117 * Then, check above dip-switch.
Kuninori Morimoto17ccb832010-02-23 07:07:01 +0000118 */
119
Kuninori Morimotofb54d262010-04-13 06:16:32 +0000120/*
121 * USB
122 *
123 * J7 : 1-2 MAX3355E VBUS
124 * 2-3 DC 5.0V
125 *
126 * S39: bit2: off
127 */
128
Kuninori Morimotocb9215e2010-05-24 06:50:44 +0000129/*
130 * FSI/FSMI
131 *
132 * SW41 : ON : SH-Mobile AP4 Audio Mode
133 * : OFF : Bluetooth Audio Mode
134 */
135
Kuninori Morimotoc8ee3d42010-05-13 01:08:21 +0000136/*
Kuninori Morimotod3d03e42010-06-01 04:31:29 +0000137 * MMC0/SDHI1 (CN7)
Kuninori Morimotoc8ee3d42010-05-13 01:08:21 +0000138 *
Kuninori Morimotod3d03e42010-06-01 04:31:29 +0000139 * J22 : select card voltage
140 * 1-2 pin : 1.8v
141 * 2-3 pin : 3.3v
142 *
143 * SW1 | SW33
144 * | bit1 | bit2 | bit3 | bit4
145 * ------------+------+------+------+-------
146 * MMC0 OFF | OFF | ON | ON | X
147 * SDHI1 OFF | ON | X | OFF | ON
148 *
149 * voltage lebel
150 * CN7 : 1.8v
151 * CN12: 3.3v
Kuninori Morimotoc8ee3d42010-05-13 01:08:21 +0000152 */
153
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000154/* MTD */
Magnus Damm2b7eda62010-02-05 11:14:58 +0000155static struct mtd_partition nor_flash_partitions[] = {
156 {
157 .name = "loader",
158 .offset = 0x00000000,
159 .size = 512 * 1024,
160 },
161 {
162 .name = "bootenv",
163 .offset = MTDPART_OFS_APPEND,
164 .size = 512 * 1024,
165 },
166 {
167 .name = "kernel_ro",
168 .offset = MTDPART_OFS_APPEND,
169 .size = 8 * 1024 * 1024,
170 .mask_flags = MTD_WRITEABLE,
171 },
172 {
173 .name = "kernel",
174 .offset = MTDPART_OFS_APPEND,
175 .size = 8 * 1024 * 1024,
176 },
177 {
178 .name = "data",
179 .offset = MTDPART_OFS_APPEND,
180 .size = MTDPART_SIZ_FULL,
181 },
182};
183
184static struct physmap_flash_data nor_flash_data = {
185 .width = 2,
186 .parts = nor_flash_partitions,
187 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
188};
189
190static struct resource nor_flash_resources[] = {
191 [0] = {
192 .start = 0x00000000,
193 .end = 0x08000000 - 1,
194 .flags = IORESOURCE_MEM,
195 }
196};
197
198static struct platform_device nor_flash_device = {
199 .name = "physmap-flash",
200 .dev = {
201 .platform_data = &nor_flash_data,
202 },
203 .num_resources = ARRAY_SIZE(nor_flash_resources),
204 .resource = nor_flash_resources,
205};
206
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000207/* SMSC 9220 */
208static struct resource smc911x_resources[] = {
209 {
210 .start = 0x14000000,
211 .end = 0x16000000 - 1,
212 .flags = IORESOURCE_MEM,
213 }, {
Magnus Damm33c96072010-05-20 14:41:00 +0000214 .start = evt2irq(0x02c0) /* IRQ6A */,
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000215 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
216 },
217};
218
219static struct smsc911x_platform_config smsc911x_info = {
220 .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
221 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
222 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
223};
224
225static struct platform_device smc911x_device = {
226 .name = "smsc911x",
227 .id = -1,
228 .num_resources = ARRAY_SIZE(smc911x_resources),
229 .resource = smc911x_resources,
230 .dev = {
231 .platform_data = &smsc911x_info,
232 },
233};
Magnus Damm2b7eda62010-02-05 11:14:58 +0000234
Kuninori Morimotoc8ee3d42010-05-13 01:08:21 +0000235/* SH_MMCIF */
236static struct resource sh_mmcif_resources[] = {
237 [0] = {
238 .name = "SH_MMCIF",
239 .start = 0xE6BD0000,
240 .end = 0xE6BD00FF,
241 .flags = IORESOURCE_MEM,
242 },
243 [1] = {
244 /* MMC ERR */
Kuninori Morimoto8d569342010-06-01 02:40:05 +0000245 .start = evt2irq(0x1ac0),
Kuninori Morimotoc8ee3d42010-05-13 01:08:21 +0000246 .flags = IORESOURCE_IRQ,
247 },
248 [2] = {
249 /* MMC NOR */
Kuninori Morimoto8d569342010-06-01 02:40:05 +0000250 .start = evt2irq(0x1ae0),
Kuninori Morimotoc8ee3d42010-05-13 01:08:21 +0000251 .flags = IORESOURCE_IRQ,
252 },
253};
254
Kuninori Morimotobb04e192010-06-02 00:25:03 +0000255static struct sh_mmcif_plat_data sh_mmcif_plat = {
Kuninori Morimotoc8ee3d42010-05-13 01:08:21 +0000256 .sup_pclk = 0,
257 .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
258 .caps = MMC_CAP_4_BIT_DATA |
259 MMC_CAP_8_BIT_DATA |
260 MMC_CAP_NEEDS_POLL,
261};
262
263static struct platform_device sh_mmcif_device = {
264 .name = "sh_mmcif",
265 .id = 0,
266 .dev = {
267 .dma_mask = NULL,
268 .coherent_dma_mask = 0xffffffff,
269 .platform_data = &sh_mmcif_plat,
270 },
271 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
272 .resource = sh_mmcif_resources,
273};
274
Magnus Damm3a14d032010-03-10 09:26:44 +0000275/* SDHI0 */
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000276static struct sh_mobile_sdhi_info sdhi0_info = {
Guennadi Liakhovetski341291a2010-05-23 14:12:46 +0000277 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
278 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000279};
280
Magnus Damm3a14d032010-03-10 09:26:44 +0000281static struct resource sdhi0_resources[] = {
282 [0] = {
283 .name = "SDHI0",
284 .start = 0xe6850000,
285 .end = 0xe68501ff,
286 .flags = IORESOURCE_MEM,
287 },
288 [1] = {
Magnus Damm33c96072010-05-20 14:41:00 +0000289 .start = evt2irq(0x0e00) /* SDHI0 */,
Magnus Damm3a14d032010-03-10 09:26:44 +0000290 .flags = IORESOURCE_IRQ,
291 },
292};
293
294static struct platform_device sdhi0_device = {
295 .name = "sh_mobile_sdhi",
296 .num_resources = ARRAY_SIZE(sdhi0_resources),
297 .resource = sdhi0_resources,
298 .id = 0,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000299 .dev = {
300 .platform_data = &sdhi0_info,
301 },
Magnus Damm3a14d032010-03-10 09:26:44 +0000302};
303
Guennadi Liakhovetski341291a2010-05-23 14:12:46 +0000304/* SDHI1 */
305static struct sh_mobile_sdhi_info sdhi1_info = {
306 .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
307 .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
308 .tmio_ocr_mask = MMC_VDD_165_195,
309};
310
311static struct resource sdhi1_resources[] = {
312 [0] = {
313 .name = "SDHI1",
314 .start = 0xe6860000,
315 .end = 0xe68601ff,
316 .flags = IORESOURCE_MEM,
317 },
318 [1] = {
319 .start = evt2irq(0x0e80),
320 .flags = IORESOURCE_IRQ,
321 },
322};
323
324static struct platform_device sdhi1_device = {
325 .name = "sh_mobile_sdhi",
326 .num_resources = ARRAY_SIZE(sdhi1_resources),
327 .resource = sdhi1_resources,
328 .id = 1,
329 .dev = {
330 .platform_data = &sdhi1_info,
331 },
332};
333
Kuninori Morimotofb54d262010-04-13 06:16:32 +0000334/* USB1 */
Kuninori Morimotobb04e192010-06-02 00:25:03 +0000335static void usb1_host_port_power(int port, int power)
Kuninori Morimotofb54d262010-04-13 06:16:32 +0000336{
337 if (!power) /* only power-on supported for now */
338 return;
339
340 /* set VBOUT/PWEN and EXTLP1 in DVSTCTR */
341 __raw_writew(__raw_readw(0xE68B0008) | 0x600, 0xE68B0008);
342}
343
344static struct r8a66597_platdata usb1_host_data = {
345 .on_chip = 1,
346 .port_power = usb1_host_port_power,
347};
348
349static struct resource usb1_host_resources[] = {
350 [0] = {
351 .name = "USBHS",
352 .start = 0xE68B0000,
353 .end = 0xE68B00E6 - 1,
354 .flags = IORESOURCE_MEM,
355 },
356 [1] = {
Magnus Damm33c96072010-05-20 14:41:00 +0000357 .start = evt2irq(0x1ce0) /* USB1_USB1I0 */,
Kuninori Morimotofb54d262010-04-13 06:16:32 +0000358 .flags = IORESOURCE_IRQ,
359 },
360};
361
362static struct platform_device usb1_host_device = {
363 .name = "r8a66597_hcd",
364 .id = 1,
365 .dev = {
366 .dma_mask = NULL, /* not use dma */
367 .coherent_dma_mask = 0xffffffff,
368 .platform_data = &usb1_host_data,
369 },
370 .num_resources = ARRAY_SIZE(usb1_host_resources),
371 .resource = usb1_host_resources,
372};
373
Kuninori Morimoto9fa1b7f2010-06-04 03:15:09 +0000374static struct sh_mobile_lcdc_info lcdc_info = {
Guennadi Liakhovetski8eda2f22010-05-23 14:04:03 +0000375 .ch[0] = {
376 .chan = LCDC_CHAN_MAINLCD,
377 .bpp = 16,
Guennadi Liakhovetski8eda2f22010-05-23 14:04:03 +0000378 }
379};
380
381static struct resource lcdc_resources[] = {
382 [0] = {
383 .name = "LCDC",
384 .start = 0xfe940000, /* P4-only space */
385 .end = 0xfe943fff,
386 .flags = IORESOURCE_MEM,
387 },
388 [1] = {
389 .start = intcs_evt2irq(0x580),
390 .flags = IORESOURCE_IRQ,
391 },
392};
393
394static struct platform_device lcdc_device = {
395 .name = "sh_mobile_lcdc_fb",
396 .num_resources = ARRAY_SIZE(lcdc_resources),
397 .resource = lcdc_resources,
398 .dev = {
Kuninori Morimoto9fa1b7f2010-06-04 03:15:09 +0000399 .platform_data = &lcdc_info,
Guennadi Liakhovetski8eda2f22010-05-23 14:04:03 +0000400 .coherent_dma_mask = ~0,
401 },
402};
403
Kuninori Morimoto9fa1b7f2010-06-04 03:15:09 +0000404/*
405 * QHD display
406 */
407#ifdef CONFIG_AP4EVB_QHD
408
409/* KEYSC (Needs SW43 set to ON) */
410static struct sh_keysc_info keysc_info = {
411 .mode = SH_KEYSC_MODE_1,
412 .scan_timing = 3,
413 .delay = 2500,
414 .keycodes = {
415 KEY_0, KEY_1, KEY_2, KEY_3, KEY_4,
416 KEY_5, KEY_6, KEY_7, KEY_8, KEY_9,
417 KEY_A, KEY_B, KEY_C, KEY_D, KEY_E,
418 KEY_F, KEY_G, KEY_H, KEY_I, KEY_J,
419 KEY_K, KEY_L, KEY_M, KEY_N, KEY_O,
420 },
421};
422
423static struct resource keysc_resources[] = {
424 [0] = {
425 .name = "KEYSC",
426 .start = 0xe61b0000,
427 .end = 0xe61b0063,
428 .flags = IORESOURCE_MEM,
429 },
430 [1] = {
431 .start = evt2irq(0x0be0), /* KEYSC_KEY */
432 .flags = IORESOURCE_IRQ,
433 },
434};
435
436static struct platform_device keysc_device = {
437 .name = "sh_keysc",
438 .id = 0, /* "keysc0" clock */
439 .num_resources = ARRAY_SIZE(keysc_resources),
440 .resource = keysc_resources,
441 .dev = {
442 .platform_data = &keysc_info,
443 },
444};
445
446/* MIPI-DSI */
Guennadi Liakhovetski8eda2f22010-05-23 14:04:03 +0000447static struct resource mipidsi0_resources[] = {
448 [0] = {
449 .start = 0xffc60000,
450 .end = 0xffc68fff,
451 .flags = IORESOURCE_MEM,
452 },
453};
454
455static struct sh_mipi_dsi_info mipidsi0_info = {
456 .data_format = MIPI_RGB888,
Kuninori Morimoto9fa1b7f2010-06-04 03:15:09 +0000457 .lcd_chan = &lcdc_info.ch[0],
Guennadi Liakhovetski8eda2f22010-05-23 14:04:03 +0000458};
459
460static struct platform_device mipidsi0_device = {
461 .name = "sh-mipi-dsi",
462 .num_resources = ARRAY_SIZE(mipidsi0_resources),
463 .resource = mipidsi0_resources,
464 .id = 0,
465 .dev = {
466 .platform_data = &mipidsi0_info,
467 },
468};
469
Kuninori Morimoto9fa1b7f2010-06-04 03:15:09 +0000470/* This function will disappear when we switch to (runtime) PM */
471static int __init ap4evb_init_display_clk(void)
472{
473 struct clk *lcdc_clk;
474 struct clk *dsitx_clk;
475 int ret;
476
477 lcdc_clk = clk_get(&lcdc_device.dev, "sh_mobile_lcdc_fb.0");
478 if (IS_ERR(lcdc_clk))
479 return PTR_ERR(lcdc_clk);
480
481 dsitx_clk = clk_get(&mipidsi0_device.dev, "sh-mipi-dsi.0");
482 if (IS_ERR(dsitx_clk)) {
483 ret = PTR_ERR(dsitx_clk);
484 goto eclkdsitxget;
485 }
486
487 ret = clk_enable(lcdc_clk);
488 if (ret < 0)
489 goto eclklcdcon;
490
491 ret = clk_enable(dsitx_clk);
492 if (ret < 0)
493 goto eclkdsitxon;
494
495 return 0;
496
497eclkdsitxon:
498 clk_disable(lcdc_clk);
499eclklcdcon:
500 clk_put(dsitx_clk);
501eclkdsitxget:
502 clk_put(lcdc_clk);
503
504 return ret;
505}
506device_initcall(ap4evb_init_display_clk);
507
508static struct platform_device *qhd_devices[] __initdata = {
509 &mipidsi0_device,
510 &keysc_device,
511};
512#endif /* CONFIG_AP4EVB_QHD */
513
Kuninori Morimotocb9215e2010-05-24 06:50:44 +0000514/* FSI */
515#define IRQ_FSI evt2irq(0x1840)
516#define FSIACKCR 0xE6150018
517static void fsiackcr_init(struct clk *clk)
518{
519 u32 status = __raw_readl(clk->enable_reg);
520
521 /* use external clock */
522 status &= ~0x000000ff;
523 status |= 0x00000080;
524 __raw_writel(status, clk->enable_reg);
525}
526
527static struct clk_ops fsiackcr_clk_ops = {
528 .init = fsiackcr_init,
529};
530
531static struct clk fsiackcr_clk = {
532 .ops = &fsiackcr_clk_ops,
533 .enable_reg = (void __iomem *)FSIACKCR,
534 .rate = 0, /* unknown */
535};
536
Kuninori Morimotobb04e192010-06-02 00:25:03 +0000537static struct sh_fsi_platform_info fsi_info = {
Kuninori Morimotocb9215e2010-05-24 06:50:44 +0000538 .porta_flags = SH_FSI_BRS_INV |
539 SH_FSI_OUT_SLAVE_MODE |
540 SH_FSI_IN_SLAVE_MODE |
541 SH_FSI_OFMT(PCM) |
542 SH_FSI_IFMT(PCM),
543};
544
545static struct resource fsi_resources[] = {
546 [0] = {
547 .name = "FSI",
548 .start = 0xFE3C0000,
549 .end = 0xFE3C0400 - 1,
550 .flags = IORESOURCE_MEM,
551 },
552 [1] = {
553 .start = IRQ_FSI,
554 .flags = IORESOURCE_IRQ,
555 },
556};
557
558static struct platform_device fsi_device = {
559 .name = "sh_fsi2",
560 .id = 0,
561 .num_resources = ARRAY_SIZE(fsi_resources),
562 .resource = fsi_resources,
563 .dev = {
564 .platform_data = &fsi_info,
565 },
566};
567
Magnus Damm2b7eda62010-02-05 11:14:58 +0000568static struct platform_device *ap4evb_devices[] __initdata = {
569 &nor_flash_device,
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000570 &smc911x_device,
Magnus Damm3a14d032010-03-10 09:26:44 +0000571 &sdhi0_device,
Guennadi Liakhovetski341291a2010-05-23 14:12:46 +0000572 &sdhi1_device,
Kuninori Morimotofb54d262010-04-13 06:16:32 +0000573 &usb1_host_device,
Guennadi Liakhovetski8eda2f22010-05-23 14:04:03 +0000574 &lcdc_device,
Kuninori Morimotocb9215e2010-05-24 06:50:44 +0000575 &fsi_device,
Kuninori Morimotoc8ee3d42010-05-13 01:08:21 +0000576 &sh_mmcif_device
Magnus Damm2b7eda62010-02-05 11:14:58 +0000577};
578
Kuninori Morimoto9fa1b7f2010-06-04 03:15:09 +0000579/* TouchScreen */
Magnus Damm33c96072010-05-20 14:41:00 +0000580#define IRQ28 evt2irq(0x3380) /* IRQ28A */
Kuninori Morimoto9fa1b7f2010-06-04 03:15:09 +0000581#define IRQ7 evt2irq(0x02e0) /* IRQ7A */
Kuninori Morimotobb04e192010-06-02 00:25:03 +0000582static struct tsc2007_platform_data tsc2007_info = {
Kuninori Morimoto91cf5082010-03-11 10:42:52 +0000583 .model = 2007,
584 .x_plate_ohms = 180,
585};
586
Kuninori Morimoto9fa1b7f2010-06-04 03:15:09 +0000587static struct i2c_board_info tsc_device = {
588 I2C_BOARD_INFO("tsc2007", 0x48),
589 .type = "tsc2007",
590 .platform_data = &tsc2007_info,
591 /*.irq is selected on ap4evb_init */
592};
593
Kuninori Morimoto91cf5082010-03-11 10:42:52 +0000594/* I2C */
Kuninori Morimotocb9215e2010-05-24 06:50:44 +0000595static struct i2c_board_info i2c0_devices[] = {
596 {
597 I2C_BOARD_INFO("ak4643", 0x13),
598 },
599};
600
Kuninori Morimoto91cf5082010-03-11 10:42:52 +0000601static struct i2c_board_info i2c1_devices[] = {
602 {
Kuninori Morimoto8fc883c2010-03-11 07:34:37 +0000603 I2C_BOARD_INFO("r2025sd", 0x32),
604 },
Kuninori Morimoto91cf5082010-03-11 10:42:52 +0000605};
606
Magnus Damm2b7eda62010-02-05 11:14:58 +0000607static struct map_desc ap4evb_io_desc[] __initdata = {
608 /* create a 1:1 entity map for 0xe6xxxxxx
609 * used by CPGA, INTC and PFC.
610 */
611 {
612 .virtual = 0xe6000000,
613 .pfn = __phys_to_pfn(0xe6000000),
614 .length = 256 << 20,
615 .type = MT_DEVICE_NONSHARED
616 },
617};
618
619static void __init ap4evb_map_io(void)
620{
621 iotable_init(ap4evb_io_desc, ARRAY_SIZE(ap4evb_io_desc));
622
Magnus Damm495b3ce2010-05-12 14:21:34 +0000623 /* setup early devices and console here as well */
Magnus Damm2b7eda62010-02-05 11:14:58 +0000624 sh7372_add_early_devices();
Magnus Damm4ae04ac2010-02-08 11:02:54 +0000625 shmobile_setup_console();
Magnus Damm2b7eda62010-02-05 11:14:58 +0000626}
627
Kuninori Morimotocb9215e2010-05-24 06:50:44 +0000628/*
629 * FIXME !!
630 *
631 * gpio_no_direction is quick_hack.
632 *
633 * current gpio frame work doesn't have
634 * the method to control only pull up/down/free.
635 * this function should be replaced by correct gpio function
636 */
637static void __init gpio_no_direction(u32 addr)
638{
639 __raw_writeb(0x00, addr);
640}
641
642#define GPIO_PORT9CR 0xE6051009
643#define GPIO_PORT10CR 0xE605100A
644
Magnus Damm2b7eda62010-02-05 11:14:58 +0000645static void __init ap4evb_init(void)
646{
Kuninori Morimotocb9215e2010-05-24 06:50:44 +0000647 struct clk *clk;
648
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000649 sh7372_pinmux_init();
650
Kuninori Morimotob228b482010-02-18 16:44:41 +0900651 /* enable SCIFA0 */
652 gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
653 gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
654
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000655 /* enable SMSC911X */
656 gpio_request(GPIO_FN_CS5A, NULL);
657 gpio_request(GPIO_FN_IRQ6_39, NULL);
658
Kuninori Morimoto50982802010-02-22 09:20:39 +0000659 /* enable LED 1 - 4 */
660 gpio_request(GPIO_PORT185, NULL);
661 gpio_request(GPIO_PORT186, NULL);
662 gpio_request(GPIO_PORT187, NULL);
663 gpio_request(GPIO_PORT188, NULL);
664 gpio_direction_output(GPIO_PORT185, 1);
665 gpio_direction_output(GPIO_PORT186, 1);
666 gpio_direction_output(GPIO_PORT187, 1);
667 gpio_direction_output(GPIO_PORT188, 1);
668 gpio_export(GPIO_PORT185, 0);
669 gpio_export(GPIO_PORT186, 0);
670 gpio_export(GPIO_PORT187, 0);
671 gpio_export(GPIO_PORT188, 0);
672
Kuninori Morimoto8cb3a2e2010-02-22 09:30:12 +0000673 /* enable Debug switch (S6) */
674 gpio_request(GPIO_PORT32, NULL);
675 gpio_request(GPIO_PORT33, NULL);
676 gpio_request(GPIO_PORT34, NULL);
677 gpio_request(GPIO_PORT35, NULL);
678 gpio_direction_input(GPIO_PORT32);
679 gpio_direction_input(GPIO_PORT33);
680 gpio_direction_input(GPIO_PORT34);
681 gpio_direction_input(GPIO_PORT35);
682 gpio_export(GPIO_PORT32, 0);
683 gpio_export(GPIO_PORT33, 0);
684 gpio_export(GPIO_PORT34, 0);
685 gpio_export(GPIO_PORT35, 0);
686
Magnus Damm3a14d032010-03-10 09:26:44 +0000687 /* SDHI0 */
688 gpio_request(GPIO_FN_SDHICD0, NULL);
689 gpio_request(GPIO_FN_SDHIWP0, NULL);
690 gpio_request(GPIO_FN_SDHICMD0, NULL);
691 gpio_request(GPIO_FN_SDHICLK0, NULL);
692 gpio_request(GPIO_FN_SDHID0_3, NULL);
693 gpio_request(GPIO_FN_SDHID0_2, NULL);
694 gpio_request(GPIO_FN_SDHID0_1, NULL);
695 gpio_request(GPIO_FN_SDHID0_0, NULL);
696
Kuninori Morimoto9fa1b7f2010-06-04 03:15:09 +0000697 /* SDHI1 */
698 gpio_request(GPIO_FN_SDHICMD1, NULL);
699 gpio_request(GPIO_FN_SDHICLK1, NULL);
700 gpio_request(GPIO_FN_SDHID1_3, NULL);
701 gpio_request(GPIO_FN_SDHID1_2, NULL);
702 gpio_request(GPIO_FN_SDHID1_1, NULL);
703 gpio_request(GPIO_FN_SDHID1_0, NULL);
Kuninori Morimoto91cf5082010-03-11 10:42:52 +0000704
Kuninori Morimotoc8ee3d42010-05-13 01:08:21 +0000705 /* MMCIF */
706 gpio_request(GPIO_FN_MMCD0_0, NULL);
707 gpio_request(GPIO_FN_MMCD0_1, NULL);
708 gpio_request(GPIO_FN_MMCD0_2, NULL);
709 gpio_request(GPIO_FN_MMCD0_3, NULL);
710 gpio_request(GPIO_FN_MMCD0_4, NULL);
711 gpio_request(GPIO_FN_MMCD0_5, NULL);
712 gpio_request(GPIO_FN_MMCD0_6, NULL);
713 gpio_request(GPIO_FN_MMCD0_7, NULL);
714 gpio_request(GPIO_FN_MMCCMD0, NULL);
715 gpio_request(GPIO_FN_MMCCLK0, NULL);
716
Kuninori Morimotofb54d262010-04-13 06:16:32 +0000717 /* USB enable */
718 gpio_request(GPIO_FN_VBUS0_1, NULL);
719 gpio_request(GPIO_FN_IDIN_1_18, NULL);
720 gpio_request(GPIO_FN_PWEN_1_115, NULL);
721 gpio_request(GPIO_FN_OVCN_1_114, NULL);
722 gpio_request(GPIO_FN_EXTLP_1, NULL);
723 gpio_request(GPIO_FN_OVCN2_1, NULL);
724
725 /* setup USB phy */
726 __raw_writew(0x8a0a, 0xE6058130); /* USBCR2 */
727
Kuninori Morimotocb9215e2010-05-24 06:50:44 +0000728 /* enable FSI2 */
729 gpio_request(GPIO_FN_FSIAIBT, NULL);
730 gpio_request(GPIO_FN_FSIAILR, NULL);
731 gpio_request(GPIO_FN_FSIAISLD, NULL);
732 gpio_request(GPIO_FN_FSIAOSLD, NULL);
733 gpio_request(GPIO_PORT161, NULL);
734 gpio_direction_output(GPIO_PORT161, 0); /* slave */
735
736 gpio_request(GPIO_PORT9, NULL);
737 gpio_request(GPIO_PORT10, NULL);
738 gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */
739 gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */
740
741 /* set SPU2 clock to 119.6 MHz */
742 clk = clk_get(NULL, "spu_clk");
Paul Mundt2ae2b762010-05-31 14:25:57 +0900743 if (!IS_ERR(clk)) {
Kuninori Morimotocb9215e2010-05-24 06:50:44 +0000744 clk_set_rate(clk, clk_round_rate(clk, 119600000));
745 clk_put(clk);
746 }
747
748 /* change parent of FSI A */
749 clk = clk_get(NULL, "fsia_clk");
Paul Mundt2ae2b762010-05-31 14:25:57 +0900750 if (!IS_ERR(clk)) {
Kuninori Morimotocb9215e2010-05-24 06:50:44 +0000751 clk_register(&fsiackcr_clk);
752 clk_set_parent(clk, &fsiackcr_clk);
753 clk_put(clk);
754 }
755
756 /*
757 * set irq priority, to avoid sound chopping
758 * when NFS rootfs is used
759 * FSI(3) > SMSC911X(2)
760 */
761 intc_set_priority(IRQ_FSI, 3);
762
763 i2c_register_board_info(0, i2c0_devices,
764 ARRAY_SIZE(i2c0_devices));
765
766 i2c_register_board_info(1, i2c1_devices,
767 ARRAY_SIZE(i2c1_devices));
768
Kuninori Morimoto9fa1b7f2010-06-04 03:15:09 +0000769#ifdef CONFIG_AP4EVB_QHD
770 /*
771 * QHD
772 */
773
774 /* enable KEYSC */
775 gpio_request(GPIO_FN_KEYOUT0, NULL);
776 gpio_request(GPIO_FN_KEYOUT1, NULL);
777 gpio_request(GPIO_FN_KEYOUT2, NULL);
778 gpio_request(GPIO_FN_KEYOUT3, NULL);
779 gpio_request(GPIO_FN_KEYOUT4, NULL);
780 gpio_request(GPIO_FN_KEYIN0_136, NULL);
781 gpio_request(GPIO_FN_KEYIN1_135, NULL);
782 gpio_request(GPIO_FN_KEYIN2_134, NULL);
783 gpio_request(GPIO_FN_KEYIN3_133, NULL);
784 gpio_request(GPIO_FN_KEYIN4, NULL);
785
786 /* enable TouchScreen */
787 gpio_request(GPIO_FN_IRQ28_123, NULL);
788 set_irq_type(IRQ28, IRQ_TYPE_LEVEL_LOW);
789
790 tsc_device.irq = IRQ28;
791 i2c_register_board_info(1, &tsc_device, 1);
792
793 /* LCDC0 */
794 lcdc_info.clock_source = LCDC_CLK_PERIPHERAL;
795 lcdc_info.ch[0].interface_type = RGB24;
796 lcdc_info.ch[0].clock_divider = 1;
797 lcdc_info.ch[0].flags = LCDC_FLAGS_DWPOL;
798 lcdc_info.ch[0].lcd_cfg.name = "R63302(QHD)";
799 lcdc_info.ch[0].lcd_cfg.xres = 544;
800 lcdc_info.ch[0].lcd_cfg.yres = 961;
801 lcdc_info.ch[0].lcd_cfg.left_margin = 72;
802 lcdc_info.ch[0].lcd_cfg.right_margin = 600;
803 lcdc_info.ch[0].lcd_cfg.hsync_len = 16;
804 lcdc_info.ch[0].lcd_cfg.upper_margin = 8;
805 lcdc_info.ch[0].lcd_cfg.lower_margin = 8;
806 lcdc_info.ch[0].lcd_cfg.vsync_len = 2;
807 lcdc_info.ch[0].lcd_cfg.sync = FB_SYNC_VERT_HIGH_ACT |
808 FB_SYNC_HOR_HIGH_ACT;
809 lcdc_info.ch[0].lcd_size_cfg.width = 44;
810 lcdc_info.ch[0].lcd_size_cfg.height = 79;
811
812 platform_add_devices(qhd_devices, ARRAY_SIZE(qhd_devices));
813
814#else
815 /*
816 * WVGA
817 */
818 gpio_request(GPIO_FN_LCDD17, NULL);
819 gpio_request(GPIO_FN_LCDD16, NULL);
820 gpio_request(GPIO_FN_LCDD15, NULL);
821 gpio_request(GPIO_FN_LCDD14, NULL);
822 gpio_request(GPIO_FN_LCDD13, NULL);
823 gpio_request(GPIO_FN_LCDD12, NULL);
824 gpio_request(GPIO_FN_LCDD11, NULL);
825 gpio_request(GPIO_FN_LCDD10, NULL);
826 gpio_request(GPIO_FN_LCDD9, NULL);
827 gpio_request(GPIO_FN_LCDD8, NULL);
828 gpio_request(GPIO_FN_LCDD7, NULL);
829 gpio_request(GPIO_FN_LCDD6, NULL);
830 gpio_request(GPIO_FN_LCDD5, NULL);
831 gpio_request(GPIO_FN_LCDD4, NULL);
832 gpio_request(GPIO_FN_LCDD3, NULL);
833 gpio_request(GPIO_FN_LCDD2, NULL);
834 gpio_request(GPIO_FN_LCDD1, NULL);
835 gpio_request(GPIO_FN_LCDD0, NULL);
836 gpio_request(GPIO_FN_LCDDISP, NULL);
837 gpio_request(GPIO_FN_LCDDCK, NULL);
838
839 gpio_request(GPIO_PORT189, NULL); /* backlight */
840 gpio_direction_output(GPIO_PORT189, 1);
841
842 gpio_request(GPIO_PORT151, NULL); /* LCDDON */
843 gpio_direction_output(GPIO_PORT151, 1);
844
845 lcdc_info.clock_source = LCDC_CLK_BUS;
846 lcdc_info.ch[0].interface_type = RGB18;
847 lcdc_info.ch[0].clock_divider = 2;
848 lcdc_info.ch[0].flags = 0;
849 lcdc_info.ch[0].lcd_cfg.name = "WVGA Panel";
850 lcdc_info.ch[0].lcd_cfg.xres = 800;
851 lcdc_info.ch[0].lcd_cfg.yres = 480;
852 lcdc_info.ch[0].lcd_cfg.left_margin = 220;
853 lcdc_info.ch[0].lcd_cfg.right_margin = 110;
854 lcdc_info.ch[0].lcd_cfg.hsync_len = 70;
855 lcdc_info.ch[0].lcd_cfg.upper_margin = 20;
856 lcdc_info.ch[0].lcd_cfg.lower_margin = 5;
857 lcdc_info.ch[0].lcd_cfg.vsync_len = 5;
858 lcdc_info.ch[0].lcd_cfg.sync = 0;
859 lcdc_info.ch[0].lcd_size_cfg.width = 152;
860 lcdc_info.ch[0].lcd_size_cfg.height = 91;
861
862 /* enable TouchScreen */
863 gpio_request(GPIO_FN_IRQ7_40, NULL);
864 set_irq_type(IRQ7, IRQ_TYPE_LEVEL_LOW);
865
866 tsc_device.irq = IRQ7;
867 i2c_register_board_info(0, &tsc_device, 1);
868#endif /* CONFIG_AP4EVB_QHD */
Guennadi Liakhovetski341291a2010-05-23 14:12:46 +0000869
Magnus Damm2b7eda62010-02-05 11:14:58 +0000870 sh7372_add_standard_devices();
871
872 platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices));
873}
874
Magnus Damm495b3ce2010-05-12 14:21:34 +0000875static void __init ap4evb_timer_init(void)
876{
877 sh7372_clock_init();
878 shmobile_timer.init();
879}
880
881static struct sys_timer ap4evb_timer = {
882 .init = ap4evb_timer_init,
883};
884
Magnus Damm2b7eda62010-02-05 11:14:58 +0000885MACHINE_START(AP4EVB, "ap4evb")
886 .phys_io = 0xe6000000,
887 .io_pg_offst = ((0xe6000000) >> 18) & 0xfffc,
888 .map_io = ap4evb_map_io,
889 .init_irq = sh7372_init_irq,
890 .init_machine = ap4evb_init,
Magnus Damm495b3ce2010-05-12 14:21:34 +0000891 .timer = &ap4evb_timer,
Magnus Damm2b7eda62010-02-05 11:14:58 +0000892MACHINE_END