aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Baryshkov <dbaryshkov@gmail.com>2008-04-12 15:16:16 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-04-19 06:29:08 -0400
commitd4e7d09f7accd1b0d1c8f149a44deffc8c141a46 (patch)
tree66b73501e3a89ba30da34a6c08c0961f93a0ab77
parentbaf1c5d2a08c828d6333e0a37bcdf5afb3d5d003 (diff)
[ARM] 4972/1: Tosa: convert scoop GPIOs usage to generic gpio code
Convert set/reset_scoop_gpio to generic gpio calls. This patch depends on the pxaficp_ir hooks patch. Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/mach-pxa/tosa.c88
-rw-r--r--include/asm-arm/arch-pxa/tosa.h25
2 files changed, 71 insertions, 42 deletions
diff --git a/arch/arm/mach-pxa/tosa.c b/arch/arm/mach-pxa/tosa.c
index 9f5ca5497bb9..49b5b83c0e4c 100644
--- a/arch/arm/mach-pxa/tosa.c
+++ b/arch/arm/mach-pxa/tosa.c
@@ -23,6 +23,7 @@
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/gpio_keys.h> 24#include <linux/gpio_keys.h>
25#include <linux/input.h> 25#include <linux/input.h>
26#include <linux/gpio.h>
26 27
27#include <asm/setup.h> 28#include <asm/setup.h>
28#include <asm/memory.h> 29#include <asm/memory.h>
@@ -166,8 +167,7 @@ static struct resource tosa_scoop_resources[] = {
166 167
167static struct scoop_config tosa_scoop_setup = { 168static struct scoop_config tosa_scoop_setup = {
168 .io_dir = TOSA_SCOOP_IO_DIR, 169 .io_dir = TOSA_SCOOP_IO_DIR,
169 .io_out = TOSA_SCOOP_IO_OUT, 170 .gpio_base = TOSA_SCOOP_GPIO_BASE,
170
171}; 171};
172 172
173struct platform_device tosascoop_device = { 173struct platform_device tosascoop_device = {
@@ -194,7 +194,7 @@ static struct resource tosa_scoop_jc_resources[] = {
194 194
195static struct scoop_config tosa_scoop_jc_setup = { 195static struct scoop_config tosa_scoop_jc_setup = {
196 .io_dir = TOSA_SCOOP_JC_IO_DIR, 196 .io_dir = TOSA_SCOOP_JC_IO_DIR,
197 .io_out = TOSA_SCOOP_JC_IO_OUT, 197 .gpio_base = TOSA_SCOOP_JC_GPIO_BASE,
198}; 198};
199 199
200struct platform_device tosascoop_jc_device = { 200struct platform_device tosascoop_jc_device = {
@@ -232,20 +232,8 @@ static struct scoop_pcmcia_config tosa_pcmcia_config = {
232/* 232/*
233 * USB Device Controller 233 * USB Device Controller
234 */ 234 */
235static void tosa_udc_command(int cmd)
236{
237 switch(cmd) {
238 case PXA2XX_UDC_CMD_CONNECT:
239 set_scoop_gpio(&tosascoop_jc_device.dev,TOSA_SCOOP_JC_USB_PULLUP);
240 break;
241 case PXA2XX_UDC_CMD_DISCONNECT:
242 reset_scoop_gpio(&tosascoop_jc_device.dev,TOSA_SCOOP_JC_USB_PULLUP);
243 break;
244 }
245}
246
247static struct pxa2xx_udc_mach_info udc_info __initdata = { 235static struct pxa2xx_udc_mach_info udc_info __initdata = {
248 .udc_command = tosa_udc_command, 236 .gpio_pullup = TOSA_GPIO_USB_PULLUP,
249 .gpio_vbus = TOSA_GPIO_USB_IN, 237 .gpio_vbus = TOSA_GPIO_USB_IN,
250 .gpio_vbus_inverted = 1, 238 .gpio_vbus_inverted = 1,
251}; 239};
@@ -264,9 +252,39 @@ static int tosa_mci_init(struct device *dev, irq_handler_t tosa_detect_int, void
264 err = request_irq(TOSA_IRQ_GPIO_nSD_DETECT, tosa_detect_int, 252 err = request_irq(TOSA_IRQ_GPIO_nSD_DETECT, tosa_detect_int,
265 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, 253 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
266 "MMC/SD card detect", data); 254 "MMC/SD card detect", data);
267 if (err) 255 if (err) {
268 printk(KERN_ERR "tosa_mci_init: MMC/SD: can't request MMC card detect IRQ\n"); 256 printk(KERN_ERR "tosa_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
257 goto err_irq;
258 }
259
260 err = gpio_request(TOSA_GPIO_SD_WP, "sd_wp");
261 if (err) {
262 printk(KERN_ERR "tosa_mci_init: can't request SD_WP gpio\n");
263 goto err_gpio_wp;
264 }
265 err = gpio_direction_input(TOSA_GPIO_SD_WP);
266 if (err)
267 goto err_gpio_wp_dir;
268
269 err = gpio_request(TOSA_GPIO_PWR_ON, "sd_pwr");
270 if (err) {
271 printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n");
272 goto err_gpio_pwr;
273 }
274 err = gpio_direction_output(TOSA_GPIO_PWR_ON, 0);
275 if (err)
276 goto err_gpio_pwr_dir;
269 277
278 return 0;
279
280err_gpio_pwr_dir:
281 gpio_free(TOSA_GPIO_PWR_ON);
282err_gpio_pwr:
283err_gpio_wp_dir:
284 gpio_free(TOSA_GPIO_SD_WP);
285err_gpio_wp:
286 free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
287err_irq:
270 return err; 288 return err;
271} 289}
272 290
@@ -275,19 +293,21 @@ static void tosa_mci_setpower(struct device *dev, unsigned int vdd)
275 struct pxamci_platform_data* p_d = dev->platform_data; 293 struct pxamci_platform_data* p_d = dev->platform_data;
276 294
277 if (( 1 << vdd) & p_d->ocr_mask) { 295 if (( 1 << vdd) & p_d->ocr_mask) {
278 set_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_PWR_ON); 296 gpio_set_value(TOSA_GPIO_PWR_ON, 1);
279 } else { 297 } else {
280 reset_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_PWR_ON); 298 gpio_set_value(TOSA_GPIO_PWR_ON, 0);
281 } 299 }
282} 300}
283 301
284static int tosa_mci_get_ro(struct device *dev) 302static int tosa_mci_get_ro(struct device *dev)
285{ 303{
286 return (read_scoop_reg(&tosascoop_device.dev, SCOOP_GPWR)&TOSA_SCOOP_SD_WP); 304 return gpio_get_value(TOSA_GPIO_SD_WP);
287} 305}
288 306
289static void tosa_mci_exit(struct device *dev, void *data) 307static void tosa_mci_exit(struct device *dev, void *data)
290{ 308{
309 gpio_free(TOSA_GPIO_PWR_ON);
310 gpio_free(TOSA_GPIO_SD_WP);
291 free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data); 311 free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
292} 312}
293 313
@@ -302,18 +322,36 @@ static struct pxamci_platform_data tosa_mci_platform_data = {
302/* 322/*
303 * Irda 323 * Irda
304 */ 324 */
305static void tosa_irda_transceiver_mode(struct device *dev, int mode) 325static int tosa_irda_startup(struct device *dev)
306{ 326{
307 if (mode & IR_OFF) { 327 int ret;
308 reset_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_IR_POWERDWN); 328
309 } else { 329 ret = gpio_request(TOSA_GPIO_IR_POWERDWN, "IrDA powerdown");
310 set_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_IR_POWERDWN); 330 if (ret)
331 return ret;
332
333 ret = gpio_direction_output(TOSA_GPIO_IR_POWERDWN, 0);
334 if (ret)
335 gpio_free(TOSA_GPIO_IR_POWERDWN);
336
337 return ret;
311 } 338 }
339
340static void tosa_irda_shutdown(struct device *dev)
341{
342 gpio_free(TOSA_GPIO_IR_POWERDWN);
343}
344
345static void tosa_irda_transceiver_mode(struct device *dev, int mode)
346{
347 gpio_set_value(TOSA_GPIO_IR_POWERDWN, !(mode & IR_OFF));
312} 348}
313 349
314static struct pxaficp_platform_data tosa_ficp_platform_data = { 350static struct pxaficp_platform_data tosa_ficp_platform_data = {
315 .transceiver_cap = IR_SIRMODE | IR_OFF, 351 .transceiver_cap = IR_SIRMODE | IR_OFF,
316 .transceiver_mode = tosa_irda_transceiver_mode, 352 .transceiver_mode = tosa_irda_transceiver_mode,
353 .startup = tosa_irda_startup,
354 .shutdown = tosa_irda_shutdown,
317}; 355};
318 356
319/* 357/*
diff --git a/include/asm-arm/arch-pxa/tosa.h b/include/asm-arm/arch-pxa/tosa.h
index c05e4faf85a6..130bc6025cf4 100644
--- a/include/asm-arm/arch-pxa/tosa.h
+++ b/include/asm-arm/arch-pxa/tosa.h
@@ -23,11 +23,12 @@
23/* 23/*
24 * SCOOP2 internal GPIOs 24 * SCOOP2 internal GPIOs
25 */ 25 */
26#define TOSA_SCOOP_GPIO_BASE NR_BUILTIN_GPIO
26#define TOSA_SCOOP_PXA_VCORE1 SCOOP_GPCR_PA11 27#define TOSA_SCOOP_PXA_VCORE1 SCOOP_GPCR_PA11
27#define TOSA_SCOOP_TC6393_REST_IN SCOOP_GPCR_PA12 28#define TOSA_SCOOP_TC6393_REST_IN SCOOP_GPCR_PA12
28#define TOSA_SCOOP_IR_POWERDWN SCOOP_GPCR_PA13 29#define TOSA_GPIO_IR_POWERDWN (TOSA_SCOOP_GPIO_BASE + 2)
29#define TOSA_SCOOP_SD_WP SCOOP_GPCR_PA14 30#define TOSA_GPIO_SD_WP (TOSA_SCOOP_GPIO_BASE + 3)
30#define TOSA_SCOOP_PWR_ON SCOOP_GPCR_PA15 31#define TOSA_GPIO_PWR_ON (TOSA_SCOOP_GPIO_BASE + 4)
31#define TOSA_SCOOP_AUD_PWR_ON SCOOP_GPCR_PA16 32#define TOSA_SCOOP_AUD_PWR_ON SCOOP_GPCR_PA16
32#define TOSA_SCOOP_BT_RESET SCOOP_GPCR_PA17 33#define TOSA_SCOOP_BT_RESET SCOOP_GPCR_PA17
33#define TOSA_SCOOP_BT_PWR_EN SCOOP_GPCR_PA18 34#define TOSA_SCOOP_BT_PWR_EN SCOOP_GPCR_PA18
@@ -35,7 +36,7 @@
35 36
36/* GPIO Direction 1 : output mode / 0:input mode */ 37/* GPIO Direction 1 : output mode / 0:input mode */
37#define TOSA_SCOOP_IO_DIR ( TOSA_SCOOP_PXA_VCORE1 | TOSA_SCOOP_TC6393_REST_IN | \ 38#define TOSA_SCOOP_IO_DIR ( TOSA_SCOOP_PXA_VCORE1 | TOSA_SCOOP_TC6393_REST_IN | \
38 TOSA_SCOOP_IR_POWERDWN | TOSA_SCOOP_PWR_ON | TOSA_SCOOP_AUD_PWR_ON |\ 39 TOSA_SCOOP_AUD_PWR_ON |\
39 TOSA_SCOOP_BT_RESET | TOSA_SCOOP_BT_PWR_EN ) 40 TOSA_SCOOP_BT_RESET | TOSA_SCOOP_BT_PWR_EN )
40/* GPIO out put level when init 1: Hi */ 41/* GPIO out put level when init 1: Hi */
41#define TOSA_SCOOP_IO_OUT ( TOSA_SCOOP_TC6393_REST_IN ) 42#define TOSA_SCOOP_IO_OUT ( TOSA_SCOOP_TC6393_REST_IN )
@@ -43,10 +44,11 @@
43/* 44/*
44 * SCOOP2 jacket GPIOs 45 * SCOOP2 jacket GPIOs
45 */ 46 */
47#define TOSA_SCOOP_JC_GPIO_BASE (NR_BUILTIN_GPIO + 12)
46#define TOSA_SCOOP_JC_BT_LED SCOOP_GPCR_PA11 48#define TOSA_SCOOP_JC_BT_LED SCOOP_GPCR_PA11
47#define TOSA_SCOOP_JC_NOTE_LED SCOOP_GPCR_PA12 49#define TOSA_SCOOP_JC_NOTE_LED SCOOP_GPCR_PA12
48#define TOSA_SCOOP_JC_CHRG_ERR_LED SCOOP_GPCR_PA13 50#define TOSA_SCOOP_JC_CHRG_ERR_LED SCOOP_GPCR_PA13
49#define TOSA_SCOOP_JC_USB_PULLUP SCOOP_GPCR_PA14 51#define TOSA_GPIO_USB_PULLUP (TOSA_SCOOP_JC_GPIO_BASE + 3)
50#define TOSA_SCOOP_JC_TC6393_SUSPEND SCOOP_GPCR_PA15 52#define TOSA_SCOOP_JC_TC6393_SUSPEND SCOOP_GPCR_PA15
51#define TOSA_SCOOP_JC_TC3693_L3V_ON SCOOP_GPCR_PA16 53#define TOSA_SCOOP_JC_TC3693_L3V_ON SCOOP_GPCR_PA16
52#define TOSA_SCOOP_JC_WLAN_DETECT SCOOP_GPCR_PA17 54#define TOSA_SCOOP_JC_WLAN_DETECT SCOOP_GPCR_PA17
@@ -55,11 +57,9 @@
55 57
56/* GPIO Direction 1 : output mode / 0:input mode */ 58/* GPIO Direction 1 : output mode / 0:input mode */
57#define TOSA_SCOOP_JC_IO_DIR ( TOSA_SCOOP_JC_BT_LED | TOSA_SCOOP_JC_NOTE_LED | \ 59#define TOSA_SCOOP_JC_IO_DIR ( TOSA_SCOOP_JC_BT_LED | TOSA_SCOOP_JC_NOTE_LED | \
58 TOSA_SCOOP_JC_CHRG_ERR_LED | TOSA_SCOOP_JC_USB_PULLUP | \ 60 TOSA_SCOOP_JC_CHRG_ERR_LED | \
59 TOSA_SCOOP_JC_TC6393_SUSPEND | TOSA_SCOOP_JC_TC3693_L3V_ON | \ 61 TOSA_SCOOP_JC_TC6393_SUSPEND | TOSA_SCOOP_JC_TC3693_L3V_ON | \
60 TOSA_SCOOP_JC_WLAN_LED | TOSA_SCOOP_JC_CARD_LIMIT_SEL ) 62 TOSA_SCOOP_JC_WLAN_LED | TOSA_SCOOP_JC_CARD_LIMIT_SEL )
61/* GPIO out put level when init 1: Hi */
62#define TOSA_SCOOP_JC_IO_OUT ( 0 )
63 63
64/* 64/*
65 * Timing Generator 65 * Timing Generator
@@ -74,15 +74,6 @@
74#define TG_HPOSCTL 0x07 74#define TG_HPOSCTL 0x07
75 75
76/* 76/*
77 * LED
78 */
79#define TOSA_SCOOP_LED_BLUE TOSA_SCOOP_GPCR_PA11
80#define TOSA_SCOOP_LED_GREEN TOSA_SCOOP_GPCR_PA12
81#define TOSA_SCOOP_LED_ORANGE TOSA_SCOOP_GPCR_PA13
82#define TOSA_SCOOP_LED_WLAN TOSA_SCOOP_GPCR_PA18
83
84
85/*
86 * PXA GPIOs 77 * PXA GPIOs
87 */ 78 */
88#define TOSA_GPIO_POWERON (0) 79#define TOSA_GPIO_POWERON (0)