]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - arch/arm/mach-at91/board-gsia18s.c
ARM: at91: remove static irq priorities for sam9x5
[mirror_ubuntu-artful-kernel.git] / arch / arm / mach-at91 / board-gsia18s.c
CommitLineData
fcdc2ea7
IP
1/*
2 * Copyright (C) 2010 Christian Glindkamp <christian.glindkamp@taskit.de>
3 * taskit GmbH
4 * 2010 Igor Plyatov <plyatov@gmail.com>
5 * GeoSIG Ltd
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; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#include <linux/platform_device.h>
23#include <linux/gpio.h>
24#include <linux/w1-gpio.h>
25#include <linux/i2c.h>
26#include <linux/i2c/pcf857x.h>
27#include <linux/gpio_keys.h>
28#include <linux/input.h>
29
30#include <asm/mach-types.h>
31#include <asm/mach/arch.h>
32
33#include <mach/board.h>
34#include <mach/at91sam9_smc.h>
35#include <mach/gsia18s.h>
36#include <mach/stamp9g20.h>
37
38#include "sam9_smc.h"
39#include "generic.h"
40
1b021a3b 41static void __init gsia18s_init_early(void)
fcdc2ea7 42{
1b021a3b 43 stamp9g20_init_early();
fcdc2ea7
IP
44}
45
fcdc2ea7
IP
46/*
47 * Two USB Host ports
48 */
49static struct at91_usbh_data __initdata usbh_data = {
50 .ports = 2,
63b4c296
JCPV
51 .vbus_pin = {-EINVAL, -EINVAL},
52 .overcurrent_pin= {-EINVAL, -EINVAL},
fcdc2ea7
IP
53};
54
55/*
56 * USB Device port
57 */
58static struct at91_udc_data __initdata udc_data = {
59 .vbus_pin = AT91_PIN_PA22,
63b4c296 60 .pullup_pin = -EINVAL, /* pull-up driven by UDC */
fcdc2ea7
IP
61};
62
63/*
64 * MACB Ethernet device
65 */
84e0cdb0 66static struct macb_platform_data __initdata macb_data = {
fcdc2ea7
IP
67 .phy_irq_pin = AT91_PIN_PA28,
68 .is_rmii = 1,
69};
70
71/*
72 * LEDs and GPOs
73 */
74static struct gpio_led gpio_leds[] = {
75 {
76 .name = "gpo:spi1reset",
77 .gpio = AT91_PIN_PC1,
78 .active_low = 0,
79 .default_trigger = "none",
80 .default_state = LEDS_GPIO_DEFSTATE_OFF,
81 },
82 {
83 .name = "gpo:trig_net_out",
84 .gpio = AT91_PIN_PB20,
85 .active_low = 0,
86 .default_trigger = "none",
87 .default_state = LEDS_GPIO_DEFSTATE_OFF,
88 },
89 {
90 .name = "gpo:trig_net_dir",
91 .gpio = AT91_PIN_PB19,
92 .active_low = 0,
93 .default_trigger = "none",
94 .default_state = LEDS_GPIO_DEFSTATE_OFF,
95 },
96 {
97 .name = "gpo:charge_dis",
98 .gpio = AT91_PIN_PC2,
99 .active_low = 0,
100 .default_trigger = "none",
101 .default_state = LEDS_GPIO_DEFSTATE_OFF,
102 },
103 {
104 .name = "led:event",
105 .gpio = AT91_PIN_PB17,
106 .active_low = 1,
107 .default_trigger = "none",
108 .default_state = LEDS_GPIO_DEFSTATE_OFF,
109 },
110 {
111 .name = "led:lan",
112 .gpio = AT91_PIN_PB18,
113 .active_low = 1,
114 .default_trigger = "none",
115 .default_state = LEDS_GPIO_DEFSTATE_OFF,
116 },
117 {
118 .name = "led:error",
119 .gpio = AT91_PIN_PB16,
120 .active_low = 1,
121 .default_trigger = "none",
122 .default_state = LEDS_GPIO_DEFSTATE_ON,
123 }
124};
125
126static struct gpio_led_platform_data gpio_led_info = {
127 .leds = gpio_leds,
128 .num_leds = ARRAY_SIZE(gpio_leds),
129};
130
131static struct platform_device leds = {
132 .name = "leds-gpio",
133 .id = 0,
134 .dev = {
135 .platform_data = &gpio_led_info,
136 }
137};
138
139static void __init gsia18s_leds_init(void)
140{
141 platform_device_register(&leds);
142}
143
144/* PCF8574 0x20 GPIO - U1 on the GS_IA18-CB_V3 board */
145static struct gpio_led pcf_gpio_leds1[] = {
146 { /* bit 0 */
147 .name = "gpo:hdc_power",
148 .gpio = PCF_GPIO_HDC_POWER,
149 .active_low = 0,
150 .default_trigger = "none",
151 .default_state = LEDS_GPIO_DEFSTATE_OFF,
152 },
153 { /* bit 1 */
154 .name = "gpo:wifi_setup",
155 .gpio = PCF_GPIO_WIFI_SETUP,
156 .active_low = 1,
157 .default_trigger = "none",
158 .default_state = LEDS_GPIO_DEFSTATE_OFF,
159 },
160 { /* bit 2 */
161 .name = "gpo:wifi_enable",
162 .gpio = PCF_GPIO_WIFI_ENABLE,
163 .active_low = 1,
164 .default_trigger = "none",
165 .default_state = LEDS_GPIO_DEFSTATE_OFF,
166 },
167 { /* bit 3 */
168 .name = "gpo:wifi_reset",
169 .gpio = PCF_GPIO_WIFI_RESET,
170 .active_low = 1,
171 .default_trigger = "none",
172 .default_state = LEDS_GPIO_DEFSTATE_ON,
173 },
174 /* bit 4 used as GPI */
175 { /* bit 5 */
176 .name = "gpo:gps_setup",
177 .gpio = PCF_GPIO_GPS_SETUP,
178 .active_low = 1,
179 .default_trigger = "none",
180 .default_state = LEDS_GPIO_DEFSTATE_OFF,
181 },
182 { /* bit 6 */
183 .name = "gpo:gps_standby",
184 .gpio = PCF_GPIO_GPS_STANDBY,
185 .active_low = 0,
186 .default_trigger = "none",
187 .default_state = LEDS_GPIO_DEFSTATE_ON,
188 },
189 { /* bit 7 */
190 .name = "gpo:gps_power",
191 .gpio = PCF_GPIO_GPS_POWER,
192 .active_low = 0,
193 .default_trigger = "none",
194 .default_state = LEDS_GPIO_DEFSTATE_OFF,
195 }
196};
197
198static struct gpio_led_platform_data pcf_gpio_led_info1 = {
199 .leds = pcf_gpio_leds1,
200 .num_leds = ARRAY_SIZE(pcf_gpio_leds1),
201};
202
203static struct platform_device pcf_leds1 = {
204 .name = "leds-gpio", /* GS_IA18-CB_board */
205 .id = 1,
206 .dev = {
207 .platform_data = &pcf_gpio_led_info1,
208 }
209};
210
211/* PCF8574 0x22 GPIO - U1 on the GS_2G_OPT1-A_V0 board (Alarm) */
212static struct gpio_led pcf_gpio_leds2[] = {
213 { /* bit 0 */
214 .name = "gpo:alarm_1",
215 .gpio = PCF_GPIO_ALARM1,
216 .active_low = 1,
217 .default_trigger = "none",
218 .default_state = LEDS_GPIO_DEFSTATE_OFF,
219 },
220 { /* bit 1 */
221 .name = "gpo:alarm_2",
222 .gpio = PCF_GPIO_ALARM2,
223 .active_low = 1,
224 .default_trigger = "none",
225 .default_state = LEDS_GPIO_DEFSTATE_OFF,
226 },
227 { /* bit 2 */
228 .name = "gpo:alarm_3",
229 .gpio = PCF_GPIO_ALARM3,
230 .active_low = 1,
231 .default_trigger = "none",
232 .default_state = LEDS_GPIO_DEFSTATE_OFF,
233 },
234 { /* bit 3 */
235 .name = "gpo:alarm_4",
236 .gpio = PCF_GPIO_ALARM4,
237 .active_low = 1,
238 .default_trigger = "none",
239 .default_state = LEDS_GPIO_DEFSTATE_OFF,
240 },
241 /* bits 4, 5, 6 not used */
242 { /* bit 7 */
243 .name = "gpo:alarm_v_relay_on",
244 .gpio = PCF_GPIO_ALARM_V_RELAY_ON,
245 .active_low = 0,
246 .default_trigger = "none",
247 .default_state = LEDS_GPIO_DEFSTATE_OFF,
248 },
249};
250
251static struct gpio_led_platform_data pcf_gpio_led_info2 = {
252 .leds = pcf_gpio_leds2,
253 .num_leds = ARRAY_SIZE(pcf_gpio_leds2),
254};
255
256static struct platform_device pcf_leds2 = {
257 .name = "leds-gpio",
258 .id = 2,
259 .dev = {
260 .platform_data = &pcf_gpio_led_info2,
261 }
262};
263
264/* PCF8574 0x24 GPIO U1 on the GS_2G-OPT23-A_V0 board (Modem) */
265static struct gpio_led pcf_gpio_leds3[] = {
266 { /* bit 0 */
267 .name = "gpo:modem_power",
268 .gpio = PCF_GPIO_MODEM_POWER,
269 .active_low = 1,
270 .default_trigger = "none",
271 .default_state = LEDS_GPIO_DEFSTATE_OFF,
272 },
273 /* bits 1 and 2 not used */
274 { /* bit 3 */
275 .name = "gpo:modem_reset",
276 .gpio = PCF_GPIO_MODEM_RESET,
277 .active_low = 1,
278 .default_trigger = "none",
279 .default_state = LEDS_GPIO_DEFSTATE_ON,
280 },
281 /* bits 4, 5 and 6 not used */
282 { /* bit 7 */
283 .name = "gpo:trx_reset",
284 .gpio = PCF_GPIO_TRX_RESET,
285 .active_low = 1,
286 .default_trigger = "none",
287 .default_state = LEDS_GPIO_DEFSTATE_ON,
288 }
289};
290
291static struct gpio_led_platform_data pcf_gpio_led_info3 = {
292 .leds = pcf_gpio_leds3,
293 .num_leds = ARRAY_SIZE(pcf_gpio_leds3),
294};
295
296static struct platform_device pcf_leds3 = {
297 .name = "leds-gpio",
298 .id = 3,
299 .dev = {
300 .platform_data = &pcf_gpio_led_info3,
301 }
302};
303
304static void __init gsia18s_pcf_leds_init(void)
305{
306 platform_device_register(&pcf_leds1);
307 platform_device_register(&pcf_leds2);
308 platform_device_register(&pcf_leds3);
309}
310
311/*
312 * SPI busses.
313 */
314static struct spi_board_info gsia18s_spi_devices[] = {
315 { /* User accessible spi0, cs0 used for communication with MSP RTC */
316 .modalias = "spidev",
317 .bus_num = 0,
318 .chip_select = 0,
319 .max_speed_hz = 580000,
320 .mode = SPI_MODE_1,
321 },
322 { /* User accessible spi1, cs0 used for communication with int. DSP */
323 .modalias = "spidev",
324 .bus_num = 1,
325 .chip_select = 0,
326 .max_speed_hz = 5600000,
327 .mode = SPI_MODE_0,
328 },
329 { /* User accessible spi1, cs1 used for communication with ext. DSP */
330 .modalias = "spidev",
331 .bus_num = 1,
332 .chip_select = 1,
333 .max_speed_hz = 5600000,
334 .mode = SPI_MODE_0,
335 },
336 { /* User accessible spi1, cs2 used for communication with ext. DSP */
337 .modalias = "spidev",
338 .bus_num = 1,
339 .chip_select = 2,
340 .max_speed_hz = 5600000,
341 .mode = SPI_MODE_0,
342 },
343 { /* User accessible spi1, cs3 used for communication with ext. DSP */
344 .modalias = "spidev",
345 .bus_num = 1,
346 .chip_select = 3,
347 .max_speed_hz = 5600000,
348 .mode = SPI_MODE_0,
349 }
350};
351
352/*
353 * GPI Buttons
354 */
355static struct gpio_keys_button buttons[] = {
356 {
357 .gpio = GPIO_TRIG_NET_IN,
358 .code = BTN_1,
359 .desc = "TRIG_NET_IN",
360 .type = EV_KEY,
361 .active_low = 0,
362 .wakeup = 1,
363 },
364 { /* SW80 on the GS_IA18_S-MN board*/
365 .gpio = GPIO_CARD_UNMOUNT_0,
366 .code = BTN_2,
367 .desc = "Card umount 0",
368 .type = EV_KEY,
369 .active_low = 1,
370 .wakeup = 1,
371 },
372 { /* SW79 on the GS_IA18_S-MN board*/
373 .gpio = GPIO_CARD_UNMOUNT_1,
374 .code = BTN_3,
375 .desc = "Card umount 1",
376 .type = EV_KEY,
377 .active_low = 1,
378 .wakeup = 1,
379 },
380 { /* SW280 on the GS_IA18-CB board*/
381 .gpio = GPIO_KEY_POWER,
382 .code = KEY_POWER,
383 .desc = "Power Off Button",
384 .type = EV_KEY,
385 .active_low = 0,
386 .wakeup = 1,
387 }
388};
389
390static struct gpio_keys_platform_data button_data = {
391 .buttons = buttons,
392 .nbuttons = ARRAY_SIZE(buttons),
393};
394
395static struct platform_device button_device = {
396 .name = "gpio-keys",
397 .id = -1,
398 .num_resources = 0,
399 .dev = {
400 .platform_data = &button_data,
401 }
402};
403
404static void __init gsia18s_add_device_buttons(void)
405{
406 at91_set_gpio_input(GPIO_TRIG_NET_IN, 1);
407 at91_set_deglitch(GPIO_TRIG_NET_IN, 1);
408 at91_set_gpio_input(GPIO_CARD_UNMOUNT_0, 1);
409 at91_set_deglitch(GPIO_CARD_UNMOUNT_0, 1);
410 at91_set_gpio_input(GPIO_CARD_UNMOUNT_1, 1);
411 at91_set_deglitch(GPIO_CARD_UNMOUNT_1, 1);
412 at91_set_gpio_input(GPIO_KEY_POWER, 0);
413 at91_set_deglitch(GPIO_KEY_POWER, 1);
414
415 platform_device_register(&button_device);
416}
417
418/*
419 * I2C
420 */
421static int pcf8574x_0x20_setup(struct i2c_client *client, int gpio,
422 unsigned int ngpio, void *context)
423{
424 int status;
425
426 status = gpio_request(gpio + PCF_GPIO_ETH_DETECT, "eth_det");
427 if (status < 0) {
428 pr_err("error: can't request GPIO%d\n",
429 gpio + PCF_GPIO_ETH_DETECT);
430 return status;
431 }
432 status = gpio_direction_input(gpio + PCF_GPIO_ETH_DETECT);
433 if (status < 0) {
434 pr_err("error: can't setup GPIO%d as input\n",
435 gpio + PCF_GPIO_ETH_DETECT);
436 return status;
437 }
438 status = gpio_export(gpio + PCF_GPIO_ETH_DETECT, false);
439 if (status < 0) {
440 pr_err("error: can't export GPIO%d\n",
441 gpio + PCF_GPIO_ETH_DETECT);
442 return status;
443 }
444 status = gpio_sysfs_set_active_low(gpio + PCF_GPIO_ETH_DETECT, 1);
445 if (status < 0) {
446 pr_err("error: gpio_sysfs_set active_low(GPIO%d, 1)\n",
447 gpio + PCF_GPIO_ETH_DETECT);
448 return status;
449 }
450
451 return 0;
452}
453
454static int pcf8574x_0x20_teardown(struct i2c_client *client, int gpio,
455 unsigned ngpio, void *context)
456{
457 gpio_free(gpio + PCF_GPIO_ETH_DETECT);
458 return 0;
459}
460
461static struct pcf857x_platform_data pcf20_pdata = {
462 .gpio_base = GS_IA18_S_PCF_GPIO_BASE0,
463 .n_latch = (1 << 4),
464 .setup = pcf8574x_0x20_setup,
465 .teardown = pcf8574x_0x20_teardown,
466};
467
468static struct pcf857x_platform_data pcf22_pdata = {
469 .gpio_base = GS_IA18_S_PCF_GPIO_BASE1,
470};
471
472static struct pcf857x_platform_data pcf24_pdata = {
473 .gpio_base = GS_IA18_S_PCF_GPIO_BASE2,
474};
475
476static struct i2c_board_info __initdata gsia18s_i2c_devices[] = {
477 { /* U1 on the GS_IA18-CB_V3 board */
478 I2C_BOARD_INFO("pcf8574", 0x20),
479 .platform_data = &pcf20_pdata,
480 },
481 { /* U1 on the GS_2G_OPT1-A_V0 board (Alarm) */
482 I2C_BOARD_INFO("pcf8574", 0x22),
483 .platform_data = &pcf22_pdata,
484 },
485 { /* U1 on the GS_2G-OPT23-A_V0 board (Modem) */
486 I2C_BOARD_INFO("pcf8574", 0x24),
487 .platform_data = &pcf24_pdata,
488 },
489 { /* U161 on the GS_IA18_S-MN board */
490 I2C_BOARD_INFO("24c1024", 0x50),
491 },
492 { /* U162 on the GS_IA18_S-MN board */
493 I2C_BOARD_INFO("24c01", 0x53),
494 },
495};
496
497/*
498 * Compact Flash
499 */
500static struct at91_cf_data __initdata gsia18s_cf1_data = {
501 .irq_pin = AT91_PIN_PA27,
502 .det_pin = AT91_PIN_PB30,
63b4c296 503 .vcc_pin = -EINVAL,
fcdc2ea7
IP
504 .rst_pin = AT91_PIN_PB31,
505 .chipselect = 5,
506 .flags = AT91_CF_TRUE_IDE,
507};
508
509/* Power Off by RTC */
510static void gsia18s_power_off(void)
511{
512 pr_notice("Power supply will be switched off automatically now or after 60 seconds without ArmDAS.\n");
513 at91_set_gpio_output(AT91_PIN_PA25, 1);
514 /* Spin to death... */
515 while (1)
516 ;
517}
518
519static int __init gsia18s_power_off_init(void)
520{
521 pm_power_off = gsia18s_power_off;
522 return 0;
523}
524
525/* ---------------------------------------------------------------------------*/
526
527static void __init gsia18s_board_init(void)
528{
71b149b3
JCPV
529 /*
530 * USART0 on ttyS1 (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI).
531 * Used for Internal Analog Modem.
532 */
533 at91_register_uart(AT91SAM9260_ID_US0, 1,
534 ATMEL_UART_CTS | ATMEL_UART_RTS |
535 ATMEL_UART_DTR | ATMEL_UART_DSR |
536 ATMEL_UART_DCD | ATMEL_UART_RI);
537 /*
538 * USART1 on ttyS2 (Rx, Tx, CTS, RTS).
539 * Used for GPS or WiFi or Data stream.
540 */
541 at91_register_uart(AT91SAM9260_ID_US1, 2,
542 ATMEL_UART_CTS | ATMEL_UART_RTS);
543 /*
544 * USART2 on ttyS3 (Rx, Tx, CTS, RTS).
545 * Used for External Modem.
546 */
547 at91_register_uart(AT91SAM9260_ID_US2, 3,
548 ATMEL_UART_CTS | ATMEL_UART_RTS);
549 /*
550 * USART3 on ttyS4 (Rx, Tx, RTS).
551 * Used for RS-485.
552 */
553 at91_register_uart(AT91SAM9260_ID_US3, 4, ATMEL_UART_RTS);
554
555 /*
556 * USART4 on ttyS5 (Rx, Tx).
557 * Used for TRX433 Radio Module.
558 */
559 at91_register_uart(AT91SAM9260_ID_US4, 5, 0);
fcdc2ea7
IP
560 stamp9g20_board_init();
561 at91_add_device_usbh(&usbh_data);
562 at91_add_device_udc(&udc_data);
563 at91_add_device_eth(&macb_data);
564 gsia18s_leds_init();
565 gsia18s_pcf_leds_init();
566 gsia18s_add_device_buttons();
567 at91_add_device_i2c(gsia18s_i2c_devices,
568 ARRAY_SIZE(gsia18s_i2c_devices));
569 at91_add_device_cf(&gsia18s_cf1_data);
570 at91_add_device_spi(gsia18s_spi_devices,
571 ARRAY_SIZE(gsia18s_spi_devices));
572 gsia18s_power_off_init();
573}
574
575MACHINE_START(GSIA18S, "GS_IA18_S")
fcdc2ea7 576 .timer = &at91sam926x_timer,
21d08b9d 577 .map_io = at91_map_io,
1b021a3b 578 .init_early = gsia18s_init_early,
92100c12 579 .init_irq = at91_init_irq_default,
fcdc2ea7
IP
580 .init_machine = gsia18s_board_init,
581MACHINE_END