[PATCH v5] xhci: Bad Ethernet performance plugged in ASM1042A host

2017-06-21 Thread Jiahau Chang
When USB Ethernet is plugged in ASMEDIA ASM1042A xHCI host, bad
performance was manifesting in Web browser use (like download
large file such as ISO image). It is known limitation of
ASM1042A that is not compatible with driver scheduling,
As a workaround we can modify flow control handling of ASM1042A.
The register we modify is changes the behavior

Signed-off-by: Jiahau Chang 
Signed-off-by: Ian Pilcher 
---
v5: run usb_asmedia_modifyflowcontrol after CMD_RESET and resume

v4 changes from Ian Pilcher

v4: use usleep_range instead of usleep (which doesn't seem to exist)
make flow of usb_asmedia_modifyflowcontrol easier to understand
use helper function to wait for controller

Earlier changes from Jiahu Chang:

v3: add define value of setting ASMT write Reg
modify dev_dbg message
use usleep
v2: fix coding format

 drivers/usb/host/pci-quirks.c | 54 +++
 drivers/usb/host/pci-quirks.h |  1 +
 drivers/usb/host/xhci-pci.c   |  5 
 drivers/usb/host/xhci.c   |  6 +
 drivers/usb/host/xhci.h   |  1 +
 5 files changed, 67 insertions(+)

diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index a9a1e4c..2e60053 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -77,6 +77,16 @@
 #define USB_INTEL_USB3_PSSEN   0xD8
 #define USB_INTEL_USB3PRM  0xDC
 
+/* ASMEDIA quirk use */
+#define ASMT_DATA_WRITE0_REG   0xF8
+#define ASMT_DATA_WRITE1_REG   0xFC
+#define ASMT_CONTROL_REG   0xE0
+#define ASMT_CONTROL_WRITE_BIT 0x02
+#define ASMT_WRITEREG_CMD  0x10423
+#define ASMT_FLOWCTL_ADDR  0xFA30
+#define ASMT_FLOWCTL_DATA  0xBA
+#define ASMT_PSEUDO_DATA   0
+
 /*
  * amd_chipset_gen values represent AMD different chipset generations
  */
@@ -412,6 +422,50 @@ void usb_amd_quirk_pll_disable(void)
 }
 EXPORT_SYMBOL_GPL(usb_amd_quirk_pll_disable);
 
+static int usb_asmedia_wait_write(struct pci_dev *pdev)
+{
+   unsigned long retry_count;
+   unsigned char value;
+
+   for (retry_count = 1000; retry_count > 0; --retry_count) {
+
+   pci_read_config_byte(pdev, ASMT_CONTROL_REG, );
+
+   if (value == 0xff) {
+   dev_err(>dev, "%s: check_ready ERROR", __func__);
+   return -EIO;
+   }
+
+   if ((value & ASMT_CONTROL_WRITE_BIT) == 0)
+   return 0;
+
+   usleep_range(50, 50);
+   }
+
+   dev_warn(>dev, "%s: check_write_ready timeout", __func__);
+   return -ETIMEDOUT;
+}
+
+void usb_asmedia_modifyflowcontrol(struct pci_dev *pdev)
+{
+   if (usb_asmedia_wait_write(pdev) != 0)
+   return;
+
+   /* send command and address to device */
+   pci_write_config_dword(pdev, ASMT_DATA_WRITE0_REG, ASMT_WRITEREG_CMD);
+   pci_write_config_dword(pdev, ASMT_DATA_WRITE1_REG, ASMT_FLOWCTL_ADDR);
+   pci_write_config_byte(pdev, ASMT_CONTROL_REG, ASMT_CONTROL_WRITE_BIT);
+
+   if (usb_asmedia_wait_write(pdev) != 0)
+   return;
+
+   /* send data to device */
+   pci_write_config_dword(pdev, ASMT_DATA_WRITE0_REG, ASMT_FLOWCTL_DATA);
+   pci_write_config_dword(pdev, ASMT_DATA_WRITE1_REG, ASMT_PSEUDO_DATA);
+   pci_write_config_byte(pdev, ASMT_CONTROL_REG, ASMT_CONTROL_WRITE_BIT);
+}
+EXPORT_SYMBOL_GPL(usb_asmedia_modifyflowcontrol);
+
 void usb_amd_quirk_pll_enable(void)
 {
usb_amd_quirk_pll(0);
diff --git a/drivers/usb/host/pci-quirks.h b/drivers/usb/host/pci-quirks.h
index 0222195..6ce1df1 100644
--- a/drivers/usb/host/pci-quirks.h
+++ b/drivers/usb/host/pci-quirks.h
@@ -11,6 +11,7 @@ bool usb_amd_prefetch_quirk(void);
 void usb_amd_dev_put(void);
 void usb_amd_quirk_pll_disable(void);
 void usb_amd_quirk_pll_enable(void);
+void usb_asmedia_modifyflowcontrol(struct pci_dev *pdev);
 void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev);
 void usb_disable_xhci_ports(struct pci_dev *xhci_pdev);
 void sb800_prefetch(struct device *dev, int on);
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 1bcf971..f1e7c58 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -53,6 +53,7 @@
 #define PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI 0x1aa8
 #define PCI_DEVICE_ID_INTEL_APL_XHCI   0x5aa8
 #define PCI_DEVICE_ID_INTEL_DNV_XHCI   0x19d0
+#define PCI_DEVICE_ID_ASMEDIA_1042A_XHCI   0x1142
 
 static const char hcd_name[] = "xhci_hcd";
 
@@ -205,6 +206,10 @@ static void xhci_pci_quirks(struct device *dev, struct 
xhci_hcd *xhci)
pdev->device == 0x1142)
xhci->quirks |= XHCI_TRUST_TX_LENGTH;
 
+   if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
+   pdev->device == PCI_DEVICE_ID_ASMEDIA_1042A_XHCI)
+   xhci->quirks |= XHCI_ASMEDIA_MODIFY_FLOWCONTROL;
+
if (pdev->vendor == PCI_VENDOR_ID_TI && 

Re: BUG: Soft lockup calling xhci_free_streams in 4.12-rc6 when USB-C hub and SSD is connected

2017-06-21 Thread rocko r
> does this help:
>
> diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c


Thanks! That patch stops the lockup (at least for the one reboot that
I had time to test before leaving for work). The patched 4.12 now
works just like 4.11 with my USB-C to USB-3 hub hardware configuration
- while starting up the desktop, the devices attached to USB-C go
offline for some seconds and then come back online.
--
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


AW: Wir geben jährlich Darlehen für 2% Zinsen aus

2017-06-21 Thread Bernhard Stöckl

Wir vergeben Kredite mit einem Zinssatz von jährlich 2%.

Die Bearbeitung des Antrags erfolgt rasch, wir verlangen keine Gebühren, was 
sie beantragen werden wir annehmen. Wir bewilligen Kredite von bis zu 40 
Millionen Euro und von mindestens 15.000 Euro. Sie können einen geschäftlichen 
oder privaten Kredit beantrage, wobei Sie bei Geschäftskrediten eine 
Zahlungsfrist von einem Jahr erhalten.

Anfragen bitte per Mail an: sunrisefundin...@hotmail.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.org/majordomo-info.html


Re: [PATCH 2/3] usb: dwc3: gadget: Fix early exit in set/clear ep halt

2017-06-21 Thread John Youn
On 6/21/2017 3:38 AM, Felipe Balbi wrote:
>
> Hi,
>
> John Youn  writes:
>
> 
>
 I haven't checked, but Thinh looked and couldn't find anything
 relating to the macOS issue. Which is why we want more information
 about the problem.

 I can take a look at it too later today when I get a chance.

 When you say you fixed the issue in the vendor driver, do you mean the
 macOS problem (multiple clear stalls) or the regression that it caused
 when it was fixed (the MSC data sequence issue)?
>>>
>>> Hi John,
>>>
>>> The issue was with the host sending a CLEAR_FEATURE(ENDPOINT_HALT) when the
>>> EP was not actually halted. The host does this to reset the EP data toggle /
>>> sequence number to 0, and it is allowed by some USB spec. The problem was
>>> that for DWC3 if you issue a Clear Stall when the EP is not halted, nothing
>>> happens. I *think* the fix was to issue a Set EP Config command instead,
>>> which does reset the sequence number, but I'm not 100% sure about that.
>>>
>>
>> Hi Paul,
>>
>> Ok thanks, that will definitely help looking into it.
>>
>> Though our issue seems the opposite. Since Felipe's macOS patch
>> prevents the clear stall when already halted, but *without* that, the
>
>> controller doesn't clear the sequence number and fails the MSC CV
>> test.
>
> I can see this failure here. We really need a way to reset Data
> toggle/seqNum without issuing Clear Stall command. I tried issuing
> set_ep_config instead, but there's still something wrong going on. It
> seems like g_mass_storage won't requeue a new request for the following
> CBW.
>
> John, can you check on your list of STARS if there's anything related to
> issuing Clear Halt when the endpoint is not halted?

Hi Felipe,

We tried Paul's workaround but it also does not work for us. We're
looking into why. We're also investigating other possible workarounds
and searching our list of STARs. We'll get back to you once we have
some more information.

Thanks,
John
--
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 1/5] clk: hisilicon: add usb2 clocks for hi3798cv200 SoC

2017-06-21 Thread Stephen Boyd
On 06/21, Jiancheng Xue wrote:
> Add usb2 clocks for hi3798cv200 SoC.
> 
> Signed-off-by: Jiancheng Xue 
> Reviewed-by: Daniel Thompson 
> ---

Applied to clk-next

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
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 net-next] r8152: correct the definition

2017-06-21 Thread David Miller
From: Hayes Wang 
Date: Wed, 21 Jun 2017 11:25:18 +0800

> Replace VLAN_HLEN and CRC_SIZE with ETH_FCS_LEN.
> 
> Signed-off-by: Hayes Wang 

Applied.
--
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] usb:gadget:hid: This patch adds support for set_protocol and get_protocol for remote wakeup

2017-06-21 Thread Alan Stern
On Wed, 21 Jun 2017 abdulahha...@gmail.com wrote:

