Commit 9da605be6d73b8fca627cdd272fce51bdc4c0b6d
1 parent
da81fab877
Exists in
smarc_8mm-imx_v2018.03_4.14.98_2.0.0_ga
and in
5 other branches
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> (cherry picked from commit 733a7fde6fea35d6f2ea18c7759a06904b655e54)
Showing 1 changed file with 13 additions and 5 deletions Side-by-side Diff
drivers/mmc/fsl_esdhc.c
... | ... | @@ -296,6 +296,13 @@ |
296 | 296 | printf("\nThe SD card is locked. Can not write to a locked card.\n\n"); |
297 | 297 | return -ETIMEDOUT; |
298 | 298 | } |
299 | + } else { | |
300 | +#ifdef CONFIG_DM_GPIO | |
301 | + if (dm_gpio_is_valid(&priv->wp_gpio) && dm_gpio_get_value(&priv->wp_gpio)) { | |
302 | + printf("\nThe SD card is locked. Can not write to a locked card.\n\n"); | |
303 | + return -ETIMEDOUT; | |
304 | + } | |
305 | +#endif | |
299 | 306 | } |
300 | 307 | |
301 | 308 | esdhc_clrsetbits32(®s->wml, WML_WR_WML_MASK, |
302 | 309 | |
303 | 310 | |
304 | 311 | |
... | ... | @@ -1441,14 +1448,15 @@ |
1441 | 1448 | #endif |
1442 | 1449 | } |
1443 | 1450 | |
1444 | - priv->wp_enable = 1; | |
1445 | - | |
1451 | + if (dev_read_prop(dev, "fsl,wp-controller", NULL)) { | |
1452 | + priv->wp_enable = 1; | |
1453 | + } else { | |
1454 | + priv->wp_enable = 0; | |
1446 | 1455 | #ifdef CONFIG_DM_GPIO |
1447 | - ret = gpio_request_by_name(dev, "wp-gpios", 0, &priv->wp_gpio, | |
1456 | + gpio_request_by_name(dev, "wp-gpios", 0, &priv->wp_gpio, | |
1448 | 1457 | GPIOD_IS_IN); |
1449 | - if (ret) | |
1450 | - priv->wp_enable = 0; | |
1451 | 1458 | #endif |
1459 | + } | |
1452 | 1460 | |
1453 | 1461 | priv->vs18_enable = 0; |
1454 | 1462 |