devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Add Aspeed AST2700 ehci support
@ 2025-09-18  6:49 Ryan Chen
  2025-09-18  6:49 ` [PATCH 1/2] dt-bindings: usb: ehci: Add Aspeed AST2700 compatible Ryan Chen
  2025-09-18  6:49 ` [PATCH 2/2] usb: ehci: Add Aspeed AST2700 support Ryan Chen
  0 siblings, 2 replies; 6+ messages in thread
From: Ryan Chen @ 2025-09-18  6:49 UTC (permalink / raw)
  To: ryan_chen, Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Alan Stern, linux-usb, devicetree, linux-kernel

This series adds support for the EHCI controller found in Aspeed's
new AST2700 SoC.

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              | 26 +++++++++++++++----
 2 files changed, 22 insertions(+), 5 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] dt-bindings: usb: ehci: Add Aspeed AST2700 compatible
  2025-09-18  6:49 [PATCH 0/2] Add Aspeed AST2700 ehci support Ryan Chen
@ 2025-09-18  6:49 ` Ryan Chen
  2025-09-18 15:16   ` Conor Dooley
  2025-09-18  6:49 ` [PATCH 2/2] usb: ehci: Add Aspeed AST2700 support Ryan Chen
  1 sibling, 1 reply; 6+ messages in thread
From: Ryan Chen @ 2025-09-18  6:49 UTC (permalink / raw)
  To: ryan_chen, Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Alan Stern, linux-usb, devicetree, linux-kernel

Add the compatible string for Aspeed AST2700 SoC.

Signed-off-by: Ryan Chen <ryan_chen@aspeedtech.com>
---
 Documentation/devicetree/bindings/usb/generic-ehci.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/usb/generic-ehci.yaml b/Documentation/devicetree/bindings/usb/generic-ehci.yaml
index 508d958e698c..4e84bead0232 100644
--- a/Documentation/devicetree/bindings/usb/generic-ehci.yaml
+++ b/Documentation/devicetree/bindings/usb/generic-ehci.yaml
@@ -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
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] usb: ehci: Add Aspeed AST2700 support
  2025-09-18  6:49 [PATCH 0/2] Add Aspeed AST2700 ehci support Ryan Chen
  2025-09-18  6:49 ` [PATCH 1/2] dt-bindings: usb: ehci: Add Aspeed AST2700 compatible Ryan Chen
@ 2025-09-18  6:49 ` Ryan Chen
  2025-09-18 14:02   ` Alan Stern
  1 sibling, 1 reply; 6+ messages in thread
From: Ryan Chen @ 2025-09-18  6:49 UTC (permalink / raw)
  To: ryan_chen, Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Alan Stern, linux-usb, devicetree, linux-kernel

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 <ryan_chen@aspeedtech.com>
---
 drivers/usb/host/ehci-platform.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
index 6aab45c8525c..edf1fb4033c2 100644
--- a/drivers/usb/host/ehci-platform.c
+++ b/drivers/usb/host/ehci-platform.c
@@ -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>
@@ -122,10 +123,18 @@ static const struct ehci_driver_overrides platform_overrides __initconst = {
 	.extra_priv_size =	sizeof(struct ehci_platform_priv),
 };
 
+#define EHCI_PDATA_COMMON        \
+	.power_on		= ehci_platform_power_on,	\
+	.power_suspend	= ehci_platform_power_off,	\
+	.power_off		= ehci_platform_power_off
+
 static struct usb_ehci_pdata ehci_platform_defaults = {
-	.power_on =		ehci_platform_power_on,
-	.power_suspend =	ehci_platform_power_off,
-	.power_off =		ehci_platform_power_off,
+	EHCI_PDATA_COMMON,
+};
+
+static const struct usb_ehci_pdata ehci_ast2700_platform = {
+	EHCI_PDATA_COMMON,
+	.dma_mask_64 = 1,
 };
 
 /**
@@ -239,6 +248,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;
@@ -250,7 +260,10 @@ static int ehci_platform_probe(struct platform_device *dev)
 	 * Use reasonable defaults so platforms don't have to provide these
 	 * with DT probing on ARM.
 	 */
