[PATCH 1/2] usb: phy: samsung: Fix wrong bit mask for PHYPARAM1_PCS_TXDEEMPH

2014-08-08 Thread Jingoo Han
According to the datasheet, PHYPARAM1_PCS_TXDEEMPH is set as
6 bits [5:0]. Thus, the bit mask should be set as 0x3f, instead
of 0x1f.

Signed-off-by: Jingoo Han 
---
These patches have a dependency on the patch ([PATCH] usb: phy:
samsung: Remove unnecessary lines of register bit definitions). [1]

[1] http://www.spinics.net/lists/linux-usb/msg111437.html

 drivers/usb/phy/phy-samsung-usb.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/phy/phy-samsung-usb.h 
b/drivers/usb/phy/phy-samsung-usb.h
index 4eef4971..44e7605e4875 100644
--- a/drivers/usb/phy/phy-samsung-usb.h
+++ b/drivers/usb/phy/phy-samsung-usb.h
@@ -185,7 +185,7 @@
 #define PHYPARAM0_REF_LOSLEVEL (0x9 << 26)
 
 #define EXYNOS5_DRD_PHYPARAM1  (0x20)
-#define PHYPARAM1_PCS_TXDEEMPH_MASK(0x1f << 0)
+#define PHYPARAM1_PCS_TXDEEMPH_MASK(0x3f << 0)
 #define PHYPARAM1_PCS_TXDEEMPH (0x1c)
 
 #define EXYNOS5_DRD_PHYTERM(0x24)
-- 
2.0.0


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] usb: phy: samsung: Add a _3P5DB suffix for PHYPARAM1_PCS_TXDEEMPH

2014-08-08 Thread Jingoo Han
According to the datasheet, PHYPARAM1_PCS_TXDEEMPH_3P5DB is a
correct name. Thus, a _3P5DB suffix for the PHYPARAM1_PCS_TXDEEMPH
register bit field definition is added.

In addition, PHYPARAM1_PCS_TXDEEMPH_3P5DB(_x) is added in order to
keep the same style, as other register bit field definitions are
used in this way.

Signed-off-by: Jingoo Han 
---
These patches have a dependency on the patch ([PATCH] usb: phy:
samsung: Remove unnecessary lines of register bit definitions). [1]

[1] http://www.spinics.net/lists/linux-usb/msg111437.html

 drivers/usb/phy/phy-samsung-usb.h  | 4 ++--
 drivers/usb/phy/phy-samsung-usb3.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/phy/phy-samsung-usb.h 
b/drivers/usb/phy/phy-samsung-usb.h
index 44e7605e4875..dc1dadea7ac9 100644
--- a/drivers/usb/phy/phy-samsung-usb.h
+++ b/drivers/usb/phy/phy-samsung-usb.h
@@ -185,8 +185,8 @@
 #define PHYPARAM0_REF_LOSLEVEL (0x9 << 26)
 
 #define EXYNOS5_DRD_PHYPARAM1  (0x20)
-#define PHYPARAM1_PCS_TXDEEMPH_MASK(0x3f << 0)
-#define PHYPARAM1_PCS_TXDEEMPH (0x1c)
+#define PHYPARAM1_PCS_TXDEEMPH_3P5DB_MASK  (0x3f << 0)
+#define PHYPARAM1_PCS_TXDEEMPH_3P5DB(_x)   ((_x) << 0)
 
 #define EXYNOS5_DRD_PHYTERM(0x24)
 
diff --git a/drivers/usb/phy/phy-samsung-usb3.c 
b/drivers/usb/phy/phy-samsung-usb3.c
index cc0819248acf..97151b9065e4 100644
--- a/drivers/usb/phy/phy-samsung-usb3.c
+++ b/drivers/usb/phy/phy-samsung-usb3.c
@@ -98,8 +98,8 @@ static void samsung_exynos5_usb3phy_enable(struct 
samsung_usbphy *sphy)
 
phyparam1 = readl(regs + EXYNOS5_DRD_PHYPARAM1);
/* Set Tx De-Emphasis level */
-   phyparam1 &= ~PHYPARAM1_PCS_TXDEEMPH_MASK;
-   phyparam1 |= PHYPARAM1_PCS_TXDEEMPH;
+   phyparam1 &= ~PHYPARAM1_PCS_TXDEEMPH_3P5DB_MASK;
+   phyparam1 |= PHYPARAM1_PCS_TXDEEMPH_3P5DB(0x1c);
writel(phyparam1, regs + EXYNOS5_DRD_PHYPARAM1);
 
phybatchg = readl(regs + EXYNOS5_DRD_PHYBATCHG);
-- 
2.0.0


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Resend Re: [PATCH v6] usb:serial:pl2303: add GPIOs interface on PL2303

2014-08-08 Thread Johan Hovold
On Fri, Aug 08, 2014 at 03:10:34AM +0800, Wang YanQing wrote:
> On Tue, Aug 05, 2014 at 03:54:08PM +0200, Johan Hovold wrote:
> > > > I noticed that setting direction to output and setting the gpio high has
> > > > no effect on the read-back value (i.e. I still read back 0) for my
> > > > pl2303hx (note that my device has no easily accessible gpios so I
> > > > haven't verified the actual state of the output pin).
> > > > 
> > > > What happens on your system? Is the read-back value still 0, even when
> > > > the GPIO output is actually high? Should we return the cached value in
> > > > this case?
> > > 
> > > If i set direction to output, then I could control gpio high and low
> > > by set 1 or 0, and the read-back value is 1 or 0 according to high and
> > > low(I test high and low by oscillscope)
> > > 
> > > I test it with my pl2303hx with only two gpios.
> > >
> > > Could you use usbmon to see whether the traffic is right according
> > > to comment in struct pl2303_gpio?
> > 
> > The traffic appears correct judging from the debug output (which I
> > trust). Output-enable is reflected in register 0x81, but the value
> > isn't.
> > 
> > What is the lsusb -v output for your device?
> 
> Bus 001 Device 005: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port.

You forgot the verbose flag (-v).
 
> It is strange your device doesn't work, I verify the control method by
> analyze usbmon output from linux host which has VirtualBox running 
> gpio test program, but I don't have right to distribute the gpio test
> program I think, so I can't help you to figure out why it doesn't work 
> for your device.

What do you use the gpio test program for? I thought you verified the
gpios with a scope?

Perhaps mine just does not support GPIOs? I don't know, but that's
partly why I asked for the lsusb output. Apparently there's a bunch of
different versions of these chips out there.

I'll see if I can find time to dissect my converter and try to access
the GPIO pins with the next version of the patch.

> > I suggest you just set the label to pl2303 until we have a valid
> > use-case that requires something more elaborate.
> 
> Ok, but pl2303-gpio maybe a better name?

No, not really. It's a gpio-chip label and is only used in that context
so a "-gpio" suffix adds no information.

Thanks,
Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] USB: Register VIA Telecom CDS7 chipset with Option USB serial driver

2014-08-08 Thread Johan Hovold
On Wed, Aug 06, 2014 at 08:46:44AM -0700, Brennan Ashton wrote:
> This VIA Telecom baseband processor is used is used by by u-blox in both the
> FW2770 and FW2760 products and may be used in others as well.
> 
> This patch has been tested on both of these modem versions.
> 
> Signed-off-by: Brennan Ashton 

Looks good. I'll queue this up once v3.17-rc1 is out.

Thanks,
Johan

> ---
>  drivers/usb/serial/option.c | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
> index a968894..b398ab7 100644
> --- a/drivers/usb/serial/option.c
> +++ b/drivers/usb/serial/option.c
> @@ -494,6 +494,10 @@ static void option_instat_callback(struct urb *urb);
>  #define INOVIA_VENDOR_ID 0x20a6
>  #define INOVIA_SEW8580x1105
>  
> +/* VIA Telecom */
> +#define VIATELECOM_VENDOR_ID 0x15eb
> +#define VIATELECOM_PRODUCT_CDS7  0x0001
> +
>  /* some devices interfaces need special handling due to a number of reasons 
> */
>  enum option_blacklist_reason {
>   OPTION_BLACKLIST_NONE = 0,
> @@ -1724,6 +1728,7 @@ static const struct usb_device_id option_ids[] = {
>   { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* 
> D-Link DWM-152/C1 */
>   { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* 
> D-Link DWM-156/C1 */
>   { USB_DEVICE(INOVIA_VENDOR_ID, INOVIA_SEW858) },
> + { USB_DEVICE(VIATELECOM_VENDOR_ID, VIATELECOM_PRODUCT_CDS7) },
>   { } /* Terminating entry */
>  };
>  MODULE_DEVICE_TABLE(usb, option_ids);
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Backslash repeat bug

2014-08-08 Thread Fredrik Hallenberg
Hi,

On my Corsair K70 keyboard, when pressing some key and then the backslash
key (KEY_BACKSLASH) in rapid succession the backslash character will be
repeated three times.

This bug is discussed on the Corsair forums, and it seems the exact same
thing also happens with Gigabyte Osmium and QPAD MK85, all keyboards
supporting n-key rollover.

I believe the root cause of this is that the keyboard reports all keys
including both HID keys 0x31 and 0x32 which are both mapped to
KEY_BACKSLASH in hid-input.c. I am using a nordic keyboard meaning
KEY_BACKSLASH is labeled "apostrophe" and that HID key 0x32 is reported. A
US keyboard has a backslash key which should report 0x31.

I have added some traces before the input_event call at the end of
hidinput_report_event. When pressing A key and then apostrophe something
like this is seen (omitting all inactive keys):

VALUE 1 CODE 30 HID 0x4
VALUE 0 CODE 43 HID 0x31
VALUE 0 CODE 43 HID 0x32
Output: a

VALUE 1 CODE 30 HID 0x4
VALUE 0 CODE 43 HID 0x31
VALUE 1 CODE 43 HID 0x32
Output: '

VALUE 0 CODE 30 HID 0x4
VALUE 0 CODE 43 HID 0x31
VALUE 1 CODE 43 HID 0x32
Output: '

VALUE 0 CODE 30 HID 0x4
VALUE 0 CODE 43 HID 0x31
VALUE 1 CODE 43 HID 0x32
Output: '

VALUE 0 CODE 30 HID 0x4
VALUE 0 CODE 43 HID 0x31
VALUE 0 CODE 43 HID 0x32

So the fact that 0x31 is inactive will cause bad release events on key 43
to be sent.

I have made a simple patch that tracks which of the two variants is active
and ignores the other one. It works but I don't have much knowledge on HID
input so before posting it would like to know if someone has input on how
to do a cleaner fix. I am happy to help with testing or implementation if I
am able.

Regards,

Fredrik
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4] usb: gadget: at91_udc: move prepare clk into process context

2014-08-08 Thread Ronald Wahl
Commit 7628083227b6bc4a7e33d7c381d7a4e558424b6b (usb: gadget: at91_udc:
prepare clk before calling enable) added clock preparation in interrupt
context. This is not allowed as it might sleep. Also setting the clock
rate is unsafe to call from there for the same reason. Move clock
preparation and setting clock rate into process context (at91udc_probe).

Signed-off-by: Ronald Wahl 
---
v3 -> v4:
- no code changes
- update commit message
- add changelog

v2 -> v3: (NOTE: this patch was also send with the v2 tag)
- moved setting the clock rate into process context as well as it may
  also sleep
- update commit message

v1 -> v2:
- no changes (first v2 got out accidently)

 drivers/usb/gadget/udc/at91_udc.c | 44 ---
 1 file changed, 32 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/gadget/udc/at91_udc.c 
b/drivers/usb/gadget/udc/at91_udc.c
index cfd18bc..0d685d0 100644
--- a/drivers/usb/gadget/udc/at91_udc.c
+++ b/drivers/usb/gadget/udc/at91_udc.c
@@ -870,12 +870,10 @@ static void clk_on(struct at91_udc *udc)
return;
udc->clocked = 1;
 
-   if (IS_ENABLED(CONFIG_COMMON_CLK)) {
-   clk_set_rate(udc->uclk, 4800);
-   clk_prepare_enable(udc->uclk);
-   }
-   clk_prepare_enable(udc->iclk);
-   clk_prepare_enable(udc->fclk);
+   if (IS_ENABLED(CONFIG_COMMON_CLK))
+   clk_enable(udc->uclk);
+   clk_enable(udc->iclk);
+   clk_enable(udc->fclk);
 }
 
 static void clk_off(struct at91_udc *udc)
@@ -884,10 +882,10 @@ static void clk_off(struct at91_udc *udc)
return;
udc->clocked = 0;
udc->gadget.speed = USB_SPEED_UNKNOWN;
-   clk_disable_unprepare(udc->fclk);
-   clk_disable_unprepare(udc->iclk);
+   clk_disable(udc->fclk);
+   clk_disable(udc->iclk);
if (IS_ENABLED(CONFIG_COMMON_CLK))
-   clk_disable_unprepare(udc->uclk);
+   clk_disable(udc->uclk);
 }
 
 /*
@@ -1780,14 +1778,24 @@ static int at91udc_probe(struct platform_device *pdev)
}
 
/* don't do anything until we have both gadget driver and VBUS */
+   if (IS_ENABLED(CONFIG_COMMON_CLK)) {
+   clk_set_rate(udc->uclk, 4800);
+   retval = clk_prepare(udc->uclk);
+   if (retval)
+   goto fail1;
+   }
+   retval = clk_prepare(udc->fclk);
+   if (retval)
+   goto fail1a;
+
retval = clk_prepare_enable(udc->iclk);
if (retval)
-   goto fail1;
+   goto fail1b;
at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS);
at91_udp_write(udc, AT91_UDP_IDR, 0x);
/* Clear all pending interrupts - UDP may be used by bootloader. */
at91_udp_write(udc, AT91_UDP_ICR, 0x);
-   clk_disable_unprepare(udc->iclk);
+   clk_disable(udc->iclk);
 
