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>
This commit is contained in:
committed by
Chris Ball
parent
7725a52c03
commit
214fc309d1
@@ -374,7 +374,7 @@ int mmc_of_parse(struct mmc_host *host)
|
|||||||
if (!(flags & OF_GPIO_ACTIVE_LOW))
|
if (!(flags & OF_GPIO_ACTIVE_LOW))
|
||||||
gpio_inv_cd = true;
|
gpio_inv_cd = true;
|
||||||
|
|
||||||
ret = mmc_gpio_request_cd(host, gpio);
|
ret = mmc_gpio_request_cd(host, gpio, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(host->parent,
|
dev_err(host->parent,
|
||||||
"Failed to request CD GPIO #%d: %d!\n",
|
"Failed to request CD GPIO #%d: %d!\n",
|
||||||
|
@@ -135,6 +135,7 @@ EXPORT_SYMBOL(mmc_gpio_request_ro);
|
|||||||
* mmc_gpio_request_cd - request a gpio for card-detection
|
* mmc_gpio_request_cd - request a gpio for card-detection
|
||||||
* @host: mmc host
|
* @host: mmc host
|
||||||
* @gpio: gpio number requested
|
* @gpio: gpio number requested
|
||||||
|
* @debounce: debounce time in microseconds
|
||||||
*
|
*
|
||||||
* As devm_* managed functions are used in mmc_gpio_request_cd(), client
|
* As devm_* managed functions are used in mmc_gpio_request_cd(), client
|
||||||
* drivers do not need to explicitly call mmc_gpio_free_cd() for freeing up,
|
* drivers do not need to explicitly call mmc_gpio_free_cd() for freeing up,
|
||||||
@@ -143,9 +144,14 @@ EXPORT_SYMBOL(mmc_gpio_request_ro);
|
|||||||
* switching for card-detection, they are responsible for calling
|
* switching for card-detection, they are responsible for calling
|
||||||
* mmc_gpio_request_cd() and mmc_gpio_free_cd() as a pair on their own.
|
* mmc_gpio_request_cd() and mmc_gpio_free_cd() as a pair on their own.
|
||||||
*
|
*
|
||||||
|
* If GPIO debouncing is desired, set the debounce parameter to a non-zero
|
||||||
|
* value. The caller is responsible for ensuring that the GPIO driver associated
|
||||||
|
* with the GPIO supports debouncing, otherwise an error will be returned.
|
||||||
|
*
|
||||||
* Returns zero on success, else an error.
|
* Returns zero on success, else an error.
|
||||||
*/
|
*/
|
||||||
int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio)
|
int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio,
|
||||||
|
unsigned int debounce)
|
||||||
{
|
{
|
||||||
struct mmc_gpio *ctx;
|
struct mmc_gpio *ctx;
|
||||||
int irq = gpio_to_irq(gpio);
|
int irq = gpio_to_irq(gpio);
|
||||||
@@ -167,6 +173,12 @@ int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio)
|
|||||||
*/
|
*/
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
if (debounce) {
|
||||||
|
ret = gpio_set_debounce(gpio, debounce);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Even if gpio_to_irq() returns a valid IRQ number, the platform might
|
* Even if gpio_to_irq() returns a valid IRQ number, the platform might
|
||||||
* still prefer to poll, e.g., because that IRQ number is already used
|
* still prefer to poll, e.g., because that IRQ number is already used
|
||||||
|
@@ -713,7 +713,7 @@ static int jz4740_mmc_request_gpios(struct mmc_host *mmc,
|
|||||||
mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
|
mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
|
||||||
|
|
||||||
if (gpio_is_valid(pdata->gpio_card_detect)) {
|
if (gpio_is_valid(pdata->gpio_card_detect)) {
|
||||||
ret = mmc_gpio_request_cd(mmc, pdata->gpio_card_detect);
|
ret = mmc_gpio_request_cd(mmc, pdata->gpio_card_detect, 0);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -757,7 +757,8 @@ static int __init mvsd_probe(struct platform_device *pdev)
|
|||||||
if (mvsd_data->gpio_card_detect &&
|
if (mvsd_data->gpio_card_detect &&
|
||||||
gpio_is_valid(mvsd_data->gpio_card_detect)) {
|
gpio_is_valid(mvsd_data->gpio_card_detect)) {
|
||||||
ret = mmc_gpio_request_cd(mmc,
|
ret = mmc_gpio_request_cd(mmc,
|
||||||
mvsd_data->gpio_card_detect);
|
mvsd_data->gpio_card_detect,
|
||||||
|
0);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -616,7 +616,7 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
|
|||||||
/* card_detect */
|
/* card_detect */
|
||||||
switch (boarddata->cd_type) {
|
switch (boarddata->cd_type) {
|
||||||
case ESDHC_CD_GPIO:
|
case ESDHC_CD_GPIO:
|
||||||
err = mmc_gpio_request_cd(host->mmc, boarddata->cd_gpio);
|
err = mmc_gpio_request_cd(host->mmc, boarddata->cd_gpio, 0);
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_err(mmc_dev(host->mmc),
|
dev_err(mmc_dev(host->mmc),
|
||||||
"failed to request card-detect gpio!\n");
|
"failed to request card-detect gpio!\n");
|
||||||
|
@@ -278,7 +278,8 @@ static int sdhci_pxav3_probe(struct platform_device *pdev)
|
|||||||
host->mmc->pm_caps |= pdata->pm_caps;
|
host->mmc->pm_caps |= pdata->pm_caps;
|
||||||
|
|
||||||
if (gpio_is_valid(pdata->ext_cd_gpio)) {
|
if (gpio_is_valid(pdata->ext_cd_gpio)) {
|
||||||
ret = mmc_gpio_request_cd(host->mmc, pdata->ext_cd_gpio);
|
ret = mmc_gpio_request_cd(host->mmc, pdata->ext_cd_gpio,
|
||||||
|
0);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(mmc_dev(host->mmc),
|
dev_err(mmc_dev(host->mmc),
|
||||||
"failed to allocate card detect gpio\n");
|
"failed to allocate card detect gpio\n");
|
||||||
|
@@ -84,7 +84,7 @@ static int sdhci_sirf_probe(struct platform_device *pdev)
|
|||||||
* gets setup in sdhci_add_host() and we oops.
|
* gets setup in sdhci_add_host() and we oops.
|
||||||
*/
|
*/
|
||||||
if (gpio_is_valid(priv->gpio_cd)) {
|
if (gpio_is_valid(priv->gpio_cd)) {
|
||||||
ret = mmc_gpio_request_cd(host->mmc, priv->gpio_cd);
|
ret = mmc_gpio_request_cd(host->mmc, priv->gpio_cd, 0);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "card detect irq request failed: %d\n",
|
dev_err(&pdev->dev, "card detect irq request failed: %d\n",
|
||||||
ret);
|
ret);
|
||||||
|
@@ -1436,7 +1436,7 @@ static int sh_mmcif_probe(struct platform_device *pdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pd && pd->use_cd_gpio) {
|
if (pd && pd->use_cd_gpio) {
|
||||||
ret = mmc_gpio_request_cd(mmc, pd->cd_gpio);
|
ret = mmc_gpio_request_cd(mmc, pd->cd_gpio, 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto erqcd;
|
goto erqcd;
|
||||||
}
|
}
|
||||||
|
@@ -1110,7 +1110,7 @@ int tmio_mmc_host_probe(struct tmio_mmc_host **host,
|
|||||||
dev_pm_qos_expose_latency_limit(&pdev->dev, 100);
|
dev_pm_qos_expose_latency_limit(&pdev->dev, 100);
|
||||||
|
|
||||||
if (pdata->flags & TMIO_MMC_USE_GPIO_CD) {
|
if (pdata->flags & TMIO_MMC_USE_GPIO_CD) {
|
||||||
ret = mmc_gpio_request_cd(mmc, pdata->cd_gpio);
|
ret = mmc_gpio_request_cd(mmc, pdata->cd_gpio, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
tmio_mmc_host_remove(_host);
|
tmio_mmc_host_remove(_host);
|
||||||
return ret;
|
return ret;
|
||||||
|
@@ -18,7 +18,8 @@ int mmc_gpio_request_ro(struct mmc_host *host, unsigned int gpio);
|
|||||||
void mmc_gpio_free_ro(struct mmc_host *host);
|
void mmc_gpio_free_ro(struct mmc_host *host);
|
||||||
|
|
||||||
int mmc_gpio_get_cd(struct mmc_host *host);
|
int mmc_gpio_get_cd(struct mmc_host *host);
|
||||||
int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio);
|
int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio,
|
||||||
|
unsigned int debounce);
|
||||||
void mmc_gpio_free_cd(struct mmc_host *host);
|
void mmc_gpio_free_cd(struct mmc_host *host);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user