ARM: mach-shmobile: G3EVM KEYSC platform data
[deliverable/linux.git] / arch / arm / mach-shmobile / board-g3evm.c
CommitLineData
c793c1b0
MD
1/*
2 * G3EVM board support
3 *
4 * Copyright (C) 2010 Magnus Damm
5 * Copyright (C) 2008 Yoshihiro Shimoda
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20#include <linux/kernel.h>
21#include <linux/init.h>
22#include <linux/interrupt.h>
23#include <linux/irq.h>
24#include <linux/platform_device.h>
25#include <linux/delay.h>
26#include <linux/mtd/mtd.h>
27#include <linux/mtd/partitions.h>
28#include <linux/mtd/physmap.h>
3a7b802d 29#include <linux/usb/r8a66597.h>
c793c1b0 30#include <linux/io.h>
7fdda678 31#include <linux/gpio.h>
03fb256d
MD
32#include <linux/input.h>
33#include <linux/input/sh_keysc.h>
7fdda678 34#include <mach/sh7367.h>
c793c1b0
MD
35#include <mach/common.h>
36#include <asm/mach-types.h>
37#include <asm/mach/arch.h>
38#include <asm/mach/map.h>
39
40static struct mtd_partition nor_flash_partitions[] = {
41 {
42 .name = "loader",
43 .offset = 0x00000000,
44 .size = 512 * 1024,
45 },
46 {
47 .name = "bootenv",
48 .offset = MTDPART_OFS_APPEND,
49 .size = 512 * 1024,
50 },
51 {
52 .name = "kernel_ro",
53 .offset = MTDPART_OFS_APPEND,
54 .size = 8 * 1024 * 1024,
55 .mask_flags = MTD_WRITEABLE,
56 },
57 {
58 .name = "kernel",
59 .offset = MTDPART_OFS_APPEND,
60 .size = 8 * 1024 * 1024,
61 },
62 {
63 .name = "data",
64 .offset = MTDPART_OFS_APPEND,
65 .size = MTDPART_SIZ_FULL,
66 },
67};
68
69static struct physmap_flash_data nor_flash_data = {
70 .width = 2,
71 .parts = nor_flash_partitions,
72 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
73};
74
75static struct resource nor_flash_resources[] = {
76 [0] = {
77 .start = 0x00000000,
78 .end = 0x08000000 - 1,
79 .flags = IORESOURCE_MEM,
80 }
81};
82
83static struct platform_device nor_flash_device = {
84 .name = "physmap-flash",
85 .dev = {
86 .platform_data = &nor_flash_data,
87 },
88 .num_resources = ARRAY_SIZE(nor_flash_resources),
89 .resource = nor_flash_resources,
90};
91
3a7b802d
MD
92/* USBHS */
93void usb_host_port_power(int port, int power)
94{
95 if (!power) /* only power-on supported for now */
96 return;
97
98 /* set VBOUT/PWEN and EXTLP0 in DVSTCTR */
99 __raw_writew(__raw_readw(0xe6890008) | 0x600, 0xe6890008);
100}
101
102static struct r8a66597_platdata usb_host_data = {
103 .on_chip = 1,
104 .port_power = usb_host_port_power,
105};
106
107static struct resource usb_host_resources[] = {
108 [0] = {
109 .name = "USBHS",
110 .start = 0xe6890000,
111 .end = 0xe68900e5,
112 .flags = IORESOURCE_MEM,
113 },
114 [1] = {
115 .start = 65,
116 .flags = IORESOURCE_IRQ,
117 },
118};
119
120static struct platform_device usb_host_device = {
121 .name = "r8a66597_hcd",
122 .id = 0,
123 .dev = {
124 .platform_data = &usb_host_data,
125 .dma_mask = NULL,
126 .coherent_dma_mask = 0xffffffff,
127 },
128 .num_resources = ARRAY_SIZE(usb_host_resources),
129 .resource = usb_host_resources,
130};
c793c1b0 131
03fb256d
MD
132/* KEYSC */
133static struct sh_keysc_info keysc_info = {
134 .mode = SH_KEYSC_MODE_5,
135 .scan_timing = 3,
136 .delay = 100,
137 .keycodes = {
138 KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G,
139 KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N,
140 KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U,
141 KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_HOME, KEY_SLEEP,
142 KEY_WAKEUP, KEY_COFFEE, KEY_0, KEY_1, KEY_2, KEY_3, KEY_4,
143 KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_STOP, KEY_COMPUTER,
144 },
145};
146
147static struct resource keysc_resources[] = {
148 [0] = {
149 .name = "KEYSC",
150 .start = 0xe61b0000,
151 .end = 0xe61b000f,
152 .flags = IORESOURCE_MEM,
153 },
154 [1] = {
155 .start = 79,
156 .flags = IORESOURCE_IRQ,
157 },
158};
159
160static struct platform_device keysc_device = {
161 .name = "sh_keysc",
162 .num_resources = ARRAY_SIZE(keysc_resources),
163 .resource = keysc_resources,
164 .dev = {
165 .platform_data = &keysc_info,
166 },
167};
168
c793c1b0
MD
169static struct platform_device *g3evm_devices[] __initdata = {
170 &nor_flash_device,
3a7b802d 171 &usb_host_device,
03fb256d 172 &keysc_device,
c793c1b0
MD
173};
174
175static struct map_desc g3evm_io_desc[] __initdata = {
176 /* create a 1:1 entity map for 0xe6xxxxxx
177 * used by CPGA, INTC and PFC.
178 */
179 {
180 .virtual = 0xe6000000,
181 .pfn = __phys_to_pfn(0xe6000000),
182 .length = 256 << 20,
183 .type = MT_DEVICE_NONSHARED
184 },
185};
186
187static void __init g3evm_map_io(void)
188{
189 iotable_init(g3evm_io_desc, ARRAY_SIZE(g3evm_io_desc));
190
4ae04acb 191 /* setup early devices, clocks and console here as well */
c793c1b0
MD
192 sh7367_add_early_devices();
193 sh7367_clock_init();
4ae04acb 194 shmobile_setup_console();
c793c1b0
MD
195}
196
197static void __init g3evm_init(void)
198{
7fdda678
MD
199 sh7367_pinmux_init();
200
201 /* Lit DS4 LED */
202 gpio_request(GPIO_PORT22, NULL);
203 gpio_direction_output(GPIO_PORT22, 1);
204 gpio_export(GPIO_PORT22, 0);
205
206 /* Lit DS8 LED */
207 gpio_request(GPIO_PORT23, NULL);
208 gpio_direction_output(GPIO_PORT23, 1);
209 gpio_export(GPIO_PORT23, 0);
210
211 /* Lit DS3 LED */
212 gpio_request(GPIO_PORT24, NULL);
213 gpio_direction_output(GPIO_PORT24, 1);
214 gpio_export(GPIO_PORT24, 0);
215
216 /* SCIFA1 */
217 gpio_request(GPIO_FN_SCIFA1_TXD, NULL);
218 gpio_request(GPIO_FN_SCIFA1_RXD, NULL);
219 gpio_request(GPIO_FN_SCIFA1_CTS, NULL);
220 gpio_request(GPIO_FN_SCIFA1_RTS, NULL);
221
3a7b802d
MD
222 /* USBHS */
223 gpio_request(GPIO_FN_VBUS0, NULL);
224 gpio_request(GPIO_FN_PWEN, NULL);
225 gpio_request(GPIO_FN_OVCN, NULL);
226 gpio_request(GPIO_FN_OVCN2, NULL);
227 gpio_request(GPIO_FN_EXTLP, NULL);
228 gpio_request(GPIO_FN_IDIN, NULL);
229
230 /* enable clock in SYMSTPCR2 */
231 __raw_writel(__raw_readl(0xe6158048) & ~(1 << 22), 0xe6158048);
232
233 /* setup USB phy */
234 __raw_writew(0x0300, 0xe605810a); /* USBCR1 */
235 __raw_writew(0x00e0, 0xe60581c0); /* CPFCH */
236 __raw_writew(0x6010, 0xe60581c6); /* CGPOSR */
237 __raw_writew(0x8a0a, 0xe605810c); /* USBCR2 */
238
03fb256d
MD
239 /* KEYSC @ CN7 */
240 gpio_request(GPIO_FN_PORT42_KEYOUT0, NULL);
241 gpio_request(GPIO_FN_PORT43_KEYOUT1, NULL);
242 gpio_request(GPIO_FN_PORT44_KEYOUT2, NULL);
243 gpio_request(GPIO_FN_PORT45_KEYOUT3, NULL);
244 gpio_request(GPIO_FN_PORT46_KEYOUT4, NULL);
245 gpio_request(GPIO_FN_PORT47_KEYOUT5, NULL);
246 gpio_request(GPIO_FN_PORT48_KEYIN0_PU, NULL);
247 gpio_request(GPIO_FN_PORT49_KEYIN1_PU, NULL);
248 gpio_request(GPIO_FN_PORT50_KEYIN2_PU, NULL);
249 gpio_request(GPIO_FN_PORT55_KEYIN3_PU, NULL);
250 gpio_request(GPIO_FN_PORT56_KEYIN4_PU, NULL);
251 gpio_request(GPIO_FN_PORT57_KEYIN5_PU, NULL);
252 gpio_request(GPIO_FN_PORT58_KEYIN6_PU, NULL);
253
c793c1b0
MD
254 sh7367_add_standard_devices();
255
256 platform_add_devices(g3evm_devices, ARRAY_SIZE(g3evm_devices));
257}
258
259MACHINE_START(G3EVM, "g3evm")
260 .phys_io = 0xe6000000,
261 .io_pg_offst = ((0xe6000000) >> 18) & 0xfffc,
262 .map_io = g3evm_map_io,
263 .init_irq = sh7367_init_irq,
264 .init_machine = g3evm_init,
265 .timer = &shmobile_timer,
266MACHINE_END
This page took 0.036707 seconds and 5 git commands to generate.