USB: gadget: atmel_usba: move global struct usba_ep usba_ep to struct usba_udc
Subsystems (5)
PATCH 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
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
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
@@ -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
@@ -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
PATCH 2/7 USB: gadget: atmel_usba: allow multi instance
drop static struct usba_udc the_udc
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
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
@@ -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
PATCH 3/7 USB: gadget: atmel_usba: add DT support
In reply to Jean-Christophe PLAGNIOL-VILLARDAllow to compile the driver all the time if AT91 enabled.
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
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
@@ -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
@@ -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
@@ -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
PATCH 4/7 ARM: at91: sam9x5 add udc DT support
In reply to Jean-Christophe PLAGNIOL-VILLARDSigned-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Cc Nicolas Ferre <[email protected]>
--- 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
@@ -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
@@ -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