Commit f29bf660 authored by Marcin Wojtas's avatar Marcin Wojtas Committed by Ulf Hansson
Browse files

mmc: sdhci-xenon: switch to device_* API



In order to support both ACPI and DT, modify the driver
to use device_* routines for obtaining the properties
values.

Signed-off-by: default avatarMarcin Wojtas <mw@semihalf.com>
Link: https://lore.kernel.org/r/20201204171626.10935-3-mw@semihalf.com


Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent f75fda37
Loading
Loading
Loading
Loading
+19 −17
Original line number Diff line number Diff line
@@ -691,35 +691,37 @@ static int get_dt_pad_ctrl_data(struct sdhci_host *host,
	return ret;
}

static int xenon_emmc_phy_parse_param_dt(struct sdhci_host *host,
					 struct device_node *np,
static int xenon_emmc_phy_parse_params(struct sdhci_host *host,
				       struct device *dev,
				       struct xenon_emmc_phy_params *params)
{
	u32 value;

	params->slow_mode = false;
	if (of_property_read_bool(np, "marvell,xenon-phy-slow-mode"))
	if (device_property_read_bool(dev, "marvell,xenon-phy-slow-mode"))
		params->slow_mode = true;

	params->znr = XENON_ZNR_DEF_VALUE;
	if (!of_property_read_u32(np, "marvell,xenon-phy-znr", &value))
	if (!device_property_read_u32(dev, "marvell,xenon-phy-znr", &value))
		params->znr = value & XENON_ZNR_MASK;

	params->zpr = XENON_ZPR_DEF_VALUE;
	if (!of_property_read_u32(np, "marvell,xenon-phy-zpr", &value))
	if (!device_property_read_u32(dev, "marvell,xenon-phy-zpr", &value))
		params->zpr = value & XENON_ZPR_MASK;

	params->nr_tun_times = XENON_TUN_CONSECUTIVE_TIMES;
	if (!of_property_read_u32(np, "marvell,xenon-phy-nr-success-tun",
	if (!device_property_read_u32(dev, "marvell,xenon-phy-nr-success-tun",
				      &value))
		params->nr_tun_times = value & XENON_TUN_CONSECUTIVE_TIMES_MASK;

	params->tun_step_divider = XENON_TUNING_STEP_DIVIDER;
	if (!of_property_read_u32(np, "marvell,xenon-phy-tun-step-divider",
	if (!device_property_read_u32(dev, "marvell,xenon-phy-tun-step-divider",
				      &value))
		params->tun_step_divider = value & 0xFF;

	return get_dt_pad_ctrl_data(host, np, params);
	if (dev->of_node)
		return get_dt_pad_ctrl_data(host, dev->of_node, params);
	return 0;
}

/* Set SoC PHY Voltage PAD */
@@ -813,7 +815,7 @@ int xenon_phy_adj(struct sdhci_host *host, struct mmc_ios *ios)
	return ret;
}

static int xenon_add_phy(struct device_node *np, struct sdhci_host *host,
static int xenon_add_phy(struct device *dev, struct sdhci_host *host,
			 const char *phy_name)
{
	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
@@ -832,15 +834,15 @@ static int xenon_add_phy(struct device_node *np, struct sdhci_host *host,
	if (ret)
		return ret;

	return xenon_emmc_phy_parse_param_dt(host, np, priv->phy_params);
	return xenon_emmc_phy_parse_params(host, dev, priv->phy_params);
}

int xenon_phy_parse_dt(struct device_node *np, struct sdhci_host *host)
int xenon_phy_parse_params(struct device *dev, struct sdhci_host *host)
{
	const char *phy_type = NULL;

	if (!of_property_read_string(np, "marvell,xenon-phy-type", &phy_type))
		return xenon_add_phy(np, host, phy_type);
	if (!device_property_read_string(dev, "marvell,xenon-phy-type", &phy_type))
		return xenon_add_phy(dev, host, phy_type);

	return xenon_add_phy(np, host, "emmc 5.1 phy");
	return xenon_add_phy(dev, host, "emmc 5.1 phy");
}
+9 −9
Original line number Diff line number Diff line
@@ -407,9 +407,9 @@ static void xenon_replace_mmc_host_ops(struct sdhci_host *host)
 *	    Refer to XENON_SYS_CFG_INFO register
 * tun-count: the interval between re-tuning
 */
static int xenon_probe_dt(struct platform_device *pdev)
static int xenon_probe_params(struct platform_device *pdev)
{
	struct device_node *np = pdev->dev.of_node;
	struct device *dev = &pdev->dev;
	struct sdhci_host *host = platform_get_drvdata(pdev);
	struct mmc_host *mmc = host->mmc;
	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
@@ -422,7 +422,7 @@ static int xenon_probe_dt(struct platform_device *pdev)
		host->quirks2 |= SDHCI_QUIRK2_BROKEN_HS200;

	sdhc_id = 0x0;
	if (!of_property_read_u32(np, "marvell,xenon-sdhc-id", &sdhc_id)) {
	if (!device_property_read_u32(dev, "marvell,xenon-sdhc-id", &sdhc_id)) {
		nr_sdhc = sdhci_readl(host, XENON_SYS_CFG_INFO);
		nr_sdhc &= XENON_NR_SUPPORTED_SLOT_MASK;
		if (unlikely(sdhc_id > nr_sdhc)) {
@@ -434,7 +434,7 @@ static int xenon_probe_dt(struct platform_device *pdev)
	priv->sdhc_id = sdhc_id;

	tuning_count = XENON_DEF_TUNING_COUNT;
	if (!of_property_read_u32(np, "marvell,xenon-tun-count",
	if (!device_property_read_u32(dev, "marvell,xenon-tun-count",
				      &tuning_count)) {
		if (unlikely(tuning_count >= XENON_TMR_RETUN_NO_PRESENT)) {
			dev_err(mmc_dev(mmc), "Wrong Re-tuning Count. Set default value %d\n",
@@ -444,7 +444,7 @@ static int xenon_probe_dt(struct platform_device *pdev)
	}
	priv->tuning_count = tuning_count;

	return xenon_phy_parse_dt(np, host);
	return xenon_phy_parse_params(dev, host);
}

static int xenon_sdhc_prepare(struct sdhci_host *host)
@@ -528,12 +528,12 @@ static int xenon_probe(struct platform_device *pdev)
	if (err)
		goto err_clk_axi;

	sdhci_get_of_property(pdev);
	sdhci_get_property(pdev);

	xenon_set_acg(host, false);

	/* Xenon specific dt parse */
	err = xenon_probe_dt(pdev);
	/* Xenon specific parameters parse */
	err = xenon_probe_params(pdev);
	if (err)
		goto err_clk_axi;

+2 −2
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ struct xenon_priv {
};

int xenon_phy_adj(struct sdhci_host *host, struct mmc_ios *ios);
int xenon_phy_parse_dt(struct device_node *np,
int xenon_phy_parse_params(struct device *dev,
			   struct sdhci_host *host);
void xenon_soc_pad_ctrl(struct sdhci_host *host,
			unsigned char signal_voltage);