blob: 81618ba598e9ba71e407b8ce3a08a44540308261 [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 Morimotodda128d2010-03-12 10:07:55 +0000104 * IRQ = IRQ26 (TS), IRQ27 (VIO), IRQ28 (TouchScreen)
105 * LCD = 2nd LCDC
106 *
107 * | SW43 |
108 * SW3 | ON | OFF |
109 * -------------+-----------------------+---------------+
110 * ON | KEY / IrDA | LCD |
111 * OFF | KEY / IrDA / IRQ | IRQ |
Kuninori Morimoto17ccb832010-02-23 07:07:01 +0000112 */
113
Kuninori Morimotofb54d262010-04-13 06:16:32 +0000114/*
115 * USB
116 *
117 * J7 : 1-2 MAX3355E VBUS
118 * 2-3 DC 5.0V
119 *
120 * S39: bit2: off
121 */
122
Kuninori Morimotocb9215e2010-05-24 06:50:44 +0000123/*
124 * FSI/FSMI
125 *
126 * SW41 : ON : SH-Mobile AP4 Audio Mode
127 * : OFF : Bluetooth Audio Mode
128 */
129
Kuninori Morimotoc8ee3d42010-05-13 01:08:21 +0000130/*
131 * MMC (CN7)
132 *
133 * J22 : 1-2: 1.8v for MMC
134 * 2-3: 3.3v for MMC
135 * SW1 : OFF
136 * SW33: bit1: OFF
137 * bit2: ON
138 * bit3: ON
139 * bit4: X
140 */
141
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000142/* MTD */
Magnus Damm2b7eda62010-02-05 11:14:58 +0000143static struct mtd_partition nor_flash_partitions[] = {
144 {
145 .name = "loader",
146 .offset = 0x00000000,
147 .size = 512 * 1024,
148 },
149 {
150 .name = "bootenv",
151 .offset = MTDPART_OFS_APPEND,
152 .size = 512 * 1024,
153 },
154 {
155 .name = "kernel_ro",
156 .offset = MTDPART_OFS_APPEND,
157 .size = 8 * 1024 * 1024,
158 .mask_flags = MTD_WRITEABLE,
159 },
160 {
161 .name = "kernel",
162 .offset = MTDPART_OFS_APPEND,
163 .size = 8 * 1024 * 1024,
164 },
165 {
166 .name = "data",
167 .offset = MTDPART_OFS_APPEND,
168 .size = MTDPART_SIZ_FULL,
169 },
170};
171
172static struct physmap_flash_data nor_flash_data = {
173 .width = 2,
174 .parts = nor_flash_partitions,
175 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
176};
177
178static struct resource nor_flash_resources[] = {
179 [0] = {
180 .start = 0x00000000,
181 .end = 0x08000000 - 1,
182 .flags = IORESOURCE_MEM,
183 }
184};
185
186static struct platform_device nor_flash_device = {
187 .name = "physmap-flash",
188 .dev = {
189 .platform_data = &nor_flash_data,
190 },
191 .num_resources = ARRAY_SIZE(nor_flash_resources),
192 .resource = nor_flash_resources,
193};
194
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000195/* SMSC 9220 */
196static struct resource smc911x_resources[] = {
197 {
198 .start = 0x14000000,
199 .end = 0x16000000 - 1,
200 .flags = IORESOURCE_MEM,
201 }, {
Magnus Damm33c96072010-05-20 14:41:00 +0000202 .start = evt2irq(0x02c0) /* IRQ6A */,
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000203 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
204 },
205};
206
207static struct smsc911x_platform_config smsc911x_info = {
208 .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
209 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
210 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
211};
212
213static struct platform_device smc911x_device = {
214 .name = "smsc911x",
215 .id = -1,
216 .num_resources = ARRAY_SIZE(smc911x_resources),
217 .resource = smc911x_resources,
218 .dev = {
219 .platform_data = &smsc911x_info,
220 },
221};
Magnus Damm2b7eda62010-02-05 11:14:58 +0000222
Kuninori Morimoto17ccb832010-02-23 07:07:01 +0000223/* KEYSC (Needs SW43 set to ON) */
224static struct sh_keysc_info keysc_info = {
225 .mode = SH_KEYSC_MODE_1,
226 .scan_timing = 3,
227 .delay = 2500,
228 .keycodes = {
229 KEY_0, KEY_1, KEY_2, KEY_3, KEY_4,
230 KEY_5, KEY_6, KEY_7, KEY_8, KEY_9,
231 KEY_A, KEY_B, KEY_C, KEY_D, KEY_E,
232 KEY_F, KEY_G, KEY_H, KEY_I, KEY_J,
233 KEY_K, KEY_L, KEY_M, KEY_N, KEY_O,
234 },
235};
236
237static struct resource keysc_resources[] = {
238 [0] = {
239 .name = "KEYSC",
240 .start = 0xe61b0000,
241 .end = 0xe61b0063,
242 .flags = IORESOURCE_MEM,
243 },
244 [1] = {
Magnus Damm33c96072010-05-20 14:41:00 +0000245 .start = evt2irq(0x0be0), /* KEYSC_KEY */
Kuninori Morimoto17ccb832010-02-23 07:07:01 +0000246 .flags = IORESOURCE_IRQ,
247 },
248};
249
250static struct platform_device keysc_device = {
251 .name = "sh_keysc",
252 .id = 0, /* "keysc0" clock */
253 .num_resources = ARRAY_SIZE(keysc_resources),
254 .resource = keysc_resources,
255 .dev = {
256 .platform_data = &keysc_info,
257 },
258};
259
Kuninori Morimotoc8ee3d42010-05-13 01:08:21 +0000260/* SH_MMCIF */
261static struct resource sh_mmcif_resources[] = {
262 [0] = {
263 .name = "SH_MMCIF",
264 .start = 0xE6BD0000,
265 .end = 0xE6BD00FF,
266 .flags = IORESOURCE_MEM,
267 },
268 [1] = {
269 /* MMC ERR */
270 .start = 198,
271 .flags = IORESOURCE_IRQ,
272 },
273 [2] = {
274 /* MMC NOR */
275 .start = 199,
276 .flags = IORESOURCE_IRQ,
277 },
278};
279
280struct sh_mmcif_plat_data sh_mmcif_plat = {
281 .sup_pclk = 0,
282 .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
283 .caps = MMC_CAP_4_BIT_DATA |
284 MMC_CAP_8_BIT_DATA |
285 MMC_CAP_NEEDS_POLL,
286};
287
288static struct platform_device sh_mmcif_device = {
289 .name = "sh_mmcif",
290 .id = 0,
291 .dev = {
292 .dma_mask = NULL,
293 .coherent_dma_mask = 0xffffffff,
294 .platform_data = &sh_mmcif_plat,
295 },
296 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
297 .resource = sh_mmcif_resources,
298};
299
Magnus Damm3a14d032010-03-10 09:26:44 +0000300/* SDHI0 */
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000301static struct sh_mobile_sdhi_info sdhi0_info = {
Guennadi Liakhovetski341291a2010-05-23 14:12:46 +0000302 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
303 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000304};
305
Magnus Damm3a14d032010-03-10 09:26:44 +0000306static struct resource sdhi0_resources[] = {
307 [0] = {
308 .name = "SDHI0",
309 .start = 0xe6850000,
310 .end = 0xe68501ff,
311 .flags = IORESOURCE_MEM,
312 },
313 [1] = {
Magnus Damm33c96072010-05-20 14:41:00 +0000314 .start = evt2irq(0x0e00) /* SDHI0 */,
Magnus Damm3a14d032010-03-10 09:26:44 +0000315 .flags = IORESOURCE_IRQ,
316 },
317};
318
319static struct platform_device sdhi0_device = {
320 .name = "sh_mobile_sdhi",
321 .num_resources = ARRAY_SIZE(sdhi0_resources),
322 .resource = sdhi0_resources,
323 .id = 0,
Guennadi Liakhovetski69bf6f452010-05-04 14:07:15 +0000324 .dev = {
325 .platform_data = &sdhi0_info,
326 },
Magnus Damm3a14d032010-03-10 09:26:44 +0000327};
328
Guennadi Liakhovetski341291a2010-05-23 14:12:46 +0000329/* SDHI1 */
330static struct sh_mobile_sdhi_info sdhi1_info = {
331 .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
332 .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
333 .tmio_ocr_mask = MMC_VDD_165_195,
334};
335
336static struct resource sdhi1_resources[] = {
337 [0] = {
338 .name = "SDHI1",
339 .start = 0xe6860000,
340 .end = 0xe68601ff,
341 .flags = IORESOURCE_MEM,
342 },
343 [1] = {
344 .start = evt2irq(0x0e80),
345 .flags = IORESOURCE_IRQ,
346 },
347};
348
349static struct platform_device sdhi1_device = {
350 .name = "sh_mobile_sdhi",
351 .num_resources = ARRAY_SIZE(sdhi1_resources),
352 .resource = sdhi1_resources,
353 .id = 1,
354 .dev = {
355 .platform_data = &sdhi1_info,
356 },
357};
358
Kuninori Morimotofb54d262010-04-13 06:16:32 +0000359/* USB1 */
360void usb1_host_port_power(int port, int power)
361{
362 if (!power) /* only power-on supported for now */
363 return;
364
365 /* set VBOUT/PWEN and EXTLP1 in DVSTCTR */
366 __raw_writew(__raw_readw(0xE68B0008) | 0x600, 0xE68B0008);
367}
368
369static struct r8a66597_platdata usb1_host_data = {
370 .on_chip = 1,
371 .port_power = usb1_host_port_power,
372};
373
374static struct resource usb1_host_resources[] = {
375 [0] = {
376 .name = "USBHS",
377 .start = 0xE68B0000,
378 .end = 0xE68B00E6 - 1,
379 .flags = IORESOURCE_MEM,
380 },
381 [1] = {
Magnus Damm33c96072010-05-20 14:41:00 +0000382 .start = evt2irq(0x1ce0) /* USB1_USB1I0 */,
Kuninori Morimotofb54d262010-04-13 06:16:32 +0000383 .flags = IORESOURCE_IRQ,
384 },
385};
386
387static struct platform_device usb1_host_device = {
388 .name = "r8a66597_hcd",
389 .id = 1,
390 .dev = {
391 .dma_mask = NULL, /* not use dma */
392 .coherent_dma_mask = 0xffffffff,
393 .platform_data = &usb1_host_data,
394 },
395 .num_resources = ARRAY_SIZE(usb1_host_resources),
396 .resource = usb1_host_resources,
397};
398
Guennadi Liakhovetski8eda2f22010-05-23 14:04:03 +0000399static struct sh_mobile_lcdc_info sh_mobile_lcdc_info = {
400 .clock_source = LCDC_CLK_PERIPHERAL, /* One of interface clocks */
401 .ch[0] = {
402 .chan = LCDC_CHAN_MAINLCD,
403 .bpp = 16,
404 .interface_type = RGB24,
405 .clock_divider = 1,
406 .flags = LCDC_FLAGS_DWPOL,
407 .lcd_cfg = {
408 .name = "R63302(QHD)",
409 .xres = 544,
410 .yres = 961,
411 .left_margin = 72,
412 .right_margin = 600,
413 .hsync_len = 16,
414 .upper_margin = 8,
415 .lower_margin = 8,
416 .vsync_len = 2,
417 .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
418 },
419 .lcd_size_cfg = {
420 .width = 44,
421 .height = 79,
422 },
423 }
424};
425
426static struct resource lcdc_resources[] = {
427 [0] = {
428 .name = "LCDC",
429 .start = 0xfe940000, /* P4-only space */
430 .end = 0xfe943fff,
431 .flags = IORESOURCE_MEM,
432 },
433 [1] = {
434 .start = intcs_evt2irq(0x580),
435 .flags = IORESOURCE_IRQ,
436 },
437};
438
439static struct platform_device lcdc_device = {
440 .name = "sh_mobile_lcdc_fb",
441 .num_resources = ARRAY_SIZE(lcdc_resources),
442 .resource = lcdc_resources,
443 .dev = {
444 .platform_data = &sh_mobile_lcdc_info,
445 .coherent_dma_mask = ~0,
446 },
447};
448
449static struct resource mipidsi0_resources[] = {
450 [0] = {
451 .start = 0xffc60000,
452 .end = 0xffc68fff,
453 .flags = IORESOURCE_MEM,
454 },
455};
456
457static struct sh_mipi_dsi_info mipidsi0_info = {
458 .data_format = MIPI_RGB888,
459 .lcd_chan = &sh_mobile_lcdc_info.ch[0],
460};
461
462static struct platform_device mipidsi0_device = {
463 .name = "sh-mipi-dsi",
464 .num_resources = ARRAY_SIZE(mipidsi0_resources),
465 .resource = mipidsi0_resources,
466 .id = 0,
467 .dev = {
468 .platform_data = &mipidsi0_info,
469 },
470};
471
Kuninori Morimotocb9215e2010-05-24 06:50:44 +0000472/* FSI */
473#define IRQ_FSI evt2irq(0x1840)
474#define FSIACKCR 0xE6150018
475static void fsiackcr_init(struct clk *clk)
476{
477 u32 status = __raw_readl(clk->enable_reg);
478
479 /* use external clock */
480 status &= ~0x000000ff;
481 status |= 0x00000080;
482 __raw_writel(status, clk->enable_reg);
483}
484
485static struct clk_ops fsiackcr_clk_ops = {
486 .init = fsiackcr_init,
487};
488
489static struct clk fsiackcr_clk = {
490 .ops = &fsiackcr_clk_ops,
491 .enable_reg = (void __iomem *)FSIACKCR,
492 .rate = 0, /* unknown */
493};
494
495struct sh_fsi_platform_info fsi_info = {
496 .porta_flags = SH_FSI_BRS_INV |
497 SH_FSI_OUT_SLAVE_MODE |
498 SH_FSI_IN_SLAVE_MODE |
499 SH_FSI_OFMT(PCM) |
500 SH_FSI_IFMT(PCM),
501};
502
503static struct resource fsi_resources[] = {
504 [0] = {
505 .name = "FSI",
506 .start = 0xFE3C0000,
507 .end = 0xFE3C0400 - 1,
508 .flags = IORESOURCE_MEM,
509 },
510 [1] = {
511 .start = IRQ_FSI,
512 .flags = IORESOURCE_IRQ,
513 },
514};
515
516static struct platform_device fsi_device = {
517 .name = "sh_fsi2",
518 .id = 0,
519 .num_resources = ARRAY_SIZE(fsi_resources),
520 .resource = fsi_resources,
521 .dev = {
522 .platform_data = &fsi_info,
523 },
524};
525
Magnus Damm2b7eda62010-02-05 11:14:58 +0000526static struct platform_device *ap4evb_devices[] __initdata = {
527 &nor_flash_device,
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000528 &smc911x_device,
Kuninori Morimoto17ccb832010-02-23 07:07:01 +0000529 &keysc_device,
Magnus Damm3a14d032010-03-10 09:26:44 +0000530 &sdhi0_device,
Guennadi Liakhovetski341291a2010-05-23 14:12:46 +0000531 &sdhi1_device,
Kuninori Morimotofb54d262010-04-13 06:16:32 +0000532 &usb1_host_device,
Guennadi Liakhovetski8eda2f22010-05-23 14:04:03 +0000533 &lcdc_device,
534 &mipidsi0_device,
Kuninori Morimotocb9215e2010-05-24 06:50:44 +0000535 &fsi_device,
Kuninori Morimotoc8ee3d42010-05-13 01:08:21 +0000536 &sh_mmcif_device
Magnus Damm2b7eda62010-02-05 11:14:58 +0000537};
538
Kuninori Morimotodda128d2010-03-12 10:07:55 +0000539/* TouchScreen (Needs SW3 set to OFF) */
Magnus Damm33c96072010-05-20 14:41:00 +0000540#define IRQ28 evt2irq(0x3380) /* IRQ28A */
Kuninori Morimoto91cf5082010-03-11 10:42:52 +0000541struct tsc2007_platform_data tsc2007_info = {
542 .model = 2007,
543 .x_plate_ohms = 180,
544};
545
546/* I2C */
Kuninori Morimotocb9215e2010-05-24 06:50:44 +0000547static struct i2c_board_info i2c0_devices[] = {
548 {
549 I2C_BOARD_INFO("ak4643", 0x13),
550 },
551};
552
Kuninori Morimoto91cf5082010-03-11 10:42:52 +0000553static struct i2c_board_info i2c1_devices[] = {
554 {
Kuninori Morimoto8fc883c2010-03-11 07:34:37 +0000555 I2C_BOARD_INFO("r2025sd", 0x32),
556 },
557 {
Kuninori Morimoto91cf5082010-03-11 10:42:52 +0000558 I2C_BOARD_INFO("tsc2007", 0x48),
559 .type = "tsc2007",
560 .platform_data = &tsc2007_info,
561 .irq = IRQ28,
562 },
563};
564
Magnus Damm2b7eda62010-02-05 11:14:58 +0000565static struct map_desc ap4evb_io_desc[] __initdata = {
566 /* create a 1:1 entity map for 0xe6xxxxxx
567 * used by CPGA, INTC and PFC.
568 */
569 {
570 .virtual = 0xe6000000,
571 .pfn = __phys_to_pfn(0xe6000000),
572 .length = 256 << 20,
573 .type = MT_DEVICE_NONSHARED
574 },
575};
576
577static void __init ap4evb_map_io(void)
578{
579 iotable_init(ap4evb_io_desc, ARRAY_SIZE(ap4evb_io_desc));
580
Magnus Damm495b3ce2010-05-12 14:21:34 +0000581 /* setup early devices and console here as well */
Magnus Damm2b7eda62010-02-05 11:14:58 +0000582 sh7372_add_early_devices();
Magnus Damm4ae04ac2010-02-08 11:02:54 +0000583 shmobile_setup_console();
Magnus Damm2b7eda62010-02-05 11:14:58 +0000584}
585
Guennadi Liakhovetski8eda2f22010-05-23 14:04:03 +0000586/* This function will disappear when we switch to (runtime) PM */
587static int __init ap4evb_init_display_clk(void)
588{
589 struct clk *lcdc_clk;
590 struct clk *dsitx_clk;
591 int ret;
592
593 lcdc_clk = clk_get(&lcdc_device.dev, "sh_mobile_lcdc_fb.0");
594 if (IS_ERR(lcdc_clk))
595 return PTR_ERR(lcdc_clk);
596
597 dsitx_clk = clk_get(&mipidsi0_device.dev, "sh-mipi-dsi.0");
598 if (IS_ERR(dsitx_clk)) {
599 ret = PTR_ERR(dsitx_clk);
600 goto eclkdsitxget;
601 }
602
603 ret = clk_enable(lcdc_clk);
604 if (ret < 0)
605 goto eclklcdcon;
606
607 ret = clk_enable(dsitx_clk);
608 if (ret < 0)
609 goto eclkdsitxon;
610
611 return 0;
612
613eclkdsitxon:
614 clk_disable(lcdc_clk);
615eclklcdcon:
616 clk_put(dsitx_clk);
617eclkdsitxget:
618 clk_put(lcdc_clk);
619
620 return ret;
621}
622
623device_initcall(ap4evb_init_display_clk);
624
Kuninori Morimotocb9215e2010-05-24 06:50:44 +0000625/*
626 * FIXME !!
627 *
628 * gpio_no_direction is quick_hack.
629 *
630 * current gpio frame work doesn't have
631 * the method to control only pull up/down/free.
632 * this function should be replaced by correct gpio function
633 */
634static void __init gpio_no_direction(u32 addr)
635{
636 __raw_writeb(0x00, addr);
637}
638
639#define GPIO_PORT9CR 0xE6051009
640#define GPIO_PORT10CR 0xE605100A
641
Magnus Damm2b7eda62010-02-05 11:14:58 +0000642static void __init ap4evb_init(void)
643{
Kuninori Morimotocb9215e2010-05-24 06:50:44 +0000644 struct clk *clk;
645
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000646 sh7372_pinmux_init();
647
Kuninori Morimotob228b482010-02-18 16:44:41 +0900648 /* enable SCIFA0 */
649 gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
650 gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
651
Kuninori Morimoto1b7e0672010-02-17 09:30:14 +0000652 /* enable SMSC911X */
653 gpio_request(GPIO_FN_CS5A, NULL);
654 gpio_request(GPIO_FN_IRQ6_39, NULL);
655
Kuninori Morimoto50982802010-02-22 09:20:39 +0000656 /* enable LED 1 - 4 */
657 gpio_request(GPIO_PORT185, NULL);
658 gpio_request(GPIO_PORT186, NULL);
659 gpio_request(GPIO_PORT187, NULL);
660 gpio_request(GPIO_PORT188, NULL);
661 gpio_direction_output(GPIO_PORT185, 1);
662 gpio_direction_output(GPIO_PORT186, 1);
663 gpio_direction_output(GPIO_PORT187, 1);
664 gpio_direction_output(GPIO_PORT188, 1);
665 gpio_export(GPIO_PORT185, 0);
666 gpio_export(GPIO_PORT186, 0);
667 gpio_export(GPIO_PORT187, 0);
668 gpio_export(GPIO_PORT188, 0);
669
Kuninori Morimoto8cb3a2e2010-02-22 09:30:12 +0000670 /* enable Debug switch (S6) */
671 gpio_request(GPIO_PORT32, NULL);
672 gpio_request(GPIO_PORT33, NULL);
673 gpio_request(GPIO_PORT34, NULL);
674 gpio_request(GPIO_PORT35, NULL);
675 gpio_direction_input(GPIO_PORT32);
676 gpio_direction_input(GPIO_PORT33);
677 gpio_direction_input(GPIO_PORT34);
678 gpio_direction_input(GPIO_PORT35);
679 gpio_export(GPIO_PORT32, 0);
680 gpio_export(GPIO_PORT33, 0);
681 gpio_export(GPIO_PORT34, 0);
682 gpio_export(GPIO_PORT35, 0);
683
Kuninori Morimoto17ccb832010-02-23 07:07:01 +0000684 /* enable KEYSC */
685 gpio_request(GPIO_FN_KEYOUT0, NULL);
686 gpio_request(GPIO_FN_KEYOUT1, NULL);
687 gpio_request(GPIO_FN_KEYOUT2, NULL);
688 gpio_request(GPIO_FN_KEYOUT3, NULL);
689 gpio_request(GPIO_FN_KEYOUT4, NULL);
690 gpio_request(GPIO_FN_KEYIN0_136, NULL);
691 gpio_request(GPIO_FN_KEYIN1_135, NULL);
692 gpio_request(GPIO_FN_KEYIN2_134, NULL);
693 gpio_request(GPIO_FN_KEYIN3_133, NULL);
694 gpio_request(GPIO_FN_KEYIN4, NULL);
695
Magnus Damm3a14d032010-03-10 09:26:44 +0000696 /* SDHI0 */
697 gpio_request(GPIO_FN_SDHICD0, NULL);
698 gpio_request(GPIO_FN_SDHIWP0, NULL);
699 gpio_request(GPIO_FN_SDHICMD0, NULL);
700 gpio_request(GPIO_FN_SDHICLK0, NULL);
701 gpio_request(GPIO_FN_SDHID0_3, NULL);
702 gpio_request(GPIO_FN_SDHID0_2, NULL);
703 gpio_request(GPIO_FN_SDHID0_1, NULL);
704 gpio_request(GPIO_FN_SDHID0_0, NULL);
705
Kuninori Morimoto91cf5082010-03-11 10:42:52 +0000706 /* enable TouchScreen */
707 gpio_request(GPIO_FN_IRQ28_123, NULL);
708 set_irq_type(IRQ28, IRQ_TYPE_LEVEL_LOW);
709
Kuninori Morimotoc8ee3d42010-05-13 01:08:21 +0000710 /* MMCIF */
711 gpio_request(GPIO_FN_MMCD0_0, NULL);
712 gpio_request(GPIO_FN_MMCD0_1, NULL);
713 gpio_request(GPIO_FN_MMCD0_2, NULL);
714 gpio_request(GPIO_FN_MMCD0_3, NULL);
715 gpio_request(GPIO_FN_MMCD0_4, NULL);
716 gpio_request(GPIO_FN_MMCD0_5, NULL);
717 gpio_request(GPIO_FN_MMCD0_6, NULL);
718 gpio_request(GPIO_FN_MMCD0_7, NULL);
719 gpio_request(GPIO_FN_MMCCMD0, NULL);
720 gpio_request(GPIO_FN_MMCCLK0, NULL);
721
Kuninori Morimotofb54d262010-04-13 06:16:32 +0000722 /* USB enable */
723 gpio_request(GPIO_FN_VBUS0_1, NULL);
724 gpio_request(GPIO_FN_IDIN_1_18, NULL);
725 gpio_request(GPIO_FN_PWEN_1_115, NULL);
726 gpio_request(GPIO_FN_OVCN_1_114, NULL);
727 gpio_request(GPIO_FN_EXTLP_1, NULL);
728 gpio_request(GPIO_FN_OVCN2_1, NULL);
729
730 /* setup USB phy */
731 __raw_writew(0x8a0a, 0xE6058130); /* USBCR2 */
732
Kuninori Morimotocb9215e2010-05-24 06:50:44 +0000733 /* enable FSI2 */
734 gpio_request(GPIO_FN_FSIAIBT, NULL);
735 gpio_request(GPIO_FN_FSIAILR, NULL);
736 gpio_request(GPIO_FN_FSIAISLD, NULL);
737 gpio_request(GPIO_FN_FSIAOSLD, NULL);
738 gpio_request(GPIO_PORT161, NULL);
739 gpio_direction_output(GPIO_PORT161, 0); /* slave */
740
741 gpio_request(GPIO_PORT9, NULL);
742 gpio_request(GPIO_PORT10, NULL);
743 gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */
744 gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */
745
746 /* set SPU2 clock to 119.6 MHz */
747 clk = clk_get(NULL, "spu_clk");
748 if (!IS_ERR_VALUE(clk)) {
749 clk_set_rate(clk, clk_round_rate(clk, 119600000));
750 clk_put(clk);
751 }
752
753 /* change parent of FSI A */
754 clk = clk_get(NULL, "fsia_clk");
755 if (!IS_ERR_VALUE(clk)) {
756 clk_register(&fsiackcr_clk);
757 clk_set_parent(clk, &fsiackcr_clk);
758 clk_put(clk);
759 }
760
761 /*
762 * set irq priority, to avoid sound chopping
763 * when NFS rootfs is used
764 * FSI(3) > SMSC911X(2)
765 */
766 intc_set_priority(IRQ_FSI, 3);
767
768 i2c_register_board_info(0, i2c0_devices,
769 ARRAY_SIZE(i2c0_devices));
770
771 i2c_register_board_info(1, i2c1_devices,
772 ARRAY_SIZE(i2c1_devices));
773
Guennadi Liakhovetski341291a2010-05-23 14:12:46 +0000774 /* SDHI1 */
775 gpio_request(GPIO_FN_SDHICMD1, NULL);
776 gpio_request(GPIO_FN_SDHICLK1, NULL);
777 gpio_request(GPIO_FN_SDHID1_3, NULL);
778 gpio_request(GPIO_FN_SDHID1_2, NULL);
779 gpio_request(GPIO_FN_SDHID1_1, NULL);
780 gpio_request(GPIO_FN_SDHID1_0, NULL);
781
Magnus Damm2b7eda62010-02-05 11:14:58 +0000782 sh7372_add_standard_devices();
783
784 platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices));
785}
786
Magnus Damm495b3ce2010-05-12 14:21:34 +0000787static void __init ap4evb_timer_init(void)
788{
789 sh7372_clock_init();
790 shmobile_timer.init();
791}
792
793static struct sys_timer ap4evb_timer = {
794 .init = ap4evb_timer_init,
795};
796
Magnus Damm2b7eda62010-02-05 11:14:58 +0000797MACHINE_START(AP4EVB, "ap4evb")
798 .phys_io = 0xe6000000,
799 .io_pg_offst = ((0xe6000000) >> 18) & 0xfffc,
800 .map_io = ap4evb_map_io,
801 .init_irq = sh7372_init_irq,
802 .init_machine = ap4evb_init,
Magnus Damm495b3ce2010-05-12 14:21:34 +0000803 .timer = &ap4evb_timer,
Magnus Damm2b7eda62010-02-05 11:14:58 +0000804MACHINE_END