Skip to contentSkip to conversation

mmc: mxcmmc: completion of MPC512x support

PATCH In review Gerhard Sittig 2 participants 3 messages May 14, 2013 – May 15, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover mmc: mxcmmc: completion of MPC512x support

the mxcmmc(4) driver is shared across the i.MX and the MPC512x platforms

the driver's initialization did setup the i.MX related clocks but did not setup the MPC512x related clock, this change fixes the omission and thus makes SDHC/MMC fully operational on both platforms

Gerhard Sittig (1):
mmc: mxcmmc: setup mpc512x related clocks

 drivers/mmc/host/mxcmmc.c |   41 +++++++++++++++++++++++++++--------------
 1 file changed, 27 insertions(+), 14 deletions(-)
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/1 mmc: mxcmmc: setup mpc512x related clocks

the mxcmmc(4) driver is shared across the i.MX and MPC512x platforms, setup the 'sdhc_clk' instead of 'ipg' and 'per' in the mpc512x case

this change re-uses the i.MX 'per' clock related variable for everything SDHC/MMC related, and makes the 'ipg' clock related variable access conditional -- this approach is less intrusive than adding an #ifdef and two sets of variables everywhere

viewing the change with 'git diff -w' better reflects its nature

---
 drivers/mmc/host/mxcmmc.c |   41 +++++++++++++++++++++++++++--------------
 1 file changed, 27 insertions(+), 14 deletions(-)
drivers/mmc/host/mxcmmc.c +27 -14
index d503635..b9d21cc 100644
@@ -1121,20 +1121,29 @@ static int mxcmci_probe(struct platform_device *pdev)
 	host->res = r;
 	host->irq = irq;
 
-	host->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
-	if (IS_ERR(host->clk_ipg)) {
-		ret = PTR_ERR(host->clk_ipg);
-		goto out_iounmap;
-	}
+	if (!is_mpc512x_mmc(host)) {
+		host->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
+		if (IS_ERR(host->clk_ipg)) {
+			ret = PTR_ERR(host->clk_ipg);
+			goto out_iounmap;
+		}
 
-	host->clk_per = devm_clk_get(&pdev->dev, "per");
-	if (IS_ERR(host->clk_per)) {
-		ret = PTR_ERR(host->clk_per);
-		goto out_iounmap;
+		host->clk_per = devm_clk_get(&pdev->dev, "per");
+		if (IS_ERR(host->clk_per)) {
+			ret = PTR_ERR(host->clk_per);
+			goto out_iounmap;
+		}
+	} else {
+		host->clk_per = devm_clk_get(&pdev->dev, "sdhc_clk");
+		if (IS_ERR(host->clk_per)) {
+			ret = PTR_ERR(host->clk_per);
+			goto out_iounmap;
+		}
 	}
 
 	clk_prepare_enable(host->clk_per);
-	clk_prepare_enable(host->clk_ipg);
+	if (host->clk_ipg)
+		clk_prepare_enable(host->clk_ipg);
 
 	mxcmci_softreset(host);
 
@@ -1204,7 +1213,8 @@ out_free_dma:
 		dma_release_channel(host->dma);
 out_clk_put:
 	clk_disable_unprepare(host->clk_per);
-	clk_disable_unprepare(host->clk_ipg);
+	if (host->clk_ipg)
+		clk_disable_unprepare(host->clk_ipg);
 out_iounmap:
 	iounmap(host->base);
 out_free:
@@ -1236,7 +1246,8 @@ static int mxcmci_remove(struct platform_device *pdev)
 		dma_release_channel(host->dma);
 
 	clk_disable_unprepare(host->clk_per);
-	clk_disable_unprepare(host->clk_ipg);
+	if (host->clk_ipg)
+		clk_disable_unprepare(host->clk_ipg);
 
 	release_mem_region(host->res->start, resource_size(host->res));
 
@@ -1255,7 +1266,8 @@ static int mxcmci_suspend(struct device *dev)
 	if (mmc)
 		ret = mmc_suspend_host(mmc);
 	clk_disable_unprepare(host->clk_per);
-	clk_disable_unprepare(host->clk_ipg);
+	if (host->clk_ipg)
+		clk_disable_unprepare(host->clk_ipg);
 
 	return ret;
 }