> Hi,
> 
> Thanks for the reply! I'll be sure to send in another patch
> with fixes to all the formatting errors. But before that
> just a couple of points on your feedback.
> 
> > > struct usb_request *req;
> > > unsigned long flags;
> > > ssize_t status = -ENOMEM;
> > >  
> > > +   usb_gadget_wakeup(cdev->gadget);
> > 
> > this seems unrelated to implemeting GET/SET_PROTOCOL. Why do you need this?
> 
> Right, I intially suspected support for these two features
> were dependant on one another. However, that does not seem to be the case.
> I'll send in a seperate patch to handle remote wake up support in
> the driver later.
> 
> > 
> > > @@ -528,6 +532,9 @@ static int hidg_setup(struct usb_function *f,
> > >   | HID_REQ_GET_PROTOCOL):
> > > VDBG(cdev, "get_protocol\n");
> > > goto stall;
> > > +   length = min_t(unsigned, length, 1); 
> > > +   ((u8 *) req->buf)[0]= hidg->protocol_is_report;
> > > +   goto respond; 
> > > break;

Felipe didn't mention this, but the lines you added here are dead code 
because you forgot to remove the "goto stall".

Also, you have a number of excess space characters before the second
'=' sign.

> > >  
> > > case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8
> > > @@ -539,6 +546,17 @@ static int hidg_setup(struct usb_function *f,
> > > case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8
> > >   | HID_REQ_SET_PROTOCOL):
> > > VDBG(cdev, "set_protocol\n");
> > > +   if (value > 1)
> > 
> > why 1 here? Seems like this should be
> > USB_INTERFACE_PROTOCOL_KEYBOARD. And are you sure there's nobody using
> > this to emulate a mouse?
> 
> According to 7.2.6 of the HID spec. For the wValue field, 0 indicates Boot
> Protocol and 1 indicates Report Protocol, which applies to both mice
> and keyboards. So the use of that macro wouldn't make sense.
>  
> > > +   goto stall; 
> > > +   length = 0;
> > > +   /*
> > > +* We assume that programs implementing the Boot protocol 
> > > +* are also compatible with the Report protocol. 
> > > +*/ 
> > 
> > Why is this a safe assumption?
> 
> Any device in the Boot subclass supports both Report and Boot protocols by
> definition according to the HID spec. Although the implementations of
> these two procotols maybe the same in some cases, there is a possbility
> that they are different. In this case  it would pose a problem to the
> current driver, which offers no switching capabiliy via SET_PROTOCOL while
> in BIOS.

Also, if the assumption turns out to be wrong, there's nothing you can 
do about it.  :-)

> > > +   if(hidg->bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT) { 
> > > +   hidg->protocol_is_report = value; 
> > > +   goto respond;
> > 
> > wrong indentation.
> > 
> > > @@ -768,6 +786,7 @@ static int hidg_bind(struct usb_configuration *c, 
> > > struct usb_function *f)
> > > /* set descriptor dynamic values */
> > > hidg_interface_desc.bInterfaceSubClass = hidg->bInterfaceSubClass;
> > > hidg_interface_desc.bInterfaceProtocol = hidg->bInterfaceProtocol;
> > > +   hidg->protocol_is_report = 1; 
> > 
> > no idea why you called this "protocol_is_report" when "protocol"
> > would've been better.
> 
> True, that name would probably make it more concise.

I originally called it "protocol_is_report" to improve readability for
things like:

if (protocol_is_report) ...

as opposed to:

if (protocol == 1)

But with new macros for HID_BOOT_PROTOCOL and HID_REPORT_PROTOCOL,
either way would be acceptable.

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 5/5] watchdog: sp5100_tco: Use request_declared_muxed_region()

