Add Aspeed AST2700 uhci support
Subsystems (3)
cover Add Aspeed AST2700 uhci support
This patch series adds support for the UHCI controller found on the Aspeed AST2700 SoC.
Compared to earlier SoCs (AST2400/2500/2600), AST2700 UHCI:
- requires a reset line to be deasserted before use
- supports 64-bit DMA addressing
This series updates the bindings and platform driver accordingly.
Ryan Chen (4):
dt-bindings: usb: uhci: Add reset property
usb: uhci: Add reset control support
dt-bindings: usb: uhci: Add Aspeed AST2700 compatible
usb: uhci: Add Aspeed AST2700 support
.../devicetree/bindings/usb/usb-uhci.yaml | 4 +++ drivers/usb/host/uhci-hcd.h | 1 + drivers/usb/host/uhci-platform.c | 34 +++++++++++++++---- 3 files changed, 33 insertions(+), 6 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/4 dt-bindings: usb: uhci: Add reset property
The UHCI controller on Aspeed SoCs (including AST2700) requires its reset line to be deasserted before the controller can be used. Add an optional "resets" property to the UHCI device tree bindings to describe the phandle to the reset controller.
This property is optional for platforms which do not require explicit reset handling.
--- Documentation/devicetree/bindings/usb/usb-uhci.yaml | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/usb/usb-uhci.yaml +3 -0
@@ -28,6 +28,9 @@ properties: interrupts: maxItems: 1 + resets: + maxItems: 1 + '#ports': $ref: /schemas/types.yaml#/definitions/uint32
Signature · 1 line
2.34.1
Re: [PATCH 1/4] dt-bindings: usb: uhci: Add reset property
Quoted 4 lines · Ryan Chen
The UHCI controller on Aspeed SoCs (including AST2700) requires its reset line to be deasserted before the controller can be used. Add an optional "resets" property to the UHCI device tree bindings to describe the phandle to the reset controller.
Looks like the property is not optional at all for your aspeed devices, and you should require it for those compatibles.
Quoted 26 lines
This property is optional for platforms which do not require explicit reset handling.
Signed-off-by Ryan Chen <[email protected]>--- Documentation/devicetree/bindings/usb/usb-uhci.yaml | 3 +++ 1 file changed, 3 insertions(+)Documentation/devicetree/bindings/usb/usb-uhci.yaml +3
-0@@ -28,6 +28,9 @@ properties: interrupts: maxItems: 1 + resets: + maxItems: 1 + '#ports': $ref: /schemas/types.yaml#/definitions/uint32Signature · 1 line
2.34.1
RE: [PATCH 1/4] dt-bindings: usb: uhci: Add reset property
Quoted 14 lines
Subject: Re: [PATCH 1/4] dt-bindings: usb: uhci: Add reset property
Quoted 4 lines · Ryan Chen
The UHCI controller on Aspeed SoCs (including AST2700) requires its reset line to be deasserted before the controller can be used. Add an optional "resets" property to the UHCI device tree bindings to describe the phandle to the reset controller.
Looks like the property is not optional at all for your aspeed devices, and you should require it for those compatibles.
Quoted 3 lines
This property is optional for platforms which do not require explicit reset handling.
Thanks, resets is required for ast2700-uhci.
I will add in following.
- if:
properties:
compatible:
contains:
const: aspeed,ast2700-uhci
then:
required:
- resets
Quoted 24 lines
Quoted 24 lines
Signed-off-by Ryan Chen <[email protected]>--- Documentation/devicetree/bindings/usb/usb-uhci.yaml | 3 +++ 1 file changed, 3 insertions(+)Documentation/devicetree/bindings/usb/usb-uhci.yaml +3
-1@@ -28,6 +28,9 @@ properties: interrupts: maxItems: 1 + resets: + maxItems: 1 + '#ports': $ref: /schemas/types.yaml#/definitions/uint32 --2.34.1
PATCH 2/4 usb: uhci: Add reset control support
In reply to Ryan ChenSome SoCs, such as the Aspeed AST2700, require the UHCI controller to be taken out of reset before it can operate. Add optional reset control support to the UHCI platform driver.
The driver now acquires an optional reset line from device tree, deasserts it during probe, and asserts it again in the error path and shutdown.
--- drivers/usb/host/uhci-hcd.h | 1 + drivers/usb/host/uhci-platform.c | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-)
drivers/usb/host/uhci-hcd.h +1 -0
@@ -445,6 +445,7 @@ struct uhci_hcd {short load[MAX_PHASE ];/* Periodic allocations */ struct clk *clk;/* (optional) clock source */ +struct reset_control *rsts;/* (optional) clock reset */ /* Reset host controller */ void (*reset_hc) (struct uhci_hcd *uhci);
drivers/usb/host/uhci-platform.c +17 -2
@@ -11,6 +11,7 @@#include <linux/of.h> #include <linux/device.h> #include <linux/platform_device.h> +#include <linux/reset.h> static int uhci_platform_init (struct usb_hcd *hcd) {
@@ -132,19 +133,33 @@ static int uhci_hcd_platform_probe(struct platform_device *pdev) goto err_rmr; } + uhci->rsts =devm_reset_control_array_get_optional_shared (&pdev->dev); +if (IS_ERR (uhci->rsts)) { + ret =PTR_ERR (uhci->rsts); + goto err_clk; + } + ret =reset_control_deassert (uhci->rsts); +if (ret) + goto err_clk; + ret =platform_get_irq (pdev,0 );if (ret <0 ) - goto err_clk; + goto err_reset; ret =usb_add_hcd (hcd, ret,IRQF_SHARED );if (ret) - goto err_clk; + goto err_reset;device_wakeup_enable (hcd->self.controller);return 0 ; err_clk:clk_disable_unprepare (uhci->clk); + +err_reset: +if (!IS_ERR_OR_NULL (uhci->rsts)) +reset_control_assert (uhci->rsts); + err_rmr:usb_put_hcd (hcd);
Signature · 1 line
2.34.1
Alan Stern
maintainerRe: [PATCH 2/4] usb: uhci: Add reset control support
Quoted 60 lines · Ryan Chen
Some SoCs, such as the Aspeed AST2700, require the UHCI controller to be taken out of reset before it can operate. Add optional reset control support to the UHCI platform driver.
The driver now acquires an optional reset line from device tree, deasserts it during probe, and asserts it again in the error path and shutdown.
Signed-off-by Ryan Chen <[email protected]>--- drivers/usb/host/uhci-hcd.h | 1 + drivers/usb/host/uhci-platform.c | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-)drivers/usb/host/uhci-hcd.h +1
-0@@ -445,6 +445,7 @@ struct uhci_hcd {short load[MAX_PHASE ];/* Periodic allocations */ struct clk *clk;/* (optional) clock source */ +struct reset_control *rsts;/* (optional) clock reset */ /* Reset host controller */ void (*reset_hc) (struct uhci_hcd *uhci);drivers/usb/host/uhci-platform.c +12
-2@@ -11,6 +11,7 @@#include <linux/of.h> #include <linux/device.h> #include <linux/platform_device.h> +#include <linux/reset.h> static int uhci_platform_init (struct usb_hcd *hcd) {@@ -132,19 +133,33 @@ static int uhci_hcd_platform_probe(struct platform_device *pdev) goto err_rmr; } + uhci->rsts =devm_reset_control_array_get_optional_shared (&pdev->dev); +if (IS_ERR (uhci->rsts)) { + ret =PTR_ERR (uhci->rsts); + goto err_clk; + } + ret =reset_control_deassert (uhci->rsts); +if (ret) + goto err_clk; + ret =platform_get_irq (pdev,0 );if (ret <0 ) - goto err_clk; + goto err_reset; ret =usb_add_hcd (hcd, ret,IRQF_SHARED );if (ret) - goto err_clk; + goto err_reset;
drivers/usb/host/uhci-platform.c static int uhci_hcd_platform_probe(struct platform_device *pdev) · line 161
Quoted 10 lines
drivers/usb/host/uhci-platform.c +4
-0device_wakeup_enable (hcd->self.controller);return 0 ; err_clk:clk_disable_unprepare (uhci->clk); + +err_reset: +if (!IS_ERR_OR_NULL (uhci->rsts)) +reset_control_assert (uhci->rsts);
This error handler was added in the wrong place. It should come before err_clk, so that if an error occurs in platform_get_irq(), the clock will be unprepared and disabled.
Alan Stern
Quoted 6 lines
drivers/usb/host/uhci-platform.c +1
-0+ err_rmr:usb_put_hcd (hcd);Signature · 1 line
2.34.1
RE: [PATCH 2/4] usb: uhci: Add reset control support
Quoted 68 lines
Subject: Re: [PATCH 2/4] usb: uhci: Add reset control support
Quoted 32 lines · Ryan Chen
Some SoCs, such as the Aspeed AST2700, require the UHCI controller to be taken out of reset before it can operate. Add optional reset control support to the UHCI platform driver.
The driver now acquires an optional reset line from device tree, deasserts it during probe, and asserts it again in the error path and shutdown.
Signed-off-by Ryan Chen <[email protected]>--- drivers/usb/host/uhci-hcd.h | 1 + drivers/usb/host/uhci-platform.c | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-)drivers/usb/host/uhci-hcd.h +1
-0@@ -445,6 +445,7 @@ struct uhci_hcd {short load[MAX_PHASE ];/* Periodic allocations */ struct clk *clk;/* (optional) clock source */ +struct reset_control *rsts;/* (optional) clock reset */ /* Reset host controller */ void (*reset_hc) (struct uhci_hcd *uhci);drivers/usb/host/uhci-platform.c +0
-0drivers/usb/host/uhci-platform.c line 17
Quoted 7 lines
drivers/usb/host/uhci-platform.c +2
-0@@ -11,6 +11,7 @@#include <linux/of.h> #include <linux/device.h> #include <linux/platform_device.h> +#include <linux/reset.h> static int uhci_platform_init(struct usb_hcd *hcd) { @@ -132,19 +133,33 @@ static int uhci_hcd_platform_probe(struct platform_device*pdev)
Quoted 25 lines
drivers/usb/host/uhci-platform.c +11
-2goto err_rmr; } + uhci->rsts =devm_reset_control_array_get_optional_shared (&pdev->dev); +if (IS_ERR (uhci->rsts)) { + ret =PTR_ERR (uhci->rsts); + goto err_clk; + } + ret =reset_control_deassert (uhci->rsts); +if (ret) + goto err_clk; + ret =platform_get_irq (pdev,0 );if (ret <0 ) - goto err_clk; + goto err_reset; ret =usb_add_hcd (hcd, ret,IRQF_SHARED );if (ret) - goto err_clk; + goto err_reset;device_wakeup_enable (hcd->self.controller);return 0 ;
Quoted 10 lines
drivers/usb/host/uhci-platform.c static int uhci_hcd_platform_probe(struct platform_device *pdev) · line 161
Quoted 6 lines
err_clk:drivers/usb/host/uhci-platform.c +4
-0clk_disable_unprepare (uhci->clk); + +err_reset: +if (!IS_ERR_OR_NULL (uhci->rsts)) +reset_control_assert (uhci->rsts);This error handler was added in the wrong place. It should come before
err_clk, so that if an error occurs inplatform_get_irq(), the clock will be unprepared and disabled.
Thanks, will update in next version.
Quoted 9 lines
Alan Stern
Quoted 6 lines
drivers/usb/host/uhci-platform.c +1
-1+ err_rmr:usb_put_hcd (hcd); --2.34.1
PATCH 3/4 dt-bindings: usb: uhci: Add Aspeed AST2700 compatible
In reply to Ryan ChenAdd the compatible string for Aspeed AST2700 SoC.
--- Documentation/devicetree/bindings/usb/usb-uhci.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/usb/usb-uhci.yaml +1 -0
@@ -20,6 +20,7 @@ properties: - aspeed,ast2400-uhci - aspeed,ast2500-uhci - aspeed,ast2600-uhci + - aspeed,ast2700-uhci - const: generic-uhci reg:
Signature · 1 line
2.34.1
Re: [PATCH 3/4] dt-bindings: usb: uhci: Add Aspeed AST2700 compatible
RE: [PATCH 3/4] dt-bindings: usb: uhci: Add Aspeed AST2700 compatible
Quoted 2 lines
Subject: Re: [PATCH 3/4] dt-bindings: usb: uhci: Add Aspeed AST2700 compatible
Hello Conor,
I will add resets required in this patch at next send patch, is this ok for you?
https://lore.kernel.org/all/OS8PR06MB75419B97CDB5EA24560FB9ECF214A@OS8PR06MB7541.apcprd06.prod.outlook.com/
Quoted 2 lines
Acked-by Conor Dooley <[email protected]>
PATCH 4/4 usb: uhci: Add Aspeed AST2700 support
In reply to Ryan ChenUnlike earlier Aspeed SoCs (AST2400/2500/2600) which are limited to 32-bit DMA addressing, the UHCI controller in AST2700 supports 64-bit DMA. Update the platform UHCI driver to select the appropriate DMA mask based on the device tree compatible string.
--- drivers/usb/host/uhci-platform.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/usb/host/uhci-platform.c +11 -4
@@ -71,6 +71,7 @@ static int uhci_hcd_platform_probe(struct platform_device *pdev)struct usb_hcd *hcd;struct uhci_hcd *uhci;struct resource *res; +u64 *dma_mask_ptr;int ret;if (usb_disabled ())
@@ -81,7 +82,8 @@ static int uhci_hcd_platform_probe(struct platform_device *pdev)* Since shared usb code relies on it, set it here for now. * Once we have dma capability bindings this can go away. */ - ret =dma_coerce_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 )); + dma_mask_ptr = (u64 *)of_device_get_match_data (&pdev->dev); + ret =dma_coerce_mask_and_coherent (&pdev->dev, *dma_mask_ptr);if (ret)return ret;
@@ -114,7 +116,8 @@ static int uhci_hcd_platform_probe(struct platform_device *pdev) }if (of_device_is_compatible (np,"aspeed,ast2400-uhci" ) ||of_device_is_compatible (np,"aspeed,ast2500-uhci" ) || -of_device_is_compatible (np,"aspeed,ast2600-uhci" )) { +of_device_is_compatible (np,"aspeed,ast2600-uhci" ) || +of_device_is_compatible (np,"aspeed,ast2700-uhci" )) { uhci->is_aspeed =1 ;dev_info (&pdev->dev,"Enabled Aspeed implementation workarounds\n" );
@@ -190,9 +193,13 @@ static void uhci_hcd_platform_shutdown(struct platform_device *op)uhci_hc_died (hcd_to_uhci (hcd)); } +static const u64 dma_mask_32 =DMA_BIT_MASK (32 ); +static const u64 dma_mask_64 =DMA_BIT_MASK (64 ); +static const struct of_device_id platform_uhci_ids[] = { - { .compatible ="generic-uhci" , }, - { .compatible ="platform-uhci" , }, + { .compatible ="generic-uhci" , .data = &dma_mask_32}, + { .compatible ="platform-uhci" , .data = &dma_mask_32}, + { .compatible ="aspeed,ast2700-uhci" , .data = &dma_mask_64}, {} };MODULE_DEVICE_TABLE (of, platform_uhci_ids);
Signature · 1 line
2.34.1