blob: dff89d0fa20f10c3e387fd0ef905daaed67fba55 [file] [log] [blame]
Kuninori Morimoto287c1292009-05-26 07:04:52 +00001/*
2 * linux/arch/sh/boards/se/7724/setup.c
3 *
4 * Copyright (C) 2009 Renesas Solutions Corp.
5 *
6 * Kuninori Morimoto <morimoto.kuninori@renesas.com>
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
12
13#include <linux/init.h>
14#include <linux/device.h>
15#include <linux/interrupt.h>
16#include <linux/platform_device.h>
Guennadi Liakhovetski470ef1a2010-05-19 18:34:32 +000017#include <linux/mfd/sh_mobile_sdhi.h>
Kuninori Morimoto287c1292009-05-26 07:04:52 +000018#include <linux/mtd/physmap.h>
19#include <linux/delay.h>
20#include <linux/smc91x.h>
21#include <linux/gpio.h>
22#include <linux/input.h>
Magnus Dammfc1d0032009-11-27 07:32:24 +000023#include <linux/input/sh_keysc.h>
Magnus Damm9731f4a2009-07-03 09:40:03 +000024#include <linux/usb/r8a66597.h>
Kuninori Morimoto287c1292009-05-26 07:04:52 +000025#include <video/sh_mobile_lcdc.h>
26#include <media/sh_mobile_ceu.h>
Kuninori Morimoto3e9ad522009-08-21 01:24:54 +000027#include <sound/sh_fsi.h>
Kuninori Morimoto287c1292009-05-26 07:04:52 +000028#include <asm/io.h>
29#include <asm/heartbeat.h>
Kuninori Morimotoa80cad92009-06-26 07:05:39 +000030#include <asm/sh_eth.h>
31#include <asm/clock.h>
Magnus Damm3b9f2952009-10-29 10:52:23 +000032#include <asm/suspend.h>
Kuninori Morimoto287c1292009-05-26 07:04:52 +000033#include <cpu/sh7724.h>
34#include <mach-se/mach/se7724.h>
35
36/*
37 * SWx 1234 5678
38 * ------------------------------------
39 * SW31 : 1001 1100 : default
40 * SW32 : 0111 1111 : use on board flash
41 *
42 * SW41 : abxx xxxx -> a = 0 : Analog monitor
43 * 1 : Digital monitor
44 * b = 0 : VGA
Kuninori Morimoto4f324312009-08-03 04:52:03 +000045 * 1 : 720p
46 */
47
48/*
49 * about 720p
50 *
51 * When you use 1280 x 720 lcdc output,
52 * you should change OSC6 lcdc clock from 25.175MHz to 74.25MHz,
53 * and change SW41 to use 720p
Kuninori Morimoto287c1292009-05-26 07:04:52 +000054 */
55
Kuninori Morimotobec9fb02010-03-16 02:01:53 +000056/*
57 * about sound
58 *
59 * This setup.c supports FSI slave mode.
60 * Please change J20, J21, J22 pin to 1-2 connection.
61 */
62
Kuninori Morimoto287c1292009-05-26 07:04:52 +000063/* Heartbeat */
Paul Mundta09d2832010-01-15 12:24:34 +090064static struct resource heartbeat_resource = {
65 .start = PA_LED,
66 .end = PA_LED,
67 .flags = IORESOURCE_MEM | IORESOURCE_MEM_16BIT,
Kuninori Morimoto287c1292009-05-26 07:04:52 +000068};
69
70static struct platform_device heartbeat_device = {
71 .name = "heartbeat",
72 .id = -1,
Paul Mundta09d2832010-01-15 12:24:34 +090073 .num_resources = 1,
74 .resource = &heartbeat_resource,
Kuninori Morimoto287c1292009-05-26 07:04:52 +000075};
76
77/* LAN91C111 */
78static struct smc91x_platdata smc91x_info = {
79 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
80};
81
82static struct resource smc91x_eth_resources[] = {
83 [0] = {
84 .name = "SMC91C111" ,
85 .start = 0x1a300300,
86 .end = 0x1a30030f,
87 .flags = IORESOURCE_MEM,
88 },
89 [1] = {
90 .start = IRQ0_SMC,
91 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
92 },
93};
94
95static struct platform_device smc91x_eth_device = {
96 .name = "smc91x",
97 .num_resources = ARRAY_SIZE(smc91x_eth_resources),
98 .resource = smc91x_eth_resources,
99 .dev = {
100 .platform_data = &smc91x_info,
101 },
102};
103
104/* MTD */
105static struct mtd_partition nor_flash_partitions[] = {
106 {
107 .name = "uboot",
108 .offset = 0,
109 .size = (1 * 1024 * 1024),
110 .mask_flags = MTD_WRITEABLE, /* Read-only */
111 }, {
112 .name = "kernel",
113 .offset = MTDPART_OFS_APPEND,
114 .size = (2 * 1024 * 1024),
115 }, {
116 .name = "free-area",
117 .offset = MTDPART_OFS_APPEND,
118 .size = MTDPART_SIZ_FULL,
119 },
120};
121
122static struct physmap_flash_data nor_flash_data = {
123 .width = 2,
124 .parts = nor_flash_partitions,
125 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
126};
127
128static struct resource nor_flash_resources[] = {
129 [0] = {
130 .name = "NOR Flash",
131 .start = 0x00000000,
132 .end = 0x01ffffff,
133 .flags = IORESOURCE_MEM,
134 }
135};
136
137static struct platform_device nor_flash_device = {
138 .name = "physmap-flash",
139 .resource = nor_flash_resources,
140 .num_resources = ARRAY_SIZE(nor_flash_resources),
141 .dev = {
142 .platform_data = &nor_flash_data,
143 },
144};
145
146/* LCDC */
Guennadi Liakhovetski44432402010-09-03 07:20:04 +0000147const static struct fb_videomode lcdc_720p_modes[] = {
148 {
149 .name = "LB070WV1",
150 .sync = 0, /* hsync and vsync are active low */
Guennadi Liakhovetski46f12932010-10-03 04:24:42 +0000151 .xres = 1280,
152 .yres = 720,
153 .left_margin = 220,
154 .right_margin = 110,
155 .hsync_len = 40,
156 .upper_margin = 20,
157 .lower_margin = 5,
158 .vsync_len = 5,
Guennadi Liakhovetski44432402010-09-03 07:20:04 +0000159 },
160};
161
162const static struct fb_videomode lcdc_vga_modes[] = {
163 {
164 .name = "LB070WV1",
165 .sync = 0, /* hsync and vsync are active low */
Guennadi Liakhovetski46f12932010-10-03 04:24:42 +0000166 .xres = 640,
167 .yres = 480,
168 .left_margin = 105,
169 .right_margin = 50,
170 .hsync_len = 96,
171 .upper_margin = 33,
172 .lower_margin = 10,
173 .vsync_len = 2,
Guennadi Liakhovetski44432402010-09-03 07:20:04 +0000174 },
175};
176
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000177static struct sh_mobile_lcdc_info lcdc_info = {
178 .clock_source = LCDC_CLK_EXTERNAL,
179 .ch[0] = {
180 .chan = LCDC_CHAN_MAINLCD,
181 .bpp = 16,
182 .clock_divider = 1,
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000183 .lcd_size_cfg = { /* 7.0 inch */
184 .width = 152,
185 .height = 91,
186 },
187 .board_cfg = {
188 },
189 }
190};
191
192static struct resource lcdc_resources[] = {
193 [0] = {
194 .name = "LCDC",
195 .start = 0xfe940000,
Phil Edworthya6f15ad2009-09-15 12:00:30 +0000196 .end = 0xfe942fff,
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000197 .flags = IORESOURCE_MEM,
198 },
199 [1] = {
200 .start = 106,
201 .flags = IORESOURCE_IRQ,
202 },
203};
204
205static struct platform_device lcdc_device = {
206 .name = "sh_mobile_lcdc_fb",
207 .num_resources = ARRAY_SIZE(lcdc_resources),
208 .resource = lcdc_resources,
209 .dev = {
210 .platform_data = &lcdc_info,
211 },
Magnus Dammdf47cd02009-07-31 07:48:29 +0000212 .archdata = {
213 .hwblk_id = HWBLK_LCDC,
214 },
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000215};
216
217/* CEU0 */
218static struct sh_mobile_ceu_info sh_mobile_ceu0_info = {
219 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
220};
221
222static struct resource ceu0_resources[] = {
223 [0] = {
224 .name = "CEU0",
225 .start = 0xfe910000,
226 .end = 0xfe91009f,
227 .flags = IORESOURCE_MEM,
228 },
229 [1] = {
230 .start = 52,
231 .flags = IORESOURCE_IRQ,
232 },
233 [2] = {
234 /* place holder for contiguous memory */
235 },
236};
237
238static struct platform_device ceu0_device = {
239 .name = "sh_mobile_ceu",
240 .id = 0, /* "ceu0" clock */
241 .num_resources = ARRAY_SIZE(ceu0_resources),
242 .resource = ceu0_resources,
243 .dev = {
244 .platform_data = &sh_mobile_ceu0_info,
245 },
Magnus Dammdf47cd02009-07-31 07:48:29 +0000246 .archdata = {
247 .hwblk_id = HWBLK_CEU0,
248 },
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000249};
250
251/* CEU1 */
252static struct sh_mobile_ceu_info sh_mobile_ceu1_info = {
253 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
254};
255
256static struct resource ceu1_resources[] = {
257 [0] = {
258 .name = "CEU1",
259 .start = 0xfe914000,
260 .end = 0xfe91409f,
261 .flags = IORESOURCE_MEM,
262 },
263 [1] = {
264 .start = 63,
265 .flags = IORESOURCE_IRQ,
266 },
267 [2] = {
268 /* place holder for contiguous memory */
269 },
270};
271
272static struct platform_device ceu1_device = {
273 .name = "sh_mobile_ceu",
274 .id = 1, /* "ceu1" clock */
275 .num_resources = ARRAY_SIZE(ceu1_resources),
276 .resource = ceu1_resources,
277 .dev = {
278 .platform_data = &sh_mobile_ceu1_info,
279 },
Magnus Dammdf47cd02009-07-31 07:48:29 +0000280 .archdata = {
281 .hwblk_id = HWBLK_CEU1,
282 },
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000283};
284
Kuninori Morimoto3e9ad522009-08-21 01:24:54 +0000285/* FSI */
286/*
287 * FSI-A use external clock which came from ak464x.
288 * So, we should change parent of fsi
289 */
290#define FCLKACR 0xa4150008
291static void fsimck_init(struct clk *clk)
292{
Paul Mundt9d56dd32010-01-26 12:58:40 +0900293 u32 status = __raw_readl(clk->enable_reg);
Kuninori Morimoto3e9ad522009-08-21 01:24:54 +0000294
295 /* use external clock */
296 status &= ~0x000000ff;
297 status |= 0x00000080;
Paul Mundt9d56dd32010-01-26 12:58:40 +0900298 __raw_writel(status, clk->enable_reg);
Kuninori Morimoto3e9ad522009-08-21 01:24:54 +0000299}
300
301static struct clk_ops fsimck_clk_ops = {
302 .init = fsimck_init,
303};
304
305static struct clk fsimcka_clk = {
Kuninori Morimoto3e9ad522009-08-21 01:24:54 +0000306 .ops = &fsimck_clk_ops,
307 .enable_reg = (void __iomem *)FCLKACR,
308 .rate = 0, /* unknown */
309};
310
Kuninori Morimotobec9fb02010-03-16 02:01:53 +0000311/* change J20, J21, J22 pin to 1-2 connection to use slave mode */
Kuninori Morimoto560526f2010-06-02 00:27:38 +0000312static struct sh_fsi_platform_info fsi_info = {
Kuninori Morimoto3e9ad522009-08-21 01:24:54 +0000313 .porta_flags = SH_FSI_BRS_INV |
314 SH_FSI_OUT_SLAVE_MODE |
315 SH_FSI_IN_SLAVE_MODE |
316 SH_FSI_OFMT(PCM) |
317 SH_FSI_IFMT(PCM),
318};
319
320static struct resource fsi_resources[] = {
321 [0] = {
322 .name = "FSI",
323 .start = 0xFE3C0000,
324 .end = 0xFE3C021d,
325 .flags = IORESOURCE_MEM,
326 },
327 [1] = {
328 .start = 108,
329 .flags = IORESOURCE_IRQ,
330 },
331};
332
333static struct platform_device fsi_device = {
334 .name = "sh_fsi",
335 .id = 0,
336 .num_resources = ARRAY_SIZE(fsi_resources),
337 .resource = fsi_resources,
338 .dev = {
339 .platform_data = &fsi_info,
340 },
Kuninori Morimotod53bd802009-11-09 11:12:49 +0900341 .archdata = {
342 .hwblk_id = HWBLK_SPU, /* FSI needs SPU hwblk */
343 },
Kuninori Morimoto3e9ad522009-08-21 01:24:54 +0000344};
345
Kuninori Morimotoc8d6bf92010-11-30 11:32:04 +0900346static struct platform_device fsi_ak4642_device = {
347 .name = "sh_fsi_a_ak4642",
348};
349
Magnus Damm9747e782009-08-15 02:53:34 +0000350/* KEYSC in SoC (Needs SW33-2 set to ON) */
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000351static struct sh_keysc_info keysc_info = {
352 .mode = SH_KEYSC_MODE_1,
Kuninori Morimoto29463c22010-02-24 00:16:47 +0000353 .scan_timing = 3,
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000354 .delay = 50,
355 .keycodes = {
356 KEY_1, KEY_2, KEY_3, KEY_4, KEY_5,
357 KEY_6, KEY_7, KEY_8, KEY_9, KEY_A,
358 KEY_B, KEY_C, KEY_D, KEY_E, KEY_F,
359 KEY_G, KEY_H, KEY_I, KEY_K, KEY_L,
360 KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q,
361 KEY_R, KEY_S, KEY_T, KEY_U, KEY_V,
362 },
363};
364
365static struct resource keysc_resources[] = {
366 [0] = {
Magnus Damm9747e782009-08-15 02:53:34 +0000367 .name = "KEYSC",
368 .start = 0x044b0000,
369 .end = 0x044b000f,
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000370 .flags = IORESOURCE_MEM,
371 },
372 [1] = {
Magnus Damm9747e782009-08-15 02:53:34 +0000373 .start = 79,
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000374 .flags = IORESOURCE_IRQ,
375 },
376};
377
378static struct platform_device keysc_device = {
379 .name = "sh_keysc",
380 .id = 0, /* "keysc0" clock */
381 .num_resources = ARRAY_SIZE(keysc_resources),
382 .resource = keysc_resources,
383 .dev = {
384 .platform_data = &keysc_info,
385 },
Magnus Dammdf47cd02009-07-31 07:48:29 +0000386 .archdata = {
387 .hwblk_id = HWBLK_KEYSC,
388 },
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000389};
390
Kuninori Morimotoa80cad92009-06-26 07:05:39 +0000391/* SH Eth */
392static struct resource sh_eth_resources[] = {
393 [0] = {
394 .start = SH_ETH_ADDR,
395 .end = SH_ETH_ADDR + 0x1FC,
396 .flags = IORESOURCE_MEM,
397 },
398 [1] = {
399 .start = 91,
400 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
401 },
402};
403
Kuninori Morimoto560526f2010-06-02 00:27:38 +0000404static struct sh_eth_plat_data sh_eth_plat = {
Kuninori Morimotoa80cad92009-06-26 07:05:39 +0000405 .phy = 0x1f, /* SMSC LAN8187 */
406 .edmac_endian = EDMAC_LITTLE_ENDIAN,
407};
408
409static struct platform_device sh_eth_device = {
410 .name = "sh-eth",
411 .id = 0,
412 .dev = {
413 .platform_data = &sh_eth_plat,
414 },
415 .num_resources = ARRAY_SIZE(sh_eth_resources),
416 .resource = sh_eth_resources,
Magnus Dammdf47cd02009-07-31 07:48:29 +0000417 .archdata = {
418 .hwblk_id = HWBLK_ETHER,
419 },
Kuninori Morimotoa80cad92009-06-26 07:05:39 +0000420};
421
Magnus Damm9731f4a2009-07-03 09:40:03 +0000422static struct r8a66597_platdata sh7724_usb0_host_data = {
Magnus Damm719a72b2009-07-17 14:59:55 +0000423 .on_chip = 1,
Magnus Damm9731f4a2009-07-03 09:40:03 +0000424};
425
426static struct resource sh7724_usb0_host_resources[] = {
427 [0] = {
428 .start = 0xa4d80000,
Kuninori Morimoto1bc265d02009-08-19 00:12:15 +0000429 .end = 0xa4d80124 - 1,
Magnus Damm9731f4a2009-07-03 09:40:03 +0000430 .flags = IORESOURCE_MEM,
431 },
432 [1] = {
433 .start = 65,
434 .end = 65,
435 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
436 },
437};
438
439static struct platform_device sh7724_usb0_host_device = {
440 .name = "r8a66597_hcd",
441 .id = 0,
442 .dev = {
443 .dma_mask = NULL, /* not use dma */
444 .coherent_dma_mask = 0xffffffff,
445 .platform_data = &sh7724_usb0_host_data,
446 },
447 .num_resources = ARRAY_SIZE(sh7724_usb0_host_resources),
448 .resource = sh7724_usb0_host_resources,
Magnus Dammdf47cd02009-07-31 07:48:29 +0000449 .archdata = {
450 .hwblk_id = HWBLK_USB0,
451 },
Magnus Damm9731f4a2009-07-03 09:40:03 +0000452};
453
Magnus Dammf8f8c072009-08-19 09:52:02 +0000454static struct r8a66597_platdata sh7724_usb1_gadget_data = {
455 .on_chip = 1,
456};
457
458static struct resource sh7724_usb1_gadget_resources[] = {
459 [0] = {
460 .start = 0xa4d90000,
461 .end = 0xa4d90123,
462 .flags = IORESOURCE_MEM,
463 },
464 [1] = {
465 .start = 66,
466 .end = 66,
467 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
468 },
469};
470
471static struct platform_device sh7724_usb1_gadget_device = {
472 .name = "r8a66597_udc",
473 .id = 1, /* USB1 */
474 .dev = {
475 .dma_mask = NULL, /* not use dma */
476 .coherent_dma_mask = 0xffffffff,
477 .platform_data = &sh7724_usb1_gadget_data,
478 },
479 .num_resources = ARRAY_SIZE(sh7724_usb1_gadget_resources),
480 .resource = sh7724_usb1_gadget_resources,
481};
482
Magnus Damm0f79af62009-10-02 02:23:07 +0000483static struct resource sdhi0_cn7_resources[] = {
484 [0] = {
485 .name = "SDHI0",
486 .start = 0x04ce0000,
487 .end = 0x04ce01ff,
488 .flags = IORESOURCE_MEM,
489 },
490 [1] = {
Magnus Damm3844ead2010-02-09 06:50:04 +0000491 .start = 100,
Magnus Damm0f79af62009-10-02 02:23:07 +0000492 .flags = IORESOURCE_IRQ,
493 },
494};
495
Guennadi Liakhovetski470ef1a2010-05-19 18:34:32 +0000496static struct sh_mobile_sdhi_info sh7724_sdhi0_data = {
497 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
498 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
499};
500
Magnus Damm0f79af62009-10-02 02:23:07 +0000501static struct platform_device sdhi0_cn7_device = {
502 .name = "sh_mobile_sdhi",
Magnus Damm5b380ec2009-10-27 10:49:55 +0000503 .id = 0,
Magnus Damm0f79af62009-10-02 02:23:07 +0000504 .num_resources = ARRAY_SIZE(sdhi0_cn7_resources),
505 .resource = sdhi0_cn7_resources,
Guennadi Liakhovetski470ef1a2010-05-19 18:34:32 +0000506 .dev = {
507 .platform_data = &sh7724_sdhi0_data,
508 },
Magnus Damm0f79af62009-10-02 02:23:07 +0000509 .archdata = {
510 .hwblk_id = HWBLK_SDHI0,
511 },
512};
513
Magnus Damm5b380ec2009-10-27 10:49:55 +0000514static struct resource sdhi1_cn8_resources[] = {
515 [0] = {
516 .name = "SDHI1",
517 .start = 0x04cf0000,
518 .end = 0x04cf01ff,
519 .flags = IORESOURCE_MEM,
520 },
521 [1] = {
Magnus Damm3844ead2010-02-09 06:50:04 +0000522 .start = 23,
Magnus Damm5b380ec2009-10-27 10:49:55 +0000523 .flags = IORESOURCE_IRQ,
524 },
525};
526
Guennadi Liakhovetski470ef1a2010-05-19 18:34:32 +0000527static struct sh_mobile_sdhi_info sh7724_sdhi1_data = {
528 .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
529 .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
530};
531
Magnus Damm5b380ec2009-10-27 10:49:55 +0000532static struct platform_device sdhi1_cn8_device = {
533 .name = "sh_mobile_sdhi",
534 .id = 1,
535 .num_resources = ARRAY_SIZE(sdhi1_cn8_resources),
536 .resource = sdhi1_cn8_resources,
Guennadi Liakhovetski470ef1a2010-05-19 18:34:32 +0000537 .dev = {
538 .platform_data = &sh7724_sdhi1_data,
539 },
Magnus Damm5b380ec2009-10-27 10:49:55 +0000540 .archdata = {
541 .hwblk_id = HWBLK_SDHI1,
542 },
543};
544
Kuninori Morimotobbb892a2010-02-23 08:19:14 +0000545/* IrDA */
546static struct resource irda_resources[] = {
547 [0] = {
548 .name = "IrDA",
549 .start = 0xA45D0000,
550 .end = 0xA45D0049,
551 .flags = IORESOURCE_MEM,
552 },
553 [1] = {
554 .start = 20,
555 .flags = IORESOURCE_IRQ,
556 },
557};
558
559static struct platform_device irda_device = {
560 .name = "sh_sir",
561 .num_resources = ARRAY_SIZE(irda_resources),
562 .resource = irda_resources,
563};
564
Guennadi Liakhovetski2d151242010-03-29 07:45:28 +0000565#include <media/ak881x.h>
566#include <media/sh_vou.h>
567
Kuninori Morimoto560526f2010-06-02 00:27:38 +0000568static struct ak881x_pdata ak881x_pdata = {
Guennadi Liakhovetski2d151242010-03-29 07:45:28 +0000569 .flags = AK881X_IF_MODE_SLAVE,
570};
571
572static struct i2c_board_info ak8813 = {
573 /* With open J18 jumper address is 0x21 */
574 I2C_BOARD_INFO("ak8813", 0x20),
575 .platform_data = &ak881x_pdata,
576};
577
Kuninori Morimoto560526f2010-06-02 00:27:38 +0000578static struct sh_vou_pdata sh_vou_pdata = {
Guennadi Liakhovetski2d151242010-03-29 07:45:28 +0000579 .bus_fmt = SH_VOU_BUS_8BIT,
580 .flags = SH_VOU_HSYNC_LOW | SH_VOU_VSYNC_LOW,
581 .board_info = &ak8813,
582 .i2c_adap = 0,
Guennadi Liakhovetski2d151242010-03-29 07:45:28 +0000583};
584
585static struct resource sh_vou_resources[] = {
586 [0] = {
587 .start = 0xfe960000,
588 .end = 0xfe962043,
589 .flags = IORESOURCE_MEM,
590 },
591 [1] = {
592 .start = 55,
593 .flags = IORESOURCE_IRQ,
594 },
595};
596
597static struct platform_device vou_device = {
598 .name = "sh-vou",
599 .id = -1,
600 .num_resources = ARRAY_SIZE(sh_vou_resources),
601 .resource = sh_vou_resources,
602 .dev = {
603 .platform_data = &sh_vou_pdata,
604 },
605 .archdata = {
606 .hwblk_id = HWBLK_VOU,
607 },
608};
609
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000610static struct platform_device *ms7724se_devices[] __initdata = {
611 &heartbeat_device,
612 &smc91x_eth_device,
613 &lcdc_device,
614 &nor_flash_device,
615 &ceu0_device,
616 &ceu1_device,
617 &keysc_device,
Kuninori Morimotoa80cad92009-06-26 07:05:39 +0000618 &sh_eth_device,
Magnus Damm9731f4a2009-07-03 09:40:03 +0000619 &sh7724_usb0_host_device,
Magnus Dammf8f8c072009-08-19 09:52:02 +0000620 &sh7724_usb1_gadget_device,
Kuninori Morimoto3e9ad522009-08-21 01:24:54 +0000621 &fsi_device,
Kuninori Morimotoc8d6bf92010-11-30 11:32:04 +0900622 &fsi_ak4642_device,
Magnus Damm0f79af62009-10-02 02:23:07 +0000623 &sdhi0_cn7_device,
Magnus Damm5b380ec2009-10-27 10:49:55 +0000624 &sdhi1_cn8_device,
Kuninori Morimotobbb892a2010-02-23 08:19:14 +0000625 &irda_device,
Guennadi Liakhovetski2d151242010-03-29 07:45:28 +0000626 &vou_device,
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000627};
628
Kuninori Morimoto9f815a12009-12-15 00:27:57 +0000629/* I2C device */
630static struct i2c_board_info i2c0_devices[] = {
631 {
632 I2C_BOARD_INFO("ak4642", 0x12),
633 },
634};
635
Kuninori Morimotoa80cad92009-06-26 07:05:39 +0000636#define EEPROM_OP 0xBA206000
637#define EEPROM_ADR 0xBA206004
638#define EEPROM_DATA 0xBA20600C
639#define EEPROM_STAT 0xBA206010
640#define EEPROM_STRT 0xBA206014
641static int __init sh_eth_is_eeprom_ready(void)
642{
643 int t = 10000;
644
645 while (t--) {
Paul Mundt9d56dd32010-01-26 12:58:40 +0900646 if (!__raw_readw(EEPROM_STAT))
Kuninori Morimotoa80cad92009-06-26 07:05:39 +0000647 return 1;
Kuninori Morimotoc718aff2009-12-24 08:31:44 +0000648 udelay(1);
Kuninori Morimotoa80cad92009-06-26 07:05:39 +0000649 }
650
651 printk(KERN_ERR "ms7724se can not access to eeprom\n");
652 return 0;
653}
654
655static void __init sh_eth_init(void)
656{
657 int i;
Magnus Damm8013cc92009-10-27 10:47:34 +0000658 u16 mac;
Kuninori Morimotoa80cad92009-06-26 07:05:39 +0000659
660 /* check EEPROM status */
661 if (!sh_eth_is_eeprom_ready())
662 return;
663
664 /* read MAC addr from EEPROM */
665 for (i = 0 ; i < 3 ; i++) {
Paul Mundt9d56dd32010-01-26 12:58:40 +0900666 __raw_writew(0x0, EEPROM_OP); /* read */
667 __raw_writew(i*2, EEPROM_ADR);
668 __raw_writew(0x1, EEPROM_STRT);
Kuninori Morimotoa80cad92009-06-26 07:05:39 +0000669 if (!sh_eth_is_eeprom_ready())
670 return;
671
Paul Mundt9d56dd32010-01-26 12:58:40 +0900672 mac = __raw_readw(EEPROM_DATA);
Magnus Damm8013cc92009-10-27 10:47:34 +0000673 sh_eth_plat.mac_addr[i << 1] = mac & 0xff;
674 sh_eth_plat.mac_addr[(i << 1) + 1] = mac >> 8;
Kuninori Morimotoa80cad92009-06-26 07:05:39 +0000675 }
Kuninori Morimotoa80cad92009-06-26 07:05:39 +0000676}
677
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000678#define SW4140 0xBA201000
679#define FPGA_OUT 0xBA200400
680#define PORT_HIZA 0xA4050158
Magnus Damm9731f4a2009-07-03 09:40:03 +0000681#define PORT_MSELCRB 0xA4050182
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000682
683#define SW41_A 0x0100
684#define SW41_B 0x0200
685#define SW41_C 0x0400
686#define SW41_D 0x0800
687#define SW41_E 0x1000
688#define SW41_F 0x2000
689#define SW41_G 0x4000
690#define SW41_H 0x8000
Magnus Damm9731f4a2009-07-03 09:40:03 +0000691
Magnus Damm3b9f2952009-10-29 10:52:23 +0000692extern char ms7724se_sdram_enter_start;
693extern char ms7724se_sdram_enter_end;
694extern char ms7724se_sdram_leave_start;
695extern char ms7724se_sdram_leave_end;
696
Kuninori Morimoto9f815a12009-12-15 00:27:57 +0000697
698static int __init arch_setup(void)
699{
700 /* enable I2C device */
701 i2c_register_board_info(0, i2c0_devices,
702 ARRAY_SIZE(i2c0_devices));
703 return 0;
704}
705arch_initcall(arch_setup);
706
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000707static int __init devices_setup(void)
708{
Paul Mundt9d56dd32010-01-26 12:58:40 +0900709 u16 sw = __raw_readw(SW4140); /* select camera, monitor */
Kuninori Morimoto16afc9f2010-02-22 05:18:10 +0000710 struct clk *clk;
Guennadi Liakhovetski2d151242010-03-29 07:45:28 +0000711 u16 fpga_out;
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000712
Magnus Damm3b9f2952009-10-29 10:52:23 +0000713 /* register board specific self-refresh code */
Magnus Dammb67cf282010-02-25 11:06:02 +0000714 sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF |
715 SUSP_SH_RSTANDBY,
Magnus Damm3b9f2952009-10-29 10:52:23 +0000716 &ms7724se_sdram_enter_start,
717 &ms7724se_sdram_enter_end,
718 &ms7724se_sdram_leave_start,
719 &ms7724se_sdram_leave_end);
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000720 /* Reset Release */
Guennadi Liakhovetski2d151242010-03-29 07:45:28 +0000721 fpga_out = __raw_readw(FPGA_OUT);
722 /* bit4: NTSC_PDN, bit5: NTSC_RESET */
723 fpga_out &= ~((1 << 1) | /* LAN */
724 (1 << 4) | /* AK8813 PDN */
725 (1 << 5) | /* AK8813 RESET */
726 (1 << 6) | /* VIDEO DAC */
727 (1 << 7) | /* AK4643 */
728 (1 << 8) | /* IrDA */
729 (1 << 12) | /* USB0 */
730 (1 << 14)); /* RMII */
731 __raw_writew(fpga_out | (1 << 4), FPGA_OUT);
732
733 udelay(10);
734
735 /* AK8813 RESET */
736 __raw_writew(fpga_out | (1 << 5), FPGA_OUT);
737
738 udelay(10);
739
740 __raw_writew(fpga_out, FPGA_OUT);
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000741
Magnus Damm9731f4a2009-07-03 09:40:03 +0000742 /* turn on USB clocks, use external clock */
Paul Mundt9d56dd32010-01-26 12:58:40 +0900743 __raw_writew((__raw_readw(PORT_MSELCRB) & ~0xc000) | 0x8000, PORT_MSELCRB);
Magnus Damm9731f4a2009-07-03 09:40:03 +0000744
Magnus Damm7766e162009-08-06 15:03:43 +0000745 /* Let LED9 show STATUS2 */
746 gpio_request(GPIO_FN_STATUS2, NULL);
747
748 /* Lit LED10 show STATUS0 */
749 gpio_request(GPIO_FN_STATUS0, NULL);
750
751 /* Lit LED11 show PDSTATUS */
752 gpio_request(GPIO_FN_PDSTATUS, NULL);
Magnus Damm7766e162009-08-06 15:03:43 +0000753
Magnus Damm9731f4a2009-07-03 09:40:03 +0000754 /* enable USB0 port */
Paul Mundt9d56dd32010-01-26 12:58:40 +0900755 __raw_writew(0x0600, 0xa40501d4);
Magnus Damm9731f4a2009-07-03 09:40:03 +0000756
Magnus Dammf8f8c072009-08-19 09:52:02 +0000757 /* enable USB1 port */
Paul Mundt9d56dd32010-01-26 12:58:40 +0900758 __raw_writew(0x0600, 0xa4050192);
Magnus Dammf8f8c072009-08-19 09:52:02 +0000759
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000760 /* enable IRQ 0,1,2 */
761 gpio_request(GPIO_FN_INTC_IRQ0, NULL);
762 gpio_request(GPIO_FN_INTC_IRQ1, NULL);
763 gpio_request(GPIO_FN_INTC_IRQ2, NULL);
764
765 /* enable SCIFA3 */
766 gpio_request(GPIO_FN_SCIF3_I_SCK, NULL);
767 gpio_request(GPIO_FN_SCIF3_I_RXD, NULL);
768 gpio_request(GPIO_FN_SCIF3_I_TXD, NULL);
769 gpio_request(GPIO_FN_SCIF3_I_CTS, NULL);
770 gpio_request(GPIO_FN_SCIF3_I_RTS, NULL);
771
772 /* enable LCDC */
773 gpio_request(GPIO_FN_LCDD23, NULL);
774 gpio_request(GPIO_FN_LCDD22, NULL);
775 gpio_request(GPIO_FN_LCDD21, NULL);
776 gpio_request(GPIO_FN_LCDD20, NULL);
777 gpio_request(GPIO_FN_LCDD19, NULL);
778 gpio_request(GPIO_FN_LCDD18, NULL);
779 gpio_request(GPIO_FN_LCDD17, NULL);
780 gpio_request(GPIO_FN_LCDD16, NULL);
781 gpio_request(GPIO_FN_LCDD15, NULL);
782 gpio_request(GPIO_FN_LCDD14, NULL);
783 gpio_request(GPIO_FN_LCDD13, NULL);
784 gpio_request(GPIO_FN_LCDD12, NULL);
785 gpio_request(GPIO_FN_LCDD11, NULL);
786 gpio_request(GPIO_FN_LCDD10, NULL);
787 gpio_request(GPIO_FN_LCDD9, NULL);
788 gpio_request(GPIO_FN_LCDD8, NULL);
789 gpio_request(GPIO_FN_LCDD7, NULL);
790 gpio_request(GPIO_FN_LCDD6, NULL);
791 gpio_request(GPIO_FN_LCDD5, NULL);
792 gpio_request(GPIO_FN_LCDD4, NULL);
793 gpio_request(GPIO_FN_LCDD3, NULL);
794 gpio_request(GPIO_FN_LCDD2, NULL);
795 gpio_request(GPIO_FN_LCDD1, NULL);
796 gpio_request(GPIO_FN_LCDD0, NULL);
797 gpio_request(GPIO_FN_LCDDISP, NULL);
798 gpio_request(GPIO_FN_LCDHSYN, NULL);
799 gpio_request(GPIO_FN_LCDDCK, NULL);
800 gpio_request(GPIO_FN_LCDVSYN, NULL);
801 gpio_request(GPIO_FN_LCDDON, NULL);
802 gpio_request(GPIO_FN_LCDVEPWC, NULL);
803 gpio_request(GPIO_FN_LCDVCPWC, NULL);
804 gpio_request(GPIO_FN_LCDRD, NULL);
805 gpio_request(GPIO_FN_LCDLCLK, NULL);
Paul Mundt9d56dd32010-01-26 12:58:40 +0900806 __raw_writew((__raw_readw(PORT_HIZA) & ~0x0001), PORT_HIZA);
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000807
808 /* enable CEU0 */
809 gpio_request(GPIO_FN_VIO0_D15, NULL);
810 gpio_request(GPIO_FN_VIO0_D14, NULL);
811 gpio_request(GPIO_FN_VIO0_D13, NULL);
812 gpio_request(GPIO_FN_VIO0_D12, NULL);
813 gpio_request(GPIO_FN_VIO0_D11, NULL);
814 gpio_request(GPIO_FN_VIO0_D10, NULL);
815 gpio_request(GPIO_FN_VIO0_D9, NULL);
816 gpio_request(GPIO_FN_VIO0_D8, NULL);
817 gpio_request(GPIO_FN_VIO0_D7, NULL);
818 gpio_request(GPIO_FN_VIO0_D6, NULL);
819 gpio_request(GPIO_FN_VIO0_D5, NULL);
820 gpio_request(GPIO_FN_VIO0_D4, NULL);
821 gpio_request(GPIO_FN_VIO0_D3, NULL);
822 gpio_request(GPIO_FN_VIO0_D2, NULL);
823 gpio_request(GPIO_FN_VIO0_D1, NULL);
824 gpio_request(GPIO_FN_VIO0_D0, NULL);
825 gpio_request(GPIO_FN_VIO0_VD, NULL);
826 gpio_request(GPIO_FN_VIO0_CLK, NULL);
827 gpio_request(GPIO_FN_VIO0_FLD, NULL);
828 gpio_request(GPIO_FN_VIO0_HD, NULL);
Magnus Damm84f75972009-07-01 04:55:35 +0000829 platform_resource_setup_memory(&ceu0_device, "ceu0", 4 << 20);
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000830
831 /* enable CEU1 */
832 gpio_request(GPIO_FN_VIO1_D7, NULL);
833 gpio_request(GPIO_FN_VIO1_D6, NULL);
834 gpio_request(GPIO_FN_VIO1_D5, NULL);
835 gpio_request(GPIO_FN_VIO1_D4, NULL);
836 gpio_request(GPIO_FN_VIO1_D3, NULL);
837 gpio_request(GPIO_FN_VIO1_D2, NULL);
838 gpio_request(GPIO_FN_VIO1_D1, NULL);
839 gpio_request(GPIO_FN_VIO1_D0, NULL);
840 gpio_request(GPIO_FN_VIO1_FLD, NULL);
841 gpio_request(GPIO_FN_VIO1_HD, NULL);
842 gpio_request(GPIO_FN_VIO1_VD, NULL);
843 gpio_request(GPIO_FN_VIO1_CLK, NULL);
Magnus Damm84f75972009-07-01 04:55:35 +0000844 platform_resource_setup_memory(&ceu1_device, "ceu1", 4 << 20);
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000845
846 /* KEYSC */
847 gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
848 gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);
849 gpio_request(GPIO_FN_KEYIN4, NULL);
850 gpio_request(GPIO_FN_KEYIN3, NULL);
851 gpio_request(GPIO_FN_KEYIN2, NULL);
852 gpio_request(GPIO_FN_KEYIN1, NULL);
853 gpio_request(GPIO_FN_KEYIN0, NULL);
854 gpio_request(GPIO_FN_KEYOUT3, NULL);
855 gpio_request(GPIO_FN_KEYOUT2, NULL);
856 gpio_request(GPIO_FN_KEYOUT1, NULL);
857 gpio_request(GPIO_FN_KEYOUT0, NULL);
858
Kuninori Morimoto3e9ad522009-08-21 01:24:54 +0000859 /* enable FSI */
860 gpio_request(GPIO_FN_FSIMCKB, NULL);
861 gpio_request(GPIO_FN_FSIMCKA, NULL);
862 gpio_request(GPIO_FN_FSIOASD, NULL);
863 gpio_request(GPIO_FN_FSIIABCK, NULL);
864 gpio_request(GPIO_FN_FSIIALRCK, NULL);
865 gpio_request(GPIO_FN_FSIOABCK, NULL);
866 gpio_request(GPIO_FN_FSIOALRCK, NULL);
867 gpio_request(GPIO_FN_CLKAUDIOAO, NULL);
868 gpio_request(GPIO_FN_FSIIBSD, NULL);
869 gpio_request(GPIO_FN_FSIOBSD, NULL);
870 gpio_request(GPIO_FN_FSIIBBCK, NULL);
871 gpio_request(GPIO_FN_FSIIBLRCK, NULL);
872 gpio_request(GPIO_FN_FSIOBBCK, NULL);
873 gpio_request(GPIO_FN_FSIOBLRCK, NULL);
874 gpio_request(GPIO_FN_CLKAUDIOBO, NULL);
875 gpio_request(GPIO_FN_FSIIASD, NULL);
876
Kuninori Morimoto16afc9f2010-02-22 05:18:10 +0000877 /* set SPU2 clock to 83.4 MHz */
878 clk = clk_get(NULL, "spu_clk");
Kuninori Morimoto03c5ecd2010-05-13 01:08:37 +0000879 if (clk) {
880 clk_set_rate(clk, clk_round_rate(clk, 83333333));
881 clk_put(clk);
882 }
Kuninori Morimoto16afc9f2010-02-22 05:18:10 +0000883
Kuninori Morimoto3e9ad522009-08-21 01:24:54 +0000884 /* change parent of FSI A */
Kuninori Morimoto16afc9f2010-02-22 05:18:10 +0000885 clk = clk_get(NULL, "fsia_clk");
Kuninori Morimoto03c5ecd2010-05-13 01:08:37 +0000886 if (clk) {
887 clk_register(&fsimcka_clk);
888 clk_set_parent(clk, &fsimcka_clk);
889 clk_set_rate(clk, 11000);
890 clk_set_rate(&fsimcka_clk, 11000);
891 clk_put(clk);
892 }
Kuninori Morimoto3e9ad522009-08-21 01:24:54 +0000893
Magnus Damm0f79af62009-10-02 02:23:07 +0000894 /* SDHI0 connected to cn7 */
895 gpio_request(GPIO_FN_SDHI0CD, NULL);
896 gpio_request(GPIO_FN_SDHI0WP, NULL);
897 gpio_request(GPIO_FN_SDHI0D3, NULL);
898 gpio_request(GPIO_FN_SDHI0D2, NULL);
899 gpio_request(GPIO_FN_SDHI0D1, NULL);
900 gpio_request(GPIO_FN_SDHI0D0, NULL);
901 gpio_request(GPIO_FN_SDHI0CMD, NULL);
902 gpio_request(GPIO_FN_SDHI0CLK, NULL);
903
Magnus Damm5b380ec2009-10-27 10:49:55 +0000904 /* SDHI1 connected to cn8 */
905 gpio_request(GPIO_FN_SDHI1CD, NULL);
906 gpio_request(GPIO_FN_SDHI1WP, NULL);
907 gpio_request(GPIO_FN_SDHI1D3, NULL);
908 gpio_request(GPIO_FN_SDHI1D2, NULL);
909 gpio_request(GPIO_FN_SDHI1D1, NULL);
910 gpio_request(GPIO_FN_SDHI1D0, NULL);
911 gpio_request(GPIO_FN_SDHI1CMD, NULL);
912 gpio_request(GPIO_FN_SDHI1CLK, NULL);
913
Kuninori Morimotobbb892a2010-02-23 08:19:14 +0000914 /* enable IrDA */
915 gpio_request(GPIO_FN_IRDA_OUT, NULL);
916 gpio_request(GPIO_FN_IRDA_IN, NULL);
917
Kuninori Morimotoa80cad92009-06-26 07:05:39 +0000918 /*
919 * enable SH-Eth
920 *
921 * please remove J33 pin from your board !!
922 *
923 * ms7724 board should not use GPIO_FN_LNKSTA pin
924 * So, This time PTX5 is set to input pin
925 */
926 gpio_request(GPIO_FN_RMII_RXD0, NULL);
927 gpio_request(GPIO_FN_RMII_RXD1, NULL);
928 gpio_request(GPIO_FN_RMII_TXD0, NULL);
929 gpio_request(GPIO_FN_RMII_TXD1, NULL);
930 gpio_request(GPIO_FN_RMII_REF_CLK, NULL);
931 gpio_request(GPIO_FN_RMII_TX_EN, NULL);
932 gpio_request(GPIO_FN_RMII_RX_ER, NULL);
933 gpio_request(GPIO_FN_RMII_CRS_DV, NULL);
934 gpio_request(GPIO_FN_MDIO, NULL);
935 gpio_request(GPIO_FN_MDC, NULL);
936 gpio_request(GPIO_PTX5, NULL);
937 gpio_direction_input(GPIO_PTX5);
938 sh_eth_init();
939
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000940 if (sw & SW41_B) {
Kuninori Morimoto4f324312009-08-03 04:52:03 +0000941 /* 720p */
Guennadi Liakhovetski44432402010-09-03 07:20:04 +0000942 lcdc_info.ch[0].lcd_cfg = lcdc_720p_modes;
943 lcdc_info.ch[0].num_cfg = ARRAY_SIZE(lcdc_720p_modes);
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000944 } else {
945 /* VGA */
Guennadi Liakhovetski44432402010-09-03 07:20:04 +0000946 lcdc_info.ch[0].lcd_cfg = lcdc_vga_modes;
947 lcdc_info.ch[0].num_cfg = ARRAY_SIZE(lcdc_vga_modes);
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000948 }
949
950 if (sw & SW41_A) {
951 /* Digital monitor */
952 lcdc_info.ch[0].interface_type = RGB18;
953 lcdc_info.ch[0].flags = 0;
954 } else {
955 /* Analog monitor */
956 lcdc_info.ch[0].interface_type = RGB24;
957 lcdc_info.ch[0].flags = LCDC_FLAGS_DWPOL;
958 }
959
Guennadi Liakhovetski2d151242010-03-29 07:45:28 +0000960 /* VOU */
961 gpio_request(GPIO_FN_DV_D15, NULL);
962 gpio_request(GPIO_FN_DV_D14, NULL);
963 gpio_request(GPIO_FN_DV_D13, NULL);
964 gpio_request(GPIO_FN_DV_D12, NULL);
965 gpio_request(GPIO_FN_DV_D11, NULL);
966 gpio_request(GPIO_FN_DV_D10, NULL);
967 gpio_request(GPIO_FN_DV_D9, NULL);
968 gpio_request(GPIO_FN_DV_D8, NULL);
969 gpio_request(GPIO_FN_DV_CLKI, NULL);
970 gpio_request(GPIO_FN_DV_CLK, NULL);
971 gpio_request(GPIO_FN_DV_VSYNC, NULL);
972 gpio_request(GPIO_FN_DV_HSYNC, NULL);
973
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000974 return platform_add_devices(ms7724se_devices,
Kuninori Morimotoa80cad92009-06-26 07:05:39 +0000975 ARRAY_SIZE(ms7724se_devices));
Kuninori Morimoto287c1292009-05-26 07:04:52 +0000976}
977device_initcall(devices_setup);
978
979static struct sh_machine_vector mv_ms7724se __initmv = {
980 .mv_name = "ms7724se",
981 .mv_init_irq = init_se7724_IRQ,
982 .mv_nr_irqs = SE7724_FPGA_IRQ_BASE + SE7724_FPGA_IRQ_NR,
983};