blob: b9528b0211dca3282c5fd8d42ed4c12def6b2447 [file] [log] [blame]
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001/*
2 * mackerel board support
3 *
4 * Copyright (C) 2010 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * based on ap4evb
8 * Copyright (C) 2010 Magnus Damm
9 * Copyright (C) 2008 Yoshihiro Shimoda
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; version 2 of the License.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24#include <linux/kernel.h>
25#include <linux/init.h>
26#include <linux/interrupt.h>
27#include <linux/irq.h>
28#include <linux/platform_device.h>
29#include <linux/gpio.h>
30#include <linux/input.h>
31#include <linux/io.h>
Kuninori Morimotod44deb32010-11-30 06:52:18 +000032#include <linux/leds.h>
Kuninori Morimoto920adc72010-11-29 02:21:21 +000033#include <linux/mtd/mtd.h>
34#include <linux/mtd/partitions.h>
35#include <linux/mtd/physmap.h>
Kuninori Morimoto2264c152010-11-29 02:21:37 +000036#include <linux/smsc911x.h>
Kuninori Morimoto25338f22010-11-30 04:37:33 +000037#include <linux/usb/r8a66597.h>
Kuninori Morimoto920adc72010-11-29 02:21:21 +000038
Kuninori Morimoto11fee462010-11-29 02:21:43 +000039#include <video/sh_mobile_lcdc.h>
40
Kuninori Morimoto920adc72010-11-29 02:21:21 +000041#include <mach/common.h>
42#include <mach/sh7372.h>
43
44#include <asm/mach/arch.h>
45#include <asm/mach/time.h>
46#include <asm/mach/map.h>
47#include <asm/mach-types.h>
48
49/*
50 * Address Interface BusWidth note
51 * ------------------------------------------------------------------
52 * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON
53 * 0x0800_0000 user area -
54 * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF
55 * 0x1400_0000 Ether (LAN9220) 16bit
56 * 0x1600_0000 user area - cannot use with NAND
57 * 0x1800_0000 user area -
58 * 0x1A00_0000 -
59 * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit
60 */
61
Kuninori Morimoto4b82b682010-11-29 02:21:48 +000062/*
63 * CPU mode
64 *
65 * SW4 | Boot Area| Master | Remarks
66 * 1 | 2 | 3 | 4 | 5 | 6 | 8 | | Processor|
67 * ----+-----+-----+-----+-----+-----+-----+----------+----------+--------------
68 * ON | ON | OFF | ON | ON | OFF | OFF | External | System | External ROM
69 * ON | ON | ON | ON | ON | OFF | OFF | External | System | ROM Debug
70 * ON | ON | X | ON | OFF | OFF | OFF | Built-in | System | ROM Debug
71 * X | OFF | X | X | X | X | OFF | Built-in | System | MaskROM
72 * OFF | X | X | X | X | X | OFF | Built-in | System | MaskROM
73 * X | X | X | OFF | X | X | OFF | Built-in | System | MaskROM
74 * OFF | ON | OFF | X | X | OFF | ON | External | System | Standalone
75 * ON | OFF | OFF | X | X | OFF | ON | External | Realtime | Standalone
76*/
77
78/*
79 * NOR Flash ROM
80 *
81 * SW1 | SW2 | SW7 | NOR Flash ROM
82 * bit1 | bit1 bit2 | bit1 | Memory allocation
83 * ------+------------+------+------------------
84 * OFF | ON OFF | ON | Area 0
85 * OFF | ON OFF | OFF | Area 4
86 */
87
88/*
89 * SMSC 9220
90 *
91 * SW1 SMSC 9220
92 * -----------------------
93 * ON access disable
94 * OFF access enable
95 */
96
97/*
98 * NAND Flash ROM
99 *
100 * SW1 | SW2 | SW7 | NAND Flash ROM
101 * bit1 | bit1 bit2 | bit2 | Memory allocation
102 * ------+------------+------+------------------
103 * OFF | ON OFF | ON | FCE 0
104 * OFF | ON OFF | OFF | FCE 1
105 */
106
107/*
108 * External interrupt pin settings
109 *
110 * IRQX | pin setting | device | level
111 * ------+--------------------+--------------------+-------
112 * IRQ0 | ICR1A.IRQ0SA=0010 | SDHI2 card detect | Low
113 * IRQ6 | ICR1A.IRQ6SA=0011 | Ether(LAN9220) | High
114 * IRQ7 | ICR1A.IRQ7SA=0010 | LCD Tuch Panel | Low
115 * IRQ8 | ICR2A.IRQ8SA=0010 | MMC/SD card detect | Low
116 * IRQ9 | ICR2A.IRQ9SA=0010 | KEY(TCA6408) | Low
117 * IRQ21 | ICR4A.IRQ21SA=0011 | Sensor(ADXL345) | High
118 * IRQ22 | ICR4A.IRQ22SA=0011 | Sensor(AK8975) | High
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000119 */
Kuninori Morimoto4b82b682010-11-29 02:21:48 +0000120
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000121/*
122 * USB
123 *
124 * USB0 : CN22 : Function
125 * USB1 : CN31 : Function/Host *1
126 *
127 * J30 (for CN31) *1
128 * ----------+---------------+-------------
129 * 1-2 short | VBUS 5V | Host
130 * open | external VBUS | Function
131 *
132 * *1
133 * CN31 is used as Host in Linux.
134 */
Kuninori Morimoto4b82b682010-11-29 02:21:48 +0000135
Kuninori Morimoto920adc72010-11-29 02:21:21 +0000136/* MTD */
137static struct mtd_partition nor_flash_partitions[] = {
138 {
139 .name = "loader",
140 .offset = 0x00000000,
141 .size = 512 * 1024,
142 .mask_flags = MTD_WRITEABLE,
143 },
144 {
145 .name = "bootenv",
146 .offset = MTDPART_OFS_APPEND,
147 .size = 512 * 1024,
148 .mask_flags = MTD_WRITEABLE,
149 },
150 {
151 .name = "kernel_ro",
152 .offset = MTDPART_OFS_APPEND,
153 .size = 8 * 1024 * 1024,
154 .mask_flags = MTD_WRITEABLE,
155 },
156 {
157 .name = "kernel",
158 .offset = MTDPART_OFS_APPEND,
159 .size = 8 * 1024 * 1024,
160 },
161 {
162 .name = "data",
163 .offset = MTDPART_OFS_APPEND,
164 .size = MTDPART_SIZ_FULL,
165 },
166};
167
168static struct physmap_flash_data nor_flash_data = {
169 .width = 2,
170 .parts = nor_flash_partitions,
171 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
172};
173
174static struct resource nor_flash_resources[] = {
175 [0] = {
176 .start = 0x00000000,
177 .end = 0x08000000 - 1,
178 .flags = IORESOURCE_MEM,
179 }
180};
181
182static struct platform_device nor_flash_device = {
183 .name = "physmap-flash",
184 .dev = {
185 .platform_data = &nor_flash_data,
186 },
187 .num_resources = ARRAY_SIZE(nor_flash_resources),
188 .resource = nor_flash_resources,
189};
190
Kuninori Morimoto2264c152010-11-29 02:21:37 +0000191/* SMSC */
192static struct resource smc911x_resources[] = {
193 {
194 .start = 0x14000000,
195 .end = 0x16000000 - 1,
196 .flags = IORESOURCE_MEM,
197 }, {
198 .start = evt2irq(0x02c0) /* IRQ6A */,
199 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
200 },
201};
202
203static struct smsc911x_platform_config smsc911x_info = {
204 .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
205 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
206 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
207};
208
209static struct platform_device smc911x_device = {
210 .name = "smsc911x",
211 .id = -1,
212 .num_resources = ARRAY_SIZE(smc911x_resources),
213 .resource = smc911x_resources,
214 .dev = {
215 .platform_data = &smsc911x_info,
216 },
217};
218
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000219/* LCDC */
220static struct fb_videomode mackerel_lcdc_modes[] = {
221 {
222 .name = "WVGA Panel",
223 .xres = 800,
224 .yres = 480,
225 .left_margin = 220,
226 .right_margin = 110,
227 .hsync_len = 70,
228 .upper_margin = 20,
229 .lower_margin = 5,
230 .vsync_len = 5,
231 .sync = 0,
232 },
233};
234
235static struct sh_mobile_lcdc_info lcdc_info = {
236 .clock_source = LCDC_CLK_BUS,
237 .ch[0] = {
238 .chan = LCDC_CHAN_MAINLCD,
239 .bpp = 16,
240 .lcd_cfg = mackerel_lcdc_modes,
241 .num_cfg = ARRAY_SIZE(mackerel_lcdc_modes),
242 .interface_type = RGB24,
243 .clock_divider = 2,
244 .flags = 0,
245 .lcd_size_cfg.width = 152,
246 .lcd_size_cfg.height = 91,
247 }
248};
249
250static struct resource lcdc_resources[] = {
251 [0] = {
252 .name = "LCDC",
253 .start = 0xfe940000,
254 .end = 0xfe943fff,
255 .flags = IORESOURCE_MEM,
256 },
257 [1] = {
258 .start = intcs_evt2irq(0x580),
259 .flags = IORESOURCE_IRQ,
260 },
261};
262
263static struct platform_device lcdc_device = {
264 .name = "sh_mobile_lcdc_fb",
265 .num_resources = ARRAY_SIZE(lcdc_resources),
266 .resource = lcdc_resources,
267 .dev = {
268 .platform_data = &lcdc_info,
269 .coherent_dma_mask = ~0,
270 },
271};
272
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000273/* USB1 (Host) */
274static void usb1_host_port_power(int port, int power)
275{
276 if (!power) /* only power-on is supported for now */
277 return;
278
279 /* set VBOUT/PWEN and EXTLP1 in DVSTCTR */
280 __raw_writew(__raw_readw(0xE68B0008) | 0x600, 0xE68B0008);
281}
282
283static struct r8a66597_platdata usb1_host_data = {
284 .on_chip = 1,
285 .port_power = usb1_host_port_power,
286};
287
288static struct resource usb1_host_resources[] = {
289 [0] = {
290 .name = "USBHS",
291 .start = 0xE68B0000,
292 .end = 0xE68B00E6 - 1,
293 .flags = IORESOURCE_MEM,
294 },
295 [1] = {
296 .start = evt2irq(0x1ce0) /* USB1_USB1I0 */,
297 .flags = IORESOURCE_IRQ,
298 },
299};
300
301static struct platform_device usb1_host_device = {
302 .name = "r8a66597_hcd",
303 .id = 1,
304 .dev = {
305 .dma_mask = NULL, /* not use dma */
306 .coherent_dma_mask = 0xffffffff,
307 .platform_data = &usb1_host_data,
308 },
309 .num_resources = ARRAY_SIZE(usb1_host_resources),
310 .resource = usb1_host_resources,
311};
312
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000313/* LED */
314static struct gpio_led mackerel_leds[] = {
315 {
316 .name = "led0",
317 .gpio = GPIO_PORT0,
318 .default_state = LEDS_GPIO_DEFSTATE_ON,
319 },
320 {
321 .name = "led1",
322 .gpio = GPIO_PORT1,
323 .default_state = LEDS_GPIO_DEFSTATE_ON,
324 },
325 {
326 .name = "led2",
327 .gpio = GPIO_PORT2,
328 .default_state = LEDS_GPIO_DEFSTATE_ON,
329 },
330 {
331 .name = "led3",
332 .gpio = GPIO_PORT159,
333 .default_state = LEDS_GPIO_DEFSTATE_ON,
334 }
335};
336
337static struct gpio_led_platform_data mackerel_leds_pdata = {
338 .leds = mackerel_leds,
339 .num_leds = ARRAY_SIZE(mackerel_leds),
340};
341
342static struct platform_device leds_device = {
343 .name = "leds-gpio",
344 .id = 0,
345 .dev = {
346 .platform_data = &mackerel_leds_pdata,
347 },
348};
349
350
Kuninori Morimoto920adc72010-11-29 02:21:21 +0000351static struct platform_device *mackerel_devices[] __initdata = {
352 &nor_flash_device,
Kuninori Morimoto2264c152010-11-29 02:21:37 +0000353 &smc911x_device,
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000354 &lcdc_device,
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000355 &usb1_host_device,
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000356 &leds_device,
Kuninori Morimoto920adc72010-11-29 02:21:21 +0000357};
358
359static struct map_desc mackerel_io_desc[] __initdata = {
360 /* create a 1:1 entity map for 0xe6xxxxxx
361 * used by CPGA, INTC and PFC.
362 */
363 {
364 .virtual = 0xe6000000,
365 .pfn = __phys_to_pfn(0xe6000000),
366 .length = 256 << 20,
367 .type = MT_DEVICE_NONSHARED
368 },
369};
370
371static void __init mackerel_map_io(void)
372{
373 iotable_init(mackerel_io_desc, ARRAY_SIZE(mackerel_io_desc));
374
375 /* setup early devices and console here as well */
376 sh7372_add_early_devices();
377 shmobile_setup_console();
378}
379
380static void __init mackerel_init(void)
381{
382 sh7372_pinmux_init();
383
384 /* enable SCIFA0 */
385 gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
386 gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
387
Kuninori Morimoto2264c152010-11-29 02:21:37 +0000388 /* enable SMSC911X */
389 gpio_request(GPIO_FN_CS5A, NULL);
390 gpio_request(GPIO_FN_IRQ6_39, NULL);
391
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000392 /* LCDC */
Kuninori Morimotoeb87e672010-11-29 06:19:52 +0000393 gpio_request(GPIO_FN_LCDD23, NULL);
394 gpio_request(GPIO_FN_LCDD22, NULL);
395 gpio_request(GPIO_FN_LCDD21, NULL);
396 gpio_request(GPIO_FN_LCDD20, NULL);
397 gpio_request(GPIO_FN_LCDD19, NULL);
398 gpio_request(GPIO_FN_LCDD18, NULL);
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000399 gpio_request(GPIO_FN_LCDD17, NULL);
400 gpio_request(GPIO_FN_LCDD16, NULL);
401 gpio_request(GPIO_FN_LCDD15, NULL);
402 gpio_request(GPIO_FN_LCDD14, NULL);
403 gpio_request(GPIO_FN_LCDD13, NULL);
404 gpio_request(GPIO_FN_LCDD12, NULL);
405 gpio_request(GPIO_FN_LCDD11, NULL);
406 gpio_request(GPIO_FN_LCDD10, NULL);
407 gpio_request(GPIO_FN_LCDD9, NULL);
408 gpio_request(GPIO_FN_LCDD8, NULL);
409 gpio_request(GPIO_FN_LCDD7, NULL);
410 gpio_request(GPIO_FN_LCDD6, NULL);
411 gpio_request(GPIO_FN_LCDD5, NULL);
412 gpio_request(GPIO_FN_LCDD4, NULL);
413 gpio_request(GPIO_FN_LCDD3, NULL);
414 gpio_request(GPIO_FN_LCDD2, NULL);
415 gpio_request(GPIO_FN_LCDD1, NULL);
416 gpio_request(GPIO_FN_LCDD0, NULL);
417 gpio_request(GPIO_FN_LCDDISP, NULL);
418 gpio_request(GPIO_FN_LCDDCK, NULL);
419
420 gpio_request(GPIO_PORT31, NULL); /* backlight */
421 gpio_direction_output(GPIO_PORT31, 1);
422
423 gpio_request(GPIO_PORT151, NULL); /* LCDDON */
424 gpio_direction_output(GPIO_PORT151, 1);
425
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000426 /* USB enable */
427 gpio_request(GPIO_FN_VBUS0_1, NULL);
428 gpio_request(GPIO_FN_IDIN_1_18, NULL);
429 gpio_request(GPIO_FN_PWEN_1_115, NULL);
430 gpio_request(GPIO_FN_OVCN_1_114, NULL);
431 gpio_request(GPIO_FN_EXTLP_1, NULL);
432 gpio_request(GPIO_FN_OVCN2_1, NULL);
433
434 /* setup USB phy */
435 __raw_writew(0x8a0a, 0xE6058130); /* USBCR2 */
436
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000437
Kuninori Morimoto920adc72010-11-29 02:21:21 +0000438 sh7372_add_standard_devices();
439
440 platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices));
441}
442
443static void __init mackerel_timer_init(void)
444{
445 sh7372_clock_init();
446 shmobile_timer.init();
447}
448
449static struct sys_timer mackerel_timer = {
450 .init = mackerel_timer_init,
451};
452
453MACHINE_START(MACKEREL, "mackerel")
454 .map_io = mackerel_map_io,
455 .init_irq = sh7372_init_irq,
456 .init_machine = mackerel_init,
457 .timer = &mackerel_timer,
458MACHINE_END