diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-30 14:38:28 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-30 14:38:28 -0500 |
| commit | 6bc2b95ee602659c1be6fac0f6aadeb0c5c29a5d (patch) | |
| tree | 2509d8e58233c7de6304ed8fd4c9e11b46dba00f | |
| parent | a14a8d93169a8f2b0b000891571659ddbfa3a169 (diff) | |
| parent | a0701f04846eee9976e6b3eafca09f2a9d2744ef (diff) | |
Merge tag 'usb-3.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Here are a bunch of USB patches for 3.3-rc1.
Nothing major, largest thing here is the removal of some drivers that
did not work at all. Other than that, the normal collection of bugfixes
and new device ids.
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* tag 'usb-3.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (52 commits)
uwb & wusb: fix kconfig error
USB: Realtek cr: fix autopm scheduling while atomic
USB: ftdi_sio: Add more identifiers
xHCI: Cleanup isoc transfer ring when TD length mismatch found
usb: musb: omap2430: minor cleanups.
qcaux: add more Pantech UML190 and UML290 ports
Revert "drivers: usb: Fix dependency for USB_HWA_HCD"
usb: mv-otg - Fix build if CONFIG_USB is not set
USB: cdc-wdm: Avoid hanging on interface with no USB_CDC_DMM_TYPE
usb: add support for STA2X11 host driver
drivers: usb: Fix dependency for USB_HWA_HCD
kernel-doc: fix new warning in usb.h
USB: OHCI: fix new compiler warnings
usb: serial: kobil_sct: fix compile warning:
drivers/usb/host/ehci-fsl.c: add missing iounmap
USB: cdc-wdm: better allocate a buffer that is at least as big as we tell the USB core
USB: cdc-wdm: call wake_up_all to allow driver to shutdown on device removal
USB: cdc-wdm: use two mutexes to allow simultaneous read and write
USB: cdc-wdm: updating desc->length must be protected by spin_lock
USB: usbsevseg: fix max length
...
37 files changed, 224 insertions, 2732 deletions
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c index 1c50baff7725..d2b3cffca3f7 100644 --- a/drivers/usb/class/cdc-wdm.c +++ b/drivers/usb/class/cdc-wdm.c | |||
| @@ -57,6 +57,8 @@ MODULE_DEVICE_TABLE (usb, wdm_ids); | |||
| 57 | 57 | ||
| 58 | #define WDM_MAX 16 | 58 | #define WDM_MAX 16 |
| 59 | 59 | ||
| 60 | /* CDC-WMC r1.1 requires wMaxCommand to be "at least 256 decimal (0x100)" */ | ||
| 61 | #define WDM_DEFAULT_BUFSIZE 256 | ||
| 60 | 62 | ||
| 61 | static DEFINE_MUTEX(wdm_mutex); | 63 | static DEFINE_MUTEX(wdm_mutex); |
| 62 | 64 | ||
| @@ -88,7 +90,8 @@ struct wdm_device { | |||
| 88 | int count; | 90 | int count; |
| 89 | dma_addr_t shandle; | 91 | dma_addr_t shandle; |
| 90 | dma_addr_t ihandle; | 92 | dma_addr_t ihandle; |
| 91 | struct mutex lock; | 93 | struct mutex wlock; |
| 94 | struct mutex rlock; | ||
| 92 | wait_queue_head_t wait; | 95 | wait_queue_head_t wait; |
| 93 | struct work_struct rxwork; | 96 | struct work_struct rxwork; |
| 94 | int werr; | 97 | int werr; |
| @@ -323,7 +326,7 @@ static ssize_t wdm_write | |||
| 323 | } | 326 | } |
| 324 | 327 | ||
| 325 | /* concurrent writes and disconnect */ | 328 | /* concurrent writes and disconnect */ |
| 326 | r = mutex_lock_interruptible(&desc->lock); | 329 | r = mutex_lock_interruptible(&desc->wlock); |
| 327 | rv = -ERESTARTSYS; | 330 | rv = -ERESTARTSYS; |
| 328 | if (r) { | 331 | if (r) { |
| 329 | kfree(buf); | 332 | kfree(buf); |
| @@ -386,7 +389,7 @@ static ssize_t wdm_write | |||
| 386 | out: | 389 | out: |
| 387 | usb_autopm_put_interface(desc->intf); | 390 | usb_autopm_put_interface(desc->intf); |
| 388 | outnp: | 391 | outnp: |
| 389 | mutex_unlock(&desc->lock); | 392 | mutex_unlock(&desc->wlock); |
| 390 | outnl: | 393 | outnl: |
| 391 | return rv < 0 ? rv : count; | 394 | return rv < 0 ? rv : count; |
| 392 | } | 395 | } |
| @@ -399,7 +402,7 @@ static ssize_t wdm_read | |||
| 399 | struct wdm_device *desc = file->private_data; | 402 | struct wdm_device *desc = file->private_data; |
| 400 | 403 | ||
| 401 | 404 | ||
| 402 | rv = mutex_lock_interruptible(&desc->lock); /*concurrent reads */ | 405 | rv = mutex_lock_interruptible(&desc->rlock); /*concurrent reads */ |
| 403 | if (rv < 0) | 406 | if (rv < 0) |
| 404 | return -ERESTARTSYS; | 407 | return -ERESTARTSYS; |
| 405 | 408 | ||
| @@ -467,14 +470,16 @@ retry: | |||
| 467 | for (i = 0; i < desc->length - cntr; i++) | 470 | for (i = 0; i < desc->length - cntr; i++) |
| 468 | desc->ubuf[i] = desc->ubuf[i + cntr]; | 471 | desc->ubuf[i] = desc->ubuf[i + cntr]; |
| 469 | 472 | ||
| 473 | spin_lock_irq(&desc->iuspin); | ||
| 470 | desc->length -= cntr; | 474 | desc->length -= cntr; |
| 475 | spin_unlock_irq(&desc->iuspin); | ||
| 471 | /* in case we had outstanding data */ | 476 | /* in case we had outstanding data */ |
| 472 | if (!desc->length) | 477 | if (!desc->length) |
| 473 | clear_bit(WDM_READ, &desc->flags); | 478 | clear_bit(WDM_READ, &desc->flags); |
| 474 | rv = cntr; | 479 | rv = cntr; |
| 475 | 480 | ||
| 476 | err: | 481 | err: |
| 477 | mutex_unlock(&desc->lock); | 482 | mutex_unlock(&desc->rlock); |
| 478 | return rv; | 483 | return rv; |
| 479 | } | 484 | } |
| 480 | 485 | ||
| @@ -540,7 +545,8 @@ static int wdm_open(struct inode *inode, struct file *file) | |||
| 540 | } | 545 | } |
| 541 | intf->needs_remote_wakeup = 1; | 546 | intf->needs_remote_wakeup = 1; |
| 542 | 547 | ||
| 543 | mutex_lock(&desc->lock); | 548 | /* using write lock to protect desc->count */ |
| 549 | mutex_lock(&desc->wlock); | ||
| 544 | if (!desc->count++) { | 550 | if (!desc->count++) { |
| 545 | desc->werr = 0; | 551 | desc->werr = 0; |
| 546 | desc->rerr = 0; | 552 | desc->rerr = 0; |
| @@ -553,7 +559,7 @@ static int wdm_open(struct inode *inode, struct file *file) | |||
| 553 | } else { | 559 | } else { |
| 554 | rv = 0; | 560 | rv = 0; |
| 555 | } | 561 | } |
| 556 | mutex_unlock(&desc->lock); | 562 | mutex_unlock(&desc->wlock); |
| 557 | usb_autopm_put_interface(desc->intf); | 563 | usb_autopm_put_interface(desc->intf); |
| 558 | out: | 564 | out: |
| 559 | mutex_unlock(&wdm_mutex); | 565 | mutex_unlock(&wdm_mutex); |
| @@ -565,9 +571,11 @@ static int wdm_release(struct inode *inode, struct file *file) | |||
| 565 | struct wdm_device *desc = file->private_data; | 571 | struct wdm_device *desc = file->private_data; |
| 566 | 572 | ||
| 567 | mutex_lock(&wdm_mutex); | 573 | mutex_lock(&wdm_mutex); |
| 568 | mutex_lock(&desc->lock); | 574 | |
| 575 | /* using write lock to protect desc->count */ | ||
| 576 | mutex_lock(&desc->wlock); | ||
| 569 | desc->count--; | 577 | desc->count--; |
| 570 | mutex_unlock(&desc->lock); | 578 | mutex_unlock(&desc->wlock); |
| 571 | 579 | ||
| 572 | if (!desc->count) { | 580 | if (!desc->count) { |
| 573 | dev_dbg(&desc->intf->dev, "wdm_release: cleanup"); | 581 | dev_dbg(&desc->intf->dev, "wdm_release: cleanup"); |
| @@ -630,7 +638,7 @@ static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
| 630 | struct usb_cdc_dmm_desc *dmhd; | 638 | struct usb_cdc_dmm_desc *dmhd; |
| 631 | u8 *buffer = intf->altsetting->extra; | 639 | u8 *buffer = intf->altsetting->extra; |
| 632 | int buflen = intf->altsetting->extralen; | 640 | int buflen = intf->altsetting->extralen; |
| 633 | u16 maxcom = 0; | 641 | u16 maxcom = WDM_DEFAULT_BUFSIZE; |
| 634 | 642 | ||
| 635 | if (!buffer) | 643 | if (!buffer) |
| 636 | goto out; | 644 | goto out; |
| @@ -665,7 +673,8 @@ next_desc: | |||
| 665 | desc = kzalloc(sizeof(struct wdm_device), GFP_KERNEL); | 673 | desc = kzalloc(sizeof(struct wdm_device), GFP_KERNEL); |
| 666 | if (!desc) | 674 | if (!desc) |
| 667 | goto out; | 675 | goto out; |
| 668 | mutex_init(&desc->lock); | 676 | mutex_init(&desc->rlock); |
| 677 | mutex_init(&desc->wlock); | ||
| 669 | spin_lock_init(&desc->iuspin); | 678 | spin_lock_init(&desc->iuspin); |
| 670 | init_waitqueue_head(&desc->wait); | 679 | init_waitqueue_head(&desc->wait); |
| 671 | desc->wMaxCommand = maxcom; | 680 | desc->wMaxCommand = maxcom; |
| @@ -716,7 +725,7 @@ next_desc: | |||
| 716 | goto err; | 725 | goto err; |
| 717 | 726 | ||
| 718 | desc->inbuf = usb_alloc_coherent(interface_to_usbdev(intf), | 727 | desc->inbuf = usb_alloc_coherent(interface_to_usbdev(intf), |
| 719 | desc->bMaxPacketSize0, | 728 | desc->wMaxCommand, |
| 720 | GFP_KERNEL, | 729 | GFP_KERNEL, |
| 721 | &desc->response->transfer_dma); | 730 | &desc->response->transfer_dma); |
| 722 | if (!desc->inbuf) | 731 | if (!desc->inbuf) |
| @@ -779,11 +788,13 @@ static void wdm_disconnect(struct usb_interface *intf) | |||
| 779 | /* to terminate pending flushes */ | 788 | /* to terminate pending flushes */ |
| 780 | clear_bit(WDM_IN_USE, &desc->flags); | 789 | clear_bit(WDM_IN_USE, &desc->flags); |
| 781 | spin_unlock_irqrestore(&desc->iuspin, flags); | 790 | spin_unlock_irqrestore(&desc->iuspin, flags); |
| 782 | mutex_lock(&desc->lock); | 791 | wake_up_all(&desc->wait); |
| 792 | mutex_lock(&desc->rlock); | ||
| 793 | mutex_lock(&desc->wlock); | ||
| 783 | kill_urbs(desc); | 794 | kill_urbs(desc); |
| 784 | cancel_work_sync(&desc->rxwork); | 795 | cancel_work_sync(&desc->rxwork); |
| 785 | mutex_unlock(&desc->lock); | 796 | mutex_unlock(&desc->wlock); |
| 786 | wake_up_all(&desc->wait); | 797 | mutex_unlock(&desc->rlock); |
| 787 | if (!desc->count) | 798 | if (!desc->count) |
| 788 | cleanup(desc); | 799 | cleanup(desc); |
| 789 | mutex_unlock(&wdm_mutex); | 800 | mutex_unlock(&wdm_mutex); |
| @@ -798,8 +809,10 @@ static int wdm_suspend(struct usb_interface *intf, pm_message_t message) | |||
| 798 | dev_dbg(&desc->intf->dev, "wdm%d_suspend\n", intf->minor); | 809 | dev_dbg(&desc->intf->dev, "wdm%d_suspend\n", intf->minor); |
| 799 | 810 | ||
| 800 | /* if this is an autosuspend the caller does the locking */ | 811 | /* if this is an autosuspend the caller does the locking */ |
| 801 | if (!PMSG_IS_AUTO(message)) | 812 | if (!PMSG_IS_AUTO(message)) { |
| 802 | mutex_lock(&desc->lock); | 813 | mutex_lock(&desc->rlock); |
| 814 | mutex_lock(&desc->wlock); | ||
| 815 | } | ||
| 803 | spin_lock_irq(&desc->iuspin); | 816 | spin_lock_irq(&desc->iuspin); |
| 804 | 817 | ||
| 805 | if (PMSG_IS_AUTO(message) && | 818 | if (PMSG_IS_AUTO(message) && |
| @@ -815,8 +828,10 @@ static int wdm_suspend(struct usb_interface *intf, pm_message_t message) | |||
| 815 | kill_urbs(desc); | 828 | kill_urbs(desc); |
| 816 | cancel_work_sync(&desc->rxwork); | 829 | cancel_work_sync(&desc->rxwork); |
| 817 | } | 830 | } |
| 818 | if (!PMSG_IS_AUTO(message)) | 831 | if (!PMSG_IS_AUTO(message)) { |
| 819 | mutex_unlock(&desc->lock); | 832 | mutex_unlock(&desc->wlock); |
| 833 | mutex_unlock(&desc->rlock); | ||
| 834 | } | ||
| 820 | 835 | ||
| 821 | return rv; | 836 | return rv; |
| 822 | } | 837 | } |
| @@ -854,7 +869,8 @@ static int wdm_pre_reset(struct usb_interface *intf) | |||
| 854 | { | 869 | { |
| 855 | struct wdm_device *desc = usb_get_intfdata(intf); | 870 | struct wdm_device *desc = usb_get_intfdata(intf); |
| 856 | 871 | ||
| 857 | mutex_lock(&desc->lock); | 872 | mutex_lock(&desc->rlock); |
| 873 | mutex_lock(&desc->wlock); | ||
| 858 | kill_urbs(desc); | 874 | kill_urbs(desc); |
| 859 | 875 | ||
| 860 | /* | 876 | /* |
| @@ -876,7 +892,8 @@ static int wdm_post_reset(struct usb_interface *intf) | |||
| 876 | int rv; | 892 | int rv; |
| 877 | 893 | ||
| 878 | rv = recover_from_urb_loss(desc); | 894 | rv = recover_from_urb_loss(desc); |
| 879 | mutex_unlock(&desc->lock); | 895 | mutex_unlock(&desc->wlock); |
| 896 | mutex_unlock(&desc->rlock); | ||
| 880 | return 0; | 897 | return 0; |
| 881 | } | 898 | } |
| 882 | 899 | ||
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c index 2f51de57593a..c8df1dd967ef 100644 --- a/drivers/usb/dwc3/ep0.c +++ b/drivers/usb/dwc3/ep0.c | |||
| @@ -126,7 +126,6 @@ static int __dwc3_gadget_ep0_queue(struct dwc3_ep *dep, | |||
| 126 | struct dwc3_request *req) | 126 | struct dwc3_request *req) |
| 127 | { | 127 | { |
| 128 | struct dwc3 *dwc = dep->dwc; | 128 | struct dwc3 *dwc = dep->dwc; |
| 129 | u32 type; | ||
| 130 | int ret = 0; | 129 | int ret = 0; |
| 131 | 130 | ||
| 132 | req->request.actual = 0; | 131 | req->request.actual = 0; |
| @@ -149,20 +148,14 @@ static int __dwc3_gadget_ep0_queue(struct dwc3_ep *dep, | |||
| 149 | 148 | ||
| 150 | direction = !!(dep->flags & DWC3_EP0_DIR_IN); | 149 | direction = !!(dep->flags & DWC3_EP0_DIR_IN); |
| 151 | 150 | ||
| 152 | if (dwc->ep0state == EP0_STATUS_PHASE) { | 151 | if (dwc->ep0state != EP0_DATA_PHASE) { |
| 153 | type = dwc->three_stage_setup | 152 | dev_WARN(dwc->dev, "Unexpected pending request\n"); |
| 154 | ? DWC3_TRBCTL_CONTROL_STATUS3 | ||
| 155 | : DWC3_TRBCTL_CONTROL_STATUS2; | ||
| 156 | } else if (dwc->ep0state == EP0_DATA_PHASE) { | ||
| 157 | type = DWC3_TRBCTL_CONTROL_DATA; | ||
| 158 | } else { | ||
| 159 | /* should never happen */ | ||
| 160 | WARN_ON(1); | ||
| 161 | return 0; | 153 | return 0; |
| 162 | } | 154 | } |
| 163 | 155 | ||
| 164 | ret = dwc3_ep0_start_trans(dwc, direction, | 156 | ret = dwc3_ep0_start_trans(dwc, direction, |
| 165 | req->request.dma, req->request.length, type); | 157 | req->request.dma, req->request.length, |
| 158 | DWC3_TRBCTL_CONTROL_DATA); | ||
| 166 | dep->flags &= ~(DWC3_EP_PENDING_REQUEST | | 159 | dep->flags &= ~(DWC3_EP_PENDING_REQUEST | |
| 167 | DWC3_EP0_DIR_IN); | 160 | DWC3_EP0_DIR_IN); |
| 168 | } else if (dwc->delayed_status) { | 161 | } else if (dwc->delayed_status) { |
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index a696bde53222..064b6e2cd411 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c | |||
| @@ -101,7 +101,7 @@ void dwc3_unmap_buffer_from_dma(struct dwc3_request *req) | |||
| 101 | if (req->request.num_mapped_sgs) { | 101 | if (req->request.num_mapped_sgs) { |
| 102 | req->request.dma = DMA_ADDR_INVALID; | 102 | req->request.dma = DMA_ADDR_INVALID; |
| 103 | dma_unmap_sg(dwc->dev, req->request.sg, | 103 | dma_unmap_sg(dwc->dev, req->request.sg, |
| 104 | req->request.num_sgs, | 104 | req->request.num_mapped_sgs, |
| 105 | req->direction ? DMA_TO_DEVICE | 105 | req->direction ? DMA_TO_DEVICE |
| 106 | : DMA_FROM_DEVICE); | 106 | : DMA_FROM_DEVICE); |
| 107 | 107 | ||
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index a95de6a4a134..baaebf2830fc 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c | |||
| @@ -175,13 +175,12 @@ ep_found: | |||
| 175 | _ep->comp_desc = comp_desc; | 175 | _ep->comp_desc = comp_desc; |
| 176 | if (g->speed == USB_SPEED_SUPER) { | 176 | if (g->speed == USB_SPEED_SUPER) { |
| 177 | switch (usb_endpoint_type(_ep->desc)) { | 177 | switch (usb_endpoint_type(_ep->desc)) { |
| 178 | case USB_ENDPOINT_XFER_BULK: | ||
| 179 | case USB_ENDPOINT_XFER_INT: | ||
| 180 | _ep->maxburst = comp_desc->bMaxBurst; | ||
| 181 | break; | ||
| 182 | case USB_ENDPOINT_XFER_ISOC: | 178 | case USB_ENDPOINT_XFER_ISOC: |
| 183 | /* mult: bits 1:0 of bmAttributes */ | 179 | /* mult: bits 1:0 of bmAttributes */ |
| 184 | _ep->mult = comp_desc->bmAttributes & 0x3; | 180 | _ep->mult = comp_desc->bmAttributes & 0x3; |
| 181 | case USB_ENDPOINT_XFER_BULK: | ||
| 182 | case USB_ENDPOINT_XFER_INT: | ||
| 183 | _ep->maxburst = comp_desc->bMaxBurst; | ||
| 185 | break; | 184 | break; |
| 186 | default: | 185 | default: |
| 187 | /* Do nothing for control endpoints */ | 186 | /* Do nothing for control endpoints */ |
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 753aa0683ac1..e0e6375ef5dd 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c | |||
| @@ -126,7 +126,7 @@ ep_matches ( | |||
| 126 | * descriptor and see if the EP matches it | 126 | * descriptor and see if the EP matches it |
| 127 | */ | 127 | */ |
| 128 | if (usb_endpoint_xfer_bulk(desc)) { | 128 | if (usb_endpoint_xfer_bulk(desc)) { |
| 129 | if (ep_comp) { | 129 | if (ep_comp && gadget->max_speed >= USB_SPEED_SUPER) { |
| 130 | num_req_streams = ep_comp->bmAttributes & 0x1f; | 130 | num_req_streams = ep_comp->bmAttributes & 0x1f; |
| 131 | if (num_req_streams > ep->max_streams) | 131 | if (num_req_streams > ep->max_streams) |
| 132 | return 0; | 132 | return 0; |
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 6353eca1e852..ee8ceec01560 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c | |||
| @@ -3123,15 +3123,15 @@ fsg_add(struct usb_composite_dev *cdev, struct usb_configuration *c, | |||
| 3123 | 3123 | ||
| 3124 | struct fsg_module_parameters { | 3124 | struct fsg_module_parameters { |
| 3125 | char *file[FSG_MAX_LUNS]; | 3125 | char *file[FSG_MAX_LUNS]; |
| 3126 | int ro[FSG_MAX_LUNS]; | 3126 | bool ro[FSG_MAX_LUNS]; |
| 3127 | int removable[FSG_MAX_LUNS]; | 3127 | bool removable[FSG_MAX_LUNS]; |
| 3128 | int cdrom[FSG_MAX_LUNS]; | 3128 | bool cdrom[FSG_MAX_LUNS]; |
| 3129 | int nofua[FSG_MAX_LUNS]; | 3129 | bool nofua[FSG_MAX_LUNS]; |
| 3130 | 3130 | ||
| 3131 | unsigned int file_count, ro_count, removable_count, cdrom_count; | 3131 | unsigned int file_count, ro_count, removable_count, cdrom_count; |
| 3132 | unsigned int nofua_count; | 3132 | unsigned int nofua_count; |
| 3133 | unsigned int luns; /* nluns */ | 3133 | unsigned int luns; /* nluns */ |
| 3134 | int stall; /* can_stall */ | 3134 | bool stall; /* can_stall */ |
| 3135 | }; | 3135 | }; |
| 3136 | 3136 | ||
| 3137 | #define _FSG_MODULE_PARAM_ARRAY(prefix, params, name, type, desc) \ | 3137 | #define _FSG_MODULE_PARAM_ARRAY(prefix, params, name, type, desc) \ |
diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c index d7ea6c076ce9..b04712f19f1e 100644 --- a/drivers/usb/gadget/fsl_udc_core.c +++ b/drivers/usb/gadget/fsl_udc_core.c | |||
| @@ -1430,7 +1430,7 @@ static void setup_received_irq(struct fsl_udc *udc, | |||
| 1430 | int pipe = get_pipe_by_windex(wIndex); | 1430 | int pipe = get_pipe_by_windex(wIndex); |
| 1431 | struct fsl_ep *ep; | 1431 | struct fsl_ep *ep; |
| 1432 | 1432 | ||
| 1433 | if (wValue != 0 || wLength != 0 || pipe > udc->max_ep) | 1433 | if (wValue != 0 || wLength != 0 || pipe >= udc->max_ep) |
| 1434 | break; | 1434 | break; |
| 1435 | ep = get_ep_by_pipe(udc, pipe); | 1435 | ep = get_ep_by_pipe(udc, pipe); |
| 1436 | 1436 | ||
| @@ -1673,7 +1673,7 @@ static void dtd_complete_irq(struct fsl_udc *udc) | |||
| 1673 | if (!bit_pos) | 1673 | if (!bit_pos) |
| 1674 | return; | 1674 | return; |
| 1675 | 1675 | ||
| 1676 | for (i = 0; i < udc->max_ep * 2; i++) { | 1676 | for (i = 0; i < udc->max_ep; i++) { |
| 1677 | ep_num = i >> 1; | 1677 | ep_num = i >> 1; |
| 1678 | direction = i % 2; | 1678 | direction = i % 2; |
| 1679 | 1679 | ||
diff --git a/drivers/usb/gadget/langwell_udc.c b/drivers/usb/gadget/langwell_udc.c index fa0fcc11263f..e2293c1588ee 100644 --- a/drivers/usb/gadget/langwell_udc.c +++ b/drivers/usb/gadget/langwell_udc.c | |||
| @@ -11,11 +11,6 @@ | |||
| 11 | /* #undef DEBUG */ | 11 | /* #undef DEBUG */ |
| 12 | /* #undef VERBOSE_DEBUG */ | 12 | /* #undef VERBOSE_DEBUG */ |
| 13 | 13 | ||
| 14 | #if defined(CONFIG_USB_LANGWELL_OTG) | ||
| 15 | #define OTG_TRANSCEIVER | ||
| 16 | #endif | ||
| 17 | |||
| 18 | |||
| 19 | #include <linux/module.h> | 14 | #include <linux/module.h> |
| 20 | #include <linux/pci.h> | 15 | #include <linux/pci.h> |
| 21 | #include <linux/dma-mapping.h> | 16 | #include <linux/dma-mapping.h> |
| @@ -1522,8 +1517,7 @@ static void langwell_udc_stop(struct langwell_udc *dev) | |||
| 1522 | 1517 | ||
| 1523 | 1518 | ||
| 1524 | /* stop all USB activities */ | 1519 | /* stop all USB activities */ |
| 1525 | static void stop_activity(struct langwell_udc *dev, | 1520 | static void stop_activity(struct langwell_udc *dev) |
| 1526 | struct usb_gadget_driver *driver) | ||
| 1527 | { | 1521 | { |
| 1528 | struct langwell_ep *ep; | 1522 | struct langwell_ep *ep; |
| 1529 | dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); | 1523 | dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); |
| @@ -1535,9 +1529,9 @@ static void stop_activity(struct langwell_udc *dev, | |||
| 1535 | } | 1529 | } |
| 1536 | 1530 | ||
| 1537 | /* report disconnect; the driver is already quiesced */ | 1531 | /* report disconnect; the driver is already quiesced */ |
| 1538 | if (driver) { | 1532 | if (dev->driver) { |
| 1539 | spin_unlock(&dev->lock); | 1533 | spin_unlock(&dev->lock); |
| 1540 | driver->disconnect(&dev->gadget); | 1534 | dev->driver->disconnect(&dev->gadget); |
| 1541 | spin_lock(&dev->lock); | 1535 | spin_lock(&dev->lock); |
| 1542 | } | 1536 | } |
| 1543 | 1537 | ||
| @@ -1925,11 +1919,10 @@ static int langwell_stop(struct usb_gadget *g, | |||
| 1925 | 1919 | ||
| 1926 | /* stop all usb activities */ | 1920 | /* stop all usb activities */ |
| 1927 | dev->gadget.speed = USB_SPEED_UNKNOWN; | 1921 | dev->gadget.speed = USB_SPEED_UNKNOWN; |
| 1928 | stop_activity(dev, driver); | ||
| 1929 | spin_unlock_irqrestore(&dev->lock, flags); | ||
| 1930 | |||
| 1931 | dev->gadget.dev.driver = NULL; | 1922 | dev->gadget.dev.driver = NULL; |
| 1932 | dev->driver = NULL; | 1923 | dev->driver = NULL; |
| 1924 | stop_activity(dev); | ||
| 1925 | spin_unlock_irqrestore(&dev->lock, flags); | ||
| 1933 | 1926 | ||
| 1934 | device_remove_file(&dev->pdev->dev, &dev_attr_function); | 1927 | device_remove_file(&dev->pdev->dev, &dev_attr_function); |
| 1935 | 1928 | ||
| @@ -2315,13 +2308,9 @@ static void handle_setup_packet(struct langwell_udc *dev, | |||
| 2315 | 2308 | ||
| 2316 | if (!gadget_is_otg(&dev->gadget)) | 2309 | if (!gadget_is_otg(&dev->gadget)) |
| 2317 | break; | 2310 | break; |
| 2318 | else if (setup->bRequest == USB_DEVICE_B_HNP_ENABLE) { | 2311 | else if (setup->bRequest == USB_DEVICE_B_HNP_ENABLE) |
| 2319 | dev->gadget.b_hnp_enable = 1; | 2312 | dev->gadget.b_hnp_enable = 1; |
| 2320 | #ifdef OTG_TRANSCEIVER | 2313 | else if (setup->bRequest == USB_DEVICE_A_HNP_SUPPORT) |
| 2321 | if (!dev->lotg->otg.default_a) | ||
| 2322 | dev->lotg->hsm.b_hnp_enable = 1; | ||
| 2323 | #endif | ||
| 2324 | } else if (setup->bRequest == USB_DEVICE_A_HNP_SUPPORT) | ||
| 2325 | dev->gadget.a_hnp_support = 1; | 2314 | dev->gadget.a_hnp_support = 1; |
| 2326 | else if (setup->bRequest == | 2315 | else if (setup->bRequest == |
| 2327 | USB_DEVICE_A_ALT_HNP_SUPPORT) | 2316 | USB_DEVICE_A_ALT_HNP_SUPPORT) |
| @@ -2733,7 +2722,7 @@ static void handle_usb_reset(struct langwell_udc *dev) | |||
| 2733 | dev->bus_reset = 1; | 2722 | dev->bus_reset = 1; |
| 2734 | 2723 | ||
| 2735 | /* reset all the queues, stop all USB activities */ | 2724 | /* reset all the queues, stop all USB activities */ |
| 2736 | stop_activity(dev, dev->driver); | 2725 | stop_activity(dev); |
| 2737 | dev->usb_state = USB_STATE_DEFAULT; | 2726 | dev->usb_state = USB_STATE_DEFAULT; |
| 2738 | } else { | 2727 | } else { |
| 2739 | dev_vdbg(&dev->pdev->dev, "device controller reset\n"); | 2728 | dev_vdbg(&dev->pdev->dev, "device controller reset\n"); |
| @@ -2741,7 +2730,7 @@ static void handle_usb_reset(struct langwell_udc *dev) | |||
| 2741 | langwell_udc_reset(dev); | 2730 | langwell_udc_reset(dev); |
| 2742 | 2731 | ||
| 2743 | /* reset all the queues, stop all USB activities */ | 2732 | /* reset all the queues, stop all USB activities */ |
| 2744 | stop_activity(dev, dev->driver); | 2733 | stop_activity(dev); |
| 2745 | 2734 | ||
| 2746 | /* reset ep0 dQH and endptctrl */ | 2735 | /* reset ep0 dQH and endptctrl */ |
| 2747 | ep0_reset(dev); | 2736 | ep0_reset(dev); |
| @@ -2752,12 +2741,6 @@ static void handle_usb_reset(struct langwell_udc *dev) | |||
| 2752 | dev->usb_state = USB_STATE_ATTACHED; | 2741 | dev->usb_state = USB_STATE_ATTACHED; |
| 2753 | } | 2742 | } |
| 2754 | 2743 | ||
| 2755 | #ifdef OTG_TRANSCEIVER | ||
| 2756 | /* refer to USB OTG 6.6.2.3 b_hnp_en is cleared */ | ||
| 2757 | if (!dev->lotg->otg.default_a) | ||
| 2758 | dev->lotg->hsm.b_hnp_enable = 0; | ||
| 2759 | #endif | ||
| 2760 | |||
| 2761 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); | 2744 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
| 2762 | } | 2745 | } |
| 2763 | 2746 | ||
| @@ -2770,29 +2753,6 @@ static void handle_bus_suspend(struct langwell_udc *dev) | |||
| 2770 | dev->resume_state = dev->usb_state; | 2753 | dev->resume_state = dev->usb_state; |
| 2771 | dev->usb_state = USB_STATE_SUSPENDED; | 2754 | dev->usb_state = USB_STATE_SUSPENDED; |
| 2772 | 2755 | ||
| 2773 | #ifdef OTG_TRANSCEIVER | ||
| 2774 | if (dev->lotg->otg.default_a) { | ||
| 2775 | if (dev->lotg->hsm.b_bus_suspend_vld == 1) { | ||
| 2776 | dev->lotg->hsm.b_bus_suspend = 1; | ||
| 2777 | /* notify transceiver the state changes */ | ||
| 2778 | if (spin_trylock(&dev->lotg->wq_lock)) { | ||
| 2779 | langwell_update_transceiver(); | ||
| 2780 | spin_unlock(&dev->lotg->wq_lock); | ||
| 2781 | } | ||
| 2782 | } | ||
| 2783 | dev->lotg->hsm.b_bus_suspend_vld++; | ||
| 2784 | } else { | ||
| 2785 | if (!dev->lotg->hsm.a_bus_suspend) { | ||
| 2786 | dev->lotg->hsm.a_bus_suspend = 1; | ||
| 2787 | /* notify transceiver the state changes */ | ||
| 2788 | if (spin_trylock(&dev->lotg->wq_lock)) { | ||
| 2789 | langwell_update_transceiver(); | ||
| 2790 | spin_unlock(&dev->lotg->wq_lock); | ||
| 2791 | } | ||
| 2792 | } | ||
| 2793 | } | ||
| 2794 | #endif | ||
| 2795 | |||
| 2796 | /* report suspend to the driver */ | 2756 | /* report suspend to the driver */ |
| 2797 | if (dev->driver) { | 2757 | if (dev->driver) { |
| 2798 | if (dev->driver->suspend) { | 2758 | if (dev->driver->suspend) { |
| @@ -2823,11 +2783,6 @@ static void handle_bus_resume(struct langwell_udc *dev) | |||
| 2823 | if (dev->pdev->device != 0x0829) | 2783 | if (dev->pdev->device != 0x0829) |
| 2824 | langwell_phy_low_power(dev, 0); | 2784 | langwell_phy_low_power(dev, 0); |
| 2825 | 2785 | ||
| 2826 | #ifdef OTG_TRANSCEIVER | ||
| 2827 | if (dev->lotg->otg.default_a == 0) | ||
| 2828 | dev->lotg->hsm.a_bus_suspend = 0; | ||
| 2829 | #endif | ||
| 2830 | |||
| 2831 | /* report resume to the driver */ | 2786 | /* report resume to the driver */ |
| 2832 | if (dev->driver) { | 2787 | if (dev->driver) { |
| 2833 | if (dev->driver->resume) { | 2788 | if (dev->driver->resume) { |
| @@ -3020,7 +2975,6 @@ static void langwell_udc_remove(struct pci_dev *pdev) | |||
| 3020 | 2975 | ||
| 3021 | dev->done = &done; | 2976 | dev->done = &done; |
| 3022 | 2977 | ||
| 3023 | #ifndef OTG_TRANSCEIVER | ||
| 3024 | /* free dTD dma_pool and dQH */ | 2978 | /* free dTD dma_pool and dQH */ |
| 3025 | if (dev->dtd_pool) | 2979 | if (dev->dtd_pool) |
| 3026 | dma_pool_destroy(dev->dtd_pool); | 2980 | dma_pool_destroy(dev->dtd_pool); |
| @@ -3032,7 +2986,6 @@ static void langwell_udc_remove(struct pci_dev *pdev) | |||
| 3032 | /* release SRAM caching */ | 2986 | /* release SRAM caching */ |
| 3033 | if (dev->has_sram && dev->got_sram) | 2987 | if (dev->has_sram && dev->got_sram) |
| 3034 | sram_deinit(dev); | 2988 | sram_deinit(dev); |
| 3035 | #endif | ||
| 3036 | 2989 | ||
| 3037 | if (dev->status_req) { | 2990 | if (dev->status_req) { |
| 3038 | kfree(dev->status_req->req.buf); | 2991 | kfree(dev->status_req->req.buf); |
| @@ -3045,7 +2998,6 @@ static void langwell_udc_remove(struct pci_dev *pdev) | |||
| 3045 | if (dev->got_irq) | 2998 | if (dev->got_irq) |
| 3046 | free_irq(pdev->irq, dev); | 2999 | free_irq(pdev->irq, dev); |
| 3047 | 3000 | ||
| 3048 | #ifndef OTG_TRANSCEIVER | ||
| 3049 | if (dev->cap_regs) | 3001 | if (dev->cap_regs) |
| 3050 | iounmap(dev->cap_regs); | 3002 | iounmap(dev->cap_regs); |
| 3051 | 3003 | ||
| @@ -3055,13 +3007,6 @@ static void langwell_udc_remove(struct pci_dev *pdev) | |||
| 3055 | 3007 | ||
| 3056 | if (dev->enabled) | 3008 | if (dev->enabled) |
| 3057 | pci_disable_device(pdev); | 3009 | pci_disable_device(pdev); |
| 3058 | #else | ||
| 3059 | if (dev->transceiver) { | ||
| 3060 | otg_put_transceiver(dev->transceiver); | ||
| 3061 | dev->transceiver = NULL; | ||
| 3062 | dev->lotg = NULL; | ||
| 3063 | } | ||
| 3064 | #endif | ||
| 3065 | 3010 | ||
| 3066 | dev->cap_regs = NULL; | 3011 | dev->cap_regs = NULL; |
| 3067 | 3012 | ||
| @@ -3072,9 +3017,7 @@ static void langwell_udc_remove(struct pci_dev *pdev) | |||
| 3072 | device_remove_file(&pdev->dev, &dev_attr_langwell_udc); | 3017 | device_remove_file(&pdev->dev, &dev_attr_langwell_udc); |
| 3073 | device_remove_file(&pdev->dev, &dev_attr_remote_wakeup); | 3018 | device_remove_file(&pdev->dev, &dev_attr_remote_wakeup); |
| 3074 | 3019 | ||
| 3075 | #ifndef OTG_TRANSCEIVER | ||
| 3076 | pci_set_drvdata(pdev, NULL); | 3020 | pci_set_drvdata(pdev, NULL); |
| 3077 | #endif | ||
| 3078 | 3021 | ||
| 3079 | /* free dev, wait for the release() finished */ | 3022 | /* free dev, wait for the release() finished */ |
| 3080 | wait_for_completion(&done); | 3023 | wait_for_completion(&done); |
| @@ -3089,9 +3032,7 @@ static int langwell_udc_probe(struct pci_dev *pdev, | |||
| 3089 | const struct pci_device_id *id) | 3032 | const struct pci_device_id *id) |
| 3090 | { | 3033 | { |
| 3091 | struct langwell_udc *dev; | 3034 | struct langwell_udc *dev; |
| 3092 | #ifndef OTG_TRANSCEIVER | ||
| 3093 | unsigned long resource, len; | 3035 | unsigned long resource, len; |
| 3094 | #endif | ||
| 3095 | void __iomem *base = NULL; | 3036 | void __iomem *base = NULL; |
| 3096 | size_t size; | 3037 | size_t size; |
| 3097 | int retval; | 3038 | int retval; |
| @@ -3109,16 +3050,6 @@ static int langwell_udc_probe(struct pci_dev *pdev, | |||
| 3109 | dev->pdev = pdev; | 3050 | dev->pdev = pdev; |
| 3110 | dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); | 3051 | dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__); |
| 3111 | 3052 | ||
| 3112 | #ifdef OTG_TRANSCEIVER | ||
| 3113 | /* PCI device is already enabled by otg_transceiver driver */ | ||
| 3114 | dev->enabled = 1; | ||
| 3115 | |||
| 3116 | /* mem region and register base */ | ||
| 3117 | dev->region = 1; | ||
| 3118 | dev->transceiver = otg_get_transceiver(); | ||
| 3119 | dev->lotg = otg_to_langwell(dev->transceiver); | ||
| 3120 | base = dev->lotg->regs; | ||
| 3121 | #else | ||
| 3122 | pci_set_drvdata(pdev, dev); | 3053 | pci_set_drvdata(pdev, dev); |
| 3123 | 3054 | ||
| 3124 | /* now all the pci goodies ... */ | 3055 | /* now all the pci goodies ... */ |
| @@ -3139,7 +3070,6 @@ static int langwell_udc_probe(struct pci_dev *pdev, | |||
| 3139 | dev->region = 1; | 3070 | dev->region = 1; |
| 3140 | 3071 | ||
| 3141 | base = ioremap_nocache(resource, len); | 3072 | base = ioremap_nocache(resource, len); |
| 3142 | #endif | ||
| 3143 | if (base == NULL) { | 3073 | if (base == NULL) { |
| 3144 | dev_err(&dev->pdev->dev, "can't map memory\n"); | 3074 | dev_err(&dev->pdev->dev, "can't map memory\n"); |
| 3145 | retval = -EFAULT; | 3075 | retval = -EFAULT; |
| @@ -3163,7 +3093,6 @@ static int langwell_udc_probe(struct pci_dev *pdev, | |||
| 3163 | dev->got_sram = 0; | 3093 | dev->got_sram = 0; |
| 3164 | dev_vdbg(&dev->pdev->dev, "dev->has_sram: %d\n", dev->has_sram); | 3094 | dev_vdbg(&dev->pdev->dev, "dev->has_sram: %d\n", dev->has_sram); |
| 3165 | 3095 | ||
| 3166 | #ifndef OTG_TRANSCEIVER | ||
| 3167 | /* enable SRAM caching if detected */ | 3096 | /* enable SRAM caching if detected */ |
| 3168 | if (dev->has_sram && !dev->got_sram) | 3097 | if (dev->has_sram && !dev->got_sram) |
| 3169 | sram_init(dev); | 3098 | sram_init(dev); |
| @@ -3182,7 +3111,6 @@ static int langwell_udc_probe(struct pci_dev *pdev, | |||
| 3182 | goto error; | 3111 | goto error; |
| 3183 | } | 3112 | } |
| 3184 | dev->got_irq = 1; | 3113 | dev->got_irq = 1; |
| 3185 | #endif | ||
| 3186 | 3114 | ||
| 3187 | /* set stopped bit */ | 3115 | /* set stopped bit */ |
| 3188 | dev->stopped = 1; | 3116 | dev->stopped = 1; |
| @@ -3257,10 +3185,8 @@ static int langwell_udc_probe(struct pci_dev *pdev, | |||
| 3257 | dev->remote_wakeup = 0; | 3185 | dev->remote_wakeup = 0; |
| 3258 | dev->dev_status = 1 << USB_DEVICE_SELF_POWERED; | 3186 | dev->dev_status = 1 << USB_DEVICE_SELF_POWERED; |
| 3259 | 3187 | ||
| 3260 | #ifndef OTG_TRANSCEIVER | ||
| 3261 | /* reset device controller */ | 3188 | /* reset device controller */ |
| 3262 | langwell_udc_reset(dev); | 3189 | langwell_udc_reset(dev); |
| 3263 | #endif | ||
| 3264 | 3190 | ||
| 3265 | /* initialize gadget structure */ | 3191 | /* initialize gadget structure */ |
| 3266 | dev->gadget.ops = &langwell_ops; /* usb_gadget_ops */ | 3192 | dev->gadget.ops = &langwell_ops; /* usb_gadget_ops */ |
| @@ -3268,9 +3194,6 @@ static int langwell_udc_probe(struct pci_dev *pdev, | |||
| 3268 | INIT_LIST_HEAD(&dev->gadget.ep_list); /* ep_list */ | 3194 | INIT_LIST_HEAD(&dev->gadget.ep_list); /* ep_list */ |
| 3269 | dev->gadget.speed = USB_SPEED_UNKNOWN; /* speed */ | 3195 | dev->gadget.speed = USB_SPEED_UNKNOWN; /* speed */ |
| 3270 | dev->gadget.max_speed = USB_SPEED_HIGH; /* support dual speed */ | 3196 | dev->gadget.max_speed = USB_SPEED_HIGH; /* support dual speed */ |
| 3271 | #ifdef OTG_TRANSCEIVER | ||
| 3272 | dev->gadget.is_otg = 1; /* support otg mode */ | ||
| 3273 | #endif | ||
| 3274 | 3197 | ||
| 3275 | /* the "gadget" abstracts/virtualizes the controller */ | 3198 | /* the "gadget" abstracts/virtualizes the controller */ |
| 3276 | dev_set_name(&dev->gadget.dev, "gadget"); | 3199 | dev_set_name(&dev->gadget.dev, "gadget"); |
| @@ -3282,10 +3205,8 @@ static int langwell_udc_probe(struct pci_dev *pdev, | |||
| 3282 | /* controller endpoints reinit */ | 3205 | /* controller endpoints reinit */ |
| 3283 | eps_reinit(dev); | 3206 | eps_reinit(dev); |
| 3284 | 3207 | ||
| 3285 | #ifndef OTG_TRANSCEIVER | ||
| 3286 | /* reset ep0 dQH and endptctrl */ | 3208 | /* reset ep0 dQH and endptctrl */ |
| 3287 | ep0_reset(dev); | 3209 | ep0_reset(dev); |
| 3288 | #endif | ||
| 3289 | 3210 | ||
| 3290 | /* create dTD dma_pool resource */ | 3211 | /* create dTD dma_pool resource */ |
| 3291 | dev->dtd_pool = dma_pool_create("langwell_dtd", | 3212 | dev->dtd_pool = dma_pool_create("langwell_dtd", |
| @@ -3367,7 +3288,7 @@ static int langwell_udc_suspend(struct pci_dev *pdev, pm_message_t state) | |||
| 3367 | 3288 | ||
| 3368 | spin_lock_irq(&dev->lock); | 3289 | spin_lock_irq(&dev->lock); |
| 3369 | /* stop all usb activities */ | 3290 | /* stop all usb activities */ |
| 3370 | stop_activity(dev, dev->driver); | 3291 | stop_activity(dev); |
| 3371 | spin_unlock_irq(&dev->lock); | 3292 | spin_unlock_irq(&dev->lock); |
| 3372 | 3293 | ||
| 3373 | /* free dTD dma_pool and dQH */ | 3294 | /* free dTD dma_pool and dQH */ |
| @@ -3525,22 +3446,14 @@ static struct pci_driver langwell_pci_driver = { | |||
| 3525 | 3446 | ||
| 3526 | static int __init init(void) | 3447 | static int __init init(void) |
| 3527 | { | 3448 | { |
| 3528 | #ifdef OTG_TRANSCEIVER | ||
| 3529 | return langwell_register_peripheral(&langwell_pci_driver); | ||
| 3530 | #else | ||
| 3531 | return pci_register_driver(&langwell_pci_driver); | 3449 | return pci_register_driver(&langwell_pci_driver); |
| 3532 | #endif | ||
| 3533 | } | 3450 | } |
| 3534 | module_init(init); | 3451 | module_init(init); |
| 3535 | 3452 | ||
| 3536 | 3453 | ||
| 3537 | static void __exit cleanup(void) | 3454 | static void __exit cleanup(void) |
| 3538 | { | 3455 | { |
| 3539 | #ifdef OTG_TRANSCEIVER | ||
| 3540 | return langwell_unregister_peripheral(&langwell_pci_driver); | ||
| 3541 | #else | ||
| 3542 | pci_unregister_driver(&langwell_pci_driver); | 3456 | pci_unregister_driver(&langwell_pci_driver); |
| 3543 | #endif | ||
| 3544 | } | 3457 | } |
| 3545 | module_exit(cleanup); | 3458 | module_exit(cleanup); |
| 3546 | 3459 | ||
diff --git a/drivers/usb/gadget/langwell_udc.h b/drivers/usb/gadget/langwell_udc.h index ef79e242b7b0..d6e78accaffe 100644 --- a/drivers/usb/gadget/langwell_udc.h +++ b/drivers/usb/gadget/langwell_udc.h | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | */ | 8 | */ |
| 9 | 9 | ||
| 10 | #include <linux/usb/langwell_udc.h> | 10 | #include <linux/usb/langwell_udc.h> |
| 11 | #include <linux/usb/langwell_otg.h> | ||
| 12 | 11 | ||
| 13 | /*-------------------------------------------------------------------------*/ | 12 | /*-------------------------------------------------------------------------*/ |
| 14 | 13 | ||
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c index c7f291a331df..85ea14e2545e 100644 --- a/drivers/usb/gadget/storage_common.c +++ b/drivers/usb/gadget/storage_common.c | |||
| @@ -598,16 +598,16 @@ static __maybe_unused struct usb_ss_cap_descriptor fsg_ss_cap_desc = { | |||
| 598 | | USB_5GBPS_OPERATION), | 598 | | USB_5GBPS_OPERATION), |
| 599 | .bFunctionalitySupport = USB_LOW_SPEED_OPERATION, | 599 | .bFunctionalitySupport = USB_LOW_SPEED_OPERATION, |
| 600 | .bU1devExitLat = USB_DEFAULT_U1_DEV_EXIT_LAT, | 600 | .bU1devExitLat = USB_DEFAULT_U1_DEV_EXIT_LAT, |
| 601 | .bU2DevExitLat = USB_DEFAULT_U2_DEV_EXIT_LAT, | 601 | .bU2DevExitLat = cpu_to_le16(USB_DEFAULT_U2_DEV_EXIT_LAT), |
| 602 | }; | 602 | }; |
| 603 | 603 | ||
| 604 | static __maybe_unused struct usb_bos_descriptor fsg_bos_desc = { | 604 | static __maybe_unused struct usb_bos_descriptor fsg_bos_desc = { |
| 605 | .bLength = USB_DT_BOS_SIZE, | 605 | .bLength = USB_DT_BOS_SIZE, |
| 606 | .bDescriptorType = USB_DT_BOS, | 606 | .bDescriptorType = USB_DT_BOS, |
| 607 | 607 | ||
| 608 | .wTotalLength = USB_DT_BOS_SIZE | 608 | .wTotalLength = cpu_to_le16(USB_DT_BOS_SIZE |
| 609 | + USB_DT_USB_EXT_CAP_SIZE | 609 | + USB_DT_USB_EXT_CAP_SIZE |
| 610 | + USB_DT_USB_SS_CAP_SIZE, | 610 | + USB_DT_USB_SS_CAP_SIZE), |
| 611 | 611 | ||
| 612 | .bNumDeviceCaps = 2, | 612 | .bNumDeviceCaps = 2, |
| 613 | }; | 613 | }; |
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index e90344a17631..b556a72264d1 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c | |||
| @@ -125,7 +125,7 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver, | |||
| 125 | */ | 125 | */ |
| 126 | if (pdata->init && pdata->init(pdev)) { | 126 | if (pdata->init && pdata->init(pdev)) { |
| 127 | retval = -ENODEV; | 127 | retval = -ENODEV; |
| 128 | goto err3; | 128 | goto err4; |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | /* Enable USB controller, 83xx or 8536 */ | 131 | /* Enable USB controller, 83xx or 8536 */ |
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index f4b627d343ac..01bb7241d6ef 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c | |||
| @@ -276,6 +276,9 @@ static int ehci_pci_setup(struct usb_hcd *hcd) | |||
| 276 | 276 | ||
| 277 | /* Serial Bus Release Number is at PCI 0x60 offset */ | 277 | /* Serial Bus Release Number is at PCI 0x60 offset */ |
| 278 | pci_read_config_byte(pdev, 0x60, &ehci->sbrn); | 278 | pci_read_config_byte(pdev, 0x60, &ehci->sbrn); |
| 279 | if (pdev->vendor == PCI_VENDOR_ID_STMICRO | ||
| 280 | && pdev->device == PCI_DEVICE_ID_STMICRO_USB_HOST) | ||
| 281 | ehci->sbrn = 0x20; /* ConneXT has no sbrn register */ | ||
| 279 | 282 | ||
| 280 | /* Keep this around for a while just in case some EHCI | 283 | /* Keep this around for a while just in case some EHCI |
| 281 | * implementation uses legacy PCI PM support. This test | 284 | * implementation uses legacy PCI PM support. This test |
| @@ -526,6 +529,9 @@ static const struct pci_device_id pci_ids [] = { { | |||
| 526 | /* handle any USB 2.0 EHCI controller */ | 529 | /* handle any USB 2.0 EHCI controller */ |
| 527 | PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_EHCI, ~0), | 530 | PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_EHCI, ~0), |
| 528 | .driver_data = (unsigned long) &ehci_pci_hc_driver, | 531 | .driver_data = (unsigned long) &ehci_pci_hc_driver, |
| 532 | }, { | ||
| 533 | PCI_VDEVICE(STMICRO, PCI_DEVICE_ID_STMICRO_USB_HOST), | ||
| 534 | .driver_data = (unsigned long) &ehci_pci_hc_driver, | ||
| 529 | }, | 535 | }, |
| 530 | { /* end: all zeroes */ } | 536 | { /* end: all zeroes */ } |
| 531 | }; | 537 | }; |
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c index 5179fcd73d8a..e4bcb62b930a 100644 --- a/drivers/usb/host/ohci-dbg.c +++ b/drivers/usb/host/ohci-dbg.c | |||
| @@ -82,6 +82,14 @@ urb_print(struct urb * urb, char * str, int small, int status) | |||
| 82 | ohci_dbg(ohci,format, ## arg ); \ | 82 | ohci_dbg(ohci,format, ## arg ); \ |
| 83 | } while (0); | 83 | } while (0); |
| 84 | 84 | ||
| 85 | /* Version for use where "next" is the address of a local variable */ | ||
| 86 | #define ohci_dbg_nosw(ohci, next, size, format, arg...) \ | ||
| 87 | do { \ | ||
| 88 | unsigned s_len; \ | ||
| 89 | s_len = scnprintf(*next, *size, format, ## arg); \ | ||
| 90 | *size -= s_len; *next += s_len; \ | ||
| 91 | } while (0); | ||
| 92 | |||
| 85 | 93 | ||
| 86 | static void ohci_dump_intr_mask ( | 94 | static void ohci_dump_intr_mask ( |
| 87 | struct ohci_hcd *ohci, | 95 | struct ohci_hcd *ohci, |
| @@ -653,7 +661,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf) | |||
| 653 | 661 | ||
| 654 | /* dump driver info, then registers in spec order */ | 662 | /* dump driver info, then registers in spec order */ |
| 655 | 663 | ||
| 656 | ohci_dbg_sw (ohci, &next, &size, | 664 | ohci_dbg_nosw(ohci, &next, &size, |
| 657 | "bus %s, device %s\n" | 665 | "bus %s, device %s\n" |
| 658 | "%s\n" | 666 | "%s\n" |
| 659 | "%s\n", | 667 | "%s\n", |
| @@ -672,7 +680,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf) | |||
| 672 | 680 | ||
| 673 | /* hcca */ | 681 | /* hcca */ |
| 674 | if (ohci->hcca) | 682 | if (ohci->hcca) |
| 675 | ohci_dbg_sw (ohci, &next, &size, | 683 | ohci_dbg_nosw(ohci, &next, &size, |
| 676 | "hcca frame 0x%04x\n", ohci_frame_no(ohci)); | 684 | "hcca frame 0x%04x\n", ohci_frame_no(ohci)); |
| 677 | 685 | ||
| 678 | /* other registers mostly affect frame timings */ | 686 | /* other registers mostly affect frame timings */ |
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c index 6109810cc2d3..1843bb68ac7c 100644 --- a/drivers/usb/host/ohci-pci.c +++ b/drivers/usb/host/ohci-pci.c | |||
| @@ -397,6 +397,10 @@ static const struct pci_device_id pci_ids [] = { { | |||
| 397 | /* handle any USB OHCI controller */ | 397 | /* handle any USB OHCI controller */ |
| 398 | PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_OHCI, ~0), | 398 | PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_OHCI, ~0), |
| 399 | .driver_data = (unsigned long) &ohci_pci_hc_driver, | 399 | .driver_data = (unsigned long) &ohci_pci_hc_driver, |
| 400 | }, { | ||
| 401 | /* The device in the ConneXT I/O hub has no class reg */ | ||
| 402 | PCI_VDEVICE(STMICRO, PCI_DEVICE_ID_STMICRO_USB_OHCI), | ||
| 403 | .driver_data = (unsigned long) &ohci_pci_hc_driver, | ||
| 400 | }, { /* end: all zeroes */ } | 404 | }, { /* end: all zeroes */ } |
| 401 | }; | 405 | }; |
| 402 | MODULE_DEVICE_TABLE (pci, pci_ids); | 406 | MODULE_DEVICE_TABLE (pci, pci_ids); |
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index b90e1386418b..b62037bff688 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c | |||
| @@ -1204,6 +1204,7 @@ static void handle_vendor_event(struct xhci_hcd *xhci, | |||
| 1204 | * | 1204 | * |
| 1205 | * Returns a zero-based port number, which is suitable for indexing into each of | 1205 | * Returns a zero-based port number, which is suitable for indexing into each of |
| 1206 | * the split roothubs' port arrays and bus state arrays. | 1206 | * the split roothubs' port arrays and bus state arrays. |
| 1207 | * Add one to it in order to call xhci_find_slot_id_by_port. | ||
| 1207 | */ | 1208 | */ |
| 1208 | static unsigned int find_faked_portnum_from_hw_portnum(struct usb_hcd *hcd, | 1209 | static unsigned int find_faked_portnum_from_hw_portnum(struct usb_hcd *hcd, |
| 1209 | struct xhci_hcd *xhci, u32 port_id) | 1210 | struct xhci_hcd *xhci, u32 port_id) |
| @@ -1324,7 +1325,7 @@ static void handle_port_status(struct xhci_hcd *xhci, | |||
| 1324 | xhci_set_link_state(xhci, port_array, faked_port_index, | 1325 | xhci_set_link_state(xhci, port_array, faked_port_index, |
| 1325 | XDEV_U0); | 1326 | XDEV_U0); |
| 1326 | slot_id = xhci_find_slot_id_by_port(hcd, xhci, | 1327 | slot_id = xhci_find_slot_id_by_port(hcd, xhci, |
| 1327 | faked_port_index); | 1328 | faked_port_index + 1); |
| 1328 | if (!slot_id) { | 1329 | if (!slot_id) { |
| 1329 | xhci_dbg(xhci, "slot_id is zero\n"); | 1330 | xhci_dbg(xhci, "slot_id is zero\n"); |
| 1330 | goto cleanup; | 1331 | goto cleanup; |
| @@ -3323,7 +3324,8 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
| 3323 | /* Check TD length */ | 3324 | /* Check TD length */ |
| 3324 | if (running_total != td_len) { | 3325 | if (running_total != td_len) { |
| 3325 | xhci_err(xhci, "ISOC TD length unmatch\n"); | 3326 | xhci_err(xhci, "ISOC TD length unmatch\n"); |
| 3326 | return -EINVAL; | 3327 | ret = -EINVAL; |
| 3328 | goto cleanup; | ||
| 3327 | } | 3329 | } |
| 3328 | } | 3330 | } |
| 3329 | 3331 | ||
diff --git a/drivers/usb/misc/emi26.c b/drivers/usb/misc/emi26.c index d9b6a0355443..da97dcec1f32 100644 --- a/drivers/usb/misc/emi26.c +++ b/drivers/usb/misc/emi26.c | |||
| @@ -37,9 +37,6 @@ static int emi26_set_reset(struct usb_device *dev, unsigned char reset_bit); | |||
| 37 | static int emi26_load_firmware (struct usb_device *dev); | 37 | static int emi26_load_firmware (struct usb_device *dev); |
| 38 | static int emi26_probe(struct usb_interface *intf, const struct usb_device_id *id); | 38 | static int emi26_probe(struct usb_interface *intf, const struct usb_device_id *id); |
| 39 | static void emi26_disconnect(struct usb_interface *intf); | 39 | static void emi26_disconnect(struct usb_interface *intf); |
| 40 | static int __init emi26_init (void); | ||
| 41 | static void __exit emi26_exit (void); | ||
| 42 | |||
| 43 | 40 | ||
| 44 | /* thanks to drivers/usb/serial/keyspan_pda.c code */ | 41 | /* thanks to drivers/usb/serial/keyspan_pda.c code */ |
| 45 | static int emi26_writememory (struct usb_device *dev, int address, | 42 | static int emi26_writememory (struct usb_device *dev, int address, |
diff --git a/drivers/usb/misc/emi62.c b/drivers/usb/misc/emi62.c index 9f39062ebb08..4e0f167a6c4e 100644 --- a/drivers/usb/misc/emi62.c +++ b/drivers/usb/misc/emi62.c | |||
| @@ -46,9 +46,6 @@ static int emi62_set_reset(struct usb_device *dev, unsigned char reset_bit); | |||
| 46 | static int emi62_load_firmware (struct usb_device *dev); | 46 | static int emi62_load_firmware (struct usb_device *dev); |
| 47 | static int emi62_probe(struct usb_interface *intf, const struct usb_device_id *id); | 47 | static int emi62_probe(struct usb_interface *intf, const struct usb_device_id *id); |
| 48 | static void emi62_disconnect(struct usb_interface *intf); | 48 | static void emi62_disconnect(struct usb_interface *intf); |
| 49 | static int __init emi62_init (void); | ||
| 50 | static void __exit emi62_exit (void); | ||
| 51 | |||
| 52 | 49 | ||
| 53 | /* thanks to drivers/usb/serial/keyspan_pda.c code */ | 50 | /* thanks to drivers/usb/serial/keyspan_pda.c code */ |
| 54 | static int emi62_writememory(struct usb_device *dev, int address, | 51 | static int emi62_writememory(struct usb_device *dev, int address, |
diff --git a/drivers/usb/misc/usbsevseg.c b/drivers/usb/misc/usbsevseg.c index 107bf13b1cf1..b2d82b937392 100644 --- a/drivers/usb/misc/usbsevseg.c +++ b/drivers/usb/misc/usbsevseg.c | |||
| @@ -24,7 +24,7 @@ | |||
| 24 | 24 | ||
| 25 | #define VENDOR_ID 0x0fc5 | 25 | #define VENDOR_ID 0x0fc5 |
| 26 | #define PRODUCT_ID 0x1227 | 26 | #define PRODUCT_ID 0x1227 |
| 27 | #define MAXLEN 6 | 27 | #define MAXLEN 8 |
| 28 | 28 | ||
| 29 | /* table of devices that work with this driver */ | 29 | /* table of devices that work with this driver */ |
| 30 | static const struct usb_device_id id_table[] = { | 30 | static const struct usb_device_id id_table[] = { |
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c index f9a3f62a83b5..7c569f51212a 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c | |||
| @@ -33,9 +33,6 @@ | |||
| 33 | #include <linux/platform_device.h> | 33 | #include <linux/platform_device.h> |
| 34 | #include <linux/dma-mapping.h> | 34 | #include <linux/dma-mapping.h> |
| 35 | 35 | ||
| 36 | #include <mach/hardware.h> | ||
| 37 | #include <mach/memory.h> | ||
| 38 | #include <asm/gpio.h> | ||
| 39 | #include <mach/cputype.h> | 36 | #include <mach/cputype.h> |
| 40 | 37 | ||
| 41 | #include <asm/mach-types.h> | 38 | #include <asm/mach-types.h> |
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 56cf0243979e..3d11cf64ebd1 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c | |||
| @@ -981,6 +981,9 @@ static void musb_shutdown(struct platform_device *pdev) | |||
| 981 | unsigned long flags; | 981 | unsigned long flags; |
| 982 | 982 | ||
| 983 | pm_runtime_get_sync(musb->controller); | 983 | pm_runtime_get_sync(musb->controller); |
| 984 | |||
| 985 | musb_gadget_cleanup(musb); | ||
| 986 | |||
| 984 | spin_lock_irqsave(&musb->lock, flags); | 987 | spin_lock_irqsave(&musb->lock, flags); |
| 985 | musb_platform_disable(musb); | 988 | musb_platform_disable(musb); |
| 986 | musb_generic_disable(musb); | 989 | musb_generic_disable(musb); |
| @@ -1827,8 +1830,6 @@ static void musb_free(struct musb *musb) | |||
| 1827 | sysfs_remove_group(&musb->controller->kobj, &musb_attr_group); | 1830 | sysfs_remove_group(&musb->controller->kobj, &musb_attr_group); |
| 1828 | #endif | 1831 | #endif |
| 1829 | 1832 | ||
| 1830 | musb_gadget_cleanup(musb); | ||
| 1831 | |||
| 1832 | if (musb->nIrq >= 0) { | 1833 | if (musb->nIrq >= 0) { |
| 1833 | if (musb->irq_wake) | 1834 | if (musb->irq_wake) |
| 1834 | disable_irq_wake(musb->nIrq); | 1835 | disable_irq_wake(musb->nIrq); |
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index c27bbbf32b52..df719eae3b03 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c | |||
| @@ -222,7 +222,6 @@ static inline void omap2430_low_level_init(struct musb *musb) | |||
| 222 | musb_writel(musb->mregs, OTG_FORCESTDBY, l); | 222 | musb_writel(musb->mregs, OTG_FORCESTDBY, l); |
| 223 | } | 223 | } |
| 224 | 224 | ||
| 225 | /* blocking notifier support */ | ||
| 226 | static int musb_otg_notifications(struct notifier_block *nb, | 225 | static int musb_otg_notifications(struct notifier_block *nb, |
| 227 | unsigned long event, void *unused) | 226 | unsigned long event, void *unused) |
| 228 | { | 227 | { |
| @@ -231,7 +230,7 @@ static int musb_otg_notifications(struct notifier_block *nb, | |||
| 231 | musb->xceiv_event = event; | 230 | musb->xceiv_event = event; |
| 232 | schedule_work(&musb->otg_notifier_work); | 231 | schedule_work(&musb->otg_notifier_work); |
| 233 | 232 | ||
| 234 | return 0; | 233 | return NOTIFY_OK; |
| 235 | } | 234 | } |
| 236 | 235 | ||
| 237 | static void musb_otg_notifier_work(struct work_struct *data_notifier_work) | 236 | static void musb_otg_notifier_work(struct work_struct *data_notifier_work) |
| @@ -386,6 +385,7 @@ static void omap2430_musb_disable(struct musb *musb) | |||
| 386 | static int omap2430_musb_exit(struct musb *musb) | 385 | static int omap2430_musb_exit(struct musb *musb) |
| 387 | { | 386 | { |
| 388 | del_timer_sync(&musb_idle_timer); | 387 | del_timer_sync(&musb_idle_timer); |
| 388 | cancel_work_sync(&musb->otg_notifier_work); | ||
| 389 | 389 | ||
| 390 | omap2430_low_level_exit(musb); | 390 | omap2430_low_level_exit(musb); |
| 391 | otg_put_transceiver(musb->xceiv); | 391 | otg_put_transceiver(musb->xceiv); |
diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig index 2a25955881fc..76d629345418 100644 --- a/drivers/usb/otg/Kconfig +++ b/drivers/usb/otg/Kconfig | |||
| @@ -86,20 +86,6 @@ config NOP_USB_XCEIV | |||
| 86 | built-in with usb ip or which are autonomous and doesn't require any | 86 | built-in with usb ip or which are autonomous and doesn't require any |
| 87 | phy programming such as ISP1x04 etc. | 87 | phy programming such as ISP1x04 etc. |
| 88 | 88 | ||
| 89 | config USB_LANGWELL_OTG | ||
| 90 | tristate "Intel Langwell USB OTG dual-role support" | ||
| 91 | depends on USB && PCI && INTEL_SCU_IPC | ||
| 92 | select USB_OTG | ||
| 93 | select USB_OTG_UTILS | ||
| 94 | help | ||
| 95 | Say Y here if you want to build Intel Langwell USB OTG | ||
| 96 | transciever driver in kernel. This driver implements role | ||
| 97 | switch between EHCI host driver and Langwell USB OTG | ||
| 98 | client driver. | ||
| 99 | |||
| 100 | To compile this driver as a module, choose M here: the | ||
| 101 | module will be called langwell_otg. | ||
| 102 | |||
| 103 | config USB_MSM_OTG | 89 | config USB_MSM_OTG |
| 104 | tristate "OTG support for Qualcomm on-chip USB controller" | 90 | tristate "OTG support for Qualcomm on-chip USB controller" |
| 105 | depends on (USB || USB_GADGET) && ARCH_MSM | 91 | depends on (USB || USB_GADGET) && ARCH_MSM |
| @@ -124,7 +110,7 @@ config AB8500_USB | |||
| 124 | 110 | ||
| 125 | config FSL_USB2_OTG | 111 | config FSL_USB2_OTG |
| 126 | bool "Freescale USB OTG Transceiver Driver" | 112 | bool "Freescale USB OTG Transceiver Driver" |
| 127 | depends on USB_EHCI_FSL && USB_GADGET_FSL_USB2 | 113 | depends on USB_EHCI_FSL && USB_GADGET_FSL_USB2 && USB_SUSPEND |
| 128 | select USB_OTG | 114 | select USB_OTG |
| 129 | select USB_OTG_UTILS | 115 | select USB_OTG_UTILS |
| 130 | help | 116 | help |
| @@ -132,7 +118,7 @@ config FSL_USB2_OTG | |||
| 132 | 118 | ||
| 133 | config USB_MV_OTG | 119 | config USB_MV_OTG |
| 134 | tristate "Marvell USB OTG support" | 120 | tristate "Marvell USB OTG support" |
| 135 | depends on USB_MV_UDC | 121 | depends on USB_MV_UDC && USB_SUSPEND |
| 136 | select USB_OTG | 122 | select USB_OTG |
| 137 | select USB_OTG_UTILS | 123 | select USB_OTG_UTILS |
| 138 | help | 124 | help |
diff --git a/drivers/usb/otg/Makefile b/drivers/usb/otg/Makefile index b2c5a9598637..41aa5098b139 100644 --- a/drivers/usb/otg/Makefile +++ b/drivers/usb/otg/Makefile | |||
| @@ -13,7 +13,6 @@ obj-$(CONFIG_USB_GPIO_VBUS) += gpio_vbus.o | |||
| 13 | obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o | 13 | obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o |
| 14 | obj-$(CONFIG_TWL4030_USB) += twl4030-usb.o | 14 | obj-$(CONFIG_TWL4030_USB) += twl4030-usb.o |
| 15 | obj-$(CONFIG_TWL6030_USB) += twl6030-usb.o | 15 | obj-$(CONFIG_TWL6030_USB) += twl6030-usb.o |
| 16 | obj-$(CONFIG_USB_LANGWELL_OTG) += langwell_otg.o | ||
| 17 | obj-$(CONFIG_NOP_USB_XCEIV) += nop-usb-xceiv.o | 16 | obj-$(CONFIG_NOP_USB_XCEIV) += nop-usb-xceiv.o |
| 18 | obj-$(CONFIG_USB_ULPI) += ulpi.o | 17 | obj-$(CONFIG_USB_ULPI) += ulpi.o |
| 19 | obj-$(CONFIG_USB_ULPI_VIEWPORT) += ulpi_viewport.o | 18 | obj-$(CONFIG_USB_ULPI_VIEWPORT) += ulpi_viewport.o |
diff --git a/drivers/usb/otg/langwell_otg.c b/drivers/usb/otg/langwell_otg.c deleted file mode 100644 index f08f784086f7..000000000000 --- a/drivers/usb/otg/langwell_otg.c +++ /dev/null | |||
| @@ -1,2347 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Intel Langwell USB OTG transceiver driver | ||
| 3 | * Copyright (C) 2008 - 2010, Intel Corporation. | ||
| 4 | * | ||
| 5 | * This program is free software; you can redistribute it and/or modify it | ||
| 6 | * under the terms and conditions of the GNU General Public License, | ||
| 7 | * version 2, as published by the Free Software Foundation. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 12 | * more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License along with | ||
| 15 | * this program; if not, write to the Free Software Foundation, Inc., | ||
| 16 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 17 | * | ||
| 18 | */ | ||
| 19 | /* This driver helps to switch Langwell OTG controller function between host | ||
| 20 | * and peripheral. It works with EHCI driver and Langwell client controller | ||
| 21 | * driver together. | ||
| 22 | */ | ||
| 23 | #include <linux/module.h> | ||
| 24 | #include <linux/init.h> | ||
| 25 | #include <linux/pci.h> | ||
| 26 | #include <linux/errno.h> | ||
| 27 | #include <linux/interrupt.h> | ||
| 28 | #include <linux/kernel.h> | ||
| 29 | #include <linux/device.h> | ||
| 30 | #include <linux/moduleparam.h> | ||
| 31 | #include <linux/usb/ch9.h> | ||
| 32 | #include <linux/usb/gadget.h> | ||
| 33 | #include <linux/usb.h> | ||
| 34 | #include <linux/usb/otg.h> | ||
| 35 | #include <linux/usb/hcd.h> | ||
| 36 | #include <linux/notifier.h> | ||
| 37 | #include <linux/delay.h> | ||
| 38 | #include <asm/intel_scu_ipc.h> | ||
| 39 | |||
| 40 | #include <linux/usb/langwell_otg.h> | ||
| 41 | |||
| 42 | #define DRIVER_DESC "Intel Langwell USB OTG transceiver driver" | ||
| 43 | #define DRIVER_VERSION "July 10, 2010" | ||
| 44 | |||
| 45 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
| 46 | MODULE_AUTHOR("Henry Yuan <hang.yuan@intel.com>, Hao Wu <hao.wu@intel.com>"); | ||
| 47 | MODULE_VERSION(DRIVER_VERSION); | ||
| 48 | MODULE_LICENSE("GPL"); | ||
| 49 | |||
| 50 | static const char driver_name[] = "langwell_otg"; | ||
| 51 | |||
| 52 | static int langwell_otg_probe(struct pci_dev *pdev, | ||
| 53 | const struct pci_device_id *id); | ||
| 54 | static void langwell_otg_remove(struct pci_dev *pdev); | ||
| 55 | static int langwell_otg_suspend(struct pci_dev *pdev, pm_message_t message); | ||
| 56 | static int langwell_otg_resume(struct pci_dev *pdev); | ||
| 57 | |||
| 58 | static int langwell_otg_set_host(struct otg_transceiver *otg, | ||
| 59 | struct usb_bus *host); | ||
| 60 | static int langwell_otg_set_peripheral(struct otg_transceiver *otg, | ||
| 61 | struct usb_gadget *gadget); | ||
| 62 | static int langwell_otg_start_srp(struct otg_transceiver *otg); | ||
| 63 | |||
| 64 | static const struct pci_device_id pci_ids[] = {{ | ||
| 65 | .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe), | ||
| 66 | .class_mask = ~0, | ||
| 67 | .vendor = 0x8086, | ||
| 68 | .device = 0x0811, | ||
| 69 | .subvendor = PCI_ANY_ID, | ||
| 70 | .subdevice = PCI_ANY_ID, | ||
| 71 | }, { /* end: all zeroes */ } | ||
| 72 | }; | ||
| 73 | |||
| 74 | static struct pci_driver otg_pci_driver = { | ||
| 75 | .name = (char *) driver_name, | ||
| 76 | .id_table = pci_ids, | ||
| 77 | |||
| 78 | .probe = langwell_otg_probe, | ||
| 79 | .remove = langwell_otg_remove, | ||
| 80 | |||
| 81 | .suspend = langwell_otg_suspend, | ||
| 82 | .resume = langwell_otg_resume, | ||
| 83 | }; | ||
| 84 | |||
| 85 | /* HSM timers */ | ||
| 86 | static inline struct langwell_otg_timer *otg_timer_initializer | ||
| 87 | (void (*function)(unsigned long), unsigned long expires, unsigned long data) | ||
| 88 | { | ||
| 89 | struct langwell_otg_timer *timer; | ||
| 90 | timer = kmalloc(sizeof(struct langwell_otg_timer), GFP_KERNEL); | ||
| 91 | if (timer == NULL) | ||
| 92 | return timer; | ||
| 93 | |||
| 94 | timer->function = function; | ||
| 95 | timer->expires = expires; | ||
| 96 | timer->data = data; | ||
| 97 | return timer; | ||
| 98 | } | ||
| 99 | |||
| 100 | static struct langwell_otg_timer *a_wait_vrise_tmr, *a_aidl_bdis_tmr, | ||
| 101 | *b_se0_srp_tmr, *b_srp_init_tmr; | ||
| 102 | |||
| 103 | static struct list_head active_timers; | ||
| 104 | |||
| 105 | static struct langwell_otg *the_transceiver; | ||
| 106 | |||
| 107 | /* host/client notify transceiver when event affects HNP state */ | ||
| 108 | void langwell_update_transceiver(void) | ||
| 109 | { | ||
| 110 | struct langwell_otg *lnw = the_transceiver; | ||
| 111 | |||
| 112 | dev_dbg(lnw->dev, "transceiver is updated\n"); | ||
| 113 | |||
| 114 | if (!lnw->qwork) | ||
| 115 | return ; | ||
| 116 | |||
| 117 | queue_work(lnw->qwork, &lnw->work); | ||
| 118 | } | ||
| 119 | EXPORT_SYMBOL(langwell_update_transceiver); | ||
| 120 | |||
| 121 | static int langwell_otg_set_host(struct otg_transceiver *otg, | ||
| 122 | struct usb_bus *host) | ||
| 123 | { | ||
| 124 | otg->host = host; | ||
| 125 | |||
| 126 | return 0; | ||
| 127 | } | ||
| 128 | |||
| 129 | static int langwell_otg_set_peripheral(struct otg_transceiver *otg, | ||
| 130 | struct usb_gadget *gadget) | ||
| 131 | { | ||
| 132 | otg->gadget = gadget; | ||
| 133 | |||
| 134 | return 0; | ||
| 135 | } | ||
| 136 | |||
| 137 | static int langwell_otg_set_power(struct otg_transceiver *otg, | ||
| 138 | unsigned mA) | ||
| 139 | { | ||
| 140 | return 0; | ||
| 141 | } | ||
| 142 | |||
| 143 | /* A-device drives vbus, controlled through IPC commands */ | ||
| 144 | static int langwell_otg_set_vbus(struct otg_transceiver *otg, bool enabled) | ||
| 145 | { | ||
| 146 | struct langwell_otg *lnw = the_transceiver; | ||
| 147 | u8 sub_id; | ||
| 148 | |||
| 149 | dev_dbg(lnw->dev, "%s <--- %s\n", __func__, enabled ? "on" : "off"); | ||
| 150 | |||
| 151 | if (enabled) | ||
| 152 | sub_id = 0x8; /* Turn on the VBus */ | ||
| 153 | else | ||
| 154 | sub_id = 0x9; /* Turn off the VBus */ | ||
| 155 | |||
| 156 | if (intel_scu_ipc_simple_command(0xef, sub_id)) { | ||
| 157 | dev_dbg(lnw->dev, "Failed to set Vbus via IPC commands\n"); | ||
| 158 | return -EBUSY; | ||
| 159 | } | ||
| 160 | |||
| 161 | dev_dbg(lnw->dev, "%s --->\n", __func__); | ||
| 162 | |||
| 163 | return 0; | ||
| 164 | } | ||
| 165 | |||
| 166 | /* charge vbus or discharge vbus through a resistor to ground */ | ||
| 167 | static void langwell_otg_chrg_vbus(int on) | ||
| 168 | { | ||
| 169 | struct langwell_otg *lnw = the_transceiver; | ||
| 170 | u32 val; | ||
| 171 | |||
| 172 | val = readl(lnw->iotg.base + CI_OTGSC); | ||
| 173 | |||
| 174 | if (on) | ||
| 175 | writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_VC, | ||
| 176 | lnw->iotg.base + CI_OTGSC); | ||
| 177 | else | ||
| 178 | writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_VD, | ||
| 179 | lnw->iotg.base + CI_OTGSC); | ||
| 180 | } | ||
| 181 | |||
| 182 | /* Start SRP */ | ||
| 183 | static int langwell_otg_start_srp(struct otg_transceiver *otg) | ||
| 184 | { | ||
| 185 | struct langwell_otg *lnw = the_transceiver; | ||
| 186 | struct intel_mid_otg_xceiv *iotg = &lnw->iotg; | ||
| 187 | u32 val; | ||
| 188 | |||
| 189 | dev_dbg(lnw->dev, "%s --->\n", __func__); | ||
| 190 | |||
| 191 | val = readl(iotg->base + CI_OTGSC); | ||
| 192 | |||
| 193 | writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_HADP, | ||
| 194 | iotg->base + CI_OTGSC); | ||
| 195 | |||
| 196 | /* Check if the data plus is finished or not */ | ||
| 197 | msleep(8); | ||
| 198 | val = readl(iotg->base + CI_OTGSC); | ||
| 199 | if (val & (OTGSC_HADP | OTGSC_DP)) | ||
| 200 | dev_dbg(lnw->dev, "DataLine SRP Error\n"); | ||
| 201 | |||
| 202 | /* Disable interrupt - b_sess_vld */ | ||
| 203 | val = readl(iotg->base + CI_OTGSC); | ||
| 204 | val &= (~(OTGSC_BSVIE | OTGSC_BSEIE)); | ||
| 205 | writel(val, iotg->base + CI_OTGSC); | ||
| 206 | |||
| 207 | /* Start VBus SRP, drive vbus to generate VBus pulse */ | ||
| 208 | iotg->otg.set_vbus(&iotg->otg, true); | ||
| 209 | msleep(15); | ||
| 210 | iotg->otg.set_vbus(&iotg->otg, false); | ||
| 211 | |||
| 212 | /* Enable interrupt - b_sess_vld*/ | ||
| 213 | val = readl(iotg->base + CI_OTGSC); | ||
| 214 | dev_dbg(lnw->dev, "after VBUS pulse otgsc = %x\n", val); | ||
| 215 | |||
| 216 | val |= (OTGSC_BSVIE | OTGSC_BSEIE); | ||
| 217 | writel(val, iotg->base + CI_OTGSC); | ||
| 218 | |||
| 219 | /* If Vbus is valid, then update the hsm */ | ||
| 220 | if (val & OTGSC_BSV) { | ||
| 221 | dev_dbg(lnw->dev, "no b_sess_vld interrupt\n"); | ||
| 222 | |||
| 223 | lnw->iotg.hsm.b_sess_vld = 1; | ||
| 224 | langwell_update_transceiver(); | ||
| 225 | } | ||
| 226 | |||
| 227 | dev_dbg(lnw->dev, "%s <---\n", __func__); | ||
| 228 | return 0; | ||
| 229 | } | ||
| 230 | |||
| 231 | /* stop SOF via bus_suspend */ | ||
| 232 | static void langwell_otg_loc_sof(int on) | ||
| 233 | { | ||
| 234 | struct langwell_otg *lnw = the_transceiver; | ||
| 235 | struct usb_hcd *hcd; | ||
| 236 | int err; | ||
| 237 | |||
| 238 | dev_dbg(lnw->dev, "%s ---> %s\n", __func__, on ? "suspend" : "resume"); | ||
| 239 | |||
| 240 | hcd = bus_to_hcd(lnw->iotg.otg.host); | ||
| 241 | if (on) | ||
| 242 | err = hcd->driver->bus_resume(hcd); | ||
| 243 | else | ||
| 244 | err = hcd->driver->bus_suspend(hcd); | ||
| 245 | |||
| 246 | if (err) | ||
| 247 | dev_dbg(lnw->dev, "Fail to resume/suspend USB bus - %d\n", err); | ||
| 248 | |||
| 249 | dev_dbg(lnw->dev, "%s <---\n", __func__); | ||
| 250 | } | ||
| 251 | |||
| 252 | static int langwell_otg_check_otgsc(void) | ||
| 253 | { | ||
| 254 | struct langwell_otg *lnw = the_transceiver; | ||
| 255 | u32 otgsc, usbcfg; | ||
| 256 | |||
| 257 | dev_dbg(lnw->dev, "check sync OTGSC and USBCFG registers\n"); | ||
| 258 | |||
| 259 | otgsc = readl(lnw->iotg.base + CI_OTGSC); | ||
| 260 | usbcfg = readl(lnw->usbcfg); | ||
| 261 | |||
| 262 | dev_dbg(lnw->dev, "OTGSC = %08x, USBCFG = %08x\n", | ||
| 263 | otgsc, usbcfg); | ||
| 264 | dev_dbg(lnw->dev, "OTGSC_AVV = %d\n", !!(otgsc & OTGSC_AVV)); | ||
| 265 | dev_dbg(lnw->dev, "USBCFG.VBUSVAL = %d\n", | ||
| 266 | !!(usbcfg & USBCFG_VBUSVAL)); | ||
| 267 | dev_dbg(lnw->dev, "OTGSC_ASV = %d\n", !!(otgsc & OTGSC_ASV)); | ||
| 268 | dev_dbg(lnw->dev, "USBCFG.AVALID = %d\n", | ||
| 269 | !!(usbcfg & USBCFG_AVALID)); | ||
| 270 | dev_dbg(lnw->dev, "OTGSC_BSV = %d\n", !!(otgsc & OTGSC_BSV)); | ||
| 271 | dev_dbg(lnw->dev, "USBCFG.BVALID = %d\n", | ||
| 272 | !!(usbcfg & USBCFG_BVALID)); | ||
| 273 | dev_dbg(lnw->dev, "OTGSC_BSE = %d\n", !!(otgsc & OTGSC_BSE)); | ||
| 274 | dev_dbg(lnw->dev, "USBCFG.SESEND = %d\n", | ||
| 275 | !!(usbcfg & USBCFG_SESEND)); | ||
| 276 | |||
| 277 | /* Check USBCFG VBusValid/AValid/BValid/SessEnd */ | ||
| 278 | if (!!(otgsc & OTGSC_AVV) ^ !!(usbcfg & USBCFG_VBUSVAL)) { | ||
| 279 | dev_dbg(lnw->dev, "OTGSC.AVV != USBCFG.VBUSVAL\n"); | ||
| 280 | goto err; | ||
| 281 | } | ||
| 282 | if (!!(otgsc & OTGSC_ASV) ^ !!(usbcfg & USBCFG_AVALID)) { | ||
| 283 | dev_dbg(lnw->dev, "OTGSC.ASV != USBCFG.AVALID\n"); | ||
| 284 | goto err; | ||
| 285 | } | ||
| 286 | if (!!(otgsc & OTGSC_BSV) ^ !!(usbcfg & USBCFG_BVALID)) { | ||
| 287 | dev_dbg(lnw->dev, "OTGSC.BSV != USBCFG.BVALID\n"); | ||
| 288 | goto err; | ||
| 289 | } | ||
| 290 | if (!!(otgsc & OTGSC_BSE) ^ !!(usbcfg & USBCFG_SESEND)) { | ||
| 291 | dev_dbg(lnw->dev, "OTGSC.BSE != USBCFG.SESSEN\n"); | ||
| 292 | goto err; | ||
| 293 | } | ||
| 294 | |||
| 295 | dev_dbg(lnw->dev, "OTGSC and USBCFG are synced\n"); | ||
| 296 | |||
| 297 | return 0; | ||
| 298 | |||
| 299 | err: | ||
| 300 | dev_warn(lnw->dev, "OTGSC isn't equal to USBCFG\n"); | ||
| 301 | return -EPIPE; | ||
| 302 | } | ||
| 303 | |||
| 304 | |||
| 305 | static void langwell_otg_phy_low_power(int on) | ||
| 306 | { | ||
| 307 | struct langwell_otg *lnw = the_transceiver; | ||
| 308 | struct intel_mid_otg_xceiv *iotg = &lnw->iotg; | ||
| 309 | u8 val, phcd; | ||
| 310 | int retval; | ||
| 311 | |||
| 312 | dev_dbg(lnw->dev, "%s ---> %s mode\n", | ||
| 313 | __func__, on ? "Low power" : "Normal"); | ||
| 314 | |||
| 315 | phcd = 0x40; | ||
| 316 | |||
| 317 | val = readb(iotg->base + CI_HOSTPC1 + 2); | ||
| 318 | |||
| 319 | if (on) { | ||
| 320 | /* Due to hardware issue, after set PHCD, sync will failed | ||
| 321 | * between USBCFG and OTGSC, so before set PHCD, check if | ||
| 322 | * sync is in process now. If the answer is "yes", then do | ||
| 323 | * not touch PHCD bit */ | ||
| 324 | retval = langwell_otg_check_otgsc(); | ||
| 325 | if (retval) { | ||
| 326 | dev_dbg(lnw->dev, "Skip PHCD programming..\n"); | ||
| 327 | return ; | ||
| 328 | } | ||
| 329 | |||
| 330 | writeb(val | phcd, iotg->base + CI_HOSTPC1 + 2); | ||
| 331 | } else | ||
| 332 | writeb(val & ~phcd, iotg->base + CI_HOSTPC1 + 2); | ||
| 333 | |||
| 334 | dev_dbg(lnw->dev, "%s <--- done\n", __func__); | ||
| 335 | } | ||
| 336 | |||
| 337 | /* After drv vbus, add 5 ms delay to set PHCD */ | ||
| 338 | static void langwell_otg_phy_low_power_wait(int on) | ||
| 339 | { | ||
| 340 | struct langwell_otg *lnw = the_transceiver; | ||
| 341 | |||
| 342 | dev_dbg(lnw->dev, "add 5ms delay before programing PHCD\n"); | ||
| 343 | |||
| 344 | mdelay(5); | ||
| 345 | langwell_otg_phy_low_power(on); | ||
| 346 | } | ||
| 347 | |||
| 348 | /* Enable/Disable OTG interrupt */ | ||
| 349 | static void langwell_otg_intr(int on) | ||
| 350 | { | ||
| 351 | struct langwell_otg *lnw = the_transceiver; | ||
| 352 | struct intel_mid_otg_xceiv *iotg = &lnw->iotg; | ||
| 353 | u32 val; | ||
| 354 | |||
| 355 | dev_dbg(lnw->dev, "%s ---> %s\n", __func__, on ? "on" : "off"); | ||
| 356 | |||
| 357 | val = readl(iotg->base + CI_OTGSC); | ||
| 358 | |||
| 359 | /* OTGSC_INT_MASK doesn't contains 1msInt */ | ||
| 360 | if (on) { | ||
| 361 | val = val | (OTGSC_INT_MASK); | ||
| 362 | writel(val, iotg->base + CI_OTGSC); | ||
| 363 | } else { | ||
| 364 | val = val & ~(OTGSC_INT_MASK); | ||
| 365 | writel(val, iotg->base + CI_OTGSC); | ||
| 366 | } | ||
| 367 | |||
| 368 | dev_dbg(lnw->dev, "%s <---\n", __func__); | ||
| 369 | } | ||
| 370 | |||
| 371 | /* set HAAR: Hardware Assist Auto-Reset */ | ||
| 372 | static void langwell_otg_HAAR(int on) | ||
| 373 | { | ||
| 374 | struct langwell_otg *lnw = the_transceiver; | ||
| 375 | struct intel_mid_otg_xceiv *iotg = &lnw->iotg; | ||
| 376 | u32 val; | ||
| 377 | |||
| 378 | dev_dbg(lnw->dev, "%s ---> %s\n", __func__, on ? "on" : "off"); | ||
| 379 | |||
| 380 | val = readl(iotg->base + CI_OTGSC); | ||
| 381 | if (on) | ||
| 382 | writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_HAAR, | ||
| 383 | iotg->base + CI_OTGSC); | ||
| 384 | else | ||
| 385 | writel((val & ~OTGSC_INTSTS_MASK) & ~OTGSC_HAAR, | ||
| 386 | iotg->base + CI_OTGSC); | ||
| 387 | |||
| 388 | dev_dbg(lnw->dev, "%s <---\n", __func__); | ||
| 389 | } | ||
| 390 | |||
| 391 | /* set HABA: Hardware Assist B-Disconnect to A-Connect */ | ||
| 392 | static void langwell_otg_HABA(int on) | ||
| 393 | { | ||
| 394 | struct langwell_otg *lnw = the_transceiver; | ||
| 395 | struct intel_mid_otg_xceiv *iotg = &lnw->iotg; | ||
| 396 | u32 val; | ||
| 397 | |||
| 398 | dev_dbg(lnw->dev, "%s ---> %s\n", __func__, on ? "on" : "off"); | ||
| 399 | |||
| 400 | val = readl(iotg->base + CI_OTGSC); | ||
| 401 | if (on) | ||
| 402 | writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_HABA, | ||
| 403 | iotg->base + CI_OTGSC); | ||
| 404 | else | ||
| 405 | writel((val & ~OTGSC_INTSTS_MASK) & ~OTGSC_HABA, | ||
| 406 | iotg->base + CI_OTGSC); | ||
| 407 | |||
| 408 | dev_dbg(lnw->dev, "%s <---\n", __func__); | ||
| 409 | } | ||
| 410 | |||
| 411 | static int langwell_otg_check_se0_srp(int on) | ||
| 412 | { | ||
| 413 | struct langwell_otg *lnw = the_transceiver; | ||
| 414 | int delay_time = TB_SE0_SRP * 10; | ||
| 415 | u32 val; | ||
| 416 | |||
| 417 | dev_dbg(lnw->dev, "%s --->\n", __func__); | ||
| 418 | |||
| 419 | do { | ||
| 420 | udelay(100); | ||
| 421 | if (!delay_time--) | ||
| 422 | break; | ||
| 423 | val = readl(lnw->iotg.base + CI_PORTSC1); | ||
| 424 | val &= PORTSC_LS; | ||
| 425 | } while (!val); | ||
| 426 | |||
| 427 | dev_dbg(lnw->dev, "%s <---\n", __func__); | ||
| 428 | return val; | ||
| 429 | } | ||
| 430 | |||
| 431 | /* The timeout callback function to set time out bit */ | ||
| 432 | static void set_tmout(unsigned long indicator) | ||
| 433 | { | ||
| 434 | *(int *)indicator = 1; | ||
| 435 | } | ||
| 436 | |||
| 437 | void langwell_otg_nsf_msg(unsigned long indicator) | ||
| 438 | { | ||
| 439 | struct langwell_otg *lnw = the_transceiver; | ||
| 440 | |||
| 441 | switch (indicator) { | ||
| 442 | case 2: | ||
| 443 | case 4: | ||
| 444 | case 6: | ||
| 445 | case 7: | ||
| 446 | dev_warn(lnw->dev, | ||
| 447 | "OTG:NSF-%lu - deivce not responding\n", indicator); | ||
| 448 | break; | ||
| 449 | case 3: | ||
| 450 | dev_warn(lnw->dev, | ||
| 451 | "OTG:NSF-%lu - deivce not supported\n", indicator); | ||
| 452 | break; | ||
| 453 | default: | ||
| 454 | dev_warn(lnw->dev, "Do not have this kind of NSF\n"); | ||
| 455 | break; | ||
| 456 | } | ||
| 457 | } | ||
| 458 | |||
| 459 | /* Initialize timers */ | ||
| 460 | static int langwell_otg_init_timers(struct otg_hsm *hsm) | ||
| 461 | { | ||
| 462 | /* HSM used timers */ | ||
| 463 | a_wait_vrise_tmr = otg_timer_initializer(&set_tmout, TA_WAIT_VRISE, | ||
| 464 | (unsigned long)&hsm->a_wait_vrise_tmout); | ||
| 465 | if (a_wait_vrise_tmr == NULL) | ||
| 466 | return -ENOMEM; | ||
| 467 | a_aidl_bdis_tmr = otg_timer_initializer(&set_tmout, TA_AIDL_BDIS, | ||
| 468 | (unsigned long)&hsm->a_aidl_bdis_tmout); | ||
| 469 | if (a_aidl_bdis_tmr == NULL) | ||
| 470 | return -ENOMEM; | ||
| 471 | b_se0_srp_tmr = otg_timer_initializer(&set_tmout, TB_SE0_SRP, | ||
| 472 | (unsigned long)&hsm->b_se0_srp); | ||
| 473 | if (b_se0_srp_tmr == NULL) | ||
| 474 | return -ENOMEM; | ||
| 475 | b_srp_init_tmr = otg_timer_initializer(&set_tmout, TB_SRP_INIT, | ||
| 476 | (unsigned long)&hsm->b_srp_init_tmout); | ||
| 477 | if (b_srp_init_tmr == NULL) | ||
| 478 | return -ENOMEM; | ||
| 479 | |||
| 480 | return 0; | ||
| 481 | } | ||
| 482 | |||
| 483 | /* Free timers */ | ||
| 484 | static void langwell_otg_free_timers(void) | ||
| 485 | { | ||
| 486 | kfree(a_wait_vrise_tmr); | ||
| 487 | kfree(a_aidl_bdis_tmr); | ||
| 488 | kfree(b_se0_srp_tmr); | ||
| 489 | kfree(b_srp_init_tmr); | ||
| 490 | } | ||
| 491 | |||
| 492 | /* The timeout callback function to set time out bit */ | ||
| 493 | static void langwell_otg_timer_fn(unsigned long indicator) | ||
| 494 | { | ||
| 495 | struct langwell_otg *lnw = the_transceiver; | ||
| 496 | |||
| 497 | *(int *)indicator = 1; | ||
| 498 | |||
| 499 | dev_dbg(lnw->dev, "kernel timer - timeout\n"); | ||
| 500 | |||
| 501 | langwell_update_transceiver(); | ||
| 502 | } | ||
| 503 | |||
| 504 | /* kernel timer used instead of HW based interrupt */ | ||
| 505 | static void langwell_otg_add_ktimer(enum langwell_otg_timer_type timers) | ||
| 506 | { | ||
| 507 | struct langwell_otg *lnw = the_transceiver; | ||
| 508 | struct intel_mid_otg_xceiv *iotg = &lnw->iotg; | ||
| 509 | unsigned long j = jiffies; | ||
| 510 | unsigned long data, time; | ||
| 511 | |||
| 512 | switch (timers) { | ||
| 513 | case TA_WAIT_VRISE_TMR: | ||
| 514 | iotg->hsm.a_wait_vrise_tmout = 0; | ||
| 515 | data = (unsigned long)&iotg->hsm.a_wait_vrise_tmout; | ||
| 516 | time = TA_WAIT_VRISE; | ||
| 517 | break; | ||
| 518 | case TA_WAIT_BCON_TMR: | ||
| 519 | iotg->hsm.a_wait_bcon_tmout = 0; | ||
| 520 | data = (unsigned long)&iotg->hsm.a_wait_bcon_tmout; | ||
| 521 | time = TA_WAIT_BCON; | ||
| 522 | break; | ||
| 523 | case TA_AIDL_BDIS_TMR: | ||
| 524 | iotg->hsm.a_aidl_bdis_tmout = 0; | ||
| 525 | data = (unsigned long)&iotg->hsm.a_aidl_bdis_tmout; | ||
| 526 | time = TA_AIDL_BDIS; | ||
| 527 | break; | ||
| 528 | case TB_ASE0_BRST_TMR: | ||
| 529 | iotg->hsm.b_ase0_brst_tmout = 0; | ||
| 530 | data = (unsigned long)&iotg->hsm.b_ase0_brst_tmout; | ||
| 531 | time = TB_ASE0_BRST; | ||
| 532 | break; | ||
| 533 | case TB_SRP_INIT_TMR: | ||
| 534 | iotg->hsm.b_srp_init_tmout = 0; | ||
| 535 | data = (unsigned long)&iotg->hsm.b_srp_init_tmout; | ||
| 536 | time = TB_SRP_INIT; | ||
| 537 | break; | ||
| 538 | case TB_SRP_FAIL_TMR: | ||
| 539 | iotg->hsm.b_srp_fail_tmout = 0; | ||
| 540 | data = (unsigned long)&iotg->hsm.b_srp_fail_tmout; | ||
| 541 | time = TB_SRP_FAIL; | ||
| 542 | break; | ||
| 543 | case TB_BUS_SUSPEND_TMR: | ||
| 544 | iotg->hsm.b_bus_suspend_tmout = 0; | ||
| 545 | data = (unsigned long)&iotg->hsm.b_bus_suspend_tmout; | ||
| 546 | time = TB_BUS_SUSPEND; | ||
| 547 | break; | ||
| 548 | default: | ||
| 549 | dev_dbg(lnw->dev, "unknown timer, cannot enable it\n"); | ||
| 550 | return; | ||
| 551 | } | ||
| 552 | |||
| 553 | lnw->hsm_timer.data = data; | ||
| 554 | lnw->hsm_timer.function = langwell_otg_timer_fn; | ||
| 555 | lnw->hsm_timer.expires = j + time * HZ / 1000; /* milliseconds */ | ||
| 556 | |||
| 557 | add_timer(&lnw->hsm_timer); | ||
| 558 | |||
| 559 | dev_dbg(lnw->dev, "add timer successfully\n"); | ||
| 560 | } | ||
| 561 | |||
| 562 | /* Add timer to timer list */ | ||
| 563 | static void langwell_otg_add_timer(void *gtimer) | ||
| 564 | { | ||
| 565 | struct langwell_otg_timer *timer = (struct langwell_otg_timer *)gtimer; | ||
| 566 | struct langwell_otg_timer *tmp_timer; | ||
| 567 | struct intel_mid_otg_xceiv *iotg = &the_transceiver->iotg; | ||
| 568 | u32 val32; | ||
| 569 | |||
| 570 | /* Check if the timer is already in the active list, | ||
| 571 | * if so update timer count | ||
| 572 | */ | ||
| 573 | list_for_each_entry(tmp_timer, &active_timers, list) | ||
| 574 | if (tmp_timer == timer) { | ||
| 575 | timer->count = timer->expires; | ||
| 576 | return; | ||
| 577 | } | ||
| 578 | timer->count = timer->expires; | ||
| 579 | |||
| 580 | if (list_empty(&active_timers)) { | ||
| 581 | val32 = readl(iotg->base + CI_OTGSC); | ||
| 582 | writel(val32 | OTGSC_1MSE, iotg->base + CI_OTGSC); | ||
| 583 | } | ||
| 584 | |||
| 585 | list_add_tail(&timer->list, &active_timers); | ||
| 586 | } | ||
| 587 | |||
| 588 | /* Remove timer from the timer list; clear timeout status */ | ||
| 589 | static void langwell_otg_del_timer(void *gtimer) | ||
| 590 | { | ||
| 591 | struct langwell_otg *lnw = the_transceiver; | ||
| 592 | struct langwell_otg_timer *timer = (struct langwell_otg_timer *)gtimer; | ||
| 593 | struct langwell_otg_timer *tmp_timer, *del_tmp; | ||
| 594 | u32 val32; | ||
| 595 | |||
| 596 | list_for_each_entry_safe(tmp_timer, del_tmp, &active_timers, list) | ||
| 597 | if (tmp_timer == timer) | ||
| 598 | list_del(&timer->list); | ||
| 599 | |||
| 600 | if (list_empty(&active_timers)) { | ||
| 601 | val32 = readl(lnw->iotg.base + CI_OTGSC); | ||
| 602 | writel(val32 & ~OTGSC_1MSE, lnw->iotg.base + CI_OTGSC); | ||
| 603 | } | ||
| 604 | } | ||
| 605 | |||
| 606 | /* Reduce timer count by 1, and find timeout conditions.*/ | ||
| 607 | static int langwell_otg_tick_timer(u32 *int_sts) | ||
| 608 | { | ||
| 609 | struct langwell_otg *lnw = the_transceiver; | ||
| 610 | struct langwell_otg_timer *tmp_timer, *del_tmp; | ||
| 611 | int expired = 0; | ||
| 612 | |||
| 613 | list_for_each_entry_safe(tmp_timer, del_tmp, &active_timers, list) { | ||
| 614 | tmp_timer->count--; | ||
| 615 | /* check if timer expires */ | ||
| 616 | if (!tmp_timer->count) { | ||
| 617 | list_del(&tmp_timer->list); | ||
| 618 | tmp_timer->function(tmp_timer->data); | ||
| 619 | expired = 1; | ||
| 620 | } | ||
| 621 | } | ||
| 622 | |||
| 623 | if (list_empty(&active_timers)) { | ||
| 624 | dev_dbg(lnw->dev, "tick timer: disable 1ms int\n"); | ||
| 625 | *int_sts = *int_sts & ~OTGSC_1MSE; | ||
| 626 | } | ||
| 627 | return expired; | ||
| 628 | } | ||
| 629 | |||
| 630 | static void reset_otg(void) | ||
| 631 | { | ||
| 632 | struct langwell_otg *lnw = the_transceiver; | ||
| 633 | int delay_time = 1000; | ||
| 634 | u32 val; | ||
| 635 | |||
| 636 | dev_dbg(lnw->dev, "reseting OTG controller ...\n"); | ||
| 637 | val = readl(lnw->iotg.base + CI_USBCMD); | ||
| 638 | writel(val | USBCMD_RST, lnw->iotg.base + CI_USBCMD); | ||
| 639 | do { | ||
| 640 | udelay(100); | ||
| 641 | if (!delay_time--) | ||
| 642 | dev_dbg(lnw->dev, "reset timeout\n"); | ||
| 643 | val = readl(lnw->iotg.base + CI_USBCMD); | ||
| 644 | val &= USBCMD_RST; | ||
| 645 | } while (val != 0); | ||
| 646 | dev_dbg(lnw->dev, "reset done.\n"); | ||
| 647 | } | ||
| 648 | |||
| 649 | static void set_host_mode(void) | ||
| 650 | { | ||
| 651 | struct langwell_otg *lnw = the_transceiver; | ||
| 652 | u32 val; | ||
| 653 | |||
| 654 | reset_otg(); | ||
| 655 | val = readl(lnw->iotg.base + CI_USBMODE); | ||
| 656 | val = (val & (~USBMODE_CM)) | USBMODE_HOST; | ||
| 657 | writel(val, lnw->iotg.base + CI_USBMODE); | ||
| 658 | } | ||
| 659 | |||
| 660 | static void set_client_mode(void) | ||
| 661 | { | ||
| 662 | struct langwell_otg *lnw = the_transceiver; | ||
| 663 | u32 val; | ||
| 664 | |||
| 665 | reset_otg(); | ||
| 666 | val = readl(lnw->iotg.base + CI_USBMODE); | ||
| 667 | val = (val & (~USBMODE_CM)) | USBMODE_DEVICE; | ||
| 668 | writel(val, lnw->iotg.base + CI_USBMODE); | ||
| 669 | } | ||
| 670 | |||
| 671 | static void init_hsm(void) | ||
| 672 | { | ||
| 673 | struct langwell_otg *lnw = the_transceiver; | ||
| 674 | struct intel_mid_otg_xceiv *iotg = &lnw->iotg; | ||
| 675 | u32 val32; | ||
| 676 | |||
| 677 | /* read OTGSC after reset */ | ||
| 678 | val32 = readl(lnw->iotg.base + CI_OTGSC); | ||
| 679 | dev_dbg(lnw->dev, "%s: OTGSC init value = 0x%x\n", __func__, val32); | ||
| 680 | |||
| 681 | /* set init state */ | ||
| 682 | if (val32 & OTGSC_ID) { | ||
| 683 | iotg->hsm.id = 1; | ||
| 684 | iotg->otg.default_a = 0; | ||
| 685 | set_client_mode(); | ||
| 686 | iotg->otg.state = OTG_STATE_B_IDLE; | ||
| 687 | } else { | ||
| 688 | iotg->hsm.id = 0; | ||
| 689 | iotg->otg.default_a = 1; | ||
| 690 | set_host_mode(); | ||
| 691 | iotg->otg.state = OTG_STATE_A_IDLE; | ||
| 692 | } | ||
| 693 | |||
| 694 | /* set session indicator */ | ||
| 695 | if (val32 & OTGSC_BSE) | ||
| 696 | iotg->hsm.b_sess_end = 1; | ||
| 697 | if (val32 & OTGSC_BSV) | ||
| 698 | iotg->hsm.b_sess_vld = 1; | ||
| 699 | if (val32 & OTGSC_ASV) | ||
| 700 | iotg->hsm.a_sess_vld = 1; | ||
| 701 | if (val32 & OTGSC_AVV) | ||
| 702 | iotg->hsm.a_vbus_vld = 1; | ||
| 703 | |||
| 704 | /* defautly power the bus */ | ||
| 705 | iotg->hsm.a_bus_req = 1; | ||
| 706 | iotg->hsm.a_bus_drop = 0; | ||
| 707 | /* defautly don't request bus as B device */ | ||
| 708 | iotg->hsm.b_bus_req = 0; | ||
| 709 | /* no system error */ | ||
| 710 | iotg->hsm.a_clr_err = 0; | ||
| 711 | |||
| 712 | langwell_otg_phy_low_power_wait(1); | ||
| 713 | } | ||
| 714 | |||
| 715 | static void update_hsm(void) | ||
| 716 | { | ||
| 717 | struct langwell_otg *lnw = the_transceiver; | ||
| 718 | struct intel_mid_otg_xceiv *iotg = &lnw->iotg; | ||
| 719 | u32 val32; | ||
| 720 | |||
| 721 | /* read OTGSC */ | ||
| 722 | val32 = readl(lnw->iotg.base + CI_OTGSC); | ||
| 723 | dev_dbg(lnw->dev, "%s: OTGSC value = 0x%x\n", __func__, val32); | ||
| 724 | |||
| 725 | iotg->hsm.id = !!(val32 & OTGSC_ID); | ||
| 726 | iotg->hsm.b_sess_end = !!(val32 & OTGSC_BSE); | ||
| 727 | iotg->hsm.b_sess_vld = !!(val32 & OTGSC_BSV); | ||
| 728 | iotg->hsm.a_sess_vld = !!(val32 & OTGSC_ASV); | ||
| 729 | iotg->hsm.a_vbus_vld = !!(val32 & OTGSC_AVV); | ||
| 730 | } | ||
| 731 | |||
| 732 | static irqreturn_t otg_dummy_irq(int irq, void *_dev) | ||
| 733 | { | ||
| 734 | struct langwell_otg *lnw = the_transceiver; | ||
| 735 | void __iomem *reg_base = _dev; | ||
| 736 | u32 val; | ||
| 737 | u32 int_mask = 0; | ||
| 738 | |||
| 739 | val = readl(reg_base + CI_USBMODE); | ||
| 740 | if ((val & USBMODE_CM) != USBMODE_DEVICE) | ||
| 741 | return IRQ_NONE; | ||
| 742 | |||
| 743 | val = readl(reg_base + CI_USBSTS); | ||
| 744 | int_mask = val & INTR_DUMMY_MASK; | ||
| 745 | |||
| 746 | if (int_mask == 0) | ||
| 747 | return IRQ_NONE; | ||
| 748 | |||
| 749 | /* clear hsm.b_conn here since host driver can't detect it | ||
| 750 | * otg_dummy_irq called means B-disconnect happened. | ||
| 751 | */ | ||
| 752 | if (lnw->iotg.hsm.b_conn) { | ||
| 753 | lnw->iotg.hsm.b_conn = 0; | ||
| 754 | if (spin_trylock(&lnw->wq_lock)) { | ||
| 755 | langwell_update_transceiver(); | ||
| 756 | spin_unlock(&lnw->wq_lock); | ||
| 757 | } | ||
| 758 | } | ||
| 759 | |||
| 760 | /* Clear interrupts */ | ||
| 761 | writel(int_mask, reg_base + CI_USBSTS); | ||
| 762 | return IRQ_HANDLED; | ||
| 763 | } | ||
| 764 | |||
| 765 | static irqreturn_t otg_irq(int irq, void *_dev) | ||
| 766 | { | ||
| 767 | struct langwell_otg *lnw = _dev; | ||
| 768 | struct intel_mid_otg_xceiv *iotg = &lnw->iotg; | ||
| 769 | u32 int_sts, int_en; | ||
| 770 | u32 int_mask = 0; | ||
| 771 | int flag = 0; | ||
| 772 | |||
| 773 | int_sts = readl(lnw->iotg.base + CI_OTGSC); | ||
| 774 | int_en = (int_sts & OTGSC_INTEN_MASK) >> 8; | ||
| 775 | int_mask = int_sts & int_en; | ||
| 776 | if (int_mask == 0) | ||
| 777 | return IRQ_NONE; | ||
| 778 | |||
| 779 | if (int_mask & OTGSC_IDIS) { | ||
| 780 | dev_dbg(lnw->dev, "%s: id change int\n", __func__); | ||
| 781 | iotg->hsm.id = (int_sts & OTGSC_ID) ? 1 : 0; | ||
| 782 | dev_dbg(lnw->dev, "id = %d\n", iotg->hsm.id); | ||
| 783 | flag = 1; | ||
| 784 | } | ||
| 785 | if (int_mask & OTGSC_DPIS) { | ||
| 786 | dev_dbg(lnw->dev, "%s: data pulse int\n", __func__); | ||
| 787 | iotg->hsm.a_srp_det = (int_sts & OTGSC_DPS) ? 1 : 0; | ||
| 788 | dev_dbg(lnw->dev, "data pulse = %d\n", iotg->hsm.a_srp_det); | ||
| 789 | flag = 1; | ||
| 790 | } | ||
| 791 | if (int_mask & OTGSC_BSEIS) { | ||
| 792 | dev_dbg(lnw->dev, "%s: b session end int\n", __func__); | ||
| 793 | iotg->hsm.b_sess_end = (int_sts & OTGSC_BSE) ? 1 : 0; | ||
| 794 | dev_dbg(lnw->dev, "b_sess_end = %d\n", iotg->hsm.b_sess_end); | ||
| 795 | flag = 1; | ||
| 796 | } | ||
| 797 | if (int_mask & OTGSC_BSVIS) { | ||
| 798 | dev_dbg(lnw->dev, "%s: b session valid int\n", __func__); | ||
| 799 | iotg->hsm.b_sess_vld = (int_sts & OTGSC_BSV) ? 1 : 0; | ||
| 800 | dev_dbg(lnw->dev, "b_sess_vld = %d\n", iotg->hsm.b_sess_end); | ||
| 801 | flag = 1; | ||
| 802 | } | ||
| 803 | if (int_mask & OTGSC_ASVIS) { | ||
| 804 | dev_dbg(lnw->dev, "%s: a session valid int\n", __func__); | ||
| 805 | iotg->hsm.a_sess_vld = (int_sts & OTGSC_ASV) ? 1 : 0; | ||
| 806 | dev_dbg(lnw->dev, "a_sess_vld = %d\n", iotg->hsm.a_sess_vld); | ||
| 807 | flag = 1; | ||
| 808 | } | ||
| 809 | if (int_mask & OTGSC_AVVIS) { | ||
| 810 | dev_dbg(lnw->dev, "%s: a vbus valid int\n", __func__); | ||
| 811 | iotg->hsm.a_vbus_vld = (int_sts & OTGSC_AVV) ? 1 : 0; | ||
| 812 | dev_dbg(lnw->dev, "a_vbus_vld = %d\n", iotg->hsm.a_vbus_vld); | ||
| 813 | flag = 1; | ||
| 814 | } | ||
| 815 | |||
| 816 | if (int_mask & OTGSC_1MSS) { | ||
| 817 | /* need to schedule otg_work if any timer is expired */ | ||
| 818 | if (langwell_otg_tick_timer(&int_sts)) | ||
| 819 | flag = 1; | ||
| 820 | } | ||
| 821 | |||
| 822 | writel((int_sts & ~OTGSC_INTSTS_MASK) | int_mask, | ||
| 823 | lnw->iotg.base + CI_OTGSC); | ||
| 824 | if (flag) | ||
| 825 | langwell_update_transceiver(); | ||
| 826 | |||
| 827 | return IRQ_HANDLED; | ||
| 828 | } | ||
| 829 | |||
| 830 | static int langwell_otg_iotg_notify(struct notifier_block *nb, | ||
| 831 | unsigned long action, void *data) | ||
| 832 | { | ||
| 833 | struct langwell_otg *lnw = the_transceiver; | ||
| 834 | struct intel_mid_otg_xceiv *iotg = data; | ||
| 835 | int flag = 0; | ||
| 836 | |||
| 837 | if (iotg == NULL) | ||
| 838 | return NOTIFY_BAD; | ||
| 839 | |||
| 840 | if (lnw == NULL) | ||
| 841 | return NOTIFY_BAD; | ||
| 842 | |||
| 843 | switch (action) { | ||
| 844 | case MID_OTG_NOTIFY_CONNECT: | ||
| 845 | dev_dbg(lnw->dev, "Lnw OTG Notify Connect Event\n"); | ||
| 846 | if (iotg->otg.default_a == 1) | ||
| 847 | iotg->hsm.b_conn = 1; | ||
| 848 | else | ||
| 849 | iotg->hsm.a_conn = 1; | ||
| 850 | flag = 1; | ||
| 851 | break; | ||
| 852 | case MID_OTG_NOTIFY_DISCONN: | ||
| 853 | dev_dbg(lnw->dev, "Lnw OTG Notify Disconnect Event\n"); | ||
| 854 | if (iotg->otg.default_a == 1) | ||
| 855 | iotg->hsm.b_conn = 0; | ||
| 856 | else | ||
| 857 | iotg->hsm.a_conn = 0; | ||
| 858 | flag = 1; | ||
| 859 | break; | ||
| 860 | case MID_OTG_NOTIFY_HSUSPEND: | ||
| 861 | dev_dbg(lnw->dev, "Lnw OTG Notify Host Bus suspend Event\n"); | ||
| 862 | if (iotg->otg.default_a == 1) | ||
| 863 | iotg->hsm.a_suspend_req = 1; | ||
| 864 | else | ||
| 865 | iotg->hsm.b_bus_req = 0; | ||
| 866 | flag = 1; | ||
| 867 | break; | ||
| 868 | case MID_OTG_NOTIFY_HRESUME: | ||
| 869 | dev_dbg(lnw->dev, "Lnw OTG Notify Host Bus resume Event\n"); | ||
| 870 | if (iotg->otg.default_a == 1) | ||
| 871 | iotg->hsm.b_bus_resume = 1; | ||
| 872 | flag = 1; | ||
| 873 | break; | ||
| 874 | case MID_OTG_NOTIFY_CSUSPEND: | ||
| 875 | dev_dbg(lnw->dev, "Lnw OTG Notify Client Bus suspend Event\n"); | ||
| 876 | if (iotg->otg.default_a == 1) { | ||
| 877 | if (iotg->hsm.b_bus_suspend_vld == 2) { | ||
| 878 | iotg->hsm.b_bus_suspend = 1; | ||
| 879 | iotg->hsm.b_bus_suspend_vld = 0; | ||
| 880 | flag = 1; | ||
| 881 | } else { | ||
| 882 | iotg->hsm.b_bus_suspend_vld++; | ||
| 883 | flag = 0; | ||
| 884 | } | ||
| 885 | } else { | ||
| 886 | if (iotg->hsm.a_bus_suspend == 0) { | ||
| 887 | iotg->hsm.a_bus_suspend = 1; | ||
| 888 | flag = 1; | ||
| 889 | } | ||
| 890 | } | ||
| 891 | break; | ||
| 892 | case MID_OTG_NOTIFY_CRESUME: | ||
| 893 | dev_dbg(lnw->dev, "Lnw OTG Notify Client Bus resume Event\n"); | ||
| 894 | if (iotg->otg.default_a == 0) | ||
| 895 | iotg->hsm.a_bus_suspend = 0; | ||
| 896 | flag = 0; | ||
| 897 | break; | ||
| 898 | case MID_OTG_NOTIFY_HOSTADD: | ||
| 899 | dev_dbg(lnw->dev, "Lnw OTG Nofity Host Driver Add\n"); | ||
| 900 | flag = 1; | ||
| 901 | break; | ||
| 902 | case MID_OTG_NOTIFY_HOSTREMOVE: | ||
| 903 | dev_dbg(lnw->dev, "Lnw OTG Nofity Host Driver remove\n"); | ||
| 904 | flag = 1; | ||
| 905 | break; | ||
| 906 | case MID_OTG_NOTIFY_CLIENTADD: | ||
| 907 | dev_dbg(lnw->dev, "Lnw OTG Nofity Client Driver Add\n"); | ||
| 908 | flag = 1; | ||
| 909 | break; | ||
| 910 | case MID_OTG_NOTIFY_CLIENTREMOVE: | ||
| 911 | dev_dbg(lnw->dev, "Lnw OTG Nofity Client Driver remove\n"); | ||
| 912 | flag = 1; | ||
| 913 | break; | ||
| 914 | default: | ||
| 915 | dev_dbg(lnw->dev, "Lnw OTG Nofity unknown notify message\n"); | ||
| 916 | return NOTIFY_DONE; | ||
| 917 | } | ||
| 918 | |||
| 919 | if (flag) | ||
| 920 | langwell_update_transceiver(); | ||
| 921 | |||
| 922 | return NOTIFY_OK; | ||
| 923 | } | ||
| 924 | |||
| 925 | static void langwell_otg_work(struct work_struct *work) | ||
| 926 | { | ||
| 927 | struct langwell_otg *lnw; | ||
| 928 | struct intel_mid_otg_xceiv *iotg; | ||
| 929 | int retval; | ||
| 930 | struct pci_dev *pdev; | ||
| 931 | |||
| 932 | lnw = container_of(work, struct langwell_otg, work); | ||
| 933 | iotg = &lnw->iotg; | ||
| 934 | pdev = to_pci_dev(lnw->dev); | ||
| 935 | |||
| 936 | dev_dbg(lnw->dev, "%s: old state = %s\n", __func__, | ||
| 937 | otg_state_string(iotg->otg.state)); | ||
| 938 | |||
| 939 | switch (iotg->otg.state) { | ||
| 940 | case OTG_STATE_UNDEFINED: | ||
| 941 | case OTG_STATE_B_IDLE: | ||
| 942 | if (!iotg->hsm.id) { | ||
| 943 | langwell_otg_del_timer(b_srp_init_tmr); | ||
| 944 | del_timer_sync(&lnw->hsm_timer); | ||
| 945 | |||
| 946 | iotg->otg.default_a = 1; | ||
| 947 | iotg->hsm.a_srp_det = 0; | ||
| 948 | |||
| 949 | langwell_otg_chrg_vbus(0); | ||
| 950 | set_host_mode(); | ||
| 951 | langwell_otg_phy_low_power(1); | ||
| 952 | |||
| 953 | iotg->otg.state = OTG_STATE_A_IDLE; | ||
| 954 | langwell_update_transceiver(); | ||
| 955 | } else if (iotg->hsm.b_sess_vld) { | ||
| 956 | langwell_otg_del_timer(b_srp_init_tmr); | ||
| 957 | del_timer_sync(&lnw->hsm_timer); | ||
| 958 | iotg->hsm.b_sess_end = 0; | ||
| 959 | iotg->hsm.a_bus_suspend = 0; | ||
| 960 | langwell_otg_chrg_vbus(0); | ||
| 961 | |||
| 962 | if (lnw->iotg.start_peripheral) { | ||
| 963 | lnw->iotg.start_peripheral(&lnw->iotg); | ||
| 964 | iotg->otg.state = OTG_STATE_B_PERIPHERAL; | ||
| 965 | } else | ||
| 966 | dev_dbg(lnw->dev, "client driver not loaded\n"); | ||
| 967 | |||
| 968 | } else if (iotg->hsm.b_srp_init_tmout) { | ||
| 969 | iotg->hsm.b_srp_init_tmout = 0; | ||
| 970 | dev_warn(lnw->dev, "SRP init timeout\n"); | ||
| 971 | } else if (iotg->hsm.b_srp_fail_tmout) { | ||
| 972 | iotg->hsm.b_srp_fail_tmout = 0; | ||
| 973 | iotg->hsm.b_bus_req = 0; | ||
| 974 | |||
| 975 | /* No silence failure */ | ||
| 976 | langwell_otg_nsf_msg(6); | ||
| 977 | } else if (iotg->hsm.b_bus_req && iotg->hsm.b_sess_end) { | ||
| 978 | del_timer_sync(&lnw->hsm_timer); | ||
| 979 | /* workaround for b_se0_srp detection */ | ||
| 980 | retval = langwell_otg_check_se0_srp(0); | ||
| 981 | if (retval) { | ||
| 982 | iotg->hsm.b_bus_req = 0; | ||
| 983 | dev_dbg(lnw->dev, "LS isn't SE0, try later\n"); | ||
| 984 | } else { | ||
| 985 | /* clear the PHCD before start srp */ | ||
| 986 | langwell_otg_phy_low_power(0); | ||
| 987 | |||
| 988 | /* Start SRP */ | ||
| 989 | langwell_otg_add_timer(b_srp_init_tmr); | ||
| 990 | iotg->otg.start_srp(&iotg->otg); | ||
| 991 | langwell_otg_del_timer(b_srp_init_tmr); | ||
| 992 | langwell_otg_add_ktimer(TB_SRP_FAIL_TMR); | ||
| 993 | |||
| 994 | /* reset PHY low power mode here */ | ||
| 995 | langwell_otg_phy_low_power_wait(1); | ||
| 996 | } | ||
| 997 | } | ||
| 998 | break; | ||
| 999 | case OTG_STATE_B_SRP_INIT: | ||
| 1000 | if (!iotg->hsm.id) { | ||
| 1001 | iotg->otg.default_a = 1; | ||
| 1002 | iotg->hsm.a_srp_det = 0; | ||
| 1003 | |||
| 1004 | /* Turn off VBus */ | ||
| 1005 | iotg->otg.set_vbus(&iotg->otg, false); | ||
| 1006 | langwell_otg_chrg_vbus(0); | ||
| 1007 | set_host_mode(); | ||
| 1008 | langwell_otg_phy_low_power(1); | ||
| 1009 | iotg->otg.state = OTG_STATE_A_IDLE; | ||
| 1010 | langwell_update_transceiver(); | ||
| 1011 | } else if (iotg->hsm.b_sess_vld) { | ||
| 1012 | langwell_otg_chrg_vbus(0); | ||
| 1013 | if (lnw->iotg.start_peripheral) { | ||
| 1014 | lnw->iotg.start_peripheral(&lnw->iotg); | ||
| 1015 | iotg->otg.state = OTG_STATE_B_PERIPHERAL; | ||
| 1016 | } else | ||
| 1017 | dev_dbg(lnw->dev, "client driver not loaded\n"); | ||
| 1018 | } | ||
| 1019 | break; | ||
| 1020 | case OTG_STATE_B_PERIPHERAL: | ||
| 1021 | if (!iotg->hsm.id) { | ||
| 1022 | iotg->otg.default_a = 1; | ||
| 1023 | iotg->hsm.a_srp_det = 0; | ||
| 1024 | |||
| 1025 | langwell_otg_chrg_vbus(0); | ||
| 1026 | |||
| 1027 | if (lnw->iotg.stop_peripheral) | ||
| 1028 | lnw->iotg.stop_peripheral(&lnw->iotg); | ||
| 1029 | else | ||
| 1030 | dev_dbg(lnw->dev, | ||
| 1031 | "client driver has been removed.\n"); | ||
| 1032 | |||
| 1033 | set_host_mode(); | ||
| 1034 | langwell_otg_phy_low_power(1); | ||
| 1035 | iotg->otg.state = OTG_STATE_A_IDLE; | ||
| 1036 | langwell_update_transceiver(); | ||
| 1037 | } else if (!iotg->hsm.b_sess_vld) { | ||
| 1038 | iotg->hsm.b_hnp_enable = 0; | ||
| 1039 | |||
| 1040 | if (lnw->iotg.stop_peripheral) | ||
| 1041 | lnw->iotg.stop_peripheral(&lnw->iotg); | ||
| 1042 | else | ||
| 1043 | dev_dbg(lnw->dev, | ||
| 1044 | "client driver has been removed.\n"); | ||
| 1045 | |||
| 1046 | iotg->otg.state = OTG_STATE_B_IDLE; | ||
| 1047 | } else if (iotg->hsm.b_bus_req && iotg->otg.gadget && | ||
| 1048 | iotg->otg.gadget->b_hnp_enable && | ||
| 1049 | iotg->hsm.a_bus_suspend) { | ||
| 1050 | |||
| 1051 | if (lnw->iotg.stop_peripheral) | ||
| 1052 | lnw->iotg.stop_peripheral(&lnw->iotg); | ||
| 1053 | else | ||
| 1054 | dev_dbg(lnw->dev, | ||
| 1055 | "client driver has been removed.\n"); | ||
| 1056 | |||
| 1057 | langwell_otg_HAAR(1); | ||
| 1058 | iotg->hsm.a_conn = 0; | ||
| 1059 | |||
| 1060 | if (lnw->iotg.start_host) { | ||
| 1061 | lnw->iotg.start_host(&lnw->iotg); | ||
| 1062 | iotg->otg.state = OTG_STATE_B_WAIT_ACON; | ||
| 1063 | } else | ||
| 1064 | dev_dbg(lnw->dev, | ||
| 1065 | "host driver not loaded.\n"); | ||
| 1066 | |||
| 1067 | iotg->hsm.a_bus_resume = 0; | ||
| 1068 | langwell_otg_add_ktimer(TB_ASE0_BRST_TMR); | ||
| 1069 | } | ||
| 1070 | break; | ||
| 1071 | |||
| 1072 | case OTG_STATE_B_WAIT_ACON: | ||
| 1073 | if (!iotg->hsm.id) { | ||
| 1074 | /* delete hsm timer for b_ase0_brst_tmr */ | ||
| 1075 | del_timer_sync(&lnw->hsm_timer); | ||
| 1076 | |||
| 1077 | iotg->otg.default_a = 1; | ||
| 1078 | iotg->hsm.a_srp_det = 0; | ||
| 1079 | |||
| 1080 | langwell_otg_chrg_vbus(0); | ||
| 1081 | |||
| 1082 | langwell_otg_HAAR(0); | ||
| 1083 | if (lnw->iotg.stop_host) | ||
| 1084 | lnw->iotg.stop_host(&lnw->iotg); | ||
| 1085 | else | ||
| 1086 | dev_dbg(lnw->dev, | ||
| 1087 | "host driver has been removed.\n"); | ||
| 1088 | |||
| 1089 | set_host_mode(); | ||
| 1090 | langwell_otg_phy_low_power(1); | ||
| 1091 | iotg->otg.state = OTG_STATE_A_IDLE; | ||
| 1092 | langwell_update_transceiver(); | ||
| 1093 | } else if (!iotg->hsm.b_sess_vld) { | ||
| 1094 | /* delete hsm timer for b_ase0_brst_tmr */ | ||
| 1095 | del_timer_sync(&lnw->hsm_timer); | ||
| 1096 | |||
| 1097 | iotg->hsm.b_hnp_enable = 0; | ||
| 1098 | iotg->hsm.b_bus_req = 0; | ||
| 1099 | |||
| 1100 | langwell_otg_chrg_vbus(0); | ||
| 1101 | langwell_otg_HAAR(0); | ||
| 1102 | |||
| 1103 | if (lnw->iotg.stop_host) | ||
| 1104 | lnw->iotg.stop_host(&lnw->iotg); | ||
| 1105 | else | ||
| 1106 | dev_dbg(lnw->dev, | ||
| 1107 | "host driver has been removed.\n"); | ||
| 1108 | |||
| 1109 | set_client_mode(); | ||
| 1110 | langwell_otg_phy_low_power(1); | ||
| 1111 | iotg->otg.state = OTG_STATE_B_IDLE; | ||
| 1112 | } else if (iotg->hsm.a_conn) { | ||
| 1113 | /* delete hsm timer for b_ase0_brst_tmr */ | ||
| 1114 | del_timer_sync(&lnw->hsm_timer); | ||
| 1115 | |||
| 1116 | langwell_otg_HAAR(0); | ||
| 1117 | iotg->otg.state = OTG_STATE_B_HOST; | ||
| 1118 | langwell_update_transceiver(); | ||
| 1119 | } else if (iotg->hsm.a_bus_resume || | ||
| 1120 | iotg->hsm.b_ase0_brst_tmout) { | ||
| 1121 | /* delete hsm timer for b_ase0_brst_tmr */ | ||
| 1122 | del_timer_sync(&lnw->hsm_timer); | ||
| 1123 | |||
| 1124 | langwell_otg_HAAR(0); | ||
| 1125 | langwell_otg_nsf_msg(7); | ||
| 1126 | |||
| 1127 | if (lnw->iotg.stop_host) | ||
| 1128 | lnw->iotg.stop_host(&lnw->iotg); | ||
| 1129 | else | ||
| 1130 | dev_dbg(lnw->dev, | ||
| 1131 | "host driver has been removed.\n"); | ||
| 1132 | |||
| 1133 | iotg->hsm.a_bus_suspend = 0; | ||
| 1134 | iotg->hsm.b_bus_req = 0; | ||
| 1135 | |||
| 1136 | if (lnw->iotg.start_peripheral) | ||
| 1137 | lnw->iotg.start_peripheral(&lnw->iotg); | ||
| 1138 | else | ||
| 1139 | dev_dbg(lnw->dev, | ||
| 1140 | "client driver not loaded.\n"); | ||
| 1141 | |||
| 1142 | iotg->otg.state = OTG_STATE_B_PERIPHERAL; | ||
| 1143 | } | ||
| 1144 | break; | ||
| 1145 | |||
| 1146 | case OTG_STATE_B_HOST: | ||
| 1147 | if (!iotg->hsm.id) { | ||
| 1148 | iotg->otg.default_a = 1; | ||
| 1149 | iotg->hsm.a_srp_det = 0; | ||
| 1150 | |||
| 1151 | langwell_otg_chrg_vbus(0); | ||
| 1152 | |||
| 1153 | if (lnw->iotg.stop_host) | ||
| 1154 | lnw->iotg.stop_host(&lnw->iotg); | ||
| 1155 | else | ||
| 1156 | dev_dbg(lnw->dev, | ||
| 1157 | "host driver has been removed.\n"); | ||
| 1158 | |||
| 1159 | set_host_mode(); | ||
| 1160 | langwell_otg_phy_low_power(1); | ||
| 1161 | iotg->otg.state = OTG_STATE_A_IDLE; | ||
| 1162 | langwell_update_transceiver(); | ||
| 1163 | } else if (!iotg->hsm.b_sess_vld) { | ||
| 1164 | iotg->hsm.b_hnp_enable = 0; | ||
| 1165 | iotg->hsm.b_bus_req = 0; | ||
| 1166 | |||
| 1167 | langwell_otg_chrg_vbus(0); | ||
| 1168 | if (lnw->iotg.stop_host) | ||
| 1169 | lnw->iotg.stop_host(&lnw->iotg); | ||
| 1170 | else | ||
| 1171 | dev_dbg(lnw->dev, | ||
| 1172 | "host driver has been removed.\n"); | ||
| 1173 | |||
| 1174 | set_client_mode(); | ||
| 1175 | langwell_otg_phy_low_power(1); | ||
| 1176 | iotg->otg.state = OTG_STATE_B_IDLE; | ||
| 1177 | } else if ((!iotg->hsm.b_bus_req) || | ||
| 1178 | (!iotg->hsm.a_conn)) { | ||
| 1179 | iotg->hsm.b_bus_req = 0; | ||
| 1180 | langwell_otg_loc_sof(0); | ||
| 1181 | |||
| 1182 | if (lnw->iotg.stop_host) | ||
| 1183 | lnw->iotg.stop_host(&lnw->iotg); | ||
| 1184 | else | ||
| 1185 | dev_dbg(lnw->dev, | ||
| 1186 | "host driver has been removed.\n"); | ||
| 1187 | |||
| 1188 | iotg->hsm.a_bus_suspend = 0; | ||
| 1189 | |||
| 1190 | if (lnw->iotg.start_peripheral) | ||
| 1191 | lnw->iotg.start_peripheral(&lnw->iotg); | ||
| 1192 | else | ||
| 1193 | dev_dbg(lnw->dev, | ||
| 1194 | "client driver not loaded.\n"); | ||
| 1195 | |||
| 1196 | iotg->otg.state = OTG_STATE_B_PERIPHERAL; | ||
| 1197 | } | ||
| 1198 | break; | ||
| 1199 | |||
| 1200 | case OTG_STATE_A_IDLE: | ||
| 1201 | iotg->otg.default_a = 1; | ||
| 1202 | if (iotg->hsm.id) { | ||
| 1203 | iotg->otg.default_a = 0; | ||
| 1204 | iotg->hsm.b_bus_req = 0; | ||
| 1205 | iotg->hsm.vbus_srp_up = 0; | ||
| 1206 | |||
| 1207 | langwell_otg_chrg_vbus(0); | ||
| 1208 | set_client_mode(); | ||
| 1209 | langwell_otg_phy_low_power(1); | ||
| 1210 | iotg->otg.state = OTG_STATE_B_IDLE; | ||
| 1211 | langwell_update_transceiver(); | ||
| 1212 | } else if (!iotg->hsm.a_bus_drop && | ||
| 1213 | (iotg->hsm.a_srp_det || iotg->hsm.a_bus_req)) { | ||
| 1214 | langwell_otg_phy_low_power(0); | ||
| 1215 | |||
| 1216 | /* Turn on VBus */ | ||
| 1217 | iotg->otg.set_vbus(&iotg->otg, true); | ||
| 1218 | |||
| 1219 | iotg->hsm.vbus_srp_up = 0; | ||
| 1220 | iotg->hsm.a_wait_vrise_tmout = 0; | ||
| 1221 | langwell_otg_add_timer(a_wait_vrise_tmr); | ||
| 1222 | iotg->otg.state = OTG_STATE_A_WAIT_VRISE; | ||
| 1223 | langwell_update_transceiver(); | ||
| 1224 | } else if (!iotg->hsm.a_bus_drop && iotg->hsm.a_sess_vld) { | ||
| 1225 | iotg->hsm.vbus_srp_up = 1; | ||
| 1226 | } else if (!iotg->hsm.a_sess_vld && iotg->hsm.vbus_srp_up) { | ||
| 1227 | msleep(10); | ||
| 1228 | langwell_otg_phy_low_power(0); | ||
| 1229 | |||
| 1230 | /* Turn on VBus */ | ||
| 1231 | iotg->otg.set_vbus(&iotg->otg, true); | ||
| 1232 | iotg->hsm.a_srp_det = 1; | ||
| 1233 | iotg->hsm.vbus_srp_up = 0; | ||
| 1234 | iotg->hsm.a_wait_vrise_tmout = 0; | ||
| 1235 | langwell_otg_add_timer(a_wait_vrise_tmr); | ||
| 1236 | iotg->otg.state = OTG_STATE_A_WAIT_VRISE; | ||
| 1237 | langwell_update_transceiver(); | ||
| 1238 | } else if (!iotg->hsm.a_sess_vld && | ||
| 1239 | !iotg->hsm.vbus_srp_up) { | ||
| 1240 | langwell_otg_phy_low_power(1); | ||
| 1241 | } | ||
| 1242 | break; | ||
| 1243 | case OTG_STATE_A_WAIT_VRISE: | ||
| 1244 | if (iotg->hsm.id) { | ||
| 1245 | langwell_otg_del_timer(a_wait_vrise_tmr); | ||
| 1246 | iotg->hsm.b_bus_req = 0; | ||
| 1247 | iotg->otg.default_a = 0; | ||
| 1248 | |||
| 1249 | /* Turn off VBus */ | ||
| 1250 | iotg->otg.set_vbus(&iotg->otg, false); | ||
| 1251 | set_client_mode(); | ||
| 1252 | langwell_otg_phy_low_power_wait(1); | ||
| 1253 | iotg->otg.state = OTG_STATE_B_IDLE; | ||
| 1254 | } else if (iotg->hsm.a_vbus_vld) { | ||
| 1255 | langwell_otg_del_timer(a_wait_vrise_tmr); | ||
| 1256 | iotg->hsm.b_conn = 0; | ||
| 1257 | if (lnw->iotg.start_host) | ||
| 1258 | lnw->iotg.start_host(&lnw->iotg); | ||
| 1259 | else { | ||
| 1260 | dev_dbg(lnw->dev, "host driver not loaded.\n"); | ||
| 1261 | break; | ||
| 1262 | } | ||
| 1263 | |||
| 1264 | langwell_otg_add_ktimer(TA_WAIT_BCON_TMR); | ||
| 1265 | iotg->otg.state = OTG_STATE_A_WAIT_BCON; | ||
| 1266 | } else if (iotg->hsm.a_wait_vrise_tmout) { | ||
| 1267 | iotg->hsm.b_conn = 0; | ||
| 1268 | if (iotg->hsm.a_vbus_vld) { | ||
| 1269 | if (lnw->iotg.start_host) | ||
| 1270 | lnw->iotg.start_host(&lnw->iotg); | ||
| 1271 | else { | ||
| 1272 | dev_dbg(lnw->dev, | ||
| 1273 | "host driver not loaded.\n"); | ||
| 1274 | break; | ||
| 1275 | } | ||
| 1276 | langwell_otg_add_ktimer(TA_WAIT_BCON_TMR); | ||
| 1277 | iotg->otg.state = OTG_STATE_A_WAIT_BCON; | ||
| 1278 | } else { | ||
| 1279 | |||
| 1280 | /* Turn off VBus */ | ||
| 1281 | iotg->otg.set_vbus(&iotg->otg, false); | ||
| 1282 | langwell_otg_phy_low_power_wait(1); | ||
| 1283 | iotg->otg.state = OTG_STATE_A_VBUS_ERR; | ||
| 1284 | } | ||
| 1285 | } | ||
| 1286 | break; | ||
| 1287 | case OTG_STATE_A_WAIT_BCON: | ||
| 1288 | if (iotg->hsm.id) { | ||
| 1289 | /* delete hsm timer for a_wait_bcon_tmr */ | ||
| 1290 | del_timer_sync(&lnw->hsm_timer); | ||
| 1291 | |||
| 1292 | iotg->otg.default_a = 0; | ||
| 1293 | iotg->hsm.b_bus_req = 0; | ||
| 1294 | |||
| 1295 | if (lnw->iotg.stop_host) | ||
| 1296 | lnw->iotg.stop_host(&lnw->iotg); | ||
| 1297 | else | ||
| 1298 | dev_dbg(lnw->dev, | ||
| 1299 | "host driver has been removed.\n"); | ||
| 1300 | |||
| 1301 | /* Turn off VBus */ | ||
| 1302 | iotg->otg.set_vbus(&iotg->otg, false); | ||
| 1303 | set_client_mode(); | ||
| 1304 | langwell_otg_phy_low_power_wait(1); | ||
| 1305 | iotg->otg.state = OTG_STATE_B_IDLE; | ||
| 1306 | langwell_update_transceiver(); | ||
| 1307 | } else if (!iotg->hsm.a_vbus_vld) { | ||
| 1308 | /* delete hsm timer for a_wait_bcon_tmr */ | ||
| 1309 | del_timer_sync(&lnw->hsm_timer); | ||
| 1310 | |||
| 1311 | if (lnw->iotg.stop_host) | ||
| 1312 | lnw->iotg.stop_host(&lnw->iotg); | ||
| 1313 | else | ||
| 1314 | dev_dbg(lnw->dev, | ||
| 1315 | "host driver has been removed.\n"); | ||
| 1316 | |||
| 1317 | /* Turn off VBus */ | ||
| 1318 | iotg->otg.set_vbus(&iotg->otg, false); | ||
| 1319 | langwell_otg_phy_low_power_wait(1); | ||
| 1320 | iotg->otg.state = OTG_STATE_A_VBUS_ERR; | ||
| 1321 | } else if (iotg->hsm.a_bus_drop || | ||
| 1322 | (iotg->hsm.a_wait_bcon_tmout && | ||
| 1323 | !iotg->hsm.a_bus_req)) { | ||
| 1324 | /* delete hsm timer for a_wait_bcon_tmr */ | ||
| 1325 | del_timer_sync(&lnw->hsm_timer); | ||
| 1326 | |||
| 1327 | if (lnw->iotg.stop_host) | ||
| 1328 | lnw->iotg.stop_host(&lnw->iotg); | ||
| 1329 | else | ||
| 1330 | dev_dbg(lnw->dev, | ||
| 1331 | "host driver has been removed.\n"); | ||
| 1332 | |||
| 1333 | /* Turn off VBus */ | ||
| 1334 | iotg->otg.set_vbus(&iotg->otg, false); | ||
| 1335 | iotg->otg.state = OTG_STATE_A_WAIT_VFALL; | ||
| 1336 | } else if (iotg->hsm.b_conn) { | ||
| 1337 | /* delete hsm timer for a_wait_bcon_tmr */ | ||
| 1338 | del_timer_sync(&lnw->hsm_timer); | ||
| 1339 | |||
| 1340 | iotg->hsm.a_suspend_req = 0; | ||
| 1341 | iotg->otg.state = OTG_STATE_A_HOST; | ||
| 1342 | if (iotg->hsm.a_srp_det && iotg->otg.host && | ||
| 1343 | !iotg->otg.host->b_hnp_enable) { | ||
| 1344 | /* SRP capable peripheral-only device */ | ||
| 1345 | iotg->hsm.a_bus_req = 1; | ||
| 1346 | iotg->hsm.a_srp_det = 0; | ||
| 1347 | } else if (!iotg->hsm.a_bus_req && iotg->otg.host && | ||
| 1348 | iotg->otg.host->b_hnp_enable) { | ||
| 1349 | /* It is not safe enough to do a fast | ||
| 1350 | * transition from A_WAIT_BCON to | ||
| 1351 | * A_SUSPEND */ | ||
| 1352 | msleep(10000); | ||
| 1353 | if (iotg->hsm.a_bus_req) | ||
| 1354 | break; | ||
| 1355 | |||
| 1356 | if (request_irq(pdev->irq, | ||
| 1357 | otg_dummy_irq, IRQF_SHARED, | ||
| 1358 | driver_name, iotg->base) != 0) { | ||
| 1359 | dev_dbg(lnw->dev, | ||
| 1360 | "request interrupt %d fail\n", | ||
| 1361 | pdev->irq); | ||
| 1362 | } | ||
| 1363 | |||
| 1364 | langwell_otg_HABA(1); | ||
| 1365 | iotg->hsm.b_bus_resume = 0; | ||
| 1366 | iotg->hsm.a_aidl_bdis_tmout = 0; | ||
| 1367 | |||
| 1368 | langwell_otg_loc_sof(0); | ||
| 1369 | /* clear PHCD to enable HW timer */ | ||
| 1370 | langwell_otg_phy_low_power(0); | ||
| 1371 | langwell_otg_add_timer(a_aidl_bdis_tmr); | ||
| 1372 | iotg->otg.state = OTG_STATE_A_SUSPEND; | ||
| 1373 | } else if (!iotg->hsm.a_bus_req && iotg->otg.host && | ||
| 1374 | !iotg->otg.host->b_hnp_enable) { | ||
| 1375 | if (lnw->iotg.stop_host) | ||
| 1376 | lnw->iotg.stop_host(&lnw->iotg); | ||
| 1377 | else | ||
| 1378 | dev_dbg(lnw->dev, | ||
| 1379 | "host driver removed.\n"); | ||
| 1380 | |||
| 1381 | /* Turn off VBus */ | ||
| 1382 | iotg->otg.set_vbus(&iotg->otg, false); | ||
| 1383 | iotg->otg.state = OTG_STATE_A_WAIT_VFALL; | ||
| 1384 | } | ||
| 1385 | } | ||
| 1386 | break; | ||
| 1387 | case OTG_STATE_A_HOST: | ||
| 1388 | if (iotg->hsm.id) { | ||
| 1389 | iotg->otg.default_a = 0; | ||
| 1390 | iotg->hsm.b_bus_req = 0; | ||
| 1391 | |||
| 1392 | if (lnw->iotg.stop_host) | ||
| 1393 | lnw->iotg.stop_host(&lnw->iotg); | ||
| 1394 | else | ||
| 1395 | dev_dbg(lnw->dev, | ||
| 1396 | "host driver has been removed.\n"); | ||
| 1397 | |||
| 1398 | /* Turn off VBus */ | ||
| 1399 | iotg->otg.set_vbus(&iotg->otg, false); | ||
| 1400 | set_client_mode(); | ||
| 1401 | langwell_otg_phy_low_power_wait(1); | ||
| 1402 | iotg->otg.state = OTG_STATE_B_IDLE; | ||
| 1403 | langwell_update_transceiver(); | ||
| 1404 | } else if (iotg->hsm.a_bus_drop || | ||
| 1405 | (iotg->otg.host && | ||
| 1406 | !iotg->otg.host->b_hnp_enable && | ||
| 1407 | !iotg->hsm.a_bus_req)) { | ||
| 1408 | if (lnw->iotg.stop_host) | ||
| 1409 | lnw->iotg.stop_host(&lnw->iotg); | ||
| 1410 | else | ||
| 1411 | dev_dbg(lnw->dev, | ||
| 1412 | "host driver has been removed.\n"); | ||
| 1413 | |||
| 1414 | /* Turn off VBus */ | ||
| 1415 | iotg->otg.set_vbus(&iotg->otg, false); | ||
| 1416 | iotg->otg.state = OTG_STATE_A_WAIT_VFALL; | ||
| 1417 | } else if (!iotg->hsm.a_vbus_vld) { | ||
| 1418 | if (lnw->iotg.stop_host) | ||
| 1419 | lnw->iotg.stop_host(&lnw->iotg); | ||
| 1420 | else | ||
| 1421 | dev_dbg(lnw->dev, | ||
| 1422 | "host driver has been removed.\n"); | ||
| 1423 | |||
| 1424 | /* Turn off VBus */ | ||
| 1425 | iotg->otg.set_vbus(&iotg->otg, false); | ||
| 1426 | langwell_otg_phy_low_power_wait(1); | ||
| 1427 | iotg->otg.state = OTG_STATE_A_VBUS_ERR; | ||
| 1428 | } else if (iotg->otg.host && | ||
| 1429 | iotg->otg.host->b_hnp_enable && | ||
| 1430 | !iotg->hsm.a_bus_req) { | ||
| 1431 | /* Set HABA to enable hardware assistance to signal | ||
| 1432 | * A-connect after receiver B-disconnect. Hardware | ||
| 1433 | * will then set client mode and enable URE, SLE and | ||
| 1434 | * PCE after the assistance. otg_dummy_irq is used to | ||
| 1435 | * clean these ints when client driver is not resumed. | ||
| 1436 | */ | ||
| 1437 | if (request_irq(pdev->irq, otg_dummy_irq, IRQF_SHARED, | ||
| 1438 | driver_name, iotg->base) != 0) { | ||
| 1439 | dev_dbg(lnw->dev, | ||
| 1440 | "request interrupt %d failed\n", | ||
| 1441 | pdev->irq); | ||
| 1442 | } | ||
| 1443 | |||
| 1444 | /* set HABA */ | ||
| 1445 | langwell_otg_HABA(1); | ||
| 1446 | iotg->hsm.b_bus_resume = 0; | ||
| 1447 | iotg->hsm.a_aidl_bdis_tmout = 0; | ||
| 1448 | langwell_otg_loc_sof(0); | ||
| 1449 | /* clear PHCD to enable HW timer */ | ||
| 1450 | langwell_otg_phy_low_power(0); | ||
| 1451 | langwell_otg_add_timer(a_aidl_bdis_tmr); | ||
| 1452 | iotg->otg.state = OTG_STATE_A_SUSPEND; | ||
| 1453 | } else if (!iotg->hsm.b_conn || !iotg->hsm.a_bus_req) { | ||
| 1454 | langwell_otg_add_ktimer(TA_WAIT_BCON_TMR); | ||
| 1455 | iotg->otg.state = OTG_STATE_A_WAIT_BCON; | ||
| 1456 | } | ||
| 1457 | break; | ||
| 1458 | case OTG_STATE_A_SUSPEND: | ||
| 1459 | if (iotg->hsm.id) { | ||
| 1460 | langwell_otg_del_timer(a_aidl_bdis_tmr); | ||
| 1461 | langwell_otg_HABA(0); | ||
| 1462 | free_irq(pdev->irq, iotg->base); | ||
| 1463 | iotg->otg.default_a = 0; | ||
| 1464 | iotg->hsm.b_bus_req = 0; | ||
| 1465 | |||
| 1466 | if (lnw->iotg.stop_host) | ||
| 1467 | lnw->iotg.stop_host(&lnw->iotg); | ||
| 1468 | else | ||
| 1469 | dev_dbg(lnw->dev, | ||
| 1470 | "host driver has been removed.\n"); | ||
| 1471 | |||
| 1472 | /* Turn off VBus */ | ||
| 1473 | iotg->otg.set_vbus(&iotg->otg, false); | ||
| 1474 | set_client_mode(); | ||
| 1475 | langwell_otg_phy_low_power(1); | ||
| 1476 | iotg->otg.state = OTG_STATE_B_IDLE; | ||
| 1477 | langwell_update_transceiver(); | ||
| 1478 | } else if (iotg->hsm.a_bus_req || | ||
| 1479 | iotg->hsm.b_bus_resume) { | ||
| 1480 | langwell_otg_del_timer(a_aidl_bdis_tmr); | ||
| 1481 | langwell_otg_HABA(0); | ||
| 1482 | free_irq(pdev->irq, iotg->base); | ||
| 1483 | iotg->hsm.a_suspend_req = 0; | ||
| 1484 | langwell_otg_loc_sof(1); | ||
| 1485 | iotg->otg.state = OTG_STATE_A_HOST; | ||
| 1486 | } else if (iotg->hsm.a_aidl_bdis_tmout || | ||
| 1487 | iotg->hsm.a_bus_drop) { | ||
| 1488 | langwell_otg_del_timer(a_aidl_bdis_tmr); | ||
| 1489 | langwell_otg_HABA(0); | ||
| 1490 | free_irq(pdev->irq, iotg->base); | ||
| 1491 | if (lnw->iotg.stop_host) | ||
| 1492 | lnw->iotg.stop_host(&lnw->iotg); | ||
| 1493 | else | ||
| 1494 | dev_dbg(lnw->dev, | ||
| 1495 | "host driver has been removed.\n"); | ||
| 1496 | |||
| 1497 | /* Turn off VBus */ | ||
| 1498 | iotg->otg.set_vbus(&iotg->otg, false); | ||
| 1499 | iotg->otg.state = OTG_STATE_A_WAIT_VFALL; | ||
| 1500 | } else if (!iotg->hsm.b_conn && iotg->otg.host && | ||
| 1501 | iotg->otg.host->b_hnp_enable) { | ||
| 1502 | langwell_otg_del_timer(a_aidl_bdis_tmr); | ||
| 1503 | langwell_otg_HABA(0); | ||
| 1504 | free_irq(pdev->irq, iotg->base); | ||
| 1505 | |||
| 1506 | if (lnw->iotg.stop_host) | ||
| 1507 | lnw->iotg.stop_host(&lnw->iotg); | ||
| 1508 | else | ||
| 1509 | dev_dbg(lnw->dev, | ||
| 1510 | "host driver has been removed.\n"); | ||
| 1511 | |||
| 1512 | iotg->hsm.b_bus_suspend = 0; | ||
| 1513 | iotg->hsm.b_bus_suspend_vld = 0; | ||
| 1514 | |||
| 1515 | /* msleep(200); */ | ||
| 1516 | if (lnw->iotg.start_peripheral) | ||
| 1517 | lnw->iotg.start_peripheral(&lnw->iotg); | ||
| 1518 | else | ||
| 1519 | dev_dbg(lnw->dev, | ||
| 1520 | "client driver not loaded.\n"); | ||
| 1521 | |||
| 1522 | langwell_otg_add_ktimer(TB_BUS_SUSPEND_TMR); | ||
| 1523 | iotg->otg.state = OTG_STATE_A_PERIPHERAL; | ||
| 1524 | break; | ||
| 1525 | } else if (!iotg->hsm.a_vbus_vld) { | ||
| 1526 | langwell_otg_del_timer(a_aidl_bdis_tmr); | ||
| 1527 | langwell_otg_HABA(0); | ||
| 1528 | free_irq(pdev->irq, iotg->base); | ||
| 1529 | if (lnw->iotg.stop_host) | ||
| 1530 | lnw->iotg.stop_host(&lnw->iotg); | ||
| 1531 | else | ||
| 1532 | dev_dbg(lnw->dev, | ||
| 1533 | "host driver has been removed.\n"); | ||
| 1534 | |||
| 1535 | /* Turn off VBus */ | ||
| 1536 | iotg->otg.set_vbus(&iotg->otg, false); | ||
| 1537 | langwell_otg_phy_low_power_wait(1); | ||
| 1538 | iotg->otg.state = OTG_STATE_A_VBUS_ERR; | ||
| 1539 | } | ||
| 1540 | break; | ||
| 1541 | case OTG_STATE_A_PERIPHERAL: | ||
| 1542 | if (iotg->hsm.id) { | ||
| 1543 | /* delete hsm timer for b_bus_suspend_tmr */ | ||
| 1544 | del_timer_sync(&lnw->hsm_timer); | ||
| 1545 | iotg->otg.default_a = 0; | ||
| 1546 | iotg->hsm.b_bus_req = 0; | ||
| 1547 | if (lnw->iotg.stop_peripheral) | ||
| 1548 | lnw->iotg.stop_peripheral(&lnw->iotg); | ||
| 1549 | else | ||
| 1550 | dev_dbg(lnw->dev, | ||
| 1551 | "client driver has been removed.\n"); | ||
| 1552 | |||
| 1553 | /* Turn off VBus */ | ||
| 1554 | iotg->otg.set_vbus(&iotg->otg, false); | ||
| 1555 | set_client_mode(); | ||
| 1556 | langwell_otg_phy_low_power_wait(1); | ||
| 1557 | iotg->otg.state = OTG_STATE_B_IDLE; | ||
| 1558 | langwell_update_transceiver(); | ||
| 1559 | } else if (!iotg->hsm.a_vbus_vld) { | ||
| 1560 | /* delete hsm timer for b_bus_suspend_tmr */ | ||
| 1561 | del_timer_sync(&lnw->hsm_timer); | ||
| 1562 | |||
| 1563 | if (lnw->iotg.stop_peripheral) | ||
| 1564 | lnw->iotg.stop_peripheral(&lnw->iotg); | ||
| 1565 | else | ||
| 1566 | dev_dbg(lnw->dev, | ||
| 1567 | "client driver has been removed.\n"); | ||
| 1568 | |||
| 1569 | /* Turn off VBus */ | ||
| 1570 | iotg->otg.set_vbus(&iotg->otg, false); | ||
| 1571 | langwell_otg_phy_low_power_wait(1); | ||
| 1572 | iotg->otg.state = OTG_STATE_A_VBUS_ERR; | ||
| 1573 | } else if (iotg->hsm.a_bus_drop) { | ||
| 1574 | /* delete hsm timer for b_bus_suspend_tmr */ | ||
| 1575 | del_timer_sync(&lnw->hsm_timer); | ||
| 1576 | |||
| 1577 | if (lnw->iotg.stop_peripheral) | ||
| 1578 | lnw->iotg.stop_peripheral(&lnw->iotg); | ||
| 1579 | else | ||
| 1580 | dev_dbg(lnw->dev, | ||
| 1581 | "client driver has been removed.\n"); | ||
| 1582 | |||
| 1583 | /* Turn off VBus */ | ||
| 1584 | iotg->otg.set_vbus(&iotg->otg, false); | ||
| 1585 | iotg->otg.state = OTG_STATE_A_WAIT_VFALL; | ||
| 1586 | } else if (iotg->hsm.b_bus_suspend) { | ||
| 1587 | /* delete hsm timer for b_bus_suspend_tmr */ | ||
| 1588 | del_timer_sync(&lnw->hsm_timer); | ||
| 1589 | |||
| 1590 | if (lnw->iotg.stop_peripheral) | ||
| 1591 | lnw->iotg.stop_peripheral(&lnw->iotg); | ||
| 1592 | else | ||
| 1593 | dev_dbg(lnw->dev, | ||
| 1594 | "client driver has been removed.\n"); | ||
| 1595 | |||
| 1596 | if (lnw->iotg.start_host) | ||
| 1597 | lnw->iotg.start_host(&lnw->iotg); | ||
| 1598 | else | ||
| 1599 | dev_dbg(lnw->dev, | ||
| 1600 | "host driver not loaded.\n"); | ||
| 1601 | langwell_otg_add_ktimer(TA_WAIT_BCON_TMR); | ||
| 1602 | iotg->otg.state = OTG_STATE_A_WAIT_BCON; | ||
| 1603 | } else if (iotg->hsm.b_bus_suspend_tmout) { | ||
| 1604 | u32 val; | ||
| 1605 | val = readl(lnw->iotg.base + CI_PORTSC1); | ||
| 1606 | if (!(val & PORTSC_SUSP)) | ||
| 1607 | break; | ||
| 1608 | |||
| 1609 | if (lnw->iotg.stop_peripheral) | ||
| 1610 | lnw->iotg.stop_peripheral(&lnw->iotg); | ||
| 1611 | else | ||
| 1612 | dev_dbg(lnw->dev, | ||
| 1613 | "client driver has been removed.\n"); | ||
| 1614 | |||
| 1615 | if (lnw->iotg.start_host) | ||
| 1616 | lnw->iotg.start_host(&lnw->iotg); | ||
| 1617 | else | ||
| 1618 | dev_dbg(lnw->dev, | ||
| 1619 | "host driver not loaded.\n"); | ||
| 1620 | langwell_otg_add_ktimer(TA_WAIT_BCON_TMR); | ||
| 1621 | iotg->otg.state = OTG_STATE_A_WAIT_BCON; | ||
| 1622 | } | ||
| 1623 | break; | ||
| 1624 | case OTG_STATE_A_VBUS_ERR: | ||
| 1625 | if (iotg->hsm.id) { | ||
| 1626 | iotg->otg.default_a = 0; | ||
| 1627 | iotg->hsm.a_clr_err = 0; | ||
| 1628 | iotg->hsm.a_srp_det = 0; | ||
| 1629 | set_client_mode(); | ||
| 1630 | langwell_otg_phy_low_power(1); | ||
| 1631 | iotg->otg.state = OTG_STATE_B_IDLE; | ||
| 1632 | langwell_update_transceiver(); | ||
| 1633 | } else if (iotg->hsm.a_clr_err) { | ||
| 1634 | iotg->hsm.a_clr_err = 0; | ||
| 1635 | iotg->hsm.a_srp_det = 0; | ||
| 1636 | reset_otg(); | ||
| 1637 | init_hsm(); | ||
| 1638 | if (iotg->otg.state == OTG_STATE_A_IDLE) | ||
| 1639 | langwell_update_transceiver(); | ||
| 1640 | } else { | ||
| 1641 | /* FW will clear PHCD bit when any VBus | ||
| 1642 | * event detected. Reset PHCD to 1 again */ | ||
| 1643 | langwell_otg_phy_low_power(1); | ||
| 1644 | } | ||
| 1645 | break; | ||
| 1646 | case OTG_STATE_A_WAIT_VFALL: | ||
| 1647 | if (iotg->hsm.id) { | ||
| 1648 | iotg->otg.default_a = 0; | ||
| 1649 | set_client_mode(); | ||
| 1650 | langwell_otg_phy_low_power(1); | ||
| 1651 | iotg->otg.state = OTG_STATE_B_IDLE; | ||
| 1652 | langwell_update_transceiver(); | ||
| 1653 | } else if (iotg->hsm.a_bus_req) { | ||
| 1654 | |||
| 1655 | /* Turn on VBus */ | ||
| 1656 | iotg->otg.set_vbus(&iotg->otg, true); | ||
| 1657 | iotg->hsm.a_wait_vrise_tmout = 0; | ||
| 1658 | langwell_otg_add_timer(a_wait_vrise_tmr); | ||
| 1659 | iotg->otg.state = OTG_STATE_A_WAIT_VRISE; | ||
| 1660 | } else if (!iotg->hsm.a_sess_vld) { | ||
| 1661 | iotg->hsm.a_srp_det = 0; | ||
| 1662 | set_host_mode(); | ||
| 1663 | langwell_otg_phy_low_power(1); | ||
| 1664 | iotg->otg.state = OTG_STATE_A_IDLE; | ||
| 1665 | } | ||
| 1666 | break; | ||
| 1667 | default: | ||
| 1668 | ; | ||
| 1669 | } | ||
| 1670 | |||
| 1671 | dev_dbg(lnw->dev, "%s: new state = %s\n", __func__, | ||
| 1672 | otg_state_string(iotg->otg.state)); | ||
| 1673 | } | ||
| 1674 | |||
| 1675 | static ssize_t | ||
| 1676 | show_registers(struct device *_dev, struct device_attribute *attr, char *buf) | ||
| 1677 | { | ||
| 1678 | struct langwell_otg *lnw = the_transceiver; | ||
| 1679 | char *next; | ||
| 1680 | unsigned size, t; | ||
| 1681 | |||
| 1682 | next = buf; | ||
| 1683 | size = PAGE_SIZE; | ||
| 1684 | |||
| 1685 | t = scnprintf(next, size, | ||
| 1686 | "\n" | ||
| 1687 | "USBCMD = 0x%08x\n" | ||
| 1688 | "USBSTS = 0x%08x\n" | ||
| 1689 | "USBINTR = 0x%08x\n" | ||
| 1690 | "ASYNCLISTADDR = 0x%08x\n" | ||
| 1691 | "PORTSC1 = 0x%08x\n" | ||
| 1692 | "HOSTPC1 = 0x%08x\n" | ||
| 1693 | "OTGSC = 0x%08x\n" | ||
| 1694 | "USBMODE = 0x%08x\n", | ||
| 1695 | readl(lnw->iotg.base + 0x30), | ||
| 1696 | readl(lnw->iotg.base + 0x34), | ||
| 1697 | readl(lnw->iotg.base + 0x38), | ||
| 1698 | readl(lnw->iotg.base + 0x48), | ||
| 1699 | readl(lnw->iotg.base + 0x74), | ||
| 1700 | readl(lnw->iotg.base + 0xb4), | ||
| 1701 | readl(lnw->iotg.base + 0xf4), | ||
| 1702 | readl(lnw->iotg.base + 0xf8) | ||
| 1703 | ); | ||
| 1704 | size -= t; | ||
| 1705 | next += t; | ||
| 1706 | |||
| 1707 | return PAGE_SIZE - size; | ||
| 1708 | } | ||
| 1709 | static DEVICE_ATTR(registers, S_IRUGO, show_registers, NULL); | ||
| 1710 | |||
| 1711 | static ssize_t | ||
| 1712 | show_hsm(struct device *_dev, struct device_attribute *attr, char *buf) | ||
| 1713 | { | ||
| 1714 | struct langwell_otg *lnw = the_transceiver; | ||
| 1715 | struct intel_mid_otg_xceiv *iotg = &lnw->iotg; | ||
| 1716 | char *next; | ||
| 1717 | unsigned size, t; | ||
| 1718 | |||
| 1719 | next = buf; | ||
| 1720 | size = PAGE_SIZE; | ||
| 1721 | |||
| 1722 | if (iotg->otg.host) | ||
| 1723 | iotg->hsm.a_set_b_hnp_en = iotg->otg.host->b_hnp_enable; | ||
| 1724 | |||
| 1725 | if (iotg->otg.gadget) | ||
| 1726 | iotg->hsm.b_hnp_enable = iotg->otg.gadget->b_hnp_enable; | ||
| 1727 | |||
| 1728 | t = scnprintf(next, size, | ||
| 1729 | "\n" | ||
| 1730 | "current state = %s\n" | ||
| 1731 | "a_bus_resume = \t%d\n" | ||
| 1732 | "a_bus_suspend = \t%d\n" | ||
| 1733 | "a_conn = \t%d\n" | ||
| 1734 | "a_sess_vld = \t%d\n" | ||
| 1735 | "a_srp_det = \t%d\n" | ||
| 1736 | "a_vbus_vld = \t%d\n" | ||
| 1737 | "b_bus_resume = \t%d\n" | ||
| 1738 | "b_bus_suspend = \t%d\n" | ||
| 1739 | "b_conn = \t%d\n" | ||
| 1740 | "b_se0_srp = \t%d\n" | ||
| 1741 | "b_sess_end = \t%d\n" | ||
| 1742 | "b_sess_vld = \t%d\n" | ||
| 1743 | "id = \t%d\n" | ||
| 1744 | "a_set_b_hnp_en = \t%d\n" | ||
| 1745 | "b_srp_done = \t%d\n" | ||
| 1746 | "b_hnp_enable = \t%d\n" | ||
| 1747 | "a_wait_vrise_tmout = \t%d\n" | ||
| 1748 | "a_wait_bcon_tmout = \t%d\n" | ||
| 1749 | "a_aidl_bdis_tmout = \t%d\n" | ||
| 1750 | "b_ase0_brst_tmout = \t%d\n" | ||
| 1751 | "a_bus_drop = \t%d\n" | ||
| 1752 | "a_bus_req = \t%d\n" | ||
| 1753 | "a_clr_err = \t%d\n" | ||
| 1754 | "a_suspend_req = \t%d\n" | ||
| 1755 | "b_bus_req = \t%d\n" | ||
| 1756 | "b_bus_suspend_tmout = \t%d\n" | ||
| 1757 | "b_bus_suspend_vld = \t%d\n", | ||
| 1758 | otg_state_string(iotg->otg.state), | ||
| 1759 | iotg->hsm.a_bus_resume, | ||
| 1760 | iotg->hsm.a_bus_suspend, | ||
| 1761 | iotg->hsm.a_conn, | ||
| 1762 | iotg->hsm.a_sess_vld, | ||
| 1763 | iotg->hsm.a_srp_det, | ||
| 1764 | iotg->hsm.a_vbus_vld, | ||
| 1765 | iotg->hsm.b_bus_resume, | ||
| 1766 | iotg->hsm.b_bus_suspend, | ||
| 1767 | iotg->hsm.b_conn, | ||
| 1768 | iotg->hsm.b_se0_srp, | ||
| 1769 | iotg->hsm.b_sess_end, | ||
| 1770 | iotg->hsm.b_sess_vld, | ||
| 1771 | iotg->hsm.id, | ||
| 1772 | iotg->hsm.a_set_b_hnp_en, | ||
| 1773 | iotg->hsm.b_srp_done, | ||
| 1774 | iotg->hsm.b_hnp_enable, | ||
| 1775 | iotg->hsm.a_wait_vrise_tmout, | ||
| 1776 | iotg->hsm.a_wait_bcon_tmout, | ||
| 1777 | iotg->hsm.a_aidl_bdis_tmout, | ||
| 1778 | iotg->hsm.b_ase0_brst_tmout, | ||
| 1779 | iotg->hsm.a_bus_drop, | ||
| 1780 | iotg->hsm.a_bus_req, | ||
| 1781 | iotg->hsm.a_clr_err, | ||
| 1782 | iotg->hsm.a_suspend_req, | ||
| 1783 | iotg->hsm.b_bus_req, | ||
| 1784 | iotg->hsm.b_bus_suspend_tmout, | ||
| 1785 | iotg->hsm.b_bus_suspend_vld | ||
| 1786 | ); | ||
| 1787 | size -= t; | ||
| 1788 | next += t; | ||
| 1789 | |||
| 1790 | return PAGE_SIZE - size; | ||
| 1791 | } | ||
| 1792 | static DEVICE_ATTR(hsm, S_IRUGO, show_hsm, NULL); | ||
| 1793 | |||
| 1794 | static ssize_t | ||
| 1795 | get_a_bus_req(struct device *dev, struct device_attribute *attr, char *buf) | ||
| 1796 | { | ||
| 1797 | struct langwell_otg *lnw = the_transceiver; | ||
| 1798 | char *next; | ||
| 1799 | unsigned size, t; | ||
| 1800 | |||
| 1801 | next = buf; | ||
| 1802 | size = PAGE_SIZE; | ||
| 1803 | |||
| 1804 | t = scnprintf(next, size, "%d", lnw->iotg.hsm.a_bus_req); | ||
| 1805 | size -= t; | ||
| 1806 | next += t; | ||
| 1807 | |||
| 1808 | return PAGE_SIZE - size; | ||
| 1809 | } | ||
| 1810 | |||
| 1811 | static ssize_t | ||
| 1812 | set_a_bus_req(struct device *dev, struct device_attribute *attr, | ||
| 1813 | const char *buf, size_t count) | ||
| 1814 | { | ||
| 1815 | struct langwell_otg *lnw = the_transceiver; | ||
| 1816 | struct intel_mid_otg_xceiv *iotg = &lnw->iotg; | ||
| 1817 | |||
| 1818 | if (!iotg->otg.default_a) | ||
| 1819 | return -1; | ||
| 1820 | if (count > 2) | ||
| 1821 | return -1; | ||
| 1822 | |||
| 1823 | if (buf[0] == '0') { | ||
| 1824 | iotg->hsm.a_bus_req = 0; | ||
| 1825 | dev_dbg(lnw->dev, "User request: a_bus_req = 0\n"); | ||
| 1826 | } else if (buf[0] == '1') { | ||
| 1827 | /* If a_bus_drop is TRUE, a_bus_req can't be set */ | ||
| 1828 | if (iotg->hsm.a_bus_drop) | ||
| 1829 | return -1; | ||
| 1830 | iotg->hsm.a_bus_req = 1; | ||
| 1831 | dev_dbg(lnw->dev, "User request: a_bus_req = 1\n"); | ||
| 1832 | } | ||
| 1833 | if (spin_trylock(&lnw->wq_lock)) { | ||
| 1834 | langwell_update_transceiver(); | ||
| 1835 | spin_unlock(&lnw->wq_lock); | ||
| 1836 | } | ||
| 1837 | return count; | ||
| 1838 | } | ||
| 1839 | static DEVICE_ATTR(a_bus_req, S_IRUGO | S_IWUSR, get_a_bus_req, set_a_bus_req); | ||
| 1840 | |||
| 1841 | static ssize_t | ||
| 1842 | get_a_bus_drop(struct device *dev, struct device_attribute *attr, char *buf) | ||
| 1843 | { | ||
| 1844 | struct langwell_otg *lnw = the_transceiver; | ||
| 1845 | char *next; | ||
| 1846 | unsigned size, t; | ||
| 1847 | |||
| 1848 | next = buf; | ||
| 1849 | size = PAGE_SIZE; | ||
| 1850 | |||
| 1851 | t = scnprintf(next, size, "%d", lnw->iotg.hsm.a_bus_drop); | ||
| 1852 | size -= t; | ||
| 1853 | next += t; | ||
| 1854 | |||
| 1855 | return PAGE_SIZE - size; | ||
| 1856 | } | ||
| 1857 | |||
| 1858 | static ssize_t | ||
| 1859 | set_a_bus_drop(struct device *dev, struct device_attribute *attr, | ||
| 1860 | const char *buf, size_t count) | ||
| 1861 | { | ||
| 1862 | struct langwell_otg *lnw = the_transceiver; | ||
| 1863 | struct intel_mid_otg_xceiv *iotg = &lnw->iotg; | ||
| 1864 | |||
| 1865 | if (!iotg->otg.default_a) | ||
| 1866 | return -1; | ||
| 1867 | if (count > 2) | ||
| 1868 | return -1; | ||
| 1869 | |||
| 1870 | if (buf[0] == '0') { | ||
| 1871 | iotg->hsm.a_bus_drop = 0; | ||
| 1872 | dev_dbg(lnw->dev, "User request: a_bus_drop = 0\n"); | ||
| 1873 | } else if (buf[0] == '1') { | ||
| 1874 | iotg->hsm.a_bus_drop = 1; | ||
| 1875 | iotg->hsm.a_bus_req = 0; | ||
| 1876 | dev_dbg(lnw->dev, "User request: a_bus_drop = 1\n"); | ||
| 1877 | dev_dbg(lnw->dev, "User request: and a_bus_req = 0\n"); | ||
| 1878 | } | ||
| 1879 | if (spin_trylock(&lnw->wq_lock)) { | ||
| 1880 | langwell_update_transceiver(); | ||
| 1881 | spin_unlock(&lnw->wq_lock); | ||
| 1882 | } | ||
| 1883 | return count; | ||
| 1884 | } | ||
| 1885 | static DEVICE_ATTR(a_bus_drop, S_IRUGO | S_IWUSR, get_a_bus_drop, set_a_bus_drop); | ||
| 1886 | |||
| 1887 | static ssize_t | ||
| 1888 | get_b_bus_req(struct device *dev, struct device_attribute *attr, char *buf) | ||
| 1889 | { | ||
| 1890 | struct langwell_otg *lnw = the_transceiver; | ||
| 1891 | char *next; | ||
| 1892 | unsigned size, t; | ||
| 1893 | |||
| 1894 | next = buf; | ||
| 1895 | size = PAGE_SIZE; | ||
| 1896 | |||
| 1897 | t = scnprintf(next, size, "%d", lnw->iotg.hsm.b_bus_req); | ||
| 1898 | size -= t; | ||
| 1899 | next += t; | ||
| 1900 | |||
| 1901 | return PAGE_SIZE - size; | ||
| 1902 | } | ||
| 1903 | |||
| 1904 | static ssize_t | ||
| 1905 | set_b_bus_req(struct device *dev, struct device_attribute *attr, | ||
| 1906 | const char *buf, size_t count) | ||
| 1907 | { | ||
| 1908 | struct langwell_otg *lnw = the_transceiver; | ||
| 1909 | struct intel_mid_otg_xceiv *iotg = &lnw->iotg; | ||
| 1910 | |||
| 1911 | if (iotg->otg.default_a) | ||
| 1912 | return -1; | ||
| 1913 | |||
| 1914 | if (count > 2) | ||
| 1915 | return -1; | ||
| 1916 | |||
| 1917 | if (buf[0] == '0') { | ||
| 1918 | iotg->hsm.b_bus_req = 0; | ||
| 1919 | dev_dbg(lnw->dev, "User request: b_bus_req = 0\n"); | ||
| 1920 | } else if (buf[0] == '1') { | ||
| 1921 | iotg->hsm.b_bus_req = 1; | ||
| 1922 | dev_dbg(lnw->dev, "User request: b_bus_req = 1\n"); | ||
| 1923 | } | ||
| 1924 | if (spin_trylock(&lnw->wq_lock)) { | ||
| 1925 | langwell_update_transceiver(); | ||
| 1926 | spin_unlock(&lnw->wq_lock); | ||
| 1927 | } | ||
| 1928 | return count; | ||
| 1929 | } | ||
| 1930 | static DEVICE_ATTR(b_bus_req, S_IRUGO | S_IWUSR, get_b_bus_req, set_b_bus_req); | ||
| 1931 | |||
| 1932 | static ssize_t | ||
| 1933 | set_a_clr_err(struct device *dev, struct device_attribute *attr, | ||
| 1934 | const char *buf, size_t count) | ||
| 1935 | { | ||
| 1936 | struct langwell_otg *lnw = the_transceiver; | ||
| 1937 | struct intel_mid_otg_xceiv *iotg = &lnw->iotg; | ||
| 1938 | |||
| 1939 | if (!iotg->otg.default_a) | ||
| 1940 | return -1; | ||
| 1941 | if (count > 2) | ||
| 1942 | return -1; | ||
| 1943 | |||
| 1944 | if (buf[0] == '1') { | ||
| 1945 | iotg->hsm.a_clr_err = 1; | ||
| 1946 | dev_dbg(lnw->dev, "User request: a_clr_err = 1\n"); | ||
| 1947 | } | ||
| 1948 | if (spin_trylock(&lnw->wq_lock)) { | ||
| 1949 | langwell_update_transceiver(); | ||
| 1950 | spin_unlock(&lnw->wq_lock); | ||
| 1951 | } | ||
| 1952 | return count; | ||
| 1953 | } | ||
| 1954 | static DEVICE_ATTR(a_clr_err, S_IWUSR, NULL, set_a_clr_err); | ||
| 1955 | |||
| 1956 | static struct attribute *inputs_attrs[] = { | ||
| 1957 | &dev_attr_a_bus_req.attr, | ||
| 1958 | &dev_attr_a_bus_drop.attr, | ||
| 1959 | &dev_attr_b_bus_req.attr, | ||
| 1960 | &dev_attr_a_clr_err.attr, | ||
| 1961 | NULL, | ||
| 1962 | }; | ||
| 1963 | |||
| 1964 | static struct attribute_group debug_dev_attr_group = { | ||
| 1965 | .name = "inputs", | ||
| 1966 | .attrs = inputs_attrs, | ||
| 1967 | }; | ||
| 1968 | |||
| 1969 | static int langwell_otg_probe(struct pci_dev *pdev, | ||
| 1970 | const struct pci_device_id *id) | ||
| 1971 | { | ||
| 1972 | unsigned long resource, len; | ||
| 1973 | void __iomem *base = NULL; | ||
| 1974 | int retval; | ||
| 1975 | u32 val32; | ||
| 1976 | struct langwell_otg *lnw; | ||
| 1977 | char qname[] = "langwell_otg_queue"; | ||
| 1978 | |||
| 1979 | retval = 0; | ||
| 1980 | dev_dbg(&pdev->dev, "\notg controller is detected.\n"); | ||
| 1981 | if (pci_enable_device(pdev) < 0) { | ||
| 1982 | retval = -ENODEV; | ||
| 1983 | goto done; | ||
| 1984 | } | ||
| 1985 | |||
| 1986 | lnw = kzalloc(sizeof *lnw, GFP_KERNEL); | ||
| 1987 | if (lnw == NULL) { | ||
| 1988 | retval = -ENOMEM; | ||
| 1989 | goto done; | ||
| 1990 | } | ||
| 1991 | the_transceiver = lnw; | ||
| 1992 | |||
| 1993 | /* control register: BAR 0 */ | ||
| 1994 | resource = pci_resource_start(pdev, 0); | ||
| 1995 | len = pci_resource_len(pdev, 0); | ||
| 1996 | if (!request_mem_region(resource, len, driver_name)) { | ||
| 1997 | retval = -EBUSY; | ||
| 1998 | goto err; | ||
| 1999 | } | ||
| 2000 | lnw->region = 1; | ||
| 2001 | |||
| 2002 | base = ioremap_nocache(resource, len); | ||
| 2003 | if (base == NULL) { | ||
| 2004 | retval = -EFAULT; | ||
| 2005 | goto err; | ||
| 2006 | } | ||
| 2007 | lnw->iotg.base = base; | ||
| 2008 | |||
| 2009 | if (!request_mem_region(USBCFG_ADDR, USBCFG_LEN, driver_name)) { | ||
| 2010 | retval = -EBUSY; | ||
| 2011 | goto err; | ||
| 2012 | } | ||
| 2013 | lnw->cfg_region = 1; | ||
| 2014 | |||
| 2015 | /* For the SCCB.USBCFG register */ | ||
| 2016 | base = ioremap_nocache(USBCFG_ADDR, USBCFG_LEN); | ||
| 2017 | if (base == NULL) { | ||
| 2018 | retval = -EFAULT; | ||
| 2019 | goto err; | ||
| 2020 | } | ||
| 2021 | lnw->usbcfg = base; | ||
| 2022 | |||
| 2023 | if (!pdev->irq) { | ||
| 2024 | dev_dbg(&pdev->dev, "No IRQ.\n"); | ||
| 2025 | retval = -ENODEV; | ||
| 2026 | goto err; | ||
| 2027 | } | ||
| 2028 | |||
| 2029 | lnw->qwork = create_singlethread_workqueue(qname); | ||
| 2030 | if (!lnw->qwork) { | ||
| 2031 | dev_dbg(&pdev->dev, "cannot create workqueue %s\n", qname); | ||
| 2032 | retval = -ENOMEM; | ||
| 2033 | goto err; | ||
| 2034 | } | ||
| 2035 | INIT_WORK(&lnw->work, langwell_otg_work); | ||
| 2036 | |||
| 2037 | /* OTG common part */ | ||
| 2038 | lnw->dev = &pdev->dev; | ||
| 2039 | lnw->iotg.otg.dev = lnw->dev; | ||
| 2040 | lnw->iotg.otg.label = driver_name; | ||
| 2041 | lnw->iotg.otg.set_host = langwell_otg_set_host; | ||
| 2042 | lnw->iotg.otg.set_peripheral = langwell_otg_set_peripheral; | ||
| 2043 | lnw->iotg.otg.set_power = langwell_otg_set_power; | ||
| 2044 | lnw->iotg.otg.set_vbus = langwell_otg_set_vbus; | ||
| 2045 | lnw->iotg.otg.start_srp = langwell_otg_start_srp; | ||
| 2046 | lnw->iotg.otg.state = OTG_STATE_UNDEFINED; | ||
| 2047 | |||
| 2048 | if (otg_set_transceiver(&lnw->iotg.otg)) { | ||
| 2049 | dev_dbg(lnw->dev, "can't set transceiver\n"); | ||
| 2050 | retval = -EBUSY; | ||
| 2051 | goto err; | ||
| 2052 | } | ||
| 2053 | |||
| 2054 | reset_otg(); | ||
| 2055 | init_hsm(); | ||
| 2056 | |||
| 2057 | spin_lock_init(&lnw->lock); | ||
| 2058 | spin_lock_init(&lnw->wq_lock); | ||
| 2059 | INIT_LIST_HEAD(&active_timers); | ||
| 2060 | retval = langwell_otg_init_timers(&lnw->iotg.hsm); | ||
| 2061 | if (retval) { | ||
| 2062 | dev_dbg(&pdev->dev, "Failed to init timers\n"); | ||
| 2063 | goto err; | ||
| 2064 | } | ||
| 2065 | |||
| 2066 | init_timer(&lnw->hsm_timer); | ||
| 2067 | ATOMIC_INIT_NOTIFIER_HEAD(&lnw->iotg.iotg_notifier); | ||
| 2068 | |||
| 2069 | lnw->iotg_notifier.notifier_call = langwell_otg_iotg_notify; | ||
| 2070 | |||
| 2071 | retval = intel_mid_otg_register_notifier(&lnw->iotg, | ||
| 2072 | &lnw->iotg_notifier); | ||
| 2073 | if (retval) { | ||
| 2074 | dev_dbg(lnw->dev, "Failed to register notifier\n"); | ||
| 2075 | goto err; | ||
| 2076 | } | ||
| 2077 | |||
| 2078 | if (request_irq(pdev->irq, otg_irq, IRQF_SHARED, | ||
| 2079 | driver_name, lnw) != 0) { | ||
| 2080 | dev_dbg(lnw->dev, "request interrupt %d failed\n", pdev->irq); | ||
| 2081 | retval = -EBUSY; | ||
| 2082 | goto err; | ||
| 2083 | } | ||
| 2084 | |||
| 2085 | /* enable OTGSC int */ | ||
| 2086 | val32 = OTGSC_DPIE | OTGSC_BSEIE | OTGSC_BSVIE | | ||
| 2087 | OTGSC_ASVIE | OTGSC_AVVIE | OTGSC_IDIE | OTGSC_IDPU; | ||
| 2088 | writel(val32, lnw->iotg.base + CI_OTGSC); | ||
| 2089 | |||
| 2090 | retval = device_create_file(&pdev->dev, &dev_attr_registers); | ||
| 2091 | if (retval < 0) { | ||
| 2092 | dev_dbg(lnw->dev, | ||
| 2093 | "Can't register sysfs attribute: %d\n", retval); | ||
| 2094 | goto err; | ||
| 2095 | } | ||
| 2096 | |||
| 2097 | retval = device_create_file(&pdev->dev, &dev_attr_hsm); | ||
| 2098 | if (retval < 0) { | ||
| 2099 | dev_dbg(lnw->dev, "Can't hsm sysfs attribute: %d\n", retval); | ||
| 2100 | goto err; | ||
| 2101 | } | ||
| 2102 | |||
| 2103 | retval = sysfs_create_group(&pdev->dev.kobj, &debug_dev_attr_group); | ||
| 2104 | if (retval < 0) { | ||
| 2105 | dev_dbg(lnw->dev, | ||
| 2106 | "Can't register sysfs attr group: %d\n", retval); | ||
| 2107 | goto err; | ||
| 2108 | } | ||
| 2109 | |||
| 2110 | if (lnw->iotg.otg.state == OTG_STATE_A_IDLE) | ||
| 2111 | langwell_update_transceiver(); | ||
| 2112 | |||
| 2113 | return 0; | ||
| 2114 | |||
| 2115 | err: | ||
| 2116 | if (the_transceiver) | ||
| 2117 | langwell_otg_remove(pdev); | ||
| 2118 | done: | ||
| 2119 | return retval; | ||
| 2120 | } | ||
| 2121 | |||
| 2122 | static void langwell_otg_remove(struct pci_dev *pdev) | ||
| 2123 | { | ||
| 2124 | struct langwell_otg *lnw = the_transceiver; | ||
| 2125 | |||
| 2126 | if (lnw->qwork) { | ||
| 2127 | flush_workqueue(lnw->qwork); | ||
| 2128 | destroy_workqueue(lnw->qwork); | ||
| 2129 | } | ||
| 2130 | intel_mid_otg_unregister_notifier(&lnw->iotg, &lnw->iotg_notifier); | ||
| 2131 | langwell_otg_free_timers(); | ||
| 2132 | |||
| 2133 | /* disable OTGSC interrupt as OTGSC doesn't change in reset */ | ||
| 2134 | writel(0, lnw->iotg.base + CI_OTGSC); | ||
| 2135 | |||
| 2136 | if (pdev->irq) | ||
| 2137 | free_irq(pdev->irq, lnw); | ||
| 2138 | if (lnw->usbcfg) | ||
| 2139 | iounmap(lnw->usbcfg); | ||
| 2140 | if (lnw->cfg_region) | ||
| 2141 | release_mem_region(USBCFG_ADDR, USBCFG_LEN); | ||
| 2142 | if (lnw->iotg.base) | ||
| 2143 | iounmap(lnw->iotg.base); | ||
| 2144 | if (lnw->region) | ||
| 2145 | release_mem_region(pci_resource_start(pdev, 0), | ||
| 2146 | pci_resource_len(pdev, 0)); | ||
| 2147 | |||
| 2148 | otg_set_transceiver(NULL); | ||
| 2149 | pci_disable_device(pdev); | ||
| 2150 | sysfs_remove_group(&pdev->dev.kobj, &debug_dev_attr_group); | ||
| 2151 | device_remove_file(&pdev->dev, &dev_attr_hsm); | ||
| 2152 | device_remove_file(&pdev->dev, &dev_attr_registers); | ||
| 2153 | kfree(lnw); | ||
| 2154 | lnw = NULL; | ||
| 2155 | } | ||
| 2156 | |||
| 2157 | static void transceiver_suspend(struct pci_dev *pdev) | ||
| 2158 | { | ||
| 2159 | pci_save_state(pdev); | ||
| 2160 | pci_set_power_state(pdev, PCI_D3hot); | ||
| 2161 | langwell_otg_phy_low_power(1); | ||
| 2162 | } | ||
| 2163 | |||
| 2164 | static int langwell_otg_suspend(struct pci_dev *pdev, pm_message_t message) | ||
| 2165 | { | ||
| 2166 | struct langwell_otg *lnw = the_transceiver; | ||
| 2167 | struct intel_mid_otg_xceiv *iotg = &lnw->iotg; | ||
| 2168 | int ret = 0; | ||
| 2169 | |||
| 2170 | /* Disbale OTG interrupts */ | ||
| 2171 | langwell_otg_intr(0); | ||
| 2172 | |||
| 2173 | if (pdev->irq) | ||
| 2174 | free_irq(pdev->irq, lnw); | ||
| 2175 | |||
| 2176 | /* Prevent more otg_work */ | ||
| 2177 | flush_workqueue(lnw->qwork); | ||
| 2178 | destroy_workqueue(lnw->qwork); | ||
| 2179 | lnw->qwork = NULL; | ||
| 2180 | |||
| 2181 | /* start actions */ | ||
| 2182 | switch (iotg->otg.state) { | ||
| 2183 | case OTG_STATE_A_WAIT_VFALL: | ||
| 2184 | iotg->otg.state = OTG_STATE_A_IDLE; | ||
| 2185 | case OTG_STATE_A_IDLE: | ||
| 2186 | case OTG_STATE_B_IDLE: | ||
| 2187 | case OTG_STATE_A_VBUS_ERR: | ||
| 2188 | transceiver_suspend(pdev); | ||
| 2189 | break; | ||
| 2190 | case OTG_STATE_A_WAIT_VRISE: | ||
| 2191 | langwell_otg_del_timer(a_wait_vrise_tmr); | ||
| 2192 | iotg->hsm.a_srp_det = 0; | ||
| 2193 | |||
| 2194 | /* Turn off VBus */ | ||
| 2195 | iotg->otg.set_vbus(&iotg->otg, false); | ||
| 2196 | iotg->otg.state = OTG_STATE_A_IDLE; | ||
| 2197 | transceiver_suspend(pdev); | ||
| 2198 | break; | ||
| 2199 | case OTG_STATE_A_WAIT_BCON: | ||
| 2200 | del_timer_sync(&lnw->hsm_timer); | ||
| 2201 | if (lnw->iotg.stop_host) | ||
| 2202 | lnw->iotg.stop_host(&lnw->iotg); | ||
| 2203 | else | ||
| 2204 | dev_dbg(&pdev->dev, "host driver has been removed.\n"); | ||
| 2205 | |||
| 2206 | iotg->hsm.a_srp_det = 0; | ||
| 2207 | |||
| 2208 | /* Turn off VBus */ | ||
| 2209 | iotg->otg.set_vbus(&iotg->otg, false); | ||
| 2210 | iotg->otg.state = OTG_STATE_A_IDLE; | ||
| 2211 | transceiver_suspend(pdev); | ||
| 2212 | break; | ||
| 2213 | case OTG_STATE_A_HOST: | ||
| 2214 | if (lnw->iotg.stop_host) | ||
| 2215 | lnw->iotg.stop_host(&lnw->iotg); | ||
| 2216 | else | ||
| 2217 | dev_dbg(&pdev->dev, "host driver has been removed.\n"); | ||
| 2218 | |||
| 2219 | iotg->hsm.a_srp_det = 0; | ||
| 2220 | |||
| 2221 | /* Turn off VBus */ | ||
| 2222 | iotg->otg.set_vbus(&iotg->otg, false); | ||
| 2223 | |||
| 2224 | iotg->otg.state = OTG_STATE_A_IDLE; | ||
| 2225 | transceiver_suspend(pdev); | ||
| 2226 | break; | ||
| 2227 | case OTG_STATE_A_SUSPEND: | ||
| 2228 | langwell_otg_del_timer(a_aidl_bdis_tmr); | ||
| 2229 | langwell_otg_HABA(0); | ||
| 2230 | if (lnw->iotg.stop_host) | ||
| 2231 | lnw->iotg.stop_host(&lnw->iotg); | ||
| 2232 | else | ||
| 2233 | dev_dbg(lnw->dev, "host driver has been removed.\n"); | ||
| 2234 | iotg->hsm.a_srp_det = 0; | ||
| 2235 | |||
| 2236 | /* Turn off VBus */ | ||
| 2237 | iotg->otg.set_vbus(&iotg->otg, false); | ||
| 2238 | iotg->otg.state = OTG_STATE_A_IDLE; | ||
| 2239 | transceiver_suspend(pdev); | ||
| 2240 | break; | ||
| 2241 | case OTG_STATE_A_PERIPHERAL: | ||
| 2242 | del_timer_sync(&lnw->hsm_timer); | ||
| 2243 | |||
| 2244 | if (lnw->iotg.stop_peripheral) | ||
| 2245 | lnw->iotg.stop_peripheral(&lnw->iotg); | ||
| 2246 | else | ||
| 2247 | dev_dbg(&pdev->dev, | ||
| 2248 | "client driver has been removed.\n"); | ||
| 2249 | iotg->hsm.a_srp_det = 0; | ||
| 2250 | |||
| 2251 | /* Turn off VBus */ | ||
| 2252 | iotg->otg.set_vbus(&iotg->otg, false); | ||
| 2253 | iotg->otg.state = OTG_STATE_A_IDLE; | ||
| 2254 | transceiver_suspend(pdev); | ||
| 2255 | break; | ||
| 2256 | case OTG_STATE_B_HOST: | ||
| 2257 | if (lnw->iotg.stop_host) | ||
| 2258 | lnw->iotg.stop_host(&lnw->iotg); | ||
| 2259 | else | ||
| 2260 | dev_dbg(&pdev->dev, "host driver has been removed.\n"); | ||
| 2261 | iotg->hsm.b_bus_req = 0; | ||
| 2262 | iotg->otg.state = OTG_STATE_B_IDLE; | ||
| 2263 | transceiver_suspend(pdev); | ||
| 2264 | break; | ||
| 2265 | case OTG_STATE_B_PERIPHERAL: | ||
| 2266 | if (lnw->iotg.stop_peripheral) | ||
| 2267 | lnw->iotg.stop_peripheral(&lnw->iotg); | ||
| 2268 | else | ||
| 2269 | dev_dbg(&pdev->dev, | ||
| 2270 | "client driver has been removed.\n"); | ||
| 2271 | iotg->otg.state = OTG_STATE_B_IDLE; | ||
| 2272 | transceiver_suspend(pdev); | ||
| 2273 | break; | ||
| 2274 | case OTG_STATE_B_WAIT_ACON: | ||
| 2275 | /* delete hsm timer for b_ase0_brst_tmr */ | ||
| 2276 | del_timer_sync(&lnw->hsm_timer); | ||
| 2277 | |||
| 2278 | langwell_otg_HAAR(0); | ||
| 2279 | |||
| 2280 | if (lnw->iotg.stop_host) | ||
| 2281 | lnw->iotg.stop_host(&lnw->iotg); | ||
| 2282 | else | ||
| 2283 | dev_dbg(&pdev->dev, "host driver has been removed.\n"); | ||
| 2284 | iotg->hsm.b_bus_req = 0; | ||
| 2285 | iotg->otg.state = OTG_STATE_B_IDLE; | ||
| 2286 | transceiver_suspend(pdev); | ||
| 2287 | break; | ||
| 2288 | default: | ||
| 2289 | dev_dbg(lnw->dev, "error state before suspend\n"); | ||
| 2290 | break; | ||
| 2291 | } | ||
| 2292 | |||
| 2293 | return ret; | ||
| 2294 | } | ||
| 2295 | |||
| 2296 | static void transceiver_resume(struct pci_dev *pdev) | ||
| 2297 | { | ||
| 2298 | pci_restore_state(pdev); | ||
| 2299 | pci_set_power_state(pdev, PCI_D0); | ||
| 2300 | } | ||
| 2301 | |||
| 2302 | static int langwell_otg_resume(struct pci_dev *pdev) | ||
| 2303 | { | ||
| 2304 | struct langwell_otg *lnw = the_transceiver; | ||
| 2305 | int ret = 0; | ||
| 2306 | |||
| 2307 | transceiver_resume(pdev); | ||
| 2308 | |||
| 2309 | lnw->qwork = create_singlethread_workqueue("langwell_otg_queue"); | ||
| 2310 | if (!lnw->qwork) { | ||
| 2311 | dev_dbg(&pdev->dev, "cannot create langwell otg workqueuen"); | ||
| 2312 | ret = -ENOMEM; | ||
| 2313 | goto error; | ||
| 2314 | } | ||
| 2315 | |||
| 2316 | if (request_irq(pdev->irq, otg_irq, IRQF_SHARED, | ||
| 2317 | driver_name, lnw) != 0) { | ||
| 2318 | dev_dbg(&pdev->dev, "request interrupt %d failed\n", pdev->irq); | ||
| 2319 | ret = -EBUSY; | ||
| 2320 | goto error; | ||
| 2321 | } | ||
| 2322 | |||
| 2323 | /* enable OTG interrupts */ | ||
| 2324 | langwell_otg_intr(1); | ||
| 2325 | |||
| 2326 | update_hsm(); | ||
| 2327 | |||
| 2328 | langwell_update_transceiver(); | ||
| 2329 | |||
| 2330 | return ret; | ||
| 2331 | error: | ||
| 2332 | langwell_otg_intr(0); | ||
| 2333 | transceiver_suspend(pdev); | ||
| 2334 | return ret; | ||
| 2335 | } | ||
| 2336 | |||
| 2337 | static int __init langwell_otg_init(void) | ||
| 2338 | { | ||
| 2339 | return pci_register_driver(&otg_pci_driver); | ||
| 2340 | } | ||
| 2341 | module_init(langwell_otg_init); | ||
| 2342 | |||
| 2343 | static void __exit langwell_otg_cleanup(void) | ||
| 2344 | { | ||
| 2345 | pci_unregister_driver(&otg_pci_driver); | ||
| 2346 | } | ||
| 2347 | module_exit(langwell_otg_cleanup); | ||
diff --git a/drivers/usb/otg/mv_otg.c b/drivers/usb/otg/mv_otg.c index db0d4fcdc8e2..b5fbe1452ab0 100644 --- a/drivers/usb/otg/mv_otg.c +++ b/drivers/usb/otg/mv_otg.c | |||
| @@ -202,6 +202,7 @@ static void mv_otg_init_irq(struct mv_otg *mvotg) | |||
| 202 | 202 | ||
| 203 | static void mv_otg_start_host(struct mv_otg *mvotg, int on) | 203 | static void mv_otg_start_host(struct mv_otg *mvotg, int on) |
| 204 | { | 204 | { |
| 205 | #ifdef CONFIG_USB | ||
| 205 | struct otg_transceiver *otg = &mvotg->otg; | 206 | struct otg_transceiver *otg = &mvotg->otg; |
| 206 | struct usb_hcd *hcd; | 207 | struct usb_hcd *hcd; |
| 207 | 208 | ||
| @@ -216,6 +217,7 @@ static void mv_otg_start_host(struct mv_otg *mvotg, int on) | |||
| 216 | usb_add_hcd(hcd, hcd->irq, IRQF_SHARED); | 217 | usb_add_hcd(hcd, hcd->irq, IRQF_SHARED); |
| 217 | else | 218 | else |
| 218 | usb_remove_hcd(hcd); | 219 | usb_remove_hcd(hcd); |
| 220 | #endif /* CONFIG_USB */ | ||
| 219 | } | 221 | } |
| 220 | 222 | ||
| 221 | static void mv_otg_start_periphrals(struct mv_otg *mvotg, int on) | 223 | static void mv_otg_start_periphrals(struct mv_otg *mvotg, int on) |
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c index 528691d5f3e2..7542aa94a462 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c | |||
| @@ -425,7 +425,7 @@ static int usbhsg_recip_run_handle(struct usbhs_priv *priv, | |||
| 425 | struct usbhs_pipe *pipe; | 425 | struct usbhs_pipe *pipe; |
| 426 | int recip = ctrl->bRequestType & USB_RECIP_MASK; | 426 | int recip = ctrl->bRequestType & USB_RECIP_MASK; |
| 427 | int nth = le16_to_cpu(ctrl->wIndex) & USB_ENDPOINT_NUMBER_MASK; | 427 | int nth = le16_to_cpu(ctrl->wIndex) & USB_ENDPOINT_NUMBER_MASK; |
| 428 | int ret; | 428 | int ret = 0; |
| 429 | int (*func)(struct usbhs_priv *priv, struct usbhsg_uep *uep, | 429 | int (*func)(struct usbhs_priv *priv, struct usbhsg_uep *uep, |
| 430 | struct usb_ctrlrequest *ctrl); | 430 | struct usb_ctrlrequest *ctrl); |
| 431 | char *msg; | 431 | char *msg; |
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index fba1147ed916..8dbf51a43c45 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c | |||
| @@ -39,6 +39,8 @@ static void cp210x_get_termios(struct tty_struct *, | |||
| 39 | struct usb_serial_port *port); | 39 | struct usb_serial_port *port); |
| 40 | static void cp210x_get_termios_port(struct usb_serial_port *port, | 40 | static void cp210x_get_termios_port(struct usb_serial_port *port, |
| 41 | unsigned int *cflagp, unsigned int *baudp); | 41 | unsigned int *cflagp, unsigned int *baudp); |
| 42 | static void cp210x_change_speed(struct tty_struct *, struct usb_serial_port *, | ||
| 43 | struct ktermios *); | ||
| 42 | static void cp210x_set_termios(struct tty_struct *, struct usb_serial_port *, | 44 | static void cp210x_set_termios(struct tty_struct *, struct usb_serial_port *, |
| 43 | struct ktermios*); | 45 | struct ktermios*); |
| 44 | static int cp210x_tiocmget(struct tty_struct *); | 46 | static int cp210x_tiocmget(struct tty_struct *); |
| @@ -138,6 +140,7 @@ static const struct usb_device_id id_table[] = { | |||
| 138 | { USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */ | 140 | { USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */ |
| 139 | { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */ | 141 | { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */ |
| 140 | { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */ | 142 | { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */ |
| 143 | { USB_DEVICE(0x3195, 0xF190) }, /* Link Instruments MSO-19 */ | ||
| 141 | { USB_DEVICE(0x413C, 0x9500) }, /* DW700 GPS USB interface */ | 144 | { USB_DEVICE(0x413C, 0x9500) }, /* DW700 GPS USB interface */ |
| 142 | { } /* Terminating Entry */ | 145 | { } /* Terminating Entry */ |
| 143 | }; | 146 | }; |
| @@ -201,6 +204,8 @@ static struct usb_serial_driver cp210x_device = { | |||
| 201 | #define CP210X_EMBED_EVENTS 0x15 | 204 | #define CP210X_EMBED_EVENTS 0x15 |
| 202 | #define CP210X_GET_EVENTSTATE 0x16 | 205 | #define CP210X_GET_EVENTSTATE 0x16 |
| 203 | #define CP210X_SET_CHARS 0x19 | 206 | #define CP210X_SET_CHARS 0x19 |
| 207 | #define CP210X_GET_BAUDRATE 0x1D | ||
| 208 | #define CP210X_SET_BAUDRATE 0x1E | ||
| 204 | 209 | ||
| 205 | /* CP210X_IFC_ENABLE */ | 210 | /* CP210X_IFC_ENABLE */ |
| 206 | #define UART_ENABLE 0x0001 | 211 | #define UART_ENABLE 0x0001 |
| @@ -360,8 +365,8 @@ static inline int cp210x_set_config_single(struct usb_serial_port *port, | |||
| 360 | * Quantises the baud rate as per AN205 Table 1 | 365 | * Quantises the baud rate as per AN205 Table 1 |
| 361 | */ | 366 | */ |
| 362 | static unsigned int cp210x_quantise_baudrate(unsigned int baud) { | 367 | static unsigned int cp210x_quantise_baudrate(unsigned int baud) { |
| 363 | if (baud <= 56) baud = 0; | 368 | if (baud <= 300) |
| 364 | else if (baud <= 300) baud = 300; | 369 | baud = 300; |
| 365 | else if (baud <= 600) baud = 600; | 370 | else if (baud <= 600) baud = 600; |
| 366 | else if (baud <= 1200) baud = 1200; | 371 | else if (baud <= 1200) baud = 1200; |
| 367 | else if (baud <= 1800) baud = 1800; | 372 | else if (baud <= 1800) baud = 1800; |
| @@ -389,10 +394,10 @@ static unsigned int cp210x_quantise_baudrate(unsigned int baud) { | |||
| 389 | else if (baud <= 491520) baud = 460800; | 394 | else if (baud <= 491520) baud = 460800; |
| 390 | else if (baud <= 567138) baud = 500000; | 395 | else if (baud <= 567138) baud = 500000; |
| 391 | else if (baud <= 670254) baud = 576000; | 396 | else if (baud <= 670254) baud = 576000; |
| 392 | else if (baud <= 1053257) baud = 921600; | 397 | else if (baud < 1000000) |
| 393 | else if (baud <= 1474560) baud = 1228800; | 398 | baud = 921600; |
| 394 | else if (baud <= 2457600) baud = 1843200; | 399 | else if (baud > 2000000) |
| 395 | else baud = 3686400; | 400 | baud = 2000000; |
| 396 | return baud; | 401 | return baud; |
| 397 | } | 402 | } |
| 398 | 403 | ||
| @@ -409,13 +414,14 @@ static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
| 409 | return result; | 414 | return result; |
| 410 | } | 415 | } |
| 411 | 416 | ||
| 412 | result = usb_serial_generic_open(tty, port); | ||
| 413 | if (result) | ||
| 414 | return result; | ||
| 415 | |||
| 416 | /* Configure the termios structure */ | 417 | /* Configure the termios structure */ |
| 417 | cp210x_get_termios(tty, port); | 418 | cp210x_get_termios(tty, port); |
| 418 | return 0; | 419 | |
| 420 | /* The baud rate must be initialised on cp2104 */ | ||
| 421 | if (tty) | ||
| 422 | cp210x_change_speed(tty, port, NULL); | ||
| 423 | |||
| 424 | return usb_serial_generic_open(tty, port); | ||
| 419 | } | 425 | } |
| 420 | 426 | ||
| 421 | static void cp210x_close(struct usb_serial_port *port) | 427 | static void cp210x_close(struct usb_serial_port *port) |
| @@ -467,10 +473,7 @@ static void cp210x_get_termios_port(struct usb_serial_port *port, | |||
| 467 | 473 | ||
| 468 | dbg("%s - port %d", __func__, port->number); | 474 | dbg("%s - port %d", __func__, port->number); |
| 469 | 475 | ||
| 470 | cp210x_get_config(port, CP210X_GET_BAUDDIV, &baud, 2); | 476 | cp210x_get_config(port, CP210X_GET_BAUDRATE, &baud, 4); |
| 471 | /* Convert to baudrate */ | ||
| 472 | if (baud) | ||
| 473 | baud = cp210x_quantise_baudrate((BAUD_RATE_GEN_FREQ + baud/2)/ baud); | ||
| 474 | 477 | ||
| 475 | dbg("%s - baud rate = %d", __func__, baud); | 478 | dbg("%s - baud rate = %d", __func__, baud); |
| 476 | *baudp = baud; | 479 | *baudp = baud; |
| @@ -579,11 +582,64 @@ static void cp210x_get_termios_port(struct usb_serial_port *port, | |||
| 579 | *cflagp = cflag; | 582 | *cflagp = cflag; |
| 580 | } | 583 | } |
| 581 | 584 | ||
| 585 | /* | ||
| 586 | * CP2101 supports the following baud rates: | ||
| 587 | * | ||
| 588 | * 300, 600, 1200, 1800, 2400, 4800, 7200, 9600, 14400, 19200, 28800, | ||
| 589 | * 38400, 56000, 57600, 115200, 128000, 230400, 460800, 921600 | ||
| 590 | * | ||
| 591 | * CP2102 and CP2103 support the following additional rates: | ||
| 592 | * | ||
| 593 | * 4000, 16000, 51200, 64000, 76800, 153600, 250000, 256000, 500000, | ||
| 594 | * 576000 | ||
| 595 | * | ||
| 596 | * The device will map a requested rate to a supported one, but the result | ||
| 597 | * of requests for rates greater than 1053257 is undefined (see AN205). | ||
| 598 | * | ||
| 599 | * CP2104, CP2105 and CP2110 support most rates up to 2M, 921k and 1M baud, | ||
| 600 | * respectively, with an error less than 1%. The actual rates are determined | ||
| 601 | * by | ||
| 602 | * | ||
| 603 | * div = round(freq / (2 x prescale x request)) | ||
| 604 | * actual = freq / (2 x prescale x div) | ||
| 605 | * | ||
| 606 | * For CP2104 and CP2105 freq is 48Mhz and prescale is 4 for request <= 365bps | ||
| 607 | * or 1 otherwise. | ||
| 608 | * For CP2110 freq is 24Mhz and prescale is 4 for request <= 300bps or 1 | ||
| 609 | * otherwise. | ||
| 610 | */ | ||
| 611 | static void cp210x_change_speed(struct tty_struct *tty, | ||
| 612 | struct usb_serial_port *port, struct ktermios *old_termios) | ||
| 613 | { | ||
| 614 | u32 baud; | ||
| 615 | |||
| 616 | baud = tty->termios->c_ospeed; | ||
| 617 | |||
| 618 | /* This maps the requested rate to a rate valid on cp2102 or cp2103, | ||
| 619 | * or to an arbitrary rate in [1M,2M]. | ||
| 620 | * | ||
| 621 | * NOTE: B0 is not implemented. | ||
| 622 | */ | ||
| 623 | baud = cp210x_quantise_baudrate(baud); | ||
| 624 | |||
| 625 | dbg("%s - setting baud rate to %u", __func__, baud); | ||
| 626 | if (cp210x_set_config(port, CP210X_SET_BAUDRATE, &baud, | ||
| 627 | sizeof(baud))) { | ||
| 628 | dev_warn(&port->dev, "failed to set baud rate to %u\n", baud); | ||
| 629 | if (old_termios) | ||
| 630 | baud = old_termios->c_ospeed; | ||
| 631 | else | ||
| 632 | baud = 9600; | ||
| 633 | } | ||
| 634 | |||
| 635 | tty_encode_baud_rate(tty, baud, baud); | ||
| 636 | } | ||
| 637 | |||
| 582 | static void cp210x_set_termios(struct tty_struct *tty, | 638 | static void cp210x_set_termios(struct tty_struct *tty, |
| 583 | struct usb_serial_port *port, struct ktermios *old_termios) | 639 | struct usb_serial_port *port, struct ktermios *old_termios) |
| 584 | { | 640 | { |
| 585 | unsigned int cflag, old_cflag; | 641 | unsigned int cflag, old_cflag; |
| 586 | unsigned int baud = 0, bits; | 642 | unsigned int bits; |
| 587 | unsigned int modem_ctl[4]; | 643 | unsigned int modem_ctl[4]; |
| 588 | 644 | ||
| 589 | dbg("%s - port %d", __func__, port->number); | 645 | dbg("%s - port %d", __func__, port->number); |
| @@ -593,20 +649,9 @@ static void cp210x_set_termios(struct tty_struct *tty, | |||
| 593 | 649 | ||
| 594 | cflag = tty->termios->c_cflag; | 650 | cflag = tty->termios->c_cflag; |
| 595 | old_cflag = old_termios->c_cflag; | 651 | old_cflag = old_termios->c_cflag; |
| 596 | baud = cp210x_quantise_baudrate(tty_get_baud_rate(tty)); | 652 | |
| 597 | 653 | if (tty->termios->c_ospeed != old_termios->c_ospeed) | |
| 598 | /* If the baud rate is to be updated*/ | 654 | cp210x_change_speed(tty, port, old_termios); |
| 599 | if (baud != tty_termios_baud_rate(old_termios) && baud != 0) { | ||
| 600 | dbg("%s - Setting baud rate to %d baud", __func__, | ||
| 601 | baud); | ||
| 602 | if (cp210x_set_config_single(port, CP210X_SET_BAUDDIV, | ||
| 603 | ((BAUD_RATE_GEN_FREQ + baud/2) / baud))) { | ||
| 604 | dbg("Baud rate requested not supported by device"); | ||
| 605 | baud = tty_termios_baud_rate(old_termios); | ||
| 606 | } | ||
| 607 | } | ||
| 608 | /* Report back the resulting baud rate */ | ||
| 609 | tty_encode_baud_rate(tty, baud, baud); | ||
| 610 | 655 | ||
| 611 | /* If the number of data bits is to be updated */ | 656 | /* If the number of data bits is to be updated */ |
| 612 | if ((cflag & CSIZE) != (old_cflag & CSIZE)) { | 657 | if ((cflag & CSIZE) != (old_cflag & CSIZE)) { |
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 01b6404df395..ad654f8208ef 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
| @@ -797,6 +797,7 @@ static struct usb_device_id id_table_combined [] = { | |||
| 797 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, | 797 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, |
| 798 | { USB_DEVICE(ADI_VID, ADI_GNICEPLUS_PID), | 798 | { USB_DEVICE(ADI_VID, ADI_GNICEPLUS_PID), |
| 799 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, | 799 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, |
| 800 | { USB_DEVICE(HORNBY_VID, HORNBY_ELITE_PID) }, | ||
| 800 | { USB_DEVICE(JETI_VID, JETI_SPC1201_PID) }, | 801 | { USB_DEVICE(JETI_VID, JETI_SPC1201_PID) }, |
| 801 | { USB_DEVICE(MARVELL_VID, MARVELL_SHEEVAPLUG_PID), | 802 | { USB_DEVICE(MARVELL_VID, MARVELL_SHEEVAPLUG_PID), |
| 802 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, | 803 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, |
| @@ -805,6 +806,8 @@ static struct usb_device_id id_table_combined [] = { | |||
| 805 | { USB_DEVICE(BAYER_VID, BAYER_CONTOUR_CABLE_PID) }, | 806 | { USB_DEVICE(BAYER_VID, BAYER_CONTOUR_CABLE_PID) }, |
| 806 | { USB_DEVICE(FTDI_VID, MARVELL_OPENRD_PID), | 807 | { USB_DEVICE(FTDI_VID, MARVELL_OPENRD_PID), |
| 807 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, | 808 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, |
| 809 | { USB_DEVICE(FTDI_VID, TI_XDS100V2_PID), | ||
| 810 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, | ||
| 808 | { USB_DEVICE(FTDI_VID, HAMEG_HO820_PID) }, | 811 | { USB_DEVICE(FTDI_VID, HAMEG_HO820_PID) }, |
| 809 | { USB_DEVICE(FTDI_VID, HAMEG_HO720_PID) }, | 812 | { USB_DEVICE(FTDI_VID, HAMEG_HO720_PID) }, |
| 810 | { USB_DEVICE(FTDI_VID, HAMEG_HO730_PID) }, | 813 | { USB_DEVICE(FTDI_VID, HAMEG_HO730_PID) }, |
| @@ -841,6 +844,7 @@ static struct usb_device_id id_table_combined [] = { | |||
| 841 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, | 844 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, |
| 842 | { USB_DEVICE(ST_VID, ST_STMCLT1030_PID), | 845 | { USB_DEVICE(ST_VID, ST_STMCLT1030_PID), |
| 843 | .driver_info = (kernel_ulong_t)&ftdi_stmclite_quirk }, | 846 | .driver_info = (kernel_ulong_t)&ftdi_stmclite_quirk }, |
| 847 | { USB_DEVICE(FTDI_VID, FTDI_RF_R106) }, | ||
| 844 | { }, /* Optional parameter entry */ | 848 | { }, /* Optional parameter entry */ |
| 845 | { } /* Terminating entry */ | 849 | { } /* Terminating entry */ |
| 846 | }; | 850 | }; |
| @@ -1333,8 +1337,7 @@ static int set_serial_info(struct tty_struct *tty, | |||
| 1333 | goto check_and_exit; | 1337 | goto check_and_exit; |
| 1334 | } | 1338 | } |
| 1335 | 1339 | ||
| 1336 | if ((new_serial.baud_base != priv->baud_base) && | 1340 | if (new_serial.baud_base != priv->baud_base) { |
| 1337 | (new_serial.baud_base < 9600)) { | ||
| 1338 | mutex_unlock(&priv->cfg_lock); | 1341 | mutex_unlock(&priv->cfg_lock); |
| 1339 | return -EINVAL; | 1342 | return -EINVAL; |
| 1340 | } | 1343 | } |
| @@ -1824,6 +1827,7 @@ static int ftdi_sio_port_remove(struct usb_serial_port *port) | |||
| 1824 | 1827 | ||
| 1825 | static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port) | 1828 | static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port) |
| 1826 | { | 1829 | { |
| 1830 | struct ktermios dummy; | ||
| 1827 | struct usb_device *dev = port->serial->dev; | 1831 | struct usb_device *dev = port->serial->dev; |
| 1828 | struct ftdi_private *priv = usb_get_serial_port_data(port); | 1832 | struct ftdi_private *priv = usb_get_serial_port_data(port); |
| 1829 | int result; | 1833 | int result; |
| @@ -1842,8 +1846,10 @@ static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
| 1842 | This is same behaviour as serial.c/rs_open() - Kuba */ | 1846 | This is same behaviour as serial.c/rs_open() - Kuba */ |
| 1843 | 1847 | ||
| 1844 | /* ftdi_set_termios will send usb control messages */ | 1848 | /* ftdi_set_termios will send usb control messages */ |
| 1845 | if (tty) | 1849 | if (tty) { |
| 1846 | ftdi_set_termios(tty, port, tty->termios); | 1850 | memset(&dummy, 0, sizeof(dummy)); |
| 1851 | ftdi_set_termios(tty, port, &dummy); | ||
| 1852 | } | ||
| 1847 | 1853 | ||
| 1848 | /* Start reading from the device */ | 1854 | /* Start reading from the device */ |
| 1849 | result = usb_serial_generic_open(tty, port); | 1855 | result = usb_serial_generic_open(tty, port); |
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h index df1d7da933ec..f994503df2dd 100644 --- a/drivers/usb/serial/ftdi_sio_ids.h +++ b/drivers/usb/serial/ftdi_sio_ids.h | |||
| @@ -39,6 +39,13 @@ | |||
| 39 | /* www.candapter.com Ewert Energy Systems CANdapter device */ | 39 | /* www.candapter.com Ewert Energy Systems CANdapter device */ |
| 40 | #define FTDI_CANDAPTER_PID 0x9F80 /* Product Id */ | 40 | #define FTDI_CANDAPTER_PID 0x9F80 /* Product Id */ |
| 41 | 41 | ||
| 42 | /* | ||
| 43 | * Texas Instruments XDS100v2 JTAG / BeagleBone A3 | ||
| 44 | * http://processors.wiki.ti.com/index.php/XDS100 | ||
| 45 | * http://beagleboard.org/bone | ||
| 46 | */ | ||
| 47 | #define TI_XDS100V2_PID 0xa6d0 | ||
| 48 | |||
| 42 | #define FTDI_NXTCAM_PID 0xABB8 /* NXTCam for Mindstorms NXT */ | 49 | #define FTDI_NXTCAM_PID 0xABB8 /* NXTCam for Mindstorms NXT */ |
| 43 | 50 | ||
| 44 | /* US Interface Navigator (http://www.usinterface.com/) */ | 51 | /* US Interface Navigator (http://www.usinterface.com/) */ |
| @@ -525,6 +532,12 @@ | |||
| 525 | #define ADI_GNICEPLUS_PID 0xF001 | 532 | #define ADI_GNICEPLUS_PID 0xF001 |
| 526 | 533 | ||
| 527 | /* | 534 | /* |
| 535 | * Hornby Elite | ||
| 536 | */ | ||
| 537 | #define HORNBY_VID 0x04D8 | ||
| 538 | #define HORNBY_ELITE_PID 0x000A | ||
| 539 | |||
| 540 | /* | ||
| 528 | * RATOC REX-USB60F | 541 | * RATOC REX-USB60F |
| 529 | */ | 542 | */ |
| 530 | #define RATOC_VENDOR_ID 0x0584 | 543 | #define RATOC_VENDOR_ID 0x0584 |
| @@ -1168,3 +1181,9 @@ | |||
| 1168 | */ | 1181 | */ |
| 1169 | /* TagTracer MIFARE*/ | 1182 | /* TagTracer MIFARE*/ |
| 1170 | #define FTDI_ZEITCONTROL_TAGTRACE_MIFARE_PID 0xF7C0 | 1183 | #define FTDI_ZEITCONTROL_TAGTRACE_MIFARE_PID 0xF7C0 |
| 1184 | |||
| 1185 | /* | ||
| 1186 | * Rainforest Automation | ||
| 1187 | */ | ||
| 1188 | /* ZigBee controller */ | ||
| 1189 | #define FTDI_RF_R106 0x8A28 | ||
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index 65bf06aa591a..5818bfc3261e 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c | |||
| @@ -2657,15 +2657,7 @@ cleanup: | |||
| 2657 | 2657 | ||
| 2658 | static void edge_disconnect(struct usb_serial *serial) | 2658 | static void edge_disconnect(struct usb_serial *serial) |
| 2659 | { | 2659 | { |
| 2660 | int i; | ||
| 2661 | struct edgeport_port *edge_port; | ||
| 2662 | |||
| 2663 | dbg("%s", __func__); | 2660 | dbg("%s", __func__); |
| 2664 | |||
| 2665 | for (i = 0; i < serial->num_ports; ++i) { | ||
| 2666 | edge_port = usb_get_serial_port_data(serial->port[i]); | ||
| 2667 | edge_remove_sysfs_attrs(edge_port->port); | ||
| 2668 | } | ||
| 2669 | } | 2661 | } |
| 2670 | 2662 | ||
| 2671 | static void edge_release(struct usb_serial *serial) | 2663 | static void edge_release(struct usb_serial *serial) |
| @@ -2744,6 +2736,7 @@ static struct usb_serial_driver edgeport_1port_device = { | |||
| 2744 | .disconnect = edge_disconnect, | 2736 | .disconnect = edge_disconnect, |
| 2745 | .release = edge_release, | 2737 | .release = edge_release, |
| 2746 | .port_probe = edge_create_sysfs_attrs, | 2738 | .port_probe = edge_create_sysfs_attrs, |
| 2739 | .port_remove = edge_remove_sysfs_attrs, | ||
| 2747 | .ioctl = edge_ioctl, | 2740 | .ioctl = edge_ioctl, |
| 2748 | .set_termios = edge_set_termios, | 2741 | .set_termios = edge_set_termios, |
| 2749 | .tiocmget = edge_tiocmget, | 2742 | .tiocmget = edge_tiocmget, |
| @@ -2775,6 +2768,7 @@ static struct usb_serial_driver edgeport_2port_device = { | |||
| 2775 | .disconnect = edge_disconnect, | 2768 | .disconnect = edge_disconnect, |
| 2776 | .release = edge_release, | 2769 | .release = edge_release, |
| 2777 | .port_probe = edge_create_sysfs_attrs, | 2770 | .port_probe = edge_create_sysfs_attrs, |
| 2771 | .port_remove = edge_remove_sysfs_attrs, | ||
| 2778 | .ioctl = edge_ioctl, | 2772 | .ioctl = edge_ioctl, |
| 2779 | .set_termios = edge_set_termios, | 2773 | .set_termios = edge_set_termios, |
| 2780 | .tiocmget = edge_tiocmget, | 2774 | .tiocmget = edge_tiocmget, |
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index 5d3beeeb5fd9..a92a3efb507b 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c | |||
| @@ -38,7 +38,7 @@ | |||
| 38 | #include <linux/ioctl.h> | 38 | #include <linux/ioctl.h> |
| 39 | #include "kobil_sct.h" | 39 | #include "kobil_sct.h" |
| 40 | 40 | ||
| 41 | static int debug; | 41 | static bool debug; |
| 42 | 42 | ||
| 43 | /* Version Information */ | 43 | /* Version Information */ |
| 44 | #define DRIVER_VERSION "21/05/2004" | 44 | #define DRIVER_VERSION "21/05/2004" |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 420d9857394a..ea126a4490cd 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
| @@ -480,6 +480,10 @@ static void option_instat_callback(struct urb *urb); | |||
| 480 | #define ZD_VENDOR_ID 0x0685 | 480 | #define ZD_VENDOR_ID 0x0685 |
| 481 | #define ZD_PRODUCT_7000 0x7000 | 481 | #define ZD_PRODUCT_7000 0x7000 |
| 482 | 482 | ||
| 483 | /* LG products */ | ||
| 484 | #define LG_VENDOR_ID 0x1004 | ||
| 485 | #define LG_PRODUCT_L02C 0x618f | ||
| 486 | |||
| 483 | /* some devices interfaces need special handling due to a number of reasons */ | 487 | /* some devices interfaces need special handling due to a number of reasons */ |
| 484 | enum option_blacklist_reason { | 488 | enum option_blacklist_reason { |
| 485 | OPTION_BLACKLIST_NONE = 0, | 489 | OPTION_BLACKLIST_NONE = 0, |
| @@ -1183,6 +1187,7 @@ static const struct usb_device_id option_ids[] = { | |||
| 1183 | { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU526) }, | 1187 | { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU526) }, |
| 1184 | { USB_DEVICE_AND_INTERFACE_INFO(VIETTEL_VENDOR_ID, VIETTEL_PRODUCT_VT1000, 0xff, 0xff, 0xff) }, | 1188 | { USB_DEVICE_AND_INTERFACE_INFO(VIETTEL_VENDOR_ID, VIETTEL_PRODUCT_VT1000, 0xff, 0xff, 0xff) }, |
| 1185 | { USB_DEVICE_AND_INTERFACE_INFO(ZD_VENDOR_ID, ZD_PRODUCT_7000, 0xff, 0xff, 0xff) }, | 1189 | { USB_DEVICE_AND_INTERFACE_INFO(ZD_VENDOR_ID, ZD_PRODUCT_7000, 0xff, 0xff, 0xff) }, |
| 1190 | { USB_DEVICE(LG_VENDOR_ID, LG_PRODUCT_L02C) }, /* docomo L-02C modem */ | ||
| 1186 | { } /* Terminating entry */ | 1191 | { } /* Terminating entry */ |
| 1187 | }; | 1192 | }; |
| 1188 | MODULE_DEVICE_TABLE(usb, option_ids); | 1193 | MODULE_DEVICE_TABLE(usb, option_ids); |
diff --git a/drivers/usb/serial/qcaux.c b/drivers/usb/serial/qcaux.c index 30b73e68a904..a34819884c1a 100644 --- a/drivers/usb/serial/qcaux.c +++ b/drivers/usb/serial/qcaux.c | |||
| @@ -36,6 +36,7 @@ | |||
| 36 | #define UTSTARCOM_PRODUCT_UM175_V1 0x3712 | 36 | #define UTSTARCOM_PRODUCT_UM175_V1 0x3712 |
| 37 | #define UTSTARCOM_PRODUCT_UM175_V2 0x3714 | 37 | #define UTSTARCOM_PRODUCT_UM175_V2 0x3714 |
| 38 | #define UTSTARCOM_PRODUCT_UM175_ALLTEL 0x3715 | 38 | #define UTSTARCOM_PRODUCT_UM175_ALLTEL 0x3715 |
| 39 | #define PANTECH_PRODUCT_UML190_VZW 0x3716 | ||
| 39 | #define PANTECH_PRODUCT_UML290_VZW 0x3718 | 40 | #define PANTECH_PRODUCT_UML290_VZW 0x3718 |
| 40 | 41 | ||
| 41 | /* CMOTECH devices */ | 42 | /* CMOTECH devices */ |
| @@ -67,7 +68,11 @@ static struct usb_device_id id_table[] = { | |||
| 67 | { USB_DEVICE_AND_INTERFACE_INFO(LG_VENDOR_ID, LG_PRODUCT_VX4400_6000, 0xff, 0xff, 0x00) }, | 68 | { USB_DEVICE_AND_INTERFACE_INFO(LG_VENDOR_ID, LG_PRODUCT_VX4400_6000, 0xff, 0xff, 0x00) }, |
| 68 | { USB_DEVICE_AND_INTERFACE_INFO(SANYO_VENDOR_ID, SANYO_PRODUCT_KATANA_LX, 0xff, 0xff, 0x00) }, | 69 | { USB_DEVICE_AND_INTERFACE_INFO(SANYO_VENDOR_ID, SANYO_PRODUCT_KATANA_LX, 0xff, 0xff, 0x00) }, |
| 69 | { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_U520, 0xff, 0x00, 0x00) }, | 70 | { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_U520, 0xff, 0x00, 0x00) }, |
| 70 | { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML290_VZW, 0xff, 0xff, 0xff) }, | 71 | { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML190_VZW, 0xff, 0xff, 0xff) }, |
| 72 | { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML190_VZW, 0xff, 0xfe, 0xff) }, | ||
| 73 | { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML290_VZW, 0xff, 0xfd, 0xff) }, /* NMEA */ | ||
| 74 | { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML290_VZW, 0xff, 0xfe, 0xff) }, /* WMC */ | ||
| 75 | { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML290_VZW, 0xff, 0xff, 0xff) }, /* DIAG */ | ||
| 71 | { }, | 76 | { }, |
| 72 | }; | 77 | }; |
| 73 | MODULE_DEVICE_TABLE(usb, id_table); | 78 | MODULE_DEVICE_TABLE(usb, id_table); |
diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c index 1f62723ef1a8..d32f72061c09 100644 --- a/drivers/usb/storage/realtek_cr.c +++ b/drivers/usb/storage/realtek_cr.c | |||
| @@ -789,7 +789,7 @@ static void rts51x_suspend_timer_fn(unsigned long data) | |||
| 789 | rts51x_set_stat(chip, RTS51X_STAT_SS); | 789 | rts51x_set_stat(chip, RTS51X_STAT_SS); |
| 790 | /* ignore mass storage interface's children */ | 790 | /* ignore mass storage interface's children */ |
| 791 | pm_suspend_ignore_children(&us->pusb_intf->dev, true); | 791 | pm_suspend_ignore_children(&us->pusb_intf->dev, true); |
| 792 | usb_autopm_put_interface(us->pusb_intf); | 792 | usb_autopm_put_interface_async(us->pusb_intf); |
| 793 | US_DEBUGP("%s: RTS51X_STAT_SS 01," | 793 | US_DEBUGP("%s: RTS51X_STAT_SS 01," |
| 794 | "intf->pm_usage_cnt:%d, power.usage:%d\n", | 794 | "intf->pm_usage_cnt:%d, power.usage:%d\n", |
| 795 | __func__, | 795 | __func__, |
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c index 8efeae24764f..b4a71679c933 100644 --- a/drivers/usb/usb-skeleton.c +++ b/drivers/usb/usb-skeleton.c | |||
| @@ -27,8 +27,6 @@ | |||
| 27 | #define USB_SKEL_VENDOR_ID 0xfff0 | 27 | #define USB_SKEL_VENDOR_ID 0xfff0 |
| 28 | #define USB_SKEL_PRODUCT_ID 0xfff0 | 28 | #define USB_SKEL_PRODUCT_ID 0xfff0 |
| 29 | 29 | ||
| 30 | static DEFINE_MUTEX(skel_mutex); | ||
| 31 | |||
| 32 | /* table of devices that work with this driver */ | 30 | /* table of devices that work with this driver */ |
| 33 | static const struct usb_device_id skel_table[] = { | 31 | static const struct usb_device_id skel_table[] = { |
| 34 | { USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) }, | 32 | { USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) }, |
| @@ -101,25 +99,18 @@ static int skel_open(struct inode *inode, struct file *file) | |||
| 101 | goto exit; | 99 | goto exit; |
| 102 | } | 100 | } |
| 103 | 101 | ||
| 104 | mutex_lock(&skel_mutex); | ||
| 105 | dev = usb_get_intfdata(interface); | 102 | dev = usb_get_intfdata(interface); |
| 106 | if (!dev) { | 103 | if (!dev) { |
| 107 | mutex_unlock(&skel_mutex); | ||
| 108 | retval = -ENODEV; | 104 | retval = -ENODEV; |
| 109 | goto exit; | 105 | goto exit; |
| 110 | } | 106 | } |
| 111 | 107 | ||
| 112 | /* increment our usage count for the device */ | 108 | /* increment our usage count for the device */ |
| 113 | kref_get(&dev->kref); | 109 | kref_get(&dev->kref); |
| 114 | mutex_unlock(&skel_mutex); | ||
| 115 | 110 | ||
| 116 | /* lock the device to allow correctly handling errors | 111 | /* lock the device to allow correctly handling errors |
| 117 | * in resumption */ | 112 | * in resumption */ |
| 118 | mutex_lock(&dev->io_mutex); | 113 | mutex_lock(&dev->io_mutex); |
| 119 | if (!dev->interface) { | ||
| 120 | retval = -ENODEV; | ||
| 121 | goto out_err; | ||
| 122 | } | ||
| 123 | 114 | ||
| 124 | retval = usb_autopm_get_interface(interface); | 115 | retval = usb_autopm_get_interface(interface); |
| 125 | if (retval) | 116 | if (retval) |
| @@ -127,11 +118,7 @@ static int skel_open(struct inode *inode, struct file *file) | |||
| 127 | 118 | ||
| 128 | /* save our object in the file's private structure */ | 119 | /* save our object in the file's private structure */ |
| 129 | file->private_data = dev; | 120 | file->private_data = dev; |
| 130 | |||
| 131 | out_err: | ||
| 132 | mutex_unlock(&dev->io_mutex); | 121 | mutex_unlock(&dev->io_mutex); |
| 133 | if (retval) | ||
| 134 | kref_put(&dev->kref, skel_delete); | ||
| 135 | 122 | ||
| 136 | exit: | 123 | exit: |
| 137 | return retval; | 124 | return retval; |
| @@ -611,6 +598,7 @@ static void skel_disconnect(struct usb_interface *interface) | |||
| 611 | int minor = interface->minor; | 598 | int minor = interface->minor; |
| 612 | 599 | ||
| 613 | dev = usb_get_intfdata(interface); | 600 | dev = usb_get_intfdata(interface); |
| 601 | usb_set_intfdata(interface, NULL); | ||
| 614 | 602 | ||
| 615 | /* give back our minor */ | 603 | /* give back our minor */ |
| 616 | usb_deregister_dev(interface, &skel_class); | 604 | usb_deregister_dev(interface, &skel_class); |
| @@ -622,12 +610,8 @@ static void skel_disconnect(struct usb_interface *interface) | |||
| 622 | 610 | ||
| 623 | usb_kill_anchored_urbs(&dev->submitted); | 611 | usb_kill_anchored_urbs(&dev->submitted); |
| 624 | 612 | ||
| 625 | mutex_lock(&skel_mutex); | ||
| 626 | usb_set_intfdata(interface, NULL); | ||
| 627 | |||
| 628 | /* decrement our usage count */ | 613 | /* decrement our usage count */ |
| 629 | kref_put(&dev->kref, skel_delete); | 614 | kref_put(&dev->kref, skel_delete); |
| 630 | mutex_unlock(&skel_mutex); | ||
| 631 | 615 | ||
| 632 | dev_info(&interface->dev, "USB Skeleton #%d now disconnected", minor); | 616 | dev_info(&interface->dev, "USB Skeleton #%d now disconnected", minor); |
| 633 | } | 617 | } |
diff --git a/drivers/usb/wusbcore/Kconfig b/drivers/usb/wusbcore/Kconfig index 0ead8826ec79..f29fdd7f6d75 100644 --- a/drivers/usb/wusbcore/Kconfig +++ b/drivers/usb/wusbcore/Kconfig | |||
| @@ -6,7 +6,7 @@ config USB_WUSB | |||
| 6 | depends on EXPERIMENTAL | 6 | depends on EXPERIMENTAL |
| 7 | depends on USB | 7 | depends on USB |
| 8 | depends on PCI | 8 | depends on PCI |
| 9 | select UWB | 9 | depends on UWB |
| 10 | select CRYPTO | 10 | select CRYPTO |
| 11 | select CRYPTO_BLKCIPHER | 11 | select CRYPTO_BLKCIPHER |
| 12 | select CRYPTO_CBC | 12 | select CRYPTO_CBC |
diff --git a/include/linux/usb/langwell_otg.h b/include/linux/usb/langwell_otg.h deleted file mode 100644 index 51f17b16d312..000000000000 --- a/include/linux/usb/langwell_otg.h +++ /dev/null | |||
| @@ -1,139 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Intel Langwell USB OTG transceiver driver | ||
| 3 | * Copyright (C) 2008 - 2010, Intel Corporation. | ||
| 4 | * | ||
| 5 | * This program is free software; you can redistribute it and/or modify it | ||
| 6 | * under the terms and conditions of the GNU General Public License, | ||
| 7 | * version 2, as published by the Free Software Foundation. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 12 | * more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License along with | ||
| 15 | * this program; if not, write to the Free Software Foundation, Inc., | ||
| 16 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 17 | * | ||
| 18 | */ | ||
| 19 | |||
| 20 | #ifndef __LANGWELL_OTG_H | ||
| 21 | #define __LANGWELL_OTG_H | ||
| 22 | |||
| 23 | #include <linux/usb/intel_mid_otg.h> | ||
| 24 | |||
| 25 | #define CI_USBCMD 0x30 | ||
| 26 | # define USBCMD_RST BIT(1) | ||
| 27 | # define USBCMD_RS BIT(0) | ||
| 28 | #define CI_USBSTS 0x34 | ||
| 29 | # define USBSTS_SLI BIT(8) | ||
| 30 | # define USBSTS_URI BIT(6) | ||
| 31 | # define USBSTS_PCI BIT(2) | ||
| 32 | #define CI_PORTSC1 0x74 | ||
| 33 | # define PORTSC_PP BIT(12) | ||
| 34 | # define PORTSC_LS (BIT(11) | BIT(10)) | ||
| 35 | # define PORTSC_SUSP BIT(7) | ||
| 36 | # define PORTSC_CCS BIT(0) | ||
| 37 | #define CI_HOSTPC1 0xb4 | ||
| 38 | # define HOSTPC1_PHCD BIT(22) | ||
| 39 | #define CI_OTGSC 0xf4 | ||
| 40 | # define OTGSC_DPIE BIT(30) | ||
| 41 | # define OTGSC_1MSE BIT(29) | ||
| 42 | # define OTGSC_BSEIE BIT(28) | ||
| 43 | # define OTGSC_BSVIE BIT(27) | ||
| 44 | # define OTGSC_ASVIE BIT(26) | ||
| 45 | # define OTGSC_AVVIE BIT(25) | ||
| 46 | # define OTGSC_IDIE BIT(24) | ||
| 47 | # define OTGSC_DPIS BIT(22) | ||
| 48 | # define OTGSC_1MSS BIT(21) | ||
| 49 | # define OTGSC_BSEIS BIT(20) | ||
| 50 | # define OTGSC_BSVIS BIT(19) | ||
| 51 | # define OTGSC_ASVIS BIT(18) | ||
| 52 | # define OTGSC_AVVIS BIT(17) | ||
| 53 | # define OTGSC_IDIS BIT(16) | ||
| 54 | # define OTGSC_DPS BIT(14) | ||
| 55 | # define OTGSC_1MST BIT(13) | ||
| 56 | # define OTGSC_BSE BIT(12) | ||
| 57 | # define OTGSC_BSV BIT(11) | ||
| 58 | # define OTGSC_ASV BIT(10) | ||
| 59 | # define OTGSC_AVV BIT(9) | ||
| 60 | # define OTGSC_ID BIT(8) | ||
| 61 | # define OTGSC_HABA BIT(7) | ||
| 62 | # define OTGSC_HADP BIT(6) | ||
| 63 | # define OTGSC_IDPU BIT(5) | ||
| 64 | # define OTGSC_DP BIT(4) | ||
| 65 | # define OTGSC_OT BIT(3) | ||
| 66 | # define OTGSC_HAAR BIT(2) | ||
| 67 | # define OTGSC_VC BIT(1) | ||
| 68 | # define OTGSC_VD BIT(0) | ||
| 69 | # define OTGSC_INTEN_MASK (0x7f << 24) | ||
| 70 | # define OTGSC_INT_MASK (0x5f << 24) | ||
| 71 | # define OTGSC_INTSTS_MASK (0x7f << 16) | ||
| 72 | #define CI_USBMODE 0xf8 | ||
| 73 | # define USBMODE_CM (BIT(1) | BIT(0)) | ||
| 74 | # define USBMODE_IDLE 0 | ||
| 75 | # define USBMODE_DEVICE 0x2 | ||
| 76 | # define USBMODE_HOST 0x3 | ||
| 77 | #define USBCFG_ADDR 0xff10801c | ||
| 78 | #define USBCFG_LEN 4 | ||
| 79 | # define USBCFG_VBUSVAL BIT(14) | ||
| 80 | # define USBCFG_AVALID BIT(13) | ||
| 81 | # define USBCFG_BVALID BIT(12) | ||
| 82 | # define USBCFG_SESEND BIT(11) | ||
| 83 | |||
| 84 | #define INTR_DUMMY_MASK (USBSTS_SLI | USBSTS_URI | USBSTS_PCI) | ||
| 85 | |||
| 86 | enum langwell_otg_timer_type { | ||
| 87 | TA_WAIT_VRISE_TMR, | ||
| 88 | TA_WAIT_BCON_TMR, | ||
| 89 | TA_AIDL_BDIS_TMR, | ||
| 90 | TB_ASE0_BRST_TMR, | ||
| 91 | TB_SE0_SRP_TMR, | ||
| 92 | TB_SRP_INIT_TMR, | ||
| 93 | TB_SRP_FAIL_TMR, | ||
| 94 | TB_BUS_SUSPEND_TMR | ||
| 95 | }; | ||
| 96 | |||
| 97 | #define TA_WAIT_VRISE 100 | ||
| 98 | #define TA_WAIT_BCON 30000 | ||
| 99 | #define TA_AIDL_BDIS 15000 | ||
| 100 | #define TB_ASE0_BRST 5000 | ||
| 101 | #define TB_SE0_SRP 2 | ||
| 102 | #define TB_SRP_INIT 100 | ||
| 103 | #define TB_SRP_FAIL 5500 | ||
| 104 | #define TB_BUS_SUSPEND 500 | ||
| 105 | |||
| 106 | struct langwell_otg_timer { | ||
| 107 | unsigned long expires; /* Number of count increase to timeout */ | ||
| 108 | unsigned long count; /* Tick counter */ | ||
| 109 | void (*function)(unsigned long); /* Timeout function */ | ||
| 110 | unsigned long data; /* Data passed to function */ | ||
| 111 | struct list_head list; | ||
| 112 | }; | ||
| 113 | |||
| 114 | struct langwell_otg { | ||
| 115 | struct intel_mid_otg_xceiv iotg; | ||
| 116 | struct device *dev; | ||
| 117 | |||
| 118 | void __iomem *usbcfg; /* SCCBUSB config Reg */ | ||
| 119 | |||
| 120 | unsigned region; | ||
| 121 | unsigned cfg_region; | ||
| 122 | |||
| 123 | struct work_struct work; | ||
| 124 | struct workqueue_struct *qwork; | ||
| 125 | struct timer_list hsm_timer; | ||
| 126 | |||
| 127 | spinlock_t lock; | ||
| 128 | spinlock_t wq_lock; | ||
| 129 | |||
| 130 | struct notifier_block iotg_notifier; | ||
| 131 | }; | ||
| 132 | |||
| 133 | static inline | ||
| 134 | struct langwell_otg *mid_xceiv_to_lnw(struct intel_mid_otg_xceiv *iotg) | ||
| 135 | { | ||
| 136 | return container_of(iotg, struct langwell_otg, iotg); | ||
| 137 | } | ||
| 138 | |||
| 139 | #endif /* __LANGWELL_OTG_H__ */ | ||
