diff options
author | Olof Johansson <olof@lixom.net> | 2013-06-14 21:58:28 -0400 |
---|---|---|
committer | Olof Johansson <olof@lixom.net> | 2013-06-14 21:58:28 -0400 |
commit | 1247034ea6515d25a80220915820aa61891a78a1 (patch) | |
tree | 4cb5a05462bc5ef4c36ca8ef154673e3a7d22198 /drivers/usb/gadget/atmel_usba_udc.c | |
parent | 38d77ff90a47d198d2fd3ebd766ee84eaa71a0d2 (diff) | |
parent | 4a3ae9324ebeb9715369d2bca799bfd7dcff6dd7 (diff) |
Merge tag 'at91-drivers' of git://github.com/at91linux/linux-at91 into next/drivers
From Nicolas Ferre:
Adding the DT support to USB gadget High-Speed aka usba.
* tag 'at91-drivers' of git://github.com/at91linux/linux-at91:
USB: gadget: atmel_usba: add DT support
USB: gadget: atmel_usba: allow multi instance
USB: gadget: atmel_usba: move global struct usba_ep usba_ep to struct usba_udc
ARM: at91: udpate defconfigs
ARM: at91: dt: switch to standard IRQ flag defines
ARM: at91: dt: switch to pinctrl to pre-processor
ARM: at91: dt: add pinctrl pre-processor define
ARM: at91: dt: switch to standard GPIO flag defines.
ARM: at91: dt: use #include for all device trees
Signed-off-by: Olof Johansson <olof@lixom.net>
Conflicts:
arch/arm/boot/dts/at91sam9260.dtsi
arch/arm/boot/dts/sama5d3.dtsi
Diffstat (limited to 'drivers/usb/gadget/atmel_usba_udc.c')
-rw-r--r-- | drivers/usb/gadget/atmel_usba_udc.c | 264 |
1 files changed, 184 insertions, 80 deletions
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c index 5a5128a226f7..1d9722203ca6 100644 --- a/drivers/usb/gadget/atmel_usba_udc.c +++ b/drivers/usb/gadget/atmel_usba_udc.c | |||
@@ -22,15 +22,13 @@ | |||
22 | #include <linux/usb/atmel_usba_udc.h> | 22 | #include <linux/usb/atmel_usba_udc.h> |
23 | #include <linux/delay.h> | 23 | #include <linux/delay.h> |
24 | #include <linux/platform_data/atmel.h> | 24 | #include <linux/platform_data/atmel.h> |
25 | #include <linux/of.h> | ||
26 | #include <linux/of_gpio.h> | ||
25 | 27 | ||
26 | #include <asm/gpio.h> | 28 | #include <asm/gpio.h> |
27 | 29 | ||
28 | #include "atmel_usba_udc.h" | 30 | #include "atmel_usba_udc.h" |
29 | 31 | ||
30 | |||
31 | static struct usba_udc the_udc; | ||
32 | static struct usba_ep *usba_ep; | ||
33 | |||
34 | #ifdef CONFIG_USB_GADGET_DEBUG_FS | 32 | #ifdef CONFIG_USB_GADGET_DEBUG_FS |
35 | #include <linux/debugfs.h> | 33 | #include <linux/debugfs.h> |
36 | #include <linux/uaccess.h> | 34 | #include <linux/uaccess.h> |
@@ -1014,16 +1012,13 @@ static void nop_release(struct device *dev) | |||
1014 | 1012 | ||
1015 | } | 1013 | } |
1016 | 1014 | ||
1017 | static struct usba_udc the_udc = { | 1015 | struct usb_gadget usba_gadget_template = { |
1018 | .gadget = { | 1016 | .ops = &usba_udc_ops, |
1019 | .ops = &usba_udc_ops, | 1017 | .max_speed = USB_SPEED_HIGH, |
1020 | .ep_list = LIST_HEAD_INIT(the_udc.gadget.ep_list), | 1018 | .name = "atmel_usba_udc", |
1021 | .max_speed = USB_SPEED_HIGH, | 1019 | .dev = { |
1022 | .name = "atmel_usba_udc", | 1020 | .init_name = "gadget", |
1023 | .dev = { | 1021 | .release = nop_release, |
1024 | .init_name = "gadget", | ||
1025 | .release = nop_release, | ||
1026 | }, | ||
1027 | }, | 1022 | }, |
1028 | }; | 1023 | }; |
1029 | 1024 | ||
@@ -1147,7 +1142,7 @@ static int do_test_mode(struct usba_udc *udc) | |||
1147 | * Test_SE0_NAK: Force high-speed mode and set up ep0 | 1142 | * Test_SE0_NAK: Force high-speed mode and set up ep0 |
1148 | * for Bulk IN transfers | 1143 | * for Bulk IN transfers |
1149 | */ | 1144 | */ |
1150 | ep = &usba_ep[0]; | 1145 | ep = &udc->usba_ep[0]; |
1151 | usba_writel(udc, TST, | 1146 | usba_writel(udc, TST, |
1152 | USBA_BF(SPEED_CFG, USBA_SPEED_CFG_FORCE_HIGH)); | 1147 | USBA_BF(SPEED_CFG, USBA_SPEED_CFG_FORCE_HIGH)); |
1153 | usba_ep_writel(ep, CFG, | 1148 | usba_ep_writel(ep, CFG, |
@@ -1165,7 +1160,7 @@ static int do_test_mode(struct usba_udc *udc) | |||
1165 | break; | 1160 | break; |
1166 | case 0x0400: | 1161 | case 0x0400: |
1167 | /* Test_Packet */ | 1162 | /* Test_Packet */ |
1168 | ep = &usba_ep[0]; | 1163 | ep = &udc->usba_ep[0]; |
1169 | usba_ep_writel(ep, CFG, | 1164 | usba_ep_writel(ep, CFG, |
1170 | USBA_BF(EPT_SIZE, USBA_EPT_SIZE_64) | 1165 | USBA_BF(EPT_SIZE, USBA_EPT_SIZE_64) |
1171 | | USBA_EPT_DIR_IN | 1166 | | USBA_EPT_DIR_IN |
@@ -1668,7 +1663,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid) | |||
1668 | 1663 | ||
1669 | for (i = 1; i < USBA_NR_ENDPOINTS; i++) | 1664 | for (i = 1; i < USBA_NR_ENDPOINTS; i++) |
1670 | if (dma_status & (1 << i)) | 1665 | if (dma_status & (1 << i)) |
1671 | usba_dma_irq(udc, &usba_ep[i]); | 1666 | usba_dma_irq(udc, &udc->usba_ep[i]); |
1672 | } | 1667 | } |
1673 | 1668 | ||
1674 | ep_status = USBA_BFEXT(EPT_INT, status); | 1669 | ep_status = USBA_BFEXT(EPT_INT, status); |
@@ -1677,10 +1672,10 @@ static irqreturn_t usba_udc_irq(int irq, void *devid) | |||
1677 | 1672 | ||
1678 | for (i = 0; i < USBA_NR_ENDPOINTS; i++) | 1673 | for (i = 0; i < USBA_NR_ENDPOINTS; i++) |
1679 | if (ep_status & (1 << i)) { | 1674 | if (ep_status & (1 << i)) { |
1680 | if (ep_is_control(&usba_ep[i])) | 1675 | if (ep_is_control(&udc->usba_ep[i])) |
1681 | usba_control_irq(udc, &usba_ep[i]); | 1676 | usba_control_irq(udc, &udc->usba_ep[i]); |
1682 | else | 1677 | else |
1683 | usba_ep_irq(udc, &usba_ep[i]); | 1678 | usba_ep_irq(udc, &udc->usba_ep[i]); |
1684 | } | 1679 | } |
1685 | } | 1680 | } |
1686 | 1681 | ||
@@ -1705,7 +1700,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid) | |||
1705 | DBG(DBG_BUS, "%s bus reset detected\n", | 1700 | DBG(DBG_BUS, "%s bus reset detected\n", |
1706 | usb_speed_string(udc->gadget.speed)); | 1701 | usb_speed_string(udc->gadget.speed)); |
1707 | 1702 | ||
1708 | ep0 = &usba_ep[0]; | 1703 | ep0 = &udc->usba_ep[0]; |
1709 | ep0->ep.desc = &usba_ep0_desc; | 1704 | ep0->ep.desc = &usba_ep0_desc; |
1710 | ep0->state = WAIT_FOR_SETUP; | 1705 | ep0->state = WAIT_FOR_SETUP; |
1711 | usba_ep_writel(ep0, CFG, | 1706 | usba_ep_writel(ep0, CFG, |
@@ -1835,17 +1830,158 @@ static int atmel_usba_stop(struct usb_gadget *gadget, | |||
1835 | return 0; | 1830 | return 0; |
1836 | } | 1831 | } |
1837 | 1832 | ||
1838 | static int __init usba_udc_probe(struct platform_device *pdev) | 1833 | #ifdef CONFIG_OF |
1834 | static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev, | ||
1835 | struct usba_udc *udc) | ||
1836 | { | ||
1837 | u32 val; | ||
1838 | const char *name; | ||
1839 | enum of_gpio_flags flags; | ||
1840 | struct device_node *np = pdev->dev.of_node; | ||
1841 | struct device_node *pp; | ||
1842 | int i, ret; | ||
1843 | struct usba_ep *eps, *ep; | ||
1844 | |||
1845 | udc->num_ep = 0; | ||
1846 | |||
1847 | udc->vbus_pin = of_get_named_gpio_flags(np, "atmel,vbus-gpio", 0, | ||
1848 | &flags); | ||
1849 | udc->vbus_pin_inverted = (flags & OF_GPIO_ACTIVE_LOW) ? 1 : 0; | ||
1850 | |||
1851 | pp = NULL; | ||
1852 | while ((pp = of_get_next_child(np, pp))) | ||
1853 | udc->num_ep++; | ||
1854 | |||
1855 | eps = devm_kzalloc(&pdev->dev, sizeof(struct usba_ep) * udc->num_ep, | ||
1856 | GFP_KERNEL); | ||
1857 | if (!eps) | ||
1858 | return ERR_PTR(-ENOMEM); | ||
1859 | |||
1860 | udc->gadget.ep0 = &eps[0].ep; | ||
1861 | |||
1862 | INIT_LIST_HEAD(&eps[0].ep.ep_list); | ||
1863 | |||
1864 | pp = NULL; | ||
1865 | i = 0; | ||
1866 | while ((pp = of_get_next_child(np, pp))) { | ||
1867 | ep = &eps[i]; | ||
1868 | |||
1869 | ret = of_property_read_u32(pp, "reg", &val); | ||
1870 | if (ret) { | ||
1871 | dev_err(&pdev->dev, "of_probe: reg error(%d)\n", ret); | ||
1872 | goto err; | ||
1873 | } | ||
1874 | ep->index = val; | ||
1875 | |||
1876 | ret = of_property_read_u32(pp, "atmel,fifo-size", &val); | ||
1877 | if (ret) { | ||
1878 | dev_err(&pdev->dev, "of_probe: fifo-size error(%d)\n", ret); | ||
1879 | goto err; | ||
1880 | } | ||
1881 | ep->fifo_size = val; | ||
1882 | |||
1883 | ret = of_property_read_u32(pp, "atmel,nb-banks", &val); | ||
1884 | if (ret) { | ||
1885 | dev_err(&pdev->dev, "of_probe: nb-banks error(%d)\n", ret); | ||
1886 | goto err; | ||
1887 | } | ||
1888 | ep->nr_banks = val; | ||
1889 | |||
1890 | ep->can_dma = of_property_read_bool(pp, "atmel,can-dma"); | ||
1891 | ep->can_isoc = of_property_read_bool(pp, "atmel,can-isoc"); | ||
1892 | |||
1893 | ret = of_property_read_string(pp, "name", &name); | ||
1894 | ep->ep.name = name; | ||
1895 | |||
1896 | ep->ep_regs = udc->regs + USBA_EPT_BASE(i); | ||
1897 | ep->dma_regs = udc->regs + USBA_DMA_BASE(i); | ||
1898 | ep->fifo = udc->fifo + USBA_FIFO_BASE(i); | ||
1899 | ep->ep.ops = &usba_ep_ops; | ||
1900 | ep->ep.maxpacket = ep->fifo_size; | ||
1901 | ep->udc = udc; | ||
1902 | INIT_LIST_HEAD(&ep->queue); | ||
1903 | |||
1904 | if (i) | ||
1905 | list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); | ||
1906 | |||
1907 | i++; | ||
1908 | } | ||
1909 | |||
1910 | return eps; | ||
1911 | err: | ||
1912 | return ERR_PTR(ret); | ||
1913 | } | ||
1914 | #else | ||
1915 | static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev, | ||
1916 | struct usba_udc *udc) | ||
1917 | { | ||
1918 | return ERR_PTR(-ENOSYS); | ||
1919 | } | ||
1920 | #endif | ||
1921 | |||
1922 | static struct usba_ep * usba_udc_pdata(struct platform_device *pdev, | ||
1923 | struct usba_udc *udc) | ||
1839 | { | 1924 | { |
1840 | struct usba_platform_data *pdata = pdev->dev.platform_data; | 1925 | struct usba_platform_data *pdata = pdev->dev.platform_data; |
1926 | struct usba_ep *eps; | ||
1927 | int i; | ||
1928 | |||
1929 | if (!pdata) | ||
1930 | return ERR_PTR(-ENXIO); | ||
1931 | |||
1932 | eps = devm_kzalloc(&pdev->dev, sizeof(struct usba_ep) * pdata->num_ep, | ||
1933 | GFP_KERNEL); | ||
1934 | if (!eps) | ||
1935 | return ERR_PTR(-ENOMEM); | ||
1936 | |||
1937 | udc->gadget.ep0 = &eps[0].ep; | ||
1938 | |||
1939 | udc->vbus_pin = pdata->vbus_pin; | ||
1940 | udc->vbus_pin_inverted = pdata->vbus_pin_inverted; | ||
1941 | udc->num_ep = pdata->num_ep; | ||
1942 | |||
1943 | INIT_LIST_HEAD(&eps[0].ep.ep_list); | ||
1944 | |||
1945 | for (i = 0; i < pdata->num_ep; i++) { | ||
1946 | struct usba_ep *ep = &eps[i]; | ||
1947 | |||
1948 | ep->ep_regs = udc->regs + USBA_EPT_BASE(i); | ||
1949 | ep->dma_regs = udc->regs + USBA_DMA_BASE(i); | ||
1950 | ep->fifo = udc->fifo + USBA_FIFO_BASE(i); | ||
1951 | ep->ep.ops = &usba_ep_ops; | ||
1952 | ep->ep.name = pdata->ep[i].name; | ||
1953 | ep->fifo_size = ep->ep.maxpacket = pdata->ep[i].fifo_size; | ||
1954 | ep->udc = udc; | ||
1955 | INIT_LIST_HEAD(&ep->queue); | ||
1956 | ep->nr_banks = pdata->ep[i].nr_banks; | ||
1957 | ep->index = pdata->ep[i].index; | ||
1958 | ep->can_dma = pdata->ep[i].can_dma; | ||
1959 | ep->can_isoc = pdata->ep[i].can_isoc; | ||
1960 | |||
1961 | if (i) | ||
1962 | list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); | ||
1963 | } | ||
1964 | |||
1965 | return eps; | ||
1966 | } | ||
1967 | |||
1968 | static int __init usba_udc_probe(struct platform_device *pdev) | ||
1969 | { | ||
1841 | struct resource *regs, *fifo; | 1970 | struct resource *regs, *fifo; |
1842 | struct clk *pclk, *hclk; | 1971 | struct clk *pclk, *hclk; |
1843 | struct usba_udc *udc = &the_udc; | 1972 | struct usba_udc *udc; |
1844 | int irq, ret, i; | 1973 | int irq, ret, i; |
1845 | 1974 | ||
1975 | udc = devm_kzalloc(&pdev->dev, sizeof(*udc), GFP_KERNEL); | ||
1976 | if (!udc) | ||
1977 | return -ENOMEM; | ||
1978 | |||
1979 | udc->gadget = usba_gadget_template; | ||
1980 | INIT_LIST_HEAD(&udc->gadget.ep_list); | ||
1981 | |||
1846 | regs = platform_get_resource(pdev, IORESOURCE_MEM, CTRL_IOMEM_ID); | 1982 | regs = platform_get_resource(pdev, IORESOURCE_MEM, CTRL_IOMEM_ID); |
1847 | fifo = platform_get_resource(pdev, IORESOURCE_MEM, FIFO_IOMEM_ID); | 1983 | fifo = platform_get_resource(pdev, IORESOURCE_MEM, FIFO_IOMEM_ID); |
1848 | if (!regs || !fifo || !pdata) | 1984 | if (!regs || !fifo) |
1849 | return -ENXIO; | 1985 | return -ENXIO; |
1850 | 1986 | ||
1851 | irq = platform_get_irq(pdev, 0); | 1987 | irq = platform_get_irq(pdev, 0); |
@@ -1891,46 +2027,14 @@ static int __init usba_udc_probe(struct platform_device *pdev) | |||
1891 | usba_writel(udc, CTRL, USBA_DISABLE_MASK); | 2027 | usba_writel(udc, CTRL, USBA_DISABLE_MASK); |
1892 | clk_disable(pclk); | 2028 | clk_disable(pclk); |
1893 | 2029 | ||
1894 | usba_ep = kzalloc(sizeof(struct usba_ep) * pdata->num_ep, | 2030 | if (pdev->dev.of_node) |
1895 | GFP_KERNEL); | 2031 | udc->usba_ep = atmel_udc_of_init(pdev, udc); |
1896 | if (!usba_ep) | 2032 | else |
1897 | goto err_alloc_ep; | 2033 | udc->usba_ep = usba_udc_pdata(pdev, udc); |
1898 | |||
1899 | the_udc.gadget.ep0 = &usba_ep[0].ep; | ||
1900 | |||
1901 | INIT_LIST_HEAD(&usba_ep[0].ep.ep_list); | ||
1902 | usba_ep[0].ep_regs = udc->regs + USBA_EPT_BASE(0); | ||
1903 | usba_ep[0].dma_regs = udc->regs + USBA_DMA_BASE(0); | ||
1904 | usba_ep[0].fifo = udc->fifo + USBA_FIFO_BASE(0); | ||
1905 | usba_ep[0].ep.ops = &usba_ep_ops; | ||
1906 | usba_ep[0].ep.name = pdata->ep[0].name; | ||
1907 | usba_ep[0].ep.maxpacket = pdata->ep[0].fifo_size; | ||
1908 | usba_ep[0].udc = &the_udc; | ||
1909 | INIT_LIST_HEAD(&usba_ep[0].queue); | ||
1910 | usba_ep[0].fifo_size = pdata->ep[0].fifo_size; | ||
1911 | usba_ep[0].nr_banks = pdata->ep[0].nr_banks; | ||
1912 | usba_ep[0].index = pdata->ep[0].index; | ||
1913 | usba_ep[0].can_dma = pdata->ep[0].can_dma; | ||
1914 | usba_ep[0].can_isoc = pdata->ep[0].can_isoc; | ||
1915 | |||
1916 | for (i = 1; i < pdata->num_ep; i++) { | ||
1917 | struct usba_ep *ep = &usba_ep[i]; | ||
1918 | |||
1919 | ep->ep_regs = udc->regs + USBA_EPT_BASE(i); | ||
1920 | ep->dma_regs = udc->regs + USBA_DMA_BASE(i); | ||
1921 | ep->fifo = udc->fifo + USBA_FIFO_BASE(i); | ||
1922 | ep->ep.ops = &usba_ep_ops; | ||
1923 | ep->ep.name = pdata->ep[i].name; | ||
1924 | ep->ep.maxpacket = pdata->ep[i].fifo_size; | ||
1925 | ep->udc = &the_udc; | ||
1926 | INIT_LIST_HEAD(&ep->queue); | ||
1927 | ep->fifo_size = pdata->ep[i].fifo_size; | ||
1928 | ep->nr_banks = pdata->ep[i].nr_banks; | ||
1929 | ep->index = pdata->ep[i].index; | ||
1930 | ep->can_dma = pdata->ep[i].can_dma; | ||
1931 | ep->can_isoc = pdata->ep[i].can_isoc; | ||
1932 | 2034 | ||
1933 | list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); | 2035 | if (IS_ERR(udc->usba_ep)) { |
2036 | ret = PTR_ERR(udc->usba_ep); | ||
2037 | goto err_alloc_ep; | ||
1934 | } | 2038 | } |
1935 | 2039 | ||
1936 | ret = request_irq(irq, usba_udc_irq, 0, "atmel_usba_udc", udc); | 2040 | ret = request_irq(irq, usba_udc_irq, 0, "atmel_usba_udc", udc); |
@@ -1941,16 +2045,12 @@ static int __init usba_udc_probe(struct platform_device *pdev) | |||
1941 | } | 2045 | } |
1942 | udc->irq = irq; | 2046 | udc->irq = irq; |
1943 | 2047 | ||
1944 | if (gpio_is_valid(pdata->vbus_pin)) { | 2048 | if (gpio_is_valid(udc->vbus_pin)) { |
1945 | if (!gpio_request(pdata->vbus_pin, "atmel_usba_udc")) { | 2049 | if (!devm_gpio_request(&pdev->dev, udc->vbus_pin, "atmel_usba_udc")) { |
1946 | udc->vbus_pin = pdata->vbus_pin; | ||
1947 | udc->vbus_pin_inverted = pdata->vbus_pin_inverted; | ||
1948 | |||
1949 | ret = request_irq(gpio_to_irq(udc->vbus_pin), | 2050 | ret = request_irq(gpio_to_irq(udc->vbus_pin), |
1950 | usba_vbus_irq, 0, | 2051 | usba_vbus_irq, 0, |
1951 | "atmel_usba_udc", udc); | 2052 | "atmel_usba_udc", udc); |
1952 | if (ret) { | 2053 | if (ret) { |
1953 | gpio_free(udc->vbus_pin); | ||
1954 | udc->vbus_pin = -ENODEV; | 2054 | udc->vbus_pin = -ENODEV; |
1955 | dev_warn(&udc->pdev->dev, | 2055 | dev_warn(&udc->pdev->dev, |
1956 | "failed to request vbus irq; " | 2056 | "failed to request vbus irq; " |
@@ -1969,20 +2069,17 @@ static int __init usba_udc_probe(struct platform_device *pdev) | |||
1969 | goto err_add_udc; | 2069 | goto err_add_udc; |
1970 | 2070 | ||
1971 | usba_init_debugfs(udc); | 2071 | usba_init_debugfs(udc); |
1972 | for (i = 1; i < pdata->num_ep; i++) | 2072 | for (i = 1; i < udc->num_ep; i++) |
1973 | usba_ep_init_debugfs(udc, &usba_ep[i]); | 2073 | usba_ep_init_debugfs(udc, &udc->usba_ep[i]); |
1974 | 2074 | ||
1975 | return 0; | 2075 | return 0; |
1976 | 2076 | ||
1977 | err_add_udc: | 2077 | err_add_udc: |
1978 | if (gpio_is_valid(pdata->vbus_pin)) { | 2078 | if (gpio_is_valid(udc->vbus_pin)) |
1979 | free_irq(gpio_to_irq(udc->vbus_pin), udc); | 2079 | free_irq(gpio_to_irq(udc->vbus_pin), udc); |
1980 | gpio_free(udc->vbus_pin); | ||
1981 | } | ||
1982 | 2080 | ||
1983 | free_irq(irq, udc); | 2081 | free_irq(irq, udc); |
1984 | err_request_irq: | 2082 | err_request_irq: |
1985 | kfree(usba_ep); | ||
1986 | err_alloc_ep: | 2083 | err_alloc_ep: |
1987 | iounmap(udc->fifo); | 2084 | iounmap(udc->fifo); |
1988 | err_map_fifo: | 2085 | err_map_fifo: |
@@ -1999,23 +2096,20 @@ static int __exit usba_udc_remove(struct platform_device *pdev) | |||
1999 | { | 2096 | { |
2000 | struct usba_udc *udc; | 2097 | struct usba_udc *udc; |
2001 | int i; | 2098 | int i; |
2002 | struct usba_platform_data *pdata = pdev->dev.platform_data; | ||
2003 | 2099 | ||
2004 | udc = platform_get_drvdata(pdev); | 2100 | udc = platform_get_drvdata(pdev); |
2005 | 2101 | ||
2006 | usb_del_gadget_udc(&udc->gadget); | 2102 | usb_del_gadget_udc(&udc->gadget); |
2007 | 2103 | ||
2008 | for (i = 1; i < pdata->num_ep; i++) | 2104 | for (i = 1; i < udc->num_ep; i++) |
2009 | usba_ep_cleanup_debugfs(&usba_ep[i]); | 2105 | usba_ep_cleanup_debugfs(&udc->usba_ep[i]); |
2010 | usba_cleanup_debugfs(udc); | 2106 | usba_cleanup_debugfs(udc); |
2011 | 2107 | ||
2012 | if (gpio_is_valid(udc->vbus_pin)) { | 2108 | if (gpio_is_valid(udc->vbus_pin)) { |
2013 | free_irq(gpio_to_irq(udc->vbus_pin), udc); | 2109 | free_irq(gpio_to_irq(udc->vbus_pin), udc); |
2014 | gpio_free(udc->vbus_pin); | ||
2015 | } | 2110 | } |
2016 | 2111 | ||
2017 | free_irq(udc->irq, udc); | 2112 | free_irq(udc->irq, udc); |
2018 | kfree(usba_ep); | ||
2019 | iounmap(udc->fifo); | 2113 | iounmap(udc->fifo); |
2020 | iounmap(udc->regs); | 2114 | iounmap(udc->regs); |
2021 | clk_put(udc->hclk); | 2115 | clk_put(udc->hclk); |
@@ -2024,11 +2118,21 @@ static int __exit usba_udc_remove(struct platform_device *pdev) | |||
2024 | return 0; | 2118 | return 0; |
2025 | } | 2119 | } |
2026 | 2120 | ||
2121 | #if defined(CONFIG_OF) | ||
2122 | static const struct of_device_id atmel_udc_dt_ids[] = { | ||
2123 | { .compatible = "atmel,at91sam9rl-udc" }, | ||
2124 | { /* sentinel */ } | ||
2125 | }; | ||
2126 | |||
2127 | MODULE_DEVICE_TABLE(of, atmel_udc_dt_ids); | ||
2128 | #endif | ||
2129 | |||
2027 | static struct platform_driver udc_driver = { | 2130 | static struct platform_driver udc_driver = { |
2028 | .remove = __exit_p(usba_udc_remove), | 2131 | .remove = __exit_p(usba_udc_remove), |
2029 | .driver = { | 2132 | .driver = { |
2030 | .name = "atmel_usba_udc", | 2133 | .name = "atmel_usba_udc", |
2031 | .owner = THIS_MODULE, | 2134 | .owner = THIS_MODULE, |
2135 | .of_match_table = of_match_ptr(atmel_udc_dt_ids), | ||
2032 | }, | 2136 | }, |
2033 | }; | 2137 | }; |
2034 | 2138 | ||