summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
84ecdf6)
Introudce wp_enable. To check WPSPL, wp_enable needs to be set
to 1 in board code.
Take i.MX6UL for example, for some boards, they do not use WP singal,
so they does not configure USDHC1_WP_SELECT_INPUT, and its default
value is 0(GPIO1_IO02). However GPIO1_IO02 is muxed for i2c usage and
SION bit set. So USDHC controller can always get wp signal and WPSPL
shows write protect and blocks driver continuing. This is not what
we want to see, so add wp_enable, and if set to 0, just omit the
WPSPL checking and this does not effect normal working of usdhc
controller.
If wp-gpios is provided in dts, wp_enable is set to 1, otherwise 0.
Signed-off-by: Peng Fan <van.freenix@gmail.com>
Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
Cc: York Sun <york.sun@nxp.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Tested-by: Fabio Estevam <fabio.estevam@nxp.com>
Reviewed-by: York Sun <york.sun@nxp.com>
* Following is used when Driver Model is enabled for MMC
* @dev: pointer for the device
* @non_removable: 0: removable; 1: non-removable
* Following is used when Driver Model is enabled for MMC
* @dev: pointer for the device
* @non_removable: 0: removable; 1: non-removable
+ * @wp_enable: 1: enable checking wp; 0: no check
* @cd_gpio: gpio for card detection
* @cd_gpio: gpio for card detection
+ * @wp_gpio: gpio for write protection
*/
struct fsl_esdhc_priv {
struct fsl_esdhc *esdhc_regs;
*/
struct fsl_esdhc_priv {
struct fsl_esdhc *esdhc_regs;
struct mmc *mmc;
struct udevice *dev;
int non_removable;
struct mmc *mmc;
struct udevice *dev;
int non_removable;
struct gpio_desc cd_gpio;
struct gpio_desc cd_gpio;
+ struct gpio_desc wp_gpio;
};
/* Return the XFERTYP flags for a given command and data packet */
};
/* Return the XFERTYP flags for a given command and data packet */
#endif
if (wml_value > WML_WR_WML_MAX)
wml_value = WML_WR_WML_MAX_VAL;
#endif
if (wml_value > WML_WR_WML_MAX)
wml_value = WML_WR_WML_MAX_VAL;
- if ((esdhc_read32(®s->prsstat) & PRSSTAT_WPSPL) == 0) {
- printf("\nThe SD card is locked. Can not write to a locked card.\n\n");
- return TIMEOUT;
+ if (priv->wp_enable) {
+ if ((esdhc_read32(®s->prsstat) &
+ PRSSTAT_WPSPL) == 0) {
+ printf("\nThe SD card is locked. Can not write to a locked card.\n\n");
+ return TIMEOUT;
+ }
}
esdhc_clrsetbits32(®s->wml, WML_WR_WML_MASK,
}
esdhc_clrsetbits32(®s->wml, WML_WR_WML_MASK,
priv->esdhc_regs = (struct fsl_esdhc *)(unsigned long)(cfg->esdhc_base);
priv->bus_width = cfg->max_bus_width;
priv->sdhc_clk = cfg->sdhc_clk;
priv->esdhc_regs = (struct fsl_esdhc *)(unsigned long)(cfg->esdhc_base);
priv->bus_width = cfg->max_bus_width;
priv->sdhc_clk = cfg->sdhc_clk;
+ priv->wp_enable = cfg->wp_enable;
&priv->cd_gpio, GPIOD_IS_IN);
}
&priv->cd_gpio, GPIOD_IS_IN);
}
+ priv->wp_enable = 1;
+
+ ret = gpio_request_by_name_nodev(fdt, node, "wp-gpios", 0,
+ &priv->wp_gpio, GPIOD_IS_IN);
+ if (ret)
+ priv->wp_enable = 0;
+
/*
* TODO:
* Because lack of clk driver, if SDHC clk is not enabled,
/*
* TODO:
* Because lack of clk driver, if SDHC clk is not enabled,
phys_addr_t esdhc_base;
u32 sdhc_clk;
u8 max_bus_width;
phys_addr_t esdhc_base;
u32 sdhc_clk;
u8 max_bus_width;
struct mmc_config cfg;
};
struct mmc_config cfg;
};