aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorEric Miao <eric.miao@marvell.com>2008-09-05 10:15:23 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-09-23 17:04:39 -0400
commitfff147208b48680cb7b627a144113a6585828a0e (patch)
treeb628a27aa4d8baf61a6fdfc8896dc322941e3625 /arch/arm
parent60cf711d47d995c3d61e222502fde3c11cedc434 (diff)
[ARM] pxa/spitz: use generic GPIO API for SCOOP1/SCOOP2 GPIOs
Original patch from Dmitry Baryshkov's inital scoop gpio conversion work at http://git.infradead.org/users/dbaryshkov/zaurus-2.6.git. Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com> Signed-off-by: Eric Miao <eric.miao@marvell.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/mach-pxa/include/mach/spitz.h22
-rw-r--r--arch/arm/mach-pxa/spitz.c66
-rw-r--r--arch/arm/mach-pxa/spitz_pm.c28
3 files changed, 73 insertions, 43 deletions
diff --git a/arch/arm/mach-pxa/include/mach/spitz.h b/arch/arm/mach-pxa/include/mach/spitz.h
index d2fc22df0d7f..e9b3d33daed6 100644
--- a/arch/arm/mach-pxa/include/mach/spitz.h
+++ b/arch/arm/mach-pxa/include/mach/spitz.h
@@ -16,6 +16,7 @@
16#endif 16#endif
17 17
18#include <linux/fb.h> 18#include <linux/fb.h>
19#include <linux/gpio.h>
19 20
20/* Spitz/Akita GPIOs */ 21/* Spitz/Akita GPIOs */
21 22
@@ -107,6 +108,17 @@
107#define SPITZ_SCP_SUS_CLR (SPITZ_SCP_MUTE_L | SPITZ_SCP_MUTE_R | SPITZ_SCP_JK_A | SPITZ_SCP_ADC_TEMP_ON) 108#define SPITZ_SCP_SUS_CLR (SPITZ_SCP_MUTE_L | SPITZ_SCP_MUTE_R | SPITZ_SCP_JK_A | SPITZ_SCP_ADC_TEMP_ON)
108#define SPITZ_SCP_SUS_SET 0 109#define SPITZ_SCP_SUS_SET 0
109 110
111#define SPITZ_SCP_GPIO_BASE (NR_BUILTIN_GPIO)
112#define SPITZ_GPIO_LED_GREEN (SPITZ_SCP_GPIO_BASE + 0)
113#define SPITZ_GPIO_JK_B (SPITZ_SCP_GPIO_BASE + 1)
114#define SPITZ_GPIO_CHRG_ON (SPITZ_SCP_GPIO_BASE + 2)
115#define SPITZ_GPIO_MUTE_L (SPITZ_SCP_GPIO_BASE + 3)
116#define SPITZ_GPIO_MUTE_R (SPITZ_SCP_GPIO_BASE + 4)
117#define SPITZ_GPIO_CF_POWER (SPITZ_SCP_GPIO_BASE + 5)
118#define SPITZ_GPIO_LED_ORANGE (SPITZ_SCP_GPIO_BASE + 6)
119#define SPITZ_GPIO_JK_A (SPITZ_SCP_GPIO_BASE + 7)
120#define SPITZ_GPIO_ADC_TEMP_ON (SPITZ_SCP_GPIO_BASE + 8)
121
110/* Spitz Scoop Device (No. 2) GPIOs */ 122/* Spitz Scoop Device (No. 2) GPIOs */
111/* Suspend States in comments */ 123/* Suspend States in comments */
112#define SPITZ_SCP2_IR_ON SCOOP_GPCR_PA11 /* High */ 124#define SPITZ_SCP2_IR_ON SCOOP_GPCR_PA11 /* High */
@@ -128,6 +140,16 @@
128 SPITZ_SCP2_BACKLIGHT_CONT | SPITZ_SCP2_BACKLIGHT_ON | SPITZ_SCP2_MIC_BIAS) 140 SPITZ_SCP2_BACKLIGHT_CONT | SPITZ_SCP2_BACKLIGHT_ON | SPITZ_SCP2_MIC_BIAS)
129#define SPITZ_SCP2_SUS_SET (SPITZ_SCP2_IR_ON | SPITZ_SCP2_RESERVED_1) 141#define SPITZ_SCP2_SUS_SET (SPITZ_SCP2_IR_ON | SPITZ_SCP2_RESERVED_1)
130 142
143#define SPITZ_SCP2_GPIO_BASE (NR_BUILTIN_GPIO + 12)
144#define SPITZ_GPIO_IR_ON (SPITZ_SCP2_GPIO_BASE + 0)
145#define SPITZ_GPIO_AKIN_PULLUP (SPITZ_SCP2_GPIO_BASE + 1
146#define SPITZ_GPIO_RESERVED_1 (SPITZ_SCP2_GPIO_BASE + 2)
147#define SPITZ_GPIO_RESERVED_2 (SPITZ_SCP2_GPIO_BASE + 3)
148#define SPITZ_GPIO_RESERVED_3 (SPITZ_SCP2_GPIO_BASE + 4)
149#define SPITZ_GPIO_RESERVED_4 (SPITZ_SCP2_GPIO_BASE + 5)
150#define SPITZ_GPIO_BACKLIGHT_CONT (SPITZ_SCP2_GPIO_BASE + 6)
151#define SPITZ_GPIO_BACKLIGHT_ON (SPITZ_SCP2_GPIO_BASE + 7)
152#define SPITZ_GPIO_MIC_BIAS (SPITZ_SCP2_GPIO_BASE + 8)
131 153
132/* Spitz IRQ Definitions */ 154/* Spitz IRQ Definitions */
133 155
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index 8b06b7a749df..290008296e1b 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -134,10 +134,11 @@ static struct resource spitz_scoop_resources[] = {
134}; 134};
135 135
136static struct scoop_config spitz_scoop_setup = { 136static struct scoop_config spitz_scoop_setup = {
137 .io_dir = SPITZ_SCP_IO_DIR, 137 .io_dir = SPITZ_SCP_IO_DIR,
138 .io_out = SPITZ_SCP_IO_OUT, 138 .io_out = SPITZ_SCP_IO_OUT,
139 .suspend_clr = SPITZ_SCP_SUS_CLR, 139 .suspend_clr = SPITZ_SCP_SUS_CLR,
140 .suspend_set = SPITZ_SCP_SUS_SET, 140 .suspend_set = SPITZ_SCP_SUS_SET,
141 .gpio_base = SPITZ_SCP_GPIO_BASE,
141}; 142};
142 143
143struct platform_device spitzscoop_device = { 144struct platform_device spitzscoop_device = {
@@ -162,10 +163,11 @@ static struct resource spitz_scoop2_resources[] = {
162}; 163};
163 164
164static struct scoop_config spitz_scoop2_setup = { 165static struct scoop_config spitz_scoop2_setup = {
165 .io_dir = SPITZ_SCP2_IO_DIR, 166 .io_dir = SPITZ_SCP2_IO_DIR,
166 .io_out = SPITZ_SCP2_IO_OUT, 167 .io_out = SPITZ_SCP2_IO_OUT,
167 .suspend_clr = SPITZ_SCP2_SUS_CLR, 168 .suspend_clr = SPITZ_SCP2_SUS_CLR,
168 .suspend_set = SPITZ_SCP2_SUS_SET, 169 .suspend_set = SPITZ_SCP2_SUS_SET,
170 .gpio_base = SPITZ_SCP2_GPIO_BASE,
169}; 171};
170 172
171struct platform_device spitzscoop2_device = { 173struct platform_device spitzscoop2_device = {
@@ -187,7 +189,7 @@ static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr)
187 unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR); 189 unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR);
188 190
189 if (new_cpr & 0x0007) { 191 if (new_cpr & 0x0007) {
190 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER); 192 gpio_set_value(SPITZ_GPIO_CF_POWER, 1);
191 if (!(cpr & 0x0002) && !(cpr & 0x0004)) 193 if (!(cpr & 0x0002) && !(cpr & 0x0004))
192 mdelay(5); 194 mdelay(5);
193 if (device == SPITZ_PWR_CF) 195 if (device == SPITZ_PWR_CF)
@@ -203,7 +205,7 @@ static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr)
203 if (!(cpr & 0x0002) && !(cpr & 0x0004)) { 205 if (!(cpr & 0x0002) && !(cpr & 0x0004)) {
204 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, 0x0000); 206 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, 0x0000);
205 mdelay(1); 207 mdelay(1);
206 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER); 208 gpio_set_value(SPITZ_GPIO_CF_POWER, 0);
207 } else { 209 } else {
208 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr); 210 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
209 } 211 }
@@ -283,16 +285,8 @@ static struct pxa2xx_spi_chip spitz_ads7846_chip = {
283static void spitz_notify_intensity(int intensity) 285static void spitz_notify_intensity(int intensity)
284{ 286{
285 if (machine_is_spitz() || machine_is_borzoi()) { 287 if (machine_is_spitz() || machine_is_borzoi()) {
286 /* Bit 5 is via SCOOP */ 288 gpio_set_value(SPITZ_GPIO_BACKLIGHT_CONT, !(intensity & 0x20));
287 if (intensity & 0x0020) 289 gpio_set_value(SPITZ_GPIO_BACKLIGHT_ON, intensity);
288 reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_CONT);
289 else
290 set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_CONT);
291
292 if (intensity)
293 set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_ON);
294 else
295 reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_ON);
296 return; 290 return;
297 } 291 }
298 292
@@ -515,12 +509,34 @@ static struct pxaohci_platform_data spitz_ohci_platform_data = {
515/* 509/*
516 * Irda 510 * Irda
517 */ 511 */
512static int spitz_irda_startup(struct device *dev)
513{
514 int rc;
515
516 rc = gpio_request(SPITZ_GPIO_IR_ON, "IrDA on");
517 if (rc)
518 goto err;
519
520 rc = gpio_direction_output(SPITZ_GPIO_IR_ON, 1);
521 if (rc)
522 goto err_dir;
523
524 return 0;
525
526err_dir:
527 gpio_free(SPITZ_GPIO_IR_ON);
528err:
529 return rc;
530}
531
532static void spitz_irda_shutdown(struct device *dev)
533{
534 gpio_free(SPITZ_GPIO_IR_ON);
535}
536
518static void spitz_irda_transceiver_mode(struct device *dev, int mode) 537static void spitz_irda_transceiver_mode(struct device *dev, int mode)
519{ 538{
520 if (mode & IR_OFF) 539 gpio_set_value(SPITZ_GPIO_IR_ON, mode & IR_OFF);
521 set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON);
522 else
523 reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON);
524 pxa2xx_transceiver_mode(dev, mode); 540 pxa2xx_transceiver_mode(dev, mode);
525} 541}
526 542
@@ -536,8 +552,10 @@ static void akita_irda_transceiver_mode(struct device *dev, int mode)
536#endif 552#endif
537 553
538static struct pxaficp_platform_data spitz_ficp_platform_data = { 554static struct pxaficp_platform_data spitz_ficp_platform_data = {
539 .transceiver_cap = IR_SIRMODE | IR_OFF, 555 .transceiver_cap = IR_SIRMODE | IR_OFF,
540 .transceiver_mode = spitz_irda_transceiver_mode, 556 .transceiver_mode = spitz_irda_transceiver_mode,
557 .startup = spitz_irda_startup,
558 .shutdown = spitz_irda_shutdown,
541}; 559};
542 560
543 561
diff --git a/arch/arm/mach-pxa/spitz_pm.c b/arch/arm/mach-pxa/spitz_pm.c
index 8a40505dfd28..53018db106ac 100644
--- a/arch/arm/mach-pxa/spitz_pm.c
+++ b/arch/arm/mach-pxa/spitz_pm.c
@@ -21,7 +21,6 @@
21#include <asm/irq.h> 21#include <asm/irq.h>
22#include <asm/mach-types.h> 22#include <asm/mach-types.h>
23#include <mach/hardware.h> 23#include <mach/hardware.h>
24#include <asm/hardware/scoop.h>
25 24
26#include <mach/sharpsl.h> 25#include <mach/sharpsl.h>
27#include <mach/spitz.h> 26#include <mach/spitz.h>
@@ -48,44 +47,35 @@ static void spitz_charger_init(void)
48 47
49static void spitz_measure_temp(int on) 48static void spitz_measure_temp(int on)
50{ 49{
51 if (on) 50 gpio_set_value(SPITZ_GPIO_ADC_TEMP_ON, on);
52 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_ADC_TEMP_ON);
53 else
54 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_ADC_TEMP_ON);
55} 51}
56 52
57static void spitz_charge(int on) 53static void spitz_charge(int on)
58{ 54{
59 if (on) { 55 if (on) {
60 if (sharpsl_pm.flags & SHARPSL_SUSPENDED) { 56 if (sharpsl_pm.flags & SHARPSL_SUSPENDED) {
61 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_B); 57 gpio_set_value(SPITZ_GPIO_JK_B, 1);
62 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CHRG_ON); 58 gpio_set_value(SPITZ_GPIO_CHRG_ON, 0);
63 } else { 59 } else {
64 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_B); 60 gpio_set_value(SPITZ_GPIO_JK_B, 0);
65 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CHRG_ON); 61 gpio_set_value(SPITZ_GPIO_CHRG_ON, 0);
66 } 62 }
67 } else { 63 } else {
68 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_B); 64 gpio_set_value(SPITZ_GPIO_JK_B, 0);
69 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CHRG_ON); 65 gpio_set_value(SPITZ_GPIO_CHRG_ON, 1);
70 } 66 }
71} 67}
72 68
73static void spitz_discharge(int on) 69static void spitz_discharge(int on)
74{ 70{
75 if (on) 71 gpio_set_value(SPITZ_GPIO_JK_A, on);
76 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_A);
77 else
78 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_A);
79} 72}
80 73
81/* HACK - For unknown reasons, accurate voltage readings are only made with a load 74/* HACK - For unknown reasons, accurate voltage readings are only made with a load
82 on the power bus which the green led on spitz provides */ 75 on the power bus which the green led on spitz provides */
83static void spitz_discharge1(int on) 76static void spitz_discharge1(int on)
84{ 77{
85 if (on) 78 gpio_set_value(SPITZ_GPIO_LED_GREEN, on);
86 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_GREEN);
87 else
88 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_GREEN);
89} 79}
90 80
91static void spitz_presuspend(void) 81static void spitz_presuspend(void)