| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * OHCI HCD (Host Controller Driver) for USB. | 
|  | 3 | * | 
|  | 4 | * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at> | 
|  | 5 | * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net> | 
|  | 6 | * (C) Copyright 2002 Hewlett-Packard Company | 
|  | 7 | * | 
|  | 8 | * USB Bus Glue for Samsung S3C2410 | 
|  | 9 | * | 
|  | 10 | * Written by Christopher Hoover <ch@hpl.hp.com> | 
| Uwe Kleine-König | ac310bb | 2008-07-10 17:30:46 -0700 | [diff] [blame] | 11 | * Based on fragments of previous driver by Russell King et al. | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 12 | * | 
|  | 13 | * Modified for S3C2410 from ohci-sa1111.c, ohci-omap.c and ohci-lh7a40.c | 
|  | 14 | *	by Ben Dooks, <ben@simtec.co.uk> | 
|  | 15 | *	Copyright (C) 2004 Simtec Electronics | 
|  | 16 | * | 
|  | 17 | * Thanks to basprog@mail.ru for updates to newer kernels | 
|  | 18 | * | 
|  | 19 | * This file is licenced under the GPL. | 
|  | 20 | */ | 
|  | 21 |  | 
| Russell King | d052d1b | 2005-10-29 19:07:23 +0100 | [diff] [blame] | 22 | #include <linux/platform_device.h> | 
| Russell King | f8ce254 | 2006-01-07 16:15:52 +0000 | [diff] [blame] | 23 | #include <linux/clk.h> | 
| Ben Dooks | 49121aa | 2009-03-07 11:44:21 +0000 | [diff] [blame] | 24 | #include <plat/usb-control.h> | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 25 |  | 
|  | 26 | #define valid_port(idx) ((idx) == 1 || (idx) == 2) | 
|  | 27 |  | 
|  | 28 | /* clock device associated with the hcd */ | 
|  | 29 |  | 
|  | 30 | static struct clk *clk; | 
| Ben Dooks | 3799c40 | 2006-04-02 01:45:00 +0100 | [diff] [blame] | 31 | static struct clk *usb_clk; | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 32 |  | 
|  | 33 | /* forward definitions */ | 
|  | 34 |  | 
|  | 35 | static void s3c2410_hcd_oc(struct s3c2410_hcd_info *info, int port_oc); | 
|  | 36 |  | 
|  | 37 | /* conversion functions */ | 
|  | 38 |  | 
| Ben Dooks | f096e04 | 2006-03-21 22:54:47 +0000 | [diff] [blame] | 39 | static struct s3c2410_hcd_info *to_s3c2410_info(struct usb_hcd *hcd) | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 40 | { | 
|  | 41 | return hcd->self.controller->platform_data; | 
|  | 42 | } | 
|  | 43 |  | 
|  | 44 | static void s3c2410_start_hc(struct platform_device *dev, struct usb_hcd *hcd) | 
|  | 45 | { | 
|  | 46 | struct s3c2410_hcd_info *info = dev->dev.platform_data; | 
|  | 47 |  | 
|  | 48 | dev_dbg(&dev->dev, "s3c2410_start_hc:\n"); | 
| Ben Dooks | 3799c40 | 2006-04-02 01:45:00 +0100 | [diff] [blame] | 49 |  | 
|  | 50 | clk_enable(usb_clk); | 
|  | 51 | mdelay(2);			/* let the bus clock stabilise */ | 
|  | 52 |  | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 53 | clk_enable(clk); | 
|  | 54 |  | 
|  | 55 | if (info != NULL) { | 
|  | 56 | info->hcd	= hcd; | 
|  | 57 | info->report_oc = s3c2410_hcd_oc; | 
|  | 58 |  | 
|  | 59 | if (info->enable_oc != NULL) { | 
|  | 60 | (info->enable_oc)(info, 1); | 
|  | 61 | } | 
|  | 62 | } | 
|  | 63 | } | 
|  | 64 |  | 
|  | 65 | static void s3c2410_stop_hc(struct platform_device *dev) | 
|  | 66 | { | 
|  | 67 | struct s3c2410_hcd_info *info = dev->dev.platform_data; | 
|  | 68 |  | 
|  | 69 | dev_dbg(&dev->dev, "s3c2410_stop_hc:\n"); | 
|  | 70 |  | 
|  | 71 | if (info != NULL) { | 
|  | 72 | info->report_oc = NULL; | 
|  | 73 | info->hcd	= NULL; | 
|  | 74 |  | 
|  | 75 | if (info->enable_oc != NULL) { | 
|  | 76 | (info->enable_oc)(info, 0); | 
|  | 77 | } | 
|  | 78 | } | 
|  | 79 |  | 
|  | 80 | clk_disable(clk); | 
| Ben Dooks | 3799c40 | 2006-04-02 01:45:00 +0100 | [diff] [blame] | 81 | clk_disable(usb_clk); | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 82 | } | 
|  | 83 |  | 
|  | 84 | /* ohci_s3c2410_hub_status_data | 
|  | 85 | * | 
|  | 86 | * update the status data from the hub with anything that | 
|  | 87 | * has been detected by our system | 
|  | 88 | */ | 
|  | 89 |  | 
|  | 90 | static int | 
|  | 91 | ohci_s3c2410_hub_status_data (struct usb_hcd *hcd, char *buf) | 
|  | 92 | { | 
|  | 93 | struct s3c2410_hcd_info *info = to_s3c2410_info(hcd); | 
|  | 94 | struct s3c2410_hcd_port *port; | 
|  | 95 | int orig; | 
|  | 96 | int portno; | 
|  | 97 |  | 
|  | 98 | orig  = ohci_hub_status_data (hcd, buf); | 
|  | 99 |  | 
|  | 100 | if (info == NULL) | 
|  | 101 | return orig; | 
|  | 102 |  | 
|  | 103 | port = &info->port[0]; | 
|  | 104 |  | 
|  | 105 | /* mark any changed port as changed */ | 
|  | 106 |  | 
|  | 107 | for (portno = 0; portno < 2; port++, portno++) { | 
|  | 108 | if (port->oc_changed == 1 && | 
|  | 109 | port->flags & S3C_HCDFLG_USED) { | 
|  | 110 | dev_dbg(hcd->self.controller, | 
|  | 111 | "oc change on port %d\n", portno); | 
|  | 112 |  | 
|  | 113 | if (orig < 1) | 
|  | 114 | orig = 1; | 
|  | 115 |  | 
|  | 116 | buf[0] |= 1<<(portno+1); | 
|  | 117 | } | 
|  | 118 | } | 
|  | 119 |  | 
|  | 120 | return orig; | 
|  | 121 | } | 
|  | 122 |  | 
|  | 123 | /* s3c2410_usb_set_power | 
|  | 124 | * | 
|  | 125 | * configure the power on a port, by calling the platform device | 
|  | 126 | * routine registered with the platform device | 
|  | 127 | */ | 
|  | 128 |  | 
|  | 129 | static void s3c2410_usb_set_power(struct s3c2410_hcd_info *info, | 
|  | 130 | int port, int to) | 
|  | 131 | { | 
|  | 132 | if (info == NULL) | 
|  | 133 | return; | 
|  | 134 |  | 
|  | 135 | if (info->power_control != NULL) { | 
|  | 136 | info->port[port-1].power = to; | 
| Ben Dooks | ba44e7c | 2005-08-09 15:04:00 +0100 | [diff] [blame] | 137 | (info->power_control)(port-1, to); | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 138 | } | 
|  | 139 | } | 
|  | 140 |  | 
|  | 141 | /* ohci_s3c2410_hub_control | 
|  | 142 | * | 
|  | 143 | * look at control requests to the hub, and see if we need | 
|  | 144 | * to take any action or over-ride the results from the | 
|  | 145 | * request. | 
|  | 146 | */ | 
|  | 147 |  | 
|  | 148 | static int ohci_s3c2410_hub_control ( | 
|  | 149 | struct usb_hcd	*hcd, | 
|  | 150 | u16		typeReq, | 
|  | 151 | u16		wValue, | 
|  | 152 | u16		wIndex, | 
|  | 153 | char		*buf, | 
|  | 154 | u16		wLength) | 
|  | 155 | { | 
|  | 156 | struct s3c2410_hcd_info *info = to_s3c2410_info(hcd); | 
|  | 157 | struct usb_hub_descriptor *desc; | 
|  | 158 | int ret = -EINVAL; | 
|  | 159 | u32 *data = (u32 *)buf; | 
|  | 160 |  | 
|  | 161 | dev_dbg(hcd->self.controller, | 
|  | 162 | "s3c2410_hub_control(%p,0x%04x,0x%04x,0x%04x,%p,%04x)\n", | 
|  | 163 | hcd, typeReq, wValue, wIndex, buf, wLength); | 
|  | 164 |  | 
| Alexey Dobriyan | 7f927fc | 2006-03-28 01:56:53 -0800 | [diff] [blame] | 165 | /* if we are only an humble host without any special capabilities | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 166 | * process the request straight away and exit */ | 
|  | 167 |  | 
|  | 168 | if (info == NULL) { | 
|  | 169 | ret = ohci_hub_control(hcd, typeReq, wValue, | 
|  | 170 | wIndex, buf, wLength); | 
|  | 171 | goto out; | 
|  | 172 | } | 
|  | 173 |  | 
|  | 174 | /* check the request to see if it needs handling */ | 
|  | 175 |  | 
|  | 176 | switch (typeReq) { | 
|  | 177 | case SetPortFeature: | 
|  | 178 | if (wValue == USB_PORT_FEAT_POWER) { | 
|  | 179 | dev_dbg(hcd->self.controller, "SetPortFeat: POWER\n"); | 
|  | 180 | s3c2410_usb_set_power(info, wIndex, 1); | 
|  | 181 | goto out; | 
|  | 182 | } | 
|  | 183 | break; | 
|  | 184 |  | 
|  | 185 | case ClearPortFeature: | 
|  | 186 | switch (wValue) { | 
|  | 187 | case USB_PORT_FEAT_C_OVER_CURRENT: | 
|  | 188 | dev_dbg(hcd->self.controller, | 
|  | 189 | "ClearPortFeature: C_OVER_CURRENT\n"); | 
|  | 190 |  | 
|  | 191 | if (valid_port(wIndex)) { | 
|  | 192 | info->port[wIndex-1].oc_changed = 0; | 
|  | 193 | info->port[wIndex-1].oc_status = 0; | 
|  | 194 | } | 
|  | 195 |  | 
|  | 196 | goto out; | 
|  | 197 |  | 
|  | 198 | case USB_PORT_FEAT_OVER_CURRENT: | 
|  | 199 | dev_dbg(hcd->self.controller, | 
|  | 200 | "ClearPortFeature: OVER_CURRENT\n"); | 
|  | 201 |  | 
|  | 202 | if (valid_port(wIndex)) { | 
|  | 203 | info->port[wIndex-1].oc_status = 0; | 
|  | 204 | } | 
|  | 205 |  | 
|  | 206 | goto out; | 
|  | 207 |  | 
|  | 208 | case USB_PORT_FEAT_POWER: | 
|  | 209 | dev_dbg(hcd->self.controller, | 
|  | 210 | "ClearPortFeature: POWER\n"); | 
|  | 211 |  | 
|  | 212 | if (valid_port(wIndex)) { | 
|  | 213 | s3c2410_usb_set_power(info, wIndex, 0); | 
|  | 214 | return 0; | 
|  | 215 | } | 
|  | 216 | } | 
|  | 217 | break; | 
|  | 218 | } | 
|  | 219 |  | 
|  | 220 | ret = ohci_hub_control(hcd, typeReq, wValue, wIndex, buf, wLength); | 
|  | 221 | if (ret) | 
|  | 222 | goto out; | 
|  | 223 |  | 
|  | 224 | switch (typeReq) { | 
|  | 225 | case GetHubDescriptor: | 
|  | 226 |  | 
|  | 227 | /* update the hub's descriptor */ | 
|  | 228 |  | 
|  | 229 | desc = (struct usb_hub_descriptor *)buf; | 
|  | 230 |  | 
|  | 231 | if (info->power_control == NULL) | 
|  | 232 | return ret; | 
|  | 233 |  | 
|  | 234 | dev_dbg(hcd->self.controller, "wHubCharacteristics 0x%04x\n", | 
|  | 235 | desc->wHubCharacteristics); | 
|  | 236 |  | 
|  | 237 | /* remove the old configurations for power-switching, and | 
|  | 238 | * over-current protection, and insert our new configuration | 
|  | 239 | */ | 
|  | 240 |  | 
|  | 241 | desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_LPSM); | 
|  | 242 | desc->wHubCharacteristics |= cpu_to_le16(0x0001); | 
|  | 243 |  | 
|  | 244 | if (info->enable_oc) { | 
|  | 245 | desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_OCPM); | 
|  | 246 | desc->wHubCharacteristics |=  cpu_to_le16(0x0008|0x0001); | 
|  | 247 | } | 
|  | 248 |  | 
|  | 249 | dev_dbg(hcd->self.controller, "wHubCharacteristics after 0x%04x\n", | 
|  | 250 | desc->wHubCharacteristics); | 
|  | 251 |  | 
|  | 252 | return ret; | 
|  | 253 |  | 
|  | 254 | case GetPortStatus: | 
|  | 255 | /* check port status */ | 
|  | 256 |  | 
|  | 257 | dev_dbg(hcd->self.controller, "GetPortStatus(%d)\n", wIndex); | 
|  | 258 |  | 
|  | 259 | if (valid_port(wIndex)) { | 
|  | 260 | if (info->port[wIndex-1].oc_changed) { | 
|  | 261 | *data |= cpu_to_le32(RH_PS_OCIC); | 
|  | 262 | } | 
|  | 263 |  | 
|  | 264 | if (info->port[wIndex-1].oc_status) { | 
|  | 265 | *data |= cpu_to_le32(RH_PS_POCI); | 
|  | 266 | } | 
|  | 267 | } | 
|  | 268 | } | 
|  | 269 |  | 
|  | 270 | out: | 
|  | 271 | return ret; | 
|  | 272 | } | 
|  | 273 |  | 
|  | 274 | /* s3c2410_hcd_oc | 
|  | 275 | * | 
|  | 276 | * handle an over-current report | 
|  | 277 | */ | 
|  | 278 |  | 
|  | 279 | static void s3c2410_hcd_oc(struct s3c2410_hcd_info *info, int port_oc) | 
|  | 280 | { | 
|  | 281 | struct s3c2410_hcd_port *port; | 
|  | 282 | struct usb_hcd *hcd; | 
|  | 283 | unsigned long flags; | 
|  | 284 | int portno; | 
|  | 285 |  | 
|  | 286 | if (info == NULL) | 
|  | 287 | return; | 
|  | 288 |  | 
|  | 289 | port = &info->port[0]; | 
|  | 290 | hcd = info->hcd; | 
|  | 291 |  | 
|  | 292 | local_irq_save(flags); | 
|  | 293 |  | 
|  | 294 | for (portno = 0; portno < 2; port++, portno++) { | 
|  | 295 | if (port_oc & (1<<portno) && | 
|  | 296 | port->flags & S3C_HCDFLG_USED) { | 
|  | 297 | port->oc_status = 1; | 
|  | 298 | port->oc_changed = 1; | 
|  | 299 |  | 
|  | 300 | /* ok, once over-current is detected, | 
|  | 301 | the port needs to be powered down */ | 
|  | 302 | s3c2410_usb_set_power(info, portno+1, 0); | 
|  | 303 | } | 
|  | 304 | } | 
|  | 305 |  | 
|  | 306 | local_irq_restore(flags); | 
|  | 307 | } | 
|  | 308 |  | 
|  | 309 | /* may be called without controller electrically present */ | 
|  | 310 | /* may be called with controller, bus, and devices active */ | 
|  | 311 |  | 
|  | 312 | /* | 
|  | 313 | * usb_hcd_s3c2410_remove - shutdown processing for HCD | 
|  | 314 | * @dev: USB Host Controller being removed | 
|  | 315 | * Context: !in_interrupt() | 
|  | 316 | * | 
|  | 317 | * Reverses the effect of usb_hcd_3c2410_probe(), first invoking | 
|  | 318 | * the HCD's stop() method.  It is always called from a thread | 
|  | 319 | * context, normally "rmmod", "apmd", or something similar. | 
|  | 320 | * | 
|  | 321 | */ | 
|  | 322 |  | 
| Ben Dooks | f096e04 | 2006-03-21 22:54:47 +0000 | [diff] [blame] | 323 | static void | 
|  | 324 | usb_hcd_s3c2410_remove (struct usb_hcd *hcd, struct platform_device *dev) | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 325 | { | 
|  | 326 | usb_remove_hcd(hcd); | 
|  | 327 | s3c2410_stop_hc(dev); | 
|  | 328 | iounmap(hcd->regs); | 
|  | 329 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | 
|  | 330 | usb_put_hcd(hcd); | 
|  | 331 | } | 
|  | 332 |  | 
|  | 333 | /** | 
|  | 334 | * usb_hcd_s3c2410_probe - initialize S3C2410-based HCDs | 
|  | 335 | * Context: !in_interrupt() | 
|  | 336 | * | 
|  | 337 | * Allocates basic resources for this USB host controller, and | 
|  | 338 | * then invokes the start() method for the HCD associated with it | 
|  | 339 | * through the hotplug entry's driver_data. | 
|  | 340 | * | 
|  | 341 | */ | 
| Ben Dooks | f096e04 | 2006-03-21 22:54:47 +0000 | [diff] [blame] | 342 | static int usb_hcd_s3c2410_probe (const struct hc_driver *driver, | 
|  | 343 | struct platform_device *dev) | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 344 | { | 
|  | 345 | struct usb_hcd *hcd = NULL; | 
|  | 346 | int retval; | 
|  | 347 |  | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 348 | s3c2410_usb_set_power(dev->dev.platform_data, 1, 1); | 
| Ben Dooks | ba44e7c | 2005-08-09 15:04:00 +0100 | [diff] [blame] | 349 | s3c2410_usb_set_power(dev->dev.platform_data, 2, 1); | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 350 |  | 
|  | 351 | hcd = usb_create_hcd(driver, &dev->dev, "s3c24xx"); | 
|  | 352 | if (hcd == NULL) | 
|  | 353 | return -ENOMEM; | 
|  | 354 |  | 
|  | 355 | hcd->rsrc_start = dev->resource[0].start; | 
|  | 356 | hcd->rsrc_len   = dev->resource[0].end - dev->resource[0].start + 1; | 
|  | 357 |  | 
|  | 358 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | 
| Joe Perches | 898eb71 | 2007-10-18 03:06:30 -0700 | [diff] [blame] | 359 | dev_err(&dev->dev, "request_mem_region failed\n"); | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 360 | retval = -EBUSY; | 
| Ben Dooks | 3799c40 | 2006-04-02 01:45:00 +0100 | [diff] [blame] | 361 | goto err_put; | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 362 | } | 
|  | 363 |  | 
| Ben Dooks | 3799c40 | 2006-04-02 01:45:00 +0100 | [diff] [blame] | 364 | clk = clk_get(&dev->dev, "usb-host"); | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 365 | if (IS_ERR(clk)) { | 
|  | 366 | dev_err(&dev->dev, "cannot get usb-host clock\n"); | 
|  | 367 | retval = -ENOENT; | 
| Ben Dooks | 3799c40 | 2006-04-02 01:45:00 +0100 | [diff] [blame] | 368 | goto err_mem; | 
|  | 369 | } | 
|  | 370 |  | 
| Ben Dooks | b2a8e09 | 2006-06-26 23:36:07 +0100 | [diff] [blame] | 371 | usb_clk = clk_get(&dev->dev, "usb-bus-host"); | 
| Ben Dooks | 3799c40 | 2006-04-02 01:45:00 +0100 | [diff] [blame] | 372 | if (IS_ERR(usb_clk)) { | 
| Ben Dooks | 2dfa319 | 2009-02-26 23:03:15 +0000 | [diff] [blame] | 373 | dev_err(&dev->dev, "cannot get usb-bus-host clock\n"); | 
| Ben Dooks | 3799c40 | 2006-04-02 01:45:00 +0100 | [diff] [blame] | 374 | retval = -ENOENT; | 
|  | 375 | goto err_clk; | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 376 | } | 
|  | 377 |  | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 378 | s3c2410_start_hc(dev, hcd); | 
|  | 379 |  | 
|  | 380 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | 
|  | 381 | if (!hcd->regs) { | 
|  | 382 | dev_err(&dev->dev, "ioremap failed\n"); | 
|  | 383 | retval = -ENOMEM; | 
| Ben Dooks | 3799c40 | 2006-04-02 01:45:00 +0100 | [diff] [blame] | 384 | goto err_ioremap; | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 385 | } | 
|  | 386 |  | 
|  | 387 | ohci_hcd_init(hcd_to_ohci(hcd)); | 
|  | 388 |  | 
| Thomas Gleixner | d54b5ca | 2006-07-01 19:29:44 -0700 | [diff] [blame] | 389 | retval = usb_add_hcd(hcd, dev->resource[1].start, IRQF_DISABLED); | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 390 | if (retval != 0) | 
| Ben Dooks | 3799c40 | 2006-04-02 01:45:00 +0100 | [diff] [blame] | 391 | goto err_ioremap; | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 392 |  | 
|  | 393 | return 0; | 
|  | 394 |  | 
| Ben Dooks | 3799c40 | 2006-04-02 01:45:00 +0100 | [diff] [blame] | 395 | err_ioremap: | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 396 | s3c2410_stop_hc(dev); | 
|  | 397 | iounmap(hcd->regs); | 
| Ben Dooks | 3799c40 | 2006-04-02 01:45:00 +0100 | [diff] [blame] | 398 | clk_put(usb_clk); | 
|  | 399 |  | 
|  | 400 | err_clk: | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 401 | clk_put(clk); | 
|  | 402 |  | 
| Ben Dooks | 3799c40 | 2006-04-02 01:45:00 +0100 | [diff] [blame] | 403 | err_mem: | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 404 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | 
|  | 405 |  | 
| Ben Dooks | 3799c40 | 2006-04-02 01:45:00 +0100 | [diff] [blame] | 406 | err_put: | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 407 | usb_put_hcd(hcd); | 
|  | 408 | return retval; | 
|  | 409 | } | 
|  | 410 |  | 
|  | 411 | /*-------------------------------------------------------------------------*/ | 
|  | 412 |  | 
|  | 413 | static int | 
|  | 414 | ohci_s3c2410_start (struct usb_hcd *hcd) | 
|  | 415 | { | 
|  | 416 | struct ohci_hcd	*ohci = hcd_to_ohci (hcd); | 
|  | 417 | int ret; | 
|  | 418 |  | 
|  | 419 | if ((ret = ohci_init(ohci)) < 0) | 
|  | 420 | return ret; | 
|  | 421 |  | 
|  | 422 | if ((ret = ohci_run (ohci)) < 0) { | 
|  | 423 | err ("can't start %s", hcd->self.bus_name); | 
|  | 424 | ohci_stop (hcd); | 
|  | 425 | return ret; | 
|  | 426 | } | 
|  | 427 |  | 
|  | 428 | return 0; | 
|  | 429 | } | 
|  | 430 |  | 
|  | 431 |  | 
|  | 432 | static const struct hc_driver ohci_s3c2410_hc_driver = { | 
|  | 433 | .description =		hcd_name, | 
|  | 434 | .product_desc =		"S3C24XX OHCI", | 
|  | 435 | .hcd_priv_size =	sizeof(struct ohci_hcd), | 
|  | 436 |  | 
|  | 437 | /* | 
|  | 438 | * generic hardware linkage | 
|  | 439 | */ | 
|  | 440 | .irq =			ohci_irq, | 
|  | 441 | .flags =		HCD_USB11 | HCD_MEMORY, | 
|  | 442 |  | 
|  | 443 | /* | 
|  | 444 | * basic lifecycle operations | 
|  | 445 | */ | 
|  | 446 | .start =		ohci_s3c2410_start, | 
|  | 447 | .stop =			ohci_stop, | 
| David Brownell | dd9048a | 2006-12-05 03:18:31 -0800 | [diff] [blame] | 448 | .shutdown =		ohci_shutdown, | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 449 |  | 
|  | 450 | /* | 
|  | 451 | * managing i/o requests and associated device resources | 
|  | 452 | */ | 
|  | 453 | .urb_enqueue =		ohci_urb_enqueue, | 
|  | 454 | .urb_dequeue =		ohci_urb_dequeue, | 
|  | 455 | .endpoint_disable =	ohci_endpoint_disable, | 
|  | 456 |  | 
|  | 457 | /* | 
|  | 458 | * scheduling support | 
|  | 459 | */ | 
|  | 460 | .get_frame_number =	ohci_get_frame, | 
|  | 461 |  | 
|  | 462 | /* | 
|  | 463 | * root hub support | 
|  | 464 | */ | 
|  | 465 | .hub_status_data =	ohci_s3c2410_hub_status_data, | 
|  | 466 | .hub_control =		ohci_s3c2410_hub_control, | 
| David Brownell | 8ad7fe1 | 2005-09-13 19:59:11 -0700 | [diff] [blame] | 467 | #ifdef	CONFIG_PM | 
| Alan Stern | 0c0382e | 2005-10-13 17:08:02 -0400 | [diff] [blame] | 468 | .bus_suspend =		ohci_bus_suspend, | 
|  | 469 | .bus_resume =		ohci_bus_resume, | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 470 | #endif | 
| David Brownell | 9293677 | 2005-09-22 22:32:11 -0700 | [diff] [blame] | 471 | .start_port_reset =	ohci_start_port_reset, | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 472 | }; | 
|  | 473 |  | 
|  | 474 | /* device driver */ | 
|  | 475 |  | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 476 | static int ohci_hcd_s3c2410_drv_probe(struct platform_device *pdev) | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 477 | { | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 478 | return usb_hcd_s3c2410_probe(&ohci_s3c2410_hc_driver, pdev); | 
|  | 479 | } | 
|  | 480 |  | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 481 | static int ohci_hcd_s3c2410_drv_remove(struct platform_device *pdev) | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 482 | { | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 483 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 484 |  | 
|  | 485 | usb_hcd_s3c2410_remove(hcd, pdev); | 
|  | 486 | return 0; | 
|  | 487 | } | 
|  | 488 |  | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 489 | static struct platform_driver ohci_hcd_s3c2410_driver = { | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 490 | .probe		= ohci_hcd_s3c2410_drv_probe, | 
|  | 491 | .remove		= ohci_hcd_s3c2410_drv_remove, | 
| David Brownell | dd9048a | 2006-12-05 03:18:31 -0800 | [diff] [blame] | 492 | .shutdown	= usb_hcd_platform_shutdown, | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 493 | /*.suspend	= ohci_hcd_s3c2410_drv_suspend, */ | 
|  | 494 | /*.resume	= ohci_hcd_s3c2410_drv_resume, */ | 
| Russell King | 3ae5eae | 2005-11-09 22:32:44 +0000 | [diff] [blame] | 495 | .driver		= { | 
|  | 496 | .owner	= THIS_MODULE, | 
|  | 497 | .name	= "s3c2410-ohci", | 
|  | 498 | }, | 
| Ben Dooks | 3eb0c5f | 2005-07-29 12:18:03 -0700 | [diff] [blame] | 499 | }; | 
|  | 500 |  | 
| Kay Sievers | f4fce61 | 2008-04-10 21:29:22 -0700 | [diff] [blame] | 501 | MODULE_ALIAS("platform:s3c2410-ohci"); |