ARM: mach-shmobile: Kota2 GPIO LEDs support
[deliverable/linux.git] / arch / arm / mach-shmobile / board-kota2.c
CommitLineData
28626632
MD
1/*
2 * kota2 board support
3 *
4 * Copyright (C) 2011 Renesas Solutions Corp.
5 * Copyright (C) 2011 Magnus Damm
6 * Copyright (C) 2010 Takashi Yoshii <yoshii.takashi.zj@renesas.com>
7 * Copyright (C) 2009 Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 2 of the License.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#include <linux/kernel.h>
24#include <linux/init.h>
25#include <linux/interrupt.h>
26#include <linux/irq.h>
27#include <linux/platform_device.h>
28#include <linux/delay.h>
29#include <linux/io.h>
30#include <linux/smsc911x.h>
31#include <linux/gpio.h>
ef4f994a
MD
32#include <linux/input.h>
33#include <linux/input/sh_keysc.h>
6b7c0ea2 34#include <linux/gpio_keys.h>
ae6e7083 35#include <linux/leds.h>
28626632
MD
36#include <mach/hardware.h>
37#include <mach/sh73a0.h>
38#include <mach/common.h>
39#include <asm/mach-types.h>
40#include <asm/mach/arch.h>
41#include <asm/mach/map.h>
42#include <asm/mach/time.h>
43#include <asm/hardware/gic.h>
44#include <asm/hardware/cache-l2x0.h>
45#include <asm/traps.h>
46
47static struct resource smsc9220_resources[] = {
48 [0] = {
49 .start = 0x14000000, /* CS5A */
50 .end = 0x140000ff, /* A1->A7 */
51 .flags = IORESOURCE_MEM,
52 },
53 [1] = {
54 .start = gic_spi(33), /* PINTA2 @ PORT144 */
55 .flags = IORESOURCE_IRQ,
56 },
57};
58
59static struct smsc911x_platform_config smsc9220_platdata = {
60 .flags = SMSC911X_USE_32BIT, /* 32-bit SW on 16-bit HW bus */
61 .phy_interface = PHY_INTERFACE_MODE_MII,
62 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
63 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
64};
65
66static struct platform_device eth_device = {
67 .name = "smsc911x",
68 .id = 0,
69 .dev = {
70 .platform_data = &smsc9220_platdata,
71 },
72 .resource = smsc9220_resources,
73 .num_resources = ARRAY_SIZE(smsc9220_resources),
74};
75
ef4f994a
MD
76static struct sh_keysc_info keysc_platdata = {
77 .mode = SH_KEYSC_MODE_6,
78 .scan_timing = 3,
79 .delay = 100,
80 .keycodes = {
81 KEY_NUMERIC_STAR, KEY_NUMERIC_0, KEY_NUMERIC_POUND,
82 0, 0, 0, 0, 0,
83 KEY_NUMERIC_7, KEY_NUMERIC_8, KEY_NUMERIC_9,
84 0, KEY_DOWN, 0, 0, 0,
85 KEY_NUMERIC_4, KEY_NUMERIC_5, KEY_NUMERIC_6,
86 KEY_LEFT, KEY_ENTER, KEY_RIGHT, 0, 0,
87 KEY_NUMERIC_1, KEY_NUMERIC_2, KEY_NUMERIC_3,
88 0, KEY_UP, 0, 0, 0,
89 0, 0, 0, 0, 0, 0, 0, 0,
90 0, 0, 0, 0, 0, 0, 0, 0,
91 0, 0, 0, 0, 0, 0, 0, 0,
92 0, 0, 0, 0, 0, 0, 0, 0,
93 },
94};
95
96static struct resource keysc_resources[] = {
97 [0] = {
98 .name = "KEYSC",
99 .start = 0xe61b0000,
100 .end = 0xe61b0098 - 1,
101 .flags = IORESOURCE_MEM,
102 },
103 [1] = {
104 .start = gic_spi(71),
105 .flags = IORESOURCE_IRQ,
106 },
107};
108
109static struct platform_device keysc_device = {
110 .name = "sh_keysc",
111 .id = 0,
112 .num_resources = ARRAY_SIZE(keysc_resources),
113 .resource = keysc_resources,
114 .dev = {
115 .platform_data = &keysc_platdata,
116 },
117};
118
6b7c0ea2
MD
119#define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 }
120
121static struct gpio_keys_button gpio_buttons[] = {
122 GPIO_KEY(KEY_VOLUMEUP, GPIO_PORT56, "+"), /* S2: VOL+ [IRQ9] */
123 GPIO_KEY(KEY_VOLUMEDOWN, GPIO_PORT54, "-"), /* S3: VOL- [IRQ10] */
124 GPIO_KEY(KEY_MENU, GPIO_PORT27, "Menu"), /* S4: MENU [IRQ30] */
125 GPIO_KEY(KEY_HOMEPAGE, GPIO_PORT26, "Home"), /* S5: HOME [IRQ31] */
126 GPIO_KEY(KEY_BACK, GPIO_PORT11, "Back"), /* S6: BACK [IRQ0] */
127 GPIO_KEY(KEY_PHONE, GPIO_PORT238, "Tel"), /* S7: TEL [IRQ11] */
128 GPIO_KEY(KEY_POWER, GPIO_PORT239, "C1"), /* S8: CAM [IRQ13] */
129 GPIO_KEY(KEY_MAIL, GPIO_PORT224, "Mail"), /* S9: MAIL [IRQ3] */
130 /* Omitted button "C3?": GPIO_PORT223 - S10: CUST [IRQ8] */
131 GPIO_KEY(KEY_CAMERA, GPIO_PORT164, "C2"), /* S11: CAM_HALF [IRQ25] */
132 /* Omitted button "?": GPIO_PORT152 - S12: CAM_FULL [No IRQ] */
133};
134
135static struct gpio_keys_platform_data gpio_key_info = {
136 .buttons = gpio_buttons,
137 .nbuttons = ARRAY_SIZE(gpio_buttons),
138 .poll_interval = 250, /* polled for now */
139};
140
141static struct platform_device gpio_keys_device = {
142 .name = "gpio-keys-polled", /* polled for now */
143 .id = -1,
144 .dev = {
145 .platform_data = &gpio_key_info,
146 },
147};
148
ae6e7083
MD
149#define GPIO_LED(n, g) { .name = n, .gpio = g }
150
151static struct gpio_led gpio_leds[] = {
152 GPIO_LED("V2513", GPIO_PORT153), /* PORT153 [TPU1T02] -> V2513 */
153 GPIO_LED("V2514", GPIO_PORT199), /* PORT199 [TPU4TO1] -> V2514 */
154 GPIO_LED("V2515", GPIO_PORT197), /* PORT197 [TPU2TO1] -> V2515 */
155 GPIO_LED("KEYLED", GPIO_PORT163), /* PORT163 [TPU3TO0] -> KEYLED */
156 GPIO_LED("G", GPIO_PORT20), /* PORT20 [GPO0] -> LED7 -> "G" */
157 GPIO_LED("H", GPIO_PORT21), /* PORT21 [GPO1] -> LED8 -> "H" */
158 GPIO_LED("J", GPIO_PORT22), /* PORT22 [GPO2] -> LED9 -> "J" */
159};
160
161static struct gpio_led_platform_data gpio_leds_info = {
162 .leds = gpio_leds,
163 .num_leds = ARRAY_SIZE(gpio_leds),
164};
165
166static struct platform_device gpio_leds_device = {
167 .name = "leds-gpio",
168 .id = -1,
169 .dev = {
170 .platform_data = &gpio_leds_info,
171 },
172};
173
28626632
MD
174static struct platform_device *kota2_devices[] __initdata = {
175 &eth_device,
ef4f994a 176 &keysc_device,
6b7c0ea2 177 &gpio_keys_device,
ae6e7083 178 &gpio_leds_device,
28626632
MD
179};
180
181static struct map_desc kota2_io_desc[] __initdata = {
182 /* create a 1:1 entity map for 0xe6xxxxxx
183 * used by CPGA, INTC and PFC.
184 */
185 {
186 .virtual = 0xe6000000,
187 .pfn = __phys_to_pfn(0xe6000000),
188 .length = 256 << 20,
189 .type = MT_DEVICE_NONSHARED
190 },
191};
192
193static void __init kota2_map_io(void)
194{
195 iotable_init(kota2_io_desc, ARRAY_SIZE(kota2_io_desc));
196
197 /* setup early devices and console here as well */
198 sh73a0_add_early_devices();
199 shmobile_setup_console();
200}
201
202#define PINTER0A 0xe69000a0
203#define PINTCR0A 0xe69000b0
204
205void __init kota2_init_irq(void)
206{
207 sh73a0_init_irq();
208
209 /* setup PINT: enable PINTA2 as active low */
210 __raw_writel(1 << 29, PINTER0A);
211 __raw_writew(2 << 10, PINTCR0A);
212}
213
214static void __init kota2_init(void)
215{
216 sh73a0_pinmux_init();
217
218 /* SCIFA2 (UART2) */
219 gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
220 gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
221 gpio_request(GPIO_FN_SCIFA2_RTS1_, NULL);
222 gpio_request(GPIO_FN_SCIFA2_CTS1_, NULL);
223
224 /* SMSC911X */
225 gpio_request(GPIO_FN_D0_NAF0, NULL);
226 gpio_request(GPIO_FN_D1_NAF1, NULL);
227 gpio_request(GPIO_FN_D2_NAF2, NULL);
228 gpio_request(GPIO_FN_D3_NAF3, NULL);
229 gpio_request(GPIO_FN_D4_NAF4, NULL);
230 gpio_request(GPIO_FN_D5_NAF5, NULL);
231 gpio_request(GPIO_FN_D6_NAF6, NULL);
232 gpio_request(GPIO_FN_D7_NAF7, NULL);
233 gpio_request(GPIO_FN_D8_NAF8, NULL);
234 gpio_request(GPIO_FN_D9_NAF9, NULL);
235 gpio_request(GPIO_FN_D10_NAF10, NULL);
236 gpio_request(GPIO_FN_D11_NAF11, NULL);
237 gpio_request(GPIO_FN_D12_NAF12, NULL);
238 gpio_request(GPIO_FN_D13_NAF13, NULL);
239 gpio_request(GPIO_FN_D14_NAF14, NULL);
240 gpio_request(GPIO_FN_D15_NAF15, NULL);
241 gpio_request(GPIO_FN_CS5A_, NULL);
242 gpio_request(GPIO_FN_WE0__FWE, NULL);
243 gpio_request(GPIO_PORT144, NULL); /* PINTA2 */
244 gpio_direction_input(GPIO_PORT144);
245 gpio_request(GPIO_PORT145, NULL); /* RESET */
246 gpio_direction_output(GPIO_PORT145, 1);
247
ef4f994a
MD
248 /* KEYSC */
249 gpio_request(GPIO_FN_KEYIN0_PU, NULL);
250 gpio_request(GPIO_FN_KEYIN1_PU, NULL);
251 gpio_request(GPIO_FN_KEYIN2_PU, NULL);
252 gpio_request(GPIO_FN_KEYIN3_PU, NULL);
253 gpio_request(GPIO_FN_KEYIN4_PU, NULL);
254 gpio_request(GPIO_FN_KEYIN5_PU, NULL);
255 gpio_request(GPIO_FN_KEYIN6_PU, NULL);
256 gpio_request(GPIO_FN_KEYIN7_PU, NULL);
257 gpio_request(GPIO_FN_KEYOUT0, NULL);
258 gpio_request(GPIO_FN_KEYOUT1, NULL);
259 gpio_request(GPIO_FN_KEYOUT2, NULL);
260 gpio_request(GPIO_FN_KEYOUT3, NULL);
261 gpio_request(GPIO_FN_KEYOUT4, NULL);
262 gpio_request(GPIO_FN_KEYOUT5, NULL);
263 gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL);
264 gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL);
265 gpio_request(GPIO_FN_KEYOUT8, NULL);
266
28626632
MD
267#ifdef CONFIG_CACHE_L2X0
268 /* Early BRESP enable, Shared attribute override enable, 64K*8way */
269 l2x0_init(__io(0xf0100000), 0x40460000, 0x82000fff);
270#endif
271 sh73a0_add_standard_devices();
272 platform_add_devices(kota2_devices, ARRAY_SIZE(kota2_devices));
273}
274
275static void __init kota2_timer_init(void)
276{
277 sh73a0_clock_init();
278 shmobile_timer.init();
279 return;
280}
281
282struct sys_timer kota2_timer = {
283 .init = kota2_timer_init,
284};
285
286MACHINE_START(KOTA2, "kota2")
287 .map_io = kota2_map_io,
288 .init_irq = kota2_init_irq,
289 .handle_irq = shmobile_handle_irq_gic,
290 .init_machine = kota2_init,
291 .timer = &kota2_timer,
292MACHINE_END
This page took 0.03915 seconds and 5 git commands to generate.