Skip to contentSkip to conversation

usb: chipidea: usbmisc: skip clocks on i.MX6

PATCH New Philipp Zabel 3 participants 5 messages Dec 9, 2014 – Dec 10, 2014

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

PATCH 1/2 usb: chipidea: usbmisc: skip clocks on i.MX6

On i.MX6Q, the USBMISC registers are clocked by the IPG clock, so there is no need to enable USBOH3 for the USBMISC driver.

---
 drivers/usb/chipidea/usbmisc_imx.c | 32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)
drivers/usb/chipidea/usbmisc_imx.c +18 -14
index 926c997..f7b878d 100644
@@ -338,23 +338,27 @@ static int usbmisc_imx_probe(struct platform_device *pdev)
 	if (IS_ERR(data->base))
 		return PTR_ERR(data->base);
 
-	data->clk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(data->clk)) {
-		dev_err(&pdev->dev,
-			"failed to get clock, err=%ld\n", PTR_ERR(data->clk));
-		return PTR_ERR(data->clk);
-	}
-
-	ret = clk_prepare_enable(data->clk);
-	if (ret) {
-		dev_err(&pdev->dev,
-			"clk_prepare_enable failed, err=%d\n", ret);
-		return ret;
-	}
-
 	tmp_dev = (struct of_device_id *)
 		of_match_device(usbmisc_imx_dt_ids, &pdev->dev);
 	data->ops = (const struct usbmisc_ops *)tmp_dev->data;
+
+	/* on i.MX6Q, the USBMISC register space is clocked by the IPG clock */
+	if (data->ops != &imx6q_usbmisc_ops) {
+		data->clk = devm_clk_get(&pdev->dev, NULL);
+		if (IS_ERR(data->clk)) {
+			dev_err(&pdev->dev, "failed to get clock, err=%ld\n",
+				PTR_ERR(data->clk));
+			return PTR_ERR(data->clk);
+		}
+
+		ret = clk_prepare_enable(data->clk);
+		if (ret) {
+			dev_err(&pdev->dev,
+				"clk_prepare_enable failed, err=%d\n", ret);
+			return ret;
+		}
+	}
+
 	platform_set_drvdata(pdev, data);
 
 	return 0;
Signature · 1 line
2.1.3
#1 lore raw

PATCH 2/2 ARM: dts: imx6qdl: remove USBOH3 clock from usbmisc, it is clocked by IPG

On i.MX6Q, the USBMISC registers are clocked by the IPG clock, so there is no need to enable USBOH3 for the USBMISC driver.

---
 arch/arm/boot/dts/imx6qdl.dtsi | 1 -
 1 file changed, 1 deletion(-)
arch/arm/boot/dts/imx6qdl.dtsi +0 -1
index 28e6878..ff3edb0 100644
@@ -896,7 +896,6 @@
 				#index-cells = <1>;
 				compatible = "fsl,imx6q-usbmisc";
 				reg = <0x02184800 0x200>;
-				clocks = <&clks IMX6QDL_CLK_USBOH3>;
 			};
 
 			fec: ethernet at 02188000 {
Signature · 1 line
2.1.3
#2 lore raw

PATCH 1/2 usb: chipidea: usbmisc: skip clocks on i.MX6

In reply to Philipp Zabel
Quoted 3 lines · Philipp Zabel

On i.MX6Q, the USBMISC registers are clocked by the IPG clock, so there is no need to enable USBOH3 for the USBMISC driver.

Access the registers at usbmisc needs the same clock with chipidea core, both are usboh3.

For i.mx6 series, there is only one usb clock gate at ccm which is usboh3, it is used to access register. For transfer data, it needs usb phy's (using mxs phy) clock is enabled.

Quoted 54 lines
---
 drivers/usb/chipidea/usbmisc_imx.c | 32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)
drivers/usb/chipidea/usbmisc_imx.c +18 -14
index 926c997..f7b878d 100644
@@ -338,23 +338,27 @@ static int usbmisc_imx_probe(struct platform_device *pdev)
 	if (IS_ERR(data->base))
 		return PTR_ERR(data->base);
 
-	data->clk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(data->clk)) {
-		dev_err(&pdev->dev,
-			"failed to get clock, err=%ld\n", PTR_ERR(data->clk));
-		return PTR_ERR(data->clk);
-	}
-
-	ret = clk_prepare_enable(data->clk);
-	if (ret) {
-		dev_err(&pdev->dev,
-			"clk_prepare_enable failed, err=%d\n", ret);
-		return ret;
-	}
-
 	tmp_dev = (struct of_device_id *)
 		of_match_device(usbmisc_imx_dt_ids, &pdev->dev);
 	data->ops = (const struct usbmisc_ops *)tmp_dev->data;
+
+	/* on i.MX6Q, the USBMISC register space is clocked by the IPG clock */
+	if (data->ops != &imx6q_usbmisc_ops) {
+		data->clk = devm_clk_get(&pdev->dev, NULL);
+		if (IS_ERR(data->clk)) {
+			dev_err(&pdev->dev, "failed to get clock, err=%ld\n",
+				PTR_ERR(data->clk));
+			return PTR_ERR(data->clk);
+		}
+
+		ret = clk_prepare_enable(data->clk);
+		if (ret) {
+			dev_err(&pdev->dev,
+				"clk_prepare_enable failed, err=%d\n", ret);
+			return ret;
+		}
+	}
+
 	platform_set_drvdata(pdev, data);
 
 	return 0;
Signature · 1 line
2.1.3
Signature · 2 lines
Best Regards,
Peter Chen
#3 lore raw

PATCH 1/2 usb: chipidea: usbmisc: skip clocks on i.MX6

Hi Peter,

Am Mittwoch, den 10.12.2014, 13:09 +0800 schrieb Peter Chen:

Quoted 6 lines · Philipp Zabel
Quoted 2 lines

On i.MX6Q, the USBMISC registers are clocked by the IPG clock, so there is no need to enable USBOH3 for the USBMISC driver.

Access the registers at usbmisc needs the same clock with chipidea core, both are usboh3.

Alright, I'll drop this patch.

It was my understanding that the usbmisc register space is clocked by ipg_clk_s, which is not gated by usboh3_clk_enable:
Having a look at the "i.MX 6Dual/6Quad Applications Processor Reference Manual, Rev. 1, 04/2013", Figure 65-1 "USB block diagram" shows the USB Control Register (usbmisc) directly connected via "IP Bus1" separately from the host cores (these are connected behind a PL301).
In chapter 18.4 "System Clocks", the table entry for the block instance "USB" shows that the usboh3_clk_enable bit gates only the ipg_ahb_clk, ipg_clk_s_pl301, test_clk_240m, test_clk_480m, and test_clk_60m inputs to the USB block. The ipg_clk_s (from ipg_clk_root) and ipg_clk_32khz inputs are not marked as gated. Still, it seems that indeed the usbmisc region is inaccessible after gating usboh3 by unbinding the usb drivers.

regards
Philipp

#4 lore raw

PATCH 1/2 usb: chipidea: usbmisc: skip clocks on i.MX6

In reply to Philipp Zabel

Hello Philipp,

drivers/usb/chipidea/usbmisc_imx.c static int usbmisc_imx_probe(struct platform_device *pdev) · line 347

Quoted 3 lines · Philipp Zabel
drivers/usb/chipidea/usbmisc_imx.c +3 -0
+	/* on i.MX6Q, the USBMISC register space is clocked by the IPG clock */
+	if (data->ops != &imx6q_usbmisc_ops) {
+		data->clk = devm_clk_get(&pdev->dev, NULL);

I wonder if it was better/simpler to handle devm_clk_get returning -ENOENT and assume this means there is no need for a clock in this case.

(I think devm_clk_get prints an error message in this case. That's ugly when the error is handled just fine.)

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |