aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/poodle.c
diff options
context:
space:
mode:
authorRobert Jarzmik <robert.jarzmik@free.fr>2009-07-06 16:16:42 -0400
committerEric Miao <eric.y.miao@gmail.com>2009-09-10 06:49:30 -0400
commit7a648256b20c493c99757fe1d248daf7954647bc (patch)
tree82aa6566accc96ea07a89121cb9779090a6dab40 /arch/arm/mach-pxa/poodle.c
parentb405db6c015fe8e4c9d8199a0355bb16d95d7049 (diff)
[ARM] pxa: factor pxamci gpio handling
Several boards use always the same pattern with pxamci : request gpio, request irq for that gpio to detect MMC card insertion, request gpio for read-only mode detection, etc ... Now that pxamci provides platform_data to describe simple gpio management of the MMC external controls, use it. Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Acked-by: Mike Rapoport <mike@compulab.co.il> Acked-by: Philipp Zabel <philipp.zabel@gmail.com> Acked-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> Cc: rpurdie@rpsys.net Cc: drwyrm@gmail.com Cc: sakoman@gmail.com Cc: marek.vasut@gmail.com Cc: s.hauer@pengutronix.de Signed-off-by: Eric Miao <eric.y.miao@gmail.com>
Diffstat (limited to 'arch/arm/mach-pxa/poodle.c')
-rw-r--r--arch/arm/mach-pxa/poodle.c53
1 files changed, 8 insertions, 45 deletions
diff --git a/arch/arm/mach-pxa/poodle.c b/arch/arm/mach-pxa/poodle.c
index 9352d4a34837..333b1dc2dd3e 100644
--- a/arch/arm/mach-pxa/poodle.c
+++ b/arch/arm/mach-pxa/poodle.c
@@ -245,20 +245,10 @@ static inline void poodle_init_spi(void) {}
245 * The card detect interrupt isn't debounced so we delay it by 250ms 245 * The card detect interrupt isn't debounced so we delay it by 250ms
246 * to give the card a chance to fully insert/eject. 246 * to give the card a chance to fully insert/eject.
247 */ 247 */
248static struct pxamci_platform_data poodle_mci_platform_data;
249
250static int poodle_mci_init(struct device *dev, irq_handler_t poodle_detect_int, void *data) 248static int poodle_mci_init(struct device *dev, irq_handler_t poodle_detect_int, void *data)
251{ 249{
252 int err; 250 int err;
253 251
254 err = gpio_request(POODLE_GPIO_nSD_DETECT, "nSD_DETECT");
255 if (err)
256 goto err_out;
257
258 err = gpio_request(POODLE_GPIO_nSD_WP, "nSD_WP");
259 if (err)
260 goto err_free_1;
261
262 err = gpio_request(POODLE_GPIO_SD_PWR, "SD_PWR"); 252 err = gpio_request(POODLE_GPIO_SD_PWR, "SD_PWR");
263 if (err) 253 if (err)
264 goto err_free_2; 254 goto err_free_2;
@@ -267,34 +257,14 @@ static int poodle_mci_init(struct device *dev, irq_handler_t poodle_detect_int,
267 if (err) 257 if (err)
268 goto err_free_3; 258 goto err_free_3;
269 259
270 gpio_direction_input(POODLE_GPIO_nSD_DETECT);
271 gpio_direction_input(POODLE_GPIO_nSD_WP);
272
273 gpio_direction_output(POODLE_GPIO_SD_PWR, 0); 260 gpio_direction_output(POODLE_GPIO_SD_PWR, 0);
274 gpio_direction_output(POODLE_GPIO_SD_PWR1, 0); 261 gpio_direction_output(POODLE_GPIO_SD_PWR1, 0);
275 262
276 poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250);
277
278 err = request_irq(POODLE_IRQ_GPIO_nSD_DETECT, poodle_detect_int,
279 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
280 "MMC card detect", data);
281 if (err) {
282 pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n",
283 __func__);
284 goto err_free_4;
285 }
286
287 return 0; 263 return 0;
288 264
289err_free_4:
290 gpio_free(POODLE_GPIO_SD_PWR1);
291err_free_3: 265err_free_3:
292 gpio_free(POODLE_GPIO_SD_PWR); 266 gpio_free(POODLE_GPIO_SD_PWR);
293err_free_2: 267err_free_2:
294 gpio_free(POODLE_GPIO_nSD_WP);
295err_free_1:
296 gpio_free(POODLE_GPIO_nSD_DETECT);
297err_out:
298 return err; 268 return err;
299} 269}
300 270
@@ -312,28 +282,20 @@ static void poodle_mci_setpower(struct device *dev, unsigned int vdd)
312 } 282 }
313} 283}
314 284
315static int poodle_mci_get_ro(struct device *dev)
316{
317 return !!gpio_get_value(POODLE_GPIO_nSD_WP);
318 return GPLR(POODLE_GPIO_nSD_WP) & GPIO_bit(POODLE_GPIO_nSD_WP);
319}
320
321
322static void poodle_mci_exit(struct device *dev, void *data) 285static void poodle_mci_exit(struct device *dev, void *data)
323{ 286{
324 free_irq(POODLE_IRQ_GPIO_nSD_DETECT, data);
325 gpio_free(POODLE_GPIO_SD_PWR1); 287 gpio_free(POODLE_GPIO_SD_PWR1);
326 gpio_free(POODLE_GPIO_SD_PWR); 288 gpio_free(POODLE_GPIO_SD_PWR);
327 gpio_free(POODLE_GPIO_nSD_WP);
328 gpio_free(POODLE_GPIO_nSD_DETECT);
329} 289}
330 290
331static struct pxamci_platform_data poodle_mci_platform_data = { 291static struct pxamci_platform_data poodle_mci_platform_data = {
332 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 292 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
333 .init = poodle_mci_init, 293 .init = poodle_mci_init,
334 .get_ro = poodle_mci_get_ro, 294 .setpower = poodle_mci_setpower,
335 .setpower = poodle_mci_setpower, 295 .exit = poodle_mci_exit,
336 .exit = poodle_mci_exit, 296 .gpio_card_detect = POODLE_IRQ_GPIO_nSD_DETECT,
297 .gpio_card_ro = POODLE_GPIO_nSD_WP,
298 .gpio_power = -1,
337}; 299};
338 300
339 301
@@ -521,6 +483,7 @@ static void __init poodle_init(void)
521 set_pxa_fb_parent(&poodle_locomo_device.dev); 483 set_pxa_fb_parent(&poodle_locomo_device.dev);
522 set_pxa_fb_info(&poodle_fb_info); 484 set_pxa_fb_info(&poodle_fb_info);
523 pxa_set_udc_info(&udc_info); 485 pxa_set_udc_info(&udc_info);
486 poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250);
524 pxa_set_mci_info(&poodle_mci_platform_data); 487 pxa_set_mci_info(&poodle_mci_platform_data);
525 pxa_set_ficp_info(&poodle_ficp_platform_data); 488 pxa_set_ficp_info(&poodle_ficp_platform_data);
526 pxa_set_i2c_info(NULL); 489 pxa_set_i2c_info(NULL);