Skip to contentSkip to conversation

ARM: at91: dt: add USBA support

PATCH Superseded Jean-Christophe PLAGNIOL-VILLARD 4 participants 14 messages May 20, 2013 – May 23, 2013

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v4 cover ARM: at91: dt: add USBA support

HI,

v4:
fix multi instance support

v3:
rebase againt 3.10-rc1 + dt macro cleanup

This patch serie finish to add the usb device support to dt for at91 with the usba support present on the last at91 generation since sam9g45

The following changes since commit b3f442b0eedbc20b5ce3f4a96530588d14901199:

ARM: at91: udpate defconfigs (2013-05-17 15:05:08 +0200)

are available in the git repository at:

git://github.com/at91linux/linux-at91.git j/for-3.11-usba

for you to fetch changes up to 910026a08e2c2205953f2507cc11f4822998989b:

ARM: at91: sam9m10g45ek add udc DT support (2013-05-20 23:52:17 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (7):
USB: gadget: atmel_usba: move global struct usba_ep usba_ep to struct usba_udc
USB: gadget: atmel_usba: allow multi instance
USB: gadget: atmel_usba: add DT support
ARM: at91: sam9x5 add udc DT support
ARM: at91: sam9x5ek add udc DT support
ARM: at91: sam9g45 add udc DT support
ARM: at91: sam9m10g45ek add udc DT support

 Documentation/devicetree/bindings/usb/atmel-usb.txt |   82 ++++++++++++++++++++++++++++++
 arch/arm/boot/dts/at91sam9g45.dtsi                  |   62 +++++++++++++++++++++++
 arch/arm/boot/dts/at91sam9m10g45ek.dts              |    5 ++
 arch/arm/boot/dts/at91sam9x5.dtsi                   |   62 +++++++++++++++++++++++
 arch/arm/boot/dts/at91sam9x5ek.dtsi                 |    5 ++
 arch/arm/mach-at91/at91sam9g45.c                    |    2 +
 arch/arm/mach-at91/at91sam9x5.c                     |    2 +
 drivers/usb/gadget/Kconfig                          |    2 +-
 drivers/usb/gadget/atmel_usba_udc.c                 |  264 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------
 drivers/usb/gadget/atmel_usba_udc.h                 |    2 +
 10 files changed, 407 insertions(+), 81 deletions(-)

Best Regards,
J.

#1 lore raw

PATCH v4 1/7 USB: gadget: atmel_usba: move global struct usba_ep usba_ep to struct usba_udc

so we can have multiple usb gadget instance

Cc Nicolas Ferre <[email protected]>
Cc linux-usb at vger.kernel.org
---
 drivers/usb/gadget/atmel_usba_udc.c |   20 +++++++++++---------
 drivers/usb/gadget/atmel_usba_udc.h |    1 +
 2 files changed, 12 insertions(+), 9 deletions(-)
drivers/usb/gadget/atmel_usba_udc.c +11 -9
index f2a970f..d2ffd04 100644
@@ -29,7 +29,6 @@
 
 
 static struct usba_udc the_udc;
-static struct usba_ep *usba_ep;
 
 #ifdef CONFIG_USB_GADGET_DEBUG_FS
 #include <linux/debugfs.h>
@@ -1147,7 +1146,7 @@ static int do_test_mode(struct usba_udc *udc)
 		 * Test_SE0_NAK: Force high-speed mode and set up ep0
 		 * for Bulk IN transfers
 		 */
-		ep = &usba_ep[0];
+		ep = &udc->usba_ep[0];
 		usba_writel(udc, TST,
 				USBA_BF(SPEED_CFG, USBA_SPEED_CFG_FORCE_HIGH));
 		usba_ep_writel(ep, CFG,
@@ -1165,7 +1164,7 @@ static int do_test_mode(struct usba_udc *udc)
 		break;
 	case 0x0400:
 		/* Test_Packet */
-		ep = &usba_ep[0];
+		ep = &udc->usba_ep[0];
 		usba_ep_writel(ep, CFG,
 				USBA_BF(EPT_SIZE, USBA_EPT_SIZE_64)
 				| USBA_EPT_DIR_IN
@@ -1668,7 +1667,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
 
 		for (i = 1; i < USBA_NR_ENDPOINTS; i++)
 			if (dma_status & (1 << i))
-				usba_dma_irq(udc, &usba_ep[i]);
+				usba_dma_irq(udc, &udc->usba_ep[i]);
 	}
 
 	ep_status = USBA_BFEXT(EPT_INT, status);
@@ -1677,10 +1676,10 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
 
 		for (i = 0; i < USBA_NR_ENDPOINTS; i++)
 			if (ep_status & (1 << i)) {
-				if (ep_is_control(&usba_ep[i]))
-					usba_control_irq(udc, &usba_ep[i]);
+				if (ep_is_control(&udc->usba_ep[i]))
+					usba_control_irq(udc, &udc->usba_ep[i]);
 				else
-					usba_ep_irq(udc, &usba_ep[i]);
+					usba_ep_irq(udc, &udc->usba_ep[i]);
 			}
 	}
 
@@ -1705,7 +1704,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
 		DBG(DBG_BUS, "%s bus reset detected\n",
 		    usb_speed_string(udc->gadget.speed));
 
-		ep0 = &usba_ep[0];
+		ep0 = &udc->usba_ep[0];
 		ep0->ep.desc = &usba_ep0_desc;
 		ep0->state = WAIT_FOR_SETUP;
 		usba_ep_writel(ep0, CFG,
@@ -1841,6 +1840,7 @@ static int __init usba_udc_probe(struct platform_device *pdev)
 	struct resource *regs, *fifo;
 	struct clk *pclk, *hclk;
 	struct usba_udc *udc = &the_udc;
+	static struct usba_ep *usba_ep;
 	int irq, ret, i;
 
 	regs = platform_get_resource(pdev, IORESOURCE_MEM, CTRL_IOMEM_ID);
@@ -1896,6 +1896,8 @@ static int __init usba_udc_probe(struct platform_device *pdev)
 	if (!usba_ep)
 		goto err_alloc_ep;
 
+	udc->usba_ep = usba_ep;
+
 	the_udc.gadget.ep0 = &usba_ep[0].ep;
 
 	INIT_LIST_HEAD(&usba_ep[0].ep.ep_list);
@@ -2008,7 +2010,7 @@ static int __exit usba_udc_remove(struct platform_device *pdev)
 	usb_del_gadget_udc(&udc->gadget);
 
 	for (i = 1; i < pdata->num_ep; i++)
-		usba_ep_cleanup_debugfs(&usba_ep[i]);
+		usba_ep_cleanup_debugfs(&udc->usba_ep[i]);
 	usba_cleanup_debugfs(udc);
 
 	if (gpio_is_valid(udc->vbus_pin)) {
drivers/usb/gadget/atmel_usba_udc.h +1 -0
index d65a618..0841986 100644
@@ -319,6 +319,7 @@ struct usba_udc {
 	int vbus_pin_inverted;
 	struct clk *pclk;
 	struct clk *hclk;
+	struct usba_ep *usba_ep;
 
 	u16 devstatus;
 
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH v4 2/7 USB: gadget: atmel_usba: allow multi instance

drop static struct usba_udc the_udc

Cc Nicolas Ferre <[email protected]>
Cc linux-usb at vger.kernel.org
---
 drivers/usb/gadget/atmel_usba_udc.c |   36 +++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/usb/gadget/atmel_usba_udc.c +18 -18
index d2ffd04..eea57a3 100644
@@ -27,9 +27,6 @@
 
 #include "atmel_usba_udc.h"
 
-
-static struct usba_udc the_udc;
-
 #ifdef CONFIG_USB_GADGET_DEBUG_FS
 #include <linux/debugfs.h>
 #include <linux/uaccess.h>
@@ -1013,16 +1010,13 @@ static void nop_release(struct device *dev)
 
 }
 
-static struct usba_udc the_udc = {
-	.gadget	= {
-		.ops		= &usba_udc_ops,
-		.ep_list	= LIST_HEAD_INIT(the_udc.gadget.ep_list),
-		.max_speed	= USB_SPEED_HIGH,
-		.name		= "atmel_usba_udc",
-		.dev	= {
-			.init_name	= "gadget",
-			.release	= nop_release,
-		},
+struct usb_gadget usba_gadget_template = {
+	.ops		= &usba_udc_ops,
+	.max_speed	= USB_SPEED_HIGH,
+	.name		= "atmel_usba_udc",
+	.dev	= {
+		.init_name	= "gadget",
+		.release	= nop_release,
 	},
 };
 
@@ -1839,10 +1833,17 @@ static int __init usba_udc_probe(struct platform_device *pdev)
 	struct usba_platform_data *pdata = pdev->dev.platform_data;
 	struct resource *regs, *fifo;
 	struct clk *pclk, *hclk;
-	struct usba_udc *udc = &the_udc;
+	struct usba_udc *udc;
 	static struct usba_ep *usba_ep;
 	int irq, ret, i;
 
+	udc = devm_kzalloc(&pdev->dev, sizeof(*udc), GFP_KERNEL);
+	if (!udc)
+		return -ENOMEM;
+
+	udc->gadget = usba_gadget_template;
+	INIT_LIST_HEAD(&udc->gadget.ep_list);
+
 	regs = platform_get_resource(pdev, IORESOURCE_MEM, CTRL_IOMEM_ID);
 	fifo = platform_get_resource(pdev, IORESOURCE_MEM, FIFO_IOMEM_ID);
 	if (!regs || !fifo || !pdata)
@@ -1897,8 +1898,7 @@ static int __init usba_udc_probe(struct platform_device *pdev)
 		goto err_alloc_ep;
 
 	udc->usba_ep = usba_ep;
-
-	the_udc.gadget.ep0 = &usba_ep[0].ep;
+	udc->gadget.ep0 = &usba_ep[0].ep;
 
 	INIT_LIST_HEAD(&usba_ep[0].ep.ep_list);
 	usba_ep[0].ep_regs = udc->regs + USBA_EPT_BASE(0);
@@ -1907,7 +1907,7 @@ static int __init usba_udc_probe(struct platform_device *pdev)
 	usba_ep[0].ep.ops = &usba_ep_ops;
 	usba_ep[0].ep.name = pdata->ep[0].name;
 	usba_ep[0].ep.maxpacket = pdata->ep[0].fifo_size;
-	usba_ep[0].udc = &the_udc;
+	usba_ep[0].udc = udc;
 	INIT_LIST_HEAD(&usba_ep[0].queue);
 	usba_ep[0].fifo_size = pdata->ep[0].fifo_size;
 	usba_ep[0].nr_banks = pdata->ep[0].nr_banks;
@@ -1924,7 +1924,7 @@ static int __init usba_udc_probe(struct platform_device *pdev)
 		ep->ep.ops = &usba_ep_ops;
 		ep->ep.name = pdata->ep[i].name;
 		ep->ep.maxpacket = pdata->ep[i].fifo_size;
-		ep->udc = &the_udc;
+		ep->udc = udc;
 		INIT_LIST_HEAD(&ep->queue);
 		ep->fifo_size = pdata->ep[i].fifo_size;
 		ep->nr_banks = pdata->ep[i].nr_banks;
Signature · 1 line
1.7.10.4
#4 lore raw

PATCH v4 3/7 USB: gadget: atmel_usba: add DT support

In reply to Jean-Christophe PLAGNIOL-VILLARD

Allow to compile the driver all the time if AT91 enabled.

Cc Nicolas Ferre <[email protected]>
Cc linux-usb at vger.kernel.org
---
 .../devicetree/bindings/usb/atmel-usb.txt          |   82 ++++++++
 drivers/usb/gadget/Kconfig                         |    2 +-
 drivers/usb/gadget/atmel_usba_udc.c                |  220 ++++++++++++++------
 drivers/usb/gadget/atmel_usba_udc.h                |    1 +
 4 files changed, 245 insertions(+), 60 deletions(-)
Documentation/devicetree/bindings/usb/atmel-usb.txt +82 -0
index 60bd215..55f51af 100644
@@ -47,3 +47,85 @@ usb1: gadget at fffa4000 {
 	interrupts = <10 4>;
 	atmel,vbus-gpio = <&pioC 5 0>;
 };
+
+Atmel High-Speed USB device controller
+
+Required properties:
+ - compatible: Should be "atmel,at91sam9rl-udc"
+ - reg: Address and length of the register set for the device
+ - interrupts: Should contain usba interrupt
+ - ep childnode: To specify the number of endpoints and their properties.
+
+Optional properties:
+ - atmel,vbus-gpio: If present, specifies a gpio that needs to be
+   activated for the bus to be powered.
+
+Required child node properties:
+ - name: Name of the endpoint.
+ - reg: Num of the endpoint.
+ - atmel,fifo-size: Size of the fifo.
+ - atmel,nb-banks: Number of banks.
+ - atmel,can-dma: Boolean to specify if the endpoint support DMA.
+ - atmel,can-isoc: Boolean to specify if the endpoint support ISOC.
+
+usb2: gadget at fff78000 {
+	#address-cells = <1>;
+	#size-cells = <0>;
+	compatible = "atmel,at91sam9rl-udc";
+	reg = <0x00600000 0x80000
+	       0xfff78000 0x400>;
+	interrupts = <27 4 0>;
+	atmel,vbus-gpio = <&pioB 19 0>;
+
+	ep0 {
+		reg = <0>;
+		atmel,fifo-size = <64>;
+		atmel,nb-banks = <1>;
+	};
+
+	ep1 {
+		reg = <1>;
+		atmel,fifo-size = <1024>;
+		atmel,nb-banks = <2>;
+		atmel,can-dma;
+		atmel,can-isoc;
+	};
+
+	ep2 {
+		reg = <2>;
+		atmel,fifo-size = <1024>;
+		atmel,nb-banks = <2>;
+		atmel,can-dma;
+		atmel,can-isoc;
+	};
+
+	ep3 {
+		reg = <3>;
+		atmel,fifo-size = <1024>;
+		atmel,nb-banks = <3>;
+		atmel,can-dma;
+	};
+
+	ep4 {
+		reg = <4>;
+		atmel,fifo-size = <1024>;
+		atmel,nb-banks = <3>;
+		atmel,can-dma;
+	};
+
+	ep5 {
+		reg = <5>;
+		atmel,fifo-size = <1024>;
+		atmel,nb-banks = <3>;
+		atmel,can-dma;
+		atmel,can-isoc;
+	};
+
+	ep6 {
+		reg = <6>;
+		atmel,fifo-size = <1024>;
+		atmel,nb-banks = <3>;
+		atmel,can-dma;
+		atmel,can-isoc;
+	};
+};
drivers/usb/gadget/Kconfig +1 -1
index 83300d9..5e47d50 100644
@@ -156,7 +156,7 @@ config USB_LPC32XX
 
 config USB_ATMEL_USBA
 	tristate "Atmel USBA"
-	depends on AVR32 || ARCH_AT91SAM9RL || ARCH_AT91SAM9G45
+	depends on AVR32 || ARCH_AT91
 	help
 	  USBA is the integrated high-speed USB Device controller on
 	  the AT32AP700x, some AT91SAM9 and AT91CAP9 processors from Atmel.
drivers/usb/gadget/atmel_usba_udc.c +161 -59

304 lines not on this page · raw message

drivers/usb/gadget/atmel_usba_udc.h +1 -0
index 0841986..2922db5 100644
@@ -317,6 +317,7 @@ struct usba_udc {
 	int irq;
 	int vbus_pin;
 	int vbus_pin_inverted;
+	int num_ep;
 	struct clk *pclk;
 	struct clk *hclk;
 	struct usba_ep *usba_ep;
Signature · 1 line
1.7.10.4
#6 lore raw

PATCH v4 4/7 ARM: at91: sam9x5 add udc DT support

In reply to Jean-Christophe PLAGNIOL-VILLARD
---
 arch/arm/boot/dts/at91sam9x5.dtsi |   62 +++++++++++++++++++++++++++++++++++++
 arch/arm/mach-at91/at91sam9x5.c   |    2 ++
 2 files changed, 64 insertions(+)
arch/arm/boot/dts/at91sam9x5.dtsi +62 -0
index af91599..01a815d 100644
@@ -645,6 +645,68 @@
 				status = "disabled";
 			};
 
+			usb2: gadget at f803c000 {
+				#address-cells = <1>;
+				#size-cells = <0>;
+				compatible = "atmel,at91sam9rl-udc";
+				reg = <0x00500000 0x80000
+				       0xf803c000 0x400>;
+				interrupts = <23 IRQ_TYPE_LEVEL_HIGH 0>;
+				status = "disabled";
+
+				ep0 {
+					reg = <0>;
+					atmel,fifo-size = <64>;
+					atmel,nb-banks = <1>;
+				};
+
+				ep1 {
+					reg = <1>;
+					atmel,fifo-size = <1024>;
+					atmel,nb-banks = <2>;
+					atmel,can-dma;
+					atmel,can-isoc;
+				};
+
+				ep2 {
+					reg = <2>;
+					atmel,fifo-size = <1024>;
+					atmel,nb-banks = <2>;
+					atmel,can-dma;
+					atmel,can-isoc;
+				};
+
+				ep3 {
+					reg = <3>;
+					atmel,fifo-size = <1024>;
+					atmel,nb-banks = <3>;
+					atmel,can-dma;
+				};
+
+				ep4 {
+					reg = <4>;
+					atmel,fifo-size = <1024>;
+					atmel,nb-banks = <3>;
+					atmel,can-dma;
+				};
+
+				ep5 {
+					reg = <5>;
+					atmel,fifo-size = <1024>;
+					atmel,nb-banks = <3>;
+					atmel,can-dma;
+					atmel,can-isoc;
+				};
+
+				ep6 {
+					reg = <6>;
+					atmel,fifo-size = <1024>;
+					atmel,nb-banks = <3>;
+					atmel,can-dma;
+					atmel,can-isoc;
+				};
+			};
+
 			rtc at fffffeb0 {
 				compatible = "atmel,at91rm9200-rtc";
 				reg = <0xfffffeb0 0x40>;
arch/arm/mach-at91/at91sam9x5.c +2 -0
index e631fec..2abee66 100644
@@ -249,6 +249,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("hclk", "600000.ohci", &uhphs_clk),
 	CLKDEV_CON_DEV_ID("ohci_clk", "600000.ohci", &uhphs_clk),
 	CLKDEV_CON_DEV_ID("ehci_clk", "700000.ehci", &uhphs_clk),
+	CLKDEV_CON_DEV_ID("hclk", "500000.gadget", &utmi_clk),
+	CLKDEV_CON_DEV_ID("pclk", "500000.gadget", &udphs_clk),
 };
 
 /*
Signature · 1 line
1.7.10.4
#7 lore raw

PATCH v4 5/7 ARM: at91: sam9x5ek add udc DT support

In reply to Jean-Christophe PLAGNIOL-VILLARD
---
 arch/arm/boot/dts/at91sam9x5ek.dtsi |    5 +++++
 1 file changed, 5 insertions(+)
arch/arm/boot/dts/at91sam9x5ek.dtsi +5 -0
index 19c8ebb..5e10027 100644
@@ -52,6 +52,11 @@
 				status = "okay";
 			};
 
+			usb2: gadget at f803c000 {
+				atmel,vbus-gpio = <&pioB 16 GPIO_ACTIVE_HIGH>;
+				status = "okay";
+			};
+
 			i2c0: i2c at f8010000 {
 				status = "okay";
 			};
Signature · 1 line
1.7.10.4
#8 lore raw

PATCH v4 6/7 ARM: at91: sam9g45 add udc DT support

In reply to Jean-Christophe PLAGNIOL-VILLARD
---
 arch/arm/boot/dts/at91sam9g45.dtsi |   62 ++++++++++++++++++++++++++++++++++++
 arch/arm/mach-at91/at91sam9g45.c   |    2 ++
 2 files changed, 64 insertions(+)
arch/arm/boot/dts/at91sam9g45.dtsi +62 -0
index f0091af..fccc488 100644
@@ -582,6 +582,68 @@
 				pinctrl-0 = <&pinctrl_spi1>;
 				status = "disabled";
 			};
+
+			usb2: gadget at fff78000 {
+				#address-cells = <1>;
+				#size-cells = <0>;
+				compatible = "atmel,at91sam9rl-udc";
+				reg = <0x00600000 0x80000
+				       0xfff78000 0x400>;
+				interrupts = <27 IRQ_TYPE_LEVEL_HIGH 0>;
+				status = "disabled";
+
+				ep0 {
+					reg = <0>;
+					atmel,fifo-size = <64>;
+					atmel,nb-banks = <1>;
+				};
+
+				ep1 {
+					reg = <1>;
+					atmel,fifo-size = <1024>;
+					atmel,nb-banks = <2>;
+					atmel,can-dma;
+					atmel,can-isoc;
+				};
+
+				ep2 {
+					reg = <2>;
+					atmel,fifo-size = <1024>;
+					atmel,nb-banks = <2>;
+					atmel,can-dma;
+					atmel,can-isoc;
+				};
+
+				ep3 {
+					reg = <3>;
+					atmel,fifo-size = <1024>;
+					atmel,nb-banks = <3>;
+					atmel,can-dma;
+				};
+
+				ep4 {
+					reg = <4>;
+					atmel,fifo-size = <1024>;
+					atmel,nb-banks = <3>;
+					atmel,can-dma;
+				};
+
+				ep5 {
+					reg = <5>;
+					atmel,fifo-size = <1024>;
+					atmel,nb-banks = <3>;
+					atmel,can-dma;
+					atmel,can-isoc;
+				};
+
+				ep6 {
+					reg = <6>;
+					atmel,fifo-size = <1024>;
+					atmel,nb-banks = <3>;
+					atmel,can-dma;
+					atmel,can-isoc;
+				};
+			};
 		};
 
 		nand0: nand at 40000000 {
arch/arm/mach-at91/at91sam9g45.c +2 -0
index 8b7fce0..95a418a 100644
@@ -266,6 +266,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID(NULL, "fff88000.i2c", &twi1_clk),
 	CLKDEV_CON_DEV_ID("spi_clk", "fffa4000.spi", &spi0_clk),
 	CLKDEV_CON_DEV_ID("spi_clk", "fffa8000.spi", &spi1_clk),
+	CLKDEV_CON_DEV_ID("hclk", "600000.gadget", &utmi_clk),
+	CLKDEV_CON_DEV_ID("pclk", "600000.gadget", &udphs_clk),
 	/* fake hclk clock */
 	CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &uhphs_clk),
 	CLKDEV_CON_DEV_ID(NULL, "fffff200.gpio", &pioA_clk),
Signature · 1 line
1.7.10.4
#9 lore raw

PATCH v4 7/7 ARM: at91: sam9m10g45ek add udc DT support

In reply to Jean-Christophe PLAGNIOL-VILLARD
---
 arch/arm/boot/dts/at91sam9m10g45ek.dts |    5 +++++
 1 file changed, 5 insertions(+)
arch/arm/boot/dts/at91sam9m10g45ek.dts +5 -0
index 89c50d1..17665ef 100644
@@ -112,6 +112,11 @@
 					reg = <0>;
 				};
 			};
+
+			usb2: gadget at fff78000 {
+				atmel,vbus-gpio = <&pioB 19 GPIO_ACTIVE_HIGH>;
+				status = "okay";
+			};
 		};
 
 		nand0: nand at 40000000 {
Signature · 1 line
1.7.10.4
#10 lore raw

PATCH 1/7 USB: gadget: atmel_usba: move global struct usba_ep usba_ep to struct usba_udc

In reply to Jean-Christophe PLAGNIOL-VILLARD

Hi J,

Quoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD

so we can have multiple usb gadget instance

Cc Nicolas Ferre <[email protected]>
Cc linux-usb at vger.kernel.org

For this series, test OK on at91sam9m10g45ek and at91sam9x5ek board

PS: When do testing, we need build in or choose as module: "Device Drivers ---> Generic Target Core Mod (TCM) and ConfigFS infrastructure"

Best Regards,
Bo Shen

#13 lore raw

v4 cover ARM: at91: dt: add USBA support

In reply to Jean-Christophe PLAGNIOL-VILLARD

Hi Felipe,

if it's ok with you I send the patch series via at91 with the DT

Best Regards,
J.

Quoted 51 lines · Jean-Christophe PLAGNIOL-VILLARD

HI,

v4:
fix multi instance support

v3:
rebase againt 3.10-rc1 + dt macro cleanup

This patch serie finish to add the usb device support to dt for at91 with the usba support present on the last at91 generation since sam9g45

The following changes since commit b3f442b0eedbc20b5ce3f4a96530588d14901199:

ARM: at91: udpate defconfigs (2013-05-17 15:05:08 +0200)

are available in the git repository at:

git://github.com/at91linux/linux-at91.git j/for-3.11-usba

for you to fetch changes up to 910026a08e2c2205953f2507cc11f4822998989b:

ARM: at91: sam9m10g45ek add udc DT support (2013-05-20 23:52:17 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (7):
USB: gadget: atmel_usba: move global struct usba_ep usba_ep to struct usba_udc
USB: gadget: atmel_usba: allow multi instance
USB: gadget: atmel_usba: add DT support
ARM: at91: sam9x5 add udc DT support
ARM: at91: sam9x5ek add udc DT support
ARM: at91: sam9g45 add udc DT support
ARM: at91: sam9m10g45ek add udc DT support

 Documentation/devicetree/bindings/usb/atmel-usb.txt |   82 ++++++++++++++++++++++++++++++
 arch/arm/boot/dts/at91sam9g45.dtsi                  |   62 +++++++++++++++++++++++
 arch/arm/boot/dts/at91sam9m10g45ek.dts              |    5 ++
 arch/arm/boot/dts/at91sam9x5.dtsi                   |   62 +++++++++++++++++++++++
 arch/arm/boot/dts/at91sam9x5ek.dtsi                 |    5 ++
 arch/arm/mach-at91/at91sam9g45.c                    |    2 +
 arch/arm/mach-at91/at91sam9x5.c                     |    2 +
 drivers/usb/gadget/Kconfig                          |    2 +-
 drivers/usb/gadget/atmel_usba_udc.c                 |  264 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------
 drivers/usb/gadget/atmel_usba_udc.h                 |    2 +
 10 files changed, 407 insertions(+), 81 deletions(-)

Best Regards,
J.
_______________________________________________
devicetree-discuss mailing list
devicetree-discuss at lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss

#11 lore raw

PATCH 1/7 USB: gadget: atmel_usba: move global struct usba_ep usba_ep to struct usba_udc

In reply to Bo Shen

On 23/05/2013 04:23, Bo Shen :

Quoted 11 lines

Hi J,

Quoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD

so we can have multiple usb gadget instance

Cc Nicolas Ferre <[email protected]>
Cc linux-usb at vger.kernel.org

For this series, test OK on at91sam9m10g45ek and at91sam9x5ek board

After reading this v4 series, it seems good. So, on the whole series:

Quoted 2 lines

PS: When do testing, we need build in or choose as module: "Device Drivers ---> Generic Target Core Mod (TCM) and ConfigFS infrastructure"

Thanks a lot to you, Bo and Jean-Christophe.

Bye,

Signature · 1 line
Nicolas Ferre
#3 lore raw

PATCH 2/7 USB: gadget: atmel_usba: allow multi instance

In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD

drop static struct usba_udc the_udc

Cc Nicolas Ferre <[email protected]>
Cc linux-usb at vger.kernel.org
Quoted 96 lines
---
 drivers/usb/gadget/atmel_usba_udc.c |   36 +++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/usb/gadget/atmel_usba_udc.c +18 -18
index d2ffd04..eea57a3 100644
@@ -27,9 +27,6 @@
 
 #include "atmel_usba_udc.h"
 
-
-static struct usba_udc the_udc;
-
 #ifdef CONFIG_USB_GADGET_DEBUG_FS
 #include <linux/debugfs.h>
 #include <linux/uaccess.h>
@@ -1013,16 +1010,13 @@ static void nop_release(struct device *dev)
 
 }
 
-static struct usba_udc the_udc = {
-	.gadget	= {
-		.ops		= &usba_udc_ops,
-		.ep_list	= LIST_HEAD_INIT(the_udc.gadget.ep_list),
-		.max_speed	= USB_SPEED_HIGH,
-		.name		= "atmel_usba_udc",
-		.dev	= {
-			.init_name	= "gadget",
-			.release	= nop_release,
-		},
+struct usb_gadget usba_gadget_template = {
+	.ops		= &usba_udc_ops,
+	.max_speed	= USB_SPEED_HIGH,
+	.name		= "atmel_usba_udc",
+	.dev	= {
+		.init_name	= "gadget",
+		.release	= nop_release,
 	},
 };
 
@@ -1839,10 +1833,17 @@ static int __init usba_udc_probe(struct platform_device *pdev)
 	struct usba_platform_data *pdata = pdev->dev.platform_data;
 	struct resource *regs, *fifo;
 	struct clk *pclk, *hclk;
-	struct usba_udc *udc = &the_udc;
+	struct usba_udc *udc;
 	static struct usba_ep *usba_ep;
 	int irq, ret, i;
 
+	udc = devm_kzalloc(&pdev->dev, sizeof(*udc), GFP_KERNEL);
+	if (!udc)
+		return -ENOMEM;
+
+	udc->gadget = usba_gadget_template;
+	INIT_LIST_HEAD(&udc->gadget.ep_list);
+
 	regs = platform_get_resource(pdev, IORESOURCE_MEM, CTRL_IOMEM_ID);
 	fifo = platform_get_resource(pdev, IORESOURCE_MEM, FIFO_IOMEM_ID);
 	if (!regs || !fifo || !pdata)
@@ -1897,8 +1898,7 @@ static int __init usba_udc_probe(struct platform_device *pdev)
 		goto err_alloc_ep;
 
 	udc->usba_ep = usba_ep;
-
-	the_udc.gadget.ep0 = &usba_ep[0].ep;
+	udc->gadget.ep0 = &usba_ep[0].ep;
 
 	INIT_LIST_HEAD(&usba_ep[0].ep.ep_list);
 	usba_ep[0].ep_regs = udc->regs + USBA_EPT_BASE(0);
@@ -1907,7 +1907,7 @@ static int __init usba_udc_probe(struct platform_device *pdev)
 	usba_ep[0].ep.ops = &usba_ep_ops;
 	usba_ep[0].ep.name = pdata->ep[0].name;
 	usba_ep[0].ep.maxpacket = pdata->ep[0].fifo_size;
-	usba_ep[0].udc = &the_udc;
+	usba_ep[0].udc = udc;
 	INIT_LIST_HEAD(&usba_ep[0].queue);
 	usba_ep[0].fifo_size = pdata->ep[0].fifo_size;
 	usba_ep[0].nr_banks = pdata->ep[0].nr_banks;
@@ -1924,7 +1924,7 @@ static int __init usba_udc_probe(struct platform_device *pdev)
 		ep->ep.ops = &usba_ep_ops;
 		ep->ep.name = pdata->ep[i].name;
 		ep->ep.maxpacket = pdata->ep[i].fifo_size;
-		ep->udc = &the_udc;
+		ep->udc = udc;
 		INIT_LIST_HEAD(&ep->queue);
 		ep->fifo_size = pdata->ep[i].fifo_size;
 		ep->nr_banks = pdata->ep[i].nr_banks;
Signature · 6 lines
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130523/4d1de033/attachment-0001.sig>
#12 lore raw

PATCH 1/7 USB: gadget: atmel_usba: move global struct usba_ep usba_ep to struct usba_udc

In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD

so we can have multiple usb gadget instance

Cc Nicolas Ferre <[email protected]>
Cc linux-usb at vger.kernel.org
Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130523/ae696055/attachment.sig>
#5 lore raw

PATCH 3/7 USB: gadget: atmel_usba: add DT support

In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD

Allow to compile the driver all the time if AT91 enabled.

Cc Nicolas Ferre <[email protected]>
Cc linux-usb at vger.kernel.org
Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130523/570679ff/attachment.sig>