x86/efi: Enforce CONFIG_RELOCATABLE for EFI boot stub
[linux/fpc-iii.git] / arch / arm / mach-at91 / board-gsia18s.c
blobc1d61d247790b72fc009547d61bd49a6cc3797a5
1 /*
2 * Copyright (C) 2010 Christian Glindkamp <christian.glindkamp@taskit.de>
3 * taskit GmbH
4 * 2010 Igor Plyatov <plyatov@gmail.com>
5 * GeoSIG Ltd
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.
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.
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
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>
30 #include <asm/mach-types.h>
31 #include <asm/mach/arch.h>
33 #include <mach/at91sam9_smc.h>
35 #include "at91_aic.h"
36 #include "board.h"
37 #include "sam9_smc.h"
38 #include "generic.h"
39 #include "gsia18s.h"
40 #include "stamp9g20.h"
42 static void __init gsia18s_init_early(void)
44 stamp9g20_init_early();
48 * Two USB Host ports
50 static struct at91_usbh_data __initdata usbh_data = {
51 .ports = 2,
52 .vbus_pin = {-EINVAL, -EINVAL},
53 .overcurrent_pin= {-EINVAL, -EINVAL},
57 * USB Device port
59 static struct at91_udc_data __initdata udc_data = {
60 .vbus_pin = AT91_PIN_PA22,
61 .pullup_pin = -EINVAL, /* pull-up driven by UDC */
65 * MACB Ethernet device
67 static struct macb_platform_data __initdata macb_data = {
68 .phy_irq_pin = AT91_PIN_PA28,
69 .is_rmii = 1,
73 * LEDs and GPOs
75 static struct gpio_led gpio_leds[] = {
77 .name = "gpo:spi1reset",
78 .gpio = AT91_PIN_PC1,
79 .active_low = 0,
80 .default_trigger = "none",
81 .default_state = LEDS_GPIO_DEFSTATE_OFF,
84 .name = "gpo:trig_net_out",
85 .gpio = AT91_PIN_PB20,
86 .active_low = 0,
87 .default_trigger = "none",
88 .default_state = LEDS_GPIO_DEFSTATE_OFF,
91 .name = "gpo:trig_net_dir",
92 .gpio = AT91_PIN_PB19,
93 .active_low = 0,
94 .default_trigger = "none",
95 .default_state = LEDS_GPIO_DEFSTATE_OFF,
98 .name = "gpo:charge_dis",
99 .gpio = AT91_PIN_PC2,
100 .active_low = 0,
101 .default_trigger = "none",
102 .default_state = LEDS_GPIO_DEFSTATE_OFF,
105 .name = "led:event",
106 .gpio = AT91_PIN_PB17,
107 .active_low = 1,
108 .default_trigger = "none",
109 .default_state = LEDS_GPIO_DEFSTATE_OFF,
112 .name = "led:lan",
113 .gpio = AT91_PIN_PB18,
114 .active_low = 1,
115 .default_trigger = "none",
116 .default_state = LEDS_GPIO_DEFSTATE_OFF,
119 .name = "led:error",
120 .gpio = AT91_PIN_PB16,
121 .active_low = 1,
122 .default_trigger = "none",
123 .default_state = LEDS_GPIO_DEFSTATE_ON,
127 static struct gpio_led_platform_data gpio_led_info = {
128 .leds = gpio_leds,
129 .num_leds = ARRAY_SIZE(gpio_leds),
132 static struct platform_device leds = {
133 .name = "leds-gpio",
134 .id = 0,
135 .dev = {
136 .platform_data = &gpio_led_info,
140 static void __init gsia18s_leds_init(void)
142 platform_device_register(&leds);
145 /* PCF8574 0x20 GPIO - U1 on the GS_IA18-CB_V3 board */
146 static struct gpio_led pcf_gpio_leds1[] = {
147 { /* bit 0 */
148 .name = "gpo:hdc_power",
149 .gpio = PCF_GPIO_HDC_POWER,
150 .active_low = 0,
151 .default_trigger = "none",
152 .default_state = LEDS_GPIO_DEFSTATE_OFF,
154 { /* bit 1 */
155 .name = "gpo:wifi_setup",
156 .gpio = PCF_GPIO_WIFI_SETUP,
157 .active_low = 1,
158 .default_trigger = "none",
159 .default_state = LEDS_GPIO_DEFSTATE_OFF,
161 { /* bit 2 */
162 .name = "gpo:wifi_enable",
163 .gpio = PCF_GPIO_WIFI_ENABLE,
164 .active_low = 1,
165 .default_trigger = "none",
166 .default_state = LEDS_GPIO_DEFSTATE_OFF,
168 { /* bit 3 */
169 .name = "gpo:wifi_reset",
170 .gpio = PCF_GPIO_WIFI_RESET,
171 .active_low = 1,
172 .default_trigger = "none",
173 .default_state = LEDS_GPIO_DEFSTATE_ON,
175 /* bit 4 used as GPI */
176 { /* bit 5 */
177 .name = "gpo:gps_setup",
178 .gpio = PCF_GPIO_GPS_SETUP,
179 .active_low = 1,
180 .default_trigger = "none",
181 .default_state = LEDS_GPIO_DEFSTATE_OFF,
183 { /* bit 6 */
184 .name = "gpo:gps_standby",
185 .gpio = PCF_GPIO_GPS_STANDBY,
186 .active_low = 0,
187 .default_trigger = "none",
188 .default_state = LEDS_GPIO_DEFSTATE_ON,
190 { /* bit 7 */
191 .name = "gpo:gps_power",
192 .gpio = PCF_GPIO_GPS_POWER,
193 .active_low = 0,
194 .default_trigger = "none",
195 .default_state = LEDS_GPIO_DEFSTATE_OFF,
199 static struct gpio_led_platform_data pcf_gpio_led_info1 = {
200 .leds = pcf_gpio_leds1,
201 .num_leds = ARRAY_SIZE(pcf_gpio_leds1),
204 static struct platform_device pcf_leds1 = {
205 .name = "leds-gpio", /* GS_IA18-CB_board */
206 .id = 1,
207 .dev = {
208 .platform_data = &pcf_gpio_led_info1,
212 /* PCF8574 0x22 GPIO - U1 on the GS_2G_OPT1-A_V0 board (Alarm) */
213 static struct gpio_led pcf_gpio_leds2[] = {
214 { /* bit 0 */
215 .name = "gpo:alarm_1",
216 .gpio = PCF_GPIO_ALARM1,
217 .active_low = 1,
218 .default_trigger = "none",
219 .default_state = LEDS_GPIO_DEFSTATE_OFF,
221 { /* bit 1 */
222 .name = "gpo:alarm_2",
223 .gpio = PCF_GPIO_ALARM2,
224 .active_low = 1,
225 .default_trigger = "none",
226 .default_state = LEDS_GPIO_DEFSTATE_OFF,
228 { /* bit 2 */
229 .name = "gpo:alarm_3",
230 .gpio = PCF_GPIO_ALARM3,
231 .active_low = 1,
232 .default_trigger = "none",
233 .default_state = LEDS_GPIO_DEFSTATE_OFF,
235 { /* bit 3 */
236 .name = "gpo:alarm_4",
237 .gpio = PCF_GPIO_ALARM4,
238 .active_low = 1,
239 .default_trigger = "none",
240 .default_state = LEDS_GPIO_DEFSTATE_OFF,
242 /* bits 4, 5, 6 not used */
243 { /* bit 7 */
244 .name = "gpo:alarm_v_relay_on",
245 .gpio = PCF_GPIO_ALARM_V_RELAY_ON,
246 .active_low = 0,
247 .default_trigger = "none",
248 .default_state = LEDS_GPIO_DEFSTATE_OFF,
252 static struct gpio_led_platform_data pcf_gpio_led_info2 = {
253 .leds = pcf_gpio_leds2,
254 .num_leds = ARRAY_SIZE(pcf_gpio_leds2),
257 static struct platform_device pcf_leds2 = {
258 .name = "leds-gpio",
259 .id = 2,
260 .dev = {
261 .platform_data = &pcf_gpio_led_info2,
265 /* PCF8574 0x24 GPIO U1 on the GS_2G-OPT23-A_V0 board (Modem) */
266 static struct gpio_led pcf_gpio_leds3[] = {
267 { /* bit 0 */
268 .name = "gpo:modem_power",
269 .gpio = PCF_GPIO_MODEM_POWER,
270 .active_low = 1,
271 .default_trigger = "none",
272 .default_state = LEDS_GPIO_DEFSTATE_OFF,
274 /* bits 1 and 2 not used */
275 { /* bit 3 */
276 .name = "gpo:modem_reset",
277 .gpio = PCF_GPIO_MODEM_RESET,
278 .active_low = 1,
279 .default_trigger = "none",
280 .default_state = LEDS_GPIO_DEFSTATE_ON,
282 /* bits 4, 5 and 6 not used */
283 { /* bit 7 */
284 .name = "gpo:trx_reset",
285 .gpio = PCF_GPIO_TRX_RESET,
286 .active_low = 1,
287 .default_trigger = "none",
288 .default_state = LEDS_GPIO_DEFSTATE_ON,
292 static struct gpio_led_platform_data pcf_gpio_led_info3 = {
293 .leds = pcf_gpio_leds3,
294 .num_leds = ARRAY_SIZE(pcf_gpio_leds3),
297 static struct platform_device pcf_leds3 = {
298 .name = "leds-gpio",
299 .id = 3,
300 .dev = {
301 .platform_data = &pcf_gpio_led_info3,
305 static void __init gsia18s_pcf_leds_init(void)
307 platform_device_register(&pcf_leds1);
308 platform_device_register(&pcf_leds2);
309 platform_device_register(&pcf_leds3);
313 * SPI busses.
315 static struct spi_board_info gsia18s_spi_devices[] = {
316 { /* User accessible spi0, cs0 used for communication with MSP RTC */
317 .modalias = "spidev",
318 .bus_num = 0,
319 .chip_select = 0,
320 .max_speed_hz = 580000,
321 .mode = SPI_MODE_1,
323 { /* User accessible spi1, cs0 used for communication with int. DSP */
324 .modalias = "spidev",
325 .bus_num = 1,
326 .chip_select = 0,
327 .max_speed_hz = 5600000,
328 .mode = SPI_MODE_0,
330 { /* User accessible spi1, cs1 used for communication with ext. DSP */
331 .modalias = "spidev",
332 .bus_num = 1,
333 .chip_select = 1,
334 .max_speed_hz = 5600000,
335 .mode = SPI_MODE_0,
337 { /* User accessible spi1, cs2 used for communication with ext. DSP */
338 .modalias = "spidev",
339 .bus_num = 1,
340 .chip_select = 2,
341 .max_speed_hz = 5600000,
342 .mode = SPI_MODE_0,
344 { /* User accessible spi1, cs3 used for communication with ext. DSP */
345 .modalias = "spidev",
346 .bus_num = 1,
347 .chip_select = 3,
348 .max_speed_hz = 5600000,
349 .mode = SPI_MODE_0,
354 * GPI Buttons
356 static struct gpio_keys_button buttons[] = {
358 .gpio = GPIO_TRIG_NET_IN,
359 .code = BTN_1,
360 .desc = "TRIG_NET_IN",
361 .type = EV_KEY,
362 .active_low = 0,
363 .wakeup = 1,
365 { /* SW80 on the GS_IA18_S-MN board*/
366 .gpio = GPIO_CARD_UNMOUNT_0,
367 .code = BTN_2,
368 .desc = "Card umount 0",
369 .type = EV_KEY,
370 .active_low = 1,
371 .wakeup = 1,
373 { /* SW79 on the GS_IA18_S-MN board*/
374 .gpio = GPIO_CARD_UNMOUNT_1,
375 .code = BTN_3,
376 .desc = "Card umount 1",
377 .type = EV_KEY,
378 .active_low = 1,
379 .wakeup = 1,
381 { /* SW280 on the GS_IA18-CB board*/
382 .gpio = GPIO_KEY_POWER,
383 .code = KEY_POWER,
384 .desc = "Power Off Button",
385 .type = EV_KEY,
386 .active_low = 0,
387 .wakeup = 1,
391 static struct gpio_keys_platform_data button_data = {
392 .buttons = buttons,
393 .nbuttons = ARRAY_SIZE(buttons),
396 static struct platform_device button_device = {
397 .name = "gpio-keys",
398 .id = -1,
399 .num_resources = 0,
400 .dev = {
401 .platform_data = &button_data,
405 static void __init gsia18s_add_device_buttons(void)
407 at91_set_gpio_input(GPIO_TRIG_NET_IN, 1);
408 at91_set_deglitch(GPIO_TRIG_NET_IN, 1);
409 at91_set_gpio_input(GPIO_CARD_UNMOUNT_0, 1);
410 at91_set_deglitch(GPIO_CARD_UNMOUNT_0, 1);
411 at91_set_gpio_input(GPIO_CARD_UNMOUNT_1, 1);
412 at91_set_deglitch(GPIO_CARD_UNMOUNT_1, 1);
413 at91_set_gpio_input(GPIO_KEY_POWER, 0);
414 at91_set_deglitch(GPIO_KEY_POWER, 1);
416 platform_device_register(&button_device);
420 * I2C
422 static int pcf8574x_0x20_setup(struct i2c_client *client, int gpio,
423 unsigned int ngpio, void *context)
425 int status;
427 status = gpio_request(gpio + PCF_GPIO_ETH_DETECT, "eth_det");
428 if (status < 0) {
429 pr_err("error: can't request GPIO%d\n",
430 gpio + PCF_GPIO_ETH_DETECT);
431 return status;
433 status = gpio_direction_input(gpio + PCF_GPIO_ETH_DETECT);
434 if (status < 0) {
435 pr_err("error: can't setup GPIO%d as input\n",
436 gpio + PCF_GPIO_ETH_DETECT);
437 return status;
439 status = gpio_export(gpio + PCF_GPIO_ETH_DETECT, false);
440 if (status < 0) {
441 pr_err("error: can't export GPIO%d\n",
442 gpio + PCF_GPIO_ETH_DETECT);
443 return status;
445 status = gpio_sysfs_set_active_low(gpio + PCF_GPIO_ETH_DETECT, 1);
446 if (status < 0) {
447 pr_err("error: gpio_sysfs_set active_low(GPIO%d, 1)\n",
448 gpio + PCF_GPIO_ETH_DETECT);
449 return status;
452 return 0;
455 static int pcf8574x_0x20_teardown(struct i2c_client *client, int gpio,
456 unsigned ngpio, void *context)
458 gpio_free(gpio + PCF_GPIO_ETH_DETECT);
459 return 0;
462 static struct pcf857x_platform_data pcf20_pdata = {
463 .gpio_base = GS_IA18_S_PCF_GPIO_BASE0,
464 .n_latch = (1 << 4),
465 .setup = pcf8574x_0x20_setup,
466 .teardown = pcf8574x_0x20_teardown,
469 static struct pcf857x_platform_data pcf22_pdata = {
470 .gpio_base = GS_IA18_S_PCF_GPIO_BASE1,
473 static struct pcf857x_platform_data pcf24_pdata = {
474 .gpio_base = GS_IA18_S_PCF_GPIO_BASE2,
477 static struct i2c_board_info __initdata gsia18s_i2c_devices[] = {
478 { /* U1 on the GS_IA18-CB_V3 board */
479 I2C_BOARD_INFO("pcf8574", 0x20),
480 .platform_data = &pcf20_pdata,
482 { /* U1 on the GS_2G_OPT1-A_V0 board (Alarm) */
483 I2C_BOARD_INFO("pcf8574", 0x22),
484 .platform_data = &pcf22_pdata,
486 { /* U1 on the GS_2G-OPT23-A_V0 board (Modem) */
487 I2C_BOARD_INFO("pcf8574", 0x24),
488 .platform_data = &pcf24_pdata,
490 { /* U161 on the GS_IA18_S-MN board */
491 I2C_BOARD_INFO("24c1024", 0x50),
493 { /* U162 on the GS_IA18_S-MN board */
494 I2C_BOARD_INFO("24c01", 0x53),
499 * Compact Flash
501 static struct at91_cf_data __initdata gsia18s_cf1_data = {
502 .irq_pin = AT91_PIN_PA27,
503 .det_pin = AT91_PIN_PB30,
504 .vcc_pin = -EINVAL,
505 .rst_pin = AT91_PIN_PB31,
506 .chipselect = 5,
507 .flags = AT91_CF_TRUE_IDE,
510 /* Power Off by RTC */
511 static void gsia18s_power_off(void)
513 pr_notice("Power supply will be switched off automatically now or after 60 seconds without ArmDAS.\n");
514 at91_set_gpio_output(AT91_PIN_PA25, 1);
515 /* Spin to death... */
516 while (1)
520 static int __init gsia18s_power_off_init(void)
522 pm_power_off = gsia18s_power_off;
523 return 0;
526 /* ---------------------------------------------------------------------------*/
528 static void __init gsia18s_board_init(void)
531 * USART0 on ttyS1 (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI).
532 * Used for Internal Analog Modem.
534 at91_register_uart(AT91SAM9260_ID_US0, 1,
535 ATMEL_UART_CTS | ATMEL_UART_RTS |
536 ATMEL_UART_DTR | ATMEL_UART_DSR |
537 ATMEL_UART_DCD | ATMEL_UART_RI);
539 * USART1 on ttyS2 (Rx, Tx, CTS, RTS).
540 * Used for GPS or WiFi or Data stream.
542 at91_register_uart(AT91SAM9260_ID_US1, 2,
543 ATMEL_UART_CTS | ATMEL_UART_RTS);
545 * USART2 on ttyS3 (Rx, Tx, CTS, RTS).
546 * Used for External Modem.
548 at91_register_uart(AT91SAM9260_ID_US2, 3,
549 ATMEL_UART_CTS | ATMEL_UART_RTS);
551 * USART3 on ttyS4 (Rx, Tx, RTS).
552 * Used for RS-485.
554 at91_register_uart(AT91SAM9260_ID_US3, 4, ATMEL_UART_RTS);
557 * USART4 on ttyS5 (Rx, Tx).
558 * Used for TRX433 Radio Module.
560 at91_register_uart(AT91SAM9260_ID_US4, 5, 0);
561 stamp9g20_board_init();
562 at91_add_device_usbh(&usbh_data);
563 at91_add_device_udc(&udc_data);
564 at91_add_device_eth(&macb_data);
565 gsia18s_leds_init();
566 gsia18s_pcf_leds_init();
567 gsia18s_add_device_buttons();
568 at91_add_device_i2c(gsia18s_i2c_devices,
569 ARRAY_SIZE(gsia18s_i2c_devices));
570 at91_add_device_cf(&gsia18s_cf1_data);
571 at91_add_device_spi(gsia18s_spi_devices,
572 ARRAY_SIZE(gsia18s_spi_devices));
573 gsia18s_power_off_init();
576 MACHINE_START(GSIA18S, "GS_IA18_S")
577 .init_time = at91sam926x_pit_init,
578 .map_io = at91_map_io,
579 .handle_irq = at91_aic_handle_irq,
580 .init_early = gsia18s_init_early,
581 .init_irq = at91_init_irq_default,
582 .init_machine = gsia18s_board_init,
583 MACHINE_END