summaryrefslogtreecommitdiff
path: root/drivers/mmc
diff options
context:
space:
mode:
authorShawn Lin <shawn.lin@rock-chips.com>2018-05-03 16:47:57 +0800
committerTao Huang <huangtao@rock-chips.com>2018-05-07 14:22:45 +0800
commitcda34cc0e4936c3767058aab725d7a511d16946c (patch)
tree6ed23badfb053f60d5cb0a4d208345ae51d81a50 /drivers/mmc
parentd6e7df40b5a55a612db5f76f86a6f3059ee78859 (diff)
BACKPORT: FROMLIST: mmc: core: Add tunable delay before detecting card after card is inserted
Allow to use tunable delay before detecting card after card is inserted, which either comes from firmware node, or comes from debounce value passed on to mmc_gpiod_request_cd(). If the platform doesn't support debounce, then we fall back to use the debounce period as the delay, otherwise, it behaves the same as before that a HW debounce(if set) plus a 200ms hardcode delay before detecting the card. Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Change-Id: Ib3ed4cbcdeb0986b584d7dc9057461888e554967 Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com> (cherry picked from commit 26288b77fd04ea54a84801b1c92c8da519986040 of https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git)
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/core/host.c10
-rw-r--r--drivers/mmc/core/slot-gpio.c7
2 files changed, 13 insertions, 4 deletions
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index bbe4380a8a30..5b21aad3ea91 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -154,8 +154,9 @@ static void mmc_retune_timer(unsigned long data)
*/
int mmc_of_parse(struct mmc_host *host)
{
+ struct device *dev = host->parent;
struct device_node *np;
- u32 bus_width;
+ u32 bus_width, cd_debounce_delay_ms;
int ret;
bool cd_cap_invert, cd_gpio_invert = false;
bool ro_cap_invert, ro_gpio_invert = false;
@@ -208,11 +209,16 @@ int mmc_of_parse(struct mmc_host *host)
} else {
cd_cap_invert = of_property_read_bool(np, "cd-inverted");
+ if (device_property_read_u32(dev, "cd-debounce-delay-ms",
+ &cd_debounce_delay_ms))
+ cd_debounce_delay_ms = 200;
+
if (of_property_read_bool(np, "broken-cd"))
host->caps |= MMC_CAP_NEEDS_POLL;
ret = mmc_gpiod_request_cd(host, "cd", 0, true,
- 0, &cd_gpio_invert);
+ cd_debounce_delay_ms,
+ &cd_gpio_invert);
if (!ret)
dev_info(host->parent, "Got CD GPIO\n");
else if (ret != -ENOENT && ret != -ENOSYS)
diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c
index 27117ba47073..9355140d8bb9 100644
--- a/drivers/mmc/core/slot-gpio.c
+++ b/drivers/mmc/core/slot-gpio.c
@@ -28,15 +28,17 @@ struct mmc_gpio {
irqreturn_t (*cd_gpio_isr)(int irq, void *dev_id);
char *ro_label;
char cd_label[0];
+ u32 cd_debounce_delay_ms;
};
static irqreturn_t mmc_gpio_cd_irqt(int irq, void *dev_id)
{
/* Schedule a card detection after a debounce timeout */
struct mmc_host *host = dev_id;
+ struct mmc_gpio *ctx = host->slot.handler_priv;
host->trigger_card_event = true;
- mmc_detect_change(host, msecs_to_jiffies(200));
+ mmc_detect_change(host, msecs_to_jiffies(ctx->cd_debounce_delay_ms));
return IRQ_HANDLED;
}
@@ -49,6 +51,7 @@ int mmc_gpio_alloc(struct mmc_host *host)
if (ctx) {
ctx->ro_label = ctx->cd_label + len;
+ ctx->cd_debounce_delay_ms = 200;
snprintf(ctx->cd_label, len, "%s cd", dev_name(host->parent));
snprintf(ctx->ro_label, len, "%s ro", dev_name(host->parent));
host->slot.handler_priv = ctx;
@@ -201,7 +204,7 @@ int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio,
if (debounce) {
ret = gpio_set_debounce(gpio, debounce);
if (ret < 0)
- return ret;
+ ctx->cd_debounce_delay_ms = debounce;
}
ctx->override_cd_active_level = true;