blob: 8fb51f5157f9580618473978bde96584ec37a413 [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 Liakhovetski69bf6f42010-05-04 14:07:15 +000027#include <linux/mfd/sh_mobile_sdhi.h>
Magnus Damm2b7eda62010-02-05 11:14:58 +000028#include <linux/mtd/mtd.h>
29#include <linux/mtd/partitions.h>
30#include <linux/mtd/physmap.h>
Kuninori Morimoto91cf5082010-03-11 10:42:52 +000031#include <linux/i2c.h>
32#include <linux/i2c/tsc2007.h>
Magnus Damm2b7eda62010-02-05 11:14:58 +000033#include <linux/io.h>
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +000034#include <linux/smsc911x.h>
Kuninori Morimotocb9215e2010-05-24 06:50:44 +000035#include <linux/sh_intc.h>
36#include <linux/sh_clk.h>
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +000037#include <linux/gpio.h>
Kuninori Morimoto17ccb832010-02-23 07:07:01 +000038#include <linux/input.h>
39#include <linux/input/sh_keysc.h>
Kuninori Morimotofb54d262010-04-13 06:16:32 +000040#include <linux/usb/r8a66597.h>
Guennadi Liakhovetski8eda2f22010-05-23 14:04:03 +000041
Kuninori Morimotocb9215e2010-05-24 06:50:44 +000042#include <sound/sh_fsi.h>
43
Guennadi Liakhovetski8eda2f22010-05-23 14:04:03 +000044#include <video/sh_mobile_lcdc.h>
45#include <video/sh_mipi_dsi.h>
46
Magnus Damm2b7eda62010-02-05 11:14:58 +000047#include <mach/common.h>
Guennadi Liakhovetski8eda2f22010-05-23 14:04:03 +000048#include <mach/irqs.h>
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +000049#include <mach/sh7372.h>
Guennadi Liakhovetski8eda2f22010-05-23 14:04:03 +000050
Magnus Damm2b7eda62010-02-05 11:14:58 +000051#include <asm/mach-types.h>
52#include <asm/mach/arch.h>
53#include <asm/mach/map.h>
Magnus Damm495b3ce2010-05-12 14:21:34 +000054#include <asm/mach/time.h>
Magnus Damm2b7eda62010-02-05 11:14:58 +000055
Kuninori Morimoto02624a12010-02-18 17:58:19 +090056/*
57 * Address Interface BusWidth note
58 * ------------------------------------------------------------------
59 * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON
60 * 0x0800_0000 user area -
61 * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF
62 * 0x1400_0000 Ether (LAN9220) 16bit
63 * 0x1600_0000 user area - cannot use with NAND
64 * 0x1800_0000 user area -
65 * 0x1A00_0000 -
66 * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit
67 */
68
69/*
70 * NOR Flash ROM
71 *
72 * SW1 | SW2 | SW7 | NOR Flash ROM
73 * bit1 | bit1 bit2 | bit1 | Memory allocation
74 * ------+------------+------+------------------
75 * OFF | ON OFF | ON | Area 0
76 * OFF | ON OFF | OFF | Area 4
77 */
78
79/*
80 * NAND Flash ROM
81 *
82 * SW1 | SW2 | SW7 | NAND Flash ROM
83 * bit1 | bit1 bit2 | bit2 | Memory allocation
84 * ------+------------+------+------------------
85 * OFF | ON OFF | ON | FCE 0
86 * OFF | ON OFF | OFF | FCE 1
87 */
88
89/*
90 * SMSC 9220
91 *
92 * SW1 SMSC 9220
93 * -----------------------
94 * ON access disable
95 * OFF access enable
96 */
97
Kuninori Morimoto17ccb832010-02-23 07:07:01 +000098/*
Kuninori Morimotodda128d2010-03-12 10:07:55 +000099 * LCD / IRQ / KEYSC / IrDA
Kuninori Morimoto17ccb832010-02-23 07:07:01 +0000100 *
Kuninori Morimotodda128d2010-03-12 10:07:55 +0000101 * IRQ = IRQ26 (TS), IRQ27 (VIO), IRQ28 (TouchScreen)
102 * LCD = 2nd LCDC
103 *
104 * | SW43 |
105 * SW3 | ON | OFF |
106 * -------------+-----------------------+---------------+
107 * ON | KEY / IrDA | LCD |
108 * OFF | KEY / IrDA / IRQ | IRQ |
Kuninori Morimoto17ccb832010-02-23 07:07:01 +0000109 */
110
Kuninori Morimotofb54d262010-04-13 06:16:32 +0000111/*
112 * USB
113 *
114 * J7 : 1-2 MAX3355E VBUS
115 * 2-3 DC 5.0V
116 *
117 * S39: bit2: off
118 */
119
Kuninori Morimotocb9215e2010-05-24 06:50:44 +0000120/*
121 * FSI/FSMI
122 *
123 * SW41 : ON : SH-Mobile AP4 Audio Mode
124 * : OFF : Bluetooth Audio Mode
125 */
126
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000127/* MTD */
Magnus Damm2b7eda62010-02-05 11:14:58 +0000128static struct mtd_partition nor_flash_partitions[] = {
129 {
130 .name = "loader",
131 .offset = 0x00000000,
132 .size = 512 * 1024,
133 },
134 {
135 .name = "bootenv",
136 .offset = MTDPART_OFS_APPEND,
137 .size = 512 * 1024,
138 },
139 {
140 .name = "kernel_ro",
141 .offset = MTDPART_OFS_APPEND,
142 .size = 8 * 1024 * 1024,
143 .mask_flags = MTD_WRITEABLE,
144 },
145 {
146 .name = "kernel",
147 .offset = MTDPART_OFS_APPEND,
148 .size = 8 * 1024 * 1024,
149 },
150 {
151 .name = "data",
152 .offset = MTDPART_OFS_APPEND,
153 .size = MTDPART_SIZ_FULL,
154 },
155};
156
157static struct physmap_flash_data nor_flash_data = {
158 .width = 2,
159 .parts = nor_flash_partitions,
160 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
161};
162
163static struct resource nor_flash_resources[] = {
164 [0] = {
165 .start = 0x00000000,
166 .end = 0x08000000 - 1,
167 .flags = IORESOURCE_MEM,
168 }
169};
170
171static struct platform_device nor_flash_device = {
172 .name = "physmap-flash",
173 .dev = {
174 .platform_data = &nor_flash_data,
175 },
176 .num_resources = ARRAY_SIZE(nor_flash_resources),
177 .resource = nor_flash_resources,
178};
179
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000180/* SMSC 9220 */
181static struct resource smc911x_resources[] = {
182 {
183 .start = 0x14000000,
184 .end = 0x16000000 - 1,
185 .flags = IORESOURCE_MEM,
186 }, {
Magnus Damm33c96072010-05-20 14:41:00 +0000187 .start = evt2irq(0x02c0) /* IRQ6A */,
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000188 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
189 },
190};
191
192static struct smsc911x_platform_config smsc911x_info = {
193 .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
194 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
195 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
196};
197
198static struct platform_device smc911x_device = {
199 .name = "smsc911x",
200 .id = -1,
201 .num_resources = ARRAY_SIZE(smc911x_resources),
202 .resource = smc911x_resources,
203 .dev = {
204 .platform_data = &smsc911x_info,
205 },
206};
Magnus Damm2b7eda62010-02-05 11:14:58 +0000207
Kuninori Morimoto17ccb832010-02-23 07:07:01 +0000208/* KEYSC (Needs SW43 set to ON) */
209static struct sh_keysc_info keysc_info = {
210 .mode = SH_KEYSC_MODE_1,
211 .scan_timing = 3,
212 .delay = 2500,
213 .keycodes = {
214 KEY_0, KEY_1, KEY_2, KEY_3, KEY_4,
215 KEY_5, KEY_6, KEY_7, KEY_8, KEY_9,
216 KEY_A, KEY_B, KEY_C, KEY_D, KEY_E,
217 KEY_F, KEY_G, KEY_H, KEY_I, KEY_J,
218 KEY_K, KEY_L, KEY_M, KEY_N, KEY_O,
219 },
220};
221
222static struct resource keysc_resources[] = {
223 [0] = {
224 .name = "KEYSC",
225 .start = 0xe61b0000,
226 .end = 0xe61b0063,
227 .flags = IORESOURCE_MEM,
228 },
229 [1] = {
Magnus Damm33c96072010-05-20 14:41:00 +0000230 .start = evt2irq(0x0be0), /* KEYSC_KEY */
Kuninori Morimoto17ccb832010-02-23 07:07:01 +0000231 .flags = IORESOURCE_IRQ,
232 },
233};
234
235static struct platform_device keysc_device = {
236 .name = "sh_keysc",
237 .id = 0, /* "keysc0" clock */
238 .num_resources = ARRAY_SIZE(keysc_resources),
239 .resource = keysc_resources,
240 .dev = {
241 .platform_data = &keysc_info,
242 },
243};
244
Magnus Damm3a14d032010-03-10 09:26:44 +0000245/* SDHI0 */
Guennadi Liakhovetski69bf6f42010-05-04 14:07:15 +0000246static struct sh_mobile_sdhi_info sdhi0_info = {
247 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
248 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
249};
250
Magnus Damm3a14d032010-03-10 09:26:44 +0000251static struct resource sdhi0_resources[] = {
252 [0] = {
253 .name = "SDHI0",
254 .start = 0xe6850000,
255 .end = 0xe68501ff,
256 .flags = IORESOURCE_MEM,
257 },
258 [1] = {
Magnus Damm33c96072010-05-20 14:41:00 +0000259 .start = evt2irq(0x0e00) /* SDHI0 */,
Magnus Damm3a14d032010-03-10 09:26:44 +0000260 .flags = IORESOURCE_IRQ,
261 },
262};
263
264static struct platform_device sdhi0_device = {
265 .name = "sh_mobile_sdhi",
266 .num_resources = ARRAY_SIZE(sdhi0_resources),
267 .resource = sdhi0_resources,
268 .id = 0,
Guennadi Liakhovetski69bf6f42010-05-04 14:07:15 +0000269 .dev = {
270 .platform_data = &sdhi0_info,
271 },
Magnus Damm3a14d032010-03-10 09:26:44 +0000272};
273
Kuninori Morimotofb54d262010-04-13 06:16:32 +0000274/* USB1 */
275void usb1_host_port_power(int port, int power)
276{
277 if (!power) /* only power-on supported for now */
278 return;
279
280 /* set VBOUT/PWEN and EXTLP1 in DVSTCTR */
281 __raw_writew(__raw_readw(0xE68B0008) | 0x600, 0xE68B0008);
282}
283
284static struct r8a66597_platdata usb1_host_data = {
285 .on_chip = 1,
286 .port_power = usb1_host_port_power,
287};
288
289static struct resource usb1_host_resources[] = {
290 [0] = {
291 .name = "USBHS",
292 .start = 0xE68B0000,
293 .end = 0xE68B00E6 - 1,
294 .flags = IORESOURCE_MEM,
295 },
296 [1] = {
Magnus Damm33c96072010-05-20 14:41:00 +0000297 .start = evt2irq(0x1ce0) /* USB1_USB1I0 */,
Kuninori Morimotofb54d262010-04-13 06:16:32 +0000298 .flags = IORESOURCE_IRQ,
299 },
300};
301
302static struct platform_device usb1_host_device = {
303 .name = "r8a66597_hcd",
304 .id = 1,
305 .dev = {
306 .dma_mask = NULL, /* not use dma */
307 .coherent_dma_mask = 0xffffffff,
308 .platform_data = &usb1_host_data,
309 },
310 .num_resources = ARRAY_SIZE(usb1_host_resources),
311 .resource = usb1_host_resources,
312};
313
Guennadi Liakhovetski8eda2f22010-05-23 14:04:03 +0000314static struct sh_mobile_lcdc_info sh_mobile_lcdc_info = {
315 .clock_source = LCDC_CLK_PERIPHERAL, /* One of interface clocks */
316 .ch[0] = {
317 .chan = LCDC_CHAN_MAINLCD,
318 .bpp = 16,
319 .interface_type = RGB24,
320 .clock_divider = 1,
321 .flags = LCDC_FLAGS_DWPOL,
322 .lcd_cfg = {
323 .name = "R63302(QHD)",
324 .xres = 544,
325 .yres = 961,
326 .left_margin = 72,
327 .right_margin = 600,
328 .hsync_len = 16,
329 .upper_margin = 8,
330 .lower_margin = 8,
331 .vsync_len = 2,
332 .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
333 },
334 .lcd_size_cfg = {
335 .width = 44,
336 .height = 79,
337 },
338 }
339};
340
341static struct resource lcdc_resources[] = {
342 [0] = {
343 .name = "LCDC",
344 .start = 0xfe940000, /* P4-only space */
345 .end = 0xfe943fff,
346 .flags = IORESOURCE_MEM,
347 },
348 [1] = {
349 .start = intcs_evt2irq(0x580),
350 .flags = IORESOURCE_IRQ,
351 },
352};
353
354static struct platform_device lcdc_device = {
355 .name = "sh_mobile_lcdc_fb",
356 .num_resources = ARRAY_SIZE(lcdc_resources),
357 .resource = lcdc_resources,
358 .dev = {
359 .platform_data = &sh_mobile_lcdc_info,
360 .coherent_dma_mask = ~0,
361 },
362};
363
364static struct resource mipidsi0_resources[] = {
365 [0] = {
366 .start = 0xffc60000,
367 .end = 0xffc68fff,
368 .flags = IORESOURCE_MEM,
369 },
370};
371
372static struct sh_mipi_dsi_info mipidsi0_info = {
373 .data_format = MIPI_RGB888,
374 .lcd_chan = &sh_mobile_lcdc_info.ch[0],
375};
376
377static struct platform_device mipidsi0_device = {
378 .name = "sh-mipi-dsi",
379 .num_resources = ARRAY_SIZE(mipidsi0_resources),
380 .resource = mipidsi0_resources,
381 .id = 0,
382 .dev = {
383 .platform_data = &mipidsi0_info,
384 },
385};
386
Kuninori Morimotocb9215e2010-05-24 06:50:44 +0000387/* FSI */
388#define IRQ_FSI evt2irq(0x1840)
389#define FSIACKCR 0xE6150018
390static void fsiackcr_init(struct clk *clk)
391{
392 u32 status = __raw_readl(clk->enable_reg);
393
394 /* use external clock */
395 status &= ~0x000000ff;
396 status |= 0x00000080;
397 __raw_writel(status, clk->enable_reg);
398}
399
400static struct clk_ops fsiackcr_clk_ops = {
401 .init = fsiackcr_init,
402};
403
404static struct clk fsiackcr_clk = {
405 .ops = &fsiackcr_clk_ops,
406 .enable_reg = (void __iomem *)FSIACKCR,
407 .rate = 0, /* unknown */
408};
409
410struct sh_fsi_platform_info fsi_info = {
411 .porta_flags = SH_FSI_BRS_INV |
412 SH_FSI_OUT_SLAVE_MODE |
413 SH_FSI_IN_SLAVE_MODE |
414 SH_FSI_OFMT(PCM) |
415 SH_FSI_IFMT(PCM),
416};
417
418static struct resource fsi_resources[] = {
419 [0] = {
420 .name = "FSI",
421 .start = 0xFE3C0000,
422 .end = 0xFE3C0400 - 1,
423 .flags = IORESOURCE_MEM,
424 },
425 [1] = {
426 .start = IRQ_FSI,
427 .flags = IORESOURCE_IRQ,
428 },
429};
430
431static struct platform_device fsi_device = {
432 .name = "sh_fsi2",
433 .id = 0,
434 .num_resources = ARRAY_SIZE(fsi_resources),
435 .resource = fsi_resources,
436 .dev = {
437 .platform_data = &fsi_info,
438 },
439};
440
Magnus Damm2b7eda62010-02-05 11:14:58 +0000441static struct platform_device *ap4evb_devices[] __initdata = {
442 &nor_flash_device,
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000443 &smc911x_device,
Kuninori Morimoto17ccb832010-02-23 07:07:01 +0000444 &keysc_device,
Magnus Damm3a14d032010-03-10 09:26:44 +0000445 &sdhi0_device,
Kuninori Morimotofb54d262010-04-13 06:16:32 +0000446 &usb1_host_device,
Guennadi Liakhovetski8eda2f22010-05-23 14:04:03 +0000447 &lcdc_device,
448 &mipidsi0_device,
Kuninori Morimotocb9215e2010-05-24 06:50:44 +0000449 &fsi_device,
Magnus Damm2b7eda62010-02-05 11:14:58 +0000450};
451
Kuninori Morimotodda128d2010-03-12 10:07:55 +0000452/* TouchScreen (Needs SW3 set to OFF) */
Magnus Damm33c96072010-05-20 14:41:00 +0000453#define IRQ28 evt2irq(0x3380) /* IRQ28A */
Kuninori Morimoto91cf5082010-03-11 10:42:52 +0000454struct tsc2007_platform_data tsc2007_info = {
455 .model = 2007,
456 .x_plate_ohms = 180,
457};
458
459/* I2C */
Kuninori Morimotocb9215e2010-05-24 06:50:44 +0000460static struct i2c_board_info i2c0_devices[] = {
461 {
462 I2C_BOARD_INFO("ak4643", 0x13),
463 },
464};
465
Kuninori Morimoto91cf5082010-03-11 10:42:52 +0000466static struct i2c_board_info i2c1_devices[] = {
467 {
Kuninori Morimoto8fc883c2010-03-11 07:34:37 +0000468 I2C_BOARD_INFO("r2025sd", 0x32),
469 },
470 {
Kuninori Morimoto91cf5082010-03-11 10:42:52 +0000471 I2C_BOARD_INFO("tsc2007", 0x48),
472 .type = "tsc2007",
473 .platform_data = &tsc2007_info,
474 .irq = IRQ28,
475 },
476};
477
Magnus Damm2b7eda62010-02-05 11:14:58 +0000478static struct map_desc ap4evb_io_desc[] __initdata = {
479 /* create a 1:1 entity map for 0xe6xxxxxx
480 * used by CPGA, INTC and PFC.
481 */
482 {
483 .virtual = 0xe6000000,
484 .pfn = __phys_to_pfn(0xe6000000),
485 .length = 256 << 20,
486 .type = MT_DEVICE_NONSHARED
487 },
488};
489
490static void __init ap4evb_map_io(void)
491{
492 iotable_init(ap4evb_io_desc, ARRAY_SIZE(ap4evb_io_desc));
493
Magnus Damm495b3ce2010-05-12 14:21:34 +0000494 /* setup early devices and console here as well */
Magnus Damm2b7eda62010-02-05 11:14:58 +0000495 sh7372_add_early_devices();
Magnus Damm4ae04ac2010-02-08 11:02:54 +0000496 shmobile_setup_console();
Magnus Damm2b7eda62010-02-05 11:14:58 +0000497}
498
Guennadi Liakhovetski8eda2f22010-05-23 14:04:03 +0000499/* This function will disappear when we switch to (runtime) PM */
500static int __init ap4evb_init_display_clk(void)
501{
502 struct clk *lcdc_clk;
503 struct clk *dsitx_clk;
504 int ret;
505
506 lcdc_clk = clk_get(&lcdc_device.dev, "sh_mobile_lcdc_fb.0");
507 if (IS_ERR(lcdc_clk))
508 return PTR_ERR(lcdc_clk);
509
510 dsitx_clk = clk_get(&mipidsi0_device.dev, "sh-mipi-dsi.0");
511 if (IS_ERR(dsitx_clk)) {
512 ret = PTR_ERR(dsitx_clk);
513 goto eclkdsitxget;
514 }
515
516 ret = clk_enable(lcdc_clk);
517 if (ret < 0)
518 goto eclklcdcon;
519
520 ret = clk_enable(dsitx_clk);
521 if (ret < 0)
522 goto eclkdsitxon;
523
524 return 0;
525
526eclkdsitxon:
527 clk_disable(lcdc_clk);
528eclklcdcon:
529 clk_put(dsitx_clk);
530eclkdsitxget:
531 clk_put(lcdc_clk);
532
533 return ret;
534}
535
536device_initcall(ap4evb_init_display_clk);
537
Kuninori Morimotocb9215e2010-05-24 06:50:44 +0000538/*
539 * FIXME !!
540 *
541 * gpio_no_direction is quick_hack.
542 *
543 * current gpio frame work doesn't have
544 * the method to control only pull up/down/free.
545 * this function should be replaced by correct gpio function
546 */
547static void __init gpio_no_direction(u32 addr)
548{
549 __raw_writeb(0x00, addr);
550}
551
552#define GPIO_PORT9CR 0xE6051009
553#define GPIO_PORT10CR 0xE605100A
554
Magnus Damm2b7eda62010-02-05 11:14:58 +0000555static void __init ap4evb_init(void)
556{
Kuninori Morimotocb9215e2010-05-24 06:50:44 +0000557 struct clk *clk;
558
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000559 sh7372_pinmux_init();
560
Kuninori Morimotob228b482010-02-18 16:44:41 +0900561 /* enable SCIFA0 */
562 gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
563 gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
564
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000565 /* enable SMSC911X */
566 gpio_request(GPIO_FN_CS5A, NULL);
567 gpio_request(GPIO_FN_IRQ6_39, NULL);
568
Kuninori Morimoto50982802010-02-22 09:20:39 +0000569 /* enable LED 1 - 4 */
570 gpio_request(GPIO_PORT185, NULL);
571 gpio_request(GPIO_PORT186, NULL);
572 gpio_request(GPIO_PORT187, NULL);
573 gpio_request(GPIO_PORT188, NULL);
574 gpio_direction_output(GPIO_PORT185, 1);
575 gpio_direction_output(GPIO_PORT186, 1);
576 gpio_direction_output(GPIO_PORT187, 1);
577 gpio_direction_output(GPIO_PORT188, 1);
578 gpio_export(GPIO_PORT185, 0);
579 gpio_export(GPIO_PORT186, 0);
580 gpio_export(GPIO_PORT187, 0);
581 gpio_export(GPIO_PORT188, 0);
582
Kuninori Morimoto8cb3a2e2010-02-22 09:30:12 +0000583 /* enable Debug switch (S6) */
584 gpio_request(GPIO_PORT32, NULL);
585 gpio_request(GPIO_PORT33, NULL);
586 gpio_request(GPIO_PORT34, NULL);
587 gpio_request(GPIO_PORT35, NULL);
588 gpio_direction_input(GPIO_PORT32);
589 gpio_direction_input(GPIO_PORT33);
590 gpio_direction_input(GPIO_PORT34);
591 gpio_direction_input(GPIO_PORT35);
592 gpio_export(GPIO_PORT32, 0);
593 gpio_export(GPIO_PORT33, 0);
594 gpio_export(GPIO_PORT34, 0);
595 gpio_export(GPIO_PORT35, 0);
596
Kuninori Morimoto17ccb832010-02-23 07:07:01 +0000597 /* enable KEYSC */
598 gpio_request(GPIO_FN_KEYOUT0, NULL);
599 gpio_request(GPIO_FN_KEYOUT1, NULL);
600 gpio_request(GPIO_FN_KEYOUT2, NULL);
601 gpio_request(GPIO_FN_KEYOUT3, NULL);
602 gpio_request(GPIO_FN_KEYOUT4, NULL);
603 gpio_request(GPIO_FN_KEYIN0_136, NULL);
604 gpio_request(GPIO_FN_KEYIN1_135, NULL);
605 gpio_request(GPIO_FN_KEYIN2_134, NULL);
606 gpio_request(GPIO_FN_KEYIN3_133, NULL);
607 gpio_request(GPIO_FN_KEYIN4, NULL);
608
Magnus Damm3a14d032010-03-10 09:26:44 +0000609 /* SDHI0 */
610 gpio_request(GPIO_FN_SDHICD0, NULL);
611 gpio_request(GPIO_FN_SDHIWP0, NULL);
612 gpio_request(GPIO_FN_SDHICMD0, NULL);
613 gpio_request(GPIO_FN_SDHICLK0, NULL);
614 gpio_request(GPIO_FN_SDHID0_3, NULL);
615 gpio_request(GPIO_FN_SDHID0_2, NULL);
616 gpio_request(GPIO_FN_SDHID0_1, NULL);
617 gpio_request(GPIO_FN_SDHID0_0, NULL);
618
Kuninori Morimoto91cf5082010-03-11 10:42:52 +0000619 /* enable TouchScreen */
620 gpio_request(GPIO_FN_IRQ28_123, NULL);
621 set_irq_type(IRQ28, IRQ_TYPE_LEVEL_LOW);
622
Kuninori Morimotofb54d262010-04-13 06:16:32 +0000623 /* USB enable */
624 gpio_request(GPIO_FN_VBUS0_1, NULL);
625 gpio_request(GPIO_FN_IDIN_1_18, NULL);
626 gpio_request(GPIO_FN_PWEN_1_115, NULL);
627 gpio_request(GPIO_FN_OVCN_1_114, NULL);
628 gpio_request(GPIO_FN_EXTLP_1, NULL);
629 gpio_request(GPIO_FN_OVCN2_1, NULL);
630
631 /* setup USB phy */
632 __raw_writew(0x8a0a, 0xE6058130); /* USBCR2 */
633
Kuninori Morimotocb9215e2010-05-24 06:50:44 +0000634 /* enable FSI2 */
635 gpio_request(GPIO_FN_FSIAIBT, NULL);
636 gpio_request(GPIO_FN_FSIAILR, NULL);
637 gpio_request(GPIO_FN_FSIAISLD, NULL);
638 gpio_request(GPIO_FN_FSIAOSLD, NULL);
639 gpio_request(GPIO_PORT161, NULL);
640 gpio_direction_output(GPIO_PORT161, 0); /* slave */
641
642 gpio_request(GPIO_PORT9, NULL);
643 gpio_request(GPIO_PORT10, NULL);
644 gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */
645 gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */
646
647 /* set SPU2 clock to 119.6 MHz */
648 clk = clk_get(NULL, "spu_clk");
649 if (!IS_ERR_VALUE(clk)) {
650 clk_set_rate(clk, clk_round_rate(clk, 119600000));
651 clk_put(clk);
652 }
653
654 /* change parent of FSI A */
655 clk = clk_get(NULL, "fsia_clk");
656 if (!IS_ERR_VALUE(clk)) {
657 clk_register(&fsiackcr_clk);
658 clk_set_parent(clk, &fsiackcr_clk);
659 clk_put(clk);
660 }
661
662 /*
663 * set irq priority, to avoid sound chopping
664 * when NFS rootfs is used
665 * FSI(3) > SMSC911X(2)
666 */
667 intc_set_priority(IRQ_FSI, 3);
668
669 i2c_register_board_info(0, i2c0_devices,
670 ARRAY_SIZE(i2c0_devices));
671
672 i2c_register_board_info(1, i2c1_devices,
673 ARRAY_SIZE(i2c1_devices));
674
Magnus Damm2b7eda62010-02-05 11:14:58 +0000675 sh7372_add_standard_devices();
676
677 platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices));
678}
679
Magnus Damm495b3ce2010-05-12 14:21:34 +0000680static void __init ap4evb_timer_init(void)
681{
682 sh7372_clock_init();
683 shmobile_timer.init();
684}
685
686static struct sys_timer ap4evb_timer = {
687 .init = ap4evb_timer_init,
688};
689
Magnus Damm2b7eda62010-02-05 11:14:58 +0000690MACHINE_START(AP4EVB, "ap4evb")
691 .phys_io = 0xe6000000,
692 .io_pg_offst = ((0xe6000000) >> 18) & 0xfffc,
693 .map_io = ap4evb_map_io,
694 .init_irq = sh7372_init_irq,
695 .init_machine = ap4evb_init,
Magnus Damm495b3ce2010-05-12 14:21:34 +0000696 .timer = &ap4evb_timer,
Magnus Damm2b7eda62010-02-05 11:14:58 +0000697MACHINE_END