Commit 9676a7ef authored by Chen Wang's avatar Chen Wang Committed by Ulf Hansson

mmc: sdhci-of-dwcmshc: factor out code into dwcmshc_rk35xx_init

Continue factor out code fron probe into dwcmshc_rk35xx_init.
Signed-off-by: default avatarChen Wang <unicorn_wang@outlook.com>
Tested-by: Drew Fustini <drew@pdp7.com> # TH1520
Tested-by: Inochi Amaoto <inochiama@outlook.com> # Duo and Huashan Pi
Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Link: https://lore.kernel.org/r/4f1f2fa403ce7f0b4d79afb7d7e8a1690cde5d6c.1722847198.git.unicorn_wang@outlook.comSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 76610189
...@@ -711,12 +711,22 @@ static void rk35xx_sdhci_reset(struct sdhci_host *host, u8 mask) ...@@ -711,12 +711,22 @@ static void rk35xx_sdhci_reset(struct sdhci_host *host, u8 mask)
sdhci_reset(host, mask); sdhci_reset(host, mask);
} }
static int dwcmshc_rk35xx_init(struct sdhci_host *host, struct dwcmshc_priv *dwc_priv) static int dwcmshc_rk35xx_init(struct device *dev, struct sdhci_host *host,
struct dwcmshc_priv *dwc_priv)
{ {
static const char * const clk_ids[] = {"axi", "block", "timer"}; static const char * const clk_ids[] = {"axi", "block", "timer"};
struct rk35xx_priv *priv = dwc_priv->priv; struct rk35xx_priv *priv;
int err; int err;
priv = devm_kzalloc(dev, sizeof(struct rk35xx_priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
if (of_device_is_compatible(dev->of_node, "rockchip,rk3588-dwcmshc"))
priv->devtype = DWCMSHC_RK3588;
else
priv->devtype = DWCMSHC_RK3568;
priv->reset = devm_reset_control_array_get_optional_exclusive(mmc_dev(host->mmc)); priv->reset = devm_reset_control_array_get_optional_exclusive(mmc_dev(host->mmc));
if (IS_ERR(priv->reset)) { if (IS_ERR(priv->reset)) {
err = PTR_ERR(priv->reset); err = PTR_ERR(priv->reset);
...@@ -739,6 +749,8 @@ static int dwcmshc_rk35xx_init(struct sdhci_host *host, struct dwcmshc_priv *dwc ...@@ -739,6 +749,8 @@ static int dwcmshc_rk35xx_init(struct sdhci_host *host, struct dwcmshc_priv *dwc
sdhci_writel(host, 0, DWCMSHC_EMMC_DLL_TXCLK); sdhci_writel(host, 0, DWCMSHC_EMMC_DLL_TXCLK);
sdhci_writel(host, 0, DWCMSHC_EMMC_DLL_STRBIN); sdhci_writel(host, 0, DWCMSHC_EMMC_DLL_STRBIN);
dwc_priv->priv = priv;
return 0; return 0;
} }
...@@ -1184,7 +1196,6 @@ static int dwcmshc_probe(struct platform_device *pdev) ...@@ -1184,7 +1196,6 @@ static int dwcmshc_probe(struct platform_device *pdev)
struct sdhci_pltfm_host *pltfm_host; struct sdhci_pltfm_host *pltfm_host;
struct sdhci_host *host; struct sdhci_host *host;
struct dwcmshc_priv *priv; struct dwcmshc_priv *priv;
struct rk35xx_priv *rk_priv = NULL;
const struct sdhci_pltfm_data *pltfm_data; const struct sdhci_pltfm_data *pltfm_data;
int err; int err;
u32 extra, caps; u32 extra, caps;
...@@ -1241,20 +1252,7 @@ static int dwcmshc_probe(struct platform_device *pdev) ...@@ -1241,20 +1252,7 @@ static int dwcmshc_probe(struct platform_device *pdev)
host->mmc_host_ops.execute_tuning = dwcmshc_execute_tuning; host->mmc_host_ops.execute_tuning = dwcmshc_execute_tuning;
if (pltfm_data == &sdhci_dwcmshc_rk35xx_pdata) { if (pltfm_data == &sdhci_dwcmshc_rk35xx_pdata) {
rk_priv = devm_kzalloc(&pdev->dev, sizeof(struct rk35xx_priv), GFP_KERNEL); err = dwcmshc_rk35xx_init(dev, host, priv);
if (!rk_priv) {
err = -ENOMEM;
goto err_clk;
}
if (of_device_is_compatible(pdev->dev.of_node, "rockchip,rk3588-dwcmshc"))
rk_priv->devtype = DWCMSHC_RK3588;
else
rk_priv->devtype = DWCMSHC_RK3568;
priv->priv = rk_priv;
err = dwcmshc_rk35xx_init(host, priv);
if (err) if (err)
goto err_clk; goto err_clk;
} }
...@@ -1290,7 +1288,7 @@ static int dwcmshc_probe(struct platform_device *pdev) ...@@ -1290,7 +1288,7 @@ static int dwcmshc_probe(struct platform_device *pdev)
dwcmshc_cqhci_init(host, pdev); dwcmshc_cqhci_init(host, pdev);
} }
if (rk_priv) if (pltfm_data == &sdhci_dwcmshc_rk35xx_pdata)
dwcmshc_rk35xx_postinit(host, priv); dwcmshc_rk35xx_postinit(host, priv);
err = __sdhci_add_host(host); err = __sdhci_add_host(host);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment