blob: df931e9ba5b5cfa682f8fab3272da16c5531dca4 [file] [log] [blame]
Sebastian Siewiordb11e472008-04-24 00:37:04 +02001/*
2 * Glue code for the ISP1760 driver and bus
3 * Currently there is support for
4 * - OpenFirmware
5 * - PCI
Michael Hennerich9da69c62009-07-15 23:22:54 -04006 * - PDEV (generic platform device centralized driver model)
Sebastian Siewiordb11e472008-04-24 00:37:04 +02007 *
8 * (c) 2007 Sebastian Siewior <bigeasy@linutronix.de>
9 *
10 */
11
12#include <linux/usb.h>
13#include <linux/io.h>
Paul Gortmaker6eb0de82011-07-03 16:09:31 -040014#include <linux/module.h>
Catalin Marinasf7e7aa52009-02-10 16:55:51 +000015#include <linux/platform_device.h>
Michael Hennerich9da69c62009-07-15 23:22:54 -040016#include <linux/usb/isp1760.h>
Eric Lescouet27729aa2010-04-24 23:21:52 +020017#include <linux/usb/hcd.h>
Sebastian Siewiordb11e472008-04-24 00:37:04 +020018
Sebastian Siewiordb11e472008-04-24 00:37:04 +020019#include "isp1760-hcd.h"
20
David Millerabf058e2011-12-21 17:31:54 -050021#if defined(CONFIG_OF) && defined(CONFIG_OF_IRQ)
Joachim Foerster3a7655f2011-10-19 14:18:41 +020022#include <linux/slab.h>
Sebastian Siewiordb11e472008-04-24 00:37:04 +020023#include <linux/of.h>
24#include <linux/of_platform.h>
Joachim Foerster8f5d6212011-10-10 18:06:54 +020025#include <linux/of_address.h>
26#include <linux/of_irq.h>
Joachim Foerster3a7655f2011-10-19 14:18:41 +020027#include <linux/of_gpio.h>
Sebastian Siewiordb11e472008-04-24 00:37:04 +020028#endif
29
Sebastian Andrzej Siewiorff30bf12008-11-02 15:25:42 +010030#ifdef CONFIG_PCI
Sebastian Siewiordb11e472008-04-24 00:37:04 +020031#include <linux/pci.h>
32#endif
33
David Millerabf058e2011-12-21 17:31:54 -050034#if defined(CONFIG_OF) && defined(CONFIG_OF_IRQ)
Joachim Foerster3a7655f2011-10-19 14:18:41 +020035struct isp1760 {
36 struct usb_hcd *hcd;
37 int rst_gpio;
38};
39
Grant Likelyd35fb642011-02-22 21:08:34 -070040static int of_isp1760_probe(struct platform_device *dev)
Sebastian Siewiordb11e472008-04-24 00:37:04 +020041{
Joachim Foerster3a7655f2011-10-19 14:18:41 +020042 struct isp1760 *drvdata;
Grant Likely61c7a082010-04-13 16:12:29 -070043 struct device_node *dp = dev->dev.of_node;
Sebastian Siewiordb11e472008-04-24 00:37:04 +020044 struct resource *res;
45 struct resource memory;
Sebastian Siewiordb11e472008-04-24 00:37:04 +020046 int virq;
Tobias Klausere07afd32010-05-05 11:18:41 +020047 resource_size_t res_len;
Sebastian Siewiordb11e472008-04-24 00:37:04 +020048 int ret;
Nate Case3faefc82008-06-17 11:11:38 -050049 unsigned int devflags = 0;
Joachim Foerster3a7655f2011-10-19 14:18:41 +020050 enum of_gpio_flags gpio_flags;
Dave Martin8ad028b2011-12-02 16:58:18 +000051 u32 bus_width = 0;
Joachim Foerster3a7655f2011-10-19 14:18:41 +020052
53 drvdata = kzalloc(sizeof(*drvdata), GFP_KERNEL);
54 if (!drvdata)
55 return -ENOMEM;
Sebastian Siewiordb11e472008-04-24 00:37:04 +020056
57 ret = of_address_to_resource(dp, 0, &memory);
Julia Lawall30a0dee2011-12-23 18:39:30 +010058 if (ret) {
59 ret = -ENXIO;
60 goto free_data;
61 }
Sebastian Siewiordb11e472008-04-24 00:37:04 +020062
Tobias Klausere07afd32010-05-05 11:18:41 +020063 res_len = resource_size(&memory);
64
65 res = request_mem_region(memory.start, res_len, dev_name(&dev->dev));
Julia Lawall30a0dee2011-12-23 18:39:30 +010066 if (!res) {
67 ret = -EBUSY;
68 goto free_data;
69 }
Sebastian Siewiordb11e472008-04-24 00:37:04 +020070
Nobuhiro Iwamatsud124a602012-10-22 12:02:16 +090071 virq = irq_of_parse_and_map(dp, 0);
72 if (!virq) {
Sebastian Siewiordb11e472008-04-24 00:37:04 +020073 ret = -ENODEV;
74 goto release_reg;
75 }
76
Nate Case3faefc82008-06-17 11:11:38 -050077 if (of_device_is_compatible(dp, "nxp,usb-isp1761"))
78 devflags |= ISP1760_FLAG_ISP1761;
79
Nate Case3faefc82008-06-17 11:11:38 -050080 /* Some systems wire up only 16 of the 32 data lines */
Dave Martin8ad028b2011-12-02 16:58:18 +000081 of_property_read_u32(dp, "bus-width", &bus_width);
82 if (bus_width == 16)
Nate Case3faefc82008-06-17 11:11:38 -050083 devflags |= ISP1760_FLAG_BUS_WIDTH_16;
84
85 if (of_get_property(dp, "port1-otg", NULL) != NULL)
86 devflags |= ISP1760_FLAG_OTG_EN;
87
88 if (of_get_property(dp, "analog-oc", NULL) != NULL)
89 devflags |= ISP1760_FLAG_ANALOG_OC;
90
91 if (of_get_property(dp, "dack-polarity", NULL) != NULL)
92 devflags |= ISP1760_FLAG_DACK_POL_HIGH;
93
94 if (of_get_property(dp, "dreq-polarity", NULL) != NULL)
95 devflags |= ISP1760_FLAG_DREQ_POL_HIGH;
96
Joachim Foerster3a7655f2011-10-19 14:18:41 +020097 drvdata->rst_gpio = of_get_gpio_flags(dp, 0, &gpio_flags);
98 if (gpio_is_valid(drvdata->rst_gpio)) {
99 ret = gpio_request(drvdata->rst_gpio, dev_name(&dev->dev));
100 if (!ret) {
101 if (!(gpio_flags & OF_GPIO_ACTIVE_LOW)) {
102 devflags |= ISP1760_FLAG_RESET_ACTIVE_HIGH;
103 gpio_direction_output(drvdata->rst_gpio, 0);
104 } else {
105 gpio_direction_output(drvdata->rst_gpio, 1);
106 }
107 } else {
108 drvdata->rst_gpio = ret;
109 }
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200110 }
111
Joachim Foerster3a7655f2011-10-19 14:18:41 +0200112 drvdata->hcd = isp1760_register(memory.start, res_len, virq,
113 IRQF_SHARED, drvdata->rst_gpio,
114 &dev->dev, dev_name(&dev->dev),
115 devflags);
116 if (IS_ERR(drvdata->hcd)) {
117 ret = PTR_ERR(drvdata->hcd);
118 goto free_gpio;
119 }
120
Jingoo Han477527b2013-05-23 19:18:39 +0900121 platform_set_drvdata(dev, drvdata);
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200122 return ret;
123
Joachim Foerster3a7655f2011-10-19 14:18:41 +0200124free_gpio:
125 if (gpio_is_valid(drvdata->rst_gpio))
126 gpio_free(drvdata->rst_gpio);
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200127release_reg:
Tobias Klausere07afd32010-05-05 11:18:41 +0200128 release_mem_region(memory.start, res_len);
Julia Lawall30a0dee2011-12-23 18:39:30 +0100129free_data:
Joachim Foerster3a7655f2011-10-19 14:18:41 +0200130 kfree(drvdata);
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200131 return ret;
132}
133
Grant Likely2dc11582010-08-06 09:25:50 -0600134static int of_isp1760_remove(struct platform_device *dev)
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200135{
Jingoo Han477527b2013-05-23 19:18:39 +0900136 struct isp1760 *drvdata = platform_get_drvdata(dev);
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200137
Joachim Foerster3a7655f2011-10-19 14:18:41 +0200138 usb_remove_hcd(drvdata->hcd);
139 iounmap(drvdata->hcd->regs);
140 release_mem_region(drvdata->hcd->rsrc_start, drvdata->hcd->rsrc_len);
141 usb_put_hcd(drvdata->hcd);
142
143 if (gpio_is_valid(drvdata->rst_gpio))
144 gpio_free(drvdata->rst_gpio);
145
146 kfree(drvdata);
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200147 return 0;
148}
149
Németh Mártonc4386ad2010-01-10 15:35:03 +0100150static const struct of_device_id of_isp1760_match[] = {
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200151 {
152 .compatible = "nxp,usb-isp1760",
153 },
Nate Case3faefc82008-06-17 11:11:38 -0500154 {
155 .compatible = "nxp,usb-isp1761",
156 },
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200157 { },
158};
159MODULE_DEVICE_TABLE(of, of_isp1760_match);
160
Grant Likelyd35fb642011-02-22 21:08:34 -0700161static struct platform_driver isp1760_of_driver = {
Grant Likely40182942010-04-13 16:13:02 -0700162 .driver = {
163 .name = "nxp-isp1760",
164 .owner = THIS_MODULE,
165 .of_match_table = of_isp1760_match,
166 },
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200167 .probe = of_isp1760_probe,
168 .remove = of_isp1760_remove,
169};
170#endif
171
Sebastian Andrzej Siewiorff30bf12008-11-02 15:25:42 +0100172#ifdef CONFIG_PCI
Bill Pemberton41ac7b32012-11-19 13:21:48 -0500173static int isp1761_pci_probe(struct pci_dev *dev,
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200174 const struct pci_device_id *id)
175{
176 u8 latency, limit;
177 __u32 reg_data;
178 int retry_count;
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200179 struct usb_hcd *hcd;
Nate Case3faefc82008-06-17 11:11:38 -0500180 unsigned int devflags = 0;
Karl Bongers6013bbb2008-12-01 11:47:40 +0100181 int ret_status = 0;
182
183 resource_size_t pci_mem_phy0;
184 resource_size_t memlength;
185
186 u8 __iomem *chip_addr;
187 u8 __iomem *iobase;
188 resource_size_t nxp_pci_io_base;
189 resource_size_t iolength;
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200190
191 if (usb_disabled())
192 return -ENODEV;
193
194 if (pci_enable_device(dev) < 0)
195 return -ENODEV;
196
197 if (!dev->irq)
198 return -ENODEV;
199
200 /* Grab the PLX PCI mem maped port start address we need */
201 nxp_pci_io_base = pci_resource_start(dev, 0);
202 iolength = pci_resource_len(dev, 0);
203
204 if (!request_mem_region(nxp_pci_io_base, iolength, "ISP1761 IO MEM")) {
205 printk(KERN_ERR "request region #1\n");
206 return -EBUSY;
207 }
208
209 iobase = ioremap_nocache(nxp_pci_io_base, iolength);
210 if (!iobase) {
211 printk(KERN_ERR "ioremap #1\n");
Karl Bongers6013bbb2008-12-01 11:47:40 +0100212 ret_status = -ENOMEM;
213 goto cleanup1;
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200214 }
215 /* Grab the PLX PCI shared memory of the ISP 1761 we need */
216 pci_mem_phy0 = pci_resource_start(dev, 3);
Karl Bongers6013bbb2008-12-01 11:47:40 +0100217 memlength = pci_resource_len(dev, 3);
218 if (memlength < 0xffff) {
219 printk(KERN_ERR "memory length for this resource is wrong\n");
220 ret_status = -ENOMEM;
221 goto cleanup2;
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200222 }
223
Karl Bongers6013bbb2008-12-01 11:47:40 +0100224 if (!request_mem_region(pci_mem_phy0, memlength, "ISP-PCI")) {
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200225 printk(KERN_ERR "host controller already in use\n");
Karl Bongers6013bbb2008-12-01 11:47:40 +0100226 ret_status = -EBUSY;
227 goto cleanup2;
228 }
229
230 /* map available memory */
231 chip_addr = ioremap_nocache(pci_mem_phy0,memlength);
232 if (!chip_addr) {
233 printk(KERN_ERR "Error ioremap failed\n");
234 ret_status = -ENOMEM;
235 goto cleanup3;
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200236 }
237
238 /* bad pci latencies can contribute to overruns */
239 pci_read_config_byte(dev, PCI_LATENCY_TIMER, &latency);
240 if (latency) {
241 pci_read_config_byte(dev, PCI_MAX_LAT, &limit);
242 if (limit && limit < latency)
243 pci_write_config_byte(dev, PCI_LATENCY_TIMER, limit);
244 }
245
246 /* Try to check whether we can access Scratch Register of
247 * Host Controller or not. The initial PCI access is retried until
248 * local init for the PCI bridge is completed
249 */
250 retry_count = 20;
251 reg_data = 0;
252 while ((reg_data != 0xFACE) && retry_count) {
253 /*by default host is in 16bit mode, so
254 * io operations at this stage must be 16 bit
255 * */
256 writel(0xface, chip_addr + HC_SCRATCH_REG);
257 udelay(100);
Karl Bongers6013bbb2008-12-01 11:47:40 +0100258 reg_data = readl(chip_addr + HC_SCRATCH_REG) & 0x0000ffff;
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200259 retry_count--;
260 }
261
Karl Bongers6013bbb2008-12-01 11:47:40 +0100262 iounmap(chip_addr);
263
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200264 /* Host Controller presence is detected by writing to scratch register
265 * and reading back and checking the contents are same or not
266 */
267 if (reg_data != 0xFACE) {
Greg Kroah-Hartman802f3892008-08-14 09:37:34 -0700268 dev_err(&dev->dev, "scratch register mismatch %x\n", reg_data);
Karl Bongers6013bbb2008-12-01 11:47:40 +0100269 ret_status = -ENOMEM;
270 goto cleanup3;
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200271 }
272
273 pci_set_master(dev);
274
Karl Bongers6013bbb2008-12-01 11:47:40 +0100275 /* configure PLX PCI chip to pass interrupts */
276#define PLX_INT_CSR_REG 0x68
277 reg_data = readl(iobase + PLX_INT_CSR_REG);
278 reg_data |= 0x900;
279 writel(reg_data, iobase + PLX_INT_CSR_REG);
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200280
281 dev->dev.dma_mask = NULL;
Karl Bongers6013bbb2008-12-01 11:47:40 +0100282 hcd = isp1760_register(pci_mem_phy0, memlength, dev->irq,
Joachim Foerster3a7655f2011-10-19 14:18:41 +0200283 IRQF_SHARED, -ENOENT, &dev->dev, dev_name(&dev->dev),
Nate Case3faefc82008-06-17 11:11:38 -0500284 devflags);
Karl Bongers6013bbb2008-12-01 11:47:40 +0100285 if (IS_ERR(hcd)) {
286 ret_status = -ENODEV;
287 goto cleanup3;
Julien Brunelce5dee52008-09-24 18:00:36 +0200288 }
Karl Bongers6013bbb2008-12-01 11:47:40 +0100289
290 /* done with PLX IO access */
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200291 iounmap(iobase);
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200292 release_mem_region(nxp_pci_io_base, iolength);
Karl Bongers6013bbb2008-12-01 11:47:40 +0100293
294 pci_set_drvdata(dev, hcd);
295 return 0;
296
297cleanup3:
298 release_mem_region(pci_mem_phy0, memlength);
299cleanup2:
300 iounmap(iobase);
301cleanup1:
302 release_mem_region(nxp_pci_io_base, iolength);
303 return ret_status;
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200304}
Karl Bongers6013bbb2008-12-01 11:47:40 +0100305
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200306static void isp1761_pci_remove(struct pci_dev *dev)
307{
308 struct usb_hcd *hcd;
309
310 hcd = pci_get_drvdata(dev);
311
312 usb_remove_hcd(hcd);
313 iounmap(hcd->regs);
314 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
315 usb_put_hcd(hcd);
316
317 pci_disable_device(dev);
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200318}
319
320static void isp1761_pci_shutdown(struct pci_dev *dev)
321{
322 printk(KERN_ERR "ips1761_pci_shutdown\n");
323}
324
Sebastian Andrzej Siewior6c073562008-11-30 16:50:04 +0100325static const struct pci_device_id isp1760_plx [] = {
326 {
327 .class = PCI_CLASS_BRIDGE_OTHER << 8,
328 .class_mask = ~0,
329 .vendor = PCI_VENDOR_ID_PLX,
330 .device = 0x5406,
331 .subvendor = PCI_VENDOR_ID_PLX,
332 .subdevice = 0x9054,
333 },
334 { }
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200335};
336MODULE_DEVICE_TABLE(pci, isp1760_plx);
337
338static struct pci_driver isp1761_pci_driver = {
339 .name = "isp1760",
340 .id_table = isp1760_plx,
341 .probe = isp1761_pci_probe,
342 .remove = isp1761_pci_remove,
343 .shutdown = isp1761_pci_shutdown,
344};
345#endif
346
Bill Pemberton41ac7b32012-11-19 13:21:48 -0500347static int isp1760_plat_probe(struct platform_device *pdev)
Catalin Marinasf7e7aa52009-02-10 16:55:51 +0000348{
349 int ret = 0;
350 struct usb_hcd *hcd;
351 struct resource *mem_res;
352 struct resource *irq_res;
353 resource_size_t mem_size;
Jingoo Hand4f09e22013-07-30 19:59:40 +0900354 struct isp1760_platform_data *priv = dev_get_platdata(&pdev->dev);
Michael Hennerich9da69c62009-07-15 23:22:54 -0400355 unsigned int devflags = 0;
Yong Zhangb5dd18d2011-09-07 16:10:52 +0800356 unsigned long irqflags = IRQF_SHARED;
Catalin Marinasf7e7aa52009-02-10 16:55:51 +0000357
358 mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
359 if (!mem_res) {
360 pr_warning("isp1760: Memory resource not available\n");
361 ret = -ENODEV;
362 goto out;
363 }
364 mem_size = resource_size(mem_res);
365 if (!request_mem_region(mem_res->start, mem_size, "isp1760")) {
366 pr_warning("isp1760: Cannot reserve the memory resource\n");
367 ret = -EBUSY;
368 goto out;
369 }
370
371 irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
372 if (!irq_res) {
373 pr_warning("isp1760: IRQ resource not available\n");
Libo Chen72d9c8b2013-05-09 12:58:09 +0800374 ret = -ENODEV;
375 goto cleanup;
Catalin Marinasf7e7aa52009-02-10 16:55:51 +0000376 }
Libo Chen72d9c8b2013-05-09 12:58:09 +0800377
Catalin Marinasf7e7aa52009-02-10 16:55:51 +0000378 irqflags |= irq_res->flags & IRQF_TRIGGER_MASK;
379
Michael Hennerich9da69c62009-07-15 23:22:54 -0400380 if (priv) {
381 if (priv->is_isp1761)
382 devflags |= ISP1760_FLAG_ISP1761;
383 if (priv->bus_width_16)
384 devflags |= ISP1760_FLAG_BUS_WIDTH_16;
385 if (priv->port1_otg)
386 devflags |= ISP1760_FLAG_OTG_EN;
387 if (priv->analog_oc)
388 devflags |= ISP1760_FLAG_ANALOG_OC;
389 if (priv->dack_polarity_high)
390 devflags |= ISP1760_FLAG_DACK_POL_HIGH;
391 if (priv->dreq_polarity_high)
392 devflags |= ISP1760_FLAG_DREQ_POL_HIGH;
393 }
394
Catalin Marinasf7e7aa52009-02-10 16:55:51 +0000395 hcd = isp1760_register(mem_res->start, mem_size, irq_res->start,
Joachim Foerster3a7655f2011-10-19 14:18:41 +0200396 irqflags, -ENOENT,
397 &pdev->dev, dev_name(&pdev->dev), devflags);
Michael Grzeschik310e9e32012-04-05 14:56:07 +0200398
Jingoo Han477527b2013-05-23 19:18:39 +0900399 platform_set_drvdata(pdev, hcd);
Michael Grzeschik310e9e32012-04-05 14:56:07 +0200400
Catalin Marinasf7e7aa52009-02-10 16:55:51 +0000401 if (IS_ERR(hcd)) {
402 pr_warning("isp1760: Failed to register the HCD device\n");
403 ret = -ENODEV;
404 goto cleanup;
405 }
406
407 pr_info("ISP1760 USB device initialised\n");
408 return ret;
409
410cleanup:
411 release_mem_region(mem_res->start, mem_size);
412out:
413 return ret;
414}
415
Bill Pembertonfb4e98a2012-11-19 13:26:20 -0500416static int isp1760_plat_remove(struct platform_device *pdev)
Catalin Marinasf7e7aa52009-02-10 16:55:51 +0000417{
418 struct resource *mem_res;
419 resource_size_t mem_size;
Jingoo Han477527b2013-05-23 19:18:39 +0900420 struct usb_hcd *hcd = platform_get_drvdata(pdev);
Michael Grzeschik310e9e32012-04-05 14:56:07 +0200421
422 usb_remove_hcd(hcd);
Catalin Marinasf7e7aa52009-02-10 16:55:51 +0000423
424 mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
425 mem_size = resource_size(mem_res);
426 release_mem_region(mem_res->start, mem_size);
427
Michael Grzeschik310e9e32012-04-05 14:56:07 +0200428 usb_put_hcd(hcd);
429
Catalin Marinasf7e7aa52009-02-10 16:55:51 +0000430 return 0;
431}
432
433static struct platform_driver isp1760_plat_driver = {
434 .probe = isp1760_plat_probe,
Bill Pemberton76904172012-11-19 13:21:08 -0500435 .remove = isp1760_plat_remove,
Catalin Marinasf7e7aa52009-02-10 16:55:51 +0000436 .driver = {
437 .name = "isp1760",
438 },
439};
440
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200441static int __init isp1760_init(void)
442{
Catalin Marinasf7e7aa52009-02-10 16:55:51 +0000443 int ret, any_ret = -ENODEV;
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200444
445 init_kmem_once();
446
Catalin Marinasf7e7aa52009-02-10 16:55:51 +0000447 ret = platform_driver_register(&isp1760_plat_driver);
448 if (!ret)
449 any_ret = 0;
David Millerabf058e2011-12-21 17:31:54 -0500450#if defined(CONFIG_OF) && defined(CONFIG_OF_IRQ)
Grant Likelyd35fb642011-02-22 21:08:34 -0700451 ret = platform_driver_register(&isp1760_of_driver);
Catalin Marinasf7e7aa52009-02-10 16:55:51 +0000452 if (!ret)
453 any_ret = 0;
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200454#endif
Sebastian Andrzej Siewiorff30bf12008-11-02 15:25:42 +0100455#ifdef CONFIG_PCI
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200456 ret = pci_register_driver(&isp1761_pci_driver);
Catalin Marinasf7e7aa52009-02-10 16:55:51 +0000457 if (!ret)
458 any_ret = 0;
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200459#endif
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200460
Catalin Marinasf7e7aa52009-02-10 16:55:51 +0000461 if (any_ret)
462 deinit_kmem_cache();
463 return any_ret;
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200464}
465module_init(isp1760_init);
466
467static void __exit isp1760_exit(void)
468{
Catalin Marinasf7e7aa52009-02-10 16:55:51 +0000469 platform_driver_unregister(&isp1760_plat_driver);
David Millerabf058e2011-12-21 17:31:54 -0500470#if defined(CONFIG_OF) && defined(CONFIG_OF_IRQ)
Grant Likelyd35fb642011-02-22 21:08:34 -0700471 platform_driver_unregister(&isp1760_of_driver);
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200472#endif
Sebastian Andrzej Siewiorff30bf12008-11-02 15:25:42 +0100473#ifdef CONFIG_PCI
Sebastian Siewiordb11e472008-04-24 00:37:04 +0200474 pci_unregister_driver(&isp1761_pci_driver);
475#endif
476 deinit_kmem_cache();
477}
478module_exit(isp1760_exit);