diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2014-08-27 07:00:51 -0400 |
---|---|---|
committer | Ulf Hansson <ulf.hansson@linaro.org> | 2014-09-09 08:25:14 -0400 |
commit | 9d2fa2428ae149ba3a5b7a4ceb0a9e11f1882b3b (patch) | |
tree | 27514884db5fa528f3e3fe9d53eaf8270457eaee | |
parent | 9fbc695075e905b9201100860eacac6349db6644 (diff) |
mmc: slot-gpio: add gpiod variant to get wp GPIO
This makes it possible to get the write protect (read only)
GPIO line from a GPIO descriptor. Written to exactly mirror
the card detect function.
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r-- | drivers/mmc/core/slot-gpio.c | 48 | ||||
-rw-r--r-- | include/linux/mmc/slot-gpio.h | 3 |
2 files changed, 51 insertions, 0 deletions
diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c index 908c2b29e79f..e3fce4493fab 100644 --- a/drivers/mmc/core/slot-gpio.c +++ b/drivers/mmc/core/slot-gpio.c | |||
@@ -326,6 +326,54 @@ int mmc_gpiod_request_cd(struct mmc_host *host, const char *con_id, | |||
326 | EXPORT_SYMBOL(mmc_gpiod_request_cd); | 326 | EXPORT_SYMBOL(mmc_gpiod_request_cd); |
327 | 327 | ||
328 | /** | 328 | /** |
329 | * mmc_gpiod_request_ro - request a gpio descriptor for write protection | ||
330 | * @host: mmc host | ||
331 | * @con_id: function within the GPIO consumer | ||
332 | * @idx: index of the GPIO to obtain in the consumer | ||
333 | * @override_active_level: ignore %GPIO_ACTIVE_LOW flag | ||
334 | * @debounce: debounce time in microseconds | ||
335 | * | ||
336 | * Use this function in place of mmc_gpio_request_ro() to use the GPIO | ||
337 | * descriptor API. Note that it is paired with mmc_gpiod_free_ro() not | ||
338 | * mmc_gpio_free_ro(). | ||
339 | * | ||
340 | * Returns zero on success, else an error. | ||
341 | */ | ||
342 | int mmc_gpiod_request_ro(struct mmc_host *host, const char *con_id, | ||
343 | unsigned int idx, bool override_active_level, | ||
344 | unsigned int debounce) | ||
345 | { | ||
346 | struct mmc_gpio *ctx; | ||
347 | struct gpio_desc *desc; | ||
348 | int ret; | ||
349 | |||
350 | ret = mmc_gpio_alloc(host); | ||
351 | if (ret < 0) | ||
352 | return ret; | ||
353 | |||
354 | ctx = host->slot.handler_priv; | ||
355 | |||
356 | if (!con_id) | ||
357 | con_id = ctx->ro_label; | ||
358 | |||
359 | desc = devm_gpiod_get_index(host->parent, con_id, idx, GPIOD_IN); | ||
360 | if (IS_ERR(desc)) | ||
361 | return PTR_ERR(desc); | ||
362 | |||
363 | if (debounce) { | ||
364 | ret = gpiod_set_debounce(desc, debounce); | ||
365 | if (ret < 0) | ||
366 | return ret; | ||
367 | } | ||
368 | |||
369 | ctx->override_ro_active_level = override_active_level; | ||
370 | ctx->ro_gpio = desc; | ||
371 | |||
372 | return 0; | ||
373 | } | ||
374 | EXPORT_SYMBOL(mmc_gpiod_request_ro); | ||
375 | |||
376 | /** | ||
329 | * mmc_gpiod_free_cd - free the card-detection gpio descriptor | 377 | * mmc_gpiod_free_cd - free the card-detection gpio descriptor |
330 | * @host: mmc host | 378 | * @host: mmc host |
331 | * | 379 | * |
diff --git a/include/linux/mmc/slot-gpio.h b/include/linux/mmc/slot-gpio.h index d2433381e828..a0d0442c15bf 100644 --- a/include/linux/mmc/slot-gpio.h +++ b/include/linux/mmc/slot-gpio.h | |||
@@ -25,6 +25,9 @@ void mmc_gpio_free_cd(struct mmc_host *host); | |||
25 | int mmc_gpiod_request_cd(struct mmc_host *host, const char *con_id, | 25 | int mmc_gpiod_request_cd(struct mmc_host *host, const char *con_id, |
26 | unsigned int idx, bool override_active_level, | 26 | unsigned int idx, bool override_active_level, |
27 | unsigned int debounce); | 27 | unsigned int debounce); |
28 | int mmc_gpiod_request_ro(struct mmc_host *host, const char *con_id, | ||
29 | unsigned int idx, bool override_active_level, | ||
30 | unsigned int debounce); | ||
28 | void mmc_gpiod_free_cd(struct mmc_host *host); | 31 | void mmc_gpiod_free_cd(struct mmc_host *host); |
29 | void mmc_gpiod_request_cd_irq(struct mmc_host *host); | 32 | void mmc_gpiod_request_cd_irq(struct mmc_host *host); |
30 | 33 | ||