diff options
| author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2015-01-20 17:55:57 -0500 |
|---|---|---|
| committer | Felipe Balbi <balbi@ti.com> | 2015-01-27 10:39:16 -0500 |
| commit | 4b1a577d41c99f2aa548e8de3effe1033d9ca40b (patch) | |
| tree | 181b85235f810e6e31f45a45c2316885ba96e534 | |
| parent | e19c99e7592e06b6fdf558aa8877b671f8cf0329 (diff) | |
usb: isp1760: Move core code to isp1760-core.c
Move core device initialization to a central location in order to share
it with the device mode implementation.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
| -rw-r--r-- | drivers/usb/host/Makefile | 2 | ||||
| -rw-r--r-- | drivers/usb/host/isp1760-core.c | 65 | ||||
| -rw-r--r-- | drivers/usb/host/isp1760-core.h | 33 | ||||
| -rw-r--r-- | drivers/usb/host/isp1760-hcd.c | 42 | ||||
| -rw-r--r-- | drivers/usb/host/isp1760-hcd.h | 8 | ||||
| -rw-r--r-- | drivers/usb/host/isp1760-if.c | 2 |
6 files changed, 114 insertions, 38 deletions
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index d6216a493bab..4dea9b164210 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | # tell define_trace.h where to find the xhci trace header | 5 | # tell define_trace.h where to find the xhci trace header |
| 6 | CFLAGS_xhci-trace.o := -I$(src) | 6 | CFLAGS_xhci-trace.o := -I$(src) |
| 7 | 7 | ||
| 8 | isp1760-y := isp1760-hcd.o isp1760-if.o | 8 | isp1760-y := isp1760-core.o isp1760-hcd.o isp1760-if.o |
| 9 | 9 | ||
| 10 | fhci-y := fhci-hcd.o fhci-hub.o fhci-q.o | 10 | fhci-y := fhci-hcd.o fhci-hub.o fhci-q.o |
| 11 | fhci-y += fhci-mem.o fhci-tds.o fhci-sched.o | 11 | fhci-y += fhci-mem.o fhci-tds.o fhci-sched.o |
diff --git a/drivers/usb/host/isp1760-core.c b/drivers/usb/host/isp1760-core.c new file mode 100644 index 000000000000..d38efa0e340a --- /dev/null +++ b/drivers/usb/host/isp1760-core.c | |||
| @@ -0,0 +1,65 @@ | |||
| 1 | /* | ||
| 2 | * Driver for the NXP ISP1760 chip | ||
| 3 | * | ||
| 4 | * Copyright 2014 Laurent Pinchart | ||
| 5 | * Copyright 2007 Sebastian Siewior | ||
| 6 | * | ||
| 7 | * Contacts: | ||
| 8 | * Sebastian Siewior <bigeasy@linutronix.de> | ||
| 9 | * Laurent Pinchart <laurent.pinchart@ideasonboard.com> | ||
| 10 | * | ||
| 11 | * This program is free software; you can redistribute it and/or | ||
| 12 | * modify it under the terms of the GNU General Public License | ||
| 13 | * version 2 as published by the Free Software Foundation. | ||
| 14 | */ | ||
| 15 | |||
| 16 | #include <linux/gpio.h> | ||
| 17 | #include <linux/io.h> | ||
| 18 | #include <linux/kernel.h> | ||
| 19 | #include <linux/module.h> | ||
| 20 | #include <linux/slab.h> | ||
| 21 | #include <linux/usb.h> | ||
| 22 | |||
| 23 | #include "isp1760-core.h" | ||
| 24 | #include "isp1760-hcd.h" | ||
| 25 | |||
| 26 | int isp1760_register(struct resource *mem, int irq, unsigned long irqflags, | ||
| 27 | struct device *dev, unsigned int devflags) | ||
| 28 | { | ||
| 29 | struct isp1760_device *isp; | ||
| 30 | int ret; | ||
| 31 | |||
| 32 | if (usb_disabled()) | ||
| 33 | return -ENODEV; | ||
| 34 | |||
| 35 | /* prevent usb-core allocating DMA pages */ | ||
| 36 | dev->dma_mask = NULL; | ||
| 37 | |||
| 38 | isp = devm_kzalloc(dev, sizeof(*isp), GFP_KERNEL); | ||
| 39 | if (!isp) | ||
| 40 | return -ENOMEM; | ||
| 41 | |||
| 42 | isp->regs = devm_ioremap_resource(dev, mem); | ||
| 43 | if (IS_ERR(isp->regs)) | ||
| 44 | return PTR_ERR(isp->regs); | ||
| 45 | |||
| 46 | ret = isp1760_hcd_register(&isp->hcd, isp->regs, mem, irq, irqflags, | ||
| 47 | dev, devflags); | ||
| 48 | if (ret < 0) | ||
| 49 | return ret; | ||
| 50 | |||
| 51 | dev_set_drvdata(dev, isp); | ||
| 52 | |||
| 53 | return 0; | ||
| 54 | } | ||
| 55 | |||
| 56 | void isp1760_unregister(struct device *dev) | ||
| 57 | { | ||
| 58 | struct isp1760_device *isp = dev_get_drvdata(dev); | ||
| 59 | |||
| 60 | isp1760_hcd_unregister(&isp->hcd); | ||
| 61 | } | ||
| 62 | |||
| 63 | MODULE_DESCRIPTION("Driver for the ISP1760 USB-controller from NXP"); | ||
| 64 | MODULE_AUTHOR("Sebastian Siewior <bigeasy@linuxtronix.de>"); | ||
| 65 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/usb/host/isp1760-core.h b/drivers/usb/host/isp1760-core.h new file mode 100644 index 000000000000..0caeb1135275 --- /dev/null +++ b/drivers/usb/host/isp1760-core.h | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | /* | ||
| 2 | * Driver for the NXP ISP1760 chip | ||
| 3 | * | ||
| 4 | * Copyright 2014 Laurent Pinchart | ||
| 5 | * Copyright 2007 Sebastian Siewior | ||
| 6 | * | ||
| 7 | * Contacts: | ||
| 8 | * Sebastian Siewior <bigeasy@linutronix.de> | ||
| 9 | * Laurent Pinchart <laurent.pinchart@ideasonboard.com> | ||
| 10 | * | ||
| 11 | * This program is free software; you can redistribute it and/or | ||
| 12 | * modify it under the terms of the GNU General Public License | ||
| 13 | * version 2 as published by the Free Software Foundation. | ||
| 14 | */ | ||
| 15 | |||
| 16 | #ifndef _ISP1760_CORE_H_ | ||
| 17 | #define _ISP1760_CORE_H_ | ||
| 18 | |||
| 19 | #include <linux/ioport.h> | ||
| 20 | |||
| 21 | #include "isp1760-hcd.h" | ||
| 22 | |||
| 23 | struct isp1760_device { | ||
| 24 | void __iomem *regs; | ||
| 25 | |||
| 26 | struct isp1760_hcd hcd; | ||
| 27 | }; | ||
| 28 | |||
| 29 | int isp1760_register(struct resource *mem, int irq, unsigned long irqflags, | ||
| 30 | struct device *dev, unsigned int devflags); | ||
| 31 | void isp1760_unregister(struct device *dev); | ||
| 32 | |||
| 33 | #endif | ||
diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c index 50434cc5335c..0cf620b1f6aa 100644 --- a/drivers/usb/host/isp1760-hcd.c +++ b/drivers/usb/host/isp1760-hcd.c | |||
| @@ -2232,30 +2232,20 @@ void isp1760_deinit_kmem_cache(void) | |||
| 2232 | kmem_cache_destroy(urb_listitem_cachep); | 2232 | kmem_cache_destroy(urb_listitem_cachep); |
| 2233 | } | 2233 | } |
| 2234 | 2234 | ||
| 2235 | int isp1760_register(struct resource *mem, int irq, unsigned long irqflags, | 2235 | int isp1760_hcd_register(struct isp1760_hcd *priv, void __iomem *regs, |
| 2236 | struct device *dev, unsigned int devflags) | 2236 | struct resource *mem, int irq, unsigned long irqflags, |
| 2237 | struct device *dev, unsigned int devflags) | ||
| 2237 | { | 2238 | { |
| 2238 | struct usb_hcd *hcd = NULL; | 2239 | struct usb_hcd *hcd; |
| 2239 | struct isp1760_hcd *priv; | ||
| 2240 | int ret; | 2240 | int ret; |
| 2241 | 2241 | ||
| 2242 | if (usb_disabled()) | ||
| 2243 | return -ENODEV; | ||
| 2244 | |||
| 2245 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); | ||
| 2246 | if (!priv) | ||
| 2247 | return -ENOMEM; | ||
| 2248 | |||
| 2249 | /* prevent usb-core allocating DMA pages */ | ||
| 2250 | dev->dma_mask = NULL; | ||
| 2251 | |||
| 2252 | hcd = usb_create_hcd(&isp1760_hc_driver, dev, dev_name(dev)); | 2242 | hcd = usb_create_hcd(&isp1760_hc_driver, dev, dev_name(dev)); |
| 2253 | if (!hcd) | 2243 | if (!hcd) |
| 2254 | return -ENOMEM; | 2244 | return -ENOMEM; |
| 2255 | 2245 | ||
| 2256 | priv->hcd = hcd; | ||
| 2257 | *(struct isp1760_hcd **)hcd->hcd_priv = priv; | 2246 | *(struct isp1760_hcd **)hcd->hcd_priv = priv; |
| 2258 | 2247 | ||
| 2248 | priv->hcd = hcd; | ||
| 2259 | priv->devflags = devflags; | 2249 | priv->devflags = devflags; |
| 2260 | 2250 | ||
| 2261 | priv->rst_gpio = devm_gpiod_get_optional(dev, NULL, GPIOD_OUT_HIGH); | 2251 | priv->rst_gpio = devm_gpiod_get_optional(dev, NULL, GPIOD_OUT_HIGH); |
| @@ -2265,22 +2255,17 @@ int isp1760_register(struct resource *mem, int irq, unsigned long irqflags, | |||
| 2265 | } | 2255 | } |
| 2266 | 2256 | ||
| 2267 | init_memory(priv); | 2257 | init_memory(priv); |
| 2268 | hcd->regs = devm_ioremap_resource(dev, mem); | ||
| 2269 | if (IS_ERR(hcd->regs)) { | ||
| 2270 | ret = PTR_ERR(hcd->regs); | ||
| 2271 | goto error; | ||
| 2272 | } | ||
| 2273 | 2258 | ||
| 2274 | hcd->irq = irq; | 2259 | hcd->irq = irq; |
| 2260 | hcd->regs = regs; | ||
| 2275 | hcd->rsrc_start = mem->start; | 2261 | hcd->rsrc_start = mem->start; |
| 2276 | hcd->rsrc_len = resource_size(mem); | 2262 | hcd->rsrc_len = resource_size(mem); |
| 2277 | 2263 | ||
| 2278 | ret = usb_add_hcd(hcd, irq, irqflags); | 2264 | ret = usb_add_hcd(hcd, irq, irqflags); |
| 2279 | if (ret) | 2265 | if (ret) |
| 2280 | goto error; | 2266 | goto error; |
| 2281 | device_wakeup_enable(hcd->self.controller); | ||
| 2282 | 2267 | ||
| 2283 | dev_set_drvdata(dev, priv); | 2268 | device_wakeup_enable(hcd->self.controller); |
| 2284 | 2269 | ||
| 2285 | return 0; | 2270 | return 0; |
| 2286 | 2271 | ||
| @@ -2289,15 +2274,8 @@ error: | |||
| 2289 | return ret; | 2274 | return ret; |
| 2290 | } | 2275 | } |
| 2291 | 2276 | ||
| 2292 | void isp1760_unregister(struct device *dev) | 2277 | void isp1760_hcd_unregister(struct isp1760_hcd *priv) |
| 2293 | { | 2278 | { |
| 2294 | struct isp1760_hcd *priv = dev_get_drvdata(dev); | 2279 | usb_remove_hcd(priv->hcd); |
| 2295 | struct usb_hcd *hcd = priv->hcd; | 2280 | usb_put_hcd(priv->hcd); |
| 2296 | |||
| 2297 | usb_remove_hcd(hcd); | ||
| 2298 | usb_put_hcd(hcd); | ||
| 2299 | } | 2281 | } |
| 2300 | |||
| 2301 | MODULE_DESCRIPTION("Driver for the ISP1760 USB-controller from NXP"); | ||
| 2302 | MODULE_AUTHOR("Sebastian Siewior <bigeasy@linuxtronix.de>"); | ||
| 2303 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/usb/host/isp1760-hcd.h b/drivers/usb/host/isp1760-hcd.h index 44486c86f5f7..dcd2232848cd 100644 --- a/drivers/usb/host/isp1760-hcd.h +++ b/drivers/usb/host/isp1760-hcd.h | |||
| @@ -84,10 +84,10 @@ struct isp1760_hcd { | |||
| 84 | struct gpio_desc *rst_gpio; | 84 | struct gpio_desc *rst_gpio; |
| 85 | }; | 85 | }; |
| 86 | 86 | ||
| 87 | /* exports for if */ | 87 | int isp1760_hcd_register(struct isp1760_hcd *priv, void __iomem *regs, |
| 88 | int isp1760_register(struct resource *mem, int irq, unsigned long irqflags, | 88 | struct resource *mem, int irq, unsigned long irqflags, |
| 89 | struct device *dev, unsigned int devflags); | 89 | struct device *dev, unsigned int devflags); |
| 90 | void isp1760_unregister(struct device *dev); | 90 | void isp1760_hcd_unregister(struct isp1760_hcd *priv); |
| 91 | 91 | ||
| 92 | int isp1760_init_kmem_once(void); | 92 | int isp1760_init_kmem_once(void); |
| 93 | void isp1760_deinit_kmem_cache(void); | 93 | void isp1760_deinit_kmem_cache(void); |
diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c index b1591c6cf54a..f2a399051244 100644 --- a/drivers/usb/host/isp1760-if.c +++ b/drivers/usb/host/isp1760-if.c | |||
| @@ -18,7 +18,7 @@ | |||
| 18 | #include <linux/usb/isp1760.h> | 18 | #include <linux/usb/isp1760.h> |
| 19 | #include <linux/usb/hcd.h> | 19 | #include <linux/usb/hcd.h> |
| 20 | 20 | ||
| 21 | #include "isp1760-hcd.h" | 21 | #include "isp1760-core.h" |
| 22 | #include "isp1760-regs.h" | 22 | #include "isp1760-regs.h" |
| 23 | 23 | ||
| 24 | #ifdef CONFIG_PCI | 24 | #ifdef CONFIG_PCI |
