2 * mackerel board support
4 * Copyright (C) 2010 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
8 * Copyright (C) 2010 Magnus Damm
9 * Copyright (C) 2008 Yoshihiro Shimoda
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.
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.
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
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>
32 #include <linux/mtd/mtd.h>
33 #include <linux/mtd/partitions.h>
34 #include <linux/mtd/physmap.h>
35 #include <linux/smsc911x.h>
36 #include <linux/usb/r8a66597.h>
38 #include <video/sh_mobile_lcdc.h>
40 #include <mach/common.h>
41 #include <mach/sh7372.h>
43 #include <asm/mach/arch.h>
44 #include <asm/mach/time.h>
45 #include <asm/mach/map.h>
46 #include <asm/mach-types.h>
49 * Address Interface BusWidth note
50 * ------------------------------------------------------------------
51 * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON
52 * 0x0800_0000 user area -
53 * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF
54 * 0x1400_0000 Ether (LAN9220) 16bit
55 * 0x1600_0000 user area - cannot use with NAND
56 * 0x1800_0000 user area -
58 * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit
64 * SW4 | Boot Area| Master | Remarks
65 * 1 | 2 | 3 | 4 | 5 | 6 | 8 | | Processor|
66 * ----+-----+-----+-----+-----+-----+-----+----------+----------+--------------
67 * ON | ON | OFF | ON | ON | OFF | OFF | External | System | External ROM
68 * ON | ON | ON | ON | ON | OFF | OFF | External | System | ROM Debug
69 * ON | ON | X | ON | OFF | OFF | OFF | Built-in | System | ROM Debug
70 * X | OFF | X | X | X | X | OFF | Built-in | System | MaskROM
71 * OFF | X | X | X | X | X | OFF | Built-in | System | MaskROM
72 * X | X | X | OFF | X | X | OFF | Built-in | System | MaskROM
73 * OFF | ON | OFF | X | X | OFF | ON | External | System | Standalone
74 * ON | OFF | OFF | X | X | OFF | ON | External | Realtime | Standalone
80 * SW1 | SW2 | SW7 | NOR Flash ROM
81 * bit1 | bit1 bit2 | bit1 | Memory allocation
82 * ------+------------+------+------------------
83 * OFF | ON OFF | ON | Area 0
84 * OFF | ON OFF | OFF | Area 4
91 * -----------------------
99 * SW1 | SW2 | SW7 | NAND Flash ROM
100 * bit1 | bit1 bit2 | bit2 | Memory allocation
101 * ------+------------+------+------------------
102 * OFF | ON OFF | ON | FCE 0
103 * OFF | ON OFF | OFF | FCE 1
107 * External interrupt pin settings
109 * IRQX | pin setting | device | level
110 * ------+--------------------+--------------------+-------
111 * IRQ0 | ICR1A.IRQ0SA=0010 | SDHI2 card detect | Low
112 * IRQ6 | ICR1A.IRQ6SA=0011 | Ether(LAN9220) | High
113 * IRQ7 | ICR1A.IRQ7SA=0010 | LCD Tuch Panel | Low
114 * IRQ8 | ICR2A.IRQ8SA=0010 | MMC/SD card detect | Low
115 * IRQ9 | ICR2A.IRQ9SA=0010 | KEY(TCA6408) | Low
116 * IRQ21 | ICR4A.IRQ21SA=0011 | Sensor(ADXL345) | High
117 * IRQ22 | ICR4A.IRQ22SA=0011 | Sensor(AK8975) | High
123 * USB0 : CN22 : Function
124 * USB1 : CN31 : Function/Host *1
127 * ----------+---------------+-------------
128 * 1-2 short | VBUS 5V | Host
129 * open | external VBUS | Function
132 * CN31 is used as Host in Linux.
136 static struct mtd_partition nor_flash_partitions[] = {
139 .offset = 0x00000000,
141 .mask_flags = MTD_WRITEABLE,
145 .offset = MTDPART_OFS_APPEND,
147 .mask_flags = MTD_WRITEABLE,
151 .offset = MTDPART_OFS_APPEND,
152 .size = 8 * 1024 * 1024,
153 .mask_flags = MTD_WRITEABLE,
157 .offset = MTDPART_OFS_APPEND,
158 .size = 8 * 1024 * 1024,
162 .offset = MTDPART_OFS_APPEND,
163 .size = MTDPART_SIZ_FULL,
167 static struct physmap_flash_data nor_flash_data = {
169 .parts = nor_flash_partitions,
170 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
173 static struct resource nor_flash_resources[] = {
176 .end = 0x08000000 - 1,
177 .flags = IORESOURCE_MEM,
181 static struct platform_device nor_flash_device = {
182 .name = "physmap-flash",
184 .platform_data = &nor_flash_data,
186 .num_resources = ARRAY_SIZE(nor_flash_resources),
187 .resource = nor_flash_resources,
191 static struct resource smc911x_resources[] = {
194 .end = 0x16000000 - 1,
195 .flags = IORESOURCE_MEM,
197 .start = evt2irq(0x02c0) /* IRQ6A */,
198 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
202 static struct smsc911x_platform_config smsc911x_info = {
203 .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
204 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
205 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
208 static struct platform_device smc911x_device = {
211 .num_resources = ARRAY_SIZE(smc911x_resources),
212 .resource = smc911x_resources,
214 .platform_data = &smsc911x_info,
219 static struct fb_videomode mackerel_lcdc_modes[] = {
221 .name = "WVGA Panel",
234 static struct sh_mobile_lcdc_info lcdc_info = {
235 .clock_source = LCDC_CLK_BUS,
237 .chan = LCDC_CHAN_MAINLCD,
239 .lcd_cfg = mackerel_lcdc_modes,
240 .num_cfg = ARRAY_SIZE(mackerel_lcdc_modes),
241 .interface_type = RGB24,
244 .lcd_size_cfg.width = 152,
245 .lcd_size_cfg.height = 91,
249 static struct resource lcdc_resources[] = {
254 .flags = IORESOURCE_MEM,
257 .start = intcs_evt2irq(0x580),
258 .flags = IORESOURCE_IRQ,
262 static struct platform_device lcdc_device = {
263 .name = "sh_mobile_lcdc_fb",
264 .num_resources = ARRAY_SIZE(lcdc_resources),
265 .resource = lcdc_resources,
267 .platform_data = &lcdc_info,
268 .coherent_dma_mask = ~0,
273 static void usb1_host_port_power(int port, int power)
275 if (!power) /* only power-on is supported for now */
278 /* set VBOUT/PWEN and EXTLP1 in DVSTCTR */
279 __raw_writew(__raw_readw(0xE68B0008) | 0x600, 0xE68B0008);
282 static struct r8a66597_platdata usb1_host_data = {
284 .port_power = usb1_host_port_power,
287 static struct resource usb1_host_resources[] = {
291 .end = 0xE68B00E6 - 1,
292 .flags = IORESOURCE_MEM,
295 .start = evt2irq(0x1ce0) /* USB1_USB1I0 */,
296 .flags = IORESOURCE_IRQ,
300 static struct platform_device usb1_host_device = {
301 .name = "r8a66597_hcd",
304 .dma_mask = NULL, /* not use dma */
305 .coherent_dma_mask = 0xffffffff,
306 .platform_data = &usb1_host_data,
308 .num_resources = ARRAY_SIZE(usb1_host_resources),
309 .resource = usb1_host_resources,
312 static struct platform_device *mackerel_devices[] __initdata = {
319 static struct map_desc mackerel_io_desc[] __initdata = {
320 /* create a 1:1 entity map for 0xe6xxxxxx
321 * used by CPGA, INTC and PFC.
324 .virtual = 0xe6000000,
325 .pfn = __phys_to_pfn(0xe6000000),
327 .type = MT_DEVICE_NONSHARED
331 static void __init mackerel_map_io(void)
333 iotable_init(mackerel_io_desc, ARRAY_SIZE(mackerel_io_desc));
335 /* setup early devices and console here as well */
336 sh7372_add_early_devices();
337 shmobile_setup_console();
340 static void __init mackerel_init(void)
342 sh7372_pinmux_init();
345 gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
346 gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
348 /* enable SMSC911X */
349 gpio_request(GPIO_FN_CS5A, NULL);
350 gpio_request(GPIO_FN_IRQ6_39, NULL);
353 gpio_request(GPIO_FN_LCDD23, NULL);
354 gpio_request(GPIO_FN_LCDD22, NULL);
355 gpio_request(GPIO_FN_LCDD21, NULL);
356 gpio_request(GPIO_FN_LCDD20, NULL);
357 gpio_request(GPIO_FN_LCDD19, NULL);
358 gpio_request(GPIO_FN_LCDD18, NULL);
359 gpio_request(GPIO_FN_LCDD17, NULL);
360 gpio_request(GPIO_FN_LCDD16, NULL);
361 gpio_request(GPIO_FN_LCDD15, NULL);
362 gpio_request(GPIO_FN_LCDD14, NULL);
363 gpio_request(GPIO_FN_LCDD13, NULL);
364 gpio_request(GPIO_FN_LCDD12, NULL);
365 gpio_request(GPIO_FN_LCDD11, NULL);
366 gpio_request(GPIO_FN_LCDD10, NULL);
367 gpio_request(GPIO_FN_LCDD9, NULL);
368 gpio_request(GPIO_FN_LCDD8, NULL);
369 gpio_request(GPIO_FN_LCDD7, NULL);
370 gpio_request(GPIO_FN_LCDD6, NULL);
371 gpio_request(GPIO_FN_LCDD5, NULL);
372 gpio_request(GPIO_FN_LCDD4, NULL);
373 gpio_request(GPIO_FN_LCDD3, NULL);
374 gpio_request(GPIO_FN_LCDD2, NULL);
375 gpio_request(GPIO_FN_LCDD1, NULL);
376 gpio_request(GPIO_FN_LCDD0, NULL);
377 gpio_request(GPIO_FN_LCDDISP, NULL);
378 gpio_request(GPIO_FN_LCDDCK, NULL);
380 gpio_request(GPIO_PORT31, NULL); /* backlight */
381 gpio_direction_output(GPIO_PORT31, 1);
383 gpio_request(GPIO_PORT151, NULL); /* LCDDON */
384 gpio_direction_output(GPIO_PORT151, 1);
387 gpio_request(GPIO_FN_VBUS0_1, NULL);
388 gpio_request(GPIO_FN_IDIN_1_18, NULL);
389 gpio_request(GPIO_FN_PWEN_1_115, NULL);
390 gpio_request(GPIO_FN_OVCN_1_114, NULL);
391 gpio_request(GPIO_FN_EXTLP_1, NULL);
392 gpio_request(GPIO_FN_OVCN2_1, NULL);
395 __raw_writew(0x8a0a, 0xE6058130); /* USBCR2 */
398 sh7372_add_standard_devices();
400 platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices));
403 static void __init mackerel_timer_init(void)
406 shmobile_timer.init();
409 static struct sys_timer mackerel_timer = {
410 .init = mackerel_timer_init,
413 MACHINE_START(MACKEREL, "mackerel")
414 .map_io = mackerel_map_io,
415 .init_irq = sh7372_init_irq,
416 .init_machine = mackerel_init,
417 .timer = &mackerel_timer,