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