diff options
| author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-05-07 12:03:39 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-05-07 12:03:39 -0400 |
| commit | 61906313bd41cde2f9aaa14e461e6108d3e71aaa (patch) | |
| tree | c84805a9c67e3baf9e5acf13a3f55f7058a9131f /drivers/usb | |
| parent | 3aa2ae74ba630ec9b98736d64aea8e4cb490861d (diff) | |
| parent | d48b97b403d23f6df0b990cee652bdf9a52337a3 (diff) | |
Merge 3.4-rc6 into usb-next
This resolves the conflict with:
drivers/usb/host/ehci-tegra.c
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
| -rw-r--r-- | drivers/usb/class/cdc-wdm.c | 7 | ||||
| -rw-r--r-- | drivers/usb/core/hcd-pci.c | 9 | ||||
| -rw-r--r-- | drivers/usb/gadget/dummy_hcd.c | 1 | ||||
| -rw-r--r-- | drivers/usb/gadget/f_mass_storage.c | 2 | ||||
| -rw-r--r-- | drivers/usb/gadget/file_storage.c | 2 | ||||
| -rw-r--r-- | drivers/usb/gadget/udc-core.c | 4 | ||||
| -rw-r--r-- | drivers/usb/gadget/uvc.h | 2 | ||||
| -rw-r--r-- | drivers/usb/gadget/uvc_v4l2.c | 2 | ||||
| -rw-r--r-- | drivers/usb/host/ehci-pci.c | 8 | ||||
| -rw-r--r-- | drivers/usb/host/ehci-tegra.c | 376 | ||||
| -rw-r--r-- | drivers/usb/musb/davinci.c | 3 | ||||
| -rw-r--r-- | drivers/usb/musb/musb_core.h | 2 | ||||
| -rw-r--r-- | drivers/usb/otg/gpio_vbus.c | 15 |
13 files changed, 240 insertions, 193 deletions
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c index cd017a914c5d..5d151653ae43 100644 --- a/drivers/usb/class/cdc-wdm.c +++ b/drivers/usb/class/cdc-wdm.c | |||
| @@ -157,8 +157,9 @@ static void wdm_out_callback(struct urb *urb) | |||
| 157 | spin_lock(&desc->iuspin); | 157 | spin_lock(&desc->iuspin); |
| 158 | desc->werr = urb->status; | 158 | desc->werr = urb->status; |
| 159 | spin_unlock(&desc->iuspin); | 159 | spin_unlock(&desc->iuspin); |
| 160 | clear_bit(WDM_IN_USE, &desc->flags); | ||
| 161 | kfree(desc->outbuf); | 160 | kfree(desc->outbuf); |
| 161 | desc->outbuf = NULL; | ||
| 162 | clear_bit(WDM_IN_USE, &desc->flags); | ||
| 162 | wake_up(&desc->wait); | 163 | wake_up(&desc->wait); |
| 163 | } | 164 | } |
| 164 | 165 | ||
| @@ -338,7 +339,7 @@ static ssize_t wdm_write | |||
| 338 | if (we < 0) | 339 | if (we < 0) |
| 339 | return -EIO; | 340 | return -EIO; |
| 340 | 341 | ||
| 341 | desc->outbuf = buf = kmalloc(count, GFP_KERNEL); | 342 | buf = kmalloc(count, GFP_KERNEL); |
| 342 | if (!buf) { | 343 | if (!buf) { |
| 343 | rv = -ENOMEM; | 344 | rv = -ENOMEM; |
| 344 | goto outnl; | 345 | goto outnl; |
| @@ -408,10 +409,12 @@ static ssize_t wdm_write | |||
| 408 | req->wIndex = desc->inum; | 409 | req->wIndex = desc->inum; |
| 409 | req->wLength = cpu_to_le16(count); | 410 | req->wLength = cpu_to_le16(count); |
| 410 | set_bit(WDM_IN_USE, &desc->flags); | 411 | set_bit(WDM_IN_USE, &desc->flags); |
| 412 | desc->outbuf = buf; | ||
| 411 | 413 | ||
| 412 | rv = usb_submit_urb(desc->command, GFP_KERNEL); | 414 | rv = usb_submit_urb(desc->command, GFP_KERNEL); |
| 413 | if (rv < 0) { | 415 | if (rv < 0) { |
| 414 | kfree(buf); | 416 | kfree(buf); |
| 417 | desc->outbuf = NULL; | ||
| 415 | clear_bit(WDM_IN_USE, &desc->flags); | 418 | clear_bit(WDM_IN_USE, &desc->flags); |
| 416 | dev_err(&desc->intf->dev, "Tx URB error: %d\n", rv); | 419 | dev_err(&desc->intf->dev, "Tx URB error: %d\n", rv); |
| 417 | rv = usb_translate_errors(rv); | 420 | rv = usb_translate_errors(rv); |
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index 622b4a48e732..57ed9e400c06 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c | |||
| @@ -493,6 +493,15 @@ static int hcd_pci_suspend_noirq(struct device *dev) | |||
| 493 | 493 | ||
| 494 | pci_save_state(pci_dev); | 494 | pci_save_state(pci_dev); |
| 495 | 495 | ||
| 496 | /* | ||
| 497 | * Some systems crash if an EHCI controller is in D3 during | ||
| 498 | * a sleep transition. We have to leave such controllers in D0. | ||
| 499 | */ | ||
| 500 | if (hcd->broken_pci_sleep) { | ||
| 501 | dev_dbg(dev, "Staying in PCI D0\n"); | ||
| 502 | return retval; | ||
| 503 | } | ||
| 504 | |||
| 496 | /* If the root hub is dead rather than suspended, disallow remote | 505 | /* If the root hub is dead rather than suspended, disallow remote |
| 497 | * wakeup. usb_hc_died() should ensure that both hosts are marked as | 506 | * wakeup. usb_hc_died() should ensure that both hosts are marked as |
| 498 | * dying, so we only need to check the primary roothub. | 507 | * dying, so we only need to check the primary roothub. |
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index a6dfd2164166..170cbe89d9f8 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c | |||
| @@ -927,7 +927,6 @@ static int dummy_udc_stop(struct usb_gadget *g, | |||
| 927 | 927 | ||
| 928 | dum->driver = NULL; | 928 | dum->driver = NULL; |
| 929 | 929 | ||
| 930 | dummy_pullup(&dum->gadget, 0); | ||
| 931 | return 0; | 930 | return 0; |
| 932 | } | 931 | } |
| 933 | 932 | ||
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index a371e966425f..cb8c162cae5a 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c | |||
| @@ -2189,7 +2189,7 @@ unknown_cmnd: | |||
| 2189 | common->data_size_from_cmnd = 0; | 2189 | common->data_size_from_cmnd = 0; |
| 2190 | sprintf(unknown, "Unknown x%02x", common->cmnd[0]); | 2190 | sprintf(unknown, "Unknown x%02x", common->cmnd[0]); |
| 2191 | reply = check_command(common, common->cmnd_size, | 2191 | reply = check_command(common, common->cmnd_size, |
| 2192 | DATA_DIR_UNKNOWN, 0xff, 0, unknown); | 2192 | DATA_DIR_UNKNOWN, ~0, 0, unknown); |
| 2193 | if (reply == 0) { | 2193 | if (reply == 0) { |
| 2194 | common->curlun->sense_data = SS_INVALID_COMMAND; | 2194 | common->curlun->sense_data = SS_INVALID_COMMAND; |
| 2195 | reply = -EINVAL; | 2195 | reply = -EINVAL; |
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index 4fac56927741..a896d73f7a93 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c | |||
| @@ -2579,7 +2579,7 @@ static int do_scsi_command(struct fsg_dev *fsg) | |||
| 2579 | fsg->data_size_from_cmnd = 0; | 2579 | fsg->data_size_from_cmnd = 0; |
| 2580 | sprintf(unknown, "Unknown x%02x", fsg->cmnd[0]); | 2580 | sprintf(unknown, "Unknown x%02x", fsg->cmnd[0]); |
| 2581 | if ((reply = check_command(fsg, fsg->cmnd_size, | 2581 | if ((reply = check_command(fsg, fsg->cmnd_size, |
| 2582 | DATA_DIR_UNKNOWN, 0xff, 0, unknown)) == 0) { | 2582 | DATA_DIR_UNKNOWN, ~0, 0, unknown)) == 0) { |
| 2583 | fsg->curlun->sense_data = SS_INVALID_COMMAND; | 2583 | fsg->curlun->sense_data = SS_INVALID_COMMAND; |
| 2584 | reply = -EINVAL; | 2584 | reply = -EINVAL; |
| 2585 | } | 2585 | } |
diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c index 2fa9865babed..e5e44f8cde9a 100644 --- a/drivers/usb/gadget/udc-core.c +++ b/drivers/usb/gadget/udc-core.c | |||
| @@ -263,8 +263,8 @@ static void usb_gadget_remove_driver(struct usb_udc *udc) | |||
| 263 | 263 | ||
| 264 | if (udc_is_newstyle(udc)) { | 264 | if (udc_is_newstyle(udc)) { |
| 265 | udc->driver->disconnect(udc->gadget); | 265 | udc->driver->disconnect(udc->gadget); |
| 266 | udc->driver->unbind(udc->gadget); | ||
| 267 | usb_gadget_disconnect(udc->gadget); | 266 | usb_gadget_disconnect(udc->gadget); |
| 267 | udc->driver->unbind(udc->gadget); | ||
| 268 | usb_gadget_udc_stop(udc->gadget, udc->driver); | 268 | usb_gadget_udc_stop(udc->gadget, udc->driver); |
| 269 | } else { | 269 | } else { |
| 270 | usb_gadget_stop(udc->gadget, udc->driver); | 270 | usb_gadget_stop(udc->gadget, udc->driver); |
| @@ -415,9 +415,9 @@ static ssize_t usb_udc_softconn_store(struct device *dev, | |||
| 415 | usb_gadget_udc_start(udc->gadget, udc->driver); | 415 | usb_gadget_udc_start(udc->gadget, udc->driver); |
| 416 | usb_gadget_connect(udc->gadget); | 416 | usb_gadget_connect(udc->gadget); |
| 417 | } else if (sysfs_streq(buf, "disconnect")) { | 417 | } else if (sysfs_streq(buf, "disconnect")) { |
| 418 | usb_gadget_disconnect(udc->gadget); | ||
| 418 | if (udc_is_newstyle(udc)) | 419 | if (udc_is_newstyle(udc)) |
| 419 | usb_gadget_udc_stop(udc->gadget, udc->driver); | 420 | usb_gadget_udc_stop(udc->gadget, udc->driver); |
| 420 | usb_gadget_disconnect(udc->gadget); | ||
| 421 | } else { | 421 | } else { |
| 422 | dev_err(dev, "unsupported command '%s'\n", buf); | 422 | dev_err(dev, "unsupported command '%s'\n", buf); |
| 423 | return -EINVAL; | 423 | return -EINVAL; |
diff --git a/drivers/usb/gadget/uvc.h b/drivers/usb/gadget/uvc.h index bc78c606c12b..ca4e03a1c73a 100644 --- a/drivers/usb/gadget/uvc.h +++ b/drivers/usb/gadget/uvc.h | |||
| @@ -28,7 +28,7 @@ | |||
| 28 | 28 | ||
| 29 | struct uvc_request_data | 29 | struct uvc_request_data |
| 30 | { | 30 | { |
| 31 | unsigned int length; | 31 | __s32 length; |
| 32 | __u8 data[60]; | 32 | __u8 data[60]; |
| 33 | }; | 33 | }; |
| 34 | 34 | ||
diff --git a/drivers/usb/gadget/uvc_v4l2.c b/drivers/usb/gadget/uvc_v4l2.c index f6e083b50191..54d7ca559cb2 100644 --- a/drivers/usb/gadget/uvc_v4l2.c +++ b/drivers/usb/gadget/uvc_v4l2.c | |||
| @@ -39,7 +39,7 @@ uvc_send_response(struct uvc_device *uvc, struct uvc_request_data *data) | |||
| 39 | if (data->length < 0) | 39 | if (data->length < 0) |
| 40 | return usb_ep_set_halt(cdev->gadget->ep0); | 40 | return usb_ep_set_halt(cdev->gadget->ep0); |
| 41 | 41 | ||
| 42 | req->length = min(uvc->event_length, data->length); | 42 | req->length = min_t(unsigned int, uvc->event_length, data->length); |
| 43 | req->zero = data->length < uvc->event_length; | 43 | req->zero = data->length < uvc->event_length; |
| 44 | req->dma = DMA_ADDR_INVALID; | 44 | req->dma = DMA_ADDR_INVALID; |
| 45 | 45 | ||
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index 123481793a47..bc94d7bf072d 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c | |||
| @@ -144,6 +144,14 @@ static int ehci_pci_setup(struct usb_hcd *hcd) | |||
| 144 | hcd->has_tt = 1; | 144 | hcd->has_tt = 1; |
| 145 | tdi_reset(ehci); | 145 | tdi_reset(ehci); |
| 146 | } | 146 | } |
| 147 | if (pdev->subsystem_vendor == PCI_VENDOR_ID_ASUSTEK) { | ||
| 148 | /* EHCI #1 or #2 on 6 Series/C200 Series chipset */ | ||
| 149 | if (pdev->device == 0x1c26 || pdev->device == 0x1c2d) { | ||
| 150 | ehci_info(ehci, "broken D3 during system sleep on ASUS\n"); | ||
| 151 | hcd->broken_pci_sleep = 1; | ||
| 152 | device_set_wakeup_capable(&pdev->dev, false); | ||
| 153 | } | ||
| 154 | } | ||
| 147 | break; | 155 | break; |
| 148 | case PCI_VENDOR_ID_TDI: | 156 | case PCI_VENDOR_ID_TDI: |
| 149 | if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) { | 157 | if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) { |
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index 4c1eb61bc2fc..e57aba52b31c 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #include <linux/gpio.h> | 24 | #include <linux/gpio.h> |
| 25 | #include <linux/of.h> | 25 | #include <linux/of.h> |
| 26 | #include <linux/of_gpio.h> | 26 | #include <linux/of_gpio.h> |
| 27 | #include <linux/pm_runtime.h> | ||
| 27 | 28 | ||
| 28 | #include <mach/usb_phy.h> | 29 | #include <mach/usb_phy.h> |
| 29 | #include <mach/iomap.h> | 30 | #include <mach/iomap.h> |
| @@ -37,9 +38,7 @@ struct tegra_ehci_hcd { | |||
| 37 | struct clk *emc_clk; | 38 | struct clk *emc_clk; |
| 38 | struct usb_phy *transceiver; | 39 | struct usb_phy *transceiver; |
| 39 | int host_resumed; | 40 | int host_resumed; |
| 40 | int bus_suspended; | ||
| 41 | int port_resuming; | 41 | int port_resuming; |
| 42 | int power_down_on_bus_suspend; | ||
| 43 | enum tegra_usb_phy_port_speed port_speed; | 42 | enum tegra_usb_phy_port_speed port_speed; |
| 44 | }; | 43 | }; |
| 45 | 44 | ||
| @@ -262,120 +261,6 @@ static void tegra_ehci_restart(struct usb_hcd *hcd) | |||
| 262 | up_write(&ehci_cf_port_reset_rwsem); | 261 | up_write(&ehci_cf_port_reset_rwsem); |
| 263 | } | 262 | } |
| 264 | 263 | ||
| 265 | static int tegra_usb_suspend(struct usb_hcd *hcd) | ||
| 266 | { | ||
| 267 | struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller); | ||
| 268 | struct ehci_regs __iomem *hw = tegra->ehci->regs; | ||
| 269 | unsigned long flags; | ||
| 270 | |||
| 271 | spin_lock_irqsave(&tegra->ehci->lock, flags); | ||
| 272 | |||
| 273 | tegra->port_speed = (readl(&hw->port_status[0]) >> 26) & 0x3; | ||
| 274 | ehci_halt(tegra->ehci); | ||
| 275 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
| 276 | |||
| 277 | spin_unlock_irqrestore(&tegra->ehci->lock, flags); | ||
| 278 | |||
| 279 | tegra_ehci_power_down(hcd); | ||
| 280 | return 0; | ||
| 281 | } | ||
| 282 | |||
| 283 | static int tegra_usb_resume(struct usb_hcd *hcd) | ||
| 284 | { | ||
| 285 | struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller); | ||
| 286 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
| 287 | struct ehci_regs __iomem *hw = ehci->regs; | ||
| 288 | unsigned long val; | ||
| 289 | |||
| 290 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
| 291 | tegra_ehci_power_up(hcd); | ||
| 292 | |||
| 293 | if (tegra->port_speed > TEGRA_USB_PHY_PORT_SPEED_HIGH) { | ||
| 294 | /* Wait for the phy to detect new devices | ||
| 295 | * before we restart the controller */ | ||
| 296 | msleep(10); | ||
| 297 | goto restart; | ||
| 298 | } | ||
| 299 | |||
| 300 | /* Force the phy to keep data lines in suspend state */ | ||
| 301 | tegra_ehci_phy_restore_start(tegra->phy, tegra->port_speed); | ||
| 302 | |||
| 303 | /* Enable host mode */ | ||
| 304 | tdi_reset(ehci); | ||
| 305 | |||
| 306 | /* Enable Port Power */ | ||
| 307 | val = readl(&hw->port_status[0]); | ||
| 308 | val |= PORT_POWER; | ||
| 309 | writel(val, &hw->port_status[0]); | ||
| 310 | udelay(10); | ||
| 311 | |||
| 312 | /* Check if the phy resume from LP0. When the phy resume from LP0 | ||
| 313 | * USB register will be reset. */ | ||
| 314 | if (!readl(&hw->async_next)) { | ||
| 315 | /* Program the field PTC based on the saved speed mode */ | ||
| 316 | val = readl(&hw->port_status[0]); | ||
| 317 | val &= ~PORT_TEST(~0); | ||
| 318 | if (tegra->port_speed == TEGRA_USB_PHY_PORT_SPEED_HIGH) | ||
| 319 | val |= PORT_TEST_FORCE; | ||
| 320 | else if (tegra->port_speed == TEGRA_USB_PHY_PORT_SPEED_FULL) | ||
| 321 | val |= PORT_TEST(6); | ||
| 322 | else if (tegra->port_speed == TEGRA_USB_PHY_PORT_SPEED_LOW) | ||
| 323 | val |= PORT_TEST(7); | ||
| 324 | writel(val, &hw->port_status[0]); | ||
| 325 | udelay(10); | ||
| 326 | |||
| 327 | /* Disable test mode by setting PTC field to NORMAL_OP */ | ||
| 328 | val = readl(&hw->port_status[0]); | ||
| 329 | val &= ~PORT_TEST(~0); | ||
| 330 | writel(val, &hw->port_status[0]); | ||
| 331 | udelay(10); | ||
| 332 | } | ||
| 333 | |||
| 334 | /* Poll until CCS is enabled */ | ||
| 335 | if (handshake(ehci, &hw->port_status[0], PORT_CONNECT, | ||
| 336 | PORT_CONNECT, 2000)) { | ||
| 337 | pr_err("%s: timeout waiting for PORT_CONNECT\n", __func__); | ||
| 338 | goto restart; | ||
| 339 | } | ||
| 340 | |||
| 341 | /* Poll until PE is enabled */ | ||
| 342 | if (handshake(ehci, &hw->port_status[0], PORT_PE, | ||
| 343 | PORT_PE, 2000)) { | ||
| 344 | pr_err("%s: timeout waiting for USB_PORTSC1_PE\n", __func__); | ||
| 345 | goto restart; | ||
| 346 | } | ||
| 347 | |||
| 348 | /* Clear the PCI status, to avoid an interrupt taken upon resume */ | ||
| 349 | val = readl(&hw->status); | ||
| 350 | val |= STS_PCD; | ||
| 351 | writel(val, &hw->status); | ||
| 352 | |||
| 353 | /* Put controller in suspend mode by writing 1 to SUSP bit of PORTSC */ | ||
| 354 | val = readl(&hw->port_status[0]); | ||
| 355 | if ((val & PORT_POWER) && (val & PORT_PE)) { | ||
| 356 | val |= PORT_SUSPEND; | ||
| 357 | writel(val, &hw->port_status[0]); | ||
| 358 | |||
| 359 | /* Wait until port suspend completes */ | ||
| 360 | if (handshake(ehci, &hw->port_status[0], PORT_SUSPEND, | ||
| 361 | PORT_SUSPEND, 1000)) { | ||
| 362 | pr_err("%s: timeout waiting for PORT_SUSPEND\n", | ||
| 363 | __func__); | ||
| 364 | goto restart; | ||
| 365 | } | ||
| 366 | } | ||
| 367 | |||
| 368 | tegra_ehci_phy_restore_end(tegra->phy); | ||
| 369 | return 0; | ||
| 370 | |||
| 371 | restart: | ||
| 372 | if (tegra->port_speed <= TEGRA_USB_PHY_PORT_SPEED_HIGH) | ||
| 373 | tegra_ehci_phy_restore_end(tegra->phy); | ||
| 374 | |||
| 375 | tegra_ehci_restart(hcd); | ||
| 376 | return 0; | ||
| 377 | } | ||
| 378 | |||
| 379 | static void tegra_ehci_shutdown(struct usb_hcd *hcd) | 264 | static void tegra_ehci_shutdown(struct usb_hcd *hcd) |
| 380 | { | 265 | { |
| 381 | struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller); | 266 | struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller); |
| @@ -423,36 +308,6 @@ static int tegra_ehci_setup(struct usb_hcd *hcd) | |||
| 423 | return retval; | 308 | return retval; |
| 424 | } | 309 | } |
| 425 | 310 | ||
| 426 | #ifdef CONFIG_PM | ||
| 427 | static int tegra_ehci_bus_suspend(struct usb_hcd *hcd) | ||
| 428 | { | ||
| 429 | struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller); | ||
| 430 | int error_status = 0; | ||
| 431 | |||
| 432 | error_status = ehci_bus_suspend(hcd); | ||
| 433 | if (!error_status && tegra->power_down_on_bus_suspend) { | ||
| 434 | tegra_usb_suspend(hcd); | ||
| 435 | tegra->bus_suspended = 1; | ||
| 436 | } | ||
| 437 | |||
| 438 | return error_status; | ||
| 439 | } | ||
| 440 | |||
| 441 | static int tegra_ehci_bus_resume(struct usb_hcd *hcd) | ||
| 442 | { | ||
| 443 | struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller); | ||
| 444 | |||
| 445 | if (tegra->bus_suspended && tegra->power_down_on_bus_suspend) { | ||
| 446 | tegra_usb_resume(hcd); | ||
| 447 | tegra->bus_suspended = 0; | ||
| 448 | } | ||
| 449 | |||
| 450 | tegra_usb_phy_preresume(tegra->phy); | ||
| 451 | tegra->port_resuming = 1; | ||
| 452 | return ehci_bus_resume(hcd); | ||
| 453 | } | ||
| 454 | #endif | ||
| 455 | |||
| 456 | struct dma_aligned_buffer { | 311 | struct dma_aligned_buffer { |
| 457 | void *kmalloc_ptr; | 312 | void *kmalloc_ptr; |
| 458 | void *old_xfer_buffer; | 313 | void *old_xfer_buffer; |
| @@ -559,8 +414,8 @@ static const struct hc_driver tegra_ehci_hc_driver = { | |||
| 559 | .unmap_urb_for_dma = tegra_ehci_unmap_urb_for_dma, | 414 | .unmap_urb_for_dma = tegra_ehci_unmap_urb_for_dma, |
| 560 | .hub_control = tegra_ehci_hub_control, | 415 | .hub_control = tegra_ehci_hub_control, |
| 561 | #ifdef CONFIG_PM | 416 | #ifdef CONFIG_PM |
| 562 | .bus_suspend = tegra_ehci_bus_suspend, | 417 | .bus_suspend = ehci_bus_suspend, |
| 563 | .bus_resume = tegra_ehci_bus_resume, | 418 | .bus_resume = ehci_bus_resume, |
| 564 | #endif | 419 | #endif |
| 565 | }; | 420 | }; |
| 566 | 421 | ||
| @@ -586,11 +441,187 @@ static int setup_vbus_gpio(struct platform_device *pdev) | |||
| 586 | dev_err(&pdev->dev, "can't enable vbus\n"); | 441 | dev_err(&pdev->dev, "can't enable vbus\n"); |
| 587 | return err; | 442 | return err; |
| 588 | } | 443 | } |
| 589 | gpio_set_value(gpio, 1); | ||
| 590 | 444 | ||
| 591 | return err; | 445 | return err; |
| 592 | } | 446 | } |
| 593 | 447 | ||
| 448 | #ifdef CONFIG_PM | ||
| 449 | |||
| 450 | static int controller_suspend(struct device *dev) | ||
| 451 | { | ||
| 452 | struct tegra_ehci_hcd *tegra = | ||
| 453 | platform_get_drvdata(to_platform_device(dev)); | ||
| 454 | struct ehci_hcd *ehci = tegra->ehci; | ||
| 455 | struct usb_hcd *hcd = ehci_to_hcd(ehci); | ||
| 456 | struct ehci_regs __iomem *hw = ehci->regs; | ||
| 457 | unsigned long flags; | ||
| 458 | |||
| 459 | if (time_before(jiffies, ehci->next_statechange)) | ||
| 460 | msleep(10); | ||
| 461 | |||
| 462 | spin_lock_irqsave(&ehci->lock, flags); | ||
| 463 | |||
| 464 | tegra->port_speed = (readl(&hw->port_status[0]) >> 26) & 0x3; | ||
| 465 | ehci_halt(ehci); | ||
| 466 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
| 467 | |||
| 468 | spin_unlock_irqrestore(&ehci->lock, flags); | ||
| 469 | |||
| 470 | tegra_ehci_power_down(hcd); | ||
| 471 | return 0; | ||
| 472 | } | ||
| 473 | |||
| 474 | static int controller_resume(struct device *dev) | ||
| 475 | { | ||
| 476 | struct tegra_ehci_hcd *tegra = | ||
| 477 | platform_get_drvdata(to_platform_device(dev)); | ||
| 478 | struct ehci_hcd *ehci = tegra->ehci; | ||
| 479 | struct usb_hcd *hcd = ehci_to_hcd(ehci); | ||
| 480 | struct ehci_regs __iomem *hw = ehci->regs; | ||
| 481 | unsigned long val; | ||
| 482 | |||
| 483 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
| 484 | tegra_ehci_power_up(hcd); | ||
| 485 | |||
| 486 | if (tegra->port_speed > TEGRA_USB_PHY_PORT_SPEED_HIGH) { | ||
| 487 | /* Wait for the phy to detect new devices | ||
| 488 | * before we restart the controller */ | ||
| 489 | msleep(10); | ||
| 490 | goto restart; | ||
| 491 | } | ||
| 492 | |||
| 493 | /* Force the phy to keep data lines in suspend state */ | ||
| 494 | tegra_ehci_phy_restore_start(tegra->phy, tegra->port_speed); | ||
| 495 | |||
| 496 | /* Enable host mode */ | ||
| 497 | tdi_reset(ehci); | ||
| 498 | |||
| 499 | /* Enable Port Power */ | ||
| 500 | val = readl(&hw->port_status[0]); | ||
| 501 | val |= PORT_POWER; | ||
| 502 | writel(val, &hw->port_status[0]); | ||
| 503 | udelay(10); | ||
| 504 | |||
| 505 | /* Check if the phy resume from LP0. When the phy resume from LP0 | ||
| 506 | * USB register will be reset. */ | ||
| 507 | if (!readl(&hw->async_next)) { | ||
| 508 | /* Program the field PTC based on the saved speed mode */ | ||
| 509 | val = readl(&hw->port_status[0]); | ||
| 510 | val &= ~PORT_TEST(~0); | ||
| 511 | if (tegra->port_speed == TEGRA_USB_PHY_PORT_SPEED_HIGH) | ||
| 512 | val |= PORT_TEST_FORCE; | ||
| 513 | else if (tegra->port_speed == TEGRA_USB_PHY_PORT_SPEED_FULL) | ||
| 514 | val |= PORT_TEST(6); | ||
| 515 | else if (tegra->port_speed == TEGRA_USB_PHY_PORT_SPEED_LOW) | ||
| 516 | val |= PORT_TEST(7); | ||
| 517 | writel(val, &hw->port_status[0]); | ||
| 518 | udelay(10); | ||
| 519 | |||
| 520 | /* Disable test mode by setting PTC field to NORMAL_OP */ | ||
| 521 | val = readl(&hw->port_status[0]); | ||
| 522 | val &= ~PORT_TEST(~0); | ||
| 523 | writel(val, &hw->port_status[0]); | ||
| 524 | udelay(10); | ||
| 525 | } | ||
| 526 | |||
| 527 | /* Poll until CCS is enabled */ | ||
| 528 | if (handshake(ehci, &hw->port_status[0], PORT_CONNECT, | ||
| 529 | PORT_CONNECT, 2000)) { | ||
| 530 | pr_err("%s: timeout waiting for PORT_CONNECT\n", __func__); | ||
| 531 | goto restart; | ||
| 532 | } | ||
| 533 | |||
| 534 | /* Poll until PE is enabled */ | ||
| 535 | if (handshake(ehci, &hw->port_status[0], PORT_PE, | ||
| 536 | PORT_PE, 2000)) { | ||
| 537 | pr_err("%s: timeout waiting for USB_PORTSC1_PE\n", __func__); | ||
| 538 | goto restart; | ||
| 539 | } | ||
| 540 | |||
| 541 | /* Clear the PCI status, to avoid an interrupt taken upon resume */ | ||
| 542 | val = readl(&hw->status); | ||
| 543 | val |= STS_PCD; | ||
| 544 | writel(val, &hw->status); | ||
| 545 | |||
| 546 | /* Put controller in suspend mode by writing 1 to SUSP bit of PORTSC */ | ||
| 547 | val = readl(&hw->port_status[0]); | ||
| 548 | if ((val & PORT_POWER) && (val & PORT_PE)) { | ||
| 549 | val |= PORT_SUSPEND; | ||
| 550 | writel(val, &hw->port_status[0]); | ||
| 551 | |||
| 552 | /* Wait until port suspend completes */ | ||
| 553 | if (handshake(ehci, &hw->port_status[0], PORT_SUSPEND, | ||
| 554 | PORT_SUSPEND, 1000)) { | ||
| 555 | pr_err("%s: timeout waiting for PORT_SUSPEND\n", | ||
| 556 | __func__); | ||
| 557 | goto restart; | ||
| 558 | } | ||
| 559 | } | ||
| 560 | |||
| 561 | tegra_ehci_phy_restore_end(tegra->phy); | ||
| 562 | goto done; | ||
| 563 | |||
| 564 | restart: | ||
| 565 | if (tegra->port_speed <= TEGRA_USB_PHY_PORT_SPEED_HIGH) | ||
| 566 | tegra_ehci_phy_restore_end(tegra->phy); | ||
| 567 | |||
| 568 | tegra_ehci_restart(hcd); | ||
| 569 | |||
| 570 | done: | ||
| 571 | tegra_usb_phy_preresume(tegra->phy); | ||
| 572 | tegra->port_resuming = 1; | ||
| 573 | return 0; | ||
| 574 | } | ||
| 575 | |||
| 576 | static int tegra_ehci_suspend(struct device *dev) | ||
| 577 | { | ||
| 578 | struct tegra_ehci_hcd *tegra = | ||
| 579 | platform_get_drvdata(to_platform_device(dev)); | ||
| 580 | struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci); | ||
| 581 | int rc = 0; | ||
| 582 | |||
| 583 | /* | ||
| 584 | * When system sleep is supported and USB controller wakeup is | ||
| 585 | * implemented: If the controller is runtime-suspended and the | ||
| 586 | * wakeup setting needs to be changed, call pm_runtime_resume(). | ||
| 587 | */ | ||
| 588 | if (HCD_HW_ACCESSIBLE(hcd)) | ||
| 589 | rc = controller_suspend(dev); | ||
| 590 | return rc; | ||
| 591 | } | ||
| 592 | |||
| 593 | static int tegra_ehci_resume(struct device *dev) | ||
| 594 | { | ||
| 595 | int rc; | ||
| 596 | |||
| 597 | rc = controller_resume(dev); | ||
| 598 | if (rc == 0) { | ||
| 599 | pm_runtime_disable(dev); | ||
| 600 | pm_runtime_set_active(dev); | ||
| 601 | pm_runtime_enable(dev); | ||
| 602 | } | ||
| 603 | return rc; | ||
| 604 | } | ||
| 605 | |||
| 606 | static int tegra_ehci_runtime_suspend(struct device *dev) | ||
| 607 | { | ||
| 608 | return controller_suspend(dev); | ||
| 609 | } | ||
| 610 | |||
| 611 | static int tegra_ehci_runtime_resume(struct device *dev) | ||
| 612 | { | ||
| 613 | return controller_resume(dev); | ||
| 614 | } | ||
| 615 | |||
| 616 | static const struct dev_pm_ops tegra_ehci_pm_ops = { | ||
| 617 | .suspend = tegra_ehci_suspend, | ||
| 618 | .resume = tegra_ehci_resume, | ||
| 619 | .runtime_suspend = tegra_ehci_runtime_suspend, | ||
| 620 | .runtime_resume = tegra_ehci_runtime_resume, | ||
| 621 | }; | ||
| 622 | |||
| 623 | #endif | ||
| 624 | |||
| 594 | static u64 tegra_ehci_dma_mask = DMA_BIT_MASK(32); | 625 | static u64 tegra_ehci_dma_mask = DMA_BIT_MASK(32); |
| 595 | 626 | ||
| 596 | static int tegra_ehci_probe(struct platform_device *pdev) | 627 | static int tegra_ehci_probe(struct platform_device *pdev) |
| @@ -705,7 +736,6 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
| 705 | } | 736 | } |
| 706 | 737 | ||
| 707 | tegra->host_resumed = 1; | 738 | tegra->host_resumed = 1; |
| 708 | tegra->power_down_on_bus_suspend = pdata->power_down_on_bus_suspend; | ||
| 709 | tegra->ehci = hcd_to_ehci(hcd); | 739 | tegra->ehci = hcd_to_ehci(hcd); |
| 710 | 740 | ||
| 711 | irq = platform_get_irq(pdev, 0); | 741 | irq = platform_get_irq(pdev, 0); |
| @@ -729,6 +759,14 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
| 729 | goto fail; | 759 | goto fail; |
| 730 | } | 760 | } |
| 731 | 761 | ||
| 762 | pm_runtime_set_active(&pdev->dev); | ||
| 763 | pm_runtime_get_noresume(&pdev->dev); | ||
| 764 | |||
| 765 | /* Don't skip the pm_runtime_forbid call if wakeup isn't working */ | ||
| 766 | /* if (!pdata->power_down_on_bus_suspend) */ | ||
| 767 | pm_runtime_forbid(&pdev->dev); | ||
| 768 | pm_runtime_enable(&pdev->dev); | ||
| 769 | pm_runtime_put_sync(&pdev->dev); | ||
| 732 | return err; | 770 | return err; |
| 733 | 771 | ||
| 734 | fail: | 772 | fail: |
| @@ -755,33 +793,6 @@ fail_hcd: | |||
| 755 | return err; | 793 | return err; |
| 756 | } | 794 | } |
| 757 | 795 | ||
| 758 | #ifdef CONFIG_PM | ||
| 759 | static int tegra_ehci_resume(struct platform_device *pdev) | ||
| 760 | { | ||
| 761 | struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev); | ||
| 762 | struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci); | ||
| 763 | |||
| 764 | if (tegra->bus_suspended) | ||
| 765 | return 0; | ||
| 766 | |||
| 767 | return tegra_usb_resume(hcd); | ||
| 768 | } | ||
| 769 | |||
| 770 | static int tegra_ehci_suspend(struct platform_device *pdev, pm_message_t state) | ||
| 771 | { | ||
| 772 | struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev); | ||
| 773 | struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci); | ||
| 774 | |||
| 775 | if (tegra->bus_suspended) | ||
| 776 | return 0; | ||
| 777 | |||
| 778 | if (time_before(jiffies, tegra->ehci->next_statechange)) | ||
| 779 | msleep(10); | ||
| 780 | |||
| 781 | return tegra_usb_suspend(hcd); | ||
| 782 | } | ||
| 783 | #endif | ||
| 784 | |||
| 785 | static int tegra_ehci_remove(struct platform_device *pdev) | 796 | static int tegra_ehci_remove(struct platform_device *pdev) |
| 786 | { | 797 | { |
| 787 | struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev); | 798 | struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev); |
| @@ -790,6 +801,10 @@ static int tegra_ehci_remove(struct platform_device *pdev) | |||
| 790 | if (tegra == NULL || hcd == NULL) | 801 | if (tegra == NULL || hcd == NULL) |
| 791 | return -EINVAL; | 802 | return -EINVAL; |
| 792 | 803 | ||
| 804 | pm_runtime_get_sync(&pdev->dev); | ||
| 805 | pm_runtime_disable(&pdev->dev); | ||
| 806 | pm_runtime_put_noidle(&pdev->dev); | ||
| 807 | |||
| 793 | #ifdef CONFIG_USB_OTG_UTILS | 808 | #ifdef CONFIG_USB_OTG_UTILS |
| 794 | if (tegra->transceiver) { | 809 | if (tegra->transceiver) { |
| 795 | otg_set_host(tegra->transceiver->otg, NULL); | 810 | otg_set_host(tegra->transceiver->otg, NULL); |
| @@ -830,13 +845,12 @@ static struct of_device_id tegra_ehci_of_match[] __devinitdata = { | |||
| 830 | static struct platform_driver tegra_ehci_driver = { | 845 | static struct platform_driver tegra_ehci_driver = { |
| 831 | .probe = tegra_ehci_probe, | 846 | .probe = tegra_ehci_probe, |
| 832 | .remove = tegra_ehci_remove, | 847 | .remove = tegra_ehci_remove, |
| 833 | #ifdef CONFIG_PM | ||
| 834 | .suspend = tegra_ehci_suspend, | ||
| 835 | .resume = tegra_ehci_resume, | ||
| 836 | #endif | ||
| 837 | .shutdown = tegra_ehci_hcd_shutdown, | 848 | .shutdown = tegra_ehci_hcd_shutdown, |
| 838 | .driver = { | 849 | .driver = { |
| 839 | .name = "tegra-ehci", | 850 | .name = "tegra-ehci", |
| 840 | .of_match_table = tegra_ehci_of_match, | 851 | .of_match_table = tegra_ehci_of_match, |
| 852 | #ifdef CONFIG_PM | ||
| 853 | .pm = &tegra_ehci_pm_ops, | ||
| 854 | #endif | ||
| 841 | } | 855 | } |
| 842 | }; | 856 | }; |
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c index 97ab975fa442..768b4b55c816 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c | |||
| @@ -386,7 +386,7 @@ static int davinci_musb_init(struct musb *musb) | |||
| 386 | usb_nop_xceiv_register(); | 386 | usb_nop_xceiv_register(); |
| 387 | musb->xceiv = usb_get_transceiver(); | 387 | musb->xceiv = usb_get_transceiver(); |
| 388 | if (!musb->xceiv) | 388 | if (!musb->xceiv) |
| 389 | return -ENODEV; | 389 | goto unregister; |
| 390 | 390 | ||
| 391 | musb->mregs += DAVINCI_BASE_OFFSET; | 391 | musb->mregs += DAVINCI_BASE_OFFSET; |
| 392 | 392 | ||
| @@ -444,6 +444,7 @@ static int davinci_musb_init(struct musb *musb) | |||
| 444 | 444 | ||
| 445 | fail: | 445 | fail: |
| 446 | usb_put_transceiver(musb->xceiv); | 446 | usb_put_transceiver(musb->xceiv); |
| 447 | unregister: | ||
| 447 | usb_nop_xceiv_unregister(); | 448 | usb_nop_xceiv_unregister(); |
| 448 | return -ENODEV; | 449 | return -ENODEV; |
| 449 | } | 450 | } |
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 93de517a32a0..f4a40f001c88 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h | |||
| @@ -449,7 +449,7 @@ struct musb { | |||
| 449 | * We added this flag to forcefully disable double | 449 | * We added this flag to forcefully disable double |
| 450 | * buffering until we get it working. | 450 | * buffering until we get it working. |
| 451 | */ | 451 | */ |
| 452 | unsigned double_buffer_not_ok:1 __deprecated; | 452 | unsigned double_buffer_not_ok:1; |
| 453 | 453 | ||
| 454 | struct musb_hdrc_config *config; | 454 | struct musb_hdrc_config *config; |
| 455 | 455 | ||
diff --git a/drivers/usb/otg/gpio_vbus.c b/drivers/usb/otg/gpio_vbus.c index 3ece43a2e4c1..a0a2178974fe 100644 --- a/drivers/usb/otg/gpio_vbus.c +++ b/drivers/usb/otg/gpio_vbus.c | |||
| @@ -96,7 +96,7 @@ static void gpio_vbus_work(struct work_struct *work) | |||
| 96 | struct gpio_vbus_data *gpio_vbus = | 96 | struct gpio_vbus_data *gpio_vbus = |
| 97 | container_of(work, struct gpio_vbus_data, work); | 97 | container_of(work, struct gpio_vbus_data, work); |
| 98 | struct gpio_vbus_mach_info *pdata = gpio_vbus->dev->platform_data; | 98 | struct gpio_vbus_mach_info *pdata = gpio_vbus->dev->platform_data; |
| 99 | int gpio; | 99 | int gpio, status; |
| 100 | 100 | ||
| 101 | if (!gpio_vbus->phy.otg->gadget) | 101 | if (!gpio_vbus->phy.otg->gadget) |
| 102 | return; | 102 | return; |
| @@ -108,7 +108,9 @@ static void gpio_vbus_work(struct work_struct *work) | |||
| 108 | */ | 108 | */ |
| 109 | gpio = pdata->gpio_pullup; | 109 | gpio = pdata->gpio_pullup; |
| 110 | if (is_vbus_powered(pdata)) { | 110 | if (is_vbus_powered(pdata)) { |
| 111 | status = USB_EVENT_VBUS; | ||
| 111 | gpio_vbus->phy.state = OTG_STATE_B_PERIPHERAL; | 112 | gpio_vbus->phy.state = OTG_STATE_B_PERIPHERAL; |
| 113 | gpio_vbus->phy.last_event = status; | ||
| 112 | usb_gadget_vbus_connect(gpio_vbus->phy.otg->gadget); | 114 | usb_gadget_vbus_connect(gpio_vbus->phy.otg->gadget); |
| 113 | 115 | ||
| 114 | /* drawing a "unit load" is *always* OK, except for OTG */ | 116 | /* drawing a "unit load" is *always* OK, except for OTG */ |
| @@ -117,6 +119,9 @@ static void gpio_vbus_work(struct work_struct *work) | |||
| 117 | /* optionally enable D+ pullup */ | 119 | /* optionally enable D+ pullup */ |
| 118 | if (gpio_is_valid(gpio)) | 120 | if (gpio_is_valid(gpio)) |
| 119 | gpio_set_value(gpio, !pdata->gpio_pullup_inverted); | 121 | gpio_set_value(gpio, !pdata->gpio_pullup_inverted); |
| 122 | |||
| 123 | atomic_notifier_call_chain(&gpio_vbus->phy.notifier, | ||
| 124 | status, gpio_vbus->phy.otg->gadget); | ||
| 120 | } else { | 125 | } else { |
| 121 | /* optionally disable D+ pullup */ | 126 | /* optionally disable D+ pullup */ |
| 122 | if (gpio_is_valid(gpio)) | 127 | if (gpio_is_valid(gpio)) |
| @@ -125,7 +130,12 @@ static void gpio_vbus_work(struct work_struct *work) | |||
| 125 | set_vbus_draw(gpio_vbus, 0); | 130 | set_vbus_draw(gpio_vbus, 0); |
| 126 | 131 | ||
| 127 | usb_gadget_vbus_disconnect(gpio_vbus->phy.otg->gadget); | 132 | usb_gadget_vbus_disconnect(gpio_vbus->phy.otg->gadget); |
| 133 | status = USB_EVENT_NONE; | ||
| 128 | gpio_vbus->phy.state = OTG_STATE_B_IDLE; | 134 | gpio_vbus->phy.state = OTG_STATE_B_IDLE; |
| 135 | gpio_vbus->phy.last_event = status; | ||
| 136 | |||
| 137 | atomic_notifier_call_chain(&gpio_vbus->phy.notifier, | ||
| 138 | status, gpio_vbus->phy.otg->gadget); | ||
| 129 | } | 139 | } |
| 130 | } | 140 | } |
| 131 | 141 | ||
| @@ -287,6 +297,9 @@ static int __init gpio_vbus_probe(struct platform_device *pdev) | |||
| 287 | irq, err); | 297 | irq, err); |
| 288 | goto err_irq; | 298 | goto err_irq; |
| 289 | } | 299 | } |
| 300 | |||
| 301 | ATOMIC_INIT_NOTIFIER_HEAD(&gpio_vbus->phy.notifier); | ||
| 302 | |||
| 290 | INIT_WORK(&gpio_vbus->work, gpio_vbus_work); | 303 | INIT_WORK(&gpio_vbus->work, gpio_vbus_work); |
| 291 | 304 | ||
| 292 | gpio_vbus->vbus_draw = regulator_get(&pdev->dev, "vbus_draw"); | 305 | gpio_vbus->vbus_draw = regulator_get(&pdev->dev, "vbus_draw"); |