/* request UDC and maybe VBUS irqs */
udc->udp_irq = platform_get_irq(pdev, 0);
@@ -1795,7 +1803,7 @@ static int at91udc_probe(struct platform_device *pdev)
0, driver_name, udc);
if (retval < 0) {
DBG("request irq %d failed\n", udc->udp_irq);
-   goto fail1;
+   goto fail1c;
}
if (gpio_is_valid(udc->board.vbus_pin)) {
retval = gpio_request(udc->board.vbus_pin, "udc_vbus");
@@ -1848,6 +1856,13 @@ fail3:
gpio_free(udc->board.vbus_pin);
 fail2:
free_irq(udc->udp_irq, udc);
+fail1c:
+   clk_unprepare(udc->iclk);
+fail1b:
+   clk_unprepare(udc->fclk);
+fail1a:
+   if (IS_ENABLED(CONFIG_COMMON_CLK))
+   clk_unprepare(udc->uclk);
 fail1:
if (IS_ENABLED(CONFIG_COMMON_CLK) && !IS_ERR(udc->uclk))
clk_put(udc->uclk);
@@ -1896,6 +1911,11 @@ static int __exit at91udc_remove(struct platform_device 
*pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(res->start, resource_size(res));
 
+   if (IS_ENABLED(CONFIG_COMMON_CLK))
+   clk_unprepare(udc->uclk);
+   clk_unprepare(udc->fclk);
+   clk_unprepare(udc->iclk);
+
clk_put(udc->iclk);
clk_put(udc->fclk);
if (IS_ENABLED(CONFIG_COMMON_CLK))
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: 3.15.8 USB issue with uvc cam

2014-08-08 Thread Udo van den Heuvel
Hello,

The Logitech C615 works OK if moved away from a USB3 port into a
non-USB3 port.
So it appears a USB3 issue.
Is 'xhci_hcd :02:00.0: ERROR: unexpected command
completion code 0x11' a possible root cause?

My board has:

# lspci
00:00.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h
(Models 10h-1fh) Processor Root Complex
00:00.2 IOMMU: Advanced Micro Devices, Inc. [AMD] Family 15h (Models
10h-1fh) I/O Memory Management Unit
00:01.0 VGA compatible controller: Advanced Micro Devices, Inc.
[AMD/ATI] Trinity [Radeon HD 7660D]
00:01.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Trinity
HDMI Audio Controller
00:04.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] Family 15h
(Models 10h-1fh) Processor Root Port
00:07.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] Family 15h
(Models 10h-1fh) Processor Root Port
00:10.0 USB controller: Advanced Micro Devices, Inc. [AMD] FCH USB XHCI
Controller (rev 03)
00:10.1 USB controller: Advanced Micro Devices, Inc. [AMD] FCH USB XHCI
Controller (rev 03)
00:11.0 SATA controller: Advanced Micro Devices, Inc. [AMD] FCH SATA
Controller [AHCI mode] (rev 40)
00:12.0 USB controller: Advanced Micro Devices, Inc. [AMD] FCH USB OHCI
Controller (rev 11)
00:12.2 USB controller: Advanced Micro Devices, Inc. [AMD] FCH USB EHCI
Controller (rev 11)
00:13.0 USB controller: Advanced Micro Devices, Inc. [AMD] FCH USB OHCI
Controller (rev 11)
00:13.2 USB controller: Advanced Micro Devices, Inc. [AMD] FCH USB EHCI
Controller (rev 11)
00:14.0 SMBus: Advanced Micro Devices, Inc. [AMD] FCH SMBus Controller
(rev 14)
00:14.2 Audio device: Advanced Micro Devices, Inc. [AMD] FCH Azalia
Controller (rev 01)
00:14.3 ISA bridge: Advanced Micro Devices, Inc. [AMD] FCH LPC Bridge
(rev 11)
00:14.4 PCI bridge: Advanced Micro Devices, Inc. [AMD] FCH PCI Bridge
(rev 40)
00:14.5 USB controller: Advanced Micro Devices, Inc. [AMD] FCH USB OHCI
Controller (rev 11)
00:18.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h
(Models 10h-1fh) Processor Function 0
00:18.1 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h
(Models 10h-1fh) Processor Function 1
00:18.2 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h
(Models 10h-1fh) Processor Function 2
00:18.3 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h
(Models 10h-1fh) Processor Function 3
00:18.4 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h
(Models 10h-1fh) Processor Function 4
00:18.5 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h
(Models 10h-1fh) Processor Function 5
01:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd.
RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 06)
02:00.0 USB controller: Etron Technology, Inc. EJ168 USB 3.0 Host
Controller (rev 01)
03:06.0 Serial controller: MosChip Semiconductor Technology Ltd. PCI
9835 Multi-I/O Controller (rev 01)


And the Etron EJ168 is the only USB3 provider here?
How can we fix this issue?

Kind regards,
Udo


On 2014-08-08 05:42, Udo van den Heuvel wrote:
> Hello,
> 
> I get WARNINGs when trying to use a Logitech C615 cam.
> See attachment for full dmesg of errors but excerpt below:
> 
> [80346.835015] xhci_hcd :02:00.0: ERROR: unexpected command
> completion code 0x11.
> [80346.835027] usb 6-2: Not enough bandwidth for altsetting 11
> [80346.835137] [ cut here ]
> [80346.835155] WARNING: CPU: 3 PID: 20594 at
> drivers/media/v4l2-core/videobuf2-core.c:2011
> __vb2_queue_cancel+0x102/0x170 [videobuf2_core]()
> [80346.835158] Modules linked in: uvcvideo cdc_acm bnep bluetooth fuse
> edac_core cpufreq_userspace ipt_REJECT nf_conntrack_netbios_ns
> nf_conntrack_broadcast iptable_filter ip6t_REJECT ipt_MASQUERADE
> xt_tcpudp nf_conntrack_ipv6 iptable_nat nf_defrag_ipv6 nf_conntrack_ipv4
> nf_defrag_ipv4 nf_nat_ipv4 nf_nat xt_conntrack nf_conntrack ip_tables
> ip6table_filter ip6_tables x_tables eeprom it87 hwmon_vid ext2
> snd_usb_audio snd_usbmidi_lib snd_hwdep snd_rawmidi ppdev pwc
> videobuf2_vmalloc videobuf2_memops kvm_amd kvm v4l2_common
> videobuf2_core snd_hda_codec_realtek snd_hda_codec_generic videodev
> snd_hda_intel snd_hda_controller cp210x snd_hda_codec usbserial snd_seq
> snd_seq_device microcode snd_pcm parport_serial parport_pc parport
> snd_timer k10temp snd evdev i2c_piix4 button acpi_cpufreq nfsd
> auth_rpcgss oid_registry
> [80346.835218]  nfs_acl lockd sunrpc binfmt_misc autofs4 hid_generic
> usbhid ohci_pci ehci_pci ehci_hcd ohci_hcd radeon sr_mod cdrom fbcon
> bitblit cfbfillrect softcursor cfbimgblt cfbcopyarea font i2c_algo_bit
> xhci_hcd backlight drm_kms_helper ttm drm fb fbdev
> [80346.835250] CPU: 3 PID: 20594 Comm: skype Tainted: GW
> 3.15.8 #6
> [80346.835254] Hardware name: Gigabyte Technology Co., Ltd. To be filled
> by O.E.M./F2A85X-UP4, BIOS F5a 04/30/2013
> [80346.835257]   79d580f4 814f2373
> 
> [80346.835262]  81069fe1  88040ec532e8
> 
> [803

Re: 3.15.8 USB issue with uvc cam

2014-08-08 Thread Udo van den Heuvel
On 2014-08-08 13:24, Udo van den Heuvel wrote:
> unexpected command
> completion code 0x11

Is bug https://bugzilla.kernel.org/show_bug.cgi?id=70531 relevant here?

Kind regards,
Udo
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH] Revert "usb: chipidea: udc: .pullup is valid only when vbus is there"

2014-08-08 Thread Michael Grzeschik
This reverts commit 4a64783b66bbeed06a1f10ab56a1dd401dd5bfba.
---

Hello Peter,

I have seen this call is still returning EOPNOTSUPP which is also
returned by usb_gadget_connect and usb_gadget_disconnect if the pullup
function is not available. Should it not handle that case somehow special?


Is it still a valid condition to bailout if vbus is not active?

 drivers/usb/chipidea/udc.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index b8125aa..6ac8849 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1531,9 +1531,6 @@ static int ci_udc_pullup(struct usb_gadget *_gadget, int 
is_on)
 {
struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget);
 
-   if (!ci->vbus_active)
-   return -EOPNOTSUPP;
-
if (is_on)
hw_write(ci, OP_USBCMD, USBCMD_RS, USBCMD_RS);
else
-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Re: Re: Re: driver option create ttyUSB

2014-08-08 Thread Greg KH

A: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

On Fri, Aug 08, 2014 at 02:48:08PM +0800, w wrote:
> 
> My kernel version is 3.0.

That's really old and unsupported, you need to get support from your
vendor if you are stuck at that version, sorry.

> I just want to get some useful information from this patch.

I don't understand what was useful about it?  Your problem is that your
userspace program is not releasing the device node, forcing the kernel
to allocate a different one when the device is removed and plugged back
into the system.  If you change your userspace program to listen for the
hangup signal, and disconnect from the tty device node when that
happens, then all should be fine, right?

> Because the patch seems solved the same problem as mine.

Did you try it out on a cdc-acm device and something different happens
from a usb-serial device?

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Backslash repeat bug

2014-08-08 Thread Greg KH
On Fri, Aug 08, 2014 at 11:15:00AM +0200, Fredrik Hallenberg wrote:
> Hi,
> 
> On my Corsair K70 keyboard, when pressing some key and then the backslash
> key (KEY_BACKSLASH) in rapid succession the backslash character will be
> repeated three times.
> 
> This bug is discussed on the Corsair forums, and it seems the exact same
> thing also happens with Gigabyte Osmium and QPAD MK85, all keyboards
> supporting n-key rollover.
> 
> I believe the root cause of this is that the keyboard reports all keys
> including both HID keys 0x31 and 0x32 which are both mapped to
> KEY_BACKSLASH in hid-input.c. I am using a nordic keyboard meaning
> KEY_BACKSLASH is labeled "apostrophe" and that HID key 0x32 is reported. A
> US keyboard has a backslash key which should report 0x31.
> 
> I have added some traces before the input_event call at the end of
> hidinput_report_event. When pressing A key and then apostrophe something
> like this is seen (omitting all inactive keys):
> 
> VALUE 1 CODE 30 HID 0x4
> VALUE 0 CODE 43 HID 0x31
> VALUE 0 CODE 43 HID 0x32
> Output: a
> 
> VALUE 1 CODE 30 HID 0x4
> VALUE 0 CODE 43 HID 0x31
> VALUE 1 CODE 43 HID 0x32
> Output: '
> 
> VALUE 0 CODE 30 HID 0x4
> VALUE 0 CODE 43 HID 0x31
> VALUE 1 CODE 43 HID 0x32
> Output: '
> 
> VALUE 0 CODE 30 HID 0x4
> VALUE 0 CODE 43 HID 0x31
> VALUE 1 CODE 43 HID 0x32
> Output: '
> 
> VALUE 0 CODE 30 HID 0x4
> VALUE 0 CODE 43 HID 0x31
> VALUE 0 CODE 43 HID 0x32
> 
> So the fact that 0x31 is inactive will cause bad release events on key 43
> to be sent.
> 
> I have made a simple patch that tracks which of the two variants is active
> and ignores the other one. It works but I don't have much knowledge on HID
> input so before posting it would like to know if someone has input on how
> to do a cleaner fix. I am happy to help with testing or implementation if I
> am able.

