usb: dwc3-am62: module removal and errata fixes
Subsystems (3)
v2 cover usb: dwc3-am62: module removal and errata fixes
Hi,
This series fixes errors during module removal. It also implements PHY core voltage selection as per TI recommendation and workaround for Errata i2409 [1].
The workaround needs PHY2 region to be present in device node. The device tree patch will be sent later after the DT binding doc is merged.
[1] - https://www.ti.com/lit/er/sprz487d/sprz487d.pdf
Changelog in each file
v1: https://lore.kernel.org/all/[email protected]/
cheers,
-roger
Roger Quadros (5):
usb: dwc3-am62: call of_platform_depopulate in .remove()
usb: dwc3-am62: fix error on module removal
usb: dwc3-am62: Fix PHY core voltage selection
dt-bindings: usb/ti,am62-usb.yaml: Add PHY2 register space
usb: dwc3-am62: add workaround for Errata i2409
.../devicetree/bindings/usb/ti,am62-usb.yaml | 8 +++- drivers/usb/dwc3/dwc3-am62.c | 47 ++++++++++++++----- 2 files changed, 41 insertions(+), 14 deletions(-)
base-commit: 6613476e225e090cc9aad49be7fa504e290dd33d
Signature · 1 line
2.34.1
PATCH v2 1/5 usb: dwc3-am62: call of_platform_depopulate in .remove()
We called of_platform_populate() in .probe() so call the cleanup function of_platform_depopulate() in .remove().
Get rid of the now unnnecessary dwc3_ti_remove_core().
---
Notes:
Changelog:
v2: no change
v1: https://lore.kernel.org/all/[email protected]/
drivers/usb/dwc3/dwc3-am62.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/usb/dwc3/dwc3-am62.c +1 -9
@@ -267,21 +267,13 @@ static int dwc3_ti_probe(struct platform_device *pdev)return ret; } -static int dwc3_ti_remove_core (struct device *dev,void *c) -{ -struct platform_device *pdev =to_platform_device (dev); - -platform_device_unregister (pdev); -return 0 ; -} -static void dwc3_ti_remove (struct platform_device *pdev) {struct device *dev = &pdev->dev;struct dwc3_am62 *am62 =platform_get_drvdata (pdev);u32 reg; -device_for_each_child (dev,NULL , dwc3_ti_remove_core); +of_platform_depopulate (dev);/* Clear mode valid bit */ reg =dwc3_ti_readl (am62,USBSS_MODE_CONTROL );
Signature · 1 line
2.34.1
PATCH v2 2/5 usb: dwc3-am62: fix error on module removal
In reply to Roger QuadrosAs runtime PM is enabled, the module can be runtime suspended when .remove() is called.
Do a pm_runtime_get_sync() to make sure module is active before doing any register operations.
Doing a pm_runtime_put_sync() should disable the refclk so no need to disable it again.
Fixes the below warning at module removel.
[ 39.705310] ------------[ cut here ]------------ [ 39.710004] clk:162:3 already disabled [ 39.713941] WARNING: CPU: 0 PID: 921 at drivers/clk/clk.c:1090 clk_core_disable+0xb0/0xb8
---
Notes:
Changelog:
v2: no change
v1: https://lore.kernel.org/all/[email protected]/
drivers/usb/dwc3/dwc3-am62.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-am62.c +5 -1
@@ -273,6 +273,11 @@ static void dwc3_ti_remove(struct platform_device *pdev)struct dwc3_am62 *am62 =platform_get_drvdata (pdev);u32 reg; +pm_runtime_get_sync (dev); + +device_wakeup_disable (dev); +device_set_wakeup_capable (dev, false); +of_platform_depopulate (dev);/* Clear mode valid bit */
@@ -281,7 +286,6 @@ static void dwc3_ti_remove(struct platform_device *pdev)dwc3_ti_writel (am62,USBSS_MODE_CONTROL , reg);pm_runtime_put_sync (dev); -clk_disable_unprepare (am62->usb2_refclk);pm_runtime_disable (dev);pm_runtime_set_suspended (dev); }
Signature · 1 line
2.34.1
PATCH v2 3/5 usb: dwc3-am62: Fix PHY core voltage selection
In reply to Roger QuadrosTRM information is outdated and design team has confirmed that PHY_CORE_VOLTAGE should be 0 irrespective of VDD_CORE voltage.
---
Notes:
Changelog:
v2: no change
v1: https://lore.kernel.org/all/[email protected]/
drivers/usb/dwc3/dwc3-am62.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-am62.c +9 -1
@@ -97,7 +97,8 @@#define USBSS_VBUS_STAT_SESSVALID BIT(2)#define USBSS_VBUS_STAT_VBUSVALID BIT(0) -/* Mask for PHY PLL REFCLK */ +/* USB_PHY_CTRL register bits in CTRL_MMR */ +#define PHY_CORE_VOLTAGE_MASK BIT(31)#define PHY_PLL_REFCLK_MASK GENMASK(3, 0)#define DWC3_AM62_AUTOSUSPEND_DELAY 100
@@ -162,6 +163,13 @@ static int phy_syscon_pll_refclk(struct dwc3_am62 *am62) am62->offset = args.args[0 ]; +/* Core voltage. PHY_CORE_VOLTAGE bit Recommended to be 0 always */ + ret =regmap_update_bits (am62->syscon, am62->offset,PHY_CORE_VOLTAGE_MASK ,0 ); +if (ret) { +dev_err (dev,"failed to set phy core voltage\n" ); +return ret; + } + ret =regmap_update_bits (am62->syscon, am62->offset,PHY_PLL_REFCLK_MASK , am62->rate_code);if (ret) {dev_err (dev,"failed to set phy pll reference clock rate\n" );
Signature · 1 line
2.34.1
PATCH v2 4/5 dt-bindings: usb/ti,am62-usb.yaml: Add PHY2 register space
In reply to Roger QuadrosAdd PHY2 register space to DT binding documentation.
We use minItems: 1 as DT update will come later and we don't want warnings for existing DTs.
So far this register space was not required but due to the newly identified Errata i2409 [1] we need to poke this register space.
[1] https://www.ti.com/lit/er/sprz487d/sprz487d.pdf
---
Notes:
Changelog:
v2: add minItems and update commit log
v1: was sent as part of different series
https://lore.kernel.org/all/[email protected]/
Documentation/devicetree/bindings/usb/ti,am62-usb.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/usb/ti,am62-usb.yaml +6 -2
@@ -14,7 +14,10 @@ properties: const: ti,am62-usb reg: - maxItems: 1 + minItems: 1 + items: + - description: USB CFG register space + - description: USB PHY2 register space ranges: true
@@ -82,7 +85,8 @@ examples: usbss1: usb@f910000 { compatible = "ti,am62-usb"; - reg = <0x00 0x0f910000 0x00 0x800>; + reg = <0x00 0x0f910000 0x00 0x800>, + <0x00 0x0f918000 0x00 0x400>; clocks = <&k3_clks 162 3>; clock-names = "ref"; ti,syscon-phy-pll-refclk = <&wkup_conf 0x4018>;
Signature · 1 line
2.34.1
Re: [PATCH v2 4/5] dt-bindings: usb/ti,am62-usb.yaml: Add PHY2 register space
Quoted 9 lines · Roger Quadros
Add PHY2 register space to DT binding documentation.
We use minItems: 1 as DT update will come later and we don't want warnings for existing DTs.
So far this register space was not required but due to the newly identified Errata i2409 [1] we need to poke this register space.
Quoted 6 lines
[1] https://www.ti.com/lit/er/sprz487d/sprz487d.pdf
Cc Rob Herring <[email protected]>Cc Krzysztof Kozlowski <[email protected]>Cc Conor Dooley <[email protected]>Signed-off-by Roger Quadros <[email protected]>
Not much improved. Still not tested. :(
Please use scripts/get_maintainers.pl to get a list of necessary people and lists to CC. It might happen, that command when run on an older kernel, gives you outdated entries. Therefore please be sure you base your patches on recent Linux kernel.
Tools like b4 or scripts/get_maintainer.pl provide you proper list of people, so fix your workflow. Tools might also fail if you work on some ancient tree (don't, instead use mainline), work on fork of kernel (don't, instead use mainline) or you ignore some maintainers (really don't). Just use b4 and everything should be fine, although remember about b4 prep --auto-to-cc if you added new patches to the patchset.
You missed at least devicetree list (maybe more), so this won't be tested by automated tooling. Performing review on untested code might be a waste of time, thus I will skip this patch entirely till you follow the process allowing the patch to be tested.
Please kindly resend and include all necessary To/Cc entries.
Best regards,
Krzysztof
PATCH v2 5/5 usb: dwc3-am62: add workaround for Errata i2409
In reply to Roger QuadrosAll AM62 devices have Errata i2409 [1] due to which USB2 PHY may lock up due to short suspend.
Workaround involves setting bit 5 and 4 PLL_REG12 in PHY2 register space after USB controller is brought out of LPSC reset but before controller initialization.
Handle this workaround.
[1] - https://www.ti.com/lit/er/sprz487d/sprz487d.pdf
---
Notes:
Changelog:
v2:
- don't add phy read/write helpers or add phy to private data
v1: https://lore.kernel.org/all/[email protected]/drivers/usb/dwc3/dwc3-am62.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-am62.c +20 -1
@@ -101,6 +101,11 @@#define PHY_CORE_VOLTAGE_MASK BIT(31)#define PHY_PLL_REFCLK_MASK GENMASK(3, 0) +/* USB PHY2 register offsets */ +#define USB_PHY_PLL_REG12 0x130 +#define USB_PHY_PLL_LDO_REF_EN BIT(5) +#define USB_PHY_PLL_LDO_REF_EN_EN BIT(4) +#define DWC3_AM62_AUTOSUSPEND_DELAY 100struct dwc3_am62 {
@@ -184,8 +189,9 @@ static int dwc3_ti_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct device_node *node = pdev->dev.of_node;struct dwc3_am62 *am62; -int i, ret;unsigned long rate; +void __iomem *phy; +int i, ret;u32 reg; am62 =devm_kzalloc (dev,sizeof (*am62),GFP_KERNEL );
@@ -201,6 +207,12 @@ static int dwc3_ti_probe(struct platform_device *pdev)return PTR_ERR (am62->usbss); } + phy =devm_platform_ioremap_resource (pdev,1 ); +if (IS_ERR (phy)) { +dev_err (dev,"can't map PHY IOMEM resource. Won't apply i2409 fix.\n" ); + phy =NULL ; + } + am62->usb2_refclk =devm_clk_get (dev,"ref" );if (IS_ERR (am62->usb2_refclk)) {dev_err (dev,"can't get usb2_refclk\n" );
@@ -227,6 +239,13 @@ static int dwc3_ti_probe(struct platform_device *pdev)if (ret)return ret; +/* Workaround Errata i2409 */ +if (phy) { + reg =readl (phy +USB_PHY_PLL_REG12 ); + reg |=USB_PHY_PLL_LDO_REF_EN |USB_PHY_PLL_LDO_REF_EN_EN ; +writel (reg, phy +USB_PHY_PLL_REG12 ); + } +/* VBUS divider select */ am62->vbus_divider =device_property_read_bool (dev,"ti,vbus-divider" ); reg =dwc3_ti_readl (am62,USBSS_PHY_CONFIG );
Signature · 1 line
2.34.1
Re: [PATCH v2 5/5] usb: dwc3-am62: add workaround for Errata i2409
Quoted 56 lines · Roger Quadros
All AM62 devices have Errata i2409 [1] due to which USB2 PHY may lock up due to short suspend.
Workaround involves setting bit 5 and 4
PLL_REG12in PHY2 register space after USB controller is brought out of LPSC reset but before controller initialization.Handle this workaround.
[1] - https://www.ti.com/lit/er/sprz487d/sprz487d.pdf
Cc Rob Herring <[email protected]>Cc Krzysztof Kozlowski <[email protected]>Cc Conor Dooley <[email protected]>Signed-off-by Roger Quadros <[email protected]>---
Notes:
Changelog: v2: - don't add phy read/write helpers or add phy to private data v1: https://lore.kernel.org/all/[email protected]/drivers/usb/dwc3/dwc3-am62.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)drivers/usb/dwc3/dwc3-am62.c +7
-1@@ -101,6 +101,11 @@#define PHY_CORE_VOLTAGE_MASK BIT(31)#define PHY_PLL_REFCLK_MASK GENMASK(3, 0) +/* USB PHY2 register offsets */ +#define USB_PHY_PLL_REG12 0x130 +#define USB_PHY_PLL_LDO_REF_EN BIT(5) +#define USB_PHY_PLL_LDO_REF_EN_EN BIT(4) +#define DWC3_AM62_AUTOSUSPEND_DELAY 100struct dwc3_am62 {@@ -184,8 +189,9 @@ static int dwc3_ti_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct device_node *node = pdev->dev.of_node;struct dwc3_am62 *am62; -int i, ret;unsigned long rate; +void __iomem *phy; +int i, ret;u32 reg; am62 =devm_kzalloc (dev,sizeof (*am62),GFP_KERNEL );
drivers/usb/dwc3/dwc3-am62.c static int dwc3_ti_probe(struct platform_device *pdev) · line 214
Quoted 8 lines
drivers/usb/dwc3/dwc3-am62.c +5
-0@@ -201,6 +207,12 @@ static int dwc3_ti_probe(struct platform_device *pdev)return PTR_ERR (am62->usbss); } + phy =devm_platform_ioremap_resource (pdev,1 ); +if (IS_ERR (phy)) { +dev_err (dev,"can't map PHY IOMEM resource. Won't apply i2409 fix.\n" ); + phy =NULL ; + }
Why not move this down to where you use it below, then just have it be an if/else with the work around in the if (!IS_ERR(phy)) and the warning in the else.
Andrew
Quoted 18 lines
drivers/usb/dwc3/dwc3-am62.c +8
-0+ am62->usb2_refclk =devm_clk_get (dev,"ref" );if (IS_ERR (am62->usb2_refclk)) {dev_err (dev,"can't get usb2_refclk\n" );@@ -227,6 +239,13 @@ static int dwc3_ti_probe(struct platform_device *pdev)if (ret)return ret; +/* Workaround Errata i2409 */ +if (phy) { + reg =readl (phy +USB_PHY_PLL_REG12 ); + reg |=USB_PHY_PLL_LDO_REF_EN |USB_PHY_PLL_LDO_REF_EN_EN ; +writel (reg, phy +USB_PHY_PLL_REG12 ); + } +/* VBUS divider select */ am62->vbus_divider =device_property_read_bool (dev,"ti,vbus-divider" ); reg =dwc3_ti_readl (am62,USBSS_PHY_CONFIG );
Re: [PATCH v2 5/5] usb: dwc3-am62: add workaround for Errata i2409
Quoted 55 lines · Andrew Davis
Quoted 54 lines · Roger Quadros
All AM62 devices have Errata i2409 [1] due to which USB2 PHY may lock up due to short suspend.
Workaround involves setting bit 5 and 4
PLL_REG12in PHY2 register space after USB controller is brought out of LPSC reset but before controller initialization.Handle this workaround.
[1] - https://www.ti.com/lit/er/sprz487d/sprz487d.pdf
Cc Rob Herring <[email protected]>Cc Krzysztof Kozlowski <[email protected]>Cc Conor Dooley <[email protected]>Signed-off-by Roger Quadros <[email protected]>---
Notes:
Changelog:
v2:
- don't add phy read/write helpers or add phy to private data
v1: https://lore.kernel.org/all/[email protected]/
drivers/usb/dwc3/dwc3-am62.c| 21 ++++++++++++++++++++-1 file changed, 20 insertions(+), 1 deletion(-)drivers/usb/dwc3/dwc3-am62.c +0
-0@@ -101,6 +101,11 @@ #define PHY_CORE_VOLTAGE_MASK BIT(31) #define PHY_PLL_REFCLK_MASK GENMASK(3, 0)+/* USB PHY2 register offsets */
drivers/usb/dwc3/dwc3-am62.c +4
-0+#define USB_PHY_PLL_REG12 0x130 +#define USB_PHY_PLL_LDO_REF_EN BIT(5) +#define USB_PHY_PLL_LDO_REF_EN_EN BIT(4) +#define DWC3_AM62_AUTOSUSPEND_DELAY 100
structdwc3_am62{drivers/usb/dwc3/dwc3-am62.c +2
-1@@ -184,8 +189,9 @@ static int dwc3_ti_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct device_node *node = pdev->dev.of_node; struct dwc3_am62 *am62; - int i, ret; unsigned long rate; + void __iomem *phy; + int i, ret; u32 reg; am62 = devm_kzalloc(dev, sizeof(*am62), GFP_KERNEL);@@ -201,6 +207,12 @@ static int dwc3_ti_probe(struct platform_device *pdev) return PTR_ERR(am62->usbss); } + phy = devm_platform_ioremap_resource(pdev, 1);
Quoted 8 lines
drivers/usb/dwc3/dwc3-am62.c static int dwc3_ti_probe(struct platform_device *pdev) · line 214
Quoted 4 lines
drivers/usb/dwc3/dwc3-am62.c +4
-0+ if (IS_ERR(phy)) { + dev_err(dev, "can't map PHY IOMEM resource. Won't apply i2409 fix.\n"); + phy = NULL; + }Why not move this down to where you use it below, then just have it be an if/else with the work around in the if (!IS_ERR(phy)) and the warning in the else.
Seems reasonable. Will fix.
Quoted 20 lines
Andrew
Quoted 17 lines
drivers/usb/dwc3/dwc3-am62.c +1
-0+ am62->usb2_refclk = devm_clk_get(dev, "ref"); if (IS_ERR(am62->usb2_refclk)) { dev_err(dev, "can't get usb2_refclk\n");@@ -227,6 +239,13 @@ static int dwc3_ti_probe(struct platform_device *pdev) if (ret) return ret;+ /* Workaround Errata i2409 */
+ if (phy) {
+ reg =readl(phy + USB_PHY_PLL_REG12);
+ reg |=USB_PHY_PLL_LDO_REF_EN|USB_PHY_PLL_LDO_REF_EN_EN; +writel(reg, phy + USB_PHY_PLL_REG12);
+ }
+
/* VBUS divider select */
am62->vbus_divider=device_property_read_bool(dev, "ti,vbus-divider"); reg =dwc3_ti_readl(am62, USBSS_PHY_CONFIG);
Signature · 2 lines
cheers, -roger
Re: [PATCH v2 5/5] usb: dwc3-am62: add workaround for Errata i2409
In reply to Roger QuadrosQuoted 2 lines · Roger Quadros
All AM62 devices have Errata i2409 [1] due to which USB2 PHY may lock up due to short suspend.
Is there any visible log trace when we have this phy lock up situation? Eventually it would be nice to have this in the commit message.
Francesco
Re: [PATCH v2 5/5] usb: dwc3-am62: add workaround for Errata i2409
Quoted 7 lines · Francesco Dolcini
Quoted 2 lines · Roger Quadros
All AM62 devices have Errata i2409 [1] due to which USB2 PHY may lock up due to short suspend.
Is there any visible log trace when we have this phy lock up situation? Eventually it would be nice to have this in the commit message.
I have not been able to reproduce this issue here so no log trace.
Signature · 2 lines
cheers, -roger