#include <linux/mmc/host.h>
#include <linux/mmc/mmc.h>
#include <linux/mmc/sdio.h>
+#include <linux/mmc/slot-gpio.h>
#include <linux/gpio.h>
#include <linux/regulator/consumer.h>
#include <linux/module.h>
unsigned char bus_width;
spinlock_t lock;
int sdio_irq_en;
- int wp_gpio;
- bool wp_inverted;
};
-static int mxs_mmc_get_ro(struct mmc_host *mmc)
-{
- struct mxs_mmc_host *host = mmc_priv(mmc);
- int ret;
-
- if (!gpio_is_valid(host->wp_gpio))
- return -EINVAL;
-
- ret = gpio_get_value(host->wp_gpio);
-
- if (host->wp_inverted)
- ret = !ret;
-
- return ret;
-}
-
static int mxs_mmc_get_cd(struct mmc_host *mmc)
{
struct mxs_mmc_host *host = mmc_priv(mmc);
static const struct mmc_host_ops mxs_mmc_ops = {
.request = mxs_mmc_request,
- .get_ro = mxs_mmc_get_ro,
+ .get_ro = mmc_gpio_get_ro,
.get_cd = mxs_mmc_get_cd,
.set_ios = mxs_mmc_set_ios,
.enable_sdio_irq = mxs_mmc_enable_sdio_irq,
struct mxs_mmc_host *host;
struct mmc_host *mmc;
struct resource *iores;
- int ret = 0, irq_err;
+ int ret = 0, irq_err, gpio;
struct regulator *reg_vmmc;
enum of_gpio_flags flags;
struct mxs_ssp *ssp;
mmc->caps |= MMC_CAP_NEEDS_POLL;
if (of_property_read_bool(np, "non-removable"))
mmc->caps |= MMC_CAP_NONREMOVABLE;
- host->wp_gpio = of_get_named_gpio_flags(np, "wp-gpios", 0, &flags);
- if (flags & OF_GPIO_ACTIVE_LOW)
- host->wp_inverted = 1;
+ gpio = of_get_named_gpio_flags(np, "wp-gpios", 0, &flags);
+ if (gpio_is_valid(gpio)) {
+ ret = mmc_gpio_request_ro(mmc, gpio);
+ if (ret)
+ goto out_clk_disable;
+ if (!(flags & OF_GPIO_ACTIVE_LOW))
+ mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
+ }
if (of_property_read_bool(np, "cd-inverted"))
mmc->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH;