firefly-linux-kernel-4.4.55.git
12 years agoUSB: add quirk for another camera
Oliver Neukum [Tue, 3 Jan 2012 08:58:54 +0000 (09:58 +0100)]
USB: add quirk for another camera

The Guillemot Webcam Hercules Dualpix Exchange camera
has been reported with a second ID.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
12 years agodrivers: usb: wusbcore: Fix dependency for USB_WUSB
Fabio Estevam [Tue, 3 Jan 2012 18:34:49 +0000 (16:34 -0200)]
drivers: usb: wusbcore: Fix dependency for USB_WUSB

Fix the following warning:

warning: (USB_WUSB) selects UWB which has unmet direct dependencies (EXPERIMENTAL && PCI)

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
12 years agoxhci: Better debugging for critical host errors.
Sarah Sharp [Thu, 1 Dec 2011 22:50:30 +0000 (14:50 -0800)]
xhci: Better debugging for critical host errors.

When a host controller gives a bad event TRB, we should print out the
contents of the TRB as a warning so that users don't have to recompile
their kernel to get information about what went wrong.  Also, print out
the event ring if they have xHCI debugging turned on, since previous
events can often explain what happened before the bad TRB occurred.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
12 years agoxhci: Be less verbose during URB cancellation.
Sarah Sharp [Tue, 20 Dec 2011 00:56:04 +0000 (16:56 -0800)]
xhci: Be less verbose during URB cancellation.

With devices that can need up to 128 segments (with 64 TRBs per
segment), we can't afford to print out the entire endpoint ring every
time an URB is canceled.  Instead, print the offset of the TRB, along
with device pathname and endpoint number.

Only print DMA addresses, since virtual addresses of internal structures
are not useful.  Change the cancellation code to be more clear about
what steps of the cancellation it is in the process of doing (queueing
the request, handling the stop endpoint command, turning the TDs into
no-ops, or moving the dequeue pointers).

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
12 years agoxhci: Remove debugging about ring structure allocation.
Sarah Sharp [Thu, 1 Dec 2011 22:41:46 +0000 (14:41 -0800)]
xhci: Remove debugging about ring structure allocation.

Debuggers only really care what the xHCI driver sets the ring dequeue
pointer to, so make the driver stop babbling about the memory addresses
of internal ring structures.  This makes wading through the output of
allocating and freeing 256 stream rings much easier by reducing the
number of output lines per ring from 9 to 1.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
12 years agoxhci: Remove debugging about toggling cycle bits.
Sarah Sharp [Fri, 16 Dec 2011 01:30:45 +0000 (17:30 -0800)]
xhci: Remove debugging about toggling cycle bits.

The code for toggling the cycle bits when the ring wraps around has
worked for years.  The print statement alone is not enough to indicate
there's something wrong with that code.  Now that full transfer tracing
has been ripped out, the print statement or lack thereof won't help
without context of where the enqueue pointer is.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
12 years agoxhci: Remove debugging for individual transfers.
Sarah Sharp [Thu, 22 Dec 2011 23:42:25 +0000 (15:42 -0800)]
xhci: Remove debugging for individual transfers.

Users can trace the submission of URBs through USBmon, so it makes no
sense to have duplicate debugging in the xHCI driver.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
12 years agoxhci: Remove useless sg-list debugging.
Sarah Sharp [Tue, 25 Oct 2011 11:55:30 +0000 (13:55 +0200)]
xhci: Remove useless sg-list debugging.

Remove verbose debugging about scatter-gather lists, as we haven't had
an issue with scatter gather list math for about a year now.  The
debugging didn't help before, and just clutters up the log file when
trying to debug other issues.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
12 years agoxhci: Remove warnings about MSI and MSI-X capabilities.
Sarah Sharp [Thu, 22 Dec 2011 23:02:13 +0000 (15:02 -0800)]
xhci: Remove warnings about MSI and MSI-X capabilities.

xHCI host controllers may not be capable of MSI, but they should be able
to be used in legacy PCI interrupt mode.  Similarly, some xHCI host
controllers will have MSI support but not MSI-X support.  Lower the
dmesg log level from an error to debug.  The message won't appear unless
CONFIG_USB_XHCI_HCD_DEBUGGING is turned on.

If we need to find out whether the device can support MSI or MSI-X and
it's not being enabled by the driver, it's easy to ask the user to run
lspci.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
12 years agoxhci: Remove scary warnings about transfer issues.
Sarah Sharp [Tue, 25 Oct 2011 11:55:30 +0000 (13:55 +0200)]
xhci: Remove scary warnings about transfer issues.

Getting a short packet or a babble error is usually a recoverable error,
so stop scaring users with warnings in dmesg when xHCI debugging is turned
off.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
12 years agoTrivial: xhci: Fix copy-paste error.
Sarah Sharp [Tue, 28 Jun 2011 22:50:19 +0000 (15:50 -0700)]
Trivial: xhci: Fix copy-paste error.

The xHCI driver will create an xhci_hcd structure, not an ehci_hci
structure.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
12 years agousbfs: Fix oops related to user namespace conversion.
Sarah Sharp [Fri, 16 Dec 2011 19:26:30 +0000 (11:26 -0800)]
usbfs: Fix oops related to user namespace conversion.

When running the Point Grey "flycap" program for their USB 3.0 camera
(which was running as a USB 2.0 device for some reason), I trigger this
oops whenever I try to open a video stream:

Dec 15 16:48:34 puck kernel: [ 1798.715559] BUG: unable to handle kernel NULL pointer dereference at           (null)
Dec 15 16:48:34 puck kernel: [ 1798.719153] IP: [<ffffffff8147841e>] free_async+0x1e/0x70
Dec 15 16:48:34 puck kernel: [ 1798.720991] PGD 6f833067 PUD 6fc56067 PMD 0
Dec 15 16:48:34 puck kernel: [ 1798.722815] Oops: 0002 [#1] SMP
Dec 15 16:48:34 puck kernel: [ 1798.724627] CPU 0
Dec 15 16:48:34 puck kernel: [ 1798.724636] Modules linked in: ecryptfs encrypted_keys sha1_generic trusted binfmt_misc sha256_generic aesni_intel cryptd aes_x86_64 aes_generic parport_pc dm_crypt ppdev joydev snd_hda_codec_hdmi snd_hda_codec_conexant arc4 iwlwifi snd_hda_intel snd_hda_codec snd_hwdep snd_pcm thinkpad_acpi mac80211 snd_seq_midi snd_rawmidi snd_seq_midi_event snd_seq snd_timer btusb uvcvideo snd_seq_device bluetooth videodev psmouse snd v4l2_compat_ioctl32 serio_raw tpm_tis cfg80211 tpm tpm_bios nvram soundcore snd_page_alloc lp parport i915 xhci_hcd ahci libahci drm_kms_helper drm sdhci_pci sdhci e1000e i2c_algo_bit video
Dec 15 16:48:34 puck kernel: [ 1798.734212]
Dec 15 16:48:34 puck kernel: [ 1798.736162] Pid: 2713, comm: FlyCap2 Not tainted 3.2.0-rc5+ #28 LENOVO 4286CTO/4286CTO
Dec 15 16:48:34 puck kernel: [ 1798.738148] RIP: 0010:[<ffffffff8147841e>]  [<ffffffff8147841e>] free_async+0x1e/0x70
Dec 15 16:48:34 puck kernel: [ 1798.740134] RSP: 0018:ffff88005715fd78  EFLAGS: 00010296
Dec 15 16:48:34 puck kernel: [ 1798.742118] RAX: 00000000fffffff4 RBX: ffff88006fe8f900 RCX: 0000000000004118
Dec 15 16:48:34 puck kernel: [ 1798.744116] RDX: 0000000001000000 RSI: 0000000000016390 RDI: 0000000000000000
Dec 15 16:48:34 puck kernel: [ 1798.746087] RBP: ffff88005715fd88 R08: 0000000000000000 R09: ffffffff8146f22e
Dec 15 16:48:34 puck kernel: [ 1798.748018] R10: ffff88006e520ac0 R11: 0000000000000001 R12: ffff88005715fe28
Dec 15 16:48:34 puck kernel: [ 1798.749916] R13: ffff88005d31df00 R14: ffff88006fe8f900 R15: 00007f688c995cb8
Dec 15 16:48:34 puck kernel: [ 1798.751785] FS:  00007f68a366da40(0000) GS:ffff880100200000(0000) knlGS:0000000000000000
Dec 15 16:48:34 puck kernel: [ 1798.753659] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
Dec 15 16:48:34 puck kernel: [ 1798.755509] CR2: 0000000000000000 CR3: 00000000706bb000 CR4: 00000000000406f0
Dec 15 16:48:34 puck kernel: [ 1798.757334] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
Dec 15 16:48:34 puck kernel: [ 1798.759124] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Dec 15 16:48:34 puck kernel: [ 1798.760871] Process FlyCap2 (pid: 2713, threadinfo ffff88005715e000, task ffff88006c675b80)
Dec 15 16:48:34 puck kernel: [ 1798.762605] Stack:
Dec 15 16:48:34 puck kernel: [ 1798.764297]  ffff88005715fe28 0000000000000000 ffff88005715fe08 ffffffff81479058
Dec 15 16:48:34 puck kernel: [ 1798.766020]  0000000000000000 ffffea0000004000 ffff880000004118 0000000000000000
Dec 15 16:48:34 puck kernel: [ 1798.767750]  ffff880000000001 ffff88006e520ac0 fffffff46fd81180 0000000000000000
Dec 15 16:48:34 puck kernel: [ 1798.769472] Call Trace:
Dec 15 16:48:34 puck kernel: [ 1798.771147]  [<ffffffff81479058>] proc_do_submiturb+0x778/0xa00
Dec 15 16:48:34 puck kernel: [ 1798.772798]  [<ffffffff8147a5fd>] usbdev_do_ioctl+0x24d/0x1200
Dec 15 16:48:34 puck kernel: [ 1798.774410]  [<ffffffff8147b5de>] usbdev_ioctl+0xe/0x20
Dec 15 16:48:34 puck kernel: [ 1798.775975]  [<ffffffff81189259>] do_vfs_ioctl+0x99/0x600
Dec 15 16:48:34 puck kernel: [ 1798.777534]  [<ffffffff81189851>] sys_ioctl+0x91/0xa0
Dec 15 16:48:34 puck kernel: [ 1798.779088]  [<ffffffff816247c2>] system_call_fastpath+0x16/0x1b
ec 15 16:48:34 puck kernel: [ 1798.780634] Code: 51 ff ff ff e9 29 ff ff ff 0f 1f 40 00 55 48 89 e5 53 48 83 ec 08 66 66 66 66 90 48 89 fb 48 8b 7f 18 e8 a6 ea c0 ff 4
8 8b 7b 20 <f0> ff 0f 0f 94 c0 84 c0 74 05 e8 d3 99 c1 ff 48 8b 43 40 48 8b
Dec 15 16:48:34 puck kernel: [ 1798.783970] RIP  [<ffffffff8147841e>] free_async+0x1e/0x70
Dec 15 16:48:34 puck kernel: [ 1798.785630]  RSP <ffff88005715fd78>
Dec 15 16:48:34 puck kernel: [ 1798.787274] CR2: 0000000000000000
Dec 15 16:48:34 puck kernel: [ 1798.794728] ---[ end trace 52894d3355f88d19 ]---

markup_oops.pl says the oops is in put_cred:

 ffffffff81478401:      48 89 e5                mov    %rsp,%rbp
 ffffffff81478404:      53                      push   %rbx
 ffffffff81478405:      48 83 ec 08             sub    $0x8,%rsp
 ffffffff81478409:      e8 f2 c0 1a 00          callq  ffffffff81624500 <mcount>
 ffffffff8147840e:      48 89 fb                mov    %rdi,%rbx   |  %ebx => ffff88006fe8f900
        put_pid(as->pid);
 ffffffff81478411:      48 8b 7f 18             mov    0x18(%rdi),%rdi
 ffffffff81478415:      e8 a6 ea c0 ff          callq  ffffffff81086ec0 <put_pid>
        put_cred(as->cred);
 ffffffff8147841a:      48 8b 7b 20             mov    0x20(%rbx),%rdi |  %edi => 0  %ebx = ffff88006fe8f900
  */
 static inline int atomic_dec_and_test(atomic_t *v)
 {
        unsigned char c;

        asm volatile(LOCK_PREFIX "decl %0; sete %1"
*ffffffff8147841e:      f0 ff 0f                lock decl (%rdi)   |  %edi = 0 <--- faulting instruction
 ffffffff81478421:      0f 94 c0                sete   %al
 static inline void put_cred(const struct cred *_cred)
 {
        struct cred *cred = (struct cred *) _cred;

        validate_creds(cred);
        if (atomic_dec_and_test(&(cred)->usage))
 ffffffff81478424:      84 c0                   test   %al,%al
 ffffffff81478426:      74 05                   je     ffffffff8147842d <free_async+0x2d>
                __put_cred(cred);
 ffffffff81478428:      e8 d3 99 c1 ff          callq  ffffffff81091e00 <__put_cred>
        kfree(as->urb->transfer_buffer);
 ffffffff8147842d:      48 8b 43 40             mov    0x40(%rbx),%rax
 ffffffff81478431:      48 8b 78 68             mov    0x68(%rax),%rdi
 ffffffff81478435:      e8 a6 e1 ce ff          callq  ffffffff811665e0 <kfree>
        kfree(as->urb->setup_packet);
 ffffffff8147843a:      48 8b 43 40             mov    0x40(%rbx),%rax
 ffffffff8147843e:      48 8b b8 90 00 00 00    mov    0x90(%rax),%rdi
 ffffffff81478445:      e8 96 e1 ce ff          callq  ffffffff811665e0 <kfree>
        usb_free_urb(as->urb);
 ffffffff8147844a:      48 8b 7b 40             mov    0x40(%rbx),%rdi
 ffffffff8147844e:      e8 0d 6b ff ff          callq  ffffffff8146ef60 <usb_free_urb>

This bug seems to have been introduced by commit
d178bc3a708f39cbfefc3fab37032d3f2511b4ec "user namespace: usb: make usb
urbs user namespace aware (v2)"

I'm not sure if this is right fix, but it does stop the oops.

Unfortunately, the Point Grey software still refuses to work, but it's a
closed source app, so I can't fix it.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
12 years agoMerge branch 'for-gadget/next' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi...
Greg Kroah-Hartman [Thu, 22 Dec 2011 22:05:01 +0000 (14:05 -0800)]
Merge branch 'for-gadget/next' of git://git./linux/kernel/git/balbi/usb into usb-next

* 'for-gadget/next' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb: (24 commits)
  usb: dwc3: gadget: add support for SG lists
  usb: dwc3: gadget: don't force 'LST' always
  usb: dwc3: gadget: don't return anything on prepare trbs
  usb: dwc3: gadget: re-factor dwc3_prepare_trbs()
  usb: gadget: introduce support for sg lists
  usb: renesas: pipe: convert a long if into a XOR operation
  usb: gadget: remove useless depends on Kconfig
  usb: gadget: s3c-hsudc: remove the_controller global
  usb: gadget: s3c-hsudc: use release_mem_region instead of release_resource
  usb: gadget: s3c-hsudc: Add regulator handling
  usb: gadget: s3c-hsudc: use udc_start and udc_stop functions
  usb: gadget: s3c-hsudc: move device registration to probe
  usb: gadget: s3c-hsudc: add missing otg_put_transceiver in probe
  usb: gadget: s3c-hsudc: add __devinit to probe function
  usb: gadget: s3c-hsudc: move platform_data struct to global header
  USB: EHCI: Add Marvell Host Controller driver
  USB: OTG: add Marvell usb OTG driver support
  usb: gadget: mv_udc: drop ARCH dependency
  usb: gadget: mv_udc: fix bug in ep_dequeue
  usb: gadget: enlarge maxburst bit width.
  ...

12 years agoMerge branch 'for-next/dwc3' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi...
Greg Kroah-Hartman [Thu, 22 Dec 2011 22:01:02 +0000 (14:01 -0800)]
Merge branch 'for-next/dwc3' of git://git./linux/kernel/git/balbi/usb into usb-next

* 'for-next/dwc3' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb:
  usb: dwc3: gadget: move us to Default State after reset

12 years agoMerge branch 'for-next/musb' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi...
Greg Kroah-Hartman [Thu, 22 Dec 2011 21:59:53 +0000 (13:59 -0800)]
Merge branch 'for-next/musb' of git://git./linux/kernel/git/balbi/usb into usb-next

* 'for-next/musb' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb:
  usb: musb: remove extern qualifier from musb_debug.h header
  usb: musb: cleanup kconfig
  usb: musb: trivial Kconfig cleanups
  musb: omap2430: avoid pm_runtime_disable()
  usb: musb: remove a bit of indentation
  usb: musb: trivial cleanup
  usb: musb: fix pm_runtime mismatch

12 years agoMerge branch 'for-next/xceiv' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi...
Greg Kroah-Hartman [Thu, 22 Dec 2011 21:58:59 +0000 (13:58 -0800)]
Merge branch 'for-next/xceiv' of git://git./linux/kernel/git/balbi/usb into usb-next

* 'for-next/xceiv' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb:
  usb: otg: trivial cleanups

12 years agousb: dwc3: gadget: add support for SG lists
Felipe Balbi [Mon, 28 Nov 2011 10:46:59 +0000 (12:46 +0200)]
usb: dwc3: gadget: add support for SG lists

add support for SG lists on dwc3 driver. With
this we can e.g. use VFS layer's SG lists on
storage gadgets so that we can start bigger
transfers and improve throughput.

Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: gadget: don't force 'LST' always
Felipe Balbi [Mon, 28 Nov 2011 10:27:17 +0000 (12:27 +0200)]
usb: dwc3: gadget: don't force 'LST' always

the LST bit is to be set on the last of a series
of consecutive TRBs. We had a workaround for a
problem where data would get corrupted but that
doesn't happen anymore. It's likely that it was
caused by some FPGA instability during development
phase.

Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: gadget: don't return anything on prepare trbs
Felipe Balbi [Mon, 28 Nov 2011 10:25:01 +0000 (12:25 +0200)]
usb: dwc3: gadget: don't return anything on prepare trbs

all that function does is setup a TRB to be sent
to HW later. There's no need to return anything
actually.

Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: gadget: re-factor dwc3_prepare_trbs()
Felipe Balbi [Tue, 22 Nov 2011 09:37:34 +0000 (11:37 +0200)]
usb: dwc3: gadget: re-factor dwc3_prepare_trbs()

In order to make it easier to add SG support,
let's split the big loop out to its own function.

Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: gadget: introduce support for sg lists
Felipe Balbi [Tue, 22 Nov 2011 09:11:50 +0000 (11:11 +0200)]
usb: gadget: introduce support for sg lists

Some controllers support scatter/gather transfers
and that might be very useful for some gadget drivers.

This means that we can make use of larger buffer
allocations which means we will have less completion
IRQs overtime, thus improving the perceived performance.

Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: renesas: pipe: convert a long if into a XOR operation
Felipe Balbi [Wed, 21 Dec 2011 11:13:33 +0000 (13:13 +0200)]
usb: renesas: pipe: convert a long if into a XOR operation

This is just a minor optimization for the long
if we have on the driver.

When we want to check that one input is true
and the other must be false, the bitwise XOR
operator will achieve that for us.

Tested-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: gadget: remove useless depends on Kconfig
Felipe Contreras [Tue, 20 Dec 2011 00:42:24 +0000 (02:42 +0200)]
usb: gadget: remove useless depends on Kconfig

Where are inside an 'if USB_GADGET'.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: gadget: s3c-hsudc: remove the_controller global
Heiko Stübner [Mon, 19 Dec 2011 18:43:35 +0000 (19:43 +0100)]
usb: gadget: s3c-hsudc: remove the_controller global

Instead use container_of to retrieve the s3c_hsudc from the
struct usb_gadget pointer.

[ balbi@ti.com : changed verbose container_of() into
an already provided helper 'to_hsudc()' ]

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: gadget: s3c-hsudc: use release_mem_region instead of release_resource
Heiko Stübner [Mon, 19 Dec 2011 18:42:52 +0000 (19:42 +0100)]
usb: gadget: s3c-hsudc: use release_mem_region instead of release_resource

As the memory region is requested through request_mem_region
use the correct paired method to release it in the error path
and don't go "beneath the API".

Reported-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: gadget: s3c-hsudc: Add regulator handling
Heiko Stübner [Mon, 19 Dec 2011 18:42:19 +0000 (19:42 +0100)]
usb: gadget: s3c-hsudc: Add regulator handling

The udc has three supplies: vdda (3.3V), vddi (1.2V) and vddosc (1.8-3.3V).
Turn these on and off on start and stop calls.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: gadget: s3c-hsudc: use udc_start and udc_stop functions
Heiko Stübner [Mon, 19 Dec 2011 18:41:45 +0000 (19:41 +0100)]
usb: gadget: s3c-hsudc: use udc_start and udc_stop functions

udc_start and udc_stop reduce code duplication in comparison to
start and stop generalising calls done by all drivers
(i.e. bind and unbind) and moving these calls to common code.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: gadget: s3c-hsudc: move device registration to probe
Heiko Stübner [Mon, 19 Dec 2011 18:41:05 +0000 (19:41 +0100)]
usb: gadget: s3c-hsudc: move device registration to probe

Instead of adding and deleting the gadget device in the start and stop
invocations. Use device_register in the probe method to initialize
and add the gadget device.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: gadget: s3c-hsudc: add missing otg_put_transceiver in probe
Heiko Stübner [Mon, 19 Dec 2011 18:40:28 +0000 (19:40 +0100)]
usb: gadget: s3c-hsudc: add missing otg_put_transceiver in probe

The number of get and put calls should always be equal.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: gadget: s3c-hsudc: add __devinit to probe function
Heiko Stübner [Mon, 19 Dec 2011 18:39:52 +0000 (19:39 +0100)]
usb: gadget: s3c-hsudc: add __devinit to probe function

Fixes possible section mismatch warnings.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: gadget: s3c-hsudc: move platform_data struct to global header
Heiko Stübner [Mon, 19 Dec 2011 18:39:15 +0000 (19:39 +0100)]
usb: gadget: s3c-hsudc: move platform_data struct to global header

Gadget drivers should be compilable on all architectures.
This patch removes one dependency on architecture-specific code.

Acked-by: Kukjin Kim <kgene.kim@samsung.com>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: musb: remove extern qualifier from musb_debug.h header
Vladimir Zapolskiy [Mon, 19 Dec 2011 14:54:02 +0000 (16:54 +0200)]
usb: musb: remove extern qualifier from musb_debug.h header

This change removes confusing extern qualifier, which doesn't have any practical
sense there.

Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@nokia.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: gadget: move us to Default State after reset
Felipe Balbi [Tue, 20 Dec 2011 13:37:21 +0000 (15:37 +0200)]
usb: dwc3: gadget: move us to Default State after reset

After a bus reset, we should move our state to
Default, in order to be able to re-enumerate again.

I only managed to trigger this problem with g_ether
by removing the cable after a few transfers had been
completed.

Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: otg: trivial cleanups
Felipe Contreras [Tue, 20 Dec 2011 00:42:26 +0000 (02:42 +0200)]
usb: otg: trivial cleanups

Spaces to tabs, proper alignment, and start sentences as they should.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: musb: cleanup kconfig
Felipe Contreras [Tue, 20 Dec 2011 00:42:27 +0000 (02:42 +0200)]
usb: musb: cleanup kconfig

The whole thing depends on USB_MUSB_HDRC, just add an 'if'.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: musb: trivial Kconfig cleanups
Felipe Contreras [Tue, 20 Dec 2011 00:42:22 +0000 (02:42 +0200)]
usb: musb: trivial Kconfig cleanups

Shuffle the code a bit so the description is at the top.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agomusb: omap2430: avoid pm_runtime_disable()
Felipe Contreras [Mon, 19 Dec 2011 20:17:51 +0000 (22:17 +0200)]
musb: omap2430: avoid pm_runtime_disable()

These are handled by drivers core, and in a way that doesn't wake up the
devices.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: musb: remove a bit of indentation
Felipe Contreras [Mon, 19 Dec 2011 20:17:50 +0000 (22:17 +0200)]
usb: musb: remove a bit of indentation

And use dev instead of musb->controller.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: musb: trivial cleanup
Felipe Contreras [Mon, 19 Dec 2011 20:17:49 +0000 (22:17 +0200)]
usb: musb: trivial cleanup

enabled && driver || !enabled can be simplified to !enabled || driver.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: musb: fix pm_runtime mismatch
Felipe Contreras [Mon, 19 Dec 2011 20:01:54 +0000 (22:01 +0200)]
usb: musb: fix pm_runtime mismatch

In musb_init_controller() there's a pm_runtime_put(), but there's no
pm_runtime_get(), which creates a mismatch that causes the driver to
sleep when it shouldn't.

This was introduced in 7acc619[1], but it wasn't triggered in my setup
until 18a2689[2] was merged to Linus' branch at point df0914[3]. IOW;
when PM is working as it was supposed to.

However, it seems most of the time this is used in a way that keeps the
counter above 0, so nobody noticed. Also, it seems to depend on the
configuration used in versions before 3.1, but not later (or in it).

I found the problem by loading isp1704_charger before any usb gadgets:
http://article.gmane.org/gmane.linux.kernel/1226122

All versions after 2.6.39 are affected.

[1] usb: musb: Idle path retention and offmode support for OMAP3
[2] OMAP2+: musb: hwmod adaptation for musb registration
[3] Merge branch 'omap-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap-2.6

Cc: stable@vger.kernel.org
Cc: Hema HK <hemahk@ti.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agoUSB: EHCI: Add Marvell Host Controller driver
Neil Zhang [Tue, 20 Dec 2011 05:20:23 +0000 (13:20 +0800)]
USB: EHCI: Add Marvell Host Controller driver

This patch adds support for EHCI compliant HSUSB Host controller found
on Marvell Socs.

It fits both OTG and SPH controller on marvell Socs, including
PXA9xx/MMP2/MMP3/MGx.

Signed-off-by: Neil Zhang <zhangwm@marvell.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agoUSB: OTG: add Marvell usb OTG driver support
Neil Zhang [Tue, 20 Dec 2011 05:20:22 +0000 (13:20 +0800)]
USB: OTG: add Marvell usb OTG driver support

This driver is for ChipIdea USB OTG controller on Marvell Socs.
PXA9xx/MMP2/MMP3/MGx all have this USB OTG controller.

Signed-off-by: Neil Zhang <zhangwm@marvell.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: gadget: mv_udc: drop ARCH dependency
Neil Zhang [Tue, 20 Dec 2011 05:20:21 +0000 (13:20 +0800)]
usb: gadget: mv_udc: drop ARCH dependency

This patch do the following things:
1. Change the Kconfig information.
2. Rename the driver name.
3. Don't do any type cast to io memory.
4. Add dummy stub for clk framework.

Signed-off-by: Neil Zhang <zhangwm@marvell.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: gadget: mv_udc: fix bug in ep_dequeue
Neil Zhang [Tue, 20 Dec 2011 05:20:20 +0000 (13:20 +0800)]
usb: gadget: mv_udc: fix bug in ep_dequeue

According to ChipIdea's SPEC, we cannot touch curr_dtd_ptr in dqh
directly, use prime endpoint instead.

Signed-off-by: Neil Zhang <zhangwm@marvell.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: gadget: enlarge maxburst bit width.
Yu Xu [Mon, 19 Dec 2011 09:33:03 +0000 (17:33 +0800)]
usb: gadget: enlarge maxburst bit width.

For super speed bulk transfer, the max burst size
is 16, so that 4 bits of maxburst cannot store it.

Signed-off-by: Yu Xu <yuxu@marvell.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: gadget: mv_udc: rewrite queue_dtd according to spec
Neil Zhang [Thu, 15 Dec 2011 11:26:39 +0000 (19:26 +0800)]
usb: gadget: mv_udc: rewrite queue_dtd according to spec

Rewrite function queue_dtd according to ChipIdea's reference manual.
Remove all unnecessary logic, it will enhance the performance.

Signed-off-by: Neil Zhang <zhangwm@marvell.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: gadget: mv_udc: fix readl error
Neil Zhang [Thu, 15 Dec 2011 11:26:38 +0000 (19:26 +0800)]
usb: gadget: mv_udc: fix readl error

readl expected 'const volatile void *' as the argument.

Signed-off-by: Neil Zhang <zhangwm@marvell.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: renesas_usbhs: silence a gcc warning
Dan Carpenter [Thu, 15 Dec 2011 11:31:37 +0000 (14:31 +0300)]
usb: renesas_usbhs: silence a gcc warning

Gcc complains about this printk:
drivers/usb/renesas_usbhs/mod_gadget.c:188:3: warning: format â€˜%x’
expects argument of type â€˜unsigned int’, but argument 3 has type
‘dma_addr_t’ [-Wformat]

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: renesas_usbhs: tidyup for smatch warnings
Kuninori Morimoto [Thu, 15 Dec 2011 09:53:18 +0000 (01:53 -0800)]
usb: renesas_usbhs: tidyup for smatch warnings

This patch tidyup below smatch complaint

drivers/usb/renesas_usbhs/mod_host.c +642 usbhsh_queue_done()
 warn: variable dereferenced before check 'urb' (see line 636)

Special thanks to Dan

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agoMerge branch 'for-next/gadget' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi...
Greg Kroah-Hartman [Tue, 13 Dec 2011 17:37:40 +0000 (09:37 -0800)]
Merge branch 'for-next/gadget' of git://git./linux/kernel/git/balbi/usb into usb-next

* 'for-next/gadget' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb: (50 commits)
  usb: renesas_usbhs: show error reason on usbhsh_urb_enqueu()
  usb: renesas_usbhs: add force packet remove method
  usb: renesas_usbhs: care usb_hcd_giveback_urb() status
  usb: renesas_usbhs: add usbhsh_is_running()
  usb: renesas_usbhs: disable attch irq after device attached
  usb: renesas_usbhs: care pipe sequence
  usb: renesas_usbhs: add usbhs_pipe_attach() method
  usb: renesas_usbhs: add usbhsh_endpoint_detach_all() for error case
  usb: renesas_usbhs: modify device attach method
  usb: renesas_usbhs: pop packet when urb dequeued
  usb: renesas_usbhs: add lost error value when enqueue
  usb: gadget: mv_udc: replace some debug info
  usb: gadget: mv_udc: refine suspend/resume function
  usb: gadget: mv_udc: refine the clock relative code
  usb: gadget: mv_udc: disable ISR when stopped
  usb: gadget: mv_udc: add otg relative code
  usb: gadget: Use kcalloc instead of kzalloc to allocate array
  usb: renesas_usbhs: remove the_controller_link
  usb: renesas_usbhs: add test-mode support
  usb: renesas_usbhs: call usbhsg_queue_pop() when pipe disable.
  ...

12 years agousb: renesas_usbhs: show error reason on usbhsh_urb_enqueu()
Kuninori Morimoto [Fri, 9 Dec 2011 02:31:53 +0000 (18:31 -0800)]
usb: renesas_usbhs: show error reason on usbhsh_urb_enqueu()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: renesas_usbhs: add force packet remove method
Kuninori Morimoto [Fri, 9 Dec 2011 02:31:37 +0000 (18:31 -0800)]
usb: renesas_usbhs: add force packet remove method

Packet should be force removed when reset/detach

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: renesas_usbhs: care usb_hcd_giveback_urb() status
Kuninori Morimoto [Fri, 9 Dec 2011 02:31:11 +0000 (18:31 -0800)]
usb: renesas_usbhs: care usb_hcd_giveback_urb() status

Without this patch, USB host hub shows error when cable was detached

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: renesas_usbhs: add usbhsh_is_running()
Kuninori Morimoto [Fri, 9 Dec 2011 02:30:23 +0000 (18:30 -0800)]
usb: renesas_usbhs: add usbhsh_is_running()

It is possible to judge whether renesas_usbhs driver is running,
by checking attch irq mask.
This patch adds usbhsh_is_running() to check it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: renesas_usbhs: disable attch irq after device attached
Kuninori Morimoto [Fri, 9 Dec 2011 02:29:22 +0000 (18:29 -0800)]
usb: renesas_usbhs: disable attch irq after device attached

attch interrupt might happen infinitely on some USB hub (self power?).
This patch disable attch irq after device attached,
and enable it again when detach irq happen.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: renesas_usbhs: care pipe sequence
Kuninori Morimoto [Fri, 9 Dec 2011 02:28:54 +0000 (18:28 -0800)]
usb: renesas_usbhs: care pipe sequence

driver has to re-use the limited pipe for each device/endpoint
when it is USB host hub mode, since number of pipe has limitation.

Then, each pipe should care own pipe sequence for next packet.
This patch adds sequence control.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: renesas_usbhs: add usbhs_pipe_attach() method
Kuninori Morimoto [Fri, 9 Dec 2011 02:28:24 +0000 (18:28 -0800)]
usb: renesas_usbhs: add usbhs_pipe_attach() method

driver has to re-use the limited pipe for each device/endpoint
when it is USB host hub mode, since number of pipe has limitation.
This patch adds usbhsh_pipe_attach/detach() functions for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: renesas_usbhs: add usbhsh_endpoint_detach_all() for error case
Kuninori Morimoto [Fri, 9 Dec 2011 02:27:49 +0000 (18:27 -0800)]
usb: renesas_usbhs: add usbhsh_endpoint_detach_all() for error case

This patch adds usbhsh_endpoint_detach_all() for error case.
usbhs_endpoitn_xxx() functions were moved to upper side in source code.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: renesas_usbhs: modify device attach method
Kuninori Morimoto [Fri, 9 Dec 2011 02:27:21 +0000 (18:27 -0800)]
usb: renesas_usbhs: modify device attach method

Current renesas_usbhs had been assigning udev to each urb.
It was executed even though it was device0.
For this reason, the device0 had to set the new device address
which has still not been assigned. (it will be assigned on next step).
Current renesas_usbhs used fixed address for it.
but it is not good for USB hub support.
This patch modifies this issue.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agoMerge branch 'for-next/musb' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi...
Greg Kroah-Hartman [Mon, 12 Dec 2011 23:51:41 +0000 (15:51 -0800)]
Merge branch 'for-next/musb' of git://git./linux/kernel/git/balbi/usb into usb-next

* 'for-next/musb' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb:
  usb: musb: omap2430: fix compile warning
  usb: musb: fix pm_runtime calls while atomic
  usb: musb: drop ARCH dependency
  usb: musb: headers cleanup
  usb: musb: allow building USB_MUSB_TUSB6010 as a module
  usb: musb: use a Kconfig choice to pick the right DMA method
  usb: musb: omap2+: save and restore OTG_INTERFSEL
  usb: musb: omap2+: fix context api's
  usb: musb: ux500: optimize DMA callback routine

12 years agoMerge branch 'for-next/dwc3' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi...
Greg Kroah-Hartman [Mon, 12 Dec 2011 23:19:40 +0000 (15:19 -0800)]
Merge branch 'for-next/dwc3' of git://git./linux/kernel/git/balbi/usb into usb-next

* 'for-next/dwc3' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb: (392 commits)
  usb: dwc3: ep0: fix for possible early delayed_status
  usb: dwc3: gadget: fix stream enable bit
  usb: dwc3: ep0: fix GetStatus handling (again)
  usb: dwc3: ep0: use dwc3_request for ep0 requsts instead of usb_request
  usb: dwc3: use correct hwparam register for power mgm check
  usb: dwc3: omap: move to module_platform_driver
  usb: dwc3: workaround: missing disconnect event
  usb: dwc3: workaround: missing USB3 Reset event
  usb: dwc3: workaround: U1/U2 -> U0 transiton
  usb: dwc3: gadget: return early in dwc3_cleanup_done_reqs()
  usb: dwc3: ep0: handle delayed_status again
  usb: dwc3: ep0: push ep0state into xfernotready processing
  usb: dwc3: fix sparse errors
  usb: dwc3: fix few coding style problems
  usb: dwc3: move generic dwc3 code from gadget into core
  usb: dwc3: use a helper function for operation mode setting
  usb: dwc3: ep0: don't use ep0in for transfers
  usb: dwc3: ep0: use proper endianess in SetFeature for wIndex
  usb: dwc3: core: drop DWC3_EVENT_BUFFERS_MAX
  usb: dwc3: omap: add multiple instances support to OMAP
  ...

12 years agoUSB: Remove the duplicate definition of HUB_SET_DEPTH
Qinglin Ye [Sun, 11 Dec 2011 08:40:22 +0000 (16:40 +0800)]
USB: Remove the duplicate definition of HUB_SET_DEPTH

The macro HUB_SET_DEPTH is defined twice in ch11.h (introduced by
commit 0eadcc0 "usb: USB3.0 ch11 definitions" and dbe79bb "USB 3.0
Hub Changes"), so remove the duplicate one in the USB 2.0 part.

Signed-off-by: Qinglin Ye <yestyle@gmail.com>
Cc: John Youn <John.Youn@synopsys.com>
Cc: Sergei Shtylyov <sshtylyov@mvista.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
12 years agousb: musb: omap2430: fix compile warning
Felipe Balbi [Thu, 24 Nov 2011 13:42:10 +0000 (15:42 +0200)]
usb: musb: omap2430: fix compile warning

fix the following compile warning:

drivers/usb/musb/omap2430.c: In function 'musb_otg_notifier_work':
drivers/usb/musb/omap2430.c:279:3: warning: 'return' with a value, in
function returning void
drivers/usb/musb/omap2430.c:282:2: warning: 'return' with a value, in
function returning void

Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: renesas_usbhs: pop packet when urb dequeued
Kuninori Morimoto [Fri, 9 Dec 2011 02:26:07 +0000 (18:26 -0800)]
usb: renesas_usbhs: pop packet when urb dequeued

usbhsh_ureq_free() is not enough when urb dequeued.

Without this patch, the driver can not recognize re-connected
USB device after USB hub disconnected

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: renesas_usbhs: add lost error value when enqueue
Kuninori Morimoto [Fri, 9 Dec 2011 02:25:37 +0000 (18:25 -0800)]
usb: renesas_usbhs: add lost error value when enqueue

usbhsh_urb_enqueue() didn't have error value when
usbhsh_device_attach() failed

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: musb: fix pm_runtime calls while atomic
Vikram Pandita [Fri, 12 Aug 2011 14:38:51 +0000 (07:38 -0700)]
usb: musb: fix pm_runtime calls while atomic

musb pm_runtime_get_sync call happens in intrrupt context on cable attach case
That can result in re-enabling the interrupts and cause side affects.

So move the code to a work queue.

Following is the error path hit on cable attach:

BUG: sleeping function called from invalid context at drivers/base/power/runtime.c:802
in_atomic(): 0, irqs_disabled(): 0, pid: 18, name: irq/378-twl6030

Backtrace:
[<c00520f0>] (dump_backtrace+0x0/0x110) from [<c054f454>] (dump_stack+0x18/0x1c)
[<c054f43c>] (dump_stack+0x0/0x1c) from [<c007f59c>] (__might_sleep+0x130/0x134)
[<c007f46c>] (__might_sleep+0x0/0x134) from [<c02c2794>] (__pm_runtime_resume+0x94/0x98)
[<c02c2700>] (__pm_runtime_resume+0x0/0x98) from [<c033e7e4>] (musb_otg_notifications+0x9c/0x164)
[<c033e748>] (musb_otg_notifications+0x0/0x164) from [<c00b3df0>] (notifier_call_chain+0x4c/0x8c)
[<c00b3da4>] (notifier_call_chain+0x0/0x8c) from [<c00b44a8>] (__atomic_notifier_call_chain+0x40/0x54)
[<c00b4468>] (__atomic_notifier_call_chain+0x0/0x54) from [<c00b44dc>] (atomic_notifier_call_chain+0x20/0x28)
[<c00b44bc>] (atomic_notifier_call_chain+0x0/0x28) from [<c033f124>] (twl6030_usb_irq+0xc8/0xdc)
[<c033f05c>] (twl6030_usb_irq+0x0/0xdc) from [<c00d79f8>] (irq_thread_fn+0x24/0x40)
[<c00d79d4>] (irq_thread_fn+0x0/0x40) from [<c00d7b64>] (irq_thread+0x150/0x1d8)
[<c00d7a14>] (irq_thread+0x0/0x1d8) from [<c00adf70>] (kthread+0x94/0x98)
[<c00adedc>] (kthread+0x0/0x98) from [<c0094388>] (do_exit+0x0/0x720)

Tested with:
MUSB Device mode: Cold boot / Hot plug
MUSB Host mode: Cold boot / Hot plug

Signed-off-by: Vikram Pandita <vikram.pandita@ti.com>
Signed-off-by: Moiz Sonasath <m-sonasath@ti.com>
Signed-off-by: Vikram Pandita <vikram.pandita@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: musb: drop ARCH dependency
Felipe Balbi [Fri, 14 Oct 2011 07:22:29 +0000 (10:22 +0300)]
usb: musb: drop ARCH dependency

musb core driver and tusb6010 glue layer don't
depend on anything which is ARCH-specific. It
builds fine on x86 and ARM. Dropping the dependency
so we can compile-test on linux-next.

Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: musb: headers cleanup
Felipe Balbi [Fri, 14 Oct 2011 07:45:15 +0000 (10:45 +0300)]
usb: musb: headers cleanup

Remove a few unnecessary headers from a
few files.

Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: musb: allow building USB_MUSB_TUSB6010 as a module
Arnd Bergmann [Sun, 2 Oct 2011 14:45:47 +0000 (16:45 +0200)]
usb: musb: allow building USB_MUSB_TUSB6010 as a module

Commit 1376d92f9 "usb: musb: allow musb and glue layers to be modules"
made the USB_MUSB_TUSB6010 option modular, but actually building
the driver as a module does not work, so various randconfig builds
actually fail. This changes all code that depends on the
option to also check for modular builds, and exports the necessary
symbols.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: musb: use a Kconfig choice to pick the right DMA method
Arnd Bergmann [Sun, 2 Oct 2011 14:45:45 +0000 (16:45 +0200)]
usb: musb: use a Kconfig choice to pick the right DMA method

The logic to allow only one DMA driver in MUSB is currently
flawed, because it also allows picking no DMA driver at all
and also not selecting PIO mode.

Using a choice statement makes this foolproof for now and
also simplifies the Makefile.

Unfortunately, we will have to revisit this when we start
supporting multiple ARM platforms in a single kernel binary,
because at that point we will actually need to select
multiple DMA drivers and pick the right one at run-time.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Felipe Balbi <balbi@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: musb: omap2+: save and restore OTG_INTERFSEL
Hema HK [Wed, 7 Sep 2011 16:19:24 +0000 (09:19 -0700)]
usb: musb: omap2+: save and restore OTG_INTERFSEL

we need to save and restore OTG_INTERFSEL register
else we will be unable to function on resume after
OFF mode.

Reported-by: Devaraj Rangasamy <dev@ti.com>
Signed-off-by: Hema HK <hemahk@ti.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Vikram Pandita <vikram.pandita@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: musb: omap2+: fix context api's
Vikram Pandita [Wed, 7 Sep 2011 16:19:23 +0000 (09:19 -0700)]
usb: musb: omap2+: fix context api's

RxFifoSz, TxFifoSz, RxFifoAddr, TxFifoAddr
are all indexed registers.

So before doing a context save or restore, INDEX register
should be set, then only one gets to the right register offset.

Signed-off-by: Vikram Pandita <vikram.pandita@ti.com>
Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: musb: ux500: optimize DMA callback routine
Per Forlin [Wed, 17 Aug 2011 09:03:40 +0000 (11:03 +0200)]
usb: musb: ux500: optimize DMA callback routine

Skip the use of work queue and call musb_dma_completion() directly from
DMA callback context.

Here follows measurements on a Snowball board with ondemand governor active.

Performance using work queue:
(105 MB) copied, 6.23758 s, 16.8 MB/s
(105 MB) copied, 5.7151 s, 18.3 MB/s
(105 MB) copied, 5.83583 s, 18.0 MB/s
(105 MB) copied, 5.93611 s, 17.7 MB/s

Performance without work queue
(105 MB) copied, 5.62173 s, 18.7 MB/s
(105 MB) copied, 5.61811 s, 18.7 MB/s
(105 MB) copied, 5.57817 s, 18.8 MB/s
(105 MB) copied, 5.58549 s, 18.8 MB/s

Signed-off-by: Per Forlin <per.forlin@linaro.org>
Acked-by: Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: ep0: fix for possible early delayed_status
Felipe Balbi [Thu, 8 Dec 2011 11:56:27 +0000 (13:56 +0200)]
usb: dwc3: ep0: fix for possible early delayed_status

There is a very small possibility (previously unimagined
by us) that the whole Mass Storage delayed status happens
rather early, before we even get our XferNotReady event.

In that case, we will be queueing a request to ep0 while
we're still on Setup Phase and we would be waiting for
another usb_ep_queue() forever.

Handle such cases by clearing dwc->delayed_status so that
we start control status from the next XferNotReady like
there was no wait for Delayed Status.

Tested against Linux 3.2-rc3 and USB30CV tool from USB-IF
(on a Windows XP with USB3 PCIe card).

Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: gadget: fix stream enable bit
Felipe Balbi [Tue, 29 Nov 2011 11:11:21 +0000 (13:11 +0200)]
usb: dwc3: gadget: fix stream enable bit

ep->max_streams is a mere hint to the gadget
driver that 'ep' supports stream handling. Using
that as a decision variable for enabling streams
was my worst brain-fart to date.

Instead, we should check from the Superspeed
Endpoint Companion Descriptor if the endpoint
has requested streams. For that we need a little
re-factoring but it is now correct.

Debugged-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: ep0: fix GetStatus handling (again)
Felipe Balbi [Tue, 29 Nov 2011 08:35:47 +0000 (10:35 +0200)]
usb: dwc3: ep0: fix GetStatus handling (again)

previous commit fixed part of it but it was still
calling usb_ep_queue() from IRQ context without
loosing locks. That cannot be done otherwise we will
have a recursive locking.

Also, we need to assign the 'dep' pointer on
dwc->ep0_usb_req otherwise we will have a NULL
pointer dereference on dwc3_map_buffer_to_dma().

Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: ep0: use dwc3_request for ep0 requsts instead of usb_request
Sebastian Andrzej Siewior [Fri, 25 Nov 2011 11:03:46 +0000 (12:03 +0100)]
usb: dwc3: ep0: use dwc3_request for ep0 requsts instead of usb_request

Instead of special functions and shortcuts for sending our internal
answers to the host we started doing what the gadget does and used the
public API for this. Since we only were using a few fields the
usb_request was enough. Later added the list handling in order to
synchronize the host / gadget events and now we require to have the
dwc3_request struct around our usb_request or else we touch memory that
does not belong to us. So this patch does this.

Reported-by: Partha Basak <p-basak2@ti.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: use correct hwparam register for power mgm check
Sebastian Andrzej Siewior [Thu, 24 Nov 2011 10:22:05 +0000 (11:22 +0100)]
usb: dwc3: use correct hwparam register for power mgm check

We mask the correct bits within the wrong register. The power
optimization mode is stored hwparam1 register and not in hwparam0.

Reported-by: Partha Basak <p-basak2@ti.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: omap: move to module_platform_driver
Felipe Balbi [Fri, 18 Nov 2011 19:31:14 +0000 (21:31 +0200)]
usb: dwc3: omap: move to module_platform_driver

the new module_platform_driver macro is a helper
for modules which just register and unregister the
platform_driver. It allows us to delete a few
duplicated lines.

Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: workaround: missing disconnect event
Felipe Balbi [Fri, 14 Oct 2011 12:11:49 +0000 (15:11 +0300)]
usb: dwc3: workaround: missing disconnect event

DWC3 revisions <1.88a have an issue which would
case a missing Disconnect event if cable is
disconnected while there's a Setup packet
pending the FIFO.

Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: workaround: missing USB3 Reset event
Felipe Balbi [Fri, 14 Oct 2011 11:51:38 +0000 (14:51 +0300)]
usb: dwc3: workaround: missing USB3 Reset event

DWC3 revisions <1.90a have an issue which would cause
a missing USB3 Reset event. In such cases, it's
suggested that we follow the steps of a normal
USB3 Reset on Connection Done Event.

Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: workaround: U1/U2 -> U0 transiton
Felipe Balbi [Fri, 14 Oct 2011 10:00:30 +0000 (13:00 +0300)]
usb: dwc3: workaround: U1/U2 -> U0 transiton

RTL revisions <1.83a have an issue where, depending
on the link partner, the USB link might do multiple
entry/exit of low power states before a transfer
takes place causing degraded throughput.

The suggested workaround is to clear bits
12:9 of DCTL register if we see a transition
from U1|U2 to U0 and only re-enable that on
a transfer complete IRQ and we have no pending
transfers on any of the enabled endpoints.

Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: gadget: return early in dwc3_cleanup_done_reqs()
Sebastian Andrzej Siewior [Thu, 3 Nov 2011 09:32:20 +0000 (10:32 +0100)]
usb: dwc3: gadget: return early in dwc3_cleanup_done_reqs()

This patch avoids the compiler spitting out the following warning:
|drivers/usb/dwc3/gadget.c:1304: warning: 'trb' is used uninitialized \
in this function

This is only uninitialized if the list of to-cleanup TRBs is empty which
should not be the case because we call this functions once a transfer
completed so it should be on list.

In order to make the warning disappear we return early. This should
never happen and the WARN_ON_ONCE(1) is there in case it happens
so we can investigate what went wrong.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: ep0: handle delayed_status again
Sebastian Andrzej Siewior [Wed, 2 Nov 2011 12:30:45 +0000 (13:30 +0100)]
usb: dwc3: ep0: handle delayed_status again

Since the re-worked ep0 handling (which uses HW's hints to recognize the ep0
status) we lost the delayed status handling. This is used by the file and mass
storage gadget to gain some extra time so setup its internal status before it
can proceed further requests.
In particular the storage gadget does nothing on USB_REQ_SET_CONFIGURATION but
wakes up a thread which handles the request. If the udc driver continues ep0
handling before the thread did its work then then endpoint is not yet
configured and further requests will fail. Once the gadget is ready, it will
enqueue an empty packet which is used for synchronization.
In order to fix this issue, the patch does the following:
Set ->delayed_status once the delayed_status has been notices and do not
continue on the next XferNotReady event. We will continues ep0 processing once
the gadget enqueued the zero packet for synchronization.

A cleaner approach would be to enforce the gadget to enqueue an empty
(zero) request even for the status phase but this would do for now.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: ep0: push ep0state into xfernotready processing
Sebastian Andrzej Siewior [Wed, 2 Nov 2011 12:30:44 +0000 (13:30 +0100)]
usb: dwc3: ep0: push ep0state into xfernotready processing

We wait for the XferNotReady before we start the transfer and by then we
know ep0 state in which we supposed to be.
This is some cleanup work for the following patch in which we require to
know the ep0 state before the transfer completes.
While here, also change the argument to dwc3_ep0_do_control_status() so
we don't require the complete event structure but only the required
piece of information.

Inspired-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: fix sparse errors
Felipe Balbi [Fri, 4 Nov 2011 10:40:05 +0000 (12:40 +0200)]
usb: dwc3: fix sparse errors

sparse caught three mistakes on this driver,
fix them:

drivers/usb/dwc3/ep0.c:806:29: warning: duplicate const
drivers/usb/dwc3/debugfs.c:481:15: warning: symbol 'dwc3_debugfs_init' \
was not declared. Should it be static?
drivers/usb/dwc3/debugfs.c:518:16: warning: symbol 'dwc3_debugfs_exit' \
was not declared. Should it be static?

Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: fix few coding style problems
Felipe Balbi [Fri, 4 Nov 2011 10:32:47 +0000 (12:32 +0200)]
usb: dwc3: fix few coding style problems

There were a few coding style issues with this driver
which are now fixed:

drivers/usb/dwc3/debugfs.c:48: WARNING: Use #include \
<linux/uaccess.h> instead of <asm/uaccess.h>
drivers/usb/dwc3/debugfs.c:484: ERROR: space required \
before the open brace '{'
drivers/usb/dwc3/ep0.c:261: WARNING: line over 80 characters
drivers/usb/dwc3/ep0.c:287: WARNING: suspect code indent \
for conditional statements (16, 23)
drivers/usb/dwc3/gadget.c:749: WARNING: line over 80 characters
drivers/usb/dwc3/gadget.c:1267: WARNING: line over 80 characters
drivers/usb/dwc3/gadget.h:116: WARNING: line over 80 characters
drivers/usb/dwc3/io.h:42: WARNING: Use #include \
<linux/io.h> instead of <asm/io.h>

Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: move generic dwc3 code from gadget into core
Sebastian Andrzej Siewior [Mon, 31 Oct 2011 21:25:41 +0000 (22:25 +0100)]
usb: dwc3: move generic dwc3 code from gadget into core

A few inits like the scale value or the removal of the DISSCRAMBLE is
done in the gadget code however it touches a general register.
Move this piece to the core.c file since it is likely to be requied by
both, parts of the core (device and host).

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: use a helper function for operation mode setting
Sebastian Andrzej Siewior [Mon, 31 Oct 2011 21:25:40 +0000 (22:25 +0100)]
usb: dwc3: use a helper function for operation mode setting

There are two where need to set operational mode:
- during initialization while we decide to run in host,device or DRD
  mode
- at runtime via the debugfs interface.

This patch provides a new function which sets the operational mode and
moves its initialiation to the mode switch instead in the gadget code
itself.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: ep0: don't use ep0in for transfers
Sebastian Andrzej Siewior [Thu, 20 Oct 2011 17:04:16 +0000 (19:04 +0200)]
usb: dwc3: ep0: don't use ep0in for transfers

In "usb: dwc3: remove special status request handling in ep0" I simplied
a few things and used the generic API for the status transfers. The bug
I introcuded here is that we queue now requests to dep[1] but we don't
clear that list in the stall+start case.
Actually we don't need to use dep[1] at all. We only did in the past to
talk to the correct endpoint (i.e. in or out). This is now take care of
in a diffent place within the ep0 code. So we could queue the in
transfers to dep[0] and don't use dep[1] at all.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: ep0: use proper endianess in SetFeature for wIndex
Sebastian Andrzej Siewior [Mon, 24 Oct 2011 09:09:39 +0000 (12:09 +0300)]
usb: dwc3: ep0: use proper endianess in SetFeature for wIndex

The first access was correct, the second was wrong.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: core: drop DWC3_EVENT_BUFFERS_MAX
Felipe Balbi [Mon, 24 Oct 2011 09:03:13 +0000 (12:03 +0300)]
usb: dwc3: core: drop DWC3_EVENT_BUFFERS_MAX

hardware will tell us how many event buffers we
need to support, so let's allocate the array
dynamically too.

Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: omap: add multiple instances support to OMAP
Felipe Balbi [Tue, 18 Oct 2011 10:58:30 +0000 (13:58 +0300)]
usb: dwc3: omap: add multiple instances support to OMAP

if we ever have an omap with multiple instances of
the DWC3 IP, we need unique names for them. In order
to achieve that, let's use the dwc3_get/put_device_id()
calls to give us an unique device identifier.

Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: move dwc3 device ID bitmap to core.c
Felipe Balbi [Tue, 18 Oct 2011 10:54:01 +0000 (13:54 +0300)]
usb: dwc3: move dwc3 device ID bitmap to core.c

if we want to support situations where we have
both SoC and PCIe versions of the IP on the same
platform, we need to have sequential numbers between
them, otherwise we will still have name collisions.

Because of that, we need to move dwc3_get/put_device_id()
to core.c and export that symbol to be used by glue
layers.

Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: remove special status request handling in ep0
Sebastian Andrzej Siewior [Tue, 18 Oct 2011 17:13:29 +0000 (19:13 +0200)]
usb: dwc3: remove special status request handling in ep0

The GetStatus (STD)-request is handled the driver and uses a tiny hack
to send the two bytes long answer. This patch removes the custom hack
uses the normal usb_ep_queue() for that.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: reset pending status flag in error case
Sebastian Andrzej Siewior [Tue, 18 Oct 2011 17:13:28 +0000 (19:13 +0200)]
usb: dwc3: reset pending status flag in error case

If we stall and restart we have to reset also this flag to 0 as there is
nothing pending anymore.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: host: remove unused includes
Sebastian Andrzej Siewior [Thu, 20 Oct 2011 16:43:10 +0000 (18:43 +0200)]
usb: dwc3: host: remove unused includes

None of these are required atm.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: debugfs: hold the lock in during mode change
Sebastian Andrzej Siewior [Thu, 20 Oct 2011 16:43:07 +0000 (18:43 +0200)]
usb: dwc3: debugfs: hold the lock in during mode change

The read and write operation is atomic and we need no locking around
this operations. What we need however is a lock that is held which
ensures that the content of the DWC3_GCTL has not been changed. With
this, the conten may have been change changed after the first but before
our write back.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: add a platform device alias
Sebastian Andrzej Siewior [Wed, 19 Oct 2011 17:39:50 +0000 (19:39 +0200)]
usb: dwc3: add a platform device alias

We can have three modules here: dwc3.ko, dwc3-omap.ko and dwc3-pci.ko.
The later have already ids-aliases for probing and is fine. The omap
module has alias for DT but lacks alias for the "native"
platform_device. Maybe we should get rid of it and stick to the DT name?
Both glue modules create a new device for which the dwc3.ko module is
responsible and that one lacks the platform alias.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
12 years agousb: dwc3: ep0: handle unexpected XferNotReady events
Felipe Balbi [Tue, 18 Oct 2011 15:00:26 +0000 (18:00 +0300)]
usb: dwc3: ep0: handle unexpected XferNotReady events

Sometimes the host might be trying to initiate Data or
Status phase for an older Control transfer. In such
situations we must STALL that transfer and restart
the state machine rather than letting such situation
go through the wire.

Signed-off-by: Felipe Balbi <balbi@ti.com>