[U-Boot] [PATCH 1/1] mmc: sunxi: support cd-inverted

With CONFIG_DM_MMC the BananaPi does not detect SD cards.
The sunxi device trees use the cd-inverted property to indicate that the card detect is inverted.
This property is documented in Linux kernel devicetree/bindings/mmc/mmc.txt The property is not marked as deprecated.
A similar patch was posted by Tuomas but is in status "Changes Requested". https://patchwork.ozlabs.org/patch/850377/
This patch is a stripped down version of his patch.
Suggested-by: Tuomas Tynkkynen tuomas@tuxera.com Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- drivers/mmc/sunxi_mmc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c index 4edb4be46c8..e7666e315f2 100644 --- a/drivers/mmc/sunxi_mmc.c +++ b/drivers/mmc/sunxi_mmc.c @@ -30,6 +30,7 @@ struct sunxi_mmc_priv { uint32_t *mclkreg; unsigned fatal_err; struct gpio_desc cd_gpio; /* Change Detect GPIO */ + int cd_inverted; /* Inverted Card Detect */ struct sunxi_mmc *reg; struct mmc_config cfg; }; @@ -544,9 +545,11 @@ static int sunxi_mmc_getcd(struct udevice *dev) { struct sunxi_mmc_priv *priv = dev_get_priv(dev);
- if (dm_gpio_is_valid(&priv->cd_gpio)) - return dm_gpio_get_value(&priv->cd_gpio); + if (dm_gpio_is_valid(&priv->cd_gpio)) { + int cd_state = dm_gpio_get_value(&priv->cd_gpio);
+ return cd_state ^ priv->cd_inverted; + } return 1; }
@@ -610,6 +613,9 @@ static int sunxi_mmc_probe(struct udevice *dev) sunxi_gpio_set_pull(cd_pin, SUNXI_GPIO_PULL_UP); }
+ /* Check if card detect is inverted */ + priv->cd_inverted = dev_read_bool(dev, "cd-inverted"); + upriv->mmc = &plat->mmc;
/* Reset controller */

On Thu, Feb 01, 2018 at 11:39:19PM +0100, Heinrich Schuchardt wrote:
With CONFIG_DM_MMC the BananaPi does not detect SD cards.
The sunxi device trees use the cd-inverted property to indicate that the card detect is inverted.
This property is documented in Linux kernel devicetree/bindings/mmc/mmc.txt The property is not marked as deprecated.
A similar patch was posted by Tuomas but is in status "Changes Requested". https://patchwork.ozlabs.org/patch/850377/
This patch is a stripped down version of his patch.
Suggested-by: Tuomas Tynkkynen tuomas@tuxera.com Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
Acked-by: Maxime Ripard maxime.ripard@free-electrons.com
Thanks! Maxime

On Fri, Feb 2, 2018 at 7:20 PM, Maxime Ripard maxime.ripard@bootlin.com wrote:
On Thu, Feb 01, 2018 at 11:39:19PM +0100, Heinrich Schuchardt wrote:
With CONFIG_DM_MMC the BananaPi does not detect SD cards.
The sunxi device trees use the cd-inverted property to indicate that the card detect is inverted.
This property is documented in Linux kernel devicetree/bindings/mmc/mmc.txt The property is not marked as deprecated.
A similar patch was posted by Tuomas but is in status "Changes Requested". https://patchwork.ozlabs.org/patch/850377/
This patch is a stripped down version of his patch.
Suggested-by: Tuomas Tynkkynen tuomas@tuxera.com Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
Acked-by: Maxime Ripard maxime.ripard@free-electrons.com
Reviewed-by: Jagan Teki jagan@openedev.com
Applied to u-boot-sunxi/master
participants (3)
-
Heinrich Schuchardt
-
Jagan Teki
-
Maxime Ripard