Interesting, but I think the linux-in...@vger.kernel.org mailing list
would be best for this, as that is where the HID and other input
developers hang out at.  It's not a "generic" USB issue that we can help
you with here, sorry.

So try the other list, you should have better luck there.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Backslash repeat bug

2014-08-08 Thread Fredrik Hallenberg
Thanks, I will try that list.

On Fri, Aug 8, 2014 at 3:29 PM, Greg KH  wrote:
> On Fri, Aug 08, 2014 at 11:15:00AM +0200, Fredrik Hallenberg wrote:
>> Hi,
>>
>> On my Corsair K70 keyboard, when pressing some key and then the backslash
>> key (KEY_BACKSLASH) in rapid succession the backslash character will be
>> repeated three times.
>>
>> This bug is discussed on the Corsair forums, and it seems the exact same
>> thing also happens with Gigabyte Osmium and QPAD MK85, all keyboards
>> supporting n-key rollover.
>>
>> I believe the root cause of this is that the keyboard reports all keys
>> including both HID keys 0x31 and 0x32 which are both mapped to
>> KEY_BACKSLASH in hid-input.c. I am using a nordic keyboard meaning
>> KEY_BACKSLASH is labeled "apostrophe" and that HID key 0x32 is reported. A
>> US keyboard has a backslash key which should report 0x31.
>>
>> I have added some traces before the input_event call at the end of
>> hidinput_report_event. When pressing A key and then apostrophe something
>> like this is seen (omitting all inactive keys):
>>
>> VALUE 1 CODE 30 HID 0x4
>> VALUE 0 CODE 43 HID 0x31
>> VALUE 0 CODE 43 HID 0x32
>> Output: a
>>
>> VALUE 1 CODE 30 HID 0x4
>> VALUE 0 CODE 43 HID 0x31
>> VALUE 1 CODE 43 HID 0x32
>> Output: '
>>
>> VALUE 0 CODE 30 HID 0x4
>> VALUE 0 CODE 43 HID 0x31
>> VALUE 1 CODE 43 HID 0x32
>> Output: '
>>
>> VALUE 0 CODE 30 HID 0x4
>> VALUE 0 CODE 43 HID 0x31
>> VALUE 1 CODE 43 HID 0x32
>> Output: '
>>
>> VALUE 0 CODE 30 HID 0x4
>> VALUE 0 CODE 43 HID 0x31
>> VALUE 0 CODE 43 HID 0x32
>>
>> So the fact that 0x31 is inactive will cause bad release events on key 43
>> to be sent.
>>
>> I have made a simple patch that tracks which of the two variants is active
>> and ignores the other one. It works but I don't have much knowledge on HID
>> input so before posting it would like to know if someone has input on how
>> to do a cleaner fix. I am happy to help with testing or implementation if I
>> am able.
>
> Interesting, but I think the linux-in...@vger.kernel.org mailing list
> would be best for this, as that is where the HID and other input
> developers hang out at.  It's not a "generic" USB issue that we can help
> you with here, sorry.
>
> So try the other list, you should have better luck there.
>
> thanks,
>
> greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4] usb: gadget: at91_udc: move prepare clk into process context

2014-08-08 Thread Alexandre Belloni
On 08/08/2014 at 11:42:42 +0200, Ronald Wahl wrote :
> Commit 7628083227b6bc4a7e33d7c381d7a4e558424b6b (usb: gadget: at91_udc:
> prepare clk before calling enable) added clock preparation in interrupt
> context. This is not allowed as it might sleep. Also setting the clock
> rate is unsafe to call from there for the same reason. Move clock
> preparation and setting clock rate into process context (at91udc_probe).
> 
> Signed-off-by: Ronald Wahl 
Acked-by: Alexandre Belloni 

> ---
> v3 -> v4:
> - no code changes
> - update commit message
> - add changelog
> 
> v2 -> v3: (NOTE: this patch was also send with the v2 tag)
> - moved setting the clock rate into process context as well as it may
>   also sleep
> - update commit message
> 
> v1 -> v2:
> - no changes (first v2 got out accidently)
> 
>  drivers/usb/gadget/udc/at91_udc.c | 44 
> ---
>  1 file changed, 32 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/at91_udc.c 
> b/drivers/usb/gadget/udc/at91_udc.c
> index cfd18bc..0d685d0 100644
> --- a/drivers/usb/gadget/udc/at91_udc.c
> +++ b/drivers/usb/gadget/udc/at91_udc.c
> @@ -870,12 +870,10 @@ static void clk_on(struct at91_udc *udc)
>   return;
>   udc->clocked = 1;
>  
> - if (IS_ENABLED(CONFIG_COMMON_CLK)) {
> - clk_set_rate(udc->uclk, 4800);
> - clk_prepare_enable(udc->uclk);
> - }
> - clk_prepare_enable(udc->iclk);
> - clk_prepare_enable(udc->fclk);
> + if (IS_ENABLED(CONFIG_COMMON_CLK))
> + clk_enable(udc->uclk);
> + clk_enable(udc->iclk);
> + clk_enable(udc->fclk);
>  }
>  
>  static void clk_off(struct at91_udc *udc)
> @@ -884,10 +882,10 @@ static void clk_off(struct at91_udc *udc)
>   return;
>   udc->clocked = 0;
>   udc->gadget.speed = USB_SPEED_UNKNOWN;
> - clk_disable_unprepare(udc->fclk);
> - clk_disable_unprepare(udc->iclk);
> + clk_disable(udc->fclk);
> + clk_disable(udc->iclk);
>   if (IS_ENABLED(CONFIG_COMMON_CLK))
> - clk_disable_unprepare(udc->uclk);
> + clk_disable(udc->uclk);
>  }
>  
>  /*
> @@ -1780,14 +1778,24 @@ static int at91udc_probe(struct platform_device *pdev)
>   }
>  
>   /* don't do anything until we have both gadget driver and VBUS */
> + if (IS_ENABLED(CONFIG_COMMON_CLK)) {
> + clk_set_rate(udc->uclk, 4800);
> + retval = clk_prepare(udc->uclk);
> + if (retval)
> + goto fail1;
> + }
> + retval = clk_prepare(udc->fclk);
> + if (retval)
> + goto fail1a;
> +
>   retval = clk_prepare_enable(udc->iclk);
>   if (retval)
> - goto fail1;
> + goto fail1b;
>   at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS);
>   at91_udp_write(udc, AT91_UDP_IDR, 0x);
>   /* Clear all pending interrupts - UDP may be used by bootloader. */
>   at91_udp_write(udc, AT91_UDP_ICR, 0x);
> - clk_disable_unprepare(udc->iclk);
> + clk_disable(udc->iclk);
>  
>   /* request UDC and maybe VBUS irqs */
>   udc->udp_irq = platform_get_irq(pdev, 0);
> @@ -1795,7 +1803,7 @@ static int at91udc_probe(struct platform_device *pdev)
>   0, driver_name, udc);
>   if (retval < 0) {
>   DBG("request irq %d failed\n", udc->udp_irq);
> - goto fail1;
> + goto fail1c;
>   }
>   if (gpio_is_valid(udc->board.vbus_pin)) {
>   retval = gpio_request(udc->board.vbus_pin, "udc_vbus");
> @@ -1848,6 +1856,13 @@ fail3:
>   gpio_free(udc->board.vbus_pin);
>  fail2:
>   free_irq(udc->udp_irq, udc);
> +fail1c:
> + clk_unprepare(udc->iclk);
> +fail1b:
> + clk_unprepare(udc->fclk);
> +fail1a:
> + if (IS_ENABLED(CONFIG_COMMON_CLK))
> + clk_unprepare(udc->uclk);
>  fail1:
>   if (IS_ENABLED(CONFIG_COMMON_CLK) && !IS_ERR(udc->uclk))
>   clk_put(udc->uclk);
> @@ -1896,6 +1911,11 @@ static int __exit at91udc_remove(struct 
> platform_device *pdev)
>   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>   release_mem_region(res->start, resource_size(res));
>  
> + if (IS_ENABLED(CONFIG_COMMON_CLK))
> + clk_unprepare(udc->uclk);
> + clk_unprepare(udc->fclk);
> + clk_unprepare(udc->iclk);
> +
>   clk_put(udc->iclk);
>   clk_put(udc->fclk);
>   if (IS_ENABLED(CONFIG_COMMON_CLK))
> -- 
> 1.9.3
> 
> 
> ___
> linux-arm-kernel mailing list
> linux-arm-ker...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.

CONFIDENTIAL

2014-08-08 Thread Google Incorporation®
Dear Google User,



Attached to this e-mail is your official Google User Reward Promotion 
notification for being an
active user of Google Services.

Best Regards,
Larry Page
Chairman Google UK.

©2014 Google Incorporation®

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv2 07/13] usb: dwc2: Update common interrupt handler to call gadget interrupt handler

2014-08-08 Thread Dinh Nguyen
On Wed, Jul 30, 2014 at 1:38 PM, Paul Zimmerman
 wrote:
>> From: linux-usb-ow...@vger.kernel.org 
>> [mailto:linux-usb-ow...@vger.kernel.org] On Behalf Of dingu...@altera.com
>> Sent: Wednesday, July 30, 2014 8:21 AM
>>
>> Make dwc2_handle_common_intr call the gadget interrupt function when 
>> operating
>> in peripheral mode. Remove the spinlock functions in s3c_hsotg_irq as
>> dwc2_handle_common_intr() already has the spinlocks.
>>
>> Remove duplicate interrupt conditions that was in gadget, as those are 
>> handled
>> by dwc2 common interrupt handler.
>>
>> Signed-off-by: Dinh Nguyen 
>> ---
>> v2: Keep interrupt handler for host and peripheral modes separate
>> ---
>>  drivers/usb/dwc2/core.h  |3 +++
>>  drivers/usb/dwc2/core_intr.c |3 +++
>>  drivers/usb/dwc2/gadget.c|   50 
>> --
>>  3 files changed, 10 insertions(+), 46 deletions(-)
>>
>> diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
>> index 28541a8..b86673c 100644
>> --- a/drivers/usb/dwc2/core.h
>> +++ b/drivers/usb/dwc2/core.h
>> @@ -961,12 +961,15 @@ extern u16 dwc2_get_otg_version(struct dwc2_hsotg 
>> *hsotg);
>>  extern int s3c_hsotg_remove(struct dwc2_hsotg *hsotg);
>>  extern void s3c_hsotg_core_init(struct dwc2_hsotg *dwc2);
>>  extern int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq);
>> +irqreturn_t s3c_hsotg_irq(int irq, void *pw);
>>  #else
>>  static inline void s3c_hsotg_core_init(struct dwc2_hsotg *dwc2) {}
>>  static inline int s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
>>  { return 0; }
>>  static inline int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
>>  { return 0; }
>> +static inline irqreturn_t s3c_hsotg_irq(int irq, void *pw)
>> +{ return IRQ_HANDLED; }
>>  #endif
>>
>>  #if defined(CONFIG_USB_DWC2_HOST) || defined(CONFIG_USB_DWC2_DUAL_ROLE)
>> diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
>> index c93918b..24d4c0d 100644
>> --- a/drivers/usb/dwc2/core_intr.c
>> +++ b/drivers/usb/dwc2/core_intr.c
>> @@ -472,6 +472,9 @@ irqreturn_t dwc2_handle_common_intr(int irq, void *dev)
>>
>>   spin_lock(&hsotg->lock);
>>
>> + if (dwc2_is_device_mode(hsotg))
>> + retval = s3c_hsotg_irq(irq, dev);
>> +
>
> Don't you want to release the spinlock and exit the function here if in
> device mode? Otherwise it continues on and does a bunch of checks for
> things that should only happen in host mode.
>

This part handles common interrupts for the core that can happen
regardless of what mode it's operating in. Things such as disconnect,
connect ID change are handle here.

Dinh
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/3] usb: gadget/uvc: fix possible lockup in uvc gadget

2014-08-08 Thread Michael Grzeschik
If the pending buffers in the queue could not be pushed to the udc
endpoint we have to cancel the uvc_queue. Otherwise the gadget will get
stuck on this error. This patch calls uvc_queue_cancel if usb_ep_queue
failed.

Signed-off-by: Michael Grzeschik 
---
v1 -> v2:
 - moved uvc_queue_cancel outside the spinlock

 drivers/usb/gadget/uvc_video.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/gadget/uvc_video.c b/drivers/usb/gadget/uvc_video.c
index 71e896d..a5eb9a3 100644
--- a/drivers/usb/gadget/uvc_video.c
+++ b/drivers/usb/gadget/uvc_video.c
@@ -195,6 +195,7 @@ uvc_video_complete(struct usb_ep *ep, struct usb_request 
*req)
printk(KERN_INFO "Failed to queue request (%d).\n", ret);
usb_ep_set_halt(ep);
spin_unlock_irqrestore(&video->queue.irqlock, flags);
+   uvc_queue_cancel(queue, 0);
goto requeue;
}
spin_unlock_irqrestore(&video->queue.irqlock, flags);
@@ -281,6 +282,7 @@ error:
 static int
 uvc_video_pump(struct uvc_video *video)
 {
+   struct uvc_video_queue *queue = &video->queue;
struct usb_request *req;
struct uvc_buffer *buf;
unsigned long flags;
@@ -322,6 +324,7 @@ uvc_video_pump(struct uvc_video *video)
printk(KERN_INFO "Failed to queue request (%d)\n", ret);
usb_ep_set_halt(video->ep);
spin_unlock_irqrestore(&video->queue.irqlock, flags);
+   uvc_queue_cancel(queue, 0);
break;
}
spin_unlock_irqrestore(&video->queue.irqlock, flags);
-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 2/3] usb: gadget/uvc: also handle v4l2 ioctl ENUM_FMT

2014-08-08 Thread Michael Grzeschik
This patch adds ENUM_FMT as possible ioctl to the uvc v4l2 device.
That makes userspace applications with a generic IOCTL calling
convention make also use of it.

Signed-off-by: Michael Grzeschik 
---
v1 -> v2:
 - changed first switch case to simple if
 - added separate function
 - added description field
 - bail out on array boundaries

 drivers/usb/gadget/uvc_v4l2.c | 30 --
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/uvc_v4l2.c b/drivers/usb/gadget/uvc_v4l2.c
index ad48e81..58633bf 100644
--- a/drivers/usb/gadget/uvc_v4l2.c
+++ b/drivers/usb/gadget/uvc_v4l2.c
@@ -55,14 +55,30 @@ struct uvc_format
 {
u8 bpp;
u32 fcc;
+   char *description;
 };

 static struct uvc_format uvc_formats[] = {
-   { 16, V4L2_PIX_FMT_YUYV  },
-   { 0,  V4L2_PIX_FMT_MJPEG },
+   { 16, V4L2_PIX_FMT_YUYV, "YUV 4:2:2" },
+   { 0,  V4L2_PIX_FMT_MJPEG, "MJPEG" },
 };

 static int
+uvc_v4l2_enum_format(struct uvc_video *video, struct v4l2_fmtdesc *fmt)
+{
+
+   int index = fmt->index;
+
+   if (index >= ARRAY_SIZE(uvc_formats))
+   return -EINVAL;
+
+   strcpy(fmt->description, uvc_formats[index].description);
+   fmt->pixelformat = uvc_formats[index].fcc;
+
+   return 0;
+}
+
+static int
 uvc_v4l2_get_format(struct uvc_video *video, struct v4l2_format *fmt)
 {
fmt->fmt.pix.pixelformat = video->fcc;
@@ -183,6 +199,16 @@ uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, 
void *arg)
break;
}

+   case VIDIOC_ENUM_FMT:
+   {
+   struct v4l2_fmtdesc *fmt = arg;
+
+   if (fmt->type != video->queue.queue.type)
+   return -EINVAL;
+
+   return uvc_v4l2_enum_format(video, fmt);
+   }
+
/* Get & Set format */
case VIDIOC_G_FMT:
{
--
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 3/3] usb: gadget/uvc: bump isoc requests from 4 to 16

2014-08-08 Thread Michael Grzeschik
While sending bigger images it is better to use more isochronous
requests in flight. This patch bumps the default from 4 to 16.

Signed-off-by: Michael Grzeschik 
---
 drivers/usb/gadget/uvc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/uvc.h b/drivers/usb/gadget/uvc.h
index 7a9111d..49d9573 100644
--- a/drivers/usb/gadget/uvc.h
+++ b/drivers/usb/gadget/uvc.h
@@ -99,7 +99,7 @@ extern unsigned int uvc_gadget_trace_param;
 #define DRIVER_VERSION "0.1.0"
 #define DRIVER_VERSION_NUMBER  KERNEL_VERSION(0, 1, 0)
 
-#define UVC_NUM_REQUESTS   4
+#define UVC_NUM_REQUESTS   16
 #define UVC_MAX_REQUEST_SIZE   64
 #define UVC_MAX_EVENTS 4
 
-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 0/3] usb: gadget/uvc: simple fixes and ENUM_FMT

2014-08-08 Thread Michael Grzeschik
This series fixes a possible lock in the uvc-gadget.
It also adds ENUM_FMT to the v4l2 ioctl list. This
way it will be possible to use gstreamer with it.
At last we increase isoc requests in flight.

Cheers,
Michael

Michael Grzeschik (3):
  usb: gadget/uvc: fix possible lockup in uvc gadget
  usb: gadget/uvc: also handle v4l2 ioctl ENUM_FMT
  usb: gadget/uvc: bump isoc requests from 4 to 16

 drivers/usb/gadget/uvc.h   |  2 +-
 drivers/usb/gadget/uvc_v4l2.c  | 30 --
 drivers/usb/gadget/uvc_video.c |  3 +++
 3 files changed, 32 insertions(+), 3 deletions(-)

-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 2/4] usb: dwc2: add compatible data for rockchip soc

2014-08-08 Thread Doug Anderson
Kever

On Thu, Aug 7, 2014 at 8:55 PM, Kever Yang  wrote:
> This patch add compatible data for dwc2 controller found on
> rk3066, rk3188 and rk3288 processors from rockchip.
>
> Signed-off-by: Kever Yang 
> Acked-by: Paul Zimmerman 
> ---
>
> Changes in v5:
> - max_transfer_size change to 65535 to met the requirement of
>   header file
>
> Changes in v4:
> - max_transfer_size change to 65536, this should be enough
>   for most transfer, the hardware auto-detect will set this
>   to 0x7 which may make dma_alloc_coherent fail when
>   non-dword aligned buf from driver like usbnet happen.
>
> Changes in v3: None
> Changes in v2:
> - set most parameters as driver auto-detect
>
>  drivers/usb/dwc2/platform.c | 29 +
>  1 file changed, 29 insertions(+)

IMHO this series is ready to go in for 3.18 whenever maintainers feel
it's the right time.

Reviewed-by: Doug Anderson 
Tested-by: Doug Anderson 
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Resend Re: [PATCH v6] usb:serial:pl2303: add GPIOs interface on PL2303

2014-08-08 Thread Wang YanQing
On Fri, Aug 08, 2014 at 09:54:42AM +0200, Johan Hovold wrote:
> On Fri, Aug 08, 2014 at 03:10:34AM +0800, Wang YanQing wrote:
> > On Tue, Aug 05, 2014 at 03:54:08PM +0200, Johan Hovold wrote:
> > > > > I noticed that setting direction to output and setting the gpio high 
> > > > > has
> > > > > no effect on the read-back value (i.e. I still read back 0) for my
> > > > > pl2303hx (note that my device has no easily accessible gpios so I
> > > > > haven't verified the actual state of the output pin).
> > > > > 
> > > > > What happens on your system? Is the read-back value still 0, even when
> > > > > the GPIO output is actually high? Should we return the cached value in
> > > > > this case?
> > > > 
> > > > If i set direction to output, then I could control gpio high and low
> > > > by set 1 or 0, and the read-back value is 1 or 0 according to high and
> > > > low(I test high and low by oscillscope)
> > > > 
> > > > I test it with my pl2303hx with only two gpios.
> > > >
> > > > Could you use usbmon to see whether the traffic is right according
> > > > to comment in struct pl2303_gpio?
> > > 
> > > The traffic appears correct judging from the debug output (which I
> > > trust). Output-enable is reflected in register 0x81, but the value
> > > isn't.
> > > 
> > > What is the lsusb -v output for your device?
> > 
> > Bus 001 Device 005: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial 
> > Port.
> 
> You forgot the verbose flag (-v).
Sorry, below is output with -v:
Bus 002 Device 004: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Device Descriptor:
  bLength18
  bDescriptorType 1
  bcdUSB   1.10
  bDeviceClass0 (Defined at Interface level)
  bDeviceSubClass 0 
  bDeviceProtocol 0 
  bMaxPacketSize064
  idVendor   0x067b Prolific Technology, Inc.
  idProduct  0x2303 PL2303 Serial Port
  bcdDevice3.00
  iManufacturer   1 Prolific Technology Inc.
  iProduct2 USB-Serial Controller
  iSerial 0 
  bNumConfigurations  1
  Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength   39
bNumInterfaces  1
bConfigurationValue 1
iConfiguration  0 
bmAttributes 0x80
  (Bus Powered)
MaxPower  100mA
Interface Descriptor:
  bLength 9
  bDescriptorType 4
  bInterfaceNumber0
  bAlternateSetting   0
  bNumEndpoints   3
  bInterfaceClass   255 Vendor Specific Class
  bInterfaceSubClass  0 
  bInterfaceProtocol  0 
  iInterface  0 
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81  EP 1 IN
bmAttributes3
  Transfer TypeInterrupt
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x000a  1x 10 bytes
bInterval   1
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02  EP 2 OUT
bmAttributes2
  Transfer TypeBulk
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0040  1x 64 bytes
bInterval   0
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83  EP 3 IN
bmAttributes2
  Transfer TypeBulk
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0040  1x 64 bytes
bInterval   0
Device Status: 0x
  (Bus Powered)
>  
> > It is strange your device doesn't work, I verify the control method by
> > analyze usbmon output from linux host which has VirtualBox running 
> > gpio test program, but I don't have right to distribute the gpio test
> > program I think, so I can't help you to figure out why it doesn't work 
> > for your device.
> 
> What do you use the gpio test program for? I thought you verified the
> gpios with a scope?

Yes, I verified gpios with a scope.

"
You must allocate the buffer dynamically as some platforms cannot do DMA to the 
stack.
"
Thanks very much for point out it, could you clarify it? 
I want to know the reason.

I am working on next version patch and hope it could be finished this weekend. 
:)

Thanks again.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv3 11/12] usb: dwc2: check that the host work queue is valid

2014-08-08 Thread dinguyen
From: Dinh Nguyen 

The Host workqueue will not get initialized if the driver is configured for
peripheral mode only. Thus we need to check for wq_otg before calling
queue_work().

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/core_intr.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index 651785d..1240875 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -287,9 +287,11 @@ static void dwc2_handle_conn_id_status_change_intr(struct 
dwc2_hsotg *hsotg)
 * Release lock before scheduling workq as it holds spinlock during
 * scheduling.
 */
-   spin_unlock(&hsotg->lock);
-   queue_work(hsotg->wq_otg, &hsotg->wf_otg);
-   spin_lock(&hsotg->lock);
+   if (hsotg->wq_otg) {
+   spin_unlock(&hsotg->lock);
+   queue_work(hsotg->wq_otg, &hsotg->wf_otg);
+   spin_lock(&hsotg->lock);
+   }
 
/* Clear interrupt */
writel(GINTSTS_CONIDSTSCHNG, hsotg->regs + GINTSTS);
-- 
2.0.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv3 10/12] usb: dwc2: Add suspend/resume for gadget

2014-08-08 Thread dinguyen
From: Dinh Nguyen 

Move suspend/resume code to common platform code.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/core.h |  6 ++
 drivers/usb/dwc2/gadget.c   |  4 ++--
 drivers/usb/dwc2/platform.c | 23 +++
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index bbb0f52..5bb7e801 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -964,12 +964,18 @@ extern u16 dwc2_get_otg_version(struct dwc2_hsotg *hsotg);
 #if defined(CONFIG_USB_DWC2_PERIPHERAL) || defined(CONFIG_USB_DWC2_DUAL_ROLE)
 extern int s3c_hsotg_remove(struct dwc2_hsotg *hsotg);
 extern void s3c_hsotg_core_init(struct dwc2_hsotg *dwc2);
+extern int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2);
+extern int s3c_hsotg_resume(struct dwc2_hsotg *dwc2);
 extern int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq);
 irqreturn_t s3c_hsotg_irq(int irq, void *pw);
 #else
 static inline void s3c_hsotg_core_init(struct dwc2_hsotg *dwc2) {}
 static inline int s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
 { return 0; }
+static inline int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2)
+{ return 0; }
+static inline int s3c_hsotg_resume(struct dwc2_hsotg *dwc2)
+{ return 0; }
 static inline int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
 { return 0; }
 static inline irqreturn_t s3c_hsotg_irq(int irq, void *pw)
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index a3a3d31..2d98100 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3555,7 +3555,7 @@ int s3c_hsotg_remove(struct dwc2_hsotg *hsotg)
return 0;
 }
 
-static int s3c_hsotg_suspend(struct dwc2_hsotg *hsotg)
+int s3c_hsotg_suspend(struct dwc2_hsotg *hsotg)
 {
unsigned long flags;
int ret = 0;
@@ -3584,7 +3584,7 @@ static int s3c_hsotg_suspend(struct dwc2_hsotg *hsotg)
return ret;
 }
 
-static int s3c_hsotg_resume(struct dwc2_hsotg *hsotg)
+int s3c_hsotg_resume(struct dwc2_hsotg *hsotg)
 {
unsigned long flags;
int ret = 0;
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 6e30289..2a67dad 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -206,6 +206,27 @@ static int dwc2_driver_probe(struct platform_device *dev)
return retval;
 }
 
+static int dwc2_suspend(struct platform_device *dev, pm_message_t state)
+{
+   struct dwc2_hsotg *dwc2 = platform_get_drvdata(dev);
+   int ret = 0;
+
+   if (dwc2_is_device_mode(dwc2))
+   ret = s3c_hsotg_suspend(dwc2);
+   return ret;
+}
+
+static int dwc2_resume(struct platform_device *dev)
+{
+   struct dwc2_hsotg *dwc2 = platform_get_drvdata(dev);
+   int ret = 0;
+
+   if (dwc2_is_device_mode(dwc2))
+   ret = s3c_hsotg_resume(dwc2);
+
+   return ret;
+}
+
 static struct platform_driver dwc2_platform_driver = {
.driver = {
.name = dwc2_driver_name,
@@ -213,6 +234,8 @@ static struct platform_driver dwc2_platform_driver = {
},
.probe = dwc2_driver_probe,
.remove = dwc2_driver_remove,
+   .suspend = dwc2_suspend,
+   .resume = dwc2_resume,
 };
 
 module_platform_driver(dwc2_platform_driver);
-- 
2.0.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv3 02/12] usb: dwc2: move "samsung,s3c6400-hsotg" into common platform

2014-08-08 Thread dinguyen
From: Dinh Nguyen 

Move the "samsung,s3c6400-hsotg" binding as the probe function in the gadget
driver will get removed when the dual-role driver is implemented.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/gadget.c   | 1 -
 drivers/usb/dwc2/platform.c | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index cc31088..c62f6c2 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3678,7 +3678,6 @@ static int s3c_hsotg_resume(struct platform_device *pdev)
 
 #ifdef CONFIG_OF
 static const struct of_device_id s3c_hsotg_of_ids[] = {
-   { .compatible = "samsung,s3c6400-hsotg", },
{ .compatible = "snps,dwc2", },
{ /* sentinel */ }
 };
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 5f0c4bb..dd2f8f5 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -100,6 +100,7 @@ static int dwc2_driver_remove(struct platform_device *dev)
 static const struct of_device_id dwc2_of_match_table[] = {
{ .compatible = "brcm,bcm2835-usb", .data = ¶ms_bcm2835 },
{ .compatible = "snps,dwc2", .data = NULL },
+   { .compatible = "samsung,s3c6400-hsotg", .data = NULL},
{},
 };
 MODULE_DEVICE_TABLE(of, dwc2_of_match_table);
-- 
2.0.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv3 04/12] usb: dwc2: Add the appropriate init calls in platform code

2014-08-08 Thread dinguyen
From: Dinh Nguyen 

Add the proper init calls for either host, gadget or both in platform.c

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/core.h | 13 +
 drivers/usb/dwc2/gadget.c   |  2 +-
 drivers/usb/dwc2/platform.c | 28 
 3 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index f55e62d..3a49a00 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -960,6 +960,19 @@ extern void dwc2_dump_global_registers(struct dwc2_hsotg 
*hsotg);
  */
 extern u16 dwc2_get_otg_version(struct dwc2_hsotg *hsotg);
 
+/* Gadget defines */
+#if defined(CONFIG_USB_DWC2_PERIPHERAL) || defined(CONFIG_USB_DWC2_DUAL_ROLE)
+extern int s3c_hsotg_remove(struct dwc2_hsotg *hsotg);
+extern void s3c_hsotg_core_init(struct dwc2_hsotg *dwc2);
+extern int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq);
+#else
+static inline void s3c_hsotg_core_init(struct dwc2_hsotg *dwc2) {}
+static inline int s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
+{ return 0; }
+static inline int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
+{ return 0; }
+#endif
+
 #if defined(CONFIG_USB_DWC2_HOST) || defined(CONFIG_USB_DWC2_DUAL_ROLE)
 /**
  * dwc2_hcd_get_frame_number() - Returns current frame number
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index ff000c9..d40f765 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3575,7 +3575,7 @@ err_clk:
  * s3c_hsotg_remove - remove function for hsotg driver
  * @pdev: The platform information for the driver
  */
-static int s3c_hsotg_remove(struct dwc2_hsotg *hsotg)
+int s3c_hsotg_remove(struct dwc2_hsotg *hsotg)
 {
usb_del_gadget_udc(&hsotg->gadget);
 
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index dd2f8f5..2871f351 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -92,7 +92,14 @@ static int dwc2_driver_remove(struct platform_device *dev)
 {
struct dwc2_hsotg *hsotg = platform_get_drvdata(dev);
 
-   dwc2_hcd_remove(hsotg);
+   if (IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL))
+   s3c_hsotg_remove(hsotg);
+   else if (IS_ENABLED(CONFIG_USB_DWC2_HOST))
+   dwc2_hcd_remove(hsotg);
+   else { /* dual role */
+   dwc2_hcd_remove(hsotg);
+   s3c_hsotg_remove(hsotg);
+   }
 
return 0;
 }
@@ -176,9 +183,22 @@ static int dwc2_driver_probe(struct platform_device *dev)
 
hsotg->dr_mode = of_usb_get_dr_mode(dev->dev.of_node);
 
-   retval = dwc2_hcd_init(hsotg, irq, params);
-   if (retval)
-   return retval;
+   if (IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)) {
+   retval = dwc2_gadget_init(hsotg, irq);
+   if (retval)
+   return retval;
+   retval = dwc2_hcd_init(hsotg, irq, params);
+   if (retval)
+   return retval;
+   } else if (IS_ENABLED(CONFIG_USB_DWC2_HOST)) {
+   retval = dwc2_hcd_init(hsotg, irq, params);
+   if (retval)
+   return retval;
+   } else if (IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL)) {
+   retval = dwc2_gadget_init(hsotg, irq);
+   if (retval)
+   return retval;
+   }
 
platform_set_drvdata(dev, hsotg);
 
-- 
2.0.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv3 08/12] usb: dwc2: gadget: Do not fail probe if there isn't a clock node

2014-08-08 Thread dinguyen
From: Dinh Nguyen 

Since the dwc2 hcd driver is currently not looking for a clock node during
init, we should not completely fail if there isn't a clock provided.
Add a check for a valid clock before calling clock functions.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/gadget.c | 36 ++--
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index d8b86a3..a3a3d31 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2854,7 +2854,8 @@ static int s3c_hsotg_udc_start(struct usb_gadget *gadget,
hsotg->gadget.dev.of_node = hsotg->dev->of_node;
hsotg->gadget.speed = USB_SPEED_UNKNOWN;
 
-   clk_enable(hsotg->clk);
+   if (!IS_ERR(hsotg->clk))
+   clk_enable(hsotg->clk);
 
ret = regulator_bulk_enable(ARRAY_SIZE(hsotg->supplies),
hsotg->supplies);
@@ -2905,7 +2906,8 @@ static int s3c_hsotg_udc_stop(struct usb_gadget *gadget,
regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies),
hsotg->supplies);
 
-   clk_disable(hsotg->clk);
+   if (!IS_ERR(hsotg->clk))
+   clk_disable(hsotg->clk);
 
return 0;
 }
@@ -2938,10 +2940,12 @@ static int s3c_hsotg_pullup(struct usb_gadget *gadget, 
int is_on)
spin_lock_irqsave(&hsotg->lock, flags);
if (is_on) {
s3c_hsotg_phy_enable(hsotg);
-   clk_enable(hsotg->clk);
+   if (!IS_ERR(hsotg->clk))
+   clk_enable(hsotg->clk);
s3c_hsotg_core_init(hsotg);
} else {
-   clk_disable(hsotg->clk);
+   if (!IS_ERR(hsotg->clk))
+   clk_disable(hsotg->clk);
s3c_hsotg_phy_disable(hsotg);
}
 
@@ -3412,16 +3416,15 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
}
 
hsotg->clk = devm_clk_get(dev, "otg");
-   if (IS_ERR(hsotg->clk)) {
-   dev_err(dev, "cannot get otg clock\n");
-   return PTR_ERR(hsotg->clk);
-   }
+   if (IS_ERR(hsotg->clk))
+   dev_warn(dev, "cannot get otg clock\n");
 
hsotg->gadget.max_speed = USB_SPEED_HIGH;
hsotg->gadget.ops = &s3c_hsotg_gadget_ops;
hsotg->gadget.name = dev_name(dev);
 
-   clk_prepare_enable(hsotg->clk);
+   if (!IS_ERR(hsotg->clk))
+   clk_prepare_enable(hsotg->clk);
 
/* regulators */
 
@@ -3454,7 +3457,8 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
dev_name(dev), hsotg);
if (ret < 0) {
s3c_hsotg_phy_disable(hsotg);
-   clk_disable_unprepare(hsotg->clk);
+   if (!IS_ERR(hsotg->clk))
+   clk_disable_unprepare(hsotg->clk);
regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies),
   hsotg->supplies);
dev_err(dev, "cannot claim IRQ\n");
@@ -3524,7 +3528,8 @@ err_ep_mem:
 err_supplies:
s3c_hsotg_phy_disable(hsotg);
 err_clk:
-   clk_disable_unprepare(hsotg->clk);
+   if (!IS_ERR(hsotg->clk))
+   clk_disable_unprepare(hsotg->clk);
 
return ret;
 }
@@ -3544,7 +3549,8 @@ int s3c_hsotg_remove(struct dwc2_hsotg *hsotg)
usb_gadget_unregister_driver(hsotg->driver);
}
 
-   clk_disable_unprepare(hsotg->clk);
+   if (!IS_ERR(hsotg->clk))
+   clk_disable_unprepare(hsotg->clk);
 
return 0;
 }
@@ -3571,7 +3577,8 @@ static int s3c_hsotg_suspend(struct dwc2_hsotg *hsotg)
 
ret = regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies),
 hsotg->supplies);
-   clk_disable(hsotg->clk);
+   if (!IS_ERR(hsotg->clk))
+   clk_disable(hsotg->clk);
}
 
return ret;
@@ -3586,7 +3593,8 @@ static int s3c_hsotg_resume(struct dwc2_hsotg *hsotg)
dev_info(hsotg->dev, "resuming usb gadget %s\n",
 hsotg->driver->driver.name);
 
-   clk_enable(hsotg->clk);
+   if (!IS_ERR(hsotg->clk))
+   clk_enable(hsotg->clk);
ret = regulator_bulk_enable(ARRAY_SIZE(hsotg->supplies),
   hsotg->supplies);
}
-- 
2.0.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv3 09/12] usb: dwc2: initialize the spin_lock for both host and gadget

2014-08-08 Thread dinguyen
From: Dinh Nguyen 

Move spin_lock_init to common location for both host and gadget.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/hcd.c  | 1 -
 drivers/usb/dwc2/platform.c | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 07a7bcd..c6778d9 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -2824,7 +2824,6 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
 
hcd->has_tt = 1;
 
-   spin_lock_init(&hsotg->lock);
((struct wrapper_priv_data *) &hcd->hcd_priv)->hsotg = hsotg;
hsotg->priv = hcd;
 
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 2871f351..6e30289 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -201,6 +201,7 @@ static int dwc2_driver_probe(struct platform_device *dev)
}
 
platform_set_drvdata(dev, hsotg);
+   spin_lock_init(&hsotg->lock);
 
return retval;
 }
-- 
2.0.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv3 05/12] usb: dwc2: Initialize the USB core for peripheral mode

2014-08-08 Thread dinguyen
From: Dinh Nguyen 

Initialize the USB driver to peripheral mode when a B-Device connector
is attached.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/hcd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 4d918ed..07a7bcd 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -1355,6 +1355,7 @@ static void dwc2_conn_id_status_change(struct work_struct 
*work)
hsotg->op_state = OTG_STATE_B_PERIPHERAL;
dwc2_core_init(hsotg, false, -1);
dwc2_enable_global_interrupts(hsotg);
+   s3c_hsotg_core_init(hsotg);
} else {
/* A-Device connector (Host Mode) */
dev_dbg(hsotg->dev, "connId A\n");
-- 
2.0.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv3 03/12] usb: dwc2: Update the gadget driver to use common dwc2_hsotg structure

2014-08-08 Thread dinguyen
From: Dinh Nguyen 

Adds the gadget data structure and appropriate data structure pointers
to the common dwc2_hsotg data structure. To keep the driver data
dereference code looking clean, the gadget variable declares are only available
for peripheral and dual-role mode. This is needed so that the dwc2_hsotg data
structure can be used by the hcd and gadget drivers.

Updates gadget.c to use the dwc2_hsotg data structure and gadget pointers
that have been moved into the common dwc2_hsotg structure. Along
with the updating the gadget driver to use the common dwc2_hsotg structure,
a few other things are required in order for this patch to build properly.
Those are:

- Remove gadget module defines. Since the driver probing will be handled
  by either the platform or pci code.
- Change the gadget probe function into gadget_init.

Signed-off-by: Dinh Nguyen 
Signed-off-by: Paul Zimmerman 
---
v3: Updated with paulz's suggestion to avoid double pointers.
v2: Left the function parameter name as 'hsotg' and just changed its type.
---
 drivers/usb/dwc2/core.h   | 176 ---
 drivers/usb/dwc2/gadget.c | 229 +-
 drivers/usb/dwc2/hcd.h|  10 --
 3 files changed, 185 insertions(+), 230 deletions(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index bf015ab..f55e62d 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -84,7 +84,7 @@ static const char * const s3c_hsotg_supply_names[] = {
  */
 #define EP0_MPS_LIMIT   64
 
-struct s3c_hsotg;
+struct dwc2_hsotg;
 struct s3c_hsotg_req;
 
 /**
@@ -130,7 +130,7 @@ struct s3c_hsotg_req;
 struct s3c_hsotg_ep {
struct usb_ep   ep;
struct list_headqueue;
-   struct s3c_hsotg*parent;
+   struct dwc2_hsotg   *parent;
struct s3c_hsotg_req*req;
struct dentry   *debugfs;
 
@@ -155,67 +155,6 @@ struct s3c_hsotg_ep {
 };
 
 /**
- * struct s3c_hsotg - driver state.
- * @dev: The parent device supplied to the probe function
- * @driver: USB gadget driver
- * @phy: The otg phy transceiver structure for phy control.
- * @uphy: The otg phy transceiver structure for old USB phy control.
- * @plat: The platform specific configuration data. This can be removed once
- * all SoCs support usb transceiver.
- * @regs: The memory area mapped for accessing registers.
- * @irq: The IRQ number we are using
- * @supplies: Definition of USB power supplies
- * @phyif: PHY interface width
- * @dedicated_fifos: Set if the hardware has dedicated IN-EP fifos.
- * @num_of_eps: Number of available EPs (excluding EP0)
- * @debug_root: root directrory for debugfs.
- * @debug_file: main status file for debugfs.
- * @debug_fifo: FIFO status file for debugfs.
- * @ep0_reply: Request used for ep0 reply.
- * @ep0_buff: Buffer for EP0 reply data, if needed.
- * @ctrl_buff: Buffer for EP0 control requests.
- * @ctrl_req: Request for EP0 control packets.
- * @setup: NAK management for EP0 SETUP
- * @last_rst: Time of last reset
- * @eps: The endpoints being supplied to the gadget framework
- */
-struct s3c_hsotg {
-   struct device*dev;
-   struct usb_gadget_driver *driver;
-   struct phy   *phy;
-   struct usb_phy   *uphy;
-   struct s3c_hsotg_plat*plat;
-
-   spinlock_t  lock;
-
-   void __iomem*regs;
-   int irq;
-   struct clk  *clk;
-
-   struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsotg_supply_names)];
-
-   u32 phyif;
-   int fifo_mem;
-   unsigned intdedicated_fifos:1;
-   unsigned char   num_of_eps;
-   u32 fifo_map;
-
-   struct dentry   *debug_root;
-   struct dentry   *debug_file;
-   struct dentry   *debug_fifo;
-
-   struct usb_request  *ep0_reply;
-   struct usb_request  *ctrl_req;
-   u8  ep0_buff[8];
-   u8  ctrl_buff[8];
-
-   struct usb_gadget   gadget;
-   unsigned intsetup;
-   unsigned long   last_rst;
-   struct s3c_hsotg_ep *eps;
-};
-
-/**
  * struct s3c_hsotg_req - data transfer request
  * @req: The USB gadget request
  * @queue: The list of requests for the endpoint this is queued for.
@@ -229,6 +168,7 @@ struct s3c_hsotg_req {
unsigned char   mapped;
 };
 
+#if defined(CONFIG_USB_DWC2_PERIPHERAL) || defined(CONFIG_USB_DWC2_DUAL_ROLE)
 #define call_gadget(_hs, _entry) \
 do { \
if ((_hs)->gadget.speed != USB_SPEED_UNKNOWN && \
@@ -238,6 +178,9 @@ do { \
spin_lock(&_hs->lock); \
} \
 } while (0)
+#else
+#define call_gadget(_hs, _entry)   do {} while (0)
+#endif
 
 struct dwc2_hsotg;
 struct dwc2_host_chan;
@@ -495,11 +438,13 @@ struct dwc2_hw_params {
  * struct dwc2_hsotg - Holds th

[PATCHv3 07/12] usb: dwc2: Add call_gadget functions for perpheral mode interrupts

2014-08-08 Thread dinguyen
From: Dinh Nguyen 

Update the dwc2 wakeup and suspend interrupt functions to use call_gadget
when the IP is in peripheral mode.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/core_intr.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index 24d4c0d..651785d 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -337,6 +337,7 @@ static void dwc2_handle_wakeup_detected_intr(struct 
dwc2_hsotg *hsotg)
}
/* Change to L0 state */
hsotg->lx_state = DWC2_L0;
+   call_gadget(hsotg, resume);
} else {
if (hsotg->lx_state != DWC2_L1) {
u32 pcgcctl = readl(hsotg->regs + PCGCTL);
@@ -397,6 +398,7 @@ static void dwc2_handle_usb_suspend_intr(struct dwc2_hsotg 
*hsotg)
"DSTS.Suspend Status=%d HWCFG4.Power Optimize=%d\n",
!!(dsts & DSTS_SUSPSTS),
hsotg->hw_params.power_optimized);
+   call_gadget(hsotg, suspend);
} else {
if (hsotg->op_state == OTG_STATE_A_PERIPHERAL) {
dev_dbg(hsotg->dev, "a_peripheral->a_host\n");
-- 
2.0.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv3 01/12] usb: dwc2: Update Kconfig to support dual-role

2014-08-08 Thread dinguyen
From: Dinh Nguyen 

Update DWC2 kconfig and makefile to support dual-role mode. The platform
file will always get compiled for the case where the controller is directly
connected to the CPU. So for loadable modules, only dwc2.ko is needed.

Signed-off-by: Dinh Nguyen 
---
v3: Add USB_GADGET=y and USB_GADGET=USB_DWC2 for peripheral and dual-role
config options.
v2: Remove reference to dwc2_gadget
---
 drivers/usb/dwc2/Kconfig  | 63 +++
 drivers/usb/dwc2/Makefile | 21 
 2 files changed, 47 insertions(+), 37 deletions(-)

diff --git a/drivers/usb/dwc2/Kconfig b/drivers/usb/dwc2/Kconfig
index f93807b..4396a1f 100644
--- a/drivers/usb/dwc2/Kconfig
+++ b/drivers/usb/dwc2/Kconfig
@@ -1,40 +1,29 @@
 config USB_DWC2
-   bool "DesignWare USB2 DRD Core Support"
+   tristate "DesignWare USB2 DRD Core Support"
depends on USB
help
  Say Y here if your system has a Dual Role Hi-Speed USB
  controller based on the DesignWare HSOTG IP Core.
 
- For host mode, if you choose to build the driver as dynamically
- linked modules, the core module will be called dwc2.ko, the PCI
- bus interface module (if you have a PCI bus system) will be
- called dwc2_pci.ko, and the platform interface module (for
- controllers directly connected to the CPU) will be called
- dwc2_platform.ko. For gadget mode, there will be a single
- module called dwc2_gadget.ko.
-
- NOTE: The s3c-hsotg driver is now renamed to dwc2_gadget. The
- host and gadget drivers are still currently separate drivers.
- There are plans to merge the dwc2_gadget driver with the dwc2
- host driver in the near future to create a dual-role driver.
+ If you choose to build the driver as dynamically
+ linked modules, a single dwc2.ko(regardless of mode of operation)
+ will get built for both platform IPs and PCI.
 
 if USB_DWC2
 
+choice
+   bool "DWC2 Mode Selection"
+   default USB_DWC2_DUAL_ROLE if (USB && USB_GADGET)
+   default USB_DWC2_HOST if (USB && !USB_GADGET)
+   default USB_DWC2_PERIPHERAL if (!USB && USB_GADGET)
+
 config USB_DWC2_HOST
-   tristate "Host only mode"
+   bool "Host only mode"
depends on USB
help
  The Designware USB2.0 high-speed host controller
- integrated into many SoCs.
-
-config USB_DWC2_PLATFORM
-   bool "DWC2 Platform"
-   depends on USB_DWC2_HOST
-   default USB_DWC2_HOST
-   help
- The Designware USB2.0 platform interface module for
- controllers directly connected to the CPU. This is only
- used for host mode.
+ integrated into many SoCs. Select this option if you want the
+ driver to operate in Host-only mode.
 
 config USB_DWC2_PCI
bool "DWC2 PCI"
@@ -47,11 +36,31 @@ config USB_DWC2_PCI
 comment "Gadget mode requires USB Gadget support to be enabled"
 
 config USB_DWC2_PERIPHERAL
-   tristate "Gadget only mode"
-   depends on USB_GADGET
+   bool "Gadget only mode"
+   depends on USB_GADGET=y || USB_GADGET=USB_DWC2
help
  The Designware USB2.0 high-speed gadget controller
- integrated into many SoCs.
+ integrated into many SoCs. Select this option if you want the
+ driver to operate in Peripheral-only mode. This option requires
+ USB_GADGET=y.
+
+config USB_DWC2_DUAL_ROLE
+   bool "Dual Role mode"
+   depends on ((USB=y || USB=USB_DWC2) && (USB_GADGET=y || 
USB_GADGET=USB_DWC2))
+   help
+ Select this option if you want the driver to work in a dual-role
+ mode. In this mode both host and gadget features are enabled, and
+ the role will be determined by the cable that gets plugged-in. This
+ option requires USB_GADGET=y.
+endchoice
+
+config USB_DWC2_PLATFORM
+   bool
+depends on !PCI
+default y
+help
+  The Designware USB2.0 platform interface module for
+  controllers directly connected to the CPU.
 
 config USB_DWC2_DEBUG
bool "Enable Debugging Messages"
diff --git a/drivers/usb/dwc2/Makefile b/drivers/usb/dwc2/Makefile
index b73d2a5..3026135 100644
--- a/drivers/usb/dwc2/Makefile
+++ b/drivers/usb/dwc2/Makefile
@@ -1,10 +1,17 @@
 ccflags-$(CONFIG_USB_DWC2_DEBUG)   += -DDEBUG
 ccflags-$(CONFIG_USB_DWC2_VERBOSE) += -DVERBOSE_DEBUG
 
-obj-$(CONFIG_USB_DWC2_HOST)+= dwc2.o
+obj-$(CONFIG_USB_DWC2) += dwc2.o
 dwc2-y := core.o core_intr.o
-dwc2-y += hcd.o hcd_intr.o
-dwc2-y += hcd_queue.o hcd_ddma.o
+
+ifneq ($(filter y,$(CONFIG_USB_DWC2_HOST) $(CONFIG_USB_DWC2_DUAL_ROLE)),)
+   dwc2-y  += hcd.o hcd_intr.o
+   dwc2-y  += hcd_queue.o hcd_ddma.o
+endif
+
+ifneq ($(filter y,$(C

[PATCHv3 12/12] usb: dwc2: pci: Update pci portion of the dwc2 driver

2014-08-08 Thread dinguyen
From: Dinh Nguyen 

Initialize the spinlock here as the original spinlock in the host driver
has been removed.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc2/pci.c b/drivers/usb/dwc2/pci.c
index c291fca..faacac9 100644
--- a/drivers/usb/dwc2/pci.c
+++ b/drivers/usb/dwc2/pci.c
@@ -148,6 +148,7 @@ static int dwc2_driver_probe(struct pci_dev *dev,
}
 
pci_set_drvdata(dev, hsotg);
+   spin_lock_init(&hsotg->lock);
 
return retval;
 }
-- 
2.0.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv3 00/12] usb: dwc2: Add support for dual role

2014-08-08 Thread dinguyen
From: Dinh Nguyen 

Hello,

This is version 3 of the patch series that combines the dwc2 gadget and host
driver into a single dual role driver. Here are the main differences from V2:

- less code change:
v3: 9 files changed, 340 insertions(+), 335 deletions(-)
v2: 9 files changed, 368 insertions(+), 357 deletions(-)
v1: 9 files changed, 877 insertions(+), 904 deletions(-)

- Patch 1/12 : Add a USB_GADGET=USB_DWC2 dependency for peripheral and
  dual-role builds

- Patch 3/12 : Per paulz's code suggestion to avoid a double pointer usage in
  order to keep the gadget driver cleaner, the gadget variable declarations
  are only visible for peripheral and dual-role builds of the driver.

  Also, in a effort to maintain bisectability, move v2's [usb: dwc2: Moves
  s3c_hsotg gadget data structure into dwc2_hsotg] and [usb: dwc2: update
  gadget portion to use common dwc2_hsotg structure] into a single patch for
  v3. In V3, a single patch [usb: dwc2: Moves s3c_hsotg gadget data structure
  into dwc2_hsotg] is the result. For this series, there are 12 patches
  instead of 13.

For v3, I have rebased the series on top of the following patches:

Doug Anderson: usb: dwc2: Read GNPTXFSIZ when in forced HOST mode
Kever Yang : usb: dwc2: add 'mode' which based on Kconfig select or dts setting
Robert Baldyga : usb: dwc2/gadget: fix series <- 12 patches

As usual, tested on SOCFPGA(host, gadget, and dual-role) and on Rpi-B(host 
mode).

This patch series is based on v3.16. I have pushed this a git repo to make
it more convenient for people to test/review.

git://git.rocketboards.org/linux-socfpga-next.git dwc2_dual_role_v3

Thanks,

Dinh Nguyen (12):
  usb: dwc2: Update Kconfig to support dual-role
  usb: dwc2: move "samsung,s3c6400-hsotg" into common platform
  usb: dwc2: Update the gadget driver to use common dwc2_hsotg structure
  usb: dwc2: Add the appropriate init calls in platform code
  usb: dwc2: Initialize the USB core for peripheral mode
  usb: dwc2: Update common interrupt handler to call gadget interrupt
handler
  usb: dwc2: Add call_gadget functions for perpheral mode interrupts
  usb: dwc2: gadget: Do not fail probe if there isn't a clock node
  usb: dwc2: initialize the spin_lock for both host and gadget
  usb: dwc2: Add suspend/resume for gadget
  usb: dwc2: check that the host work queue is valid
  usb: dwc2: pci: Update pci portion of the dwc2 driver

 drivers/usb/dwc2/Kconfig |  63 +
 drivers/usb/dwc2/Makefile|  21 +--
 drivers/usb/dwc2/core.h  | 198 ---
 drivers/usb/dwc2/core_intr.c |  13 +-
 drivers/usb/dwc2/gadget.c| 314 +++
 drivers/usb/dwc2/hcd.c   |   2 +-
 drivers/usb/dwc2/hcd.h   |  10 --
 drivers/usb/dwc2/pci.c   |   1 +
 drivers/usb/dwc2/platform.c  |  53 +++-
 9 files changed, 340 insertions(+), 335 deletions(-)

-- 
2.0.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv3 06/12] usb: dwc2: Update common interrupt handler to call gadget interrupt handler

2014-08-08 Thread dinguyen
From: Dinh Nguyen 

Make dwc2_handle_common_intr call the gadget interrupt function when operating
in peripheral mode. Remove the spinlock functions in s3c_hsotg_irq as
dwc2_handle_common_intr() already has the spinlocks.

Remove duplicate interrupt conditions that was in gadget, as those are handled
by dwc2 common interrupt handler.

Signed-off-by: Dinh Nguyen 
---
v2: Keep interrupt handler for host and peripheral modes separate
---
 drivers/usb/dwc2/core.h  |  3 +++
 drivers/usb/dwc2/core_intr.c |  3 +++
 drivers/usb/dwc2/gadget.c| 50 
 3 files changed, 10 insertions(+), 46 deletions(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 3a49a00..bbb0f52 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -965,12 +965,15 @@ extern u16 dwc2_get_otg_version(struct dwc2_hsotg *hsotg);
 extern int s3c_hsotg_remove(struct dwc2_hsotg *hsotg);
 extern void s3c_hsotg_core_init(struct dwc2_hsotg *dwc2);
 extern int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq);
+irqreturn_t s3c_hsotg_irq(int irq, void *pw);
 #else
 static inline void s3c_hsotg_core_init(struct dwc2_hsotg *dwc2) {}
 static inline int s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
 { return 0; }
 static inline int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
 { return 0; }
+static inline irqreturn_t s3c_hsotg_irq(int irq, void *pw)
+{ return IRQ_HANDLED; }
 #endif
 
 #if defined(CONFIG_USB_DWC2_HOST) || defined(CONFIG_USB_DWC2_DUAL_ROLE)
diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index c93918b..24d4c0d 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -472,6 +472,9 @@ irqreturn_t dwc2_handle_common_intr(int irq, void *dev)
 
spin_lock(&hsotg->lock);
 
+   if (dwc2_is_device_mode(hsotg))
+   retval = s3c_hsotg_irq(irq, dev);
+
gintsts = dwc2_read_common_intr(hsotg);
if (gintsts & ~GINTSTS_PRTINT)
retval = IRQ_HANDLED;
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index d40f765..d8b86a3 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2259,14 +2259,13 @@ void s3c_hsotg_core_init(struct dwc2_hsotg *hsotg)
  * @irq: The IRQ number triggered
  * @pw: The pw value when registered the handler.
  */
