.. | .. |
---|
36 | 36 | #include <asm/byteorder.h> |
---|
37 | 37 | #include <asm/irq.h> |
---|
38 | 38 | #include <asm/unaligned.h> |
---|
39 | | -#include <mach/irqs.h> |
---|
40 | 39 | |
---|
41 | | -#include <mach/hardware.h> |
---|
42 | | - |
---|
43 | | -#include <plat/regs-udc.h> |
---|
44 | 40 | #include <linux/platform_data/usb-s3c2410_udc.h> |
---|
45 | 41 | |
---|
46 | | - |
---|
47 | 42 | #include "s3c2410_udc.h" |
---|
| 43 | +#include "s3c2410_udc_regs.h" |
---|
48 | 44 | |
---|
49 | 45 | #define DRIVER_DESC "S3C2410 USB Device Controller Gadget" |
---|
50 | 46 | #define DRIVER_AUTHOR "Herbert Pƶtzl <herbert@13thfloor.at>, " \ |
---|
.. | .. |
---|
57 | 53 | static struct clk *udc_clock; |
---|
58 | 54 | static struct clk *usb_bus_clock; |
---|
59 | 55 | static void __iomem *base_addr; |
---|
60 | | -static u64 rsrc_start; |
---|
61 | | -static u64 rsrc_len; |
---|
| 56 | +static int irq_usbd; |
---|
62 | 57 | static struct dentry *s3c2410_udc_debugfs_root; |
---|
63 | 58 | |
---|
64 | 59 | static inline u32 udc_read(u32 reg) |
---|
.. | .. |
---|
119 | 114 | } |
---|
120 | 115 | #endif |
---|
121 | 116 | |
---|
122 | | -static int s3c2410_udc_debugfs_seq_show(struct seq_file *m, void *p) |
---|
| 117 | +static int s3c2410_udc_debugfs_show(struct seq_file *m, void *p) |
---|
123 | 118 | { |
---|
124 | 119 | u32 addr_reg, pwr_reg, ep_int_reg, usb_int_reg; |
---|
125 | 120 | u32 ep_int_en_reg, usb_int_en_reg, ep0_csr; |
---|
.. | .. |
---|
168 | 163 | |
---|
169 | 164 | return 0; |
---|
170 | 165 | } |
---|
171 | | - |
---|
172 | | -static int s3c2410_udc_debugfs_fops_open(struct inode *inode, |
---|
173 | | - struct file *file) |
---|
174 | | -{ |
---|
175 | | - return single_open(file, s3c2410_udc_debugfs_seq_show, NULL); |
---|
176 | | -} |
---|
177 | | - |
---|
178 | | -static const struct file_operations s3c2410_udc_debugfs_fops = { |
---|
179 | | - .open = s3c2410_udc_debugfs_fops_open, |
---|
180 | | - .read = seq_read, |
---|
181 | | - .llseek = seq_lseek, |
---|
182 | | - .release = single_release, |
---|
183 | | - .owner = THIS_MODULE, |
---|
184 | | -}; |
---|
| 166 | +DEFINE_SHOW_ATTRIBUTE(s3c2410_udc_debugfs); |
---|
185 | 167 | |
---|
186 | 168 | /* io macros */ |
---|
187 | 169 | |
---|
.. | .. |
---|
321 | 303 | switch (idx) { |
---|
322 | 304 | default: |
---|
323 | 305 | idx = 0; |
---|
| 306 | + fallthrough; |
---|
324 | 307 | case 0: |
---|
325 | 308 | fifo_reg = S3C2410_UDC_EP0_FIFO_REG; |
---|
326 | 309 | break; |
---|
.. | .. |
---|
425 | 408 | switch (idx) { |
---|
426 | 409 | default: |
---|
427 | 410 | idx = 0; |
---|
| 411 | + fallthrough; |
---|
428 | 412 | case 0: |
---|
429 | 413 | fifo_reg = S3C2410_UDC_EP0_FIFO_REG; |
---|
430 | 414 | break; |
---|
.. | .. |
---|
846 | 830 | } |
---|
847 | 831 | } |
---|
848 | 832 | |
---|
849 | | -#include <mach/regs-irq.h> |
---|
850 | | - |
---|
851 | 833 | /* |
---|
852 | 834 | * s3c2410_udc_irq - interrupt handler |
---|
853 | 835 | */ |
---|
.. | .. |
---|
988 | 970 | } |
---|
989 | 971 | } |
---|
990 | 972 | |
---|
991 | | - dprintk(DEBUG_VERBOSE, "irq: %d s3c2410_udc_done.\n", IRQ_USBD); |
---|
| 973 | + dprintk(DEBUG_VERBOSE, "irq: %d s3c2410_udc_done.\n", irq_usbd); |
---|
992 | 974 | |
---|
993 | 975 | /* Restore old index */ |
---|
994 | 976 | udc_write(idx, S3C2410_UDC_INDEX_REG); |
---|
.. | .. |
---|
1281 | 1263 | static int s3c2410_udc_dequeue(struct usb_ep *_ep, struct usb_request *_req) |
---|
1282 | 1264 | { |
---|
1283 | 1265 | struct s3c2410_ep *ep = to_s3c2410_ep(_ep); |
---|
1284 | | - struct s3c2410_udc *udc; |
---|
1285 | 1266 | int retval = -EINVAL; |
---|
1286 | 1267 | unsigned long flags; |
---|
1287 | 1268 | struct s3c2410_request *req = NULL; |
---|
.. | .. |
---|
1293 | 1274 | |
---|
1294 | 1275 | if (!_ep || !_req) |
---|
1295 | 1276 | return retval; |
---|
1296 | | - |
---|
1297 | | - udc = to_s3c2410_udc(ep->gadget); |
---|
1298 | 1277 | |
---|
1299 | 1278 | local_irq_save(flags); |
---|
1300 | 1279 | |
---|
.. | .. |
---|
1771 | 1750 | udc_clock = clk_get(NULL, "usb-device"); |
---|
1772 | 1751 | if (IS_ERR(udc_clock)) { |
---|
1773 | 1752 | dev_err(dev, "failed to get udc clock source\n"); |
---|
1774 | | - return PTR_ERR(udc_clock); |
---|
| 1753 | + retval = PTR_ERR(udc_clock); |
---|
| 1754 | + goto err_usb_bus_clk; |
---|
1775 | 1755 | } |
---|
1776 | 1756 | |
---|
1777 | 1757 | clk_prepare_enable(udc_clock); |
---|
.. | .. |
---|
1791 | 1771 | spin_lock_init(&udc->lock); |
---|
1792 | 1772 | udc_info = dev_get_platdata(&pdev->dev); |
---|
1793 | 1773 | |
---|
1794 | | - rsrc_start = S3C2410_PA_USBDEV; |
---|
1795 | | - rsrc_len = S3C24XX_SZ_USBDEV; |
---|
1796 | | - |
---|
1797 | | - if (!request_mem_region(rsrc_start, rsrc_len, gadget_name)) |
---|
1798 | | - return -EBUSY; |
---|
1799 | | - |
---|
1800 | | - base_addr = ioremap(rsrc_start, rsrc_len); |
---|
1801 | | - if (!base_addr) { |
---|
1802 | | - retval = -ENOMEM; |
---|
1803 | | - goto err_mem; |
---|
| 1774 | + base_addr = devm_platform_ioremap_resource(pdev, 0); |
---|
| 1775 | + if (IS_ERR(base_addr)) { |
---|
| 1776 | + retval = PTR_ERR(base_addr); |
---|
| 1777 | + goto err_udc_clk; |
---|
1804 | 1778 | } |
---|
1805 | 1779 | |
---|
1806 | 1780 | the_controller = udc; |
---|
.. | .. |
---|
1809 | 1783 | s3c2410_udc_disable(udc); |
---|
1810 | 1784 | s3c2410_udc_reinit(udc); |
---|
1811 | 1785 | |
---|
| 1786 | + irq_usbd = platform_get_irq(pdev, 0); |
---|
| 1787 | + if (irq_usbd < 0) { |
---|
| 1788 | + retval = irq_usbd; |
---|
| 1789 | + goto err_udc_clk; |
---|
| 1790 | + } |
---|
| 1791 | + |
---|
1812 | 1792 | /* irq setup after old hardware state is cleaned up */ |
---|
1813 | | - retval = request_irq(IRQ_USBD, s3c2410_udc_irq, |
---|
| 1793 | + retval = request_irq(irq_usbd, s3c2410_udc_irq, |
---|
1814 | 1794 | 0, gadget_name, udc); |
---|
1815 | 1795 | |
---|
1816 | 1796 | if (retval != 0) { |
---|
1817 | | - dev_err(dev, "cannot get irq %i, err %d\n", IRQ_USBD, retval); |
---|
| 1797 | + dev_err(dev, "cannot get irq %i, err %d\n", irq_usbd, retval); |
---|
1818 | 1798 | retval = -EBUSY; |
---|
1819 | | - goto err_map; |
---|
| 1799 | + goto err_udc_clk; |
---|
1820 | 1800 | } |
---|
1821 | 1801 | |
---|
1822 | | - dev_dbg(dev, "got irq %i\n", IRQ_USBD); |
---|
| 1802 | + dev_dbg(dev, "got irq %i\n", irq_usbd); |
---|
1823 | 1803 | |
---|
1824 | 1804 | if (udc_info && udc_info->vbus_pin > 0) { |
---|
1825 | 1805 | retval = gpio_request(udc_info->vbus_pin, "udc vbus"); |
---|
.. | .. |
---|
1886 | 1866 | if (udc_info && udc_info->vbus_pin > 0) |
---|
1887 | 1867 | gpio_free(udc_info->vbus_pin); |
---|
1888 | 1868 | err_int: |
---|
1889 | | - free_irq(IRQ_USBD, udc); |
---|
1890 | | -err_map: |
---|
1891 | | - iounmap(base_addr); |
---|
1892 | | -err_mem: |
---|
1893 | | - release_mem_region(rsrc_start, rsrc_len); |
---|
| 1869 | + free_irq(irq_usbd, udc); |
---|
| 1870 | +err_udc_clk: |
---|
| 1871 | + clk_disable_unprepare(udc_clock); |
---|
| 1872 | + clk_put(udc_clock); |
---|
| 1873 | + udc_clock = NULL; |
---|
| 1874 | +err_usb_bus_clk: |
---|
| 1875 | + clk_disable_unprepare(usb_bus_clock); |
---|
| 1876 | + clk_put(usb_bus_clock); |
---|
| 1877 | + usb_bus_clock = NULL; |
---|
1894 | 1878 | |
---|
1895 | 1879 | return retval; |
---|
1896 | 1880 | } |
---|
.. | .. |
---|
1920 | 1904 | free_irq(irq, udc); |
---|
1921 | 1905 | } |
---|
1922 | 1906 | |
---|
1923 | | - free_irq(IRQ_USBD, udc); |
---|
1924 | | - |
---|
1925 | | - iounmap(base_addr); |
---|
1926 | | - release_mem_region(rsrc_start, rsrc_len); |
---|
| 1907 | + free_irq(irq_usbd, udc); |
---|
1927 | 1908 | |
---|
1928 | 1909 | if (!IS_ERR(udc_clock) && udc_clock != NULL) { |
---|
1929 | 1910 | clk_disable_unprepare(udc_clock); |
---|
.. | .. |
---|
1985 | 1966 | |
---|
1986 | 1967 | dprintk(DEBUG_NORMAL, "%s\n", gadget_name); |
---|
1987 | 1968 | |
---|
1988 | | - s3c2410_udc_debugfs_root = debugfs_create_dir(gadget_name, NULL); |
---|
| 1969 | + s3c2410_udc_debugfs_root = debugfs_create_dir(gadget_name, |
---|
| 1970 | + usb_debug_root); |
---|
1989 | 1971 | |
---|
1990 | 1972 | retval = platform_driver_register(&udc_driver_24x0); |
---|
1991 | 1973 | if (retval) |
---|