Commit | Line | Data |
---|---|---|
2b7eda63 MD |
1 | /* |
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 | */ | |
8eda2f21 | 20 | #include <linux/clk.h> |
2b7eda63 MD |
21 | #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> | |
69bf6f45 | 27 | #include <linux/mfd/sh_mobile_sdhi.h> |
2b7eda63 MD |
28 | #include <linux/mtd/mtd.h> |
29 | #include <linux/mtd/partitions.h> | |
30 | #include <linux/mtd/physmap.h> | |
c8ee3d4b KM |
31 | #include <linux/mmc/host.h> |
32 | #include <linux/mmc/sh_mmcif.h> | |
91cf5082 KM |
33 | #include <linux/i2c.h> |
34 | #include <linux/i2c/tsc2007.h> | |
2b7eda63 | 35 | #include <linux/io.h> |
1b7e0677 | 36 | #include <linux/smsc911x.h> |
cb9215e1 KM |
37 | #include <linux/sh_intc.h> |
38 | #include <linux/sh_clk.h> | |
1b7e0677 | 39 | #include <linux/gpio.h> |
17ccb834 KM |
40 | #include <linux/input.h> |
41 | #include <linux/input/sh_keysc.h> | |
fb54d268 | 42 | #include <linux/usb/r8a66597.h> |
8eda2f21 | 43 | |
cb9215e1 KM |
44 | #include <sound/sh_fsi.h> |
45 | ||
8eda2f21 GL |
46 | #include <video/sh_mobile_lcdc.h> |
47 | #include <video/sh_mipi_dsi.h> | |
48 | ||
2b7eda63 | 49 | #include <mach/common.h> |
8eda2f21 | 50 | #include <mach/irqs.h> |
1b7e0677 | 51 | #include <mach/sh7372.h> |
8eda2f21 | 52 | |
2b7eda63 MD |
53 | #include <asm/mach-types.h> |
54 | #include <asm/mach/arch.h> | |
55 | #include <asm/mach/map.h> | |
495b3cea | 56 | #include <asm/mach/time.h> |
2b7eda63 | 57 | |
02624a17 KM |
58 | /* |
59 | * Address Interface BusWidth note | |
60 | * ------------------------------------------------------------------ | |
61 | * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON | |
62 | * 0x0800_0000 user area - | |
63 | * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF | |
64 | * 0x1400_0000 Ether (LAN9220) 16bit | |
65 | * 0x1600_0000 user area - cannot use with NAND | |
66 | * 0x1800_0000 user area - | |
67 | * 0x1A00_0000 - | |
68 | * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit | |
69 | */ | |
70 | ||
71 | /* | |
72 | * NOR Flash ROM | |
73 | * | |
74 | * SW1 | SW2 | SW7 | NOR Flash ROM | |
75 | * bit1 | bit1 bit2 | bit1 | Memory allocation | |
76 | * ------+------------+------+------------------ | |
77 | * OFF | ON OFF | ON | Area 0 | |
78 | * OFF | ON OFF | OFF | Area 4 | |
79 | */ | |
80 | ||
81 | /* | |
82 | * NAND Flash ROM | |
83 | * | |
84 | * SW1 | SW2 | SW7 | NAND Flash ROM | |
85 | * bit1 | bit1 bit2 | bit2 | Memory allocation | |
86 | * ------+------------+------+------------------ | |
87 | * OFF | ON OFF | ON | FCE 0 | |
88 | * OFF | ON OFF | OFF | FCE 1 | |
89 | */ | |
90 | ||
91 | /* | |
92 | * SMSC 9220 | |
93 | * | |
94 | * SW1 SMSC 9220 | |
95 | * ----------------------- | |
96 | * ON access disable | |
97 | * OFF access enable | |
98 | */ | |
99 | ||
17ccb834 | 100 | /* |
dda128dc | 101 | * LCD / IRQ / KEYSC / IrDA |
17ccb834 | 102 | * |
dda128dc KM |
103 | * IRQ = IRQ26 (TS), IRQ27 (VIO), IRQ28 (TouchScreen) |
104 | * LCD = 2nd LCDC | |
105 | * | |
106 | * | SW43 | | |
107 | * SW3 | ON | OFF | | |
108 | * -------------+-----------------------+---------------+ | |
109 | * ON | KEY / IrDA | LCD | | |
110 | * OFF | KEY / IrDA / IRQ | IRQ | | |
17ccb834 KM |
111 | */ |
112 | ||
fb54d268 KM |
113 | /* |
114 | * USB | |
115 | * | |
116 | * J7 : 1-2 MAX3355E VBUS | |
117 | * 2-3 DC 5.0V | |
118 | * | |
119 | * S39: bit2: off | |
120 | */ | |
121 | ||
cb9215e1 KM |
122 | /* |
123 | * FSI/FSMI | |
124 | * | |
125 | * SW41 : ON : SH-Mobile AP4 Audio Mode | |
126 | * : OFF : Bluetooth Audio Mode | |
127 | */ | |
128 | ||
c8ee3d4b KM |
129 | /* |
130 | * MMC (CN7) | |
131 | * | |
132 | * J22 : 1-2: 1.8v for MMC | |
133 | * 2-3: 3.3v for MMC | |
134 | * SW1 : OFF | |
135 | * SW33: bit1: OFF | |
136 | * bit2: ON | |
137 | * bit3: ON | |
138 | * bit4: X | |
139 | */ | |
140 | ||
1b7e0677 | 141 | /* MTD */ |
2b7eda63 MD |
142 | static struct mtd_partition nor_flash_partitions[] = { |
143 | { | |
144 | .name = "loader", | |
145 | .offset = 0x00000000, | |
146 | .size = 512 * 1024, | |
147 | }, | |
148 | { | |
149 | .name = "bootenv", | |
150 | .offset = MTDPART_OFS_APPEND, | |
151 | .size = 512 * 1024, | |
152 | }, | |
153 | { | |
154 | .name = "kernel_ro", | |
155 | .offset = MTDPART_OFS_APPEND, | |
156 | .size = 8 * 1024 * 1024, | |
157 | .mask_flags = MTD_WRITEABLE, | |
158 | }, | |
159 | { | |
160 | .name = "kernel", | |
161 | .offset = MTDPART_OFS_APPEND, | |
162 | .size = 8 * 1024 * 1024, | |
163 | }, | |
164 | { | |
165 | .name = "data", | |
166 | .offset = MTDPART_OFS_APPEND, | |
167 | .size = MTDPART_SIZ_FULL, | |
168 | }, | |
169 | }; | |
170 | ||
171 | static struct physmap_flash_data nor_flash_data = { | |
172 | .width = 2, | |
173 | .parts = nor_flash_partitions, | |
174 | .nr_parts = ARRAY_SIZE(nor_flash_partitions), | |
175 | }; | |
176 | ||
177 | static struct resource nor_flash_resources[] = { | |
178 | [0] = { | |
179 | .start = 0x00000000, | |
180 | .end = 0x08000000 - 1, | |
181 | .flags = IORESOURCE_MEM, | |
182 | } | |
183 | }; | |
184 | ||
185 | static struct platform_device nor_flash_device = { | |
186 | .name = "physmap-flash", | |
187 | .dev = { | |
188 | .platform_data = &nor_flash_data, | |
189 | }, | |
190 | .num_resources = ARRAY_SIZE(nor_flash_resources), | |
191 | .resource = nor_flash_resources, | |
192 | }; | |
193 | ||
1b7e0677 KM |
194 | /* SMSC 9220 */ |
195 | static struct resource smc911x_resources[] = { | |
196 | { | |
197 | .start = 0x14000000, | |
198 | .end = 0x16000000 - 1, | |
199 | .flags = IORESOURCE_MEM, | |
200 | }, { | |
33c9607a | 201 | .start = evt2irq(0x02c0) /* IRQ6A */, |
1b7e0677 KM |
202 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL, |
203 | }, | |
204 | }; | |
205 | ||
206 | static struct smsc911x_platform_config smsc911x_info = { | |
207 | .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS, | |
208 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, | |
209 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, | |
210 | }; | |
211 | ||
212 | static struct platform_device smc911x_device = { | |
213 | .name = "smsc911x", | |
214 | .id = -1, | |
215 | .num_resources = ARRAY_SIZE(smc911x_resources), | |
216 | .resource = smc911x_resources, | |
217 | .dev = { | |
218 | .platform_data = &smsc911x_info, | |
219 | }, | |
220 | }; | |
2b7eda63 | 221 | |
17ccb834 KM |
222 | /* KEYSC (Needs SW43 set to ON) */ |
223 | static struct sh_keysc_info keysc_info = { | |
224 | .mode = SH_KEYSC_MODE_1, | |
225 | .scan_timing = 3, | |
226 | .delay = 2500, | |
227 | .keycodes = { | |
228 | KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, | |
229 | KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, | |
230 | KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, | |
231 | KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, | |
232 | KEY_K, KEY_L, KEY_M, KEY_N, KEY_O, | |
233 | }, | |
234 | }; | |
235 | ||
236 | static struct resource keysc_resources[] = { | |
237 | [0] = { | |
238 | .name = "KEYSC", | |
239 | .start = 0xe61b0000, | |
240 | .end = 0xe61b0063, | |
241 | .flags = IORESOURCE_MEM, | |
242 | }, | |
243 | [1] = { | |
33c9607a | 244 | .start = evt2irq(0x0be0), /* KEYSC_KEY */ |
17ccb834 KM |
245 | .flags = IORESOURCE_IRQ, |
246 | }, | |
247 | }; | |
248 | ||
249 | static struct platform_device keysc_device = { | |
250 | .name = "sh_keysc", | |
251 | .id = 0, /* "keysc0" clock */ | |
252 | .num_resources = ARRAY_SIZE(keysc_resources), | |
253 | .resource = keysc_resources, | |
254 | .dev = { | |
255 | .platform_data = &keysc_info, | |
256 | }, | |
257 | }; | |
258 | ||
c8ee3d4b KM |
259 | /* SH_MMCIF */ |
260 | static struct resource sh_mmcif_resources[] = { | |
261 | [0] = { | |
262 | .name = "SH_MMCIF", | |
263 | .start = 0xE6BD0000, | |
264 | .end = 0xE6BD00FF, | |
265 | .flags = IORESOURCE_MEM, | |
266 | }, | |
267 | [1] = { | |
268 | /* MMC ERR */ | |
269 | .start = 198, | |
270 | .flags = IORESOURCE_IRQ, | |
271 | }, | |
272 | [2] = { | |
273 | /* MMC NOR */ | |
274 | .start = 199, | |
275 | .flags = IORESOURCE_IRQ, | |
276 | }, | |
277 | }; | |
278 | ||
279 | struct sh_mmcif_plat_data sh_mmcif_plat = { | |
280 | .sup_pclk = 0, | |
281 | .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34, | |
282 | .caps = MMC_CAP_4_BIT_DATA | | |
283 | MMC_CAP_8_BIT_DATA | | |
284 | MMC_CAP_NEEDS_POLL, | |
285 | }; | |
286 | ||
287 | static struct platform_device sh_mmcif_device = { | |
288 | .name = "sh_mmcif", | |
289 | .id = 0, | |
290 | .dev = { | |
291 | .dma_mask = NULL, | |
292 | .coherent_dma_mask = 0xffffffff, | |
293 | .platform_data = &sh_mmcif_plat, | |
294 | }, | |
295 | .num_resources = ARRAY_SIZE(sh_mmcif_resources), | |
296 | .resource = sh_mmcif_resources, | |
297 | }; | |
298 | ||
3a14d039 | 299 | /* SDHI0 */ |
69bf6f45 GL |
300 | static struct sh_mobile_sdhi_info sdhi0_info = { |
301 | .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX, | |
302 | .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX, | |
303 | }; | |
304 | ||
3a14d039 MD |
305 | static struct resource sdhi0_resources[] = { |
306 | [0] = { | |
307 | .name = "SDHI0", | |
308 | .start = 0xe6850000, | |
309 | .end = 0xe68501ff, | |
310 | .flags = IORESOURCE_MEM, | |
311 | }, | |
312 | [1] = { | |
33c9607a | 313 | .start = evt2irq(0x0e00) /* SDHI0 */, |
3a14d039 MD |
314 | .flags = IORESOURCE_IRQ, |
315 | }, | |
316 | }; | |
317 | ||
318 | static struct platform_device sdhi0_device = { | |
319 | .name = "sh_mobile_sdhi", | |
320 | .num_resources = ARRAY_SIZE(sdhi0_resources), | |
321 | .resource = sdhi0_resources, | |
322 | .id = 0, | |
69bf6f45 GL |
323 | .dev = { |
324 | .platform_data = &sdhi0_info, | |
325 | }, | |
3a14d039 MD |
326 | }; |
327 | ||
fb54d268 KM |
328 | /* USB1 */ |
329 | void usb1_host_port_power(int port, int power) | |
330 | { | |
331 | if (!power) /* only power-on supported for now */ | |
332 | return; | |
333 | ||
334 | /* set VBOUT/PWEN and EXTLP1 in DVSTCTR */ | |
335 | __raw_writew(__raw_readw(0xE68B0008) | 0x600, 0xE68B0008); | |
336 | } | |
337 | ||
338 | static struct r8a66597_platdata usb1_host_data = { | |
339 | .on_chip = 1, | |
340 | .port_power = usb1_host_port_power, | |
341 | }; | |
342 | ||
343 | static struct resource usb1_host_resources[] = { | |
344 | [0] = { | |
345 | .name = "USBHS", | |
346 | .start = 0xE68B0000, | |
347 | .end = 0xE68B00E6 - 1, | |
348 | .flags = IORESOURCE_MEM, | |
349 | }, | |
350 | [1] = { | |
33c9607a | 351 | .start = evt2irq(0x1ce0) /* USB1_USB1I0 */, |
fb54d268 KM |
352 | .flags = IORESOURCE_IRQ, |
353 | }, | |
354 | }; | |
355 | ||
356 | static struct platform_device usb1_host_device = { | |
357 | .name = "r8a66597_hcd", | |
358 | .id = 1, | |
359 | .dev = { | |
360 | .dma_mask = NULL, /* not use dma */ | |
361 | .coherent_dma_mask = 0xffffffff, | |
362 | .platform_data = &usb1_host_data, | |
363 | }, | |
364 | .num_resources = ARRAY_SIZE(usb1_host_resources), | |
365 | .resource = usb1_host_resources, | |
366 | }; | |
367 | ||
8eda2f21 GL |
368 | static struct sh_mobile_lcdc_info sh_mobile_lcdc_info = { |
369 | .clock_source = LCDC_CLK_PERIPHERAL, /* One of interface clocks */ | |
370 | .ch[0] = { | |
371 | .chan = LCDC_CHAN_MAINLCD, | |
372 | .bpp = 16, | |
373 | .interface_type = RGB24, | |
374 | .clock_divider = 1, | |
375 | .flags = LCDC_FLAGS_DWPOL, | |
376 | .lcd_cfg = { | |
377 | .name = "R63302(QHD)", | |
378 | .xres = 544, | |
379 | .yres = 961, | |
380 | .left_margin = 72, | |
381 | .right_margin = 600, | |
382 | .hsync_len = 16, | |
383 | .upper_margin = 8, | |
384 | .lower_margin = 8, | |
385 | .vsync_len = 2, | |
386 | .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT, | |
387 | }, | |
388 | .lcd_size_cfg = { | |
389 | .width = 44, | |
390 | .height = 79, | |
391 | }, | |
392 | } | |
393 | }; | |
394 | ||
395 | static struct resource lcdc_resources[] = { | |
396 | [0] = { | |
397 | .name = "LCDC", | |
398 | .start = 0xfe940000, /* P4-only space */ | |
399 | .end = 0xfe943fff, | |
400 | .flags = IORESOURCE_MEM, | |
401 | }, | |
402 | [1] = { | |
403 | .start = intcs_evt2irq(0x580), | |
404 | .flags = IORESOURCE_IRQ, | |
405 | }, | |
406 | }; | |
407 | ||
408 | static struct platform_device lcdc_device = { | |
409 | .name = "sh_mobile_lcdc_fb", | |
410 | .num_resources = ARRAY_SIZE(lcdc_resources), | |
411 | .resource = lcdc_resources, | |
412 | .dev = { | |
413 | .platform_data = &sh_mobile_lcdc_info, | |
414 | .coherent_dma_mask = ~0, | |
415 | }, | |
416 | }; | |
417 | ||
418 | static struct resource mipidsi0_resources[] = { | |
419 | [0] = { | |
420 | .start = 0xffc60000, | |
421 | .end = 0xffc68fff, | |
422 | .flags = IORESOURCE_MEM, | |
423 | }, | |
424 | }; | |
425 | ||
426 | static struct sh_mipi_dsi_info mipidsi0_info = { | |
427 | .data_format = MIPI_RGB888, | |
428 | .lcd_chan = &sh_mobile_lcdc_info.ch[0], | |
429 | }; | |
430 | ||
431 | static struct platform_device mipidsi0_device = { | |
432 | .name = "sh-mipi-dsi", | |
433 | .num_resources = ARRAY_SIZE(mipidsi0_resources), | |
434 | .resource = mipidsi0_resources, | |
435 | .id = 0, | |
436 | .dev = { | |
437 | .platform_data = &mipidsi0_info, | |
438 | }, | |
439 | }; | |
440 | ||
cb9215e1 KM |
441 | /* FSI */ |
442 | #define IRQ_FSI evt2irq(0x1840) | |
443 | #define FSIACKCR 0xE6150018 | |
444 | static void fsiackcr_init(struct clk *clk) | |
445 | { | |
446 | u32 status = __raw_readl(clk->enable_reg); | |
447 | ||
448 | /* use external clock */ | |
449 | status &= ~0x000000ff; | |
450 | status |= 0x00000080; | |
451 | __raw_writel(status, clk->enable_reg); | |
452 | } | |
453 | ||
454 | static struct clk_ops fsiackcr_clk_ops = { | |
455 | .init = fsiackcr_init, | |
456 | }; | |
457 | ||
458 | static struct clk fsiackcr_clk = { | |
459 | .ops = &fsiackcr_clk_ops, | |
460 | .enable_reg = (void __iomem *)FSIACKCR, | |
461 | .rate = 0, /* unknown */ | |
462 | }; | |
463 | ||
464 | struct sh_fsi_platform_info fsi_info = { | |
465 | .porta_flags = SH_FSI_BRS_INV | | |
466 | SH_FSI_OUT_SLAVE_MODE | | |
467 | SH_FSI_IN_SLAVE_MODE | | |
468 | SH_FSI_OFMT(PCM) | | |
469 | SH_FSI_IFMT(PCM), | |
470 | }; | |
471 | ||
472 | static struct resource fsi_resources[] = { | |
473 | [0] = { | |
474 | .name = "FSI", | |
475 | .start = 0xFE3C0000, | |
476 | .end = 0xFE3C0400 - 1, | |
477 | .flags = IORESOURCE_MEM, | |
478 | }, | |
479 | [1] = { | |
480 | .start = IRQ_FSI, | |
481 | .flags = IORESOURCE_IRQ, | |
482 | }, | |
483 | }; | |
484 | ||
485 | static struct platform_device fsi_device = { | |
486 | .name = "sh_fsi2", | |
487 | .id = 0, | |
488 | .num_resources = ARRAY_SIZE(fsi_resources), | |
489 | .resource = fsi_resources, | |
490 | .dev = { | |
491 | .platform_data = &fsi_info, | |
492 | }, | |
493 | }; | |
494 | ||
2b7eda63 MD |
495 | static struct platform_device *ap4evb_devices[] __initdata = { |
496 | &nor_flash_device, | |
1b7e0677 | 497 | &smc911x_device, |
17ccb834 | 498 | &keysc_device, |
3a14d039 | 499 | &sdhi0_device, |
fb54d268 | 500 | &usb1_host_device, |
8eda2f21 GL |
501 | &lcdc_device, |
502 | &mipidsi0_device, | |
cb9215e1 | 503 | &fsi_device, |
c8ee3d4b | 504 | &sh_mmcif_device |
2b7eda63 MD |
505 | }; |
506 | ||
dda128dc | 507 | /* TouchScreen (Needs SW3 set to OFF) */ |
33c9607a | 508 | #define IRQ28 evt2irq(0x3380) /* IRQ28A */ |
91cf5082 KM |
509 | struct tsc2007_platform_data tsc2007_info = { |
510 | .model = 2007, | |
511 | .x_plate_ohms = 180, | |
512 | }; | |
513 | ||
514 | /* I2C */ | |
cb9215e1 KM |
515 | static struct i2c_board_info i2c0_devices[] = { |
516 | { | |
517 | I2C_BOARD_INFO("ak4643", 0x13), | |
518 | }, | |
519 | }; | |
520 | ||
91cf5082 | 521 | static struct i2c_board_info i2c1_devices[] = { |
8fc883c2 KM |
522 | { |
523 | I2C_BOARD_INFO("r2025sd", 0x32), | |
524 | }, | |
91cf5082 KM |
525 | { |
526 | I2C_BOARD_INFO("tsc2007", 0x48), | |
527 | .type = "tsc2007", | |
528 | .platform_data = &tsc2007_info, | |
529 | .irq = IRQ28, | |
530 | }, | |
531 | }; | |
532 | ||
2b7eda63 MD |
533 | static struct map_desc ap4evb_io_desc[] __initdata = { |
534 | /* create a 1:1 entity map for 0xe6xxxxxx | |
535 | * used by CPGA, INTC and PFC. | |
536 | */ | |
537 | { | |
538 | .virtual = 0xe6000000, | |
539 | .pfn = __phys_to_pfn(0xe6000000), | |
540 | .length = 256 << 20, | |
541 | .type = MT_DEVICE_NONSHARED | |
542 | }, | |
543 | }; | |
544 | ||
545 | static void __init ap4evb_map_io(void) | |
546 | { | |
547 | iotable_init(ap4evb_io_desc, ARRAY_SIZE(ap4evb_io_desc)); | |
548 | ||
495b3cea | 549 | /* setup early devices and console here as well */ |
2b7eda63 | 550 | sh7372_add_early_devices(); |
4ae04acb | 551 | shmobile_setup_console(); |
2b7eda63 MD |
552 | } |
553 | ||
8eda2f21 GL |
554 | /* This function will disappear when we switch to (runtime) PM */ |
555 | static int __init ap4evb_init_display_clk(void) | |
556 | { | |
557 | struct clk *lcdc_clk; | |
558 | struct clk *dsitx_clk; | |
559 | int ret; | |
560 | ||
561 | lcdc_clk = clk_get(&lcdc_device.dev, "sh_mobile_lcdc_fb.0"); | |
562 | if (IS_ERR(lcdc_clk)) | |
563 | return PTR_ERR(lcdc_clk); | |
564 | ||
565 | dsitx_clk = clk_get(&mipidsi0_device.dev, "sh-mipi-dsi.0"); | |
566 | if (IS_ERR(dsitx_clk)) { | |
567 | ret = PTR_ERR(dsitx_clk); | |
568 | goto eclkdsitxget; | |
569 | } | |
570 | ||
571 | ret = clk_enable(lcdc_clk); | |
572 | if (ret < 0) | |
573 | goto eclklcdcon; | |
574 | ||
575 | ret = clk_enable(dsitx_clk); | |
576 | if (ret < 0) | |
577 | goto eclkdsitxon; | |
578 | ||
579 | return 0; | |
580 | ||
581 | eclkdsitxon: | |
582 | clk_disable(lcdc_clk); | |
583 | eclklcdcon: | |
584 | clk_put(dsitx_clk); | |
585 | eclkdsitxget: | |
586 | clk_put(lcdc_clk); | |
587 | ||
588 | return ret; | |
589 | } | |
590 | ||
591 | device_initcall(ap4evb_init_display_clk); | |
592 | ||
cb9215e1 KM |
593 | /* |
594 | * FIXME !! | |
595 | * | |
596 | * gpio_no_direction is quick_hack. | |
597 | * | |
598 | * current gpio frame work doesn't have | |
599 | * the method to control only pull up/down/free. | |
600 | * this function should be replaced by correct gpio function | |
601 | */ | |
602 | static void __init gpio_no_direction(u32 addr) | |
603 | { | |
604 | __raw_writeb(0x00, addr); | |
605 | } | |
606 | ||
607 | #define GPIO_PORT9CR 0xE6051009 | |
608 | #define GPIO_PORT10CR 0xE605100A | |
609 | ||
2b7eda63 MD |
610 | static void __init ap4evb_init(void) |
611 | { | |
cb9215e1 KM |
612 | struct clk *clk; |
613 | ||
1b7e0677 KM |
614 | sh7372_pinmux_init(); |
615 | ||
b228b48e KM |
616 | /* enable SCIFA0 */ |
617 | gpio_request(GPIO_FN_SCIFA0_TXD, NULL); | |
618 | gpio_request(GPIO_FN_SCIFA0_RXD, NULL); | |
619 | ||
1b7e0677 KM |
620 | /* enable SMSC911X */ |
621 | gpio_request(GPIO_FN_CS5A, NULL); | |
622 | gpio_request(GPIO_FN_IRQ6_39, NULL); | |
623 | ||
5098280e KM |
624 | /* enable LED 1 - 4 */ |
625 | gpio_request(GPIO_PORT185, NULL); | |
626 | gpio_request(GPIO_PORT186, NULL); | |
627 | gpio_request(GPIO_PORT187, NULL); | |
628 | gpio_request(GPIO_PORT188, NULL); | |
629 | gpio_direction_output(GPIO_PORT185, 1); | |
630 | gpio_direction_output(GPIO_PORT186, 1); | |
631 | gpio_direction_output(GPIO_PORT187, 1); | |
632 | gpio_direction_output(GPIO_PORT188, 1); | |
633 | gpio_export(GPIO_PORT185, 0); | |
634 | gpio_export(GPIO_PORT186, 0); | |
635 | gpio_export(GPIO_PORT187, 0); | |
636 | gpio_export(GPIO_PORT188, 0); | |
637 | ||
8cb3a2eb KM |
638 | /* enable Debug switch (S6) */ |
639 | gpio_request(GPIO_PORT32, NULL); | |
640 | gpio_request(GPIO_PORT33, NULL); | |
641 | gpio_request(GPIO_PORT34, NULL); | |
642 | gpio_request(GPIO_PORT35, NULL); | |
643 | gpio_direction_input(GPIO_PORT32); | |
644 | gpio_direction_input(GPIO_PORT33); | |
645 | gpio_direction_input(GPIO_PORT34); | |
646 | gpio_direction_input(GPIO_PORT35); | |
647 | gpio_export(GPIO_PORT32, 0); | |
648 | gpio_export(GPIO_PORT33, 0); | |
649 | gpio_export(GPIO_PORT34, 0); | |
650 | gpio_export(GPIO_PORT35, 0); | |
651 | ||
17ccb834 KM |
652 | /* enable KEYSC */ |
653 | gpio_request(GPIO_FN_KEYOUT0, NULL); | |
654 | gpio_request(GPIO_FN_KEYOUT1, NULL); | |
655 | gpio_request(GPIO_FN_KEYOUT2, NULL); | |
656 | gpio_request(GPIO_FN_KEYOUT3, NULL); | |
657 | gpio_request(GPIO_FN_KEYOUT4, NULL); | |
658 | gpio_request(GPIO_FN_KEYIN0_136, NULL); | |
659 | gpio_request(GPIO_FN_KEYIN1_135, NULL); | |
660 | gpio_request(GPIO_FN_KEYIN2_134, NULL); | |
661 | gpio_request(GPIO_FN_KEYIN3_133, NULL); | |
662 | gpio_request(GPIO_FN_KEYIN4, NULL); | |
663 | ||
3a14d039 MD |
664 | /* SDHI0 */ |
665 | gpio_request(GPIO_FN_SDHICD0, NULL); | |
666 | gpio_request(GPIO_FN_SDHIWP0, NULL); | |
667 | gpio_request(GPIO_FN_SDHICMD0, NULL); | |
668 | gpio_request(GPIO_FN_SDHICLK0, NULL); | |
669 | gpio_request(GPIO_FN_SDHID0_3, NULL); | |
670 | gpio_request(GPIO_FN_SDHID0_2, NULL); | |
671 | gpio_request(GPIO_FN_SDHID0_1, NULL); | |
672 | gpio_request(GPIO_FN_SDHID0_0, NULL); | |
673 | ||
91cf5082 KM |
674 | /* enable TouchScreen */ |
675 | gpio_request(GPIO_FN_IRQ28_123, NULL); | |
676 | set_irq_type(IRQ28, IRQ_TYPE_LEVEL_LOW); | |
677 | ||
c8ee3d4b KM |
678 | /* MMCIF */ |
679 | gpio_request(GPIO_FN_MMCD0_0, NULL); | |
680 | gpio_request(GPIO_FN_MMCD0_1, NULL); | |
681 | gpio_request(GPIO_FN_MMCD0_2, NULL); | |
682 | gpio_request(GPIO_FN_MMCD0_3, NULL); | |
683 | gpio_request(GPIO_FN_MMCD0_4, NULL); | |
684 | gpio_request(GPIO_FN_MMCD0_5, NULL); | |
685 | gpio_request(GPIO_FN_MMCD0_6, NULL); | |
686 | gpio_request(GPIO_FN_MMCD0_7, NULL); | |
687 | gpio_request(GPIO_FN_MMCCMD0, NULL); | |
688 | gpio_request(GPIO_FN_MMCCLK0, NULL); | |
689 | ||
fb54d268 KM |
690 | /* USB enable */ |
691 | gpio_request(GPIO_FN_VBUS0_1, NULL); | |
692 | gpio_request(GPIO_FN_IDIN_1_18, NULL); | |
693 | gpio_request(GPIO_FN_PWEN_1_115, NULL); | |
694 | gpio_request(GPIO_FN_OVCN_1_114, NULL); | |
695 | gpio_request(GPIO_FN_EXTLP_1, NULL); | |
696 | gpio_request(GPIO_FN_OVCN2_1, NULL); | |
697 | ||
698 | /* setup USB phy */ | |
699 | __raw_writew(0x8a0a, 0xE6058130); /* USBCR2 */ | |
700 | ||
cb9215e1 KM |
701 | /* enable FSI2 */ |
702 | gpio_request(GPIO_FN_FSIAIBT, NULL); | |
703 | gpio_request(GPIO_FN_FSIAILR, NULL); | |
704 | gpio_request(GPIO_FN_FSIAISLD, NULL); | |
705 | gpio_request(GPIO_FN_FSIAOSLD, NULL); | |
706 | gpio_request(GPIO_PORT161, NULL); | |
707 | gpio_direction_output(GPIO_PORT161, 0); /* slave */ | |
708 | ||
709 | gpio_request(GPIO_PORT9, NULL); | |
710 | gpio_request(GPIO_PORT10, NULL); | |
711 | gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */ | |
712 | gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */ | |
713 | ||
714 | /* set SPU2 clock to 119.6 MHz */ | |
715 | clk = clk_get(NULL, "spu_clk"); | |
716 | if (!IS_ERR_VALUE(clk)) { | |
717 | clk_set_rate(clk, clk_round_rate(clk, 119600000)); | |
718 | clk_put(clk); | |
719 | } | |
720 | ||
721 | /* change parent of FSI A */ | |
722 | clk = clk_get(NULL, "fsia_clk"); | |
723 | if (!IS_ERR_VALUE(clk)) { | |
724 | clk_register(&fsiackcr_clk); | |
725 | clk_set_parent(clk, &fsiackcr_clk); | |
726 | clk_put(clk); | |
727 | } | |
728 | ||
729 | /* | |
730 | * set irq priority, to avoid sound chopping | |
731 | * when NFS rootfs is used | |
732 | * FSI(3) > SMSC911X(2) | |
733 | */ | |
734 | intc_set_priority(IRQ_FSI, 3); | |
735 | ||
736 | i2c_register_board_info(0, i2c0_devices, | |
737 | ARRAY_SIZE(i2c0_devices)); | |
738 | ||
739 | i2c_register_board_info(1, i2c1_devices, | |
740 | ARRAY_SIZE(i2c1_devices)); | |
741 | ||
2b7eda63 MD |
742 | sh7372_add_standard_devices(); |
743 | ||
744 | platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices)); | |
745 | } | |
746 | ||
495b3cea MD |
747 | static void __init ap4evb_timer_init(void) |
748 | { | |
749 | sh7372_clock_init(); | |
750 | shmobile_timer.init(); | |
751 | } | |
752 | ||
753 | static struct sys_timer ap4evb_timer = { | |
754 | .init = ap4evb_timer_init, | |
755 | }; | |
756 | ||
2b7eda63 MD |
757 | MACHINE_START(AP4EVB, "ap4evb") |
758 | .phys_io = 0xe6000000, | |
759 | .io_pg_offst = ((0xe6000000) >> 18) & 0xfffc, | |
760 | .map_io = ap4evb_map_io, | |
761 | .init_irq = sh7372_init_irq, | |
762 | .init_machine = ap4evb_init, | |
495b3cea | 763 | .timer = &ap4evb_timer, |
2b7eda63 | 764 | MACHINE_END |