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/i2c.h>
33 #include <linux/leds.h>
34 #include <linux/mtd/mtd.h>
35 #include <linux/mtd/partitions.h>
36 #include <linux/mtd/physmap.h>
37 #include <linux/smsc911x.h>
38 #include <linux/sh_intc.h>
39 #include <linux/tca6416_keypad.h>
40 #include <linux/usb/r8a66597.h>
42 #include <video/sh_mobile_lcdc.h>
44 #include <sound/sh_fsi.h>
46 #include <mach/common.h>
47 #include <mach/sh7372.h>
49 #include <asm/mach/arch.h>
50 #include <asm/mach/time.h>
51 #include <asm/mach/map.h>
52 #include <asm/mach-types.h>
55 * Address Interface BusWidth note
56 * ------------------------------------------------------------------
57 * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON
58 * 0x0800_0000 user area -
59 * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF
60 * 0x1400_0000 Ether (LAN9220) 16bit
61 * 0x1600_0000 user area - cannot use with NAND
62 * 0x1800_0000 user area -
64 * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit
70 * SW4 | Boot Area| Master | Remarks
71 * 1 | 2 | 3 | 4 | 5 | 6 | 8 | | Processor|
72 * ----+-----+-----+-----+-----+-----+-----+----------+----------+--------------
73 * ON | ON | OFF | ON | ON | OFF | OFF | External | System | External ROM
74 * ON | ON | ON | ON | ON | OFF | OFF | External | System | ROM Debug
75 * ON | ON | X | ON | OFF | OFF | OFF | Built-in | System | ROM Debug
76 * X | OFF | X | X | X | X | OFF | Built-in | System | MaskROM
77 * OFF | X | X | X | X | X | OFF | Built-in | System | MaskROM
78 * X | X | X | OFF | X | X | OFF | Built-in | System | MaskROM
79 * OFF | ON | OFF | X | X | OFF | ON | External | System | Standalone
80 * ON | OFF | OFF | X | X | OFF | ON | External | Realtime | Standalone
86 * SW1 | SW2 | SW7 | NOR Flash ROM
87 * bit1 | bit1 bit2 | bit1 | Memory allocation
88 * ------+------------+------+------------------
89 * OFF | ON OFF | ON | Area 0
90 * OFF | ON OFF | OFF | Area 4
97 * -----------------------
105 * SW1 | SW2 | SW7 | NAND Flash ROM
106 * bit1 | bit1 bit2 | bit2 | Memory allocation
107 * ------+------------+------+------------------
108 * OFF | ON OFF | ON | FCE 0
109 * OFF | ON OFF | OFF | FCE 1
113 * External interrupt pin settings
115 * IRQX | pin setting | device | level
116 * ------+--------------------+--------------------+-------
117 * IRQ0 | ICR1A.IRQ0SA=0010 | SDHI2 card detect | Low
118 * IRQ6 | ICR1A.IRQ6SA=0011 | Ether(LAN9220) | High
119 * IRQ7 | ICR1A.IRQ7SA=0010 | LCD Tuch Panel | Low
120 * IRQ8 | ICR2A.IRQ8SA=0010 | MMC/SD card detect | Low
121 * IRQ9 | ICR2A.IRQ9SA=0010 | KEY(TCA6408) | Low
122 * IRQ21 | ICR4A.IRQ21SA=0011 | Sensor(ADXL345) | High
123 * IRQ22 | ICR4A.IRQ22SA=0011 | Sensor(AK8975) | High
129 * USB0 : CN22 : Function
130 * USB1 : CN31 : Function/Host *1
133 * ----------+---------------+-------------
134 * 1-2 short | VBUS 5V | Host
135 * open | external VBUS | Function
138 * CN31 is used as Host in Linux.
147 * current gpio frame work doesn't have
148 * the method to control only pull up/down/free.
149 * this function should be replaced by correct gpio function
151 static void __init gpio_no_direction(u32 addr)
153 __raw_writeb(0x00, addr);
157 static struct mtd_partition nor_flash_partitions[] = {
160 .offset = 0x00000000,
162 .mask_flags = MTD_WRITEABLE,
166 .offset = MTDPART_OFS_APPEND,
168 .mask_flags = MTD_WRITEABLE,
172 .offset = MTDPART_OFS_APPEND,
173 .size = 8 * 1024 * 1024,
174 .mask_flags = MTD_WRITEABLE,
178 .offset = MTDPART_OFS_APPEND,
179 .size = 8 * 1024 * 1024,
183 .offset = MTDPART_OFS_APPEND,
184 .size = MTDPART_SIZ_FULL,
188 static struct physmap_flash_data nor_flash_data = {
190 .parts = nor_flash_partitions,
191 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
194 static struct resource nor_flash_resources[] = {
197 .end = 0x08000000 - 1,
198 .flags = IORESOURCE_MEM,
202 static struct platform_device nor_flash_device = {
203 .name = "physmap-flash",
205 .platform_data = &nor_flash_data,
207 .num_resources = ARRAY_SIZE(nor_flash_resources),
208 .resource = nor_flash_resources,
212 static struct resource smc911x_resources[] = {
215 .end = 0x16000000 - 1,
216 .flags = IORESOURCE_MEM,
218 .start = evt2irq(0x02c0) /* IRQ6A */,
219 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
223 static struct smsc911x_platform_config smsc911x_info = {
224 .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
225 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
226 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
229 static struct platform_device smc911x_device = {
232 .num_resources = ARRAY_SIZE(smc911x_resources),
233 .resource = smc911x_resources,
235 .platform_data = &smsc911x_info,
240 static struct fb_videomode mackerel_lcdc_modes[] = {
242 .name = "WVGA Panel",
255 static struct sh_mobile_lcdc_info lcdc_info = {
256 .clock_source = LCDC_CLK_BUS,
258 .chan = LCDC_CHAN_MAINLCD,
260 .lcd_cfg = mackerel_lcdc_modes,
261 .num_cfg = ARRAY_SIZE(mackerel_lcdc_modes),
262 .interface_type = RGB24,
265 .lcd_size_cfg.width = 152,
266 .lcd_size_cfg.height = 91,
270 static struct resource lcdc_resources[] = {
275 .flags = IORESOURCE_MEM,
278 .start = intcs_evt2irq(0x580),
279 .flags = IORESOURCE_IRQ,
283 static struct platform_device lcdc_device = {
284 .name = "sh_mobile_lcdc_fb",
285 .num_resources = ARRAY_SIZE(lcdc_resources),
286 .resource = lcdc_resources,
288 .platform_data = &lcdc_info,
289 .coherent_dma_mask = ~0,
294 static void usb1_host_port_power(int port, int power)
296 if (!power) /* only power-on is supported for now */
299 /* set VBOUT/PWEN and EXTLP1 in DVSTCTR */
300 __raw_writew(__raw_readw(0xE68B0008) | 0x600, 0xE68B0008);
303 static struct r8a66597_platdata usb1_host_data = {
305 .port_power = usb1_host_port_power,
308 static struct resource usb1_host_resources[] = {
312 .end = 0xE68B00E6 - 1,
313 .flags = IORESOURCE_MEM,
316 .start = evt2irq(0x1ce0) /* USB1_USB1I0 */,
317 .flags = IORESOURCE_IRQ,
321 static struct platform_device usb1_host_device = {
322 .name = "r8a66597_hcd",
325 .dma_mask = NULL, /* not use dma */
326 .coherent_dma_mask = 0xffffffff,
327 .platform_data = &usb1_host_data,
329 .num_resources = ARRAY_SIZE(usb1_host_resources),
330 .resource = usb1_host_resources,
334 static struct gpio_led mackerel_leds[] = {
338 .default_state = LEDS_GPIO_DEFSTATE_ON,
343 .default_state = LEDS_GPIO_DEFSTATE_ON,
348 .default_state = LEDS_GPIO_DEFSTATE_ON,
352 .gpio = GPIO_PORT159,
353 .default_state = LEDS_GPIO_DEFSTATE_ON,
357 static struct gpio_led_platform_data mackerel_leds_pdata = {
358 .leds = mackerel_leds,
359 .num_leds = ARRAY_SIZE(mackerel_leds),
362 static struct platform_device leds_device = {
366 .platform_data = &mackerel_leds_pdata,
371 #define IRQ_FSI evt2irq(0x1840)
372 static struct sh_fsi_platform_info fsi_info = {
373 .porta_flags = SH_FSI_BRS_INV |
374 SH_FSI_OUT_SLAVE_MODE |
375 SH_FSI_IN_SLAVE_MODE |
380 static struct resource fsi_resources[] = {
384 .end = 0xFE3C0400 - 1,
385 .flags = IORESOURCE_MEM,
389 .flags = IORESOURCE_IRQ,
393 static struct platform_device fsi_device = {
396 .num_resources = ARRAY_SIZE(fsi_resources),
397 .resource = fsi_resources,
399 .platform_data = &fsi_info,
403 static struct platform_device fsi_ak4643_device = {
404 .name = "sh_fsi2_a_ak4643",
407 static struct platform_device *mackerel_devices[] __initdata = {
417 /* Keypad Initialization */
418 #define KEYPAD_BUTTON(ev_type, ev_code, act_low) \
422 .active_low = act_low, \
425 #define KEYPAD_BUTTON_LOW(event_code) KEYPAD_BUTTON(EV_KEY, event_code, 1)
427 static struct tca6416_button mackerel_gpio_keys[] = {
428 KEYPAD_BUTTON_LOW(KEY_HOME),
429 KEYPAD_BUTTON_LOW(KEY_MENU),
430 KEYPAD_BUTTON_LOW(KEY_BACK),
431 KEYPAD_BUTTON_LOW(KEY_POWER),
434 static struct tca6416_keys_platform_data mackerel_tca6416_keys_info = {
435 .buttons = mackerel_gpio_keys,
436 .nbuttons = ARRAY_SIZE(mackerel_gpio_keys),
443 #define IRQ9 evt2irq(0x0320)
445 static struct i2c_board_info i2c0_devices[] = {
447 I2C_BOARD_INFO("ak4643", 0x13),
451 I2C_BOARD_INFO("tca6408-keys", 0x20),
452 .platform_data = &mackerel_tca6416_keys_info,
457 #define IRQ21 evt2irq(0x32a0)
459 static struct i2c_board_info i2c1_devices[] = {
462 I2C_BOARD_INFO("adxl34x", 0x53),
467 static struct map_desc mackerel_io_desc[] __initdata = {
468 /* create a 1:1 entity map for 0xe6xxxxxx
469 * used by CPGA, INTC and PFC.
472 .virtual = 0xe6000000,
473 .pfn = __phys_to_pfn(0xe6000000),
475 .type = MT_DEVICE_NONSHARED
479 static void __init mackerel_map_io(void)
481 iotable_init(mackerel_io_desc, ARRAY_SIZE(mackerel_io_desc));
483 /* setup early devices and console here as well */
484 sh7372_add_early_devices();
485 shmobile_setup_console();
488 #define GPIO_PORT9CR 0xE6051009
489 #define GPIO_PORT10CR 0xE605100A
490 static void __init mackerel_init(void)
492 sh7372_pinmux_init();
495 gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
496 gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
498 /* enable SMSC911X */
499 gpio_request(GPIO_FN_CS5A, NULL);
500 gpio_request(GPIO_FN_IRQ6_39, NULL);
503 gpio_request(GPIO_FN_LCDD23, NULL);
504 gpio_request(GPIO_FN_LCDD22, NULL);
505 gpio_request(GPIO_FN_LCDD21, NULL);
506 gpio_request(GPIO_FN_LCDD20, NULL);
507 gpio_request(GPIO_FN_LCDD19, NULL);
508 gpio_request(GPIO_FN_LCDD18, NULL);
509 gpio_request(GPIO_FN_LCDD17, NULL);
510 gpio_request(GPIO_FN_LCDD16, NULL);
511 gpio_request(GPIO_FN_LCDD15, NULL);
512 gpio_request(GPIO_FN_LCDD14, NULL);
513 gpio_request(GPIO_FN_LCDD13, NULL);
514 gpio_request(GPIO_FN_LCDD12, NULL);
515 gpio_request(GPIO_FN_LCDD11, NULL);
516 gpio_request(GPIO_FN_LCDD10, NULL);
517 gpio_request(GPIO_FN_LCDD9, NULL);
518 gpio_request(GPIO_FN_LCDD8, NULL);
519 gpio_request(GPIO_FN_LCDD7, NULL);
520 gpio_request(GPIO_FN_LCDD6, NULL);
521 gpio_request(GPIO_FN_LCDD5, NULL);
522 gpio_request(GPIO_FN_LCDD4, NULL);
523 gpio_request(GPIO_FN_LCDD3, NULL);
524 gpio_request(GPIO_FN_LCDD2, NULL);
525 gpio_request(GPIO_FN_LCDD1, NULL);
526 gpio_request(GPIO_FN_LCDD0, NULL);
527 gpio_request(GPIO_FN_LCDDISP, NULL);
528 gpio_request(GPIO_FN_LCDDCK, NULL);
530 gpio_request(GPIO_PORT31, NULL); /* backlight */
531 gpio_direction_output(GPIO_PORT31, 1);
533 gpio_request(GPIO_PORT151, NULL); /* LCDDON */
534 gpio_direction_output(GPIO_PORT151, 1);
537 gpio_request(GPIO_FN_VBUS0_1, NULL);
538 gpio_request(GPIO_FN_IDIN_1_18, NULL);
539 gpio_request(GPIO_FN_PWEN_1_115, NULL);
540 gpio_request(GPIO_FN_OVCN_1_114, NULL);
541 gpio_request(GPIO_FN_EXTLP_1, NULL);
542 gpio_request(GPIO_FN_OVCN2_1, NULL);
545 __raw_writew(0x8a0a, 0xE6058130); /* USBCR2 */
547 /* enable FSI2 port A (ak4643) */
548 gpio_request(GPIO_FN_FSIAIBT, NULL);
549 gpio_request(GPIO_FN_FSIAILR, NULL);
550 gpio_request(GPIO_FN_FSIAISLD, NULL);
551 gpio_request(GPIO_FN_FSIAOSLD, NULL);
552 gpio_request(GPIO_PORT161, NULL);
553 gpio_direction_output(GPIO_PORT161, 0); /* slave */
555 gpio_request(GPIO_PORT9, NULL);
556 gpio_request(GPIO_PORT10, NULL);
557 gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */
558 gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */
560 intc_set_priority(IRQ_FSI, 3); /* irq priority FSI(3) > SMSC911X(2) */
563 gpio_request(GPIO_FN_IRQ9_42, NULL);
564 set_irq_type(IRQ9, IRQ_TYPE_LEVEL_HIGH);
566 /* enable Accelerometer */
567 gpio_request(GPIO_FN_IRQ21, NULL);
568 set_irq_type(IRQ21, IRQ_TYPE_LEVEL_HIGH);
570 i2c_register_board_info(0, i2c0_devices,
571 ARRAY_SIZE(i2c0_devices));
572 i2c_register_board_info(1, i2c1_devices,
573 ARRAY_SIZE(i2c1_devices));
575 sh7372_add_standard_devices();
577 platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices));
580 static void __init mackerel_timer_init(void)
583 shmobile_timer.init();
586 static struct sys_timer mackerel_timer = {
587 .init = mackerel_timer_init,
590 MACHINE_START(MACKEREL, "mackerel")
591 .map_io = mackerel_map_io,
592 .init_irq = sh7372_init_irq,
593 .init_machine = mackerel_init,
594 .timer = &mackerel_timer,