63e2807916
- switch sources to official repo https://source.denx.de/u-boot - use tag v2021.07 - extract patches from pine64-org - enable DMA transfers from eMMC and mSD (u-boot from Megi) [ci:skip-build] already built successfully in CI
107 lines
3.2 KiB
Diff
107 lines
3.2 KiB
Diff
From 93962fbf1fe4ea4a53bffa035b991315b1af46a0 Mon Sep 17 00:00:00 2001
|
|
From: Andre Przywara <andre.przywara@arm.com>
|
|
Date: Wed, 21 Apr 2021 09:33:04 +0100
|
|
Subject: [PATCH 08/29] mmc: sunxi: Use mmc_of_parse()
|
|
|
|
At the moment the Allwinner MMC driver parses the bus-width and
|
|
non-removable DT properties itself, in the probe() routine.
|
|
|
|
There is actually a generic function provided by the MMC framework doing
|
|
this job, also it parses more generic properties like broken-cd and
|
|
advanced transfer modes.
|
|
|
|
Drop our own code and call mmc_of_parse() instead, to get all new
|
|
features for free.
|
|
|
|
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
|
|
---
|
|
drivers/mmc/sunxi_mmc.c | 32 +++++++++++++++++---------------
|
|
1 file changed, 17 insertions(+), 15 deletions(-)
|
|
|
|
diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c
|
|
index ce085c69f5..28af8e6ac5 100644
|
|
--- a/drivers/mmc/sunxi_mmc.c
|
|
+++ b/drivers/mmc/sunxi_mmc.c
|
|
@@ -37,7 +37,6 @@ 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;
|
|
};
|
|
@@ -612,12 +611,21 @@ static int sunxi_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
|
|
|
|
static int sunxi_mmc_getcd(struct udevice *dev)
|
|
{
|
|
+ struct mmc *mmc = mmc_get_mmc_dev(dev);
|
|
struct sunxi_mmc_priv *priv = dev_get_priv(dev);
|
|
|
|
+ /* If polling, assume that the card is always present. */
|
|
+ if ((mmc->cfg->host_caps & MMC_CAP_NONREMOVABLE) ||
|
|
+ (mmc->cfg->host_caps & MMC_CAP_NEEDS_POLL))
|
|
+ return 1;
|
|
+
|
|
if (dm_gpio_is_valid(&priv->cd_gpio)) {
|
|
int cd_state = dm_gpio_get_value(&priv->cd_gpio);
|
|
|
|
- return cd_state ^ priv->cd_inverted;
|
|
+ if (mmc->cfg->host_caps & MMC_CAP_CD_ACTIVE_HIGH)
|
|
+ return !cd_state;
|
|
+ else
|
|
+ return cd_state;
|
|
}
|
|
return 1;
|
|
}
|
|
@@ -649,23 +657,21 @@ static int sunxi_mmc_probe(struct udevice *dev)
|
|
struct mmc_config *cfg = &plat->cfg;
|
|
struct ofnode_phandle_args args;
|
|
u32 *ccu_reg;
|
|
- int bus_width, ret;
|
|
+ int ret;
|
|
|
|
cfg->name = dev->name;
|
|
- bus_width = dev_read_u32_default(dev, "bus-width", 1);
|
|
|
|
cfg->voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
|
|
- cfg->host_caps = 0;
|
|
- if (bus_width == 8)
|
|
- cfg->host_caps |= MMC_MODE_8BIT;
|
|
- if (bus_width >= 4)
|
|
- cfg->host_caps |= MMC_MODE_4BIT;
|
|
- cfg->host_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS;
|
|
+ cfg->host_caps = MMC_MODE_HS_52MHz | MMC_MODE_HS;
|
|
cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
|
|
|
|
cfg->f_min = 400000;
|
|
cfg->f_max = 52000000;
|
|
|
|
+ ret = mmc_of_parse(dev, cfg);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
priv->reg = dev_read_addr_ptr(dev);
|
|
|
|
/* We don't have a sunxi clock driver so find the clock address here */
|
|
@@ -691,17 +697,13 @@ static int sunxi_mmc_probe(struct udevice *dev)
|
|
return ret;
|
|
|
|
/* This GPIO is optional */
|
|
- if (!dev_read_bool(dev, "non-removable") &&
|
|
- !gpio_request_by_name(dev, "cd-gpios", 0, &priv->cd_gpio,
|
|
+ if (!gpio_request_by_name(dev, "cd-gpios", 0, &priv->cd_gpio,
|
|
GPIOD_IS_IN)) {
|
|
int cd_pin = gpio_get_number(&priv->cd_gpio);
|
|
|
|
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 */
|
|
--
|
|
2.31.1
|
|
|