2017-06-21 Thread Guenter Roeck
On Wed, Jun 21, 2017 at 05:53:49AM +0200, Zoltán Böszörményi wrote:
> Use the new request_declared_muxed_region() macro to synchronize
> accesses to the SB800 I/O port pair (0xcd6 / 0xcd7) with the
> PCI quirk for isochronous USB transfers and with the i2c-piix4
> driver.
> 
> At the same time, remove the long lifetime request_region() call
> to reserve these I/O ports, similarly to i2c-piix4 so the code is
> now uniform across the three drivers.
> 
> Signed-off-by: Zoltán Böszörményi 
> ---
>  drivers/watchdog/sp5100_tco.c | 25 -
>  1 file changed, 12 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/watchdog/sp5100_tco.c b/drivers/watchdog/sp5100_tco.c
> index 028618c..9bb3bcb 100644
> --- a/drivers/watchdog/sp5100_tco.c
> +++ b/drivers/watchdog/sp5100_tco.c
> @@ -48,7 +48,6 @@
>  static u32 tcobase_phys;
>  static u32 tco_wdt_fired;
>  static void __iomem *tcobase;
> -static unsigned int pm_iobase;
>  static DEFINE_SPINLOCK(tco_lock);/* Guards the hardware */
>  static unsigned long timer_alive;
>  static char tco_expect_close;
> @@ -134,11 +133,13 @@ static int tco_timer_set_heartbeat(int t)
>  
>  static void tco_timer_enable(void)
>  {
> + struct resource res = DEFINE_RES_IO_NAMED(SB800_IO_PM_INDEX_REG, 
> SP5100_PM_IOPORTS_SIZE, TCO_MODULE_NAME);

Is it necessary to have this as a local variable ?
If not, please declare as static variable.

Either case, please run our patches through checkpatch and address 
any problems it reports.

>   int val;
>  
>   if (!tco_has_sp5100_reg_layout(sp5100_tco_pci)) {
>   /* For SB800 or later */
>   /* Set the Watchdog timer resolution to 1 sec */
> + request_declared_muxed_region();
>   outb(SB800_PM_WATCHDOG_CONFIG, SB800_IO_PM_INDEX_REG);
>   val = inb(SB800_IO_PM_DATA_REG);
>   val |= SB800_PM_WATCHDOG_SECOND_RES;
> @@ -150,6 +151,7 @@ static void tco_timer_enable(void)
>   val |= SB800_PCI_WATCHDOG_DECODE_EN;
>   val &= ~SB800_PM_WATCHDOG_DISABLE;
>   outb(val, SB800_IO_PM_DATA_REG);
> + release_region(SB800_IO_PM_INDEX_REG, SP5100_PM_IOPORTS_SIZE);
>   } else {
>   /* For SP5100 or SB7x0 */
>   /* Enable watchdog decode bit */
> @@ -164,11 +166,13 @@ static void tco_timer_enable(void)
>  val);
>  
>   /* Enable Watchdog timer and set the resolution to 1 sec */
> + request_declared_muxed_region();
>   outb(SP5100_PM_WATCHDOG_CONTROL, SP5100_IO_PM_INDEX_REG);
>   val = inb(SP5100_IO_PM_DATA_REG);
>   val |= SP5100_PM_WATCHDOG_SECOND_RES;
>   val &= ~SP5100_PM_WATCHDOG_DISABLE;
>   outb(val, SP5100_IO_PM_DATA_REG);
> + release_region(SB800_IO_PM_INDEX_REG, 2);
>   }
>  }
>  
> @@ -326,6 +330,7 @@ MODULE_DEVICE_TABLE(pci, sp5100_tco_pci_tbl);
>   */
>  static unsigned char sp5100_tco_setupdevice(void)
>  {
> + struct resource res = DEFINE_RES_IO_NAMED(SP5100_IO_PM_INDEX_REG, 
> SP5100_PM_IOPORTS_SIZE, TCO_MODULE_NAME);
>   struct pci_dev *dev = NULL;
>   const char *dev_name = NULL;
>   u32 val;
> @@ -361,16 +366,10 @@ static unsigned char sp5100_tco_setupdevice(void)
>   base_addr = SB800_PM_WATCHDOG_BASE;
>   }
>  
> - /* Request the IO ports used by this driver */
> - pm_iobase = SP5100_IO_PM_INDEX_REG;
> - if (!request_region(pm_iobase, SP5100_PM_IOPORTS_SIZE, dev_name)) {
> - pr_err("I/O address 0x%04x already in use\n", pm_iobase);
> - goto exit;
> - }
> -
>   /*
>* First, Find the watchdog timer MMIO address from indirect I/O.
>*/
> + request_declared_muxed_region();
>   outb(base_addr+3, index_reg);
>   val = inb(data_reg);
>   outb(base_addr+2, index_reg);
> @@ -380,6 +379,7 @@ static unsigned char sp5100_tco_setupdevice(void)
>   outb(base_addr+0, index_reg);
>   /* Low three bits of BASE are reserved */
>   val = val << 8 | (inb(data_reg) & 0xf8);
> + release_region(SP5100_IO_PM_INDEX_REG, SP5100_PM_IOPORTS_SIZE);
>  
>   pr_debug("Got 0x%04x from indirect I/O\n", val);
>  
> @@ -400,6 +400,7 @@ static unsigned char sp5100_tco_setupdevice(void)
> SP5100_SB_RESOURCE_MMIO_BASE, );
>   } else {
>   /* Read SBResource_MMIO from AcpiMmioEn(PM_Reg: 24h) */
> + request_declared_muxed_region();
>   outb(SB800_PM_ACPI_MMIO_EN+3, SB800_IO_PM_INDEX_REG);
>   val = inb(SB800_IO_PM_DATA_REG);
>   outb(SB800_PM_ACPI_MMIO_EN+2, SB800_IO_PM_INDEX_REG);
> @@ -408,6 +409,7 @@ static unsigned char sp5100_tco_setupdevice(void)
>   val = val << 8 | inb(SB800_IO_PM_DATA_REG);
>   outb(SB800_PM_ACPI_MMIO_EN+0, SB800_IO_PM_INDEX_REG);
>   val = val << 8 | 

Re: [PATCH] usb:gadget:hid: This patch adds support for set_protocol and get_protocol for remote wakeup

2017-06-21 Thread abdulahhadi2
Hi,

Thanks for the reply! I'll be sure to send in another patch
with fixes to all the formatting errors. But before that
just a couple of points on your feedback.

> > struct usb_request *req;
> > unsigned long flags;
> > ssize_t status = -ENOMEM;
> >  
> > +   usb_gadget_wakeup(cdev->gadget);
> 
> this seems unrelated to implemeting GET/SET_PROTOCOL. Why do you need this?

Right, I intially suspected support for these two features
were dependant on one another. However, that does not seem to be the case.
I'll send in a seperate patch to handle remote wake up support in
the driver later.

> 
> > @@ -528,6 +532,9 @@ static int hidg_setup(struct usb_function *f,
> >   | HID_REQ_GET_PROTOCOL):
> > VDBG(cdev, "get_protocol\n");
> > goto stall;
> > +   length = min_t(unsigned, length, 1); 
> > +   ((u8 *) req->buf)[0]= hidg->protocol_is_report;
> > +   goto respond; 
> > break;
> >  
> > case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8
> > @@ -539,6 +546,17 @@ static int hidg_setup(struct usb_function *f,
> > case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8
> >   | HID_REQ_SET_PROTOCOL):
> > VDBG(cdev, "set_protocol\n");
> > +   if (value > 1)
> 
> why 1 here? Seems like this should be
> USB_INTERFACE_PROTOCOL_KEYBOARD. And are you sure there's nobody using
> this to emulate a mouse?

According to 7.2.6 of the HID spec. For the wValue field, 0 indicates Boot
Protocol and 1 indicates Report Protocol, which applies to both mice
and keyboards. So the use of that macro wouldn't make sense.
 
> > +   goto stall; 
> > +   length = 0;
> > +   /*
> > +* We assume that programs implementing the Boot protocol 
> > +* are also compatible with the Report protocol. 
> > +*/ 
> 
> Why is this a safe assumption?

Any device in the Boot subclass supports both Report and Boot protocols by
definition according to the HID spec. Although the implementations of
these two procotols maybe the same in some cases, there is a possbility
that they are different. In this case  it would pose a problem to the
current driver, which offers no switching capabiliy via SET_PROTOCOL while
in BIOS.
> 
> > +   if(hidg->bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT) { 
> > +   hidg->protocol_is_report = value; 
> > +   goto respond;
> 
> wrong indentation.
> 
> > @@ -768,6 +786,7 @@ static int hidg_bind(struct usb_configuration *c, 
> > struct usb_function *f)
> > /* set descriptor dynamic values */
> > hidg_interface_desc.bInterfaceSubClass = hidg->bInterfaceSubClass;
> > hidg_interface_desc.bInterfaceProtocol = hidg->bInterfaceProtocol;
> > +   hidg->protocol_is_report = 1; 
> 
> no idea why you called this "protocol_is_report" when "protocol"
> would've been better.

True, that name would probably make it more concise.

- Abdulhadi Mohamed

--
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] usb: musb: compress return logic into one line

2017-06-21 Thread Bin Liu
Hi Greg,

On Tue, Jun 20, 2017 at 03:24:27PM -0500, Gustavo A. R. Silva wrote:
> Simplify return logic to avoid unnecessary variable assignment.
> 
> Signed-off-by: Gustavo A. R. Silva 

My tree is already closed for v4.13. if you want to pick it up directly,
here is my Acked-by, or I will take it for v4.14.

Acked-by: Bin Liu 

Regards,
-Bin.

> ---
>  drivers/usb/musb/musb_host.c | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
> index dbe617a..76decb8 100644
> --- a/drivers/usb/musb/musb_host.c
> +++ b/drivers/usb/musb/musb_host.c
> @@ -1540,7 +1540,7 @@ static int musb_rx_dma_iso_cppi41(struct dma_controller 
> *dma,
>   struct dma_channel *channel = hw_ep->rx_channel;
>   void __iomem *epio = hw_ep->regs;
>   dma_addr_t *buf;
> - u32 length, res;
> + u32 length;
>   u16 val;
>  
>   buf = (void *)urb->iso_frame_desc[qh->iso_idx].offset +
> @@ -1552,10 +1552,8 @@ static int musb_rx_dma_iso_cppi41(struct 
> dma_controller *dma,
>   val |= MUSB_RXCSR_DMAENAB;
>   musb_writew(hw_ep->regs, MUSB_RXCSR, val);
>  
> - res = dma->channel_program(channel, qh->maxpacket, 0,
> + return dma->channel_program(channel, qh->maxpacket, 0,
>  (u32)buf, length);
> -
> - return res;
>  }
>  #else
>  static inline int musb_rx_dma_iso_cppi41(struct dma_controller *dma,
> -- 
> 2.5.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: [PATCH v4 1/2] usb: typec: Add support for UCSI interface

2017-06-21 Thread Heikki Krogerus
On Fri, Jun 16, 2017 at 03:14:37PM -0700, Guenter Roeck wrote:
> On Fri, Jun 16, 2017 at 11:21:24AM +0300, Heikki Krogerus wrote:
> > UCSI - USB Type-C Connector System Software Interface - is a
> > specification that defines set of registers and data
> > structures for controlling the USB Type-C ports. It's
> > designed for systems where an embedded controller (EC) is in
> > charge of the USB Type-C PHY or USB Power Delivery
> > controller. It is designed for systems with EC, but it is
> > not limited to them, and for example some USB Power Delivery
> > controllers will use it as their direct control interface.
> > 
> > With UCSI the EC (or USB PD controller) acts as the port
> > manager, implementing all USB Type-C and Power Delivery state
> > machines. The OS can use the interfaces for reading the
> > status of the ports and controlling basic operations like
> > role swapping.
> > 
> > The UCSI specification highlights the fact that it does not
> > define the interface method (PCI/I2C/ACPI/etc.).
> > Therefore the driver is implemented as library and every
> > supported interface method needs its own driver. Driver for
> > ACPI is provided in separate patch following this one.
> > 
> > The initial driver includes support for all required
> > features from UCSI specification version 1.0 (getting
> > connector capabilities and status, and support for power and
> > data role swapping), but none of the optional UCSI features
> > (alternate modes, power source capabilities, and cable
> > capabilities).
> > 
> > Signed-off-by: Heikki Krogerus 
> 
> I looked at this way too often, so I am sure I am missing something
> really obvious (except for the u64 data:48 field, but I just assume
> you know what you are doing there).
> 
> Reviewed-by: Guenter Roeck 

Thanks Guenter!

-- 
heikki
--
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: [project-aspen-dev] [PATCH 3/5] phy: add inno-usb2-phy driver for hi3798cv200 SoC

2017-06-21 Thread Daniel Thompson

On 21/06/17 10:00, Jiancheng Xue wrote:

From: Pengcheng Li 

Add inno-usb2-phy driver for hi3798cv200 SoC.

Signed-off-by: Pengcheng Li 
Signed-off-by: Jiancheng Xue 
---
  drivers/phy/Kconfig  |  10 ++
  drivers/phy/Makefile |   1 +
  drivers/phy/phy-hisi-inno-usb2.c | 287 +++
  3 files changed, 298 insertions(+)
  create mode 100644 drivers/phy/phy-hisi-inno-usb2.c

...
diff --git a/drivers/phy/phy-hisi-inno-usb2.c b/drivers/phy/phy-hisi-inno-usb2.c
new file mode 100644
index 000..582c500
--- /dev/null
+++ b/drivers/phy/phy-hisi-inno-usb2.c
@@ -0,0 +1,287 @@

> ...> +static int hisi_inno_phy_of_get_ports(struct device *dev,

+   struct  hisi_inno_phy_priv *priv)
+{
+   struct device_node *node = dev->of_node;
+   struct device_node *child;
+   int port = 0;
+   int ret;
+
+   priv->port_num = of_get_child_count(node);
+   if (priv->port_num > MAX_PORTS) {
+   dev_err(dev, "too many ports : %d (max = %d)\n",
+   priv->port_num, MAX_PORTS);
+   return -EINVAL;
+   }
+
+   priv->ports = devm_kcalloc(dev, priv->port_num,
+   sizeof(struct hisi_inno_phy_port), GFP_KERNEL);
+   if (!priv->ports)
+   return -ENOMEM;
+
+   for_each_child_of_node(node, child) {
+   struct hisi_inno_phy_port *phy_port = >ports[port];
+
+   phy_port->utmi_clk = devm_get_clk_from_child(dev, child, NULL);
+   if (IS_ERR(phy_port->utmi_clk)) {
+   ret = PTR_ERR(phy_port->utmi_clk);
+   goto fail;
+   }
+
+   phy_port->port_rst = of_reset_control_get_exclusive(child, 
"port_rst"); > + if (IS_ERR(phy_port->port_rst)) {
+   ret = PTR_ERR(phy_port->port_rst);
+   goto fail;
+   }
+
+   phy_port->utmi_rst = of_reset_control_get_exclusive(child, 
"utmi_rst");
+   if (IS_ERR(phy_port->utmi_rst)) {
+   ret = PTR_ERR(phy_port->utmi_rst);
+   reset_control_put(phy_port->port_rst);
+   goto fail;
+   }
+   port++;
+   }
+
+   return 0;
+
+fail:
+   while (--port >= 0) {
+   struct hisi_inno_phy_port *phy_port = >ports[port];
+
+   reset_control_put(phy_port->utmi_rst);
+   reset_control_put(phy_port->port_rst) > + 
clk_put(phy_port->utmi_clk);


clk_put() should not be needed here.


+   }


Do we also need clean up code like this in a remove callback?


Daniel.
--
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: BUG: Soft lockup calling xhci_free_streams in 4.12-rc6 when USB-C hub and SSD is connected

2017-06-21 Thread Mathias Nyman

On 21.06.2017 10:06, rocko r wrote:

Does the Samsung 840 EVO SSD support UAS (USB attached SCSI?) i.e. does
it use the uas driver instead of mass-storage?


I don't think UAS is an issue here: I tried disabling it for the SSD
using a quirk (ie with the line "options usb_storage
quirks=174c:1053:u" in the file /etc/modprobe.d/usb_storage.conf) and
the kernel still locked up.


Could you take full logs from boot with xhci debugging and tracing both enabled?


See attached. The SSD is /dev/sda and /media/cat is where it tries to
mount /dev/sda1, and there's a NULL dereference at 32.736157 that
might be the cause of the lockup.


Thanks, looks like UAS and xhci streams are still in use.
This is most likely a simple off by one error. stream ID 0 is not
valid, and turns out we actually have no stream ring allocated for
ep->stream_info->stream_rings[0]

In all other places we we start stream_id indexing from 1, except in this case
when bailing out for a suddenly removed (hotplug) xHC host.

does this help:

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 03f63f5..e555a9c 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -845,11 +845,11 @@ static void xhci_kill_endpoint_urbs(struct xhci_hcd *xhci,
(ep->ep_state & EP_GETTING_NO_STREAMS)) {
int stream_id;
 
-   for (stream_id = 0; stream_id < ep->stream_info->num_streams;

+   for (stream_id = 1; stream_id < ep->stream_info->num_streams;
stream_id++) {
xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
"Killing URBs for slot ID %u, ep index %u, 
stream %u",
-   slot_id, ep_index, stream_id + 1);
+   slot_id, ep_index, stream_id);
xhci_kill_ring_urbs(xhci,

ep->stream_info->stream_rings[stream_id]);
}

Thanks
Mathias
--
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 0/5] enable usb2 function on poplar board.

2017-06-21 Thread Jiancheng Xue
This patchset is mainly used to enable usb2 function on poplar board.

Jiancheng Xue (4):
  clk: hisilicon: add usb2 clocks for hi3798cv200 SoC
  dt-bindings: phy-hisi-inno-usb2: add support for hisi-inno-usb2 phy
  arm64: dts: hisilicon: add usb2 controller and phy nodes for poplar
board.
  arm64: defconfig: enable some drivers and configs for
hi3798cv200-poplar board.

Pengcheng Li (1):
  phy: add inno-usb2-phy driver for hi3798cv200 SoC

 .../devicetree/bindings/phy/phy-hisi-inno-usb2.txt |  36 +++
 .../boot/dts/hisilicon/hi3798cv200-poplar.dts  |  13 +
 arch/arm64/boot/dts/hisilicon/hi3798cv200.dtsi |  47 
 arch/arm64/configs/defconfig   |  13 +-
 drivers/clk/hisilicon/crg-hi3798cv200.c|  21 ++
 drivers/phy/Kconfig|  10 +
 drivers/phy/Makefile   |   1 +
 drivers/phy/phy-hisi-inno-usb2.c   | 287 +
 include/dt-bindings/clock/histb-clock.h|   9 +-
 9 files changed, 435 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-hisi-inno-usb2.txt
 create mode 100644 drivers/phy/phy-hisi-inno-usb2.c

-- 
1.9.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 1/5] clk: hisilicon: add usb2 clocks for hi3798cv200 SoC

2017-06-21 Thread Jiancheng Xue
Add usb2 clocks for hi3798cv200 SoC.

Signed-off-by: Jiancheng Xue 
Reviewed-by: Daniel Thompson 
---
 drivers/clk/hisilicon/crg-hi3798cv200.c | 21 +
 include/dt-bindings/clock/histb-clock.h |  9 -
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/hisilicon/crg-hi3798cv200.c 
b/drivers/clk/hisilicon/crg-hi3798cv200.c
index fc8b5bc..ed8bb5f 100644
--- a/drivers/clk/hisilicon/crg-hi3798cv200.c
+++ b/drivers/clk/hisilicon/crg-hi3798cv200.c
@@ -44,6 +44,9 @@
 #define HI3798CV200_ETH_BUS0_CLK   78
 #define HI3798CV200_ETH_BUS1_CLK   79
 #define HI3798CV200_COMBPHY1_MUX   80
+#define HI3798CV200_FIXED_12M  81
+#define HI3798CV200_FIXED_48M  82
+#define HI3798CV200_FIXED_60M  83
 
 #define HI3798CV200_CRG_NR_CLKS128
 
@@ -51,9 +54,12 @@
{ HISTB_OSC_CLK, "clk_osc", NULL, 0, 2400, },
{ HISTB_APB_CLK, "clk_apb", NULL, 0, 1, },
{ HISTB_AHB_CLK, "clk_ahb", NULL, 0, 2, },
+   { HI3798CV200_FIXED_12M, "12m", NULL, 0, 1200, },
{ HI3798CV200_FIXED_24M, "24m", NULL, 0, 2400, },
{ HI3798CV200_FIXED_25M, "25m", NULL, 0, 2500, },
+   { HI3798CV200_FIXED_48M, "48m", NULL, 0, 4800, },
{ HI3798CV200_FIXED_50M, "50m", NULL, 0, 5000, },
+   { HI3798CV200_FIXED_60M, "60m", NULL, 0, 6000, },
{ HI3798CV200_FIXED_75M, "75m", NULL, 0, 7500, },
{ HI3798CV200_FIXED_100M, "100m", NULL, 0, 1, },
{ HI3798CV200_FIXED_150M, "150m", NULL, 0, 15000, },
@@ -134,6 +140,21 @@
/* COMBPHY1 */
{ HISTB_COMBPHY1_CLK, "clk_combphy1", "combphy1_mux",
CLK_SET_RATE_PARENT, 0x188, 8, 0, },
+   /* USB2 */
+   { HISTB_USB2_BUS_CLK, "clk_u2_bus", "clk_ahb",
+   CLK_SET_RATE_PARENT, 0xb8, 0, 0, },
+   { HISTB_USB2_PHY_CLK, "clk_u2_phy", "60m",
+   CLK_SET_RATE_PARENT, 0xb8, 4, 0, },
+   { HISTB_USB2_12M_CLK, "clk_u2_12m", "12m",
+   CLK_SET_RATE_PARENT, 0xb8, 2, 0 },
+   { HISTB_USB2_48M_CLK, "clk_u2_48m", "48m",
+   CLK_SET_RATE_PARENT, 0xb8, 1, 0 },
+   { HISTB_USB2_UTMI_CLK, "clk_u2_utmi", "60m",
+   CLK_SET_RATE_PARENT, 0xb8, 5, 0 },
+   { HISTB_USB2_PHY1_REF_CLK, "clk_u2_phy1_ref", "24m",
+   CLK_SET_RATE_PARENT, 0xbc, 0, 0 },
+   { HISTB_USB2_PHY2_REF_CLK, "clk_u2_phy2_ref", "24m",
+   CLK_SET_RATE_PARENT, 0xbc, 2, 0 },
 };
 
 static struct hisi_clock_data *hi3798cv200_clk_register(
diff --git a/include/dt-bindings/clock/histb-clock.h 
b/include/dt-bindings/clock/histb-clock.h
index 181c0f0..067f5e5 100644
--- a/include/dt-bindings/clock/histb-clock.h
+++ b/include/dt-bindings/clock/histb-clock.h
@@ -53,7 +53,14 @@
 #define HISTB_ETH1_MAC_CLK 31
 #define HISTB_ETH1_MACIF_CLK   32
 #define HISTB_COMBPHY1_CLK 33
-
+#define HISTB_USB2_BUS_CLK 34
+#define HISTB_USB2_PHY_CLK 35
+#define HISTB_USB2_UTMI_CLK36
+#define HISTB_USB2_12M_CLK 37
+#define HISTB_USB2_48M_CLK 38
+#define HISTB_USB2_OTG_UTMI_CLK39
+#define HISTB_USB2_PHY1_REF_CLK40
+#define HISTB_USB2_PHY2_REF_CLK41
 
 /* clocks provided by mcu CRG */
 #define HISTB_MCE_CLK  1
-- 
1.9.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 5/5] arm64: defconfig: enable some drivers and configs for hi3798cv200-poplar board.

2017-06-21 Thread Jiancheng Xue
Enable GMAC,I2C,IR,USB2-PHY for hi3798cv200-poplar board.

Signed-off-by: Jiancheng Xue 
---
 arch/arm64/configs/defconfig | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 97c123e..b45d760 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -31,6 +31,8 @@ CONFIG_JUMP_LABEL=y
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
 # CONFIG_IOSCHED_DEADLINE is not set
+CONFIG_PARTITION_ADVANCED=y
+CONFIG_CMDLINE_PARTITION=y
 CONFIG_ARCH_SUNXI=y
 CONFIG_ARCH_ALPINE=y
 CONFIG_ARCH_BCM2835=y
@@ -179,6 +181,7 @@ CONFIG_VIRTIO_NET=y
 CONFIG_AMD_XGBE=y
 CONFIG_NET_XGENE=y
 CONFIG_MACB=y
+CONFIG_HIX5HD2_GMAC=y
 CONFIG_HNS_DSAF=y
 CONFIG_HNS_ENET=y
 CONFIG_E1000E=y
@@ -259,6 +262,7 @@ CONFIG_I2C_TEGRA=y
 CONFIG_I2C_UNIPHIER_F=y
 CONFIG_I2C_RCAR=y
 CONFIG_I2C_CROS_EC_TUNNEL=y
+CONFIG_I2C_HIX5HD2=y
 CONFIG_SPI=y
 CONFIG_SPI_BCM2835=m
 CONFIG_SPI_BCM2835AUX=m
@@ -277,6 +281,7 @@ CONFIG_PINCTRL_MSM8994=y
 CONFIG_PINCTRL_MSM8996=y
 CONFIG_PINCTRL_QDF2XXX=y
 CONFIG_PINCTRL_QCOM_SPMI_PMIC=y
+CONFIG_GPIO_SYSFS=y
 CONFIG_GPIO_DWAPB=y
 CONFIG_GPIO_PL061=y
 CONFIG_GPIO_RCAR=y
@@ -322,7 +327,7 @@ CONFIG_REGULATOR_QCOM_SMD_RPM=y
 CONFIG_REGULATOR_QCOM_SPMI=y
 CONFIG_REGULATOR_RK808=y
 CONFIG_REGULATOR_S2MPS11=y
-CONFIG_MEDIA_SUPPORT=m
+CONFIG_MEDIA_SUPPORT=y
 CONFIG_MEDIA_CAMERA_SUPPORT=y
 CONFIG_MEDIA_ANALOG_TV_SUPPORT=y
 CONFIG_MEDIA_DIGITAL_TV_SUPPORT=y
@@ -359,6 +364,10 @@ CONFIG_BACKLIGHT_GENERIC=m
 CONFIG_BACKLIGHT_LP855X=m
 CONFIG_FRAMEBUFFER_CONSOLE=y
 CONFIG_LOGO=y
+CONFIG_MEDIA_RC_SUPPORT=y
+CONFIG_RC_DEVICES=y
+CONFIG_IR_HIX5HD2=y
+CONFIG_LIRC=y
 # CONFIG_LOGO_LINUX_MONO is not set
 # CONFIG_LOGO_LINUX_VGA16 is not set
 CONFIG_SOUND=y
@@ -488,7 +497,9 @@ CONFIG_PWM_MESON=m
 CONFIG_PWM_ROCKCHIP=y
 CONFIG_PWM_SAMSUNG=y
 CONFIG_PWM_TEGRA=m
+CONFIG_TI_SYSCON_RESET=y
 CONFIG_PHY_RCAR_GEN3_USB2=y
+CONFIG_PHY_HISI_INNO_USB2=y
 CONFIG_PHY_HI6220_USB=y
 CONFIG_PHY_SUN4I_USB=y
 CONFIG_PHY_ROCKCHIP_INNO_USB2=y
-- 
1.9.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 4/5] arm64: dts: hisilicon: add usb2 controller and phy nodes for poplar board.

2017-06-21 Thread Jiancheng Xue
Add usb2 controller and phy nodes for poplar board.

Signed-off-by: Jiancheng Xue 
Reviewed-by: Daniel Thompson 
---
 .../boot/dts/hisilicon/hi3798cv200-poplar.dts  | 13 ++
 arch/arm64/boot/dts/hisilicon/hi3798cv200.dtsi | 47 ++
 2 files changed, 60 insertions(+)

diff --git a/arch/arm64/boot/dts/hisilicon/hi3798cv200-poplar.dts 
b/arch/arm64/boot/dts/hisilicon/hi3798cv200-poplar.dts
index 684fa09..40db803 100644
--- a/arch/arm64/boot/dts/hisilicon/hi3798cv200-poplar.dts
+++ b/arch/arm64/boot/dts/hisilicon/hi3798cv200-poplar.dts
@@ -64,6 +64,10 @@
};
 };
 
