mirror of https://gitee.com/openkylin/linux.git
mmc: sdhci-esdhc-imx: use slot-gpio helpers for CD and WP
Use slot-gpio helpers to save some code in the driver. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Chris Ball <cjb@laptop.org>
This commit is contained in:
parent
60fe3ec121
commit
f6e644389d
|
@ -21,6 +21,7 @@
|
||||||
#include <linux/mmc/host.h>
|
#include <linux/mmc/host.h>
|
||||||
#include <linux/mmc/mmc.h>
|
#include <linux/mmc/mmc.h>
|
||||||
#include <linux/mmc/sdio.h>
|
#include <linux/mmc/sdio.h>
|
||||||
|
#include <linux/mmc/slot-gpio.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/of_device.h>
|
#include <linux/of_device.h>
|
||||||
#include <linux/of_gpio.h>
|
#include <linux/of_gpio.h>
|
||||||
|
@ -147,17 +148,16 @@ static u32 esdhc_readl_le(struct sdhci_host *host, int reg)
|
||||||
struct pltfm_imx_data *imx_data = pltfm_host->priv;
|
struct pltfm_imx_data *imx_data = pltfm_host->priv;
|
||||||
struct esdhc_platform_data *boarddata = &imx_data->boarddata;
|
struct esdhc_platform_data *boarddata = &imx_data->boarddata;
|
||||||
|
|
||||||
/* fake CARD_PRESENT flag */
|
|
||||||
u32 val = readl(host->ioaddr + reg);
|
u32 val = readl(host->ioaddr + reg);
|
||||||
|
|
||||||
if (unlikely((reg == SDHCI_PRESENT_STATE)
|
if (unlikely(reg == SDHCI_PRESENT_STATE)) {
|
||||||
&& gpio_is_valid(boarddata->cd_gpio))) {
|
/*
|
||||||
if (gpio_get_value(boarddata->cd_gpio))
|
* After SDHCI core gets improved to never query
|
||||||
/* no card, if a valid gpio says so... */
|
* SDHCI_CARD_PRESENT state in GPIO case, we can
|
||||||
|
* remove this check.
|
||||||
|
*/
|
||||||
|
if (boarddata->cd_type == ESDHC_CD_GPIO)
|
||||||
val &= ~SDHCI_CARD_PRESENT;
|
val &= ~SDHCI_CARD_PRESENT;
|
||||||
else
|
|
||||||
/* ... in all other cases assume card is present */
|
|
||||||
val |= SDHCI_CARD_PRESENT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlikely(reg == SDHCI_CAPABILITIES)) {
|
if (unlikely(reg == SDHCI_CAPABILITIES)) {
|
||||||
|
@ -362,8 +362,7 @@ static unsigned int esdhc_pltfm_get_ro(struct sdhci_host *host)
|
||||||
|
|
||||||
switch (boarddata->wp_type) {
|
switch (boarddata->wp_type) {
|
||||||
case ESDHC_WP_GPIO:
|
case ESDHC_WP_GPIO:
|
||||||
if (gpio_is_valid(boarddata->wp_gpio))
|
return mmc_gpio_get_ro(host->mmc);
|
||||||
return gpio_get_value(boarddata->wp_gpio);
|
|
||||||
case ESDHC_WP_CONTROLLER:
|
case ESDHC_WP_CONTROLLER:
|
||||||
return !(readl(host->ioaddr + SDHCI_PRESENT_STATE) &
|
return !(readl(host->ioaddr + SDHCI_PRESENT_STATE) &
|
||||||
SDHCI_WRITE_PROTECT);
|
SDHCI_WRITE_PROTECT);
|
||||||
|
@ -394,14 +393,6 @@ static struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = {
|
||||||
.ops = &sdhci_esdhc_ops,
|
.ops = &sdhci_esdhc_ops,
|
||||||
};
|
};
|
||||||
|
|
||||||
static irqreturn_t cd_irq(int irq, void *data)
|
|
||||||
{
|
|
||||||
struct sdhci_host *sdhost = (struct sdhci_host *)data;
|
|
||||||
|
|
||||||
tasklet_schedule(&sdhost->card_tasklet);
|
|
||||||
return IRQ_HANDLED;
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef CONFIG_OF
|
#ifdef CONFIG_OF
|
||||||
static int
|
static int
|
||||||
sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
|
sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
|
||||||
|
@ -527,37 +518,22 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
/* write_protect */
|
/* write_protect */
|
||||||
if (boarddata->wp_type == ESDHC_WP_GPIO) {
|
if (boarddata->wp_type == ESDHC_WP_GPIO) {
|
||||||
err = devm_gpio_request_one(&pdev->dev, boarddata->wp_gpio,
|
err = mmc_gpio_request_ro(host->mmc, boarddata->wp_gpio);
|
||||||
GPIOF_IN, "ESDHC_WP");
|
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_warn(mmc_dev(host->mmc),
|
dev_err(mmc_dev(host->mmc),
|
||||||
"no write-protect pin available!\n");
|
"failed to request write-protect gpio!\n");
|
||||||
boarddata->wp_gpio = -EINVAL;
|
goto disable_clk;
|
||||||
}
|
}
|
||||||
} else {
|
host->mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
|
||||||
boarddata->wp_gpio = -EINVAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* card_detect */
|
/* card_detect */
|
||||||
if (boarddata->cd_type != ESDHC_CD_GPIO)
|
|
||||||
boarddata->cd_gpio = -EINVAL;
|
|
||||||
|
|
||||||
switch (boarddata->cd_type) {
|
switch (boarddata->cd_type) {
|
||||||
case ESDHC_CD_GPIO:
|
case ESDHC_CD_GPIO:
|
||||||
err = devm_gpio_request_one(&pdev->dev, boarddata->cd_gpio,
|
err = mmc_gpio_request_cd(host->mmc, boarddata->cd_gpio);
|
||||||
GPIOF_IN, "ESDHC_CD");
|
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_err(mmc_dev(host->mmc),
|
dev_err(mmc_dev(host->mmc),
|
||||||
"no card-detect pin available!\n");
|
"failed to request card-detect gpio!\n");
|
||||||
goto disable_clk;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = devm_request_irq(&pdev->dev,
|
|
||||||
gpio_to_irq(boarddata->cd_gpio), cd_irq,
|
|
||||||
IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
|
|
||||||
mmc_hostname(host->mmc), host);
|
|
||||||
if (err) {
|
|
||||||
dev_err(mmc_dev(host->mmc), "request irq error\n");
|
|
||||||
goto disable_clk;
|
goto disable_clk;
|
||||||
}
|
}
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
Loading…
Reference in New Issue