Skip to contentSkip to conversation

Migrate AM35xx MUSB glue to device tree and enable MUSB

RFC New Adam Ford 2 participants 8 messages Jun 25, 2018 – Jul 3, 2018

Subsystems (6)
lore
Share & tools
lore

Adam Ford

author
#0 lore raw

cover Migrate AM35xx MUSB glue to device tree and enable MUSB

Currently, the AM3517.dtsi uses the omap2430 glue to connect the MUSB controller when it should use the AM35x glue. This series attempts to convert the AM35x glue to device tree, fix the clock references to the AM35X can enable/disable them correctly, and then use pdata-quirks.c to enable the register that isn't yet available using device tree to enable MSUB, then finally modifies the AM3517 and AM3517-EVM to use the updated AM35x glue to support MUSB.

It currently doesnt' work, but I am looking for ideas on what I may have missed or done incorrectly.

Adam Ford (5):
usb: musb: am35x: Add device tree support
usb: musb: am35x: Match clock assignements to hwmods
ARM: OMAP2+: Add AM3517 MUSB setup to pdata quirks.
ARM: dts: AM35x: Change MUSB from omap2430 to am35xx
ARM: dts: am3517-evm: Enable MUSB on AM3517-evm

 arch/arm/boot/dts/am3517-evm.dts   | 12 ++++++++++++
 arch/arm/boot/dts/am3517.dtsi      |  2 +-
 arch/arm/mach-omap2/pdata-quirks.c | 19 +++++++++++++++++++
 drivers/usb/musb/am35x.c           | 15 +++++++++++++--
 4 files changed, 45 insertions(+), 3 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

RFC 1/5 usb: musb: am35x: Add device tree support

The AM35x glue doesn't yet support device tree, so this patch adds the basics hooks so it doesn't haven't use pdata-quirks.c

drivers/usb/musb/am35x.c +11 -0
index 660641ab1545..a55db15a8457 100644
@@ -591,6 +591,16 @@ static int am35x_resume(struct device *dev)
 }
 #endif
 
+#ifdef CONFIG_OF
+static const struct of_device_id am35xx_id_table[] = {
+	{
+		.compatible = "ti,am35xx-musb"
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(of, am35xx_id_table);
+#endif
+
 static SIMPLE_DEV_PM_OPS(am35x_pm_ops, am35x_suspend, am35x_resume);
 
 static struct platform_driver am35x_driver = {
@@ -599,6 +609,7 @@ static struct platform_driver am35x_driver = {
 	.driver		= {
 		.name	= "musb-am35x",
 		.pm	= &am35x_pm_ops,
+		.of_match_table = of_match_ptr(am35xx_id_table),
 	},
 };
 
Signature · 1 line
2.17.1
author
#2 lore raw

RFC 2/5 usb: musb: am35x: Match clock assignements to hwmods

In reply to Adam Ford

There are two clocks that fail when attempting to use them. This patch patches the clock names to match those in hwmods.

drivers/usb/musb/am35x.c +2 -2
index a55db15a8457..56f8e13f4c1b 100644
@@ -455,14 +455,14 @@ static int am35x_probe(struct platform_device *pdev)
 	if (!glue)
 		goto err0;
 
-	phy_clk = clk_get(&pdev->dev, "fck");
+	phy_clk = clk_get(&pdev->dev, "hsotgusb_fck");
 	if (IS_ERR(phy_clk)) {
 		dev_err(&pdev->dev, "failed to get PHY clock\n");
 		ret = PTR_ERR(phy_clk);
 		goto err3;
 	}
 
-	clk = clk_get(&pdev->dev, "ick");
+	clk = clk_get(&pdev->dev, "hsotgusb_ick");
 	if (IS_ERR(clk)) {
 		dev_err(&pdev->dev, "failed to get clock\n");
 		ret = PTR_ERR(clk);
Signature · 1 line
2.17.1
author
#3 lore raw

RFC 3/5 ARM: OMAP2+: Add AM3517 MUSB setup to pdata quirks.

In reply to Adam Ford

The pin muxing and clock definitions for the MUSB controller are not done through the same registers/pin mux options, so this explicitly configures the registers and pin-mux options for MUSB on AM3517-EVM

arch/arm/mach-omap2/pdata-quirks.c +19 -0
index 7f02743edbe4..e0c7ac2c87c1 100644
@@ -258,9 +258,28 @@ static void __init omap3_sbc_t3517_legacy_init(void)
 	omap3_sbc_t3517_wifi_init();
 }
 
+/* The pin muxing for AM3517 OTG isn't done through the normal means */
+static __init void am3517_evm_musb_init(void)
+{
+	u32 devconf2;
+
+	/*
+	 * Set up USB clock/mode in the DEVCONF2 register.
+	 */
+	devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2);
+
+	/* USB2.0 PHY reference clock is 13 MHz */
+	devconf2 &= ~(CONF2_REFFREQ | CONF2_OTGMODE | CONF2_PHY_GPIOMODE);
+	devconf2 |=  CONF2_REFFREQ_13MHZ | CONF2_SESENDEN | CONF2_VBDTCTEN
+			| CONF2_DATPOL;
+
+	omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2);
+}
+
 static void __init am3517_evm_legacy_init(void)
 {
 	am35xx_emac_reset();
+	am3517_evm_musb_init();
 }
 
 static struct platform_device omap3_rom_rng_device = {
Signature · 1 line
2.17.1
maintainer
#4 lore raw

RFC 3/5 ARM: OMAP2+: Add AM3517 MUSB setup to pdata quirks.

Quoted 28 lines · Adam Ford

The pin muxing and clock definitions for the MUSB controller are not done through the same registers/pin mux options, so this explicitly configures the registers and pin-mux options for MUSB on AM3517-EVM

arch/arm/mach-omap2/pdata-quirks.c +13 -0
index 7f02743edbe4..e0c7ac2c87c1 100644
@@ -258,9 +258,28 @@ static void __init omap3_sbc_t3517_legacy_init(void)
 	omap3_sbc_t3517_wifi_init();
 }
 
+/* The pin muxing for AM3517 OTG isn't done through the normal means */
+static __init void am3517_evm_musb_init(void)
+{
+	u32 devconf2;
+
+	/*
+	 * Set up USB clock/mode in the DEVCONF2 register.
+	 */
+	devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2);
+
+	/* USB2.0 PHY reference clock is 13 MHz */
+	devconf2 &= ~(CONF2_REFFREQ | CONF2_OTGMODE | CONF2_PHY_GPIOMODE);
+	devconf2 |=  CONF2_REFFREQ_13MHZ | CONF2_SESENDEN | CONF2_VBDTCTEN

arch/arm/mach-omap2/pdata-quirks.c static void __init omap3_sbc_t3517_legacy_init(void) · line 283

Quoted 10 lines
arch/arm/mach-omap2/pdata-quirks.c +6 -0
+			| CONF2_DATPOL;
+
+	omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2);
+}
+
 static void __init am3517_evm_legacy_init(void)
 {
 	am35xx_emac_reset();
+	am3517_evm_musb_init();
 }

