Skip to content

Commit f29bf66

Browse files
wojtas-marcinUlf Hansson
authored andcommitted
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: Marcin Wojtas <mw@semihalf.com> Link: https://lore.kernel.org/r/20201204171626.10935-3-mw@semihalf.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent f75fda3 commit f29bf66

3 files changed

Lines changed: 30 additions & 28 deletions

File tree

drivers/mmc/host/sdhci-xenon-phy.c

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -691,35 +691,37 @@ static int get_dt_pad_ctrl_data(struct sdhci_host *host,
691691
return ret;
692692
}
693693

694-
static int xenon_emmc_phy_parse_param_dt(struct sdhci_host *host,
695-
struct device_node *np,
696-
struct xenon_emmc_phy_params *params)
694+
static int xenon_emmc_phy_parse_params(struct sdhci_host *host,
695+
struct device *dev,
696+
struct xenon_emmc_phy_params *params)
697697
{
698698
u32 value;
699699

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

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

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

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

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

722-
return get_dt_pad_ctrl_data(host, np, params);
722+
if (dev->of_node)
723+
return get_dt_pad_ctrl_data(host, dev->of_node, params);
724+
return 0;
723725
}
724726

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

816-
static int xenon_add_phy(struct device_node *np, struct sdhci_host *host,
818+
static int xenon_add_phy(struct device *dev, struct sdhci_host *host,
817819
const char *phy_name)
818820
{
819821
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,
832834
if (ret)
833835
return ret;
834836

835-
return xenon_emmc_phy_parse_param_dt(host, np, priv->phy_params);
837+
return xenon_emmc_phy_parse_params(host, dev, priv->phy_params);
836838
}
837839

838-
int xenon_phy_parse_dt(struct device_node *np, struct sdhci_host *host)
840+
int xenon_phy_parse_params(struct device *dev, struct sdhci_host *host)
839841
{
840842
const char *phy_type = NULL;
841843

842-
if (!of_property_read_string(np, "marvell,xenon-phy-type", &phy_type))
843-
return xenon_add_phy(np, host, phy_type);
844+
if (!device_property_read_string(dev, "marvell,xenon-phy-type", &phy_type))
845+
return xenon_add_phy(dev, host, phy_type);
844846

845-
return xenon_add_phy(np, host, "emmc 5.1 phy");
847+
return xenon_add_phy(dev, host, "emmc 5.1 phy");
846848
}

drivers/mmc/host/sdhci-xenon.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,9 @@ static void xenon_replace_mmc_host_ops(struct sdhci_host *host)
407407
* Refer to XENON_SYS_CFG_INFO register
408408
* tun-count: the interval between re-tuning
409409
*/
410-
static int xenon_probe_dt(struct platform_device *pdev)
410+
static int xenon_probe_params(struct platform_device *pdev)
411411
{
412-
struct device_node *np = pdev->dev.of_node;
412+
struct device *dev = &pdev->dev;
413413
struct sdhci_host *host = platform_get_drvdata(pdev);
414414
struct mmc_host *mmc = host->mmc;
415415
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
@@ -422,7 +422,7 @@ static int xenon_probe_dt(struct platform_device *pdev)
422422
host->quirks2 |= SDHCI_QUIRK2_BROKEN_HS200;
423423

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

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

447-
return xenon_phy_parse_dt(np, host);
447+
return xenon_phy_parse_params(dev, host);
448448
}
449449

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

531-
sdhci_get_of_property(pdev);
531+
sdhci_get_property(pdev);
532532

533533
xenon_set_acg(host, false);
534534

535-
/* Xenon specific dt parse */
536-
err = xenon_probe_dt(pdev);
535+
/* Xenon specific parameters parse */
536+
err = xenon_probe_params(pdev);
537537
if (err)
538538
goto err_clk_axi;
539539

drivers/mmc/host/sdhci-xenon.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ struct xenon_priv {
101101
};
102102

103103
int xenon_phy_adj(struct sdhci_host *host, struct mmc_ios *ios);
104-
int xenon_phy_parse_dt(struct device_node *np,
105-
struct sdhci_host *host);
104+
int xenon_phy_parse_params(struct device *dev,
105+
struct sdhci_host *host);
106106
void xenon_soc_pad_ctrl(struct sdhci_host *host,
107107
unsigned char signal_voltage);
108108
#endif

0 commit comments

Comments
 (0)