@@ -1267,7 +1279,8 @@ static int mxcmci_resume(struct device *dev)
 	int ret = 0;
 
 	clk_prepare_enable(host->clk_per);
-	clk_prepare_enable(host->clk_ipg);
+	if (host->clk_ipg)
+		clk_prepare_enable(host->clk_ipg);
 	if (mmc)
 		ret = mmc_resume_host(mmc);
 
Signature · 1 line
1.7.10.4
maintainer
#2 lore raw

Re: [PATCH v1 1/1] mmc: mxcmmc: setup mpc512x related clocks

Quoted 41 lines · Gerhard Sittig

the mxcmmc(4) driver is shared across the i.MX and MPC512x platforms, setup the 'sdhc_clk' instead of 'ipg' and 'per' in the mpc512x case

this change re-uses the i.MX 'per' clock related variable for everything SDHC/MMC related, and makes the 'ipg' clock related variable access conditional -- this approach is less intrusive than adding an #ifdef and two sets of variables everywhere

viewing the change with 'git diff -w' better reflects its nature

---
 drivers/mmc/host/mxcmmc.c |   41 +++++++++++++++++++++++++++--------------
 1 file changed, 27 insertions(+), 14 deletions(-)
drivers/mmc/host/mxcmmc.c +8 -9
index d503635..b9d21cc 100644
@@ -1121,20 +1121,29 @@ static int mxcmci_probe(struct platform_device *pdev)
 	host->res = r;
 	host->irq = irq;
 
-	host->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
-	if (IS_ERR(host->clk_ipg)) {
-		ret = PTR_ERR(host->clk_ipg);
-		goto out_iounmap;
-	}
+	if (!is_mpc512x_mmc(host)) {
+		host->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
+		if (IS_ERR(host->clk_ipg)) {
+			ret = PTR_ERR(host->clk_ipg);
+			goto out_iounmap;
+		}
 
-	host->clk_per = devm_clk_get(&pdev->dev, "per");
-	if (IS_ERR(host->clk_per)) {
-		ret = PTR_ERR(host->clk_per);
-		goto out_iounmap;
+		host->clk_per = devm_clk_get(&pdev->dev, "per");
+		if (IS_ERR(host->clk_per)) {

drivers/mmc/host/mxcmmc.c static int mxcmci_probe(struct platform_device *pdev) · line 1142

Quoted 10 lines
drivers/mmc/host/mxcmmc.c +9 -0
+			ret = PTR_ERR(host->clk_per);
+			goto out_iounmap;
+		}
+	} else {
+		host->clk_per = devm_clk_get(&pdev->dev, "sdhc_clk");
+		if (IS_ERR(host->clk_per)) {
+			ret = PTR_ERR(host->clk_per);
+			goto out_iounmap;
+		}
 	}

No! The clocks we need are SDHC core specific, not powerPC/ARM specific.

The clocks are modelled after the input clocks of the device, *not* after what the SoC offers control over.

See "Figure 34-22. Clock Used in SDHC" in the MPC5121 Programming guide. This shows that the SDHC core has a SDHC_CLK, IPG_CLK and IPG_CLK_S. These are the 3 clocks the SDHC core needs and the driver has to request them. If you do not have software control over all clocks, you still have to provide dummy clocks.

That said, this is currently hard to implement as the clock support for the MPC5121 is utterly broken. The MPC5121 clk_get implementation currently ignores the device argument and relies only on the "sdhc_clk" string.

Fix your platform code, then you don't have to mess with the driver.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |