Commit cdd36e87 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Felipe Balbi

usb: isp1760: Decouple usb_hdc and isp1760_priv

Allocate the driver private data structure manually instead of using the
usb_hcd private space. This will allow skipping hcd registration for the
isp1761 when used in device mode only.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarFelipe Balbi <balbi@ti.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent c770e001
...@@ -40,6 +40,8 @@ enum queue_head_types { ...@@ -40,6 +40,8 @@ enum queue_head_types {
}; };
struct isp1760_hcd { struct isp1760_hcd {
struct usb_hcd *hcd;
u32 hcs_params; u32 hcs_params;
spinlock_t lock; spinlock_t lock;
struct slotinfo atl_slots[32]; struct slotinfo atl_slots[32];
...@@ -65,7 +67,7 @@ typedef void (packet_enqueue)(struct usb_hcd *hcd, struct isp1760_qh *qh, ...@@ -65,7 +67,7 @@ typedef void (packet_enqueue)(struct usb_hcd *hcd, struct isp1760_qh *qh,
static inline struct isp1760_hcd *hcd_to_priv(struct usb_hcd *hcd) static inline struct isp1760_hcd *hcd_to_priv(struct usb_hcd *hcd)
{ {
return (struct isp1760_hcd *) (hcd->hcd_priv); return *(struct isp1760_hcd **)hcd->hcd_priv;
} }
/* Section 2.2 Host Controller Capability Registers */ /* Section 2.2 Host Controller Capability Registers */
...@@ -2161,7 +2163,7 @@ static void isp1760_clear_tt_buffer_complete(struct usb_hcd *hcd, ...@@ -2161,7 +2163,7 @@ static void isp1760_clear_tt_buffer_complete(struct usb_hcd *hcd,
static const struct hc_driver isp1760_hc_driver = { static const struct hc_driver isp1760_hc_driver = {
.description = "isp1760-hcd", .description = "isp1760-hcd",
.product_desc = "NXP ISP1760 USB Host Controller", .product_desc = "NXP ISP1760 USB Host Controller",
.hcd_priv_size = sizeof(struct isp1760_hcd), .hcd_priv_size = sizeof(struct isp1760_hcd *),
.irq = isp1760_irq, .irq = isp1760_irq,
.flags = HCD_MEMORY | HCD_USB2, .flags = HCD_MEMORY | HCD_USB2,
.reset = isp1760_hc_setup, .reset = isp1760_hc_setup,
...@@ -2214,13 +2216,17 @@ void isp1760_deinit_kmem_cache(void) ...@@ -2214,13 +2216,17 @@ void isp1760_deinit_kmem_cache(void)
int isp1760_register(struct resource *mem, int irq, unsigned long irqflags, int isp1760_register(struct resource *mem, int irq, unsigned long irqflags,
struct device *dev, unsigned int devflags) struct device *dev, unsigned int devflags)
{ {
struct usb_hcd *hcd; struct usb_hcd *hcd = NULL;
struct isp1760_hcd *priv; struct isp1760_hcd *priv;
int ret; int ret;
if (usb_disabled()) if (usb_disabled())
return -ENODEV; return -ENODEV;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
/* prevent usb-core allocating DMA pages */ /* prevent usb-core allocating DMA pages */
dev->dma_mask = NULL; dev->dma_mask = NULL;
...@@ -2228,7 +2234,9 @@ int isp1760_register(struct resource *mem, int irq, unsigned long irqflags, ...@@ -2228,7 +2234,9 @@ int isp1760_register(struct resource *mem, int irq, unsigned long irqflags,
if (!hcd) if (!hcd)
return -ENOMEM; return -ENOMEM;
priv = hcd_to_priv(hcd); priv->hcd = hcd;
*(struct isp1760_hcd **)hcd->hcd_priv = priv;
priv->devflags = devflags; priv->devflags = devflags;
priv->rst_gpio = devm_gpiod_get_optional(dev, NULL, GPIOD_OUT_HIGH); priv->rst_gpio = devm_gpiod_get_optional(dev, NULL, GPIOD_OUT_HIGH);
...@@ -2253,7 +2261,7 @@ int isp1760_register(struct resource *mem, int irq, unsigned long irqflags, ...@@ -2253,7 +2261,7 @@ int isp1760_register(struct resource *mem, int irq, unsigned long irqflags,
goto error; goto error;
device_wakeup_enable(hcd->self.controller); device_wakeup_enable(hcd->self.controller);
dev_set_drvdata(dev, hcd); dev_set_drvdata(dev, priv);
return 0; return 0;
...@@ -2264,7 +2272,8 @@ int isp1760_register(struct resource *mem, int irq, unsigned long irqflags, ...@@ -2264,7 +2272,8 @@ int isp1760_register(struct resource *mem, int irq, unsigned long irqflags,
void isp1760_unregister(struct device *dev) void isp1760_unregister(struct device *dev)
{ {
struct usb_hcd *hcd = dev_get_drvdata(dev); struct isp1760_hcd *priv = dev_get_drvdata(dev);
struct usb_hcd *hcd = priv->hcd;
usb_remove_hcd(hcd); usb_remove_hcd(hcd);
usb_put_hcd(hcd); usb_put_hcd(hcd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment