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> Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
This commit is contained in:
@@ -37,7 +37,6 @@ struct sunxi_mmc_priv {
|
|||||||
uint32_t *mclkreg;
|
uint32_t *mclkreg;
|
||||||
unsigned fatal_err;
|
unsigned fatal_err;
|
||||||
struct gpio_desc cd_gpio; /* Change Detect GPIO */
|
struct gpio_desc cd_gpio; /* Change Detect GPIO */
|
||||||
int cd_inverted; /* Inverted Card Detect */
|
|
||||||
struct sunxi_mmc *reg;
|
struct sunxi_mmc *reg;
|
||||||
struct mmc_config cfg;
|
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)
|
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);
|
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)) {
|
if (dm_gpio_is_valid(&priv->cd_gpio)) {
|
||||||
int cd_state = dm_gpio_get_value(&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;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -649,23 +657,21 @@ static int sunxi_mmc_probe(struct udevice *dev)
|
|||||||
struct mmc_config *cfg = &plat->cfg;
|
struct mmc_config *cfg = &plat->cfg;
|
||||||
struct ofnode_phandle_args args;
|
struct ofnode_phandle_args args;
|
||||||
u32 *ccu_reg;
|
u32 *ccu_reg;
|
||||||
int bus_width, ret;
|
int ret;
|
||||||
|
|
||||||
cfg->name = dev->name;
|
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->voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
|
||||||
cfg->host_caps = 0;
|
cfg->host_caps = MMC_MODE_HS_52MHz | MMC_MODE_HS;
|
||||||
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->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
|
cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
|
||||||
|
|
||||||
cfg->f_min = 400000;
|
cfg->f_min = 400000;
|
||||||
cfg->f_max = 52000000;
|
cfg->f_max = 52000000;
|
||||||
|
|
||||||
|
ret = mmc_of_parse(dev, cfg);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
priv->reg = dev_read_addr_ptr(dev);
|
priv->reg = dev_read_addr_ptr(dev);
|
||||||
|
|
||||||
/* We don't have a sunxi clock driver so find the clock address here */
|
/* 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;
|
return ret;
|
||||||
|
|
||||||
/* This GPIO is optional */
|
/* This GPIO is optional */
|
||||||
if (!dev_read_bool(dev, "non-removable") &&
|
if (!gpio_request_by_name(dev, "cd-gpios", 0, &priv->cd_gpio,
|
||||||
!gpio_request_by_name(dev, "cd-gpios", 0, &priv->cd_gpio,
|
|
||||||
GPIOD_IS_IN)) {
|
GPIOD_IS_IN)) {
|
||||||
int cd_pin = gpio_get_number(&priv->cd_gpio);
|
int cd_pin = gpio_get_number(&priv->cd_gpio);
|
||||||
|
|
||||||
sunxi_gpio_set_pull(cd_pin, SUNXI_GPIO_PULL_UP);
|
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;
|
upriv->mmc = &plat->mmc;
|
||||||
|
|
||||||
/* Reset controller */
|
/* Reset controller */
|
||||||
|
Reference in New Issue
Block a user