+ {
+   status = "okay";
+};
+
  {
status = "okay";
#address-cells = <1>;
@@ -147,6 +151,10 @@
status = "okay";
 };
 
+ {
+   status = "okay";
+};
+
  {
status = "okay";
label = "LS-SPI0";
@@ -161,3 +169,8 @@
label = "LS-UART0";
 };
 /* No optional LS-UART1 on Low Speed Expansion Connector. */
+
+_phy1 {
+   status = "okay";
+};
+
diff --git a/arch/arm64/boot/dts/hisilicon/hi3798cv200.dtsi 
b/arch/arm64/boot/dts/hisilicon/hi3798cv200.dtsi
index 75865f8a..422aeaf 100644
--- a/arch/arm64/boot/dts/hisilicon/hi3798cv200.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hi3798cv200.dtsi
@@ -106,6 +106,11 @@
#reset-cells = <2>;
};
 
+   peri_ctrl: system-controller@8a2 {
+   compatible = "syscon";
+   reg = <0x8a2 0x1000>;
+   };
+
uart0: serial@8b0 {
compatible = "arm,pl011", "arm,primecell";
reg = <0x8b0 0x1000>;
@@ -407,5 +412,47 @@
clocks = < HISTB_IR_CLK>;
status = "disabled";
};
+
+   ehci: ehci@0x989 {
+   compatible = "generic-ehci";
+   reg = <0x989 0x1>;
+   interrupts = ;
+   clocks = < HISTB_USB2_BUS_CLK>,
+< HISTB_USB2_PHY_CLK>;
+   clock-names = "ehci_system", "phy";
+   resets = < 0xb8 12>,
+< 0xb8 16>;
+   reset-names = "bus", "phy";
+   status = "disabled";
+   };
+
+   ohci: ohci@0x988 {
+   compatible = "generic-ohci";
+   reg = <0x988 0x1>;
+   interrupts = ;
+   clocks = < HISTB_USB2_BUS_CLK>,
+< HISTB_USB2_12M_CLK>,
+< HISTB_USB2_48M_CLK>;
+   clock-names = "ahb_biu", "clk12", "clk48";
+   resets = < 0xb8 12>;
+   reset-names = "bus";
+   status = "disabled";
+   };
+
+   usb2_phy1: usb-phy@1 {
+   compatible = "hisilicon,hi3798cv200-usb2-phy";
+   #phy-cells = <0>;
+   hisilicon,peripheral-syscon = <_ctrl>;
+   clocks = < HISTB_USB2_PHY1_REF_CLK>;
+   resets = < 0xbc 4>;
+   reset-names = "por_rst";
+   status = "disabled";
+
+   usb2_port1: port@1 {
+   clocks = < HISTB_USB2_UTMI_CLK>;
+   resets = < 0xbc 9>, < 0xb8 13>;
+   reset-names = "port_rst", "utmi_rst";
+   };
+   };
};
 };
-- 
1.9.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 3/5] phy: add inno-usb2-phy driver for hi3798cv200 SoC

2017-06-21 Thread Jiancheng Xue
From: Pengcheng Li 

Add inno-usb2-phy driver for hi3798cv200 SoC.

Signed-off-by: Pengcheng Li 
Signed-off-by: Jiancheng Xue 
---
 drivers/phy/Kconfig  |  10 ++
 drivers/phy/Makefile |   1 +
 drivers/phy/phy-hisi-inno-usb2.c | 287 +++
 3 files changed, 298 insertions(+)
 create mode 100644 drivers/phy/phy-hisi-inno-usb2.c

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index afaf7b6..f86b9b7 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -225,6 +225,16 @@ config PHY_EXYNOS5250_SATA
  SATA 3.0 Gb/s, SATA 6.0 Gb/s speeds. It supports one SATA host
  port to accept one SATA device.
 
+config PHY_HISI_INNO_USB2
+   tristate "HiSilicon INNO USB2 PHY support"
+   depends on (ARCH_HISI) || COMPILE_TEST
+   select GENERIC_PHY
+   select MFD_SYSCON
+   help
+ Support for INNO USB2 PHY on HiSilicon SoCs. This Phy supports
+ USB 1.5Mb/s, USB 12Mb/s, USB 480Mb/s speeds. It supports one
+ USB host port to accept one USB device.
+
 config PHY_HIX5HD2_SATA
tristate "HIX5HD2 SATA PHY Driver"
depends on ARCH_HIX5HD2 && OF && HAS_IOMEM
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index f8047b4..a275547 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o
 obj-$(CONFIG_PHY_EXYNOS5250_SATA)  += phy-exynos5250-sata.o
 obj-$(CONFIG_PHY_HIX5HD2_SATA) += phy-hix5hd2-sata.o
 obj-$(CONFIG_PHY_HI6220_USB)   += phy-hi6220-usb.o
+obj-$(CONFIG_PHY_HISI_INNO_USB2)   += phy-hisi-inno-usb2.o
 obj-$(CONFIG_PHY_MT65XX_USB3)  += phy-mt65xx-usb3.o
 obj-$(CONFIG_PHY_SUN4I_USB)+= phy-sun4i-usb.o
 obj-$(CONFIG_PHY_SUN9I_USB)+= phy-sun9i-usb.o
diff --git a/drivers/phy/phy-hisi-inno-usb2.c b/drivers/phy/phy-hisi-inno-usb2.c
new file mode 100644
index 000..582c500
--- /dev/null
+++ b/drivers/phy/phy-hisi-inno-usb2.c
@@ -0,0 +1,287 @@
+/*
+ * HiSilicon INNO USB2 PHY Driver.
+ *
+ * Copyright (c) 2016-2017 HiSilicon Technologies Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#defineMAX_PORTS   4
+#define REF_CLK_STABLE_TIME100 /*unit:us*/
+#define UTMI_CLK_STABLE_TIME   200 /*unit:us*/
+#define UTMI_RST_COMPLETE_TIME 200 /*unit:us*/
+#define PORT_RST_COMPLETE_TIME 2   /*unit:ms*/
+#define TEST_RST_COMPLETE_TIME 100 /*unit:us*/
+#define POR_RST_COMPLETE_TIME  300 /*unit:us*/
+
+
+struct  hisi_inno_phy_port {
+   struct clk *utmi_clk;
+   struct reset_control *port_rst;
+   struct reset_control *utmi_rst;
+};
+
+struct hisi_inno_phy_priv {
+   struct regmap *reg_peri;
+   struct clk *ref_clk;
+   struct reset_control *test_rst;
+   struct reset_control *por_rst;
+   const struct reg_sequence *reg_seq;
+   u32 reg_num;
+   struct  hisi_inno_phy_port *ports;
+   u8  port_num;
+};
+
+#define HI3798CV200_PERI_USB0  0x120
+static const struct reg_sequence hi3798cv200_reg_seq[] = {
+   { HI3798CV200_PERI_USB0, 0x00a00604, },
+   { HI3798CV200_PERI_USB0, 0x00e00604, },
+   { HI3798CV200_PERI_USB0, 0x00a00604, 1000 },
+};
+
+static int hisi_inno_phy_setup(struct hisi_inno_phy_priv *priv)
+{
+   return regmap_multi_reg_write_bypassed(priv->reg_peri,
+   priv->reg_seq, priv->reg_num);
+}
+
+static int hisi_inno_port_init(struct hisi_inno_phy_port *port)
+{
+   int ret;
+
+   reset_control_deassert(port->port_rst);
+   msleep(PORT_RST_COMPLETE_TIME);
+
+   ret = clk_prepare_enable(port->utmi_clk);
+   if (ret)
+   return ret;
+   udelay(UTMI_CLK_STABLE_TIME);
+
+   reset_control_deassert(port->utmi_rst);
+   udelay(UTMI_RST_COMPLETE_TIME);
+
+   return 0;
+}
+
+static int hisi_inno_phy_init(struct phy *phy)
+{
+   struct hisi_inno_phy_priv *priv = phy_get_drvdata(phy);
+   int ret, port;
+
+   ret = clk_prepare_enable(priv->ref_clk);
+   if (ret)
+   return ret;
+   udelay(REF_CLK_STABLE_TIME);
+
+   if (priv->test_rst) {
+   

Re: BUG: Soft lockup calling xhci_free_streams in 4.12-rc6 when USB-C hub and SSD is connected

2017-06-21 Thread rocko r
> Does the Samsung 840 EVO SSD support UAS (USB attached SCSI?) i.e. does
> it use the uas driver instead of mass-storage?

I don't think UAS is an issue here: I tried disabling it for the SSD
using a quirk (ie with the line "options usb_storage
quirks=174c:1053:u" in the file /etc/modprobe.d/usb_storage.conf) and
the kernel still locked up.

> Could you take full logs from boot with xhci debugging and tracing both 
> enabled?

See attached. The SSD is /dev/sda and /media/cat is where it tries to
mount /dev/sda1, and there's a NULL dereference at 32.736157 that
might be the cause of the lockup.



On Tue, Jun 20, 2017 at 6:17 PM, Mathias Nyman
 wrote:
> On 20.06.2017 12:47, rocko r wrote:
>>
>> Whenever I boot my laptop and log into the desktop with a USB-C to
>> USB-3 hub attached and a Samsung 840 EVO SSD attached to the USB-C
>> hub, the laptop locks up completely for kernel versions 4.12-rc1
>> through 4.12-rc6. Kernels 4.10 and 4.11 do not crash, so this is a
>> regression.
>>
>> The lock-up occurs shortly after logging into the desktop. Note that
>> when I am presented with the lightdm login screen, my mouse attached
>> via the USB-C to USB-3 hub works, but it stops working after the
>> desktop first appears, as if the USB-C hub has gone offline, and then
>> it starts working again maybe five to ten seconds later (this also
>> happens in kernel 4.11, but 4.11 successfully mounts the SSD and does
>> not lock up).
>>
>> Shortly after this in kernels 4.12-rcX, the SSD fails to mount and at
>> some point after this, syslog shows soft lockup errors. Eventually the
>> entire laptop locks up and has to be hard-reset. When I tried 4.12-rc6
>> today, the laptop locked up almost immediately and did not store a
>> message in syslog.
>>
>> This bug happens every time when rebooting and then logging into the
>> desktop with that particular configuration, ie SSD attached via the
>> USB-C to USB-3 hub. If I have the USB-C to USB-3 hub attached and the
>> SSD attached via one of the laptop's USB-3 ports, the laptop does not
>> lock up. If I plug in the SSD to the USB-C hub after booting into the
>> desktop, the laptop does not lock up.
>>
>> Attached is a log of the soft lockup BUG message from 4.12-rc5 and
>> also another NULL dereference error I noticed today that might be
>> related.
>>
>
> The type-c port is controller by a separate hotpluggable PCI xHCI
> controller,
>
> Looks like that controller disappears for a while, and driver tries to cope
> with it but hangs while freeing streams.
>
> Does the Samsung 840 EVO SSD support UAS (USB attached SCSI?) i.e. does
> it use the uas driver instead of mass-storage?
>
> Could you take full logs from boot with xhci debugging and tracing both
> enabled?
>
> add xhci_hcd.dyndbg=+p  or  module xhci_hcd +p to kernel cmdline  for xhci
> debugging,
> and trace_event=xhci-hcd  trace_buf_size=10M   for tracing
>
> Thanks
> Mathias
>


xhcd and events.log.xz
Description: application/xz


[PATCH v16 3/7] binding-doc: usb: usb-device: add optional properties for power sequence

2017-06-21 Thread Peter Chen
Add optional properties for power sequence.

Signed-off-by: Peter Chen 
Acked-by: Rob Herring 
---
 Documentation/devicetree/bindings/usb/usb-device.txt | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/usb/usb-device.txt 
b/Documentation/devicetree/bindings/usb/usb-device.txt
index 1c35e7b..3661dd2 100644
--- a/Documentation/devicetree/bindings/usb/usb-device.txt
+++ b/Documentation/devicetree/bindings/usb/usb-device.txt
@@ -13,6 +13,10 @@ Required properties:
 - reg: the port number which this device is connecting to, the range
   is 1-31.
 
+Optional properties:
+power sequence properties, see
+Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt for detail
+
 Example:
 
  {
@@ -21,8 +25,12 @@ Example:
#address-cells = <1>;
#size-cells = <0>;
 
-   hub: genesys@1 {
+   genesys: hub@1 {
compatible = "usb5e3,608";
reg = <1>;
+
+   clocks = < IMX6SX_CLK_CKO>;
+   reset-gpios = < 5 GPIO_ACTIVE_LOW>; /* hub reset pin */
+   reset-duration-us = <10>;
};
 }
-- 
2.7.4

--
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 v16 4/7] usb: core: add power sequence handling for USB devices

2017-06-21 Thread Peter Chen
Some hard-wired USB devices need to do power sequence to let the
device work normally, the typical power sequence like: enable USB
PHY clock, toggle reset pin, etc. But current Linux USB driver
lacks of such code to do it, it may cause some hard-wired USB devices
works abnormal or can't be recognized by controller at all.

In this patch, it calls power sequence library APIs to finish
the power sequence events. It will do power on sequence at hub's
probe for all devices under this hub (includes root hub).
At hub_disconnect, it will do power off sequence which is at powered
on list.

Signed-off-by: Peter Chen 
Tested-by Joshua Clayton 
Tested-by: Maciej S. Szmigiero 
Reviewed-by: Vaibhav Hiremath 
Acked-by: Alan Stern 
---
 drivers/usb/Kconfig|  1 +
 drivers/usb/core/hub.c | 49 +
 drivers/usb/core/hub.h |  1 +
 3 files changed, 47 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index 939a63b..b6f626e 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -39,6 +39,7 @@ config USB
tristate "Support for Host-side USB"
depends on USB_ARCH_HAS_HCD
select USB_COMMON
+   select POWER_SEQUENCE
select NLS  # for UTF-8 strings
---help---
  Universal Serial Bus (USB) is a specification for a serial bus
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 9dca59e..0439d4f 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -1619,6 +1620,7 @@ static void hub_disconnect(struct usb_interface *intf)
hub->error = 0;
hub_quiesce(hub, HUB_DISCONNECT);
 
+   of_pwrseq_off_list(>pwrseq_list);
mutex_lock(_port_peer_mutex);
 
/* Avoid races with recursively_mark_NOTATTACHED() */
@@ -1646,12 +1648,42 @@ static void hub_disconnect(struct usb_interface *intf)
kref_put(>kref, hub_release);
 }
 
+#ifdef CONFIG_OF
+static int hub_of_pwrseq_on(struct usb_hub *hub)
+{
+   struct device *parent;
+   struct usb_device *hdev = hub->hdev;
+   struct device_node *np;
+   int ret;
+
+   if (hdev->parent)
+   parent = >dev;
+   else
+   parent = bus_to_hcd(hdev->bus)->self.sysdev;
+
+   for_each_child_of_node(parent->of_node, np) {
+   ret = of_pwrseq_on_list(np, >pwrseq_list);
+   /* Maybe no power sequence library is chosen */
+   if (ret && ret != -ENOENT)
+   return ret;
+   }
+
+   return 0;
+}
+#else
+static int hub_of_pwrseq_on(struct usb_hub *hub)
+{
+   return 0;
+}
+#endif
+
 static int hub_probe(struct usb_interface *intf, const struct usb_device_id 
*id)
 {
struct usb_host_interface *desc;
struct usb_endpoint_descriptor *endpoint;
struct usb_device *hdev;
struct usb_hub *hub;
+   int ret = -ENODEV;
 
desc = intf->cur_altsetting;
hdev = interface_to_usbdev(intf);
@@ -1756,6 +1788,7 @@ static int hub_probe(struct usb_interface *intf, const 
struct usb_device_id *id)
INIT_DELAYED_WORK(>leds, led_work);
INIT_DELAYED_WORK(>init_work, NULL);
INIT_WORK(>events, hub_event);
+   INIT_LIST_HEAD(>pwrseq_list);
usb_get_intf(intf);
usb_get_dev(hdev);
 
@@ -1769,11 +1802,14 @@ static int hub_probe(struct usb_interface *intf, const 
struct usb_device_id *id)
if (id->driver_info & HUB_QUIRK_CHECK_PORT_AUTOSUSPEND)
hub->quirk_check_port_auto_suspend = 1;
 
-   if (hub_configure(hub, endpoint) >= 0)
-   return 0;
+   if (hub_configure(hub, endpoint) >= 0) {
+   ret = hub_of_pwrseq_on(hub);
+   if (!ret)
+   return 0;
+   }
 
hub_disconnect(intf);
-   return -ENODEV;
+   return ret;
 }
 
 static int
@@ -3593,14 +3629,19 @@ static int hub_suspend(struct usb_interface *intf, 
pm_message_t msg)
 
/* stop hub_wq and related activity */
hub_quiesce(hub, HUB_SUSPEND);
-   return 0;
+   return pwrseq_suspend_list(>pwrseq_list);
 }
 
 static int hub_resume(struct usb_interface *intf)
 {
struct usb_hub *hub = usb_get_intfdata(intf);
+   int ret;
 
dev_dbg(>dev, "%s\n", __func__);
+   ret = pwrseq_resume_list(>pwrseq_list);
+   if (ret)
+   return ret;
+
hub_activate(hub, HUB_RESUME);
return 0;
 }
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index 34c1a7e..27f56a6 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -78,6 +78,7 @@ struct usb_hub {
struct delayed_work init_work;
struct work_struct  events;
struct usb_port **ports;
+   struct list_head

[PATCH v16 5/7] ARM: dts: imx6qdl: Enable usb node children with

2017-06-21 Thread Peter Chen
From: Joshua Clayton 

Give usb nodes #address and #size attributes, so that a child node
representing a permanently connected device such as an onboard hub may
be addressed with a  attribute

Signed-off-by: Joshua Clayton 
Signed-off-by: Peter Chen 
---
 arch/arm/boot/dts/imx6qdl.dtsi | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi
index e426faa..8c064cb 100644
--- a/arch/arm/boot/dts/imx6qdl.dtsi
+++ b/arch/arm/boot/dts/imx6qdl.dtsi
@@ -945,6 +945,8 @@
 
usbh1: usb@02184200 {
compatible = "fsl,imx6q-usb", "fsl,imx27-usb";
+   #address-cells = <1>;
+   #size-cells = <0>;
reg = <0x02184200 0x200>;
interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>;
clocks = < IMX6QDL_CLK_USBOH3>;
@@ -959,6 +961,8 @@
 
usbh2: usb@02184400 {
compatible = "fsl,imx6q-usb", "fsl,imx27-usb";
+   #address-cells = <1>;
+   #size-cells = <0>;
reg = <0x02184400 0x200>;
interrupts = <0 41 IRQ_TYPE_LEVEL_HIGH>;
clocks = < IMX6QDL_CLK_USBOH3>;
@@ -972,6 +976,8 @@
 
usbh3: usb@02184600 {
compatible = "fsl,imx6q-usb", "fsl,imx27-usb";
+   #address-cells = <1>;
+   #size-cells = <0>;
reg = <0x02184600 0x200>;
interrupts = <0 42 IRQ_TYPE_LEVEL_HIGH>;
clocks = < IMX6QDL_CLK_USBOH3>;
-- 
2.7.4

--
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 v16 7/7] ARM: dts: imx6q-evi: Fix onboard hub reset line

2017-06-21 Thread Peter Chen
From: Joshua Clayton 

Previously the onboard hub was made to work by treating its
reset gpio as a regulator enable.
Get rid of that kludge now that pwseq has added reset gpio support
Move pin muxing the hub reset pin into the usbh1 group

Signed-off-by: Joshua Clayton 
Signed-off-by: Peter Chen 
---
 arch/arm/boot/dts/imx6q-evi.dts | 25 +++--
 1 file changed, 7 insertions(+), 18 deletions(-)

diff --git a/arch/arm/boot/dts/imx6q-evi.dts b/arch/arm/boot/dts/imx6q-evi.dts
index fd2220a..24fe093 100644
--- a/arch/arm/boot/dts/imx6q-evi.dts
+++ b/arch/arm/boot/dts/imx6q-evi.dts
@@ -54,18 +54,6 @@
reg = <0x1000 0x4000>;
};
 
-   reg_usbh1_vbus: regulator-usbhubreset {
-   compatible = "regulator-fixed";
-   regulator-name = "usbh1_vbus";
-   regulator-min-microvolt = <500>;
-   regulator-max-microvolt = <500>;
-   enable-active-high;
-   startup-delay-us = <2>;
-   pinctrl-names = "default";
-   pinctrl-0 = <_usbh1_hubreset>;
-   gpio = < 12 GPIO_ACTIVE_HIGH>;
-   };
-
reg_usb_otg_vbus: regulator-usbotgvbus {
compatible = "regulator-fixed";
regulator-name = "usb_otg_vbus";
@@ -204,12 +192,18 @@
 };
 
  {
-   vbus-supply = <_usbh1_vbus>;
pinctrl-names = "default";
pinctrl-0 = <_usbh1>;
dr_mode = "host";
disable-over-current;
status = "okay";
+
+   usb2415host: hub@1 {
+   compatible = "usb424,2513";
+   reg = <1>;
+   reset-gpios = < 12 GPIO_ACTIVE_LOW>;
+   reset-duration-us = <3000>;
+   };
 };
 
  {
@@ -465,11 +459,6 @@
MX6QDL_PAD_GPIO_3__USB_H1_OC 0x1b0b0
/* usbh1_b OC */
MX6QDL_PAD_GPIO_0__GPIO1_IO00 0x1b0b0
-   >;
-   };
-
-   pinctrl_usbh1_hubreset: usbh1hubresetgrp {
-   fsl,pins = <
MX6QDL_PAD_GPIO_17__GPIO7_IO12 0x1b0b0
>;
};
-- 
2.7.4

--
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 v16 6/7] ARM: dts: imx6qdl-udoo.dtsi: fix onboard USB HUB property

2017-06-21 Thread Peter Chen
The current dts describes USB HUB's property at USB controller's
entry, it is improper. The USB HUB should be the child node
under USB controller, and power sequence properties are under
it. Besides, using gpio pinctrl setting for USB2415's reset pin.

Signed-off-by: Peter Chen 
Signed-off-by: Joshua Clayton 
Tested-by: Maciej S. Szmigiero 
---
 arch/arm/boot/dts/imx6qdl-udoo.dtsi | 26 --
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/arch/arm/boot/dts/imx6qdl-udoo.dtsi 
b/arch/arm/boot/dts/imx6qdl-udoo.dtsi
index c96c91d..a173de2 100644
--- a/arch/arm/boot/dts/imx6qdl-udoo.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-udoo.dtsi
@@ -9,6 +9,8 @@
  *
  */
 
+#include 
+
 / {
aliases {
backlight = 
@@ -58,17 +60,6 @@
#address-cells = <1>;
#size-cells = <0>;
 
-   reg_usb_h1_vbus: regulator@0 {
-   compatible = "regulator-fixed";
-   reg = <0>;
-   regulator-name = "usb_h1_vbus";
-   regulator-min-microvolt = <500>;
-   regulator-max-microvolt = <500>;
-   enable-active-high;
-   startup-delay-us = <2>; /* USB2415 requires a POR of 1 
us minimum */
-   gpio = < 12 0>;
-   };
-
reg_panel: regulator@1 {
compatible = "regulator-fixed";
reg = <1>;
@@ -188,7 +179,7 @@
 
pinctrl_usbh: usbhgrp {
fsl,pins = <
-   MX6QDL_PAD_GPIO_17__GPIO7_IO12 0x8000
+   MX6QDL_PAD_GPIO_17__GPIO7_IO12  0x1b0b0
MX6QDL_PAD_NANDF_CS2__CCM_CLKO2 0x130b0
>;
};
@@ -259,9 +250,16 @@
  {
pinctrl-names = "default";
pinctrl-0 = <_usbh>;
-   vbus-supply = <_usb_h1_vbus>;
-   clocks = < IMX6QDL_CLK_CKO>;
status = "okay";
+
+   usb2415: hub@1 {
+   compatible = "usb424,2514";
+   reg = <1>;
+
+   clocks = < IMX6QDL_CLK_CKO>;
+   reset-gpios = < 12 GPIO_ACTIVE_LOW>;
+   reset-duration-us = <3000>;
+   };
 };
 
  {
-- 
2.7.4

--
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 v16 2/7] power: add power sequence library

2017-06-21 Thread Peter Chen
We have an well-known problem that the device needs to do some power
sequence before it can be recognized by related host, the typical
example like hard-wired mmc devices and usb devices.

This power sequence is hard to be described at device tree and handled by
related host driver, so we have created a common power sequence
library to cover this requirement. The core code has supplied
some common helpers for host driver, and individual power sequence
libraries handle kinds of power sequence for devices. The pwrseq
librares always need to allocate extra instance for compatible
string match.

pwrseq_generic is intended for general purpose of power sequence, which
handles gpios and clocks currently, and can cover other controls in
future. The host driver just needs to call of_pwrseq_on/of_pwrseq_off
if only one power sequence is needed, else call of_pwrseq_on_list
/of_pwrseq_off_list instead (eg, USB hub driver).

For new power sequence library, it needs to add its compatible string
and allocation function at pwrseq_match_table_list, then the pwrseq
core will match it with DT's, and choose this library at runtime.

Signed-off-by: Peter Chen 
Tested-by: Maciej S. Szmigiero 
Tested-by Joshua Clayton 
Reviewed-by: Matthias Kaehlcke 
Tested-by: Matthias Kaehlcke 
---
 Documentation/power/power-sequence/design.rst |  54 +
 MAINTAINERS   |   9 +
 drivers/power/Kconfig |   1 +
 drivers/power/Makefile|   1 +
 drivers/power/pwrseq/Kconfig  |  20 ++
 drivers/power/pwrseq/Makefile |   2 +
 drivers/power/pwrseq/core.c   | 293 ++
 drivers/power/pwrseq/pwrseq_generic.c | 210 ++
 include/linux/power/pwrseq.h  |  84 
 9 files changed, 674 insertions(+)
 create mode 100644 Documentation/power/power-sequence/design.rst
 create mode 100644 drivers/power/pwrseq/Kconfig
 create mode 100644 drivers/power/pwrseq/Makefile
 create mode 100644 drivers/power/pwrseq/core.c
 create mode 100644 drivers/power/pwrseq/pwrseq_generic.c
 create mode 100644 include/linux/power/pwrseq.h

diff --git a/Documentation/power/power-sequence/design.rst 
b/Documentation/power/power-sequence/design.rst
new file mode 100644
index 000..554608e
--- /dev/null
+++ b/Documentation/power/power-sequence/design.rst
@@ -0,0 +1,54 @@
+
+Power Sequence Library
+
+
+:Date: Feb, 2017
+:Author: Peter Chen 
+
+
+Introduction
+
+
+We have an well-known problem that the device needs to do a power
+sequence before it can be recognized by related host, the typical
+examples are hard-wired mmc devices and usb devices. The host controller
+can't know what kinds of this device is in its bus if the power
+sequence has not done, since the related devices driver's probe calling
+is determined by runtime according to eunumeration results. Besides,
+the devices may have custom power sequence, so the power sequence library
+which is independent with the devices is needed.
+
+Design
+
+
+The power sequence library includes the core file and customer power
+sequence library. The core file exports interfaces are called by
+host controller driver for power sequence and customer power sequence
+library files to register its power sequence instance to global
+power sequence list. The custom power sequence library creates power
+sequence instance and implement custom power sequence.
+
+Since the power sequence describes hardware design, the description is
+located at board description file, eg, device tree dts file. And
+a specific power sequence belongs to device, so its description
+is under the device node, please refer to:
+Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt
+
+Custom power sequence library allocates one power sequence instance at
+bootup periods using postcore_initcall, this static allocated instance is
+used to compare with device-tree (DT) node to see if this library can be
+used for the node or not. When the result is matched, the core API will
+try to get resourses (->get, implemented at each library) for power
+sequence, if all resources are got, it will try to allocate another
+instance for next possible request from host driver.
+
+Then, the host controller driver can carry out power sequence on for this
+DT node, the library will do corresponding operations, like open clocks,
+toggle gpio, etc. The power sequence off routine will close and free the
+resources, and is called when the parent is removed. And the power
+sequence suspend and resume routine can be called at host driver's
+suspend and resume routine if needed.
+
+The exported interfaces
+.. kernel-doc:: drivers/power/pwrseq/core.c
+   :export:
diff --git 

[PATCH v16 1/7] binding-doc: power: pwrseq-generic: add binding doc for generic power sequence library

2017-06-21 Thread Peter Chen
Add binding doc for generic power sequence library.

Signed-off-by: Peter Chen 
Acked-by: Philipp Zabel 
Acked-by: Rob Herring 
---
 .../bindings/power/pwrseq/pwrseq-generic.txt   | 53 ++
 1 file changed, 53 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt

diff --git a/Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt 
b/Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt
new file mode 100644
index 000..3d282ca
--- /dev/null
+++ b/Documentation/devicetree/bindings/power/pwrseq/pwrseq-generic.txt
@@ -0,0 +1,53 @@
+The generic power sequence library
+
+Some hard-wired devices (eg USB/MMC) need to do power sequence before
+the device can be enumerated on the bus, the typical power sequence
+like: enable USB PHY clock, toggle reset pin, etc. But current
+Linux device driver lacks of such code to do it, it may cause some
+hard-wired devices works abnormal or can't be recognized by
+controller at all. The power sequence will be done before this device
+can be found at the bus.
+
+The power sequence properties is under the device node.
+
+Required properties:
+- compatible: should be one of:
+   "usb424,2513"
+   "usb424,2514"
+
+Optional properties:
+- clocks: the input clocks for device.
+- reset-gpios: Should specify the GPIO for reset.
+- reset-duration-us: the duration in microsecond for assert reset signal.
+
+Below is the example of USB power sequence properties on USB device
+nodes which have two level USB hubs.
+
+ {
+   vbus-supply = <_usb_otg1_vbus>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_usb_otg1_id>;
+   status = "okay";
+
+   #address-cells = <1>;
+   #size-cells = <0>;
+   genesys: hub@1 {
+   compatible = "usb424,2513";
+   reg = <1>;
+
+   clocks = < IMX6SX_CLK_CKO>;
+   reset-gpios = < 5 GPIO_ACTIVE_LOW>; /* hub reset pin */
+   reset-duration-us = <10>;
+
+   #address-cells = <1>;
+   #size-cells = <0>;
+   asix: ethernet@1 {
+   compatible = "usb424,2514";
+   reg = <1>;
+
+   clocks = < IMX6SX_CLK_IPG>;
+   reset-gpios = < 6 GPIO_ACTIVE_LOW>;
+   reset-duration-us = <15>;
+   };
+   };
+};
-- 
2.7.4

--
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 v16 0/7] power: add power sequence library

2017-06-21 Thread Peter Chen
This is a follow-up for my last power sequence framework patch set [1].
According to Rob Herring and Ulf Hansson's comments[2]. The kinds of
power sequence instances will be added at postcore_initcall, the match
criteria is compatible string first, if the compatible string is not
matched between dts and library, it will try to use generic power sequence.
 
The host driver just needs to call of_pwrseq_on/of_pwrseq_off
if only one power sequence instance is needed, for more power sequences
are used, using of_pwrseq_on_list/of_pwrseq_off_list instead (eg, USB hub 
driver).

In future, if there are special power sequence requirements, the special
power sequence library can be created.

This patch set is tested on i.mx6 sabresx evk using a dts change, I use
two hot-plug devices to simulate this use case, the related binding
change is updated at patch [1/6], The udoo board changes were tested
using my last power sequence patch set.[3]

Except for hard-wired MMC and USB devices, I find the USB ULPI PHY also
need to power on itself before it can be found by ULPI bus.

@Rafael, USB Maintainer has already acked the USB related changes, would you
consider queueing it at v4.13-rc1, sereval guys are waiting for this series.
Thanks.

Changes for v16:
- Change match way between pwrseq instance and device. Currently, it maintains 
a global
  table for compatible string and corresponding pwrseq library allocation 
function. The
  match is occurred when host controller tries to carry out power on device, if 
it is
  matched, it will allocate pwrseq instance for this device. [Patch 2/7]
- Add related compatible string maintained at pwrseq_match_table_list. [Patch 
1/7]

Changes for v15:
- Change pwrseq list name at USB hub structure (pwrseq_on_list->pwrseq_list). 
[Patch 4/7]
- Add USB Maintainer's Ack [Patch 4/7]

Changes for v14:
- Rebase for v4.12-rc1
- Delete some USB sysdev patches which has already merged

Changes for v13:
- Add more design descriptions at design doc and fix one build error
  introduced by v12 wrongly [Patch 2/12]
- Add the last three dts patches which were forgotten at last series
- Move the comment for usb_create_shared_hcd to correct place [Patch 3/12]
- Add sysdev for shared hcd too for xhci-plat.c [Patch 6/12]

Rafael, if the first two power sequence patches are ok for you, would you 
consider
accept these first, the other USB patches can go through USB tree at v4.12-rc1?

Changes for v12:
- Add design doc and more comments at generic power sequence source file [Patch 
2/9]
- Introduce four Arnd Bergmann patches and one my ehci related patches, these 
patches
  are used to get property DT/firmware information at USB code, and these 
information
  are needed for power sequence operation at USB. With these five patches, my 
chipidea
  hack patch in previous patch set can be removed. [Patch 3-7/9]
- Add -ENOENT judgement to avoid USB error if no power sequence library is 
chosen [9/9]

Changes for v11:
- Fix warning: (USB) selects POWER_SEQUENCE which has unmet direct dependencies 
(OF)
- Delete redundant copyright statement.
- Change pr_warn to pr_debug at wrseq_find_available_instance
- Refine kerneldoc
- %s/ENONET/ENOENT 
- Allocate pwrseq list node before than carry out power sequence on 
- Add mutex_lock/mutex_lock for pwrseq node browse at 
pwrseq_find_available_instance
- Add pwrseq_suspend/resume for API both single instance and list 
- Add .pwrseq_suspend/resume for pwrseq_generic.c
- Add pwrseq_suspend_list and pwrseq_resume_list for USB hub suspend
  and resume routine

Changes for v10:
- Improve the kernel-doc for power sequence core, including exported APIs and
  main structure. [Patch 2/8]
- Change Kconfig, and let the user choose power sequence. [Patch 2/8]
- Delete EXPORT_SYMBOL and change related APIs as local, these APIs do not
  be intended to export currently. [Patch 2/8]
- Selete POWER_SEQUENCE at USB core's Kconfig. [Patch 4/8]

Changes for v9:
- Add Vaibhav Hiremath's reviewed-by [Patch 4/8]
- Rebase to v4.9-rc1

Changes for v8:
- Allocate one extra pwrseq instance if pwrseq_get has succeed, it can avoid
  preallocate instances problem which the number of instance is decided at
  compile time, thanks for Heiko Stuebner's suggestion [Patch 2/8]
- Delete pwrseq_compatible_sample.c which is the demo purpose to show compatible
  match method. [Patch 2/8]
- Add Maciej S. Szmigiero's tested-by. [Patch 7/8]

Changes for v7:
- Create kinds of power sequence instance at postcore_initcall, and match
  the instance with node using compatible string, the beneit of this is
  the host driver doesn't need to consider which pwrseq instance needs
  to be used, and pwrseq core will match it, however, it eats some memories
  if less power sequence instances are used. [Patch 2/8]
- Add pwrseq_compatible_sample.c to test match pwrseq using device_id. [Patch 
2/8]
- Fix the comments Vaibhav Hiremath adds for error path for clock and do not
  use device_node for parameters at pwrseq_on. 

Re: [PATCH] usb:gadget:hid: This patch adds support for set_protocol and get_protocol for remote wakeup

2017-06-21 Thread Felipe Balbi

Hi,

first of all, your subject line is too long. Something like:

usb: gadget: hid: Add support for {GET,SET}_PROTOCOL

would've been enough

Abdulhadi Mohamed  writes:
> This patch is required to implement the set_procotol and get_procotol 
> commands 
> for HID gadgets to interact with the BIOS using the BOOT protocol according 
> to 
> the HID specification. These two commands are also required to implement 
> remote 
> wake up for HID gadgets once the BIOS takes control of the device. 
>
> This issue was first raised by Golmer Palmer in May 25 2015 but was never 
> followed 
> up on. This version of the patch is also heavily based on the patch provided 
> by 
> Alan Stern with some added support for remote wakeup.

commit log needs to be broken at 72 characters.

> Abdul Mohamed

this is not how you sign a patch, although it's close. It needs to be:

Signed-off-by: Abdul Mohamed 

> diff --git a/drivers/usb/gadget/function/f_hid.c 
> b/drivers/usb/gadget/function/f_hid.c
> index 5eea448..ea38e36 100644
> --- a/drivers/usb/gadget/function/f_hid.c
> +++ b/drivers/usb/gadget/function/f_hid.c
> @@ -44,6 +44,7 @@ struct f_hidg {
>   /* configuration */
>   unsigned char   bInterfaceSubClass;
>   unsigned char   bInterfaceProtocol;
> + unsigned char   protocol_is_report;
>   unsigned short  report_desc_length;
>   char*report_desc;
>   unsigned short  report_length;
> @@ -338,10 +339,13 @@ static ssize_t f_hidg_write(struct file *file, const 
> char __user *buffer,
>   size_t count, loff_t *offp)
>  {
>   struct f_hidg *hidg  = file->private_data;
> + struct usb_composite_dev*cdev = hidg->func.config->cdev; 

why the tab here? Every other variable declaration is using one space
only. Just keep it consistent ;-)

>   struct usb_request *req;
>   unsigned long flags;
>   ssize_t status = -ENOMEM;
>  
> + usb_gadget_wakeup(cdev->gadget);

this seems unrelated to implemeting GET/SET_PROTOCOL. Why do you need this?

> @@ -528,6 +532,9 @@ static int hidg_setup(struct usb_function *f,
> | HID_REQ_GET_PROTOCOL):
>   VDBG(cdev, "get_protocol\n");
>   goto stall;
> + length = min_t(unsigned, length, 1); 
> + ((u8 *) req->buf)[0]= hidg->protocol_is_report;
> + goto respond; 
>   break;
>  
>   case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8
> @@ -539,6 +546,17 @@ static int hidg_setup(struct usb_function *f,
>   case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8
> | HID_REQ_SET_PROTOCOL):
>   VDBG(cdev, "set_protocol\n");
> + if (value > 1)

why 1 here? Seems like this should be
USB_INTERFACE_PROTOCOL_KEYBOARD. And are you sure there's nobody using
this to emulate a mouse?

> + goto stall; 
> + length = 0;
> + /*
> +  * We assume that programs implementing the Boot protocol 
> +  * are also compatible with the Report protocol. 
> +  */ 

Why is this a safe assumption?

> + if(hidg->bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT) { 
> + hidg->protocol_is_report = value; 
> + goto respond;

wrong indentation.

> @@ -768,6 +786,7 @@ static int hidg_bind(struct usb_configuration *c, struct 
> usb_function *f)
>   /* set descriptor dynamic values */
>   hidg_interface_desc.bInterfaceSubClass = hidg->bInterfaceSubClass;
>   hidg_interface_desc.bInterfaceProtocol = hidg->bInterfaceProtocol;
> + hidg->protocol_is_report = 1; 

no idea why you called this "protocol_is_report" when "protocol"
would've been better.

-- 
balbi


signature.asc
Description: PGP signature