To me it seems you should do this with a simple drivers/phy driver. There might be already something similar that you can use, see the da and dm related drivers under drivers/phy/ti.

Regards,

Tony

author
#5 lore raw

RFC 4/5 ARM: dts: AM35x: Change MUSB from omap2430 to am35xx

In reply to Adam Ford

The glue that connects the AM35xx is not the same as the OMAP3. With the AM35xx-MUSB now available in device tree, point to that glue instead of omap3.

arch/arm/boot/dts/am3517.dtsi +1 -1
index ca294914bbb1..c17cfe6a2132 100644
@@ -18,7 +18,7 @@
 
 	ocp at 68000000 {
 		am35x_otg_hs: am35x_otg_hs at 5c040000 {
-			compatible = "ti,omap3-musb";
+			compatible = "ti,am35xx-musb";
 			ti,hwmods = "am35x_otg_hs";
 			status = "disabled";
 			reg = <0x5c040000 0x1000>;
Signature · 1 line
2.17.1
author
#6 lore raw

RFC 5/5 ARM: dts: am3517-evm: Enable MUSB on AM3517-evm

In reply to Adam Ford

With AM35x now supported in device tree and the pdata-quirks configuring the AM3517 clocks and some of the pin-mux, this patch enables the MUSB and configures the rest of the pin- mux options

arch/arm/boot/dts/am3517-evm.dts +12 -0
index 56fdec33afc1..4aeadaca915f 100644
@@ -243,6 +243,12 @@
 	phys = <&hsusb1_phy>;
 };
 
+&am35x_otg_hs {
+        status = "okay";
+        pinctrl-names = "default";
+        pinctrl-0 = <&otg_drv_vbus>;
+};
+
 &omap3_pmx_core {
 	pinctrl-names = "default";
 	pinctrl-0 = <&hsusb1_rst_pins>;
@@ -273,6 +279,12 @@
 		>;
 	};
 
+	otg_drv_vbus: pinmux_otg_drv_vbus {
+		pinctrl-single,pins = <
+			OMAP3_CORE1_IOPAD(0x2210, PIN_INPUT_PULLDOWN | MUX_MODE0) /* rmii_50MHz_clk.usb0_drvvbus */
+		>;
+	};
+
 	backlight_pins: pinmux_backlight_pins {
 		pinctrl-single,pins = <
 			OMAP3_CORE1_IOPAD(0x21de, PIN_OUTPUT | MUX_MODE4)       /* mcspi2_cs1.gpio_182 */
Signature · 1 line
2.17.1
maintainer
#7 lore raw

cover Migrate AM35xx MUSB glue to device tree and enable MUSB

In reply to Adam Ford
Quoted 3 lines · Adam Ford

It currently doesnt' work, but I am looking for ideas on what I may have missed or done incorrectly.

Check the drivers/phy/ti driver part and make sure that works and has pins and clocks configured.

The rest should be pretty much generic stuff for musb as long as the SoC glue layer can deal with the module, clocks and pins.

Regards,

Tony