blob: 135508040907163a6cb28d65650790fd007d9084 [file] [log] [blame]
Magnus Damme7d16512009-07-22 16:20:54 +00001/*
2 * KFR2R09 board support code
3 *
4 * Copyright (C) 2009 Magnus Damm
5 *
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
8 * for more details.
9 */
10#include <linux/init.h>
11#include <linux/platform_device.h>
12#include <linux/interrupt.h>
Magnus Damma366aa642009-07-22 16:22:28 +000013#include <linux/mtd/physmap.h>
Magnus Damme7d16512009-07-22 16:20:54 +000014#include <linux/delay.h>
15#include <linux/clk.h>
16#include <linux/gpio.h>
Magnus Damm39a6bf12009-07-22 16:23:45 +000017#include <linux/input.h>
Magnus Damm9f26e652009-08-06 14:51:30 +000018#include <video/sh_mobile_lcdc.h>
Magnus Damme7d16512009-07-22 16:20:54 +000019#include <asm/clock.h>
20#include <asm/machvec.h>
21#include <asm/io.h>
Magnus Damm39a6bf12009-07-22 16:23:45 +000022#include <asm/sh_keysc.h>
Magnus Damme7d16512009-07-22 16:20:54 +000023#include <cpu/sh7724.h>
Magnus Damm9f26e652009-08-06 14:51:30 +000024#include <mach/kfr2r09.h>
Magnus Damme7d16512009-07-22 16:20:54 +000025
Magnus Damma366aa642009-07-22 16:22:28 +000026static struct mtd_partition kfr2r09_nor_flash_partitions[] =
27{
28 {
29 .name = "boot",
30 .offset = 0,
31 .size = (4 * 1024 * 1024),
32 .mask_flags = MTD_WRITEABLE, /* Read-only */
33 },
34 {
35 .name = "other",
36 .offset = MTDPART_OFS_APPEND,
37 .size = MTDPART_SIZ_FULL,
38 },
39};
40
41static struct physmap_flash_data kfr2r09_nor_flash_data = {
42 .width = 2,
43 .parts = kfr2r09_nor_flash_partitions,
44 .nr_parts = ARRAY_SIZE(kfr2r09_nor_flash_partitions),
45};
46
47static struct resource kfr2r09_nor_flash_resources[] = {
48 [0] = {
49 .name = "NOR Flash",
50 .start = 0x00000000,
51 .end = 0x03ffffff,
52 .flags = IORESOURCE_MEM,
53 }
54};
55
56static struct platform_device kfr2r09_nor_flash_device = {
57 .name = "physmap-flash",
58 .resource = kfr2r09_nor_flash_resources,
59 .num_resources = ARRAY_SIZE(kfr2r09_nor_flash_resources),
60 .dev = {
61 .platform_data = &kfr2r09_nor_flash_data,
62 },
63};
64
Magnus Damm39a6bf12009-07-22 16:23:45 +000065static struct sh_keysc_info kfr2r09_sh_keysc_info = {
66 .mode = SH_KEYSC_MODE_1, /* KEYOUT0->4, KEYIN0->4 */
67 .scan_timing = 3,
68 .delay = 10,
69 .keycodes = {
70 KEY_PHONE, KEY_CLEAR, KEY_MAIL, KEY_WWW, KEY_ENTER,
71 KEY_1, KEY_2, KEY_3, 0, KEY_UP,
72 KEY_4, KEY_5, KEY_6, 0, KEY_LEFT,
73 KEY_7, KEY_8, KEY_9, KEY_PROG1, KEY_RIGHT,
74 KEY_S, KEY_0, KEY_P, KEY_PROG2, KEY_DOWN,
75 0, 0, 0, 0, 0
76 },
77};
78
79static struct resource kfr2r09_sh_keysc_resources[] = {
80 [0] = {
81 .name = "KEYSC",
82 .start = 0x044b0000,
83 .end = 0x044b000f,
84 .flags = IORESOURCE_MEM,
85 },
86 [1] = {
87 .start = 79,
88 .flags = IORESOURCE_IRQ,
89 },
90};
91
92static struct platform_device kfr2r09_sh_keysc_device = {
93 .name = "sh_keysc",
94 .id = 0, /* "keysc0" clock */
95 .num_resources = ARRAY_SIZE(kfr2r09_sh_keysc_resources),
96 .resource = kfr2r09_sh_keysc_resources,
97 .dev = {
98 .platform_data = &kfr2r09_sh_keysc_info,
99 },
100};
101
Magnus Damm9f26e652009-08-06 14:51:30 +0000102static struct sh_mobile_lcdc_info kfr2r09_sh_lcdc_info = {
103 .clock_source = LCDC_CLK_BUS,
104 .ch[0] = {
105 .chan = LCDC_CHAN_MAINLCD,
106 .bpp = 16,
107 .interface_type = SYS18,
108 .clock_divider = 6,
109 .flags = LCDC_FLAGS_DWPOL,
110 .lcd_cfg = {
111 .name = "TX07D34VM0AAA",
112 .xres = 240,
113 .yres = 400,
114 .left_margin = 0,
115 .right_margin = 16,
116 .hsync_len = 8,
117 .upper_margin = 0,
118 .lower_margin = 1,
119 .vsync_len = 1,
120 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
121 },
122 .lcd_size_cfg = {
123 .width = 35,
124 .height = 58,
125 },
126 .board_cfg = {
127 .setup_sys = kfr2r09_lcd_setup,
128 .display_on = kfr2r09_lcd_on,
129 .display_off = kfr2r09_lcd_off,
130 },
131 .sys_bus_cfg = {
132 .ldmt2r = 0x07010904,
133 .ldmt3r = 0x14012914,
134 /* set 1s delay to encourage fsync() */
135 .deferred_io_msec = 1000,
136 },
137 }
138};
139
140static struct resource kfr2r09_sh_lcdc_resources[] = {
141 [0] = {
142 .name = "LCDC",
143 .start = 0xfe940000, /* P4-only space */
144 .end = 0xfe941fff,
145 .flags = IORESOURCE_MEM,
146 },
147 [1] = {
148 .start = 106,
149 .flags = IORESOURCE_IRQ,
150 },
151};
152
153static struct platform_device kfr2r09_sh_lcdc_device = {
154 .name = "sh_mobile_lcdc_fb",
155 .num_resources = ARRAY_SIZE(kfr2r09_sh_lcdc_resources),
156 .resource = kfr2r09_sh_lcdc_resources,
157 .dev = {
158 .platform_data = &kfr2r09_sh_lcdc_info,
159 },
160};
161
Magnus Damma366aa642009-07-22 16:22:28 +0000162static struct platform_device *kfr2r09_devices[] __initdata = {
163 &kfr2r09_nor_flash_device,
Magnus Damm39a6bf12009-07-22 16:23:45 +0000164 &kfr2r09_sh_keysc_device,
Magnus Damm9f26e652009-08-06 14:51:30 +0000165 &kfr2r09_sh_lcdc_device,
Magnus Damma366aa642009-07-22 16:22:28 +0000166};
167
168#define BSC_CS0BCR 0xfec10004
169#define BSC_CS0WCR 0xfec10024
170
Magnus Damme7d16512009-07-22 16:20:54 +0000171static int __init kfr2r09_devices_setup(void)
172{
173 /* enable SCIF1 serial port for YC401 console support */
174 gpio_request(GPIO_FN_SCIF1_RXD, NULL);
175 gpio_request(GPIO_FN_SCIF1_TXD, NULL);
176
Magnus Damma366aa642009-07-22 16:22:28 +0000177 /* setup NOR flash at CS0 */
178 ctrl_outl(0x36db0400, BSC_CS0BCR);
179 ctrl_outl(0x00000500, BSC_CS0WCR);
180
Magnus Damm39a6bf12009-07-22 16:23:45 +0000181 /* setup KEYSC pins */
182 gpio_request(GPIO_FN_KEYOUT0, NULL);
183 gpio_request(GPIO_FN_KEYOUT1, NULL);
184 gpio_request(GPIO_FN_KEYOUT2, NULL);
185 gpio_request(GPIO_FN_KEYOUT3, NULL);
186 gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);
187 gpio_request(GPIO_FN_KEYIN0, NULL);
188 gpio_request(GPIO_FN_KEYIN1, NULL);
189 gpio_request(GPIO_FN_KEYIN2, NULL);
190 gpio_request(GPIO_FN_KEYIN3, NULL);
191 gpio_request(GPIO_FN_KEYIN4, NULL);
192 gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
193
Magnus Damm9f26e652009-08-06 14:51:30 +0000194 /* setup LCDC pins for SYS panel */
195 gpio_request(GPIO_FN_LCDD17, NULL);
196 gpio_request(GPIO_FN_LCDD16, NULL);
197 gpio_request(GPIO_FN_LCDD15, NULL);
198 gpio_request(GPIO_FN_LCDD14, NULL);
199 gpio_request(GPIO_FN_LCDD13, NULL);
200 gpio_request(GPIO_FN_LCDD12, NULL);
201 gpio_request(GPIO_FN_LCDD11, NULL);
202 gpio_request(GPIO_FN_LCDD10, NULL);
203 gpio_request(GPIO_FN_LCDD9, NULL);
204 gpio_request(GPIO_FN_LCDD8, NULL);
205 gpio_request(GPIO_FN_LCDD7, NULL);
206 gpio_request(GPIO_FN_LCDD6, NULL);
207 gpio_request(GPIO_FN_LCDD5, NULL);
208 gpio_request(GPIO_FN_LCDD4, NULL);
209 gpio_request(GPIO_FN_LCDD3, NULL);
210 gpio_request(GPIO_FN_LCDD2, NULL);
211 gpio_request(GPIO_FN_LCDD1, NULL);
212 gpio_request(GPIO_FN_LCDD0, NULL);
213 gpio_request(GPIO_FN_LCDRS, NULL); /* LCD_RS */
214 gpio_request(GPIO_FN_LCDCS, NULL); /* LCD_CS/ */
215 gpio_request(GPIO_FN_LCDRD, NULL); /* LCD_RD/ */
216 gpio_request(GPIO_FN_LCDWR, NULL); /* LCD_WR/ */
217 gpio_request(GPIO_FN_LCDVSYN, NULL); /* LCD_VSYNC */
218 gpio_request(GPIO_PTE4, NULL); /* LCD_RST/ */
219 gpio_direction_output(GPIO_PTE4, 1);
220 gpio_request(GPIO_PTF4, NULL); /* PROTECT/ */
221 gpio_direction_output(GPIO_PTF4, 1);
222 gpio_request(GPIO_PTU0, NULL); /* LEDSTDBY/ */
223 gpio_direction_output(GPIO_PTU0, 1);
224
Magnus Damma366aa642009-07-22 16:22:28 +0000225 return platform_add_devices(kfr2r09_devices,
226 ARRAY_SIZE(kfr2r09_devices));
Magnus Damme7d16512009-07-22 16:20:54 +0000227}
228device_initcall(kfr2r09_devices_setup);
229
230/* Return the board specific boot mode pin configuration */
231static int kfr2r09_mode_pins(void)
232{
233 /* MD0=1, MD1=1, MD2=0: Clock Mode 3
234 * MD3=0: 16-bit Area0 Bus Width
235 * MD5=1: Little Endian
236 * MD8=1: Test Mode Disabled
237 */
238 return MODE_PIN0 | MODE_PIN1 | MODE_PIN5 | MODE_PIN8;
239}
240
241/*
242 * The Machine Vector
243 */
244static struct sh_machine_vector mv_kfr2r09 __initmv = {
245 .mv_name = "kfr2r09",
246 .mv_mode_pins = kfr2r09_mode_pins,
247};