aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>2013-08-08 06:38:31 -0400
committerChris Ball <cjb@laptop.org>2013-08-24 23:45:09 -0400
commit214fc309d1387e822d606a33a10e31cacfe83520 (patch)
tree2c266dd95d8da7f54d7b43c20e5c2c0ebe6165be /drivers
parent7725a52c03df4dff3ac3fc621749407fb319d47f (diff)
mmc: slot-gpio: Add debouncing capability to mmc_gpio_request_cd()
Add a debounce parameter to the mmc_gpio_request_cd() function that enables GPIO debouncing when set to a non-zero value. This can be used by MMC host drivers to enable debouncing on the card detect signal. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mmc/core/host.c2
-rw-r--r--drivers/mmc/core/slot-gpio.c14
-rw-r--r--drivers/mmc/host/jz4740_mmc.c2
-rw-r--r--drivers/mmc/host/mvsdio.c3
-rw-r--r--drivers/mmc/host/sdhci-esdhc-imx.c2
-rw-r--r--drivers/mmc/host/sdhci-pxav3.c3
-rw-r--r--drivers/mmc/host/sdhci-sirf.c2
-rw-r--r--drivers/mmc/host/sh_mmcif.c2
-rw-r--r--drivers/mmc/host/tmio_mmc_pio.c2
9 files changed, 23 insertions, 9 deletions
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 6fb6f77450cb..49bc403e31f0 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -374,7 +374,7 @@ int mmc_of_parse(struct mmc_host *host)
374 if (!(flags & OF_GPIO_ACTIVE_LOW)) 374 if (!(flags & OF_GPIO_ACTIVE_LOW))
375 gpio_inv_cd = true; 375 gpio_inv_cd = true;
376 376
377 ret = mmc_gpio_request_cd(host, gpio); 377 ret = mmc_gpio_request_cd(host, gpio, 0);
378 if (ret < 0) { 378 if (ret < 0) {
379 dev_err(host->parent, 379 dev_err(host->parent,
380 "Failed to request CD GPIO #%d: %d!\n", 380 "Failed to request CD GPIO #%d: %d!\n",
diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c
index 324235105519..46596b71a32f 100644
--- a/drivers/mmc/core/slot-gpio.c
+++ b/drivers/mmc/core/slot-gpio.c
@@ -135,6 +135,7 @@ EXPORT_SYMBOL(mmc_gpio_request_ro);
135 * mmc_gpio_request_cd - request a gpio for card-detection 135 * mmc_gpio_request_cd - request a gpio for card-detection
136 * @host: mmc host 136 * @host: mmc host
137 * @gpio: gpio number requested 137 * @gpio: gpio number requested
138 * @debounce: debounce time in microseconds
138 * 139 *
139 * As devm_* managed functions are used in mmc_gpio_request_cd(), client 140 * As devm_* managed functions are used in mmc_gpio_request_cd(), client
140 * drivers do not need to explicitly call mmc_gpio_free_cd() for freeing up, 141 * drivers do not need to explicitly call mmc_gpio_free_cd() for freeing up,
@@ -143,9 +144,14 @@ EXPORT_SYMBOL(mmc_gpio_request_ro);
143 * switching for card-detection, they are responsible for calling 144 * switching for card-detection, they are responsible for calling
144 * mmc_gpio_request_cd() and mmc_gpio_free_cd() as a pair on their own. 145 * mmc_gpio_request_cd() and mmc_gpio_free_cd() as a pair on their own.
145 * 146 *
147 * If GPIO debouncing is desired, set the debounce parameter to a non-zero
148 * value. The caller is responsible for ensuring that the GPIO driver associated
149 * with the GPIO supports debouncing, otherwise an error will be returned.
150 *
146 * Returns zero on success, else an error. 151 * Returns zero on success, else an error.
147 */ 152 */
148int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio) 153int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio,
154 unsigned int debounce)
149{ 155{
150 struct mmc_gpio *ctx; 156 struct mmc_gpio *ctx;
151 int irq = gpio_to_irq(gpio); 157 int irq = gpio_to_irq(gpio);
@@ -167,6 +173,12 @@ int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio)
167 */ 173 */
168 return ret; 174 return ret;
169 175
176 if (debounce) {
177 ret = gpio_set_debounce(gpio, debounce);
178 if (ret < 0)
179 return ret;
180 }
181
170 /* 182 /*
171 * Even if gpio_to_irq() returns a valid IRQ number, the platform might 183 * Even if gpio_to_irq() returns a valid IRQ number, the platform might
172 * still prefer to poll, e.g., because that IRQ number is already used 184 * still prefer to poll, e.g., because that IRQ number is already used
diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c
index d058f0c85f43..66516339e3a0 100644
--- a/drivers/mmc/host/jz4740_mmc.c
+++ b/drivers/mmc/host/jz4740_mmc.c
@@ -713,7 +713,7 @@ static int jz4740_mmc_request_gpios(struct mmc_host *mmc,
713 mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; 713 mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
714 714
715 if (gpio_is_valid(pdata->gpio_card_detect)) { 715 if (gpio_is_valid(pdata->gpio_card_detect)) {
716 ret = mmc_gpio_request_cd(mmc, pdata->gpio_card_detect); 716 ret = mmc_gpio_request_cd(mmc, pdata->gpio_card_detect, 0);
717 if (ret) 717 if (ret)
718 return ret; 718 return ret;
719 } 719 }
diff --git a/drivers/mmc/host/mvsdio.c b/drivers/mmc/host/mvsdio.c
index 4ddd83f98658..06c5b0b28ebc 100644
--- a/drivers/mmc/host/mvsdio.c
+++ b/drivers/mmc/host/mvsdio.c
@@ -757,7 +757,8 @@ static int __init mvsd_probe(struct platform_device *pdev)
757 if (mvsd_data->gpio_card_detect && 757 if (mvsd_data->gpio_card_detect &&
758 gpio_is_valid(mvsd_data->gpio_card_detect)) { 758 gpio_is_valid(mvsd_data->gpio_card_detect)) {
759 ret = mmc_gpio_request_cd(mmc, 759 ret = mmc_gpio_request_cd(mmc,
760 mvsd_data->gpio_card_detect); 760 mvsd_data->gpio_card_detect,
761 0);
761 if (ret) 762 if (ret)
762 goto out; 763 goto out;
763 } else { 764 } else {
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 1dd5ba858754..abc8cf01e6e3 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -616,7 +616,7 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
616 /* card_detect */ 616 /* card_detect */
617 switch (boarddata->cd_type) { 617 switch (boarddata->cd_type) {
618 case ESDHC_CD_GPIO: 618 case ESDHC_CD_GPIO:
619 err = mmc_gpio_request_cd(host->mmc, boarddata->cd_gpio); 619 err = mmc_gpio_request_cd(host->mmc, boarddata->cd_gpio, 0);
620 if (err) { 620 if (err) {
621 dev_err(mmc_dev(host->mmc), 621 dev_err(mmc_dev(host->mmc),
622 "failed to request card-detect gpio!\n"); 622 "failed to request card-detect gpio!\n");
diff --git a/drivers/mmc/host/sdhci-pxav3.c b/drivers/mmc/host/sdhci-pxav3.c
index bf99359a3a90..793dacd3b841 100644
--- a/drivers/mmc/host/sdhci-pxav3.c
+++ b/drivers/mmc/host/sdhci-pxav3.c
@@ -278,7 +278,8 @@ static int sdhci_pxav3_probe(struct platform_device *pdev)
278 host->mmc->pm_caps |= pdata->pm_caps; 278 host->mmc->pm_caps |= pdata->pm_caps;
279 279
280 if (gpio_is_valid(pdata->ext_cd_gpio)) { 280 if (gpio_is_valid(pdata->ext_cd_gpio)) {
281 ret = mmc_gpio_request_cd(host->mmc, pdata->ext_cd_gpio); 281 ret = mmc_gpio_request_cd(host->mmc, pdata->ext_cd_gpio,
282 0);
282 if (ret) { 283 if (ret) {
283 dev_err(mmc_dev(host->mmc), 284 dev_err(mmc_dev(host->mmc),
284 "failed to allocate card detect gpio\n"); 285 "failed to allocate card detect gpio\n");
diff --git a/drivers/mmc/host/sdhci-sirf.c b/drivers/mmc/host/sdhci-sirf.c
index 62a4a835acc6..696122c1b468 100644
--- a/drivers/mmc/host/sdhci-sirf.c
+++ b/drivers/mmc/host/sdhci-sirf.c
@@ -84,7 +84,7 @@ static int sdhci_sirf_probe(struct platform_device *pdev)
84 * gets setup in sdhci_add_host() and we oops. 84 * gets setup in sdhci_add_host() and we oops.
85 */ 85 */
86 if (gpio_is_valid(priv->gpio_cd)) { 86 if (gpio_is_valid(priv->gpio_cd)) {
87 ret = mmc_gpio_request_cd(host->mmc, priv->gpio_cd); 87 ret = mmc_gpio_request_cd(host->mmc, priv->gpio_cd, 0);
88 if (ret) { 88 if (ret) {
89 dev_err(&pdev->dev, "card detect irq request failed: %d\n", 89 dev_err(&pdev->dev, "card detect irq request failed: %d\n",
90 ret); 90 ret);
diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index 6706b5e3b974..35f61cc3a392 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -1436,7 +1436,7 @@ static int sh_mmcif_probe(struct platform_device *pdev)
1436 } 1436 }
1437 1437
1438 if (pd && pd->use_cd_gpio) { 1438 if (pd && pd->use_cd_gpio) {
1439 ret = mmc_gpio_request_cd(mmc, pd->cd_gpio); 1439 ret = mmc_gpio_request_cd(mmc, pd->cd_gpio, 0);
1440 if (ret < 0) 1440 if (ret < 0)
1441 goto erqcd; 1441 goto erqcd;
1442 } 1442 }
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 718843cfacfc..17f7fa99376e 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -1110,7 +1110,7 @@ int tmio_mmc_host_probe(struct tmio_mmc_host **host,
1110 dev_pm_qos_expose_latency_limit(&pdev->dev, 100); 1110 dev_pm_qos_expose_latency_limit(&pdev->dev, 100);
1111 1111
1112 if (pdata->flags & TMIO_MMC_USE_GPIO_CD) { 1112 if (pdata->flags & TMIO_MMC_USE_GPIO_CD) {
1113 ret = mmc_gpio_request_cd(mmc, pdata->cd_gpio); 1113 ret = mmc_gpio_request_cd(mmc, pdata->cd_gpio, 0);
1114 if (ret < 0) { 1114 if (ret < 0) {
1115 tmio_mmc_host_remove(_host); 1115 tmio_mmc_host_remove(_host);
1116 return ret; 1116 return ret;