2 * KFR2R09 board support code
4 * Copyright (C) 2009 Magnus Damm
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
10 #include <linux/init.h>
11 #include <linux/platform_device.h>
12 #include <linux/interrupt.h>
13 #include <linux/mtd/physmap.h>
14 #include <linux/delay.h>
15 #include <linux/clk.h>
16 #include <linux/gpio.h>
17 #include <linux/input.h>
18 #include <asm/clock.h>
19 #include <asm/machvec.h>
21 #include <asm/sh_keysc.h>
22 #include <cpu/sh7724.h>
24 static struct mtd_partition kfr2r09_nor_flash_partitions[] =
29 .size = (4 * 1024 * 1024),
30 .mask_flags = MTD_WRITEABLE, /* Read-only */
34 .offset = MTDPART_OFS_APPEND,
35 .size = MTDPART_SIZ_FULL,
39 static struct physmap_flash_data kfr2r09_nor_flash_data = {
41 .parts = kfr2r09_nor_flash_partitions,
42 .nr_parts = ARRAY_SIZE(kfr2r09_nor_flash_partitions),
45 static struct resource kfr2r09_nor_flash_resources[] = {
50 .flags = IORESOURCE_MEM,
54 static struct platform_device kfr2r09_nor_flash_device = {
55 .name = "physmap-flash",
56 .resource = kfr2r09_nor_flash_resources,
57 .num_resources = ARRAY_SIZE(kfr2r09_nor_flash_resources),
59 .platform_data = &kfr2r09_nor_flash_data,
63 static struct sh_keysc_info kfr2r09_sh_keysc_info = {
64 .mode = SH_KEYSC_MODE_1, /* KEYOUT0->4, KEYIN0->4 */
68 KEY_PHONE, KEY_CLEAR, KEY_MAIL, KEY_WWW, KEY_ENTER,
69 KEY_1, KEY_2, KEY_3, 0, KEY_UP,
70 KEY_4, KEY_5, KEY_6, 0, KEY_LEFT,
71 KEY_7, KEY_8, KEY_9, KEY_PROG1, KEY_RIGHT,
72 KEY_S, KEY_0, KEY_P, KEY_PROG2, KEY_DOWN,
77 static struct resource kfr2r09_sh_keysc_resources[] = {
82 .flags = IORESOURCE_MEM,
86 .flags = IORESOURCE_IRQ,
90 static struct platform_device kfr2r09_sh_keysc_device = {
92 .id = 0, /* "keysc0" clock */
93 .num_resources = ARRAY_SIZE(kfr2r09_sh_keysc_resources),
94 .resource = kfr2r09_sh_keysc_resources,
96 .platform_data = &kfr2r09_sh_keysc_info,
99 .hwblk_id = HWBLK_KEYSC,
103 static struct platform_device *kfr2r09_devices[] __initdata = {
104 &kfr2r09_nor_flash_device,
105 &kfr2r09_sh_keysc_device,
108 #define BSC_CS0BCR 0xfec10004
109 #define BSC_CS0WCR 0xfec10024
111 static int __init kfr2r09_devices_setup(void)
113 /* enable SCIF1 serial port for YC401 console support */
114 gpio_request(GPIO_FN_SCIF1_RXD, NULL);
115 gpio_request(GPIO_FN_SCIF1_TXD, NULL);
117 /* setup NOR flash at CS0 */
118 ctrl_outl(0x36db0400, BSC_CS0BCR);
119 ctrl_outl(0x00000500, BSC_CS0WCR);
121 /* setup KEYSC pins */
122 gpio_request(GPIO_FN_KEYOUT0, NULL);
123 gpio_request(GPIO_FN_KEYOUT1, NULL);
124 gpio_request(GPIO_FN_KEYOUT2, NULL);
125 gpio_request(GPIO_FN_KEYOUT3, NULL);
126 gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);
127 gpio_request(GPIO_FN_KEYIN0, NULL);
128 gpio_request(GPIO_FN_KEYIN1, NULL);
129 gpio_request(GPIO_FN_KEYIN2, NULL);
130 gpio_request(GPIO_FN_KEYIN3, NULL);
131 gpio_request(GPIO_FN_KEYIN4, NULL);
132 gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
134 return platform_add_devices(kfr2r09_devices,
135 ARRAY_SIZE(kfr2r09_devices));
137 device_initcall(kfr2r09_devices_setup);
139 /* Return the board specific boot mode pin configuration */
140 static int kfr2r09_mode_pins(void)
142 /* MD0=1, MD1=1, MD2=0: Clock Mode 3
143 * MD3=0: 16-bit Area0 Bus Width
144 * MD5=1: Little Endian
145 * MD8=1: Test Mode Disabled
147 return MODE_PIN0 | MODE_PIN1 | MODE_PIN5 | MODE_PIN8;
153 static struct sh_machine_vector mv_kfr2r09 __initmv = {
154 .mv_name = "kfr2r09",
155 .mv_mode_pins = kfr2r09_mode_pins,