1
0
Fork 0

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>
hifive-unleashed-5.1
Laurent Pinchart 2015-01-21 00:55:57 +02:00 committed by Felipe Balbi
parent e19c99e759
commit 4b1a577d41
6 changed files with 114 additions and 38 deletions

View File

@ -5,7 +5,7 @@
# tell define_trace.h where to find the xhci trace header
CFLAGS_xhci-trace.o := -I$(src)
isp1760-y := isp1760-hcd.o isp1760-if.o
isp1760-y := isp1760-core.o isp1760-hcd.o isp1760-if.o
fhci-y := fhci-hcd.o fhci-hub.o fhci-q.o
fhci-y += fhci-mem.o fhci-tds.o fhci-sched.o

View File

@ -0,0 +1,65 @@
/*
* Driver for the NXP ISP1760 chip
*
* Copyright 2014 Laurent Pinchart
* Copyright 2007 Sebastian Siewior
*
* Contacts:
* Sebastian Siewior <bigeasy@linutronix.de>
* Laurent Pinchart <laurent.pinchart@ideasonboard.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*/
#include <linux/gpio.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/usb.h>
#include "isp1760-core.h"
#include "isp1760-hcd.h"
int isp1760_register(struct resource *mem, int irq, unsigned long irqflags,
struct device *dev, unsigned int devflags)
{
struct isp1760_device *isp;
int ret;
if (usb_disabled())
return -ENODEV;
/* prevent usb-core allocating DMA pages */
dev->dma_mask = NULL;
isp = devm_kzalloc(dev, sizeof(*isp), GFP_KERNEL);
if (!isp)
return -ENOMEM;
isp->regs = devm_ioremap_resource(dev, mem);
if (IS_ERR(isp->regs))
return PTR_ERR(isp->regs);
ret = isp1760_hcd_register(&isp->hcd, isp->regs, mem, irq, irqflags,
dev, devflags);
if (ret < 0)
return ret;
dev_set_drvdata(dev, isp);
return 0;
}
void isp1760_unregister(struct device *dev)
{
struct isp1760_device *isp = dev_get_drvdata(dev);
isp1760_hcd_unregister(&isp->hcd);
}
MODULE_DESCRIPTION("Driver for the ISP1760 USB-controller from NXP");
MODULE_AUTHOR("Sebastian Siewior <bigeasy@linuxtronix.de>");
MODULE_LICENSE("GPL v2");

View File

@ -0,0 +1,33 @@
/*
* Driver for the NXP ISP1760 chip
*
* Copyright 2014 Laurent Pinchart
* Copyright 2007 Sebastian Siewior
*
* Contacts:
* Sebastian Siewior <bigeasy@linutronix.de>
* Laurent Pinchart <laurent.pinchart@ideasonboard.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*/
#ifndef _ISP1760_CORE_H_
#define _ISP1760_CORE_H_
#include <linux/ioport.h>
#include "isp1760-hcd.h"
struct isp1760_device {
void __iomem *regs;
struct isp1760_hcd hcd;
};
int isp1760_register(struct resource *mem, int irq, unsigned long irqflags,
struct device *dev, unsigned int devflags);
void isp1760_unregister(struct device *dev);
#endif

View File

@ -2232,30 +2232,20 @@ void isp1760_deinit_kmem_cache(void)
kmem_cache_destroy(urb_listitem_cachep);
}
int isp1760_register(struct resource *mem, int irq, unsigned long irqflags,
struct device *dev, unsigned int devflags)
int isp1760_hcd_register(struct isp1760_hcd *priv, void __iomem *regs,
struct resource *mem, int irq, unsigned long irqflags,
struct device *dev, unsigned int devflags)
{
struct usb_hcd *hcd = NULL;
struct isp1760_hcd *priv;
struct usb_hcd *hcd;
int ret;
if (usb_disabled())
return -ENODEV;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
/* prevent usb-core allocating DMA pages */
dev->dma_mask = NULL;
hcd = usb_create_hcd(&isp1760_hc_driver, dev, dev_name(dev));
if (!hcd)
return -ENOMEM;
priv->hcd = hcd;
*(struct isp1760_hcd **)hcd->hcd_priv = priv;
priv->hcd = hcd;
priv->devflags = devflags;
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,
}
init_memory(priv);
hcd->regs = devm_ioremap_resource(dev, mem);
if (IS_ERR(hcd->regs)) {
ret = PTR_ERR(hcd->regs);
goto error;
}
hcd->irq = irq;
hcd->regs = regs;
hcd->rsrc_start = mem->start;
hcd->rsrc_len = resource_size(mem);
ret = usb_add_hcd(hcd, irq, irqflags);
if (ret)
goto error;
device_wakeup_enable(hcd->self.controller);
dev_set_drvdata(dev, priv);
device_wakeup_enable(hcd->self.controller);
return 0;
@ -2289,15 +2274,8 @@ error:
return ret;
}
void isp1760_unregister(struct device *dev)
void isp1760_hcd_unregister(struct isp1760_hcd *priv)
{
struct isp1760_hcd *priv = dev_get_drvdata(dev);
struct usb_hcd *hcd = priv->hcd;
usb_remove_hcd(hcd);
usb_put_hcd(hcd);
usb_remove_hcd(priv->hcd);
usb_put_hcd(priv->hcd);
}
MODULE_DESCRIPTION("Driver for the ISP1760 USB-controller from NXP");
MODULE_AUTHOR("Sebastian Siewior <bigeasy@linuxtronix.de>");
MODULE_LICENSE("GPL v2");

View File

@ -84,10 +84,10 @@ struct isp1760_hcd {
struct gpio_desc *rst_gpio;
};
/* exports for if */
int isp1760_register(struct resource *mem, int irq, unsigned long irqflags,
struct device *dev, unsigned int devflags);
void isp1760_unregister(struct device *dev);
int isp1760_hcd_register(struct isp1760_hcd *priv, void __iomem *regs,
struct resource *mem, int irq, unsigned long irqflags,
struct device *dev, unsigned int devflags);
void isp1760_hcd_unregister(struct isp1760_hcd *priv);
int isp1760_init_kmem_once(void);
void isp1760_deinit_kmem_cache(void);

View File

@ -18,7 +18,7 @@
#include <linux/usb/isp1760.h>
#include <linux/usb/hcd.h>
#include "isp1760-hcd.h"
#include "isp1760-core.h"
#include "isp1760-regs.h"
#ifdef CONFIG_PCI