-static irqreturn_t s3c_hsotg_irq(int irq, void *pw)
+irqreturn_t s3c_hsotg_irq(int irq, void *pw)
 {
struct dwc2_hsotg *hsotg = pw;
int retry_count = 8;
u32 gintsts;
u32 gintmsk;
 
-   spin_lock(&hsotg->lock);
 irq_retry:
gintsts = readl(hsotg->regs + GINTSTS);
gintmsk = readl(hsotg->regs + GINTMSK);
@@ -2276,33 +2275,12 @@ irq_retry:
 
gintsts &= gintmsk;
 
-   if (gintsts & GINTSTS_OTGINT) {
-   u32 otgint = readl(hsotg->regs + GOTGINT);
-
-   dev_info(hsotg->dev, "OTGInt: %08x\n", otgint);
-
-   writel(otgint, hsotg->regs + GOTGINT);
-   }
-
-   if (gintsts & GINTSTS_SESSREQINT) {
-   dev_dbg(hsotg->dev, "%s: SessReqInt\n", __func__);
-   writel(GINTSTS_SESSREQINT, hsotg->regs + GINTSTS);
-   }
-
if (gintsts & GINTSTS_ENUMDONE) {
writel(GINTSTS_ENUMDONE, hsotg->regs + GINTSTS);
 
s3c_hsotg_irq_enumdone(hsotg);
}
 
-   if (gintsts & GINTSTS_CONIDSTSCHNG) {
-   dev_dbg(hsotg->dev, "ConIDStsChg (DSTS=0x%08x, GOTCTL=%08x)\n",
-   readl(hsotg->regs + DSTS),
-   readl(hsotg->regs + GOTGCTL));
-
-   writel(GINTSTS_CONIDSTSCHNG, hsotg->regs + GINTSTS);
-   }
-
if (gintsts & (GINTSTS_OEPINT | GINTSTS_IEPINT)) {
u32 daint = readl(hsotg->regs + DAINT);
u32 daintmsk = readl(hsotg->regs + DAINTMSK);
@@ -2383,25 +2361,6 @@ irq_retry:
s3c_hsotg_handle_rx(hsotg);
}
 
-   if (gintsts & GINTSTS_MODEMIS) {
-   dev_warn(hsotg->dev, "warning, mode mismatch triggered\n");
-   writel(GINTSTS_MODEMIS, hsotg->regs + GINTSTS);
-   }
-
-   if (gintsts & GINTSTS_USBSUSP) {
-   dev_info(hsotg->dev, "GINTSTS_USBSusp\n");
-   writel(GINTSTS_USBSUSP, hsotg->regs + GINTSTS);
-
-   call_gadget(hsotg, suspend);
-   }
-
-   if (gintsts & GINTSTS_WKUPINT) {
-   dev_info(hsotg->dev, "GINTSTS_WkUpIn\n");
-   writel(GINTSTS_WKUPINT, hsotg->regs + GINTSTS);
-
-   call_gadget(hsotg, resume);
-   }
-
if (gintsts & GINTSTS_ERLYSUSP) {
dev_dbg(hsotg->dev, "GINTSTS_ErlySusp\n");
writel(GINTSTS_ERLYSUSP, hsotg->regs + GINTSTS);
@@ -2437,10 +2396,9 @@ irq_retry:
if (gintsts & IRQ_RETRY_MASK && --retry_count > 0)
goto irq_retry;
 
-   spin_unlock(&hsotg->lock);
-
return IRQ_HANDLED;
 }
+EXPORT_SYMBOL(s3c_hsotg_irq);
 
 /**
  * s3c_hsotg

Re: [oss-security] BadUSB discussion

2014-08-08 Thread Yves-Alexis Perez
On ven., 2014-08-08 at 14:36 -0700, Greg KH wrote:
> On Fri, Aug 08, 2014 at 11:27:06PM +0200, Yves-Alexis Perez wrote:
> > On ven., 2014-08-08 at 14:20 -0700, Greg KH wrote:
> > > > Actually, since it's a module parameter, it doesn't seem possible to
> > > > toggle it without reloading the module (or rebooting if it's
> > > builtin).
> > > > So it might not be that easy to do the locking part.
> > > 
> > > echo "0" > /sys/module/usbcore/parameters/authorized_default
> > 
> > I did that, but unplugging/replugging my mouse still works after that.
> 
> Hm, not good, take it to the linux-usb@vger.kernel.org mailing list and
> we can debug it there.
> 
Ok.

So, linux-usb people, a bit of context. Following the BadUSB circus [1]
there was a thread on oss-sec about that [2], where Greg mentionned the
usbcore 'authorized_default' parameter.

I thought it would be a good idea to toggle that parameter when locking
my laptop, so I tried to echo to the above file, but it doesn't seem to
prevent me plugging my mouse or an usb key.

I'm running Debian sid, current running kernel is the Debian one:

Linux scapa 3.14-2-amd64 #1 SMP Debian 3.14.13-2 (2014-07-24) x86_64
GNU/Linux

Ben Hutching uploaded 3.14.15-1 so I'll try it asap, but I can also
build a 3.16 just to check.

Regards,


[1] https://srlabs.de/badusb/
[2] http://www.openwall.com/lists/oss-security/2014/08/08/1
-- 
Yves-Alexis


signature.asc
Description: This is a digitally signed message part


Re: [oss-security] BadUSB discussion

2014-08-08 Thread Alan Stern
On Fri, 8 Aug 2014, Yves-Alexis Perez wrote:

> On ven., 2014-08-08 at 14:36 -0700, Greg KH wrote:
> > On Fri, Aug 08, 2014 at 11:27:06PM +0200, Yves-Alexis Perez wrote:
> > > On ven., 2014-08-08 at 14:20 -0700, Greg KH wrote:
> > > > > Actually, since it's a module parameter, it doesn't seem possible to
> > > > > toggle it without reloading the module (or rebooting if it's
> > > > builtin).
> > > > > So it might not be that easy to do the locking part.
> > > > 
> > > > echo "0" > /sys/module/usbcore/parameters/authorized_default
> > > 
> > > I did that, but unplugging/replugging my mouse still works after that.
> > 
> > Hm, not good, take it to the linux-usb@vger.kernel.org mailing list and
> > we can debug it there.
> > 
> Ok.
> 
> So, linux-usb people, a bit of context. Following the BadUSB circus [1]
> there was a thread on oss-sec about that [2], where Greg mentionned the
> usbcore 'authorized_default' parameter.
> 
> I thought it would be a good idea to toggle that parameter when locking
> my laptop, so I tried to echo to the above file, but it doesn't seem to
> prevent me plugging my mouse or an usb key.
> 
> I'm running Debian sid, current running kernel is the Debian one:
> 
> Linux scapa 3.14-2-amd64 #1 SMP Debian 3.14.13-2 (2014-07-24) x86_64
> GNU/Linux
> 
> Ben Hutching uploaded 3.14.15-1 so I'll try it asap, but I can also
> build a 3.16 just to check.

The authorized_default module parameter affects USB buses when they are
discovered and registered; after that it has no effect.  Therefore to
accomplish what you want, you need to put
"usbcore.authorized_default=0" in the kernel's boot command line.

Alternatively, you can change the default authorization value for a
particular bus after it has been created, by writing to the
authorized_default sysfs file for the bus's root hub.  For example,

echo 0 >/sys/bus/usb/devices/usb1/authorized_default

will set the default value for new devices on bus 1 to 0.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [oss-security] BadUSB discussion

2014-08-08 Thread Yves-Alexis Perez
On ven., 2014-08-08 at 18:17 -0400, Alan Stern wrote:
> The authorized_default module parameter affects USB buses when they
> are
> discovered and registered; after that it has no effect.  Therefore to
> accomplish what you want, you need to put
> "usbcore.authorized_default=0" in the kernel's boot command line.
> 
> Alternatively, you can change the default authorization value for a
> particular bus after it has been created, by writing to the
> authorized_default sysfs file for the bus's root hub.  For example,
> 
> echo 0 >/sys/bus/usb/devices/usb1/authorized_default
> 
> will set the default value for new devices on bus 1 to 0.

Thanks for your answer. So that confirms it's not possible to toggle
that value depending on a platform state (for example if the session is
locked).

Regards,
-- 
Yves-Alexis


signature.asc
Description: This is a digitally signed message part


Re: [oss-security] BadUSB discussion

2014-08-08 Thread Alan Stern
On Sat, 9 Aug 2014, Yves-Alexis Perez wrote:

> On ven., 2014-08-08 at 18:17 -0400, Alan Stern wrote:
> > The authorized_default module parameter affects USB buses when they
> > are
> > discovered and registered; after that it has no effect.  Therefore to
> > accomplish what you want, you need to put
> > "usbcore.authorized_default=0" in the kernel's boot command line.
> > 
> > Alternatively, you can change the default authorization value for a
> > particular bus after it has been created, by writing to the
> > authorized_default sysfs file for the bus's root hub.  For example,
> > 
> > echo 0 >/sys/bus/usb/devices/usb1/authorized_default
> > 
> > will set the default value for new devices on bus 1 to 0.
> 
> Thanks for your answer. So that confirms it's not possible to toggle
> that value depending on a platform state (for example if the session is
> locked).

I'm not sure what you mean.  You can toggle these values at any time, 
but toggling them may not accomplish anything useful.  What do you want 
to accomplish?

Note that in addition to changing the default values, you can change
the actual authorization value for an existing device at any time by
writing to the device's "authorized" sysfs file.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [oss-security] BadUSB discussion

2014-08-08 Thread Yves-Alexis Perez
On ven., 2014-08-08 at 18:26 -0400, Alan Stern wrote:
> I'm not sure what you mean.  You can toggle these values at any time, 
> but toggling them may not accomplish anything useful.  What do you
> want 
> to accomplish?

The point would be to prevent new usb device to be plugged while a
system is locked (or no one is logged in).

Grsecurity has something like that using a custom sysctl, but Greg
comment on the oss-sec made me thing it might have already been possible
in mainline.
> 
> Note that in addition to changing the default values, you can change
> the actual authorization value for an existing device at any time by
> writing to the device's "authorized" sysfs file.

Yeah but that doesn't really work, because one would need to disable
that at the bus level (for every bus), and that would also disable the
currently plugged devices.

Regards,
-- 
Yves-Alexis


signature.asc
Description: This is a digitally signed message part


Re: [oss-security] BadUSB discussion

2014-08-08 Thread Alan Stern
On Sat, 9 Aug 2014, Yves-Alexis Perez wrote:

> On ven., 2014-08-08 at 18:26 -0400, Alan Stern wrote:
> > I'm not sure what you mean.  You can toggle these values at any time, 
> > but toggling them may not accomplish anything useful.  What do you
> > want 
> > to accomplish?
> 
> The point would be to prevent new usb device to be plugged while a
> system is locked (or no one is logged in).
> 
> Grsecurity has something like that using a custom sysctl, but Greg
> comment on the oss-sec made me thing it might have already been possible
> in mainline.

Well, you can't prevent new devices from being plugged in -- not unless
you do something pretty drastic, like filling the USB ports with glue.  
:-)  But you _can_ prevent new devices from being authorized.  You just
do what I said earlier: write

echo 0 >/sys/bus/usb/devices/usbN/authorized_default

for each N corresponding to an existing USB bus.

> > Note that in addition to changing the default values, you can change
> > the actual authorization value for an existing device at any time by
> > writing to the device's "authorized" sysfs file.
> 
> Yeah but that doesn't really work,

What do you mean?  It really _does_ work.  If you write

echo 0 >/sys/bus/usb/devices/1-3/authorized

then device 3 on bus 1 really _will_ be deauthorized.

>  because one would need to disable
> that at the bus level (for every bus), and that would also disable the
> currently plugged devices.

I don't understand this sentence.  You used the word "that" twice
without a clear antecedent either time.

If you write "echo 0 >/sys/bus/usb/devices/usb1/authorized_default", it 
will not deauthorize any currently plugged devices.  All it will do is 
change the default authorization value assigned to new devices when 
they are plugged in.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/3] usbip: move usbip out of staging

2014-08-08 Thread Valentina Manea
On Thu, Aug 7, 2014 at 1:16 PM, Greg KH  wrote:
>
> The top of the MAINTAINERS should have this information, look in the S:
> Status section about what type of category you are in.
>
> Basically I'd like you to be the one to handle patches that are sent in
> for the code, just by reviewing them, you don't have to send them on to
> me if you don't want to (some usb subsystem maintainers do do this, like
> for usb-serial and xhci), it's up to you.
>
> Also, any bug reports or questions about the code would come to you
> first, along with the rest of the linux-usb@vger developers, you aren't
> alone in this at all.
>

Ok, this sounds good. I suppose sending you the patches involves
picking them up from the email, batching them and sending with
send-email.
Shuah, I would appreciate if you'd like to help with this. The more
eyes for review, the better.

Thanks,
Valentina
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7] usb:serial:pl2303: add GPIOs interface on PL2303

2014-08-08 Thread Wang YanQing
PL2303 USB Serial devices always has GPIOs, this patch add
generic gpio support interfaces for pl2303 USB Serial devices
in pl2303_type_data and pl2303_serial_private, then use them
to add GPIOs support for one type of them, PL2303HXA.

Known issue:
If gpios are in use(export to userspace through sysfs interface, etc),
then call pl2303_release(unplug usb-serial convertor, modprobe -r, etc),
will cause trouble, so we need to make sure there is no gpio user before
call pl2303_release.

Signed-off-by: Wang YanQing 
---
 Changes 
 v6-v7:
 1: add generic gpio support interfaces for pl2303 USB Serial devices
in pl2303_type_data and pl2303_serial_private suggested by Andreas Mohr.
 2: drop different label names for different pl2303 instance suggested by Johan 
Hovold.
 3: fix missing lock corrected by Johan Hovold.
 4: use prefix pl2303hx_gpio instead pl2303_gpio, pl2303_gpio is over generic 
for current code,
and now we move gpio_startup|gpio_release into type-specified data 
structure, so pl2303hx_gpio
is a better prefix.
 5: make words in Kconfig a little more useful and clarified.
 6: many misc code quality enhancement suggested by Johan Hovold.

 v5-v6:
 1: fix typo error in Kconfig reported by Andreas Mohr 
 2: add const qulification to gpio_dir_mask and gpio_value_mask suggested by 
Andreas Mohr

 v4-v5:
 1: fix gpio_chip.lable been overwrited by template_chip. 
 2: use idr to manage minor instead of crude monotonous atomic increment. 

 v3-v4:
 1: fix missing static for gpio_dir_mask and gpio_value_mask 
 2: reduce unneeded compile macro defined suggested by 
gno...@lxorguk.ukuu.org.uk 
 3: use true instead of 1 corrected by Linus Walleij
 4: ignore return value of gpiochip_remove suggested by Linus Walleij
 5: fix multi gpio_chips registered by pl2303 can't be distinguished in kernel 
space. 

 v2-v3:
 1: fix errors and warnings reported by Daniele Forsi checked with 
checkpatch.pl 
 2: fix missing GPIOLIB dependence in Kconfig 
 3: fix pl2303_gpio_get can't work 

 v1-v2:  
 1:drop gpio-pl2303.c and relation stuff 
 2:hang gpio stuff off of pl2303.c  

 drivers/usb/serial/Kconfig  |  10 +++
 drivers/usb/serial/pl2303.c | 202 
 2 files changed, 212 insertions(+)

diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index 3ce5c74..008ec57 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -516,6 +516,16 @@ config USB_SERIAL_PL2303
  To compile this driver as a module, choose M here: the
  module will be called pl2303.
 
+config USB_SERIAL_PL2303_GPIO
+   bool "USB Prolific 2303 Single Port GPIOs support"
+   depends on USB_SERIAL_PL2303 && GPIOLIB
+   ---help---
+ Say Y here if you want to use GPIOs on PL2303 USB Serial single port
+ adapter from Prolific.
+
+ It supports 2 dedicated GPIOs on PL2303HXA only currently.
+ If unsure, say N.
+
 config USB_SERIAL_OTI6858
tristate "USB Ours Technology Inc. OTi-6858 USB To RS232 Bridge 
Controller"
help
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index b3d5a35..edbe634 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -28,6 +28,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include "pl2303.h"
 
 
@@ -131,6 +133,8 @@ MODULE_DEVICE_TABLE(usb, id_table);
 #define UART_OVERRUN_ERROR 0x40
 #define UART_CTS   0x80
 
+#define PL2303HX_REG_GPIO_CONTROL  0x01
+#define PL2303HX_REG_GPIO_STATE0x81
 
 enum pl2303_type {
TYPE_01,/* Type 0 and 1 (difference unknown) */
@@ -141,11 +145,15 @@ enum pl2303_type {
 struct pl2303_type_data {
speed_t max_baud_rate;
unsigned long quirks;
+   u16 ngpio;
+   int (*gpio_startup)(struct usb_serial *serial);
+   void (*gpio_release)(struct usb_serial *serial);
 };
 
 struct pl2303_serial_private {
const struct pl2303_type_data *type;
unsigned long quirks;
+   void *gpio;
 };
 
 struct pl2303_private {
@@ -156,11 +164,24 @@ struct pl2303_private {
u8 line_settings[7];
 };
 
+#ifdef CONFIG_USB_SERIAL_PL2303_GPIO
+static int pl2303hx_gpio_startup(struct usb_serial *serial);
+static void pl2303hx_gpio_release(struct usb_serial *serial);
+#else
+static inline int pl2303hx_gpio_startup(struct usb_serial *serial) { return 0; 
}
+static inline void pl2303hx_gpio_release(struct usb_serial *serial) {}
+#endif
+
 static const struct pl2303_type_data pl2303_type_data[TYPE_COUNT] = {
[TYPE_01] = {
.max_baud_rate =1228800,
.quirks =   PL2303_QUIRK_LEGACY,
},
+   [TYPE_HX] = {
+   .ngpio = 2,
+   .gpio_startup = pl2303hx_gpio_startup,
+   .gpio_release = pl2303hx_gpio_release,
+   }
 };
 
 static int pl2303_vendor_read(struct usb_serial *serial, u16 value,
@@ -213,6 +234,176 @@ static int pl