2008-04-23 22:37:04 +00:00
|
|
|
/*
|
|
|
|
* Glue code for the ISP1760 driver and bus
|
|
|
|
* Currently there is support for
|
|
|
|
* - OpenFirmware
|
|
|
|
* - PCI
|
2009-07-16 03:22:54 +00:00
|
|
|
* - PDEV (generic platform device centralized driver model)
|
2008-04-23 22:37:04 +00:00
|
|
|
*
|
|
|
|
* (c) 2007 Sebastian Siewior <bigeasy@linutronix.de>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/usb.h>
|
|
|
|
#include <linux/io.h>
|
2011-07-03 20:09:31 +00:00
|
|
|
#include <linux/module.h>
|
2009-02-10 16:55:51 +00:00
|
|
|
#include <linux/platform_device.h>
|
2009-07-16 03:22:54 +00:00
|
|
|
#include <linux/usb/isp1760.h>
|
2010-04-24 21:21:52 +00:00
|
|
|
#include <linux/usb/hcd.h>
|
2008-04-23 22:37:04 +00:00
|
|
|
|
|
|
|
#include "isp1760-hcd.h"
|
|
|
|
|
2011-12-21 22:31:54 +00:00
|
|
|
#if defined(CONFIG_OF) && defined(CONFIG_OF_IRQ)
|
2011-10-19 12:18:41 +00:00
|
|
|
#include <linux/slab.h>
|
2008-04-23 22:37:04 +00:00
|
|
|
#include <linux/of.h>
|
|
|
|
#include <linux/of_platform.h>
|
2011-10-10 16:06:54 +00:00
|
|
|
#include <linux/of_address.h>
|
|
|
|
#include <linux/of_irq.h>
|
2011-10-19 12:18:41 +00:00
|
|
|
#include <linux/of_gpio.h>
|
2008-04-23 22:37:04 +00:00
|
|
|
#endif
|
|
|
|
|
2008-11-02 14:25:42 +00:00
|
|
|
#ifdef CONFIG_PCI
|
2008-04-23 22:37:04 +00:00
|
|
|
#include <linux/pci.h>
|
|
|
|
#endif
|
|
|
|
|
2011-12-21 22:31:54 +00:00
|
|
|
#if defined(CONFIG_OF) && defined(CONFIG_OF_IRQ)
|
2011-10-19 12:18:41 +00:00
|
|
|
struct isp1760 {
|
|
|
|
struct usb_hcd *hcd;
|
|
|
|
int rst_gpio;
|
|
|
|
};
|
|
|
|
|
2011-02-23 04:08:34 +00:00
|
|
|
static int of_isp1760_probe(struct platform_device *dev)
|
2008-04-23 22:37:04 +00:00
|
|
|
{
|
2011-10-19 12:18:41 +00:00
|
|
|
struct isp1760 *drvdata;
|
2010-04-13 23:12:29 +00:00
|
|
|
struct device_node *dp = dev->dev.of_node;
|
2008-04-23 22:37:04 +00:00
|
|
|
struct resource *res;
|
|
|
|
struct resource memory;
|
|
|
|
int virq;
|
2010-05-05 09:18:41 +00:00
|
|
|
resource_size_t res_len;
|
2008-04-23 22:37:04 +00:00
|
|
|
int ret;
|
2008-06-17 16:11:38 +00:00
|
|
|
unsigned int devflags = 0;
|
2011-10-19 12:18:41 +00:00
|
|
|
enum of_gpio_flags gpio_flags;
|
2011-12-02 16:58:18 +00:00
|
|
|
u32 bus_width = 0;
|
2011-10-19 12:18:41 +00:00
|
|
|
|
|
|
|
drvdata = kzalloc(sizeof(*drvdata), GFP_KERNEL);
|
|
|
|
if (!drvdata)
|
|
|
|
return -ENOMEM;
|
2008-04-23 22:37:04 +00:00
|
|
|
|
|
|
|
ret = of_address_to_resource(dp, 0, &memory);
|
2011-12-23 17:39:30 +00:00
|
|
|
if (ret) {
|
|
|
|
ret = -ENXIO;
|
|
|
|
goto free_data;
|
|
|
|
}
|
2008-04-23 22:37:04 +00:00
|
|
|
|
2010-05-05 09:18:41 +00:00
|
|
|
res_len = resource_size(&memory);
|
|
|
|
|
|
|
|
res = request_mem_region(memory.start, res_len, dev_name(&dev->dev));
|
2011-12-23 17:39:30 +00:00
|
|
|
if (!res) {
|
|
|
|
ret = -EBUSY;
|
|
|
|
goto free_data;
|
|
|
|
}
|
2008-04-23 22:37:04 +00:00
|
|
|
|
2012-10-22 03:02:16 +00:00
|
|
|
virq = irq_of_parse_and_map(dp, 0);
|
|
|
|
if (!virq) {
|
2008-04-23 22:37:04 +00:00
|
|
|
ret = -ENODEV;
|
|
|
|
goto release_reg;
|
|
|
|
}
|
|
|
|
|
2008-06-17 16:11:38 +00:00
|
|
|
if (of_device_is_compatible(dp, "nxp,usb-isp1761"))
|
|
|
|
devflags |= ISP1760_FLAG_ISP1761;
|
|
|
|
|
|
|
|
/* Some systems wire up only 16 of the 32 data lines */
|
2011-12-02 16:58:18 +00:00
|
|
|
of_property_read_u32(dp, "bus-width", &bus_width);
|
|
|
|
if (bus_width == 16)
|
2008-06-17 16:11:38 +00:00
|
|
|
devflags |= ISP1760_FLAG_BUS_WIDTH_16;
|
|
|
|
|
|
|
|
if (of_get_property(dp, "port1-otg", NULL) != NULL)
|
|
|
|
devflags |= ISP1760_FLAG_OTG_EN;
|
|
|
|
|
|
|
|
if (of_get_property(dp, "analog-oc", NULL) != NULL)
|
|
|
|
devflags |= ISP1760_FLAG_ANALOG_OC;
|
|
|
|
|
|
|
|
if (of_get_property(dp, "dack-polarity", NULL) != NULL)
|
|
|
|
devflags |= ISP1760_FLAG_DACK_POL_HIGH;
|
|
|
|
|
|
|
|
if (of_get_property(dp, "dreq-polarity", NULL) != NULL)
|
|
|
|
devflags |= ISP1760_FLAG_DREQ_POL_HIGH;
|
|
|
|
|
2011-10-19 12:18:41 +00:00
|
|
|
drvdata->rst_gpio = of_get_gpio_flags(dp, 0, &gpio_flags);
|
|
|
|
if (gpio_is_valid(drvdata->rst_gpio)) {
|
|
|
|
ret = gpio_request(drvdata->rst_gpio, dev_name(&dev->dev));
|
|
|
|
if (!ret) {
|
|
|
|
if (!(gpio_flags & OF_GPIO_ACTIVE_LOW)) {
|
|
|
|
devflags |= ISP1760_FLAG_RESET_ACTIVE_HIGH;
|
|
|
|
gpio_direction_output(drvdata->rst_gpio, 0);
|
|
|
|
} else {
|
|
|
|
gpio_direction_output(drvdata->rst_gpio, 1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
drvdata->rst_gpio = ret;
|
|
|
|
}
|
2008-04-23 22:37:04 +00:00
|
|
|
}
|
|
|
|
|
2011-10-19 12:18:41 +00:00
|
|
|
drvdata->hcd = isp1760_register(memory.start, res_len, virq,
|
|
|
|
IRQF_SHARED, drvdata->rst_gpio,
|
|
|
|
&dev->dev, dev_name(&dev->dev),
|
|
|
|
devflags);
|
|
|
|
if (IS_ERR(drvdata->hcd)) {
|
|
|
|
ret = PTR_ERR(drvdata->hcd);
|
|
|
|
goto free_gpio;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev_set_drvdata(&dev->dev, drvdata);
|
2008-04-23 22:37:04 +00:00
|
|
|
return ret;
|
|
|
|
|
2011-10-19 12:18:41 +00:00
|
|
|
free_gpio:
|
|
|
|
if (gpio_is_valid(drvdata->rst_gpio))
|
|
|
|
gpio_free(drvdata->rst_gpio);
|
2008-04-23 22:37:04 +00:00
|
|
|
release_reg:
|
2010-05-05 09:18:41 +00:00
|
|
|
release_mem_region(memory.start, res_len);
|
2011-12-23 17:39:30 +00:00
|
|
|
free_data:
|
2011-10-19 12:18:41 +00:00
|
|
|
kfree(drvdata);
|
2008-04-23 22:37:04 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-08-06 15:25:50 +00:00
|
|
|
static int of_isp1760_remove(struct platform_device *dev)
|
2008-04-23 22:37:04 +00:00
|
|
|
{
|
2011-10-19 12:18:41 +00:00
|
|
|
struct isp1760 *drvdata = dev_get_drvdata(&dev->dev);
|
2008-04-23 22:37:04 +00:00
|
|
|
|
|
|
|
dev_set_drvdata(&dev->dev, NULL);
|
|
|
|
|
2011-10-19 12:18:41 +00:00
|
|
|
usb_remove_hcd(drvdata->hcd);
|
|
|
|
iounmap(drvdata->hcd->regs);
|
|
|
|
release_mem_region(drvdata->hcd->rsrc_start, drvdata->hcd->rsrc_len);
|
|
|
|
usb_put_hcd(drvdata->hcd);
|
|
|
|
|
|
|
|
if (gpio_is_valid(drvdata->rst_gpio))
|
|
|
|
gpio_free(drvdata->rst_gpio);
|
|
|
|
|
|
|
|
kfree(drvdata);
|
2008-04-23 22:37:04 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-01-10 14:35:03 +00:00
|
|
|
static const struct of_device_id of_isp1760_match[] = {
|
2008-04-23 22:37:04 +00:00
|
|
|
{
|
|
|
|
.compatible = "nxp,usb-isp1760",
|
|
|
|
},
|
2008-06-17 16:11:38 +00:00
|
|
|
{
|
|
|
|
.compatible = "nxp,usb-isp1761",
|
|
|
|
},
|
2008-04-23 22:37:04 +00:00
|
|
|
{ },
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(of, of_isp1760_match);
|
|
|
|
|
2011-02-23 04:08:34 +00:00
|
|
|
static struct platform_driver isp1760_of_driver = {
|
2010-04-13 23:13:02 +00:00
|
|
|
.driver = {
|
|
|
|
.name = "nxp-isp1760",
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.of_match_table = of_isp1760_match,
|
|
|
|
},
|
2008-04-23 22:37:04 +00:00
|
|
|
.probe = of_isp1760_probe,
|
|
|
|
.remove = of_isp1760_remove,
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2008-11-02 14:25:42 +00:00
|
|
|
#ifdef CONFIG_PCI
|
2008-04-23 22:37:04 +00:00
|
|
|
static int __devinit isp1761_pci_probe(struct pci_dev *dev,
|
|
|
|
const struct pci_device_id *id)
|
|
|
|
{
|
|
|
|
u8 latency, limit;
|
|
|
|
__u32 reg_data;
|
|
|
|
int retry_count;
|
|
|
|
struct usb_hcd *hcd;
|
2008-06-17 16:11:38 +00:00
|
|
|
unsigned int devflags = 0;
|
2008-12-01 10:47:40 +00:00
|
|
|
int ret_status = 0;
|
|
|
|
|
|
|
|
resource_size_t pci_mem_phy0;
|
|
|
|
resource_size_t memlength;
|
|
|
|
|
|
|
|
u8 __iomem *chip_addr;
|
|
|
|
u8 __iomem *iobase;
|
|
|
|
resource_size_t nxp_pci_io_base;
|
|
|
|
resource_size_t iolength;
|
2008-04-23 22:37:04 +00:00
|
|
|
|
|
|
|
if (usb_disabled())
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
if (pci_enable_device(dev) < 0)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
if (!dev->irq)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
/* Grab the PLX PCI mem maped port start address we need */
|
|
|
|
nxp_pci_io_base = pci_resource_start(dev, 0);
|
|
|
|
iolength = pci_resource_len(dev, 0);
|
|
|
|
|
|
|
|
if (!request_mem_region(nxp_pci_io_base, iolength, "ISP1761 IO MEM")) {
|
|
|
|
printk(KERN_ERR "request region #1\n");
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
iobase = ioremap_nocache(nxp_pci_io_base, iolength);
|
|
|
|
if (!iobase) {
|
|
|
|
printk(KERN_ERR "ioremap #1\n");
|
2008-12-01 10:47:40 +00:00
|
|
|
ret_status = -ENOMEM;
|
|
|
|
goto cleanup1;
|
2008-04-23 22:37:04 +00:00
|
|
|
}
|
|
|
|
/* Grab the PLX PCI shared memory of the ISP 1761 we need */
|
|
|
|
pci_mem_phy0 = pci_resource_start(dev, 3);
|
2008-12-01 10:47:40 +00:00
|
|
|
memlength = pci_resource_len(dev, 3);
|
|
|
|
if (memlength < 0xffff) {
|
|
|
|
printk(KERN_ERR "memory length for this resource is wrong\n");
|
|
|
|
ret_status = -ENOMEM;
|
|
|
|
goto cleanup2;
|
2008-04-23 22:37:04 +00:00
|
|
|
}
|
|
|
|
|
2008-12-01 10:47:40 +00:00
|
|
|
if (!request_mem_region(pci_mem_phy0, memlength, "ISP-PCI")) {
|
2008-04-23 22:37:04 +00:00
|
|
|
printk(KERN_ERR "host controller already in use\n");
|
2008-12-01 10:47:40 +00:00
|
|
|
ret_status = -EBUSY;
|
|
|
|
goto cleanup2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* map available memory */
|
|
|
|
chip_addr = ioremap_nocache(pci_mem_phy0,memlength);
|
|
|
|
if (!chip_addr) {
|
|
|
|
printk(KERN_ERR "Error ioremap failed\n");
|
|
|
|
ret_status = -ENOMEM;
|
|
|
|
goto cleanup3;
|
2008-04-23 22:37:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* bad pci latencies can contribute to overruns */
|
|
|
|
pci_read_config_byte(dev, PCI_LATENCY_TIMER, &latency);
|
|
|
|
if (latency) {
|
|
|
|
pci_read_config_byte(dev, PCI_MAX_LAT, &limit);
|
|
|
|
if (limit && limit < latency)
|
|
|
|
pci_write_config_byte(dev, PCI_LATENCY_TIMER, limit);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Try to check whether we can access Scratch Register of
|
|
|
|
* Host Controller or not. The initial PCI access is retried until
|
|
|
|
* local init for the PCI bridge is completed
|
|
|
|
*/
|
|
|
|
retry_count = 20;
|
|
|
|
reg_data = 0;
|
|
|
|
while ((reg_data != 0xFACE) && retry_count) {
|
|
|
|
/*by default host is in 16bit mode, so
|
|
|
|
* io operations at this stage must be 16 bit
|
|
|
|
* */
|
|
|
|
writel(0xface, chip_addr + HC_SCRATCH_REG);
|
|
|
|
udelay(100);
|
2008-12-01 10:47:40 +00:00
|
|
|
reg_data = readl(chip_addr + HC_SCRATCH_REG) & 0x0000ffff;
|
2008-04-23 22:37:04 +00:00
|
|
|
retry_count--;
|
|
|
|
}
|
|
|
|
|
2008-12-01 10:47:40 +00:00
|
|
|
iounmap(chip_addr);
|
|
|
|
|
2008-04-23 22:37:04 +00:00
|
|
|
/* Host Controller presence is detected by writing to scratch register
|
|
|
|
* and reading back and checking the contents are same or not
|
|
|
|
*/
|
|
|
|
if (reg_data != 0xFACE) {
|
2008-08-14 16:37:34 +00:00
|
|
|
dev_err(&dev->dev, "scratch register mismatch %x\n", reg_data);
|
2008-12-01 10:47:40 +00:00
|
|
|
ret_status = -ENOMEM;
|
|
|
|
goto cleanup3;
|
2008-04-23 22:37:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pci_set_master(dev);
|
|
|
|
|
2008-12-01 10:47:40 +00:00
|
|
|
/* configure PLX PCI chip to pass interrupts */
|
|
|
|
#define PLX_INT_CSR_REG 0x68
|
|
|
|
reg_data = readl(iobase + PLX_INT_CSR_REG);
|
|
|
|
reg_data |= 0x900;
|
|
|
|
writel(reg_data, iobase + PLX_INT_CSR_REG);
|
2008-04-23 22:37:04 +00:00
|
|
|
|
|
|
|
dev->dev.dma_mask = NULL;
|
2008-12-01 10:47:40 +00:00
|
|
|
hcd = isp1760_register(pci_mem_phy0, memlength, dev->irq,
|
2011-10-19 12:18:41 +00:00
|
|
|
IRQF_SHARED, -ENOENT, &dev->dev, dev_name(&dev->dev),
|
2008-06-17 16:11:38 +00:00
|
|
|
devflags);
|
2008-12-01 10:47:40 +00:00
|
|
|
if (IS_ERR(hcd)) {
|
|
|
|
ret_status = -ENODEV;
|
|
|
|
goto cleanup3;
|
USB: isp1760: Use an IS_ERR test rather than a NULL test
In case of error, the function isp1760_register returns an ERR
pointer, but never returns a NULL pointer. So after a call to this
function, a NULL test should be replaced by an IS_ERR test. Moreover,
we have noticed that:
(1) the result of isp1760_register is assigned through the function
pci_set_drvdata without an error test,
(2) if the call to isp1760_register fails, the current function
(isp1761_pci_probe) returns 0, and if it succeeds, it returns -ENOMEM,
which seems odd.
Thus, we suggest to move the test before the call to pci_set_drvdata
to correct (1), and to turn it into a non IS_ERR test to correct (2).
The semantic match that finds this problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@bad_null_test@
expression x,E;
statement S1, S2;
@@
x = isp1760_register(...)
... when != x = E
* if (x == NULL)
S1 else S2
// </smpl>
Signed-off-by: Julien Brunel <brunel@diku.dk>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-09-24 16:00:36 +00:00
|
|
|
}
|
2008-12-01 10:47:40 +00:00
|
|
|
|
|
|
|
/* done with PLX IO access */
|
2008-04-23 22:37:04 +00:00
|
|
|
iounmap(iobase);
|
|
|
|
release_mem_region(nxp_pci_io_base, iolength);
|
2008-12-01 10:47:40 +00:00
|
|
|
|
|
|
|
pci_set_drvdata(dev, hcd);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
cleanup3:
|
|
|
|
release_mem_region(pci_mem_phy0, memlength);
|
|
|
|
cleanup2:
|
|
|
|
iounmap(iobase);
|
|
|
|
cleanup1:
|
|
|
|
release_mem_region(nxp_pci_io_base, iolength);
|
|
|
|
return ret_status;
|
2008-04-23 22:37:04 +00:00
|
|
|
}
|
2008-12-01 10:47:40 +00:00
|
|
|
|
2008-04-23 22:37:04 +00:00
|
|
|
static void isp1761_pci_remove(struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
struct usb_hcd *hcd;
|
|
|
|
|
|
|
|
hcd = pci_get_drvdata(dev);
|
|
|
|
|
|
|
|
usb_remove_hcd(hcd);
|
|
|
|
iounmap(hcd->regs);
|
|
|
|
release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
|
|
|
|
usb_put_hcd(hcd);
|
|
|
|
|
|
|
|
pci_disable_device(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void isp1761_pci_shutdown(struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
printk(KERN_ERR "ips1761_pci_shutdown\n");
|
|
|
|
}
|
|
|
|
|
2008-11-30 15:50:04 +00:00
|
|
|
static const struct pci_device_id isp1760_plx [] = {
|
|
|
|
{
|
|
|
|
.class = PCI_CLASS_BRIDGE_OTHER << 8,
|
|
|
|
.class_mask = ~0,
|
|
|
|
.vendor = PCI_VENDOR_ID_PLX,
|
|
|
|
.device = 0x5406,
|
|
|
|
.subvendor = PCI_VENDOR_ID_PLX,
|
|
|
|
.subdevice = 0x9054,
|
|
|
|
},
|
|
|
|
{ }
|
2008-04-23 22:37:04 +00:00
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(pci, isp1760_plx);
|
|
|
|
|
|
|
|
static struct pci_driver isp1761_pci_driver = {
|
|
|
|
.name = "isp1760",
|
|
|
|
.id_table = isp1760_plx,
|
|
|
|
.probe = isp1761_pci_probe,
|
|
|
|
.remove = isp1761_pci_remove,
|
|
|
|
.shutdown = isp1761_pci_shutdown,
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2009-02-10 16:55:51 +00:00
|
|
|
static int __devinit isp1760_plat_probe(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
struct usb_hcd *hcd;
|
|
|
|
struct resource *mem_res;
|
|
|
|
struct resource *irq_res;
|
|
|
|
resource_size_t mem_size;
|
2009-07-16 03:22:54 +00:00
|
|
|
struct isp1760_platform_data *priv = pdev->dev.platform_data;
|
|
|
|
unsigned int devflags = 0;
|
2011-09-07 08:10:52 +00:00
|
|
|
unsigned long irqflags = IRQF_SHARED;
|
2009-02-10 16:55:51 +00:00
|
|
|
|
|
|
|
mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
|
|
if (!mem_res) {
|
|
|
|
pr_warning("isp1760: Memory resource not available\n");
|
|
|
|
ret = -ENODEV;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
mem_size = resource_size(mem_res);
|
|
|
|
if (!request_mem_region(mem_res->start, mem_size, "isp1760")) {
|
|
|
|
pr_warning("isp1760: Cannot reserve the memory resource\n");
|
|
|
|
ret = -EBUSY;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
|
|
|
|
if (!irq_res) {
|
|
|
|
pr_warning("isp1760: IRQ resource not available\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
irqflags |= irq_res->flags & IRQF_TRIGGER_MASK;
|
|
|
|
|
2009-07-16 03:22:54 +00:00
|
|
|
if (priv) {
|
|
|
|
if (priv->is_isp1761)
|
|
|
|
devflags |= ISP1760_FLAG_ISP1761;
|
|
|
|
if (priv->bus_width_16)
|
|
|
|
devflags |= ISP1760_FLAG_BUS_WIDTH_16;
|
|
|
|
if (priv->port1_otg)
|
|
|
|
devflags |= ISP1760_FLAG_OTG_EN;
|
|
|
|
if (priv->analog_oc)
|
|
|
|
devflags |= ISP1760_FLAG_ANALOG_OC;
|
|
|
|
if (priv->dack_polarity_high)
|
|
|
|
devflags |= ISP1760_FLAG_DACK_POL_HIGH;
|
|
|
|
if (priv->dreq_polarity_high)
|
|
|
|
devflags |= ISP1760_FLAG_DREQ_POL_HIGH;
|
|
|
|
}
|
|
|
|
|
2009-02-10 16:55:51 +00:00
|
|
|
hcd = isp1760_register(mem_res->start, mem_size, irq_res->start,
|
2011-10-19 12:18:41 +00:00
|
|
|
irqflags, -ENOENT,
|
|
|
|
&pdev->dev, dev_name(&pdev->dev), devflags);
|
2012-04-05 12:56:07 +00:00
|
|
|
|
|
|
|
dev_set_drvdata(&pdev->dev, hcd);
|
|
|
|
|
2009-02-10 16:55:51 +00:00
|
|
|
if (IS_ERR(hcd)) {
|
|
|
|
pr_warning("isp1760: Failed to register the HCD device\n");
|
|
|
|
ret = -ENODEV;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
pr_info("ISP1760 USB device initialised\n");
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
release_mem_region(mem_res->start, mem_size);
|
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __devexit isp1760_plat_remove(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct resource *mem_res;
|
|
|
|
resource_size_t mem_size;
|
2012-04-05 12:56:07 +00:00
|
|
|
struct usb_hcd *hcd = dev_get_drvdata(&pdev->dev);
|
|
|
|
|
|
|
|
usb_remove_hcd(hcd);
|
2009-02-10 16:55:51 +00:00
|
|
|
|
|
|
|
mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
|
|
mem_size = resource_size(mem_res);
|
|
|
|
release_mem_region(mem_res->start, mem_size);
|
|
|
|
|
2012-04-05 12:56:07 +00:00
|
|
|
usb_put_hcd(hcd);
|
|
|
|
|
2009-02-10 16:55:51 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct platform_driver isp1760_plat_driver = {
|
|
|
|
.probe = isp1760_plat_probe,
|
2009-06-12 01:59:00 +00:00
|
|
|
.remove = __devexit_p(isp1760_plat_remove),
|
2009-02-10 16:55:51 +00:00
|
|
|
.driver = {
|
|
|
|
.name = "isp1760",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2008-04-23 22:37:04 +00:00
|
|
|
static int __init isp1760_init(void)
|
|
|
|
{
|
2009-02-10 16:55:51 +00:00
|
|
|
int ret, any_ret = -ENODEV;
|
2008-04-23 22:37:04 +00:00
|
|
|
|
|
|
|
init_kmem_once();
|
|
|
|
|
2009-02-10 16:55:51 +00:00
|
|
|
ret = platform_driver_register(&isp1760_plat_driver);
|
|
|
|
if (!ret)
|
|
|
|
any_ret = 0;
|
2011-12-21 22:31:54 +00:00
|
|
|
#if defined(CONFIG_OF) && defined(CONFIG_OF_IRQ)
|
2011-02-23 04:08:34 +00:00
|
|
|
ret = platform_driver_register(&isp1760_of_driver);
|
2009-02-10 16:55:51 +00:00
|
|
|
if (!ret)
|
|
|
|
any_ret = 0;
|
2008-04-23 22:37:04 +00:00
|
|
|
#endif
|
2008-11-02 14:25:42 +00:00
|
|
|
#ifdef CONFIG_PCI
|
2008-04-23 22:37:04 +00:00
|
|
|
ret = pci_register_driver(&isp1761_pci_driver);
|
2009-02-10 16:55:51 +00:00
|
|
|
if (!ret)
|
|
|
|
any_ret = 0;
|
2008-04-23 22:37:04 +00:00
|
|
|
#endif
|
|
|
|
|
2009-02-10 16:55:51 +00:00
|
|
|
if (any_ret)
|
|
|
|
deinit_kmem_cache();
|
|
|
|
return any_ret;
|
2008-04-23 22:37:04 +00:00
|
|
|
}
|
|
|
|
module_init(isp1760_init);
|
|
|
|
|
|
|
|
static void __exit isp1760_exit(void)
|
|
|
|
{
|
2009-02-10 16:55:51 +00:00
|
|
|
platform_driver_unregister(&isp1760_plat_driver);
|
2011-12-21 22:31:54 +00:00
|
|
|
#if defined(CONFIG_OF) && defined(CONFIG_OF_IRQ)
|
2011-02-23 04:08:34 +00:00
|
|
|
platform_driver_unregister(&isp1760_of_driver);
|
2008-04-23 22:37:04 +00:00
|
|
|
#endif
|
2008-11-02 14:25:42 +00:00
|
|
|
#ifdef CONFIG_PCI
|
2008-04-23 22:37:04 +00:00
|
|
|
pci_unregister_driver(&isp1761_pci_driver);
|
|
|
|
#endif
|
|
|
|
deinit_kmem_cache();
|
|
|
|
}
|
|
|
|
module_exit(isp1760_exit);
|