aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/poodle.c
diff options
context:
space:
mode:
authorEric Miao <eric.miao@marvell.com>2008-07-17 20:59:04 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-09-23 17:04:34 -0400
commitce5291478c64bab3ae301c385c6c2a6575b08355 (patch)
tree5de76fc490cc9adbc4039a72d5a9358e466b57d0 /arch/arm/mach-pxa/poodle.c
parentcf5eb8c0de08a99b0ccbd22198bbb4828a04298b (diff)
[ARM] pxa/poodle: convert to use the new GPIO API
Direct manipulation of GPIO registers are no longer encouraged, use the new GPIO API instead. Since the GPIO has to be requested before use, .startup and .shutdown are added to the IrDA device platform data to request and free the GPIO. Signed-off-by: Eric Miao <eric.miao@marvell.com> Acked-by: Richard Purdie <rpurdie@rpsys.net> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-pxa/poodle.c')
-rw-r--r--arch/arm/mach-pxa/poodle.c89
1 files changed, 71 insertions, 18 deletions
diff --git a/arch/arm/mach-pxa/poodle.c b/arch/arm/mach-pxa/poodle.c
index 8972dccab5cf..00f0c897e5f8 100644
--- a/arch/arm/mach-pxa/poodle.c
+++ b/arch/arm/mach-pxa/poodle.c
@@ -20,6 +20,7 @@
20#include <linux/fb.h> 20#include <linux/fb.h>
21#include <linux/pm.h> 21#include <linux/pm.h>
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/gpio.h>
23 24
24#include <mach/hardware.h> 25#include <mach/hardware.h>
25#include <asm/mach-types.h> 26#include <asm/mach-types.h>
@@ -208,19 +209,51 @@ static int poodle_mci_init(struct device *dev, irq_handler_t poodle_detect_int,
208 /* setup GPIO for PXA25x MMC controller */ 209 /* setup GPIO for PXA25x MMC controller */
209 pxa_gpio_mode(GPIO6_MMCCLK_MD); 210 pxa_gpio_mode(GPIO6_MMCCLK_MD);
210 pxa_gpio_mode(GPIO8_MMCCS0_MD); 211 pxa_gpio_mode(GPIO8_MMCCS0_MD);
211 pxa_gpio_mode(POODLE_GPIO_nSD_DETECT | GPIO_IN); 212
212 pxa_gpio_mode(POODLE_GPIO_nSD_WP | GPIO_IN); 213 err = gpio_request(POODLE_GPIO_nSD_DETECT, "nSD_DETECT");
213 pxa_gpio_mode(POODLE_GPIO_SD_PWR | GPIO_OUT); 214 if (err)
214 pxa_gpio_mode(POODLE_GPIO_SD_PWR1 | GPIO_OUT); 215 goto err_out;
216
217 err = gpio_request(POODLE_GPIO_nSD_WP, "nSD_WP");
218 if (err)
219 goto err_free_1;
220
221 err = gpio_request(POODLE_GPIO_SD_PWR, "SD_PWR");
222 if (err)
223 goto err_free_2;
224
225 err = gpio_request(POODLE_GPIO_SD_PWR1, "SD_PWR1");
226 if (err)
227 goto err_free_3;
228
229 gpio_direction_input(POODLE_GPIO_nSD_DETECT);
230 gpio_direction_input(POODLE_GPIO_nSD_WP);
231
232 gpio_direction_output(POODLE_GPIO_SD_PWR, 0);
233 gpio_direction_output(POODLE_GPIO_SD_PWR1, 0);
215 234
216 poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250); 235 poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250);
217 236
218 err = request_irq(POODLE_IRQ_GPIO_nSD_DETECT, poodle_detect_int, 237 err = request_irq(POODLE_IRQ_GPIO_nSD_DETECT, poodle_detect_int,
219 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, 238 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
220 "MMC card detect", data); 239 "MMC card detect", data);
221 if (err) 240 if (err) {
222 printk(KERN_ERR "poodle_mci_init: MMC/SD: can't request MMC card detect IRQ\n"); 241 pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n",
242 __func__);
243 goto err_free_4;
244 }
245
246 return 0;
223 247
248err_free_4:
249 gpio_free(POODLE_GPIO_SD_PWR1);
250err_free_3:
251 gpio_free(POODLE_GPIO_SD_PWR);
252err_free_2:
253 gpio_free(POODLE_GPIO_nSD_WP);
254err_free_1:
255 gpio_free(POODLE_GPIO_nSD_DETECT);
256err_out:
224 return err; 257 return err;
225} 258}
226 259
@@ -228,18 +261,19 @@ static void poodle_mci_setpower(struct device *dev, unsigned int vdd)
228{ 261{
229 struct pxamci_platform_data* p_d = dev->platform_data; 262 struct pxamci_platform_data* p_d = dev->platform_data;
230 263
231 if (( 1 << vdd) & p_d->ocr_mask) { 264 if ((1 << vdd) & p_d->ocr_mask) {
232 GPSR(POODLE_GPIO_SD_PWR) = GPIO_bit(POODLE_GPIO_SD_PWR); 265 gpio_set_value(POODLE_GPIO_SD_PWR, 1);
233 mdelay(2); 266 mdelay(2);
234 GPSR(POODLE_GPIO_SD_PWR1) = GPIO_bit(POODLE_GPIO_SD_PWR1); 267 gpio_set_value(POODLE_GPIO_SD_PWR1, 1);
235 } else { 268 } else {
236 GPCR(POODLE_GPIO_SD_PWR1) = GPIO_bit(POODLE_GPIO_SD_PWR1); 269 gpio_set_value(POODLE_GPIO_SD_PWR1, 0);
237 GPCR(POODLE_GPIO_SD_PWR) = GPIO_bit(POODLE_GPIO_SD_PWR); 270 gpio_set_value(POODLE_GPIO_SD_PWR, 0);
238 } 271 }
239} 272}
240 273
241static int poodle_mci_get_ro(struct device *dev) 274static int poodle_mci_get_ro(struct device *dev)
242{ 275{
276 return !!gpio_get_value(POODLE_GPIO_nSD_WP);
243 return GPLR(POODLE_GPIO_nSD_WP) & GPIO_bit(POODLE_GPIO_nSD_WP); 277 return GPLR(POODLE_GPIO_nSD_WP) & GPIO_bit(POODLE_GPIO_nSD_WP);
244} 278}
245 279
@@ -247,6 +281,10 @@ static int poodle_mci_get_ro(struct device *dev)
247static void poodle_mci_exit(struct device *dev, void *data) 281static void poodle_mci_exit(struct device *dev, void *data)
248{ 282{
249 free_irq(POODLE_IRQ_GPIO_nSD_DETECT, data); 283 free_irq(POODLE_IRQ_GPIO_nSD_DETECT, data);
284 gpio_free(POODLE_GPIO_SD_PWR1);
285 gpio_free(POODLE_GPIO_SD_PWR);
286 gpio_free(POODLE_GPIO_nSD_WP);
287 gpio_free(POODLE_GPIO_nSD_DETECT);
250} 288}
251 289
252static struct pxamci_platform_data poodle_mci_platform_data = { 290static struct pxamci_platform_data poodle_mci_platform_data = {
@@ -263,17 +301,32 @@ static struct pxamci_platform_data poodle_mci_platform_data = {
263 */ 301 */
264static void poodle_irda_transceiver_mode(struct device *dev, int mode) 302static void poodle_irda_transceiver_mode(struct device *dev, int mode)
265{ 303{
266 if (mode & IR_OFF) { 304 gpio_set_value(POODLE_GPIO_IR_ON, mode & IR_OFF);
267 GPSR(POODLE_GPIO_IR_ON) = GPIO_bit(POODLE_GPIO_IR_ON);
268 } else {
269 GPCR(POODLE_GPIO_IR_ON) = GPIO_bit(POODLE_GPIO_IR_ON);
270 }
271 pxa2xx_transceiver_mode(dev, mode); 305 pxa2xx_transceiver_mode(dev, mode);
272} 306}
273 307
308static int poodle_irda_startup(struct device *dev)
309{
310 int err;
311
312 err = gpio_request(POODLE_GPIO_IR_ON, "IR_ON");
313 if (err)
314 return err;
315
316 gpio_direction_output(POODLE_GPIO_IR_ON, 1);
317 return 0;
318}
319
320static void poodle_irda_shutdown(struct device *dev)
321{
322 gpio_free(POODLE_GPIO_IR_ON);
323}
324
274static struct pxaficp_platform_data poodle_ficp_platform_data = { 325static struct pxaficp_platform_data poodle_ficp_platform_data = {
275 .transceiver_cap = IR_SIRMODE | IR_OFF, 326 .transceiver_cap = IR_SIRMODE | IR_OFF,
276 .transceiver_mode = poodle_irda_transceiver_mode, 327 .transceiver_mode = poodle_irda_transceiver_mode,
328 .startup = poodle_irda_startup,
329 .shutdown = poodle_irda_shutdown,
277}; 330};
278 331
279 332