Add Aspeed AST2700 ehci support
Subsystems (3)
v2 cover Add Aspeed AST2700 ehci support
This series adds support for the EHCI controller found in Aspeed's new AST2700 SoC.
v2:-ehci-platform.c
- remove ehci_ast2700_platform replace by of_device_id data for dma_mask_64.
Ryan Chen (2):
dt-bindings: usb: ehci: Add Aspeed AST2700 compatible
usb: ehci: Add Aspeed AST2700 support
.../devicetree/bindings/usb/generic-ehci.yaml | 1 + drivers/usb/host/ehci-platform.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-)
Signature · 1 line
2.34.1
PATCH v2 1/2 dt-bindings: usb: ehci: Add Aspeed AST2700 compatible
Add the compatible string for Aspeed AST2700 SoC.
--- Documentation/devicetree/bindings/usb/generic-ehci.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/usb/generic-ehci.yaml +1 -0
@@ -46,6 +46,7 @@ properties: - aspeed,ast2400-ehci - aspeed,ast2500-ehci - aspeed,ast2600-ehci + - aspeed,ast2700-ehci - brcm,bcm3384-ehci - brcm,bcm63268-ehci - brcm,bcm6328-ehci
Signature · 1 line
2.34.1
PATCH v2 2/2 usb: ehci: Add Aspeed AST2700 support
In reply to Ryan ChenUnlike earlier Aspeed SoCs (AST2400/2500/2600) which are limited to 32-bit DMA addressing, the EHCI controller in AST2700 supports 64-bit DMA. Update the EHCI platform driver to make use of this capability by selecting a 64-bit DMA mask when the "aspeed,ast2700-ehci" compatible is present in device tree.
--- drivers/usb/host/ehci-platform.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/usb/host/ehci-platform.c +10 -1
@@ -27,6 +27,7 @@#include <linux/io.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/of_device.h> #include <linux/platform_device.h> #include <linux/reset.h> #include <linux/sys_soc.h>
@@ -239,6 +240,7 @@ static int ehci_platform_probe(struct platform_device *dev)struct usb_hcd *hcd;struct resource *res_mem;struct usb_ehci_pdata *pdata =dev_get_platdata (&dev->dev); +const struct of_device_id *match;struct ehci_platform_priv *priv;struct ehci_hcd *ehci;int err, irq, clk =0 ;
@@ -253,6 +255,10 @@ static int ehci_platform_probe(struct platform_device *dev)if (!pdata) pdata = &ehci_platform_defaults; + match =of_match_device (dev->dev.driver->of_match_table, &dev->dev); +if (match && match->data) + pdata->dma_mask_64 =1 ; + err =dma_coerce_mask_and_coherent (&dev->dev, pdata->dma_mask_64 ?DMA_BIT_MASK (64 ) :DMA_BIT_MASK (32 ));if (err) {
@@ -298,7 +304,9 @@ static int ehci_platform_probe(struct platform_device *dev)if (of_device_is_compatible (dev->dev.of_node,"aspeed,ast2500-ehci" ) ||of_device_is_compatible (dev->dev.of_node, -"aspeed,ast2600-ehci" )) +"aspeed,ast2600-ehci" ) || +of_device_is_compatible (dev->dev.of_node, +"aspeed,ast2700-ehci" )) ehci->is_aspeed =1 ;if (soc_device_match (quirk_poll_match))
@@ -485,6 +493,7 @@ static const struct of_device_id vt8500_ehci_ids[] = { { .compatible = "wm,prizm-ehci", }, { .compatible = "generic-ehci", }, { .compatible = "cavium,octeon-6335-ehci", }, + { .compatible = "aspeed,ast2700-ehci", .data = (void *)1 }, {} }; MODULE_DEVICE_TABLE(of, vt8500_ehci_ids);
Signature · 1 line
2.34.1
Alan Stern
maintainerRe: [PATCH v2 2/2] usb: ehci: Add Aspeed AST2700 support
Quoted 32 lines · Ryan Chen
Unlike earlier Aspeed SoCs (AST2400/2500/2600) which are limited to 32-bit DMA addressing, the EHCI controller in AST2700 supports 64-bit DMA. Update the EHCI platform driver to make use of this capability by selecting a 64-bit DMA mask when the "aspeed,ast2700-ehci" compatible is present in device tree.
Signed-off-by Ryan Chen <[email protected]>--- drivers/usb/host/ehci-platform.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)drivers/usb/host/ehci-platform.c +2
-0@@ -27,6 +27,7 @@#include <linux/io.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/of_device.h> #include <linux/platform_device.h> #include <linux/reset.h> #include <linux/sys_soc.h> @@ -239,6 +240,7 @@ static int ehci_platform_probe(struct platform_device *dev)struct usb_hcd *hcd;struct resource *res_mem;struct usb_ehci_pdata *pdata =dev_get_platdata (&dev->dev); +const struct of_device_id *match;struct ehci_platform_priv *priv;struct ehci_hcd *ehci;int err, irq, clk =0 ;
drivers/usb/host/ehci-platform.c static int ehci_platform_probe(struct platform_device *dev) · line 260
Quoted 6 lines
drivers/usb/host/ehci-platform.c +3
-0@@ -253,6 +255,10 @@ static int ehci_platform_probe(struct platform_device *dev)if (!pdata) pdata = &ehci_platform_defaults; + match =of_match_device (dev->dev.driver->of_match_table, &dev->dev); +if (match && match->data) + pdata->dma_mask_64 =1 ;
You must not do this, since pdata may be pointing to the static ehci_platform_defaults structure. Instead, set a local variable to the value of pdata->dma_mask_64, and if match->data is set then update the local variable.
drivers/usb/host/ehci-platform.c static int ehci_platform_probe(struct platform_device *dev) · line 263
Quoted 3 lines
drivers/usb/host/ehci-platform.c +1
-0+ err =dma_coerce_mask_and_coherent (&dev->dev, pdata->dma_mask_64 ?DMA_BIT_MASK (64 ) :DMA_BIT_MASK (32 ));
Then use the local variable here to select which DMA mask is used.
Alan Stern
RE: [PATCH v2 2/2] usb: ehci: Add Aspeed AST2700 support
Quoted 50 lines
Subject: Re: [PATCH v2 2/2] usb: ehci: Add Aspeed AST2700 support
drivers/usb/host/ehci-platform.c static int ehci_platform_probe(struct
Quoted 25 lines · Ryan Chen
Unlike earlier Aspeed SoCs (AST2400/2500/2600) which are limited to 32-bit DMA addressing, the EHCI controller in AST2700 supports 64-bit DMA. Update the EHCI platform driver to make use of this capability by selecting a 64-bit DMA mask when the "aspeed,ast2700-ehci" compatible is present in device tree.
Signed-off-by Ryan Chen <[email protected]>--- drivers/usb/host/ehci-platform.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)drivers/usb/host/ehci-platform.c +1
-0@@ -27,6 +27,7 @@#include <linux/io.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/of_device.h> #include <linux/platform_device.h> #include <linux/reset.h> #include <linux/sys_soc.h> @@ -239,6 +240,7 @@ static int ehci_platform_probe(struct
platform_device*dev)drivers/usb/host/ehci-platform.c static int ehci_platform_probe(struct
Quoted 8 lines
drivers/usb/host/ehci-platform.c +1
-0struct usb_hcd *hcd;struct resource *res_mem;struct usb_ehci_pdata *pdata =dev_get_platdata (&dev->dev); +const struct of_device_id *match;struct ehci_platform_priv *priv;struct ehci_hcd *ehci;int err, irq, clk =0 ;@@ -253,6 +255,10 @@ static int ehci_platform_probe(struct
platform_device*dev)drivers/usb/host/ehci-platform.c static int ehci_platform_probe(struct platform_device *dev) · line 260
Quoted 6 lines
drivers/usb/host/ehci-platform.c +3
-0if (!pdata) pdata = &ehci_platform_defaults; + match =of_match_device (dev->dev.driver->of_match_table, &dev->dev); +if (match && match->data) + pdata->dma_mask_64 =1 ;You must not do this, since pdata may be pointing to the static
ehci_platform_defaultsstructure. Instead, set a local variable to the value ofpdata->dma_mask_64, and ifmatch->datais set then update the local variable.
Quoted 7 lines
drivers/usb/host/ehci-platform.c static int ehci_platform_probe(struct platform_device *dev) · line 263
Quoted 3 lines
drivers/usb/host/ehci-platform.c +1
-0+ err =dma_coerce_mask_and_coherent (&dev->dev, pdata->dma_mask_64 ?DMA_BIT_MASK (64 ) :DMA_BIT_MASK (32 ));Then use the local variable here to select which DMA mask is used.
Alan Stern
Thanks, I will modify by following.
if (!pdata)
pdata = &ehci_platform_defaults;
match = of_match_device(dev->dev.driver->of_match_table, &dev->dev);
bool dma_mask_64 = pdata->dma_mask_64;
if (match && match->data)
dma_mask_64 = true;
err = dma_coerce_mask_and_coherent(&dev->dev,
dma_mask_64 ? DMA_BIT_MASK(64) : DMA_BIT_MASK(32));
if (err) {
dev_err(&dev->dev, "Error: DMA mask configuration failed\n");
return err;
}