-	if (!pdata)
+	match = of_match_device(dev->dev.driver->of_match_table, &dev->dev);
+	if (match && match->data)
+		pdata = (struct usb_ehci_pdata *)match->data;
+	else if (!pdata)
 		pdata = &ehci_platform_defaults;
 
 	err = dma_coerce_mask_and_coherent(&dev->dev,
@@ -298,7 +311,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 +500,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 = &ehci_ast2700_platform },
 	{}
 };
 MODULE_DEVICE_TABLE(of, vt8500_ehci_ids);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] usb: ehci: Add Aspeed AST2700 support
  2025-09-18  6:49 ` [PATCH 2/2] usb: ehci: Add Aspeed AST2700 support Ryan Chen
@ 2025-09-18 14:02   ` Alan Stern
  2025-09-24  5:27     ` Ryan Chen
  0 siblings, 1 reply; 6+ messages in thread
From: Alan Stern @ 2025-09-18 14:02 UTC (permalink / raw)
  To: Ryan Chen
  Cc: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, linux-usb, devicetree, linux-kernel

On Thu, Sep 18, 2025 at 02:49:19PM +0800, Ryan Chen wrote:
> 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 <ryan_chen@aspeedtech.com>
> ---
>  drivers/usb/host/ehci-platform.c | 26 +++++++++++++++++++++-----
>  1 file changed, 21 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
> index 6aab45c8525c..edf1fb4033c2 100644
> --- a/drivers/usb/host/ehci-platform.c
> +++ b/drivers/usb/host/ehci-platform.c
> @@ -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>
> @@ -122,10 +123,18 @@ static const struct ehci_driver_overrides platform_overrides __initconst = {
>  	.extra_priv_size =	sizeof(struct ehci_platform_priv),
>  };
>  
> +#define EHCI_PDATA_COMMON        \
> +	.power_on		= ehci_platform_power_on,	\
> +	.power_suspend	= ehci_platform_power_off,	\
> +	.power_off		= ehci_platform_power_off
> +
>  static struct usb_ehci_pdata ehci_platform_defaults = {
> -	.power_on =		ehci_platform_power_on,
> -	.power_suspend =	ehci_platform_power_off,
> -	.power_off =		ehci_platform_power_off,
> +	EHCI_PDATA_COMMON,
> +};
> +
> +static const struct usb_ehci_pdata ehci_ast2700_platform = {
> +	EHCI_PDATA_COMMON,
> +	.dma_mask_64 = 1,
>  };

Arggh!  This is dreadful.  Just have two copies of the initializers.

Better yet, change your of_match data into a boolean property for 
overriding the default DMA mask and then use the original 
ehci_platform_defaults structure.  Look at ohci_platform_probe() in 
ohci-platform.c for an example.

>  
>  /**
> @@ -239,6 +248,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;
> @@ -250,7 +260,10 @@ static int ehci_platform_probe(struct platform_device *dev)
>  	 * Use reasonable defaults so platforms don't have to provide these
>  	 * with DT probing on ARM.
>  	 */
> -	if (!pdata)
> +	match = of_match_device(dev->dev.driver->of_match_table, &dev->dev);
> +	if (match && match->data)
> +		pdata = (struct usb_ehci_pdata *)match->data;

Do you really want the of_match data to override the platform data?  
Consider a system that has both.  Which one do you think would be more 
important?

(If you take my suggestion above, this question becomes moot.)

Alan Stern

> +	else if (!pdata)
>  		pdata = &ehci_platform_defaults;
>  
>  	err = dma_coerce_mask_and_coherent(&dev->dev,
> @@ -298,7 +311,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 +500,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 = &ehci_ast2700_platform },
>  	{}
>  };
>  MODULE_DEVICE_TABLE(of, vt8500_ehci_ids);
> -- 
> 2.34.1
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] dt-bindings: usb: ehci: Add Aspeed AST2700 compatible
  2025-09-18  6:49 ` [PATCH 1/2] dt-bindings: usb: ehci: Add Aspeed AST2700 compatible Ryan Chen
@ 2025-09-18 15:16   ` Conor Dooley
  0 siblings, 0 replies; 6+ messages in thread
From: Conor Dooley @ 2025-09-18 15:16 UTC (permalink / raw)
  To: Ryan Chen
  Cc: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Alan Stern, linux-usb, devicetree, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 52 bytes --]

Acked-by: Conor Dooley <conor.dooley@microchip.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH 2/2] usb: ehci: Add Aspeed AST2700 support
  2025-09-18 14:02   ` Alan Stern
@ 2025-09-24  5:27     ` Ryan Chen
  0 siblings, 0 replies; 6+ messages in thread
From: Ryan Chen @ 2025-09-24  5:27 UTC (permalink / raw)
  To: Alan Stern
  Cc: Greg Kroah-Hartman, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, linux-usb@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org

> Subject: Re: [PATCH 2/2] usb: ehci: Add Aspeed AST2700 support
> 
> On Thu, Sep 18, 2025 at 02:49:19PM +0800, Ryan Chen wrote:
> > 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 <ryan_chen@aspeedtech.com>
> > ---
> >  drivers/usb/host/ehci-platform.c | 26 +++++++++++++++++++++-----
> >  1 file changed, 21 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/usb/host/ehci-platform.c
> > b/drivers/usb/host/ehci-platform.c
> > index 6aab45c8525c..edf1fb4033c2 100644
> > --- a/drivers/usb/host/ehci-platform.c
> > +++ b/drivers/usb/host/ehci-platform.c
> > @@ -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>
> > @@ -122,10 +123,18 @@ static const struct ehci_driver_overrides
> platform_overrides __initconst = {
> >  	.extra_priv_size =	sizeof(struct ehci_platform_priv),
> >  };
> >
> > +#define EHCI_PDATA_COMMON        \
> > +	.power_on		= ehci_platform_power_on,	\
> > +	.power_suspend	= ehci_platform_power_off,	\
> > +	.power_off		= ehci_platform_power_off
> > +
> >  static struct usb_ehci_pdata ehci_platform_defaults = {
> > -	.power_on =		ehci_platform_power_on,
> > -	.power_suspend =	ehci_platform_power_off,
> > -	.power_off =		ehci_platform_power_off,
> > +	EHCI_PDATA_COMMON,
> > +};
> > +
> > +static const struct usb_ehci_pdata ehci_ast2700_platform = {
> > +	EHCI_PDATA_COMMON,
> > +	.dma_mask_64 = 1,
> >  };
> 
> Arggh!  This is dreadful.  Just have two copies of the initializers.
> 
> Better yet, change your of_match data into a boolean property for overriding
> the default DMA mask and then use the original ehci_platform_defaults
> structure.  Look at ohci_platform_probe() in ohci-platform.c for an example.
> 
Sorry, I may not see the implement on ohci probe.
https://github.com/torvalds/linux/blob/master/drivers/usb/host/ohci-platform.c#L100-L111
But I think I will modify by following.

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,
        dma64 ? DMA_BIT_MASK(64) : DMA_BIT_MASK(32));

and 
+ { .compatible = "aspeed,ast2700-ehci", .data = (void *)1 },

Thanks.

> >
> >  /**
> > @@ -239,6 +248,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;
> > @@ -250,7 +260,10 @@ static int ehci_platform_probe(struct
> platform_device *dev)
> >  	 * Use reasonable defaults so platforms don't have to provide these
> >  	 * with DT probing on ARM.
> >  	 */
> > -	if (!pdata)
> > +	match = of_match_device(dev->dev.driver->of_match_table, &dev->dev);
> > +	if (match && match->data)
> > +		pdata = (struct usb_ehci_pdata *)match->data;
> 
> Do you really want the of_match data to override the platform data?
> Consider a system that has both.  Which one do you think would be more
> important?
> 
> (If you take my suggestion above, this question becomes moot.)
> 
> Alan Stern
> 
> > +	else if (!pdata)
> >  		pdata = &ehci_platform_defaults;
> >
> >  	err = dma_coerce_mask_and_coherent(&dev->dev,
> > @@ -298,7 +311,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 +500,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 = &ehci_ast2700_platform },
> >  	{}
> >  };
> >  MODULE_DEVICE_TABLE(of, vt8500_ehci_ids);
> > --
> > 2.34.1
> >

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-09-24  5:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-18  6:49 [PATCH 0/2] Add Aspeed AST2700 ehci support Ryan Chen
2025-09-18  6:49 ` [PATCH 1/2] dt-bindings: usb: ehci: Add Aspeed AST2700 compatible Ryan Chen
2025-09-18 15:16   ` Conor Dooley
2025-09-18  6:49 ` [PATCH 2/2] usb: ehci: Add Aspeed AST2700 support Ryan Chen
2025-09-18 14:02   ` Alan Stern
2025-09-24  5:27     ` Ryan Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).