Skip to contentSkip to conversation

usb: gadget: atmel: Add SAM9X60 support

PATCH Superseded Zixun LI 4 participants 7 messages Mar 22, 2025 – Mar 31, 2025

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Zixun LI

author
#0 lore raw

PATCH 1/1 usb: gadget: atmel: Add SAM9X60 support

Add compatible "microchip,sam9x60-udc" and device tree binding. Compared to SAM9X5 the only difference is the DPRAM memory from the USB High Speed Device Port (UDPHS) hardware block was increased, so we can reuse the same endpoint data.

Tested on SAM9X60-Curiosity board with nfs and ums commands.

---
 arch/arm/dts/sam9x60.dtsi                        | 14 ++++++++++++++
 arch/arm/mach-at91/include/mach/atmel_usba_udc.h |  2 +-
 drivers/usb/gadget/atmel_usba_udc.c              |  1 +
 3 files changed, 16 insertions(+), 1 deletion(-)
arch/arm/dts/sam9x60.dtsi +14 -0
index 3b684fc63d5..96a8faf09b3 100644
@@ -69,6 +69,20 @@
 		#size-cells = <1>;
 		ranges;
 
+		usb0: gadget@500000 {
+			compatible = "microchip,sam9x60-udc";
+			reg = <0x500000 0x100000>,
+				<0xf803c000 0x400>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			interrupts = <23 IRQ_TYPE_LEVEL_HIGH 2>;
+			clocks = <&pmc PMC_TYPE_PERIPHERAL 23>, <&pmc PMC_TYPE_CORE 8>;
+			clock-names = "pclk", "hclk";
+			assigned-clocks = <&pmc PMC_TYPE_CORE 8>;
+			assigned-clock-rates = <480000000>;
+			status = "disabled";
+		};
+
 		usb1: usb@600000 {
 			compatible = "atmel,at91rm9200-ohci", "usb-ohci";
 			reg = <0x00600000 0x100000>;
arch/arm/mach-at91/include/mach/atmel_usba_udc.h +1 -1
index 835b47d91ba..23c71985c90 100644
@@ -20,7 +20,7 @@
 	}
 
 #if defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45) || \
-	defined(CONFIG_AT91SAM9X5)
+	defined(CONFIG_AT91SAM9X5) || defined(CONFIG_SAM9X60)
 static struct usba_ep_data usba_udc_ep[] = {
 	EP("ep0", 0, 64, 1, 0, 0),
 	EP("ep1", 1, 1024, 2, 1, 1),
drivers/usb/gadget/atmel_usba_udc.c +1 -0
index a77037a7094..f9326f0a7e7 100644
@@ -1443,6 +1443,7 @@ static const struct udevice_id usba_udc_ids[] = {
 	{ .compatible = "atmel,at91sam9rl-udc" },
 	{ .compatible = "atmel,at91sam9g45-udc" },
 	{ .compatible = "atmel,sama5d3-udc" },
+	{ .compatible = "microchip,sam9x60-udc" },
 	{}
 };
 
Signature · 1 line
2.39.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Zixun LI

Add compatible "microchip,sam9x60-udc" and device tree binding. Compared to SAM9X5 the only difference is the DPRAM memory from the USB High Speed Device Port (UDPHS) hardware block was increased, so we can reuse the same endpoint data.

Tested on SAM9X60-Curiosity board with nfs and ums commands.

Thanks !

#2 lore raw
In reply to Zixun LI
Quoted 6 lines · Zixun LI

Add compatible "microchip,sam9x60-udc" and device tree binding. Compared to SAM9X5 the only difference is the DPRAM memory from the USB High Speed Device Port (UDPHS) hardware block was increased, so we can reuse the same endpoint data.

Tested on SAM9X60-Curiosity board with nfs and ums commands.

Why no patch to enable it on the board as well then ?

Quoted 6 lines
---
 arch/arm/dts/sam9x60.dtsi                        | 14 ++++++++++++++
 arch/arm/mach-at91/include/mach/atmel_usba_udc.h |  2 +-
 drivers/usb/gadget/atmel_usba_udc.c              |  1 +

Device tree and driver changes should be separate commits.

Quoted 7 lines
 3 files changed, 16 insertions(+), 1 deletion(-)
arch/arm/dts/sam9x60.dtsi +0 -0
index 3b684fc63d5..96a8faf09b3 100644

arch/arm/dts/sam9x60.dtsi line 77

Quoted 9 lines
arch/arm/dts/sam9x60.dtsi +6 -0
@@ -69,6 +69,20 @@
 		#size-cells = <1>;
 		ranges;
 
+		usb0: gadget@500000 {
+			compatible = "microchip,sam9x60-udc";
+			reg = <0x500000 0x100000>,
+				<0xf803c000 0x400>;
+			#address-cells = <1>;
+			#size-cells = <0>;

Can you please reorder these to have them in the same order as in Linux DTS ? (easier to diff...)

Quoted 36 lines
arch/arm/dts/sam9x60.dtsi +8 -0
+			interrupts = <23 IRQ_TYPE_LEVEL_HIGH 2>;
+			clocks = <&pmc PMC_TYPE_PERIPHERAL 23>, <&pmc PMC_TYPE_CORE 8>;
+			clock-names = "pclk", "hclk";
+			assigned-clocks = <&pmc PMC_TYPE_CORE 8>;
+			assigned-clock-rates = <480000000>;
+			status = "disabled";
+		};
+
 		usb1: usb@600000 {
 			compatible = "atmel,at91rm9200-ohci", "usb-ohci";
 			reg = <0x00600000 0x100000>;
arch/arm/mach-at91/include/mach/atmel_usba_udc.h +1 -1
index 835b47d91ba..23c71985c90 100644
@@ -20,7 +20,7 @@
 	}
 
 #if defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45) || \
-	defined(CONFIG_AT91SAM9X5)
+	defined(CONFIG_AT91SAM9X5) || defined(CONFIG_SAM9X60)
 static struct usba_ep_data usba_udc_ep[] = {
 	EP("ep0", 0, 64, 1, 0, 0),
 	EP("ep1", 1, 1024, 2, 1, 1),
drivers/usb/gadget/atmel_usba_udc.c +1 -0
index a77037a7094..f9326f0a7e7 100644
@@ -1443,6 +1443,7 @@ static const struct udevice_id usba_udc_ids[] = {
 	{ .compatible = "atmel,at91sam9rl-udc" },
 	{ .compatible = "atmel,at91sam9g45-udc" },
 	{ .compatible = "atmel,sama5d3-udc" },
+	{ .compatible = "microchip,sam9x60-udc" },
 	{}
 };
 
#3 lore raw

Hi Eugen, Zixun,

Quoted 9 lines · Eugen Hristev
Quoted 6 lines · Zixun LI

Add compatible "microchip,sam9x60-udc" and device tree binding. Compared to SAM9X5 the only difference is the DPRAM memory from the USB High Speed Device Port (UDPHS) hardware block was increased, so we can reuse the same endpoint data.

Tested on SAM9X60-Curiosity board with nfs and ums commands.

Why no patch to enable it on the board as well then ?

Looking at configs/at91sam9x5ek_mmc_defconfig, I don't see CMD_USB_MASS_STORAGE=y in there as well.

Could you elaborate on why you'd want this to be enabled as part of the driver series?

On one hand, users has more built-in commands available and it eases the testing. On the other hand, some users might not be interested in having this by default. Enabling it via menuconfig is quite easy.

Quoted 9 lines
Quoted 7 lines
---
 arch/arm/dts/sam9x60.dtsi                        | 14 ++++++++++++++
 arch/arm/mach-at91/include/mach/atmel_usba_udc.h |  2 +-
 drivers/usb/gadget/atmel_usba_udc.c              |  1 +

Device tree and driver changes should be separate commits.

I agree with Eugen. Could you please split this out, Zixun?

Quoted 12 lines
Quoted 12 lines

 3 files changed, 16 insertions(+), 1 deletion(-)
arch/arm/dts/sam9x60.dtsi +0 -0
index 3b684fc63d5..96a8faf09b3 100644
@@ -69,6 +69,20 @@
 		#size-cells = <1>;
 		ranges;
 
Quoted 8 lines

arch/arm/dts/sam9x60.dtsi line 77

Quoted 6 lines
arch/arm/dts/sam9x60.dtsi +6 -0
+		usb0: gadget@500000 {
+			compatible = "microchip,sam9x60-udc";
+			reg = <0x500000 0x100000>,
+				<0xf803c000 0x400>;
+			#address-cells = <1>;
+			#size-cells = <0>;

Can you please reorder these to have them in the same order as in Linux DTS ? (easier to diff...)

Agreed with Eugen.

Quoted 37 lines
Quoted 37 lines
arch/arm/dts/sam9x60.dtsi +8 -0
+			interrupts = <23 IRQ_TYPE_LEVEL_HIGH 2>;
+			clocks = <&pmc PMC_TYPE_PERIPHERAL 23>, <&pmc PMC_TYPE_CORE 8>;
+			clock-names = "pclk", "hclk";
+			assigned-clocks = <&pmc PMC_TYPE_CORE 8>;
+			assigned-clock-rates = <480000000>;
+			status = "disabled";
+		};
+
 		usb1: usb@600000 {
 			compatible = "atmel,at91rm9200-ohci", "usb-ohci";
 			reg = <0x00600000 0x100000>;
arch/arm/mach-at91/include/mach/atmel_usba_udc.h +1 -1
index 835b47d91ba..23c71985c90 100644
@@ -20,7 +20,7 @@
 	}
 
 #if defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45) || \
-	defined(CONFIG_AT91SAM9X5)
+	defined(CONFIG_AT91SAM9X5) || defined(CONFIG_SAM9X60)
 static struct usba_ep_data usba_udc_ep[] = {
 	EP("ep0", 0, 64, 1, 0, 0),
 	EP("ep1", 1, 1024, 2, 1, 1),
drivers/usb/gadget/atmel_usba_udc.c +1 -0
index a77037a7094..f9326f0a7e7 100644
@@ -1443,6 +1443,7 @@ static const struct udevice_id usba_udc_ids[] = {
 	{ .compatible = "atmel,at91sam9rl-udc" },
 	{ .compatible = "atmel,at91sam9g45-udc" },
 	{ .compatible = "atmel,sama5d3-udc" },
+	{ .compatible = "microchip,sam9x60-udc" },
 	{}
 };
 
#4 lore raw
Quoted 17 lines · Mattijs Korpershoek

Hi Eugen, Zixun,

Quoted 9 lines · Eugen Hristev
Quoted 6 lines · Zixun LI

Add compatible "microchip,sam9x60-udc" and device tree binding. Compared to SAM9X5 the only difference is the DPRAM memory from the USB High Speed Device Port (UDPHS) hardware block was increased, so we can reuse the same endpoint data.

Tested on SAM9X60-Curiosity board with nfs and ums commands.

Why no patch to enable it on the board as well then ?

Looking at configs/at91sam9x5ek_mmc_defconfig, I don't see CMD_USB_MASS_STORAGE=y in there as well.

Quoted 6 lines

Could you elaborate on why you'd want this to be enabled as part of the driver series?

On one hand, users has more built-in commands available and it eases the testing. On the other hand, some users might not be interested in having this by default. Enabling it via menuconfig is quite easy.

What I meant is have the node in the board DT (gadget@500000). That cannot be enabled in the menuconfig.
The Gadget or the Host should be described in the DT as it's a description of the board, if the board supports both Gadget and Host , both should be in the DT.

If there is a hardware limitation, or something that allows only one of these to work at the same time, this should be detailed, and have both nodes anyway, with one of them Disabled, possibly two different DTs with either of the nodes enabled/disabled.

Quoted 73 lines
Quoted 10 lines
Quoted 8 lines
---
 arch/arm/dts/sam9x60.dtsi                        | 14 ++++++++++++++
 arch/arm/mach-at91/include/mach/atmel_usba_udc.h |  2 +-
 drivers/usb/gadget/atmel_usba_udc.c              |  1 +

Device tree and driver changes should be separate commits.

I agree with Eugen. Could you please split this out, Zixun?

Quoted 12 lines
Quoted 12 lines

 3 files changed, 16 insertions(+), 1 deletion(-)
arch/arm/dts/sam9x60.dtsi +0 -0
index 3b684fc63d5..96a8faf09b3 100644
@@ -69,6 +69,20 @@
 		#size-cells = <1>;
 		ranges;
 
Quoted 8 lines

arch/arm/dts/sam9x60.dtsi line 77

Quoted 6 lines
arch/arm/dts/sam9x60.dtsi +6 -0
+		usb0: gadget@500000 {
+			compatible = "microchip,sam9x60-udc";
+			reg = <0x500000 0x100000>,
+				<0xf803c000 0x400>;
+			#address-cells = <1>;
+			#size-cells = <0>;

Can you please reorder these to have them in the same order as in Linux DTS ? (easier to diff...)

Agreed with Eugen.

Quoted 37 lines
Quoted 37 lines
arch/arm/dts/sam9x60.dtsi +8 -0
+			interrupts = <23 IRQ_TYPE_LEVEL_HIGH 2>;
+			clocks = <&pmc PMC_TYPE_PERIPHERAL 23>, <&pmc PMC_TYPE_CORE 8>;
+			clock-names = "pclk", "hclk";
+			assigned-clocks = <&pmc PMC_TYPE_CORE 8>;
+			assigned-clock-rates = <480000000>;
+			status = "disabled";
+		};
+
 		usb1: usb@600000 {
 			compatible = "atmel,at91rm9200-ohci", "usb-ohci";
 			reg = <0x00600000 0x100000>;
arch/arm/mach-at91/include/mach/atmel_usba_udc.h +1 -1
index 835b47d91ba..23c71985c90 100644
@@ -20,7 +20,7 @@
 	}
 
 #if defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45) || \
-	defined(CONFIG_AT91SAM9X5)
+	defined(CONFIG_AT91SAM9X5) || defined(CONFIG_SAM9X60)
 static struct usba_ep_data usba_udc_ep[] = {
 	EP("ep0", 0, 64, 1, 0, 0),
 	EP("ep1", 1, 1024, 2, 1, 1),
drivers/usb/gadget/atmel_usba_udc.c +1 -0
index a77037a7094..f9326f0a7e7 100644
@@ -1443,6 +1443,7 @@ static const struct udevice_id usba_udc_ids[] = {
 	{ .compatible = "atmel,at91sam9rl-udc" },
 	{ .compatible = "atmel,at91sam9g45-udc" },
 	{ .compatible = "atmel,sama5d3-udc" },
+	{ .compatible = "microchip,sam9x60-udc" },
 	{}
 };
 
#5 lore raw

Hi Eugen,

Quoted 31 lines · Eugen Hristev
Quoted 17 lines · Mattijs Korpershoek

Hi Eugen, Zixun,

Quoted 9 lines · Eugen Hristev
Quoted 6 lines · Zixun LI

Add compatible "microchip,sam9x60-udc" and device tree binding. Compared to SAM9X5 the only difference is the DPRAM memory from the USB High Speed Device Port (UDPHS) hardware block was increased, so we can reuse the same endpoint data.

Tested on SAM9X60-Curiosity board with nfs and ums commands.

Why no patch to enable it on the board as well then ?

Looking at configs/at91sam9x5ek_mmc_defconfig, I don't see CMD_USB_MASS_STORAGE=y in there as well.

Quoted 6 lines

Could you elaborate on why you'd want this to be enabled as part of the driver series?

On one hand, users has more built-in commands available and it eases the testing. On the other hand, some users might not be interested in having this by default. Enabling it via menuconfig is quite easy.

What I meant is have the node in the board DT (gadget@500000). That cannot be enabled in the menuconfig.
The Gadget or the Host should be described in the DT as it's a description of the board, if the board supports both Gadget and Host , both should be in the DT.

Quoted 4 lines

If there is a hardware limitation, or something that allows only one of these to work at the same time, this should be detailed, and have both nodes anyway, with one of them Disabled, possibly two different DTs with either of the nodes enabled/disabled.

I see. Sorry I misunderstood your point initially.
I agree with you: we should enable usb0 in arch/arm/dts/at91-sam9x60_curiosity.dts as part of this series.

Thanks for the clarification!

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

---

[...]

author
#6 lore raw
Quoted 9 lines · Mattijs Korpershoek

Hi Eugen,

Quoted 4 lines · Eugen Hristev
Quoted 3 lines · Mattijs Korpershoek

Hi Eugen, Zixun,

On lun., mars 24, 2025 at 11:23, Eugen Hristev <[email protected]> wrote:

Quoted 8 lines
Quoted 4 lines

If there is a hardware limitation, or something that allows only one of these to work at the same time, this should be detailed, and have both nodes anyway, with one of them Disabled, possibly two different DTs with either of the nodes enabled/disabled.

I see. Sorry I misunderstood your point initially.
I agree with you: we should enable usb0 in arch/arm/dts/at91-sam9x60_curiosity.dts as part of this series.

Hi Eugen, Mattijs,

Thank you for the explanation, I was wrong about the gadget host conflict, in fact on gadget stop it does switch back to host mode. I've also tested on SAM9X60 that "usb start" works after the ums command is completed. It's safe to add status=ok in board dts.

Zixun