diff options
author | Ye Li <ye.li@nxp.com> | 2017-04-05 00:24:46 +0800 |
---|---|---|
committer | Ye Li <ye.li@nxp.com> | 2017-04-05 19:48:58 +0800 |
commit | 733a7fde6fea35d6f2ea18c7759a06904b655e54 (patch) | |
tree | 4e29c1995c9e3c9866d0539caf1f61d5b145dd67 | |
parent | 24984d7d47294fd8ed9ae71e7e47449e929b730f (diff) | |
download | u-boot-imx-733a7fde6fea35d6f2ea18c7759a06904b655e54.zip u-boot-imx-733a7fde6fea35d6f2ea18c7759a06904b655e54.tar.gz u-boot-imx-733a7fde6fea35d6f2ea18c7759a06904b655e54.tar.bz2 |
MLK-14608 fsl_esdhc: Fix wp_enable issue
The wp-gpios property is used for gpio, if this is set, the WP pin is muxed
to gpio function, can't be used as internal WP checking.
This patch changes to examine the "fsl,wp-controller" for using internal WP checking. And
wp-gpios for using gpio pin.
Signed-off-by: Ye Li <ye.li@nxp.com>
-rw-r--r-- | drivers/mmc/fsl_esdhc.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c index 2b148a7..bc9dc2a 100644 --- a/drivers/mmc/fsl_esdhc.c +++ b/drivers/mmc/fsl_esdhc.c @@ -262,6 +262,13 @@ static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data) printf("\nThe SD card is locked. Can not write to a locked card.\n\n"); return -ETIMEDOUT; } + } else { +#ifdef CONFIG_DM_GPIO + if (dm_gpio_is_valid(&priv->wp_gpio) && dm_gpio_get_value(&priv->wp_gpio)) { + printf("\nThe SD card is locked. Can not write to a locked card.\n\n"); + return -ETIMEDOUT; + } +#endif } esdhc_clrsetbits32(®s->wml, WML_WR_WML_MASK, @@ -1011,14 +1018,15 @@ static int fsl_esdhc_probe(struct udevice *dev) #endif } - priv->wp_enable = 1; - + if (fdt_get_property(fdt, node, "fsl,wp-controller", NULL)) { + priv->wp_enable = 1; + } else { + priv->wp_enable = 0; #ifdef CONFIG_DM_GPIO - ret = gpio_request_by_name_nodev(fdt, node, "wp-gpios", 0, + gpio_request_by_name_nodev(fdt, node, "wp-gpios", 0, &priv->wp_gpio, GPIOD_IS_IN); - if (ret) - priv->wp_enable = 0; #endif + } #ifdef CONFIG_DM_REGULATOR ret = device_get_supply_regulator(dev, "vqmmc-supply", &vqmmc_dev); |