Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Marcin Wojtas and committed by
Ulf Hansson
f29bf660 f75fda37

+30 -28
+19 -17
drivers/mmc/host/sdhci-xenon-phy.c
··· 691 691 return ret; 692 692 } 693 693 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) 697 697 { 698 698 u32 value; 699 699 700 700 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")) 702 702 params->slow_mode = true; 703 703 704 704 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)) 706 706 params->znr = value & XENON_ZNR_MASK; 707 707 708 708 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)) 710 710 params->zpr = value & XENON_ZPR_MASK; 711 711 712 712 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)) 715 715 params->nr_tun_times = value & XENON_TUN_CONSECUTIVE_TIMES_MASK; 716 716 717 717 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)) 720 720 params->tun_step_divider = value & 0xFF; 721 721 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; 723 725 } 724 726 725 727 /* Set SoC PHY Voltage PAD */ ··· 815 813 return ret; 816 814 } 817 815 818 - static int xenon_add_phy(struct device_node *np, struct sdhci_host *host, 816 + static int xenon_add_phy(struct device *dev, struct sdhci_host *host, 819 817 const char *phy_name) 820 818 { 821 819 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); ··· 834 832 if (ret) 835 833 return ret; 836 834 837 - return xenon_emmc_phy_parse_param_dt(host, np, priv->phy_params); 835 + return xenon_emmc_phy_parse_params(host, dev, priv->phy_params); 838 836 } 839 837 840 - int xenon_phy_parse_dt(struct device_node *np, struct sdhci_host *host) 838 + int xenon_phy_parse_params(struct device *dev, struct sdhci_host *host) 841 839 { 842 840 const char *phy_type = NULL; 843 841 844 - if (!of_property_read_string(np, "marvell,xenon-phy-type", &phy_type)) 845 - return xenon_add_phy(np, host, phy_type); 842 + if (!device_property_read_string(dev, "marvell,xenon-phy-type", &phy_type)) 843 + return xenon_add_phy(dev, host, phy_type); 846 844 847 - return xenon_add_phy(np, host, "emmc 5.1 phy"); 845 + return xenon_add_phy(dev, host, "emmc 5.1 phy"); 848 846 }
+9 -9
drivers/mmc/host/sdhci-xenon.c
··· 407 407 * Refer to XENON_SYS_CFG_INFO register 408 408 * tun-count: the interval between re-tuning 409 409 */ 410 - static int xenon_probe_dt(struct platform_device *pdev) 410 + static int xenon_probe_params(struct platform_device *pdev) 411 411 { 412 - struct device_node *np = pdev->dev.of_node; 412 + struct device *dev = &pdev->dev; 413 413 struct sdhci_host *host = platform_get_drvdata(pdev); 414 414 struct mmc_host *mmc = host->mmc; 415 415 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); ··· 422 422 host->quirks2 |= SDHCI_QUIRK2_BROKEN_HS200; 423 423 424 424 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)) { 426 426 nr_sdhc = sdhci_readl(host, XENON_SYS_CFG_INFO); 427 427 nr_sdhc &= XENON_NR_SUPPORTED_SLOT_MASK; 428 428 if (unlikely(sdhc_id > nr_sdhc)) { ··· 434 434 priv->sdhc_id = sdhc_id; 435 435 436 436 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)) { 439 439 if (unlikely(tuning_count >= XENON_TMR_RETUN_NO_PRESENT)) { 440 440 dev_err(mmc_dev(mmc), "Wrong Re-tuning Count. Set default value %d\n", 441 441 XENON_DEF_TUNING_COUNT); ··· 444 444 } 445 445 priv->tuning_count = tuning_count; 446 446 447 - return xenon_phy_parse_dt(np, host); 447 + return xenon_phy_parse_params(dev, host); 448 448 } 449 449 450 450 static int xenon_sdhc_prepare(struct sdhci_host *host) ··· 528 528 if (err) 529 529 goto err_clk_axi; 530 530 531 - sdhci_get_of_property(pdev); 531 + sdhci_get_property(pdev); 532 532 533 533 xenon_set_acg(host, false); 534 534 535 - /* Xenon specific dt parse */ 536 - err = xenon_probe_dt(pdev); 535 + /* Xenon specific parameters parse */ 536 + err = xenon_probe_params(pdev); 537 537 if (err) 538 538 goto err_clk_axi; 539 539
+2 -2
drivers/mmc/host/sdhci-xenon.h
··· 101 101 }; 102 102 103 103 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); 106 106 void xenon_soc_pad_ctrl(struct sdhci_host *host, 107 107 unsigned char signal_voltage); 108 108 #endif