Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Glue code for the ISP1760 driver and bus |
| 3 | * Currently there is support for |
| 4 | * - OpenFirmware |
| 5 | * - PCI |
Michael Hennerich | 9da69c6 | 2009-07-15 23:22:54 -0400 | [diff] [blame] | 6 | * - PDEV (generic platform device centralized driver model) |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 7 | * |
| 8 | * (c) 2007 Sebastian Siewior <bigeasy@linutronix.de> |
| 9 | * |
| 10 | */ |
| 11 | |
| 12 | #include <linux/usb.h> |
| 13 | #include <linux/io.h> |
Catalin Marinas | f7e7aa5 | 2009-02-10 16:55:51 +0000 | [diff] [blame] | 14 | #include <linux/platform_device.h> |
Michael Hennerich | 9da69c6 | 2009-07-15 23:22:54 -0400 | [diff] [blame] | 15 | #include <linux/usb/isp1760.h> |
Eric Lescouet | 27729aa | 2010-04-24 23:21:52 +0200 | [diff] [blame] | 16 | #include <linux/usb/hcd.h> |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 17 | |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 18 | #include "isp1760-hcd.h" |
| 19 | |
Sebastian Andrzej Siewior | ff30bf1 | 2008-11-02 15:25:42 +0100 | [diff] [blame] | 20 | #ifdef CONFIG_PPC_OF |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 21 | #include <linux/of.h> |
| 22 | #include <linux/of_platform.h> |
| 23 | #endif |
| 24 | |
Sebastian Andrzej Siewior | ff30bf1 | 2008-11-02 15:25:42 +0100 | [diff] [blame] | 25 | #ifdef CONFIG_PCI |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 26 | #include <linux/pci.h> |
| 27 | #endif |
| 28 | |
Sebastian Andrzej Siewior | ff30bf1 | 2008-11-02 15:25:42 +0100 | [diff] [blame] | 29 | #ifdef CONFIG_PPC_OF |
Grant Likely | d35fb64 | 2011-02-22 21:08:34 -0700 | [diff] [blame] | 30 | static int of_isp1760_probe(struct platform_device *dev) |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 31 | { |
| 32 | struct usb_hcd *hcd; |
Grant Likely | 61c7a08 | 2010-04-13 16:12:29 -0700 | [diff] [blame] | 33 | struct device_node *dp = dev->dev.of_node; |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 34 | struct resource *res; |
| 35 | struct resource memory; |
| 36 | struct of_irq oirq; |
| 37 | int virq; |
Tobias Klauser | e07afd3 | 2010-05-05 11:18:41 +0200 | [diff] [blame] | 38 | resource_size_t res_len; |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 39 | int ret; |
Nate Case | 3faefc8 | 2008-06-17 11:11:38 -0500 | [diff] [blame] | 40 | const unsigned int *prop; |
| 41 | unsigned int devflags = 0; |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 42 | |
| 43 | ret = of_address_to_resource(dp, 0, &memory); |
| 44 | if (ret) |
| 45 | return -ENXIO; |
| 46 | |
Tobias Klauser | e07afd3 | 2010-05-05 11:18:41 +0200 | [diff] [blame] | 47 | res_len = resource_size(&memory); |
| 48 | |
| 49 | res = request_mem_region(memory.start, res_len, dev_name(&dev->dev)); |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 50 | if (!res) |
| 51 | return -EBUSY; |
| 52 | |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 53 | if (of_irq_map_one(dp, 0, &oirq)) { |
| 54 | ret = -ENODEV; |
| 55 | goto release_reg; |
| 56 | } |
| 57 | |
| 58 | virq = irq_create_of_mapping(oirq.controller, oirq.specifier, |
| 59 | oirq.size); |
| 60 | |
Nate Case | 3faefc8 | 2008-06-17 11:11:38 -0500 | [diff] [blame] | 61 | if (of_device_is_compatible(dp, "nxp,usb-isp1761")) |
| 62 | devflags |= ISP1760_FLAG_ISP1761; |
| 63 | |
Nate Case | 3faefc8 | 2008-06-17 11:11:38 -0500 | [diff] [blame] | 64 | /* Some systems wire up only 16 of the 32 data lines */ |
| 65 | prop = of_get_property(dp, "bus-width", NULL); |
| 66 | if (prop && *prop == 16) |
| 67 | devflags |= ISP1760_FLAG_BUS_WIDTH_16; |
| 68 | |
| 69 | if (of_get_property(dp, "port1-otg", NULL) != NULL) |
| 70 | devflags |= ISP1760_FLAG_OTG_EN; |
| 71 | |
| 72 | if (of_get_property(dp, "analog-oc", NULL) != NULL) |
| 73 | devflags |= ISP1760_FLAG_ANALOG_OC; |
| 74 | |
| 75 | if (of_get_property(dp, "dack-polarity", NULL) != NULL) |
| 76 | devflags |= ISP1760_FLAG_DACK_POL_HIGH; |
| 77 | |
| 78 | if (of_get_property(dp, "dreq-polarity", NULL) != NULL) |
| 79 | devflags |= ISP1760_FLAG_DREQ_POL_HIGH; |
| 80 | |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 81 | hcd = isp1760_register(memory.start, res_len, virq, |
Yong Zhang | b5dd18d | 2011-09-07 16:10:52 +0800 | [diff] [blame^] | 82 | IRQF_SHARED, &dev->dev, dev_name(&dev->dev), |
Nate Case | 3faefc8 | 2008-06-17 11:11:38 -0500 | [diff] [blame] | 83 | devflags); |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 84 | if (IS_ERR(hcd)) { |
| 85 | ret = PTR_ERR(hcd); |
| 86 | goto release_reg; |
| 87 | } |
| 88 | |
| 89 | dev_set_drvdata(&dev->dev, hcd); |
| 90 | return ret; |
| 91 | |
| 92 | release_reg: |
Tobias Klauser | e07afd3 | 2010-05-05 11:18:41 +0200 | [diff] [blame] | 93 | release_mem_region(memory.start, res_len); |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 94 | return ret; |
| 95 | } |
| 96 | |
Grant Likely | 2dc1158 | 2010-08-06 09:25:50 -0600 | [diff] [blame] | 97 | static int of_isp1760_remove(struct platform_device *dev) |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 98 | { |
| 99 | struct usb_hcd *hcd = dev_get_drvdata(&dev->dev); |
| 100 | |
| 101 | dev_set_drvdata(&dev->dev, NULL); |
| 102 | |
| 103 | usb_remove_hcd(hcd); |
| 104 | iounmap(hcd->regs); |
| 105 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
| 106 | usb_put_hcd(hcd); |
| 107 | return 0; |
| 108 | } |
| 109 | |
Németh Márton | c4386ad | 2010-01-10 15:35:03 +0100 | [diff] [blame] | 110 | static const struct of_device_id of_isp1760_match[] = { |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 111 | { |
| 112 | .compatible = "nxp,usb-isp1760", |
| 113 | }, |
Nate Case | 3faefc8 | 2008-06-17 11:11:38 -0500 | [diff] [blame] | 114 | { |
| 115 | .compatible = "nxp,usb-isp1761", |
| 116 | }, |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 117 | { }, |
| 118 | }; |
| 119 | MODULE_DEVICE_TABLE(of, of_isp1760_match); |
| 120 | |
Grant Likely | d35fb64 | 2011-02-22 21:08:34 -0700 | [diff] [blame] | 121 | static struct platform_driver isp1760_of_driver = { |
Grant Likely | 4018294 | 2010-04-13 16:13:02 -0700 | [diff] [blame] | 122 | .driver = { |
| 123 | .name = "nxp-isp1760", |
| 124 | .owner = THIS_MODULE, |
| 125 | .of_match_table = of_isp1760_match, |
| 126 | }, |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 127 | .probe = of_isp1760_probe, |
| 128 | .remove = of_isp1760_remove, |
| 129 | }; |
| 130 | #endif |
| 131 | |
Sebastian Andrzej Siewior | ff30bf1 | 2008-11-02 15:25:42 +0100 | [diff] [blame] | 132 | #ifdef CONFIG_PCI |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 133 | static int __devinit isp1761_pci_probe(struct pci_dev *dev, |
| 134 | const struct pci_device_id *id) |
| 135 | { |
| 136 | u8 latency, limit; |
| 137 | __u32 reg_data; |
| 138 | int retry_count; |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 139 | struct usb_hcd *hcd; |
Nate Case | 3faefc8 | 2008-06-17 11:11:38 -0500 | [diff] [blame] | 140 | unsigned int devflags = 0; |
Karl Bongers | 6013bbb | 2008-12-01 11:47:40 +0100 | [diff] [blame] | 141 | int ret_status = 0; |
| 142 | |
| 143 | resource_size_t pci_mem_phy0; |
| 144 | resource_size_t memlength; |
| 145 | |
| 146 | u8 __iomem *chip_addr; |
| 147 | u8 __iomem *iobase; |
| 148 | resource_size_t nxp_pci_io_base; |
| 149 | resource_size_t iolength; |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 150 | |
| 151 | if (usb_disabled()) |
| 152 | return -ENODEV; |
| 153 | |
| 154 | if (pci_enable_device(dev) < 0) |
| 155 | return -ENODEV; |
| 156 | |
| 157 | if (!dev->irq) |
| 158 | return -ENODEV; |
| 159 | |
| 160 | /* Grab the PLX PCI mem maped port start address we need */ |
| 161 | nxp_pci_io_base = pci_resource_start(dev, 0); |
| 162 | iolength = pci_resource_len(dev, 0); |
| 163 | |
| 164 | if (!request_mem_region(nxp_pci_io_base, iolength, "ISP1761 IO MEM")) { |
| 165 | printk(KERN_ERR "request region #1\n"); |
| 166 | return -EBUSY; |
| 167 | } |
| 168 | |
| 169 | iobase = ioremap_nocache(nxp_pci_io_base, iolength); |
| 170 | if (!iobase) { |
| 171 | printk(KERN_ERR "ioremap #1\n"); |
Karl Bongers | 6013bbb | 2008-12-01 11:47:40 +0100 | [diff] [blame] | 172 | ret_status = -ENOMEM; |
| 173 | goto cleanup1; |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 174 | } |
| 175 | /* Grab the PLX PCI shared memory of the ISP 1761 we need */ |
| 176 | pci_mem_phy0 = pci_resource_start(dev, 3); |
Karl Bongers | 6013bbb | 2008-12-01 11:47:40 +0100 | [diff] [blame] | 177 | memlength = pci_resource_len(dev, 3); |
| 178 | if (memlength < 0xffff) { |
| 179 | printk(KERN_ERR "memory length for this resource is wrong\n"); |
| 180 | ret_status = -ENOMEM; |
| 181 | goto cleanup2; |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 182 | } |
| 183 | |
Karl Bongers | 6013bbb | 2008-12-01 11:47:40 +0100 | [diff] [blame] | 184 | if (!request_mem_region(pci_mem_phy0, memlength, "ISP-PCI")) { |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 185 | printk(KERN_ERR "host controller already in use\n"); |
Karl Bongers | 6013bbb | 2008-12-01 11:47:40 +0100 | [diff] [blame] | 186 | ret_status = -EBUSY; |
| 187 | goto cleanup2; |
| 188 | } |
| 189 | |
| 190 | /* map available memory */ |
| 191 | chip_addr = ioremap_nocache(pci_mem_phy0,memlength); |
| 192 | if (!chip_addr) { |
| 193 | printk(KERN_ERR "Error ioremap failed\n"); |
| 194 | ret_status = -ENOMEM; |
| 195 | goto cleanup3; |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | /* bad pci latencies can contribute to overruns */ |
| 199 | pci_read_config_byte(dev, PCI_LATENCY_TIMER, &latency); |
| 200 | if (latency) { |
| 201 | pci_read_config_byte(dev, PCI_MAX_LAT, &limit); |
| 202 | if (limit && limit < latency) |
| 203 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, limit); |
| 204 | } |
| 205 | |
| 206 | /* Try to check whether we can access Scratch Register of |
| 207 | * Host Controller or not. The initial PCI access is retried until |
| 208 | * local init for the PCI bridge is completed |
| 209 | */ |
| 210 | retry_count = 20; |
| 211 | reg_data = 0; |
| 212 | while ((reg_data != 0xFACE) && retry_count) { |
| 213 | /*by default host is in 16bit mode, so |
| 214 | * io operations at this stage must be 16 bit |
| 215 | * */ |
| 216 | writel(0xface, chip_addr + HC_SCRATCH_REG); |
| 217 | udelay(100); |
Karl Bongers | 6013bbb | 2008-12-01 11:47:40 +0100 | [diff] [blame] | 218 | reg_data = readl(chip_addr + HC_SCRATCH_REG) & 0x0000ffff; |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 219 | retry_count--; |
| 220 | } |
| 221 | |
Karl Bongers | 6013bbb | 2008-12-01 11:47:40 +0100 | [diff] [blame] | 222 | iounmap(chip_addr); |
| 223 | |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 224 | /* Host Controller presence is detected by writing to scratch register |
| 225 | * and reading back and checking the contents are same or not |
| 226 | */ |
| 227 | if (reg_data != 0xFACE) { |
Greg Kroah-Hartman | 802f389 | 2008-08-14 09:37:34 -0700 | [diff] [blame] | 228 | dev_err(&dev->dev, "scratch register mismatch %x\n", reg_data); |
Karl Bongers | 6013bbb | 2008-12-01 11:47:40 +0100 | [diff] [blame] | 229 | ret_status = -ENOMEM; |
| 230 | goto cleanup3; |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | pci_set_master(dev); |
| 234 | |
Karl Bongers | 6013bbb | 2008-12-01 11:47:40 +0100 | [diff] [blame] | 235 | /* configure PLX PCI chip to pass interrupts */ |
| 236 | #define PLX_INT_CSR_REG 0x68 |
| 237 | reg_data = readl(iobase + PLX_INT_CSR_REG); |
| 238 | reg_data |= 0x900; |
| 239 | writel(reg_data, iobase + PLX_INT_CSR_REG); |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 240 | |
| 241 | dev->dev.dma_mask = NULL; |
Karl Bongers | 6013bbb | 2008-12-01 11:47:40 +0100 | [diff] [blame] | 242 | hcd = isp1760_register(pci_mem_phy0, memlength, dev->irq, |
Yong Zhang | b5dd18d | 2011-09-07 16:10:52 +0800 | [diff] [blame^] | 243 | IRQF_SHARED, &dev->dev, dev_name(&dev->dev), |
Nate Case | 3faefc8 | 2008-06-17 11:11:38 -0500 | [diff] [blame] | 244 | devflags); |
Karl Bongers | 6013bbb | 2008-12-01 11:47:40 +0100 | [diff] [blame] | 245 | if (IS_ERR(hcd)) { |
| 246 | ret_status = -ENODEV; |
| 247 | goto cleanup3; |
Julien Brunel | ce5dee5 | 2008-09-24 18:00:36 +0200 | [diff] [blame] | 248 | } |
Karl Bongers | 6013bbb | 2008-12-01 11:47:40 +0100 | [diff] [blame] | 249 | |
| 250 | /* done with PLX IO access */ |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 251 | iounmap(iobase); |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 252 | release_mem_region(nxp_pci_io_base, iolength); |
Karl Bongers | 6013bbb | 2008-12-01 11:47:40 +0100 | [diff] [blame] | 253 | |
| 254 | pci_set_drvdata(dev, hcd); |
| 255 | return 0; |
| 256 | |
| 257 | cleanup3: |
| 258 | release_mem_region(pci_mem_phy0, memlength); |
| 259 | cleanup2: |
| 260 | iounmap(iobase); |
| 261 | cleanup1: |
| 262 | release_mem_region(nxp_pci_io_base, iolength); |
| 263 | return ret_status; |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 264 | } |
Karl Bongers | 6013bbb | 2008-12-01 11:47:40 +0100 | [diff] [blame] | 265 | |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 266 | static void isp1761_pci_remove(struct pci_dev *dev) |
| 267 | { |
| 268 | struct usb_hcd *hcd; |
| 269 | |
| 270 | hcd = pci_get_drvdata(dev); |
| 271 | |
| 272 | usb_remove_hcd(hcd); |
| 273 | iounmap(hcd->regs); |
| 274 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
| 275 | usb_put_hcd(hcd); |
| 276 | |
| 277 | pci_disable_device(dev); |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | static void isp1761_pci_shutdown(struct pci_dev *dev) |
| 281 | { |
| 282 | printk(KERN_ERR "ips1761_pci_shutdown\n"); |
| 283 | } |
| 284 | |
Sebastian Andrzej Siewior | 6c07356 | 2008-11-30 16:50:04 +0100 | [diff] [blame] | 285 | static const struct pci_device_id isp1760_plx [] = { |
| 286 | { |
| 287 | .class = PCI_CLASS_BRIDGE_OTHER << 8, |
| 288 | .class_mask = ~0, |
| 289 | .vendor = PCI_VENDOR_ID_PLX, |
| 290 | .device = 0x5406, |
| 291 | .subvendor = PCI_VENDOR_ID_PLX, |
| 292 | .subdevice = 0x9054, |
| 293 | }, |
| 294 | { } |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 295 | }; |
| 296 | MODULE_DEVICE_TABLE(pci, isp1760_plx); |
| 297 | |
| 298 | static struct pci_driver isp1761_pci_driver = { |
| 299 | .name = "isp1760", |
| 300 | .id_table = isp1760_plx, |
| 301 | .probe = isp1761_pci_probe, |
| 302 | .remove = isp1761_pci_remove, |
| 303 | .shutdown = isp1761_pci_shutdown, |
| 304 | }; |
| 305 | #endif |
| 306 | |
Catalin Marinas | f7e7aa5 | 2009-02-10 16:55:51 +0000 | [diff] [blame] | 307 | static int __devinit isp1760_plat_probe(struct platform_device *pdev) |
| 308 | { |
| 309 | int ret = 0; |
| 310 | struct usb_hcd *hcd; |
| 311 | struct resource *mem_res; |
| 312 | struct resource *irq_res; |
| 313 | resource_size_t mem_size; |
Michael Hennerich | 9da69c6 | 2009-07-15 23:22:54 -0400 | [diff] [blame] | 314 | struct isp1760_platform_data *priv = pdev->dev.platform_data; |
| 315 | unsigned int devflags = 0; |
Yong Zhang | b5dd18d | 2011-09-07 16:10:52 +0800 | [diff] [blame^] | 316 | unsigned long irqflags = IRQF_SHARED; |
Catalin Marinas | f7e7aa5 | 2009-02-10 16:55:51 +0000 | [diff] [blame] | 317 | |
| 318 | mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 319 | if (!mem_res) { |
| 320 | pr_warning("isp1760: Memory resource not available\n"); |
| 321 | ret = -ENODEV; |
| 322 | goto out; |
| 323 | } |
| 324 | mem_size = resource_size(mem_res); |
| 325 | if (!request_mem_region(mem_res->start, mem_size, "isp1760")) { |
| 326 | pr_warning("isp1760: Cannot reserve the memory resource\n"); |
| 327 | ret = -EBUSY; |
| 328 | goto out; |
| 329 | } |
| 330 | |
| 331 | irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
| 332 | if (!irq_res) { |
| 333 | pr_warning("isp1760: IRQ resource not available\n"); |
| 334 | return -ENODEV; |
| 335 | } |
| 336 | irqflags |= irq_res->flags & IRQF_TRIGGER_MASK; |
| 337 | |
Michael Hennerich | 9da69c6 | 2009-07-15 23:22:54 -0400 | [diff] [blame] | 338 | if (priv) { |
| 339 | if (priv->is_isp1761) |
| 340 | devflags |= ISP1760_FLAG_ISP1761; |
| 341 | if (priv->bus_width_16) |
| 342 | devflags |= ISP1760_FLAG_BUS_WIDTH_16; |
| 343 | if (priv->port1_otg) |
| 344 | devflags |= ISP1760_FLAG_OTG_EN; |
| 345 | if (priv->analog_oc) |
| 346 | devflags |= ISP1760_FLAG_ANALOG_OC; |
| 347 | if (priv->dack_polarity_high) |
| 348 | devflags |= ISP1760_FLAG_DACK_POL_HIGH; |
| 349 | if (priv->dreq_polarity_high) |
| 350 | devflags |= ISP1760_FLAG_DREQ_POL_HIGH; |
| 351 | } |
| 352 | |
Catalin Marinas | f7e7aa5 | 2009-02-10 16:55:51 +0000 | [diff] [blame] | 353 | hcd = isp1760_register(mem_res->start, mem_size, irq_res->start, |
Michael Hennerich | 9da69c6 | 2009-07-15 23:22:54 -0400 | [diff] [blame] | 354 | irqflags, &pdev->dev, dev_name(&pdev->dev), devflags); |
Catalin Marinas | f7e7aa5 | 2009-02-10 16:55:51 +0000 | [diff] [blame] | 355 | if (IS_ERR(hcd)) { |
| 356 | pr_warning("isp1760: Failed to register the HCD device\n"); |
| 357 | ret = -ENODEV; |
| 358 | goto cleanup; |
| 359 | } |
| 360 | |
| 361 | pr_info("ISP1760 USB device initialised\n"); |
| 362 | return ret; |
| 363 | |
| 364 | cleanup: |
| 365 | release_mem_region(mem_res->start, mem_size); |
| 366 | out: |
| 367 | return ret; |
| 368 | } |
| 369 | |
| 370 | static int __devexit isp1760_plat_remove(struct platform_device *pdev) |
| 371 | { |
| 372 | struct resource *mem_res; |
| 373 | resource_size_t mem_size; |
| 374 | |
| 375 | mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 376 | mem_size = resource_size(mem_res); |
| 377 | release_mem_region(mem_res->start, mem_size); |
| 378 | |
| 379 | return 0; |
| 380 | } |
| 381 | |
| 382 | static struct platform_driver isp1760_plat_driver = { |
| 383 | .probe = isp1760_plat_probe, |
Mike Frysinger | 4198e4f | 2009-06-11 21:59:00 -0400 | [diff] [blame] | 384 | .remove = __devexit_p(isp1760_plat_remove), |
Catalin Marinas | f7e7aa5 | 2009-02-10 16:55:51 +0000 | [diff] [blame] | 385 | .driver = { |
| 386 | .name = "isp1760", |
| 387 | }, |
| 388 | }; |
| 389 | |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 390 | static int __init isp1760_init(void) |
| 391 | { |
Catalin Marinas | f7e7aa5 | 2009-02-10 16:55:51 +0000 | [diff] [blame] | 392 | int ret, any_ret = -ENODEV; |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 393 | |
| 394 | init_kmem_once(); |
| 395 | |
Catalin Marinas | f7e7aa5 | 2009-02-10 16:55:51 +0000 | [diff] [blame] | 396 | ret = platform_driver_register(&isp1760_plat_driver); |
| 397 | if (!ret) |
| 398 | any_ret = 0; |
Sebastian Andrzej Siewior | ff30bf1 | 2008-11-02 15:25:42 +0100 | [diff] [blame] | 399 | #ifdef CONFIG_PPC_OF |
Grant Likely | d35fb64 | 2011-02-22 21:08:34 -0700 | [diff] [blame] | 400 | ret = platform_driver_register(&isp1760_of_driver); |
Catalin Marinas | f7e7aa5 | 2009-02-10 16:55:51 +0000 | [diff] [blame] | 401 | if (!ret) |
| 402 | any_ret = 0; |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 403 | #endif |
Sebastian Andrzej Siewior | ff30bf1 | 2008-11-02 15:25:42 +0100 | [diff] [blame] | 404 | #ifdef CONFIG_PCI |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 405 | ret = pci_register_driver(&isp1761_pci_driver); |
Catalin Marinas | f7e7aa5 | 2009-02-10 16:55:51 +0000 | [diff] [blame] | 406 | if (!ret) |
| 407 | any_ret = 0; |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 408 | #endif |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 409 | |
Catalin Marinas | f7e7aa5 | 2009-02-10 16:55:51 +0000 | [diff] [blame] | 410 | if (any_ret) |
| 411 | deinit_kmem_cache(); |
| 412 | return any_ret; |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 413 | } |
| 414 | module_init(isp1760_init); |
| 415 | |
| 416 | static void __exit isp1760_exit(void) |
| 417 | { |
Catalin Marinas | f7e7aa5 | 2009-02-10 16:55:51 +0000 | [diff] [blame] | 418 | platform_driver_unregister(&isp1760_plat_driver); |
Sebastian Andrzej Siewior | ff30bf1 | 2008-11-02 15:25:42 +0100 | [diff] [blame] | 419 | #ifdef CONFIG_PPC_OF |
Grant Likely | d35fb64 | 2011-02-22 21:08:34 -0700 | [diff] [blame] | 420 | platform_driver_unregister(&isp1760_of_driver); |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 421 | #endif |
Sebastian Andrzej Siewior | ff30bf1 | 2008-11-02 15:25:42 +0100 | [diff] [blame] | 422 | #ifdef CONFIG_PCI |
Sebastian Siewior | db11e47 | 2008-04-24 00:37:04 +0200 | [diff] [blame] | 423 | pci_unregister_driver(&isp1761_pci_driver); |
| 424 | #endif |
| 425 | deinit_kmem_cache(); |
| 426 | } |
| 427 | module_exit(isp1760_exit); |