[U-Boot] [PATCH v2 44/55] rockchip: mmc: Move all DT decoding to ofdata_to_platdata()

Simon Glass sjg at chromium.org
Mon Jun 13 07:33:25 CEST 2016


It is more correct to avoid touching the device tree in the probe() method.
Update the driver to work this way.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

Changes in v2: None

 drivers/mmc/rockchip_dw_mmc.c | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c
index 750ab9f..26004be 100644
--- a/drivers/mmc/rockchip_dw_mmc.c
+++ b/drivers/mmc/rockchip_dw_mmc.c
@@ -27,6 +27,9 @@ struct rockchip_dwmmc_priv {
 	struct udevice *clk;
 	int periph;
 	struct dwmci_host host;
+	int fifo_depth;
+	bool fifo_mode;
+	u32 minmax[2];
 };
 
 static uint rockchip_dwmmc_get_mmc_clk(struct dwmci_host *host, uint freq)
@@ -62,6 +65,16 @@ static int rockchip_dwmmc_ofdata_to_platdata(struct udevice *dev)
 	else
 		host->dev_index = 1;
 
+	priv->fifo_depth = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+				    "fifo-depth", 0);
+	if (priv->fifo_depth < 0)
+		return -EINVAL;
+	priv->fifo_mode = fdtdec_get_bool(gd->fdt_blob, dev->of_offset,
+					  "fifo-mode");
+	if (fdtdec_get_int_array(gd->fdt_blob, dev->of_offset,
+				 "clock-freq-min-max", priv->minmax, 2))
+		return -EINVAL;
+
 	return 0;
 }
 
@@ -74,29 +87,18 @@ static int rockchip_dwmmc_probe(struct udevice *dev)
 	struct rockchip_dwmmc_priv *priv = dev_get_priv(dev);
 	struct dwmci_host *host = &priv->host;
 	struct udevice *pwr_dev __maybe_unused;
-	u32 minmax[2];
 	int ret;
-	int fifo_depth;
 
 	ret = clk_get_by_index(dev, 0, &priv->clk);
 	if (ret < 0)
 		return ret;
 	priv->periph = ret;
 
-	if (fdtdec_get_int_array(gd->fdt_blob, dev->of_offset,
-				 "clock-freq-min-max", minmax, 2))
-		return -EINVAL;
-
-	fifo_depth = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
-				    "fifo-depth", 0);
-	if (fifo_depth < 0)
-		return -EINVAL;
-
 	host->fifoth_val = MSIZE(0x2) |
-		RX_WMARK(fifo_depth / 2 - 1) | TX_WMARK(fifo_depth / 2);
+		RX_WMARK(priv->fifo_depth / 2 - 1) |
+		TX_WMARK(priv->fifo_depth / 2);
 
-	if (fdtdec_get_bool(gd->fdt_blob, dev->of_offset, "fifo-mode"))
-		host->fifo_mode = true;
+	host->fifo_mode = priv->fifo_mode;
 
 #ifdef CONFIG_PWRSEQ
 	/* Enable power if needed */
@@ -110,10 +112,10 @@ static int rockchip_dwmmc_probe(struct udevice *dev)
 #endif
 #ifdef CONFIG_BLK
 	dwmci_setup_cfg(&plat->cfg, dev->name, host->buswidth, host->caps,
-			minmax[1], minmax[0]);
+			priv->minmax[1], priv->minmax[0]);
 	host->mmc = &plat->mmc;
 #else
-	ret = add_dwmci(host, minmax[1], minmax[0]);
+	ret = add_dwmci(host, priv->minmax[1], priv->minmax[0]);
 	if (ret)
 		return ret;
 
-- 
2.8.0.rc3.226.g39d4020



More information about the U-Boot mailing list