Re: [PATCH v2 4/4] usb: dwc3: Workaround for super-speed host on dra7 in dual-role mode

2017-02-23 Thread Vivek Gautam



On 02/24/2017 06:27 AM, Peter Chen wrote:

On Thu, Feb 23, 2017 at 02:04:50PM +0530, Vivek Gautam wrote:


On 02/16/2017 06:36 PM, Roger Quadros wrote:

dra7 OTG core limits the host controller to USB2.0 (high-speed) mode
when we're operating in dual-role.

We work around that by bypassing the OTG core and reading the
extcon framework directly for ID/VBUS events.

Signed-off-by: Roger Quadros 
---
  Documentation/devicetree/bindings/usb/dwc3.txt |   2 +
  drivers/usb/dwc3/core.c| 169 -
  drivers/usb/dwc3/core.h|   5 +
  3 files changed, 170 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
b/Documentation/devicetree/bindings/usb/dwc3.txt
index e3e6983..9955c0d 100644
--- a/Documentation/devicetree/bindings/usb/dwc3.txt
+++ b/Documentation/devicetree/bindings/usb/dwc3.txt
@@ -53,6 +53,8 @@ Optional properties:
   - snps,quirk-frame-length-adjustment: Value for GFLADJ_30MHZ field of GFLADJ
register for post-silicon frame length adjustment when the
fladj_30mhz_sdbnd signal is invalid or incorrect.
+ - extcon: phandle to the USB connector extcon device. If present, extcon
+   device will be used to get USB cable events instead of OTG controller.
   -  tx-fifo-resize: determines if the FIFO *has* to be 
reallocated.
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 619fa7c..b02d911 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c

[snip]


@@ -1587,6 +1727,14 @@ static int dwc3_probe(struct platform_device *pdev)
dwc3_get_properties(dwc);
+   if (dev->of_node) {
+   if (of_property_read_bool(dev->of_node, "extcon"))
+   dwc->edev = extcon_get_edev_by_phandle(dev, 0);

Don't we want separate edev's for vbus and id ?
One can have separate pins connected to them and in that case
we can't get the events out of one pin only.


Current extcon-usb-gpio driver supports id and vbus at the same time,
that means there are two optional gpios under one extcon node.



Right, and we would want to leverage that by providing couple
of phandles for vbus and id, and requesting the two in driver.


Regards
Vivek

--
The 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] usb: add CONFIG_USB_PCI for system have both PCI HW and non-PCI based USB HW

2017-02-23 Thread kbuild test robot
Hi yuan,

[auto build test ERROR on usb/usb-testing]
[also build test ERROR on v4.10]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/yuan-linyu/usb-add-CONFIG_USB_PCI-for-system-have-both-PCI-HW-and-non-PCI-based-USB-HW/20170215-203820
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git 
usb-testing
config: i386-randconfig-c0-02240849 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

>> drivers/usb/host/pci-quirks.c:156:6: error: redefinition of 'sb800_prefetch'
void sb800_prefetch(struct device *dev, int on)
 ^
   In file included from drivers/usb/host/pci-quirks.c:18:0:
   drivers/usb/host/pci-quirks.h:23:20: note: previous definition of 
'sb800_prefetch' was here
static inline void sb800_prefetch(struct device *dev, int on) {}
   ^
>> drivers/usb/host/pci-quirks.c:409:6: error: redefinition of 
>> 'usb_amd_quirk_pll_disable'
void usb_amd_quirk_pll_disable(void)
 ^
   In file included from drivers/usb/host/pci-quirks.c:18:0:
   drivers/usb/host/pci-quirks.h:19:20: note: previous definition of 
'usb_amd_quirk_pll_disable' was here
static inline void usb_amd_quirk_pll_disable(void) {}
   ^
>> drivers/usb/host/pci-quirks.c:415:6: error: redefinition of 
>> 'usb_amd_quirk_pll_enable'
void usb_amd_quirk_pll_enable(void)
 ^
   In file included from drivers/usb/host/pci-quirks.c:18:0:
   drivers/usb/host/pci-quirks.h:20:20: note: previous definition of 
'usb_amd_quirk_pll_enable' was here
static inline void usb_amd_quirk_pll_enable(void) {}
   ^
>> drivers/usb/host/pci-quirks.c:421:6: error: redefinition of 'usb_amd_dev_put'
void usb_amd_dev_put(void)
 ^
   In file included from drivers/usb/host/pci-quirks.c:18:0:
   drivers/usb/host/pci-quirks.h:21:20: note: previous definition of 
'usb_amd_dev_put' was here
static inline void usb_amd_dev_put(void) {}
   ^
>> drivers/usb/host/pci-quirks.c:951:6: error: redefinition of 
>> 'usb_disable_xhci_ports'
void usb_disable_xhci_ports(struct pci_dev *xhci_pdev)
 ^
   In file included from drivers/usb/host/pci-quirks.c:18:0:
   drivers/usb/host/pci-quirks.h:22:20: note: previous definition of 
'usb_disable_xhci_ports' was here
static inline void usb_disable_xhci_ports(struct pci_dev *xhci_pdev) {}
   ^

vim +/sb800_prefetch +156 drivers/usb/host/pci-quirks.c

22b4f0cd Huang Rui2013-09-16  150   }
22b4f0cd Huang Rui2013-09-16  151  
22b4f0cd Huang Rui2013-09-16  152   pinfo->sb_type.rev = rev;
22b4f0cd Huang Rui2013-09-16  153   return 1;
22b4f0cd Huang Rui2013-09-16  154  }
22b4f0cd Huang Rui2013-09-16  155  
2621d011 Manjunath Goudar 2013-05-28 @156  void sb800_prefetch(struct device 
*dev, int on)
2621d011 Manjunath Goudar 2013-05-28  157  {
2621d011 Manjunath Goudar 2013-05-28  158   u16 misc;
2621d011 Manjunath Goudar 2013-05-28  159   struct pci_dev *pdev = 
to_pci_dev(dev);

:: The code at line 156 was first introduced by commit
:: 2621d0119e574f12496c4ab731265d5777cb6a18 USB: OHCI: Generic changes to 
make ohci-pci a separate driver

:: TO: Manjunath Goudar 
:: CC: Greg Kroah-Hartman 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


Re: [Kernel] usbhid 3-2:1.1: couldn't find an input interrupt endpoint

2017-02-23 Thread Alan Stern
On Thu, 23 Feb 2017, Cristian wrote:

> Hello,
> 
> lsusb -v; https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1667370

Bus 003 Device 003: ID 0458:0186 KYE Systems Corp. (Mouse Systems) 
Couldn't open device, some information will be missing
Device Descriptor:
  bLength18
  bDescriptorType 1
  bcdUSB   1.10
  bDeviceClass0 (Defined at Interface level)
  bDeviceSubClass 0 
  bDeviceProtocol 0 
  bMaxPacketSize0 8
  idVendor   0x0458 KYE Systems Corp. (Mouse Systems)
  idProduct  0x0186 
  bcdDevice   24.58
  iManufacturer   4 
  iProduct   40 
  iSerial 0 
  bNumConfigurations  1
  Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength   52
bNumInterfaces  2
bConfigurationValue 1
iConfiguration  0 
bmAttributes 0xa0
  (Bus Powered)
  Remote Wakeup
MaxPower  100mA
Interface Descriptor:
  bLength 9
  bDescriptorType 4
  bInterfaceNumber0
  bAlternateSetting   0
  bNumEndpoints   1
  bInterfaceClass 3 Human Interface Device
  bInterfaceSubClass  1 Boot Interface Subclass
  bInterfaceProtocol  2 Mouse
  iInterface  0 
HID Device Descriptor:
  bLength 9
  bDescriptorType33
  bcdHID   1.11
  bCountryCode0 Not supported
  bNumDescriptors 1
  bDescriptorType34 Report
  wDescriptorLength  56
 Report Descriptors: 
   ** UNAVAILABLE **
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81  EP 1 IN
bmAttributes3
  Transfer TypeInterrupt
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0004  1x 4 bytes
bInterval  10
Interface Descriptor:
  bLength 9
  bDescriptorType 4
  bInterfaceNumber1
  bAlternateSetting   0
  bNumEndpoints   0
  bInterfaceClass 3 Human Interface Device
  bInterfaceSubClass  0 No Subclass
  bInterfaceProtocol  0 None
  iInterface  0 
HID Device Descriptor:
  bLength 9
  bDescriptorType33
  bcdHID   1.11
  bCountryCode0 Not supported
  bNumDescriptors 1
  bDescriptorType34 Report
  wDescriptorLength  22
 Report Descriptors: 
   ** UNAVAILABLE **

So the second interface really doesn't have an interrupt endpoint.  In
fact, it doesn't have any endpoints at all.  What it's supposed to be
used for isn't clear -- maybe turning LEDs on and off?

In any case, does the mouse work okay?  If it does, you don't have to 
worry about the error message.

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


[PATCH v2 2/2] usb: gadget: pxa27x: Test for a valid argument pointer

2017-02-23 Thread Petr Cvek
A call usb_put_phy(udc->transceiver) must be tested for a valid pointer.
Use an already existing test for usb_unregister_notifier call.

Reported-by: Robert Jarzmik 
Signed-off-by: Petr Cvek 
---
 drivers/usb/gadget/udc/pxa27x_udc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c 
b/drivers/usb/gadget/udc/pxa27x_udc.c
index 821bd8f4cae6..d48e239660c3 100644
--- a/drivers/usb/gadget/udc/pxa27x_udc.c
+++ b/drivers/usb/gadget/udc/pxa27x_udc.c
@@ -2531,9 +2531,10 @@ static int pxa_udc_remove(struct platform_device *_dev)
usb_del_gadget_udc(&udc->gadget);
pxa_cleanup_debugfs(udc);
 
-   if (!IS_ERR_OR_NULL(udc->transceiver))
+   if (!IS_ERR_OR_NULL(udc->transceiver)) {
usb_unregister_notifier(udc->transceiver, &pxa27x_udc_phy);
-   usb_put_phy(udc->transceiver);
+   usb_put_phy(udc->transceiver);
+   }
 
udc->transceiver = NULL;
the_controller = NULL;
-- 
2.11.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 v2 1/2] usb: gadget: pxa27x: Remove duplicate function prototype

2017-02-23 Thread Petr Cvek
Functions udc_enable() and udc_disable() have a duplicated prototype.
Remove it.

Signed-off-by: Petr Cvek 
---
 drivers/usb/gadget/udc/pxa27x_udc.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c 
b/drivers/usb/gadget/udc/pxa27x_udc.c
index e1335ad5bce9..821bd8f4cae6 100644
--- a/drivers/usb/gadget/udc/pxa27x_udc.c
+++ b/drivers/usb/gadget/udc/pxa27x_udc.c
@@ -1608,9 +1608,6 @@ static int pxa_udc_pullup(struct usb_gadget *_gadget, int 
is_active)
return 0;
 }
 
-static void udc_enable(struct pxa_udc *udc);
-static void udc_disable(struct pxa_udc *udc);
-
 /**
  * pxa_udc_vbus_session - Called by external transceiver to enable/disable udc
  * @_gadget: usb gadget
-- 
2.11.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 v2 0/2] usb: gadget: pxa27x: Duplicated definition and valid pointer fixes

2017-02-23 Thread Petr Cvek
Two simple fixes for pxa27x gadget UDC. First one remove function declaration
duplication, second one add test for a valid pointer before function call as
it can be called with an error value in the pointer.

Changes from v1:
 * Shorter titles, corrected Robert Jarzmik's signature

Petr Cvek (2):
  usb: gadget: pxa27x: Remove duplicate function prototype
  usb: gadget: pxa27x: Test for a valid argument pointer

 drivers/usb/gadget/udc/pxa27x_udc.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

-- 
2.11.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 v2 4/4] usb: dwc3: Workaround for super-speed host on dra7 in dual-role mode

2017-02-23 Thread Peter Chen
On Thu, Feb 23, 2017 at 02:04:50PM +0530, Vivek Gautam wrote:
> 
> 
> On 02/16/2017 06:36 PM, Roger Quadros wrote:
> >dra7 OTG core limits the host controller to USB2.0 (high-speed) mode
> >when we're operating in dual-role.
> >
> >We work around that by bypassing the OTG core and reading the
> >extcon framework directly for ID/VBUS events.
> >
> >Signed-off-by: Roger Quadros 
> >---
> >  Documentation/devicetree/bindings/usb/dwc3.txt |   2 +
> >  drivers/usb/dwc3/core.c| 169 
> > -
> >  drivers/usb/dwc3/core.h|   5 +
> >  3 files changed, 170 insertions(+), 6 deletions(-)
> >
> >diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
> >b/Documentation/devicetree/bindings/usb/dwc3.txt
> >index e3e6983..9955c0d 100644
> >--- a/Documentation/devicetree/bindings/usb/dwc3.txt
> >+++ b/Documentation/devicetree/bindings/usb/dwc3.txt
> >@@ -53,6 +53,8 @@ Optional properties:
> >   - snps,quirk-frame-length-adjustment: Value for GFLADJ_30MHZ field of 
> > GFLADJ
> > register for post-silicon frame length adjustment when the
> > fladj_30mhz_sdbnd signal is invalid or incorrect.
> >+ - extcon: phandle to the USB connector extcon device. If present, extcon
> >+device will be used to get USB cable events instead of OTG controller.
> >   -  tx-fifo-resize: determines if the FIFO *has* to be 
> > reallocated.
> >diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> >index 619fa7c..b02d911 100644
> >--- a/drivers/usb/dwc3/core.c
> >+++ b/drivers/usb/dwc3/core.c
> 
> [snip]
> 
> >@@ -1587,6 +1727,14 @@ static int dwc3_probe(struct platform_device *pdev)
> > dwc3_get_properties(dwc);
> >+if (dev->of_node) {
> >+if (of_property_read_bool(dev->of_node, "extcon"))
> >+dwc->edev = extcon_get_edev_by_phandle(dev, 0);
> 
> Don't we want separate edev's for vbus and id ?
> One can have separate pins connected to them and in that case
> we can't get the events out of one pin only.
> 

Current extcon-usb-gpio driver supports id and vbus at the same time,
that means there are two optional gpios under one extcon node.

-- 

Best Regards,
Peter Chen
--
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


dwc2 gadget issues (was: RK3288 USB OTG controller in peripheral mode)

2017-02-23 Thread Heiko Stuebner
Hi Francesco,

Am Donnerstag, 23. Februar 2017, 19:11:37 CET schrieb Francesco Lavra:
> I'm having trouble getting the RK3288 OTG controller (the one at
> ff58) to work in peripheral mode. I'm using a Firefly Reload board,
> and I know the hardware is fine because I can successfully use the port
> in device mode with U-Boot's mass storage gadget driver.
> Under Linux, the OTG port works fine when used in host mode, but fails
> to work in device mode: nothing happens when the a USB host is plugged
> into the OTG port, not even a single interrupt is generated by the
> controller. I'm using the latest device tree definitions from
> git://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git.

you shouldn't use my tree as base for any real work :-) . Best to use the 
regular mainline kernel or alternatively try linux-next to get all recent usb 
changes schedules for the next release.


> Tried with different gadget drivers (g_audio, g_ether, g_mass_storage),
> but it makes no difference.
> Tried also forcing peripheral mode in the device tree, with dr_mode =
> "peripheral", to no avail.
> 
> Are there any known problems with the RK3288 OTG controller?

In general the controller is a dwc2 and there was quite some activity on the 
driver recently. So maybe really try linux-next first and see if any of the 
changes included there improve the situation.

I've included some usb lists + people, maybe they know if anything recent may 
have changed things.


> Here is the relevant log when the dwc2 driver is loaded at boot:
> 
> [1.376935] ff58.usb supply vusb_d not found, using dummy regulator
> [1.383683] ff58.usb supply vusb_a not found, using dummy regulator
> [1.390627] dwc2 ff58.usb: dwc2_core_reset() HANG! Soft Reset
> GRSTCTL=8001
> [1.509048] dwc2 ff58.usb: dwc2_wait_for_mode: Couldn't set
> device mode
> [1.750626] dwc2 ff58.usb: dwc2_check_param_tx_fifo_sizes:
> Invalid parameter g-tx-fifo-size, setting to default average
> [1.761828] dwc2 ff58.usb: dwc2_check_param_tx_fifo_sizes:
> Invalid parameter g_tx_fifo_size[1]=104
> [1.771192] dwc2 ff58.usb: dwc2_check_param_tx_fifo_sizes:
> Invalid parameter g_tx_fifo_size[2]=104
> [1.780529] dwc2 ff58.usb: dwc2_check_param_tx_fifo_sizes:
> Invalid parameter g_tx_fifo_size[3]=104
> [1.789888] dwc2 ff58.usb: dwc2_check_param_tx_fifo_sizes:
> Invalid parameter g_tx_fifo_size[4]=104
> [1.799245] dwc2 ff58.usb: dwc2_check_param_tx_fifo_sizes:
> Invalid parameter g_tx_fifo_size[5]=104
> [1.808614] dwc2 ff58.usb: dwc2_check_param_tx_fifo_sizes:
> Invalid parameter g_tx_fifo_size[6]=104
> [1.817993] usb 1-1: new high-speed USB device number 2 using dwc2
> [1.824390] dwc2 ff58.usb: EPs: 10, dedicated fifos, 972 entries
> in SPRAM
> [1.832098] dwc2 ff58.usb: DWC OTG Controller
> [1.836924] dwc2 ff58.usb: new USB bus registered, assigned bus
> number 2
> [1.844125] dwc2 ff58.usb: irq 41, io mem 0xff58
> [1.849747] usb usb2: New USB device found, idVendor=1d6b, idProduct=0002
> [1.856598] usb usb2: New USB device strings: Mfr=3, Product=2,
> SerialNumber=1
> [1.863875] usb usb2: Product: DWC OTG Controller
> [1.868601] usb usb2: Manufacturer: Linux 4.8.1+ dwc2_hsotg
> [1.874215] usb usb2: SerialNumber: ff58.usb
> 
> and this is what I get when I load a gadget driver (in this case, g_audio):
> 
> [   19.848590] dwc2 ff58.usb: bound driver g_audio
> [   19.853816] dwc2 ff58.usb: dwc2_hsotg_enqueue_setup: failed queue
> (-11)


Heiko
--
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


Renesas/NEC 720202 ExpressCard USB 3.0 - HDD unmounted after S3 resume

2017-02-23 Thread Alessio Corbucci
Hi,
I have a problem with my new ExpressCard USB 3.0 Renesas 720202:

- PROBLEM DESCRIPTION: an external USB 3.0 drive is connected to the
Renesas ExpressCard USB 3.0 controller with a single ext4 primary
partition on it, mounted, with only a text file opened with geany; when
I put the system on S3 suspend (suspend to ram), on resume the drive is
unmounted and the /dev node is changed from /dev/sdc to /dev/sdd; if no
file is opened at suspend, the /dev node is not changed but the drive
is unmounted anyway. No problems on Windows. No problem either with the
system internal USB ports. I've heard of a quirk for Renesas 720202 but
I have not understood what was the reason for the quirk and what has
been resolved... Any hint for my problem? Thanks.

alessio


- MY SYSTEM: tried with two laptops with similar behavior (data
collected below refer to the Sony):
   Sony Vaio VPCEB4C5E (Intel i3, debian stretch)
  $ uname -r
  4.9.0-1-amd64
   Lenovo X220 (Intel i5, debian stretch)
  $ uname -r
  4.8.0-1-amd64)


- THE RENESAS/NEC 720202 USB 3.0 EXPRESSCARD CONTROLLER
  (tried two identical models):

$ lspci -vmnnd 1912:
Device:05:00.0
Class:USB controller [0c03]
Vendor:Renesas Technology Corp. [1912]
Device:uPD720202 USB 3.0 Host Controller [0015]
PhySlot:1
Rev:02
ProgIf:30

$ lspci
00:00.0 Host bridge: Intel Corporation Core Processor DRAM Controller (rev 02)
00:01.0 PCI bridge: Intel Corporation Core Processor PCI Express x16
Root Port (rev 02)
00:16.0 Communication controller: Intel Corporation 5 Series/3400
Series Chipset HECI Controller (rev 06)
00:1a.0 USB controller: Intel Corporation 5 Series/3400 Series Chipset
USB2 Enhanced Host Controller (rev 05)
00:1b.0 Audio device: Intel Corporation 5 Series/3400 Series Chipset
High Definition Audio (rev 05)
00:1c.0 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI
Express Root Port 1 (rev 05)
00:1c.1 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI
Express Root Port 2 (rev 05)
00:1c.2 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI
Express Root Port 3 (rev 05)
00:1c.5 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI
Express Root Port 6 (rev 05)
00:1d.0 USB controller: Intel Corporation 5 Series/3400 Series Chipset
USB2 Enhanced Host Controller (rev 05)
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev a5)
00:1f.0 ISA bridge: Intel Corporation HM55 Chipset LPC Interface
Controller (rev 05)
00:1f.2 SATA controller: Intel Corporation 5 Series/3400 Series
Chipset 4 port SATA AHCI Controller (rev 05)
00:1f.3 SMBus: Intel Corporation 5 Series/3400 Series Chipset SMBus
Controller (rev 05)
01:00.0 VGA compatible controller: Advanced Micro Devices, Inc.
[AMD/ATI] Madison [Mobility Radeon HD 5650/5750 / 6530M/6550M]
01:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Redwood
HDMI Audio [Radeon HD 5000 Series]
02:00.0 Network controller: Qualcomm Atheros AR9285 Wireless Network
Adapter (PCI-Express) (rev 01)
03:00.0 SD Host controller: Ricoh Co Ltd MMC/SD Host Controller
03:00.1 System peripheral: Ricoh Co Ltd R5U2xx (R5U230 / R5U231 /
R5U241) [Memory Stick Host Controller]
03:00.4 SD Host controller: Ricoh Co Ltd MMC/SD Host Controller
04:00.0 Ethernet controller: Marvell Technology Group Ltd. Yukon
Optima 88E8059 [PCIe Gigabit Ethernet Controller with AVB] (rev 11)
05:00.0 USB controller: Renesas Technology Corp. uPD720202 USB 3.0
Host Controller (rev 02)
3f:00.0 Host bridge: Intel Corporation Core Processor QuickPath
Architecture Generic Non-core Registers (rev 02)
3f:00.1 Host bridge: Intel Corporation Core Processor QuickPath
Architecture System Address Decoder (rev 02)
3f:02.0 Host bridge: Intel Corporation Core Processor QPI Link 0 (rev 02)
3f:02.1 Host bridge: Intel Corporation 1st Generation Core i3/5/7
Processor QPI Physical 0 (rev 02)
3f:02.2 Host bridge: Intel Corporation 1st Generation Core i3/5/7
Processor Reserved (rev 02)
3f:02.3 Host bridge: Intel Corporation 1st Generation Core i3/5/7
Processor Reserved (rev 02)

$ ls -l /sys/bus/usb/devices/usb*
lrwxrwxrwx 1 root root 0 Feb 23 10:20 /sys/bus/usb/devices/usb1 ->
../../../devices/pci:00/:00:1c.5/:05:00.0/usb1
lrwxrwxrwx 1 root root 0 Feb 23 10:20 /sys/bus/usb/devices/usb2 ->
../../../devices/pci:00/:00:1c.5/:05:00.0/usb2
lrwxrwxrwx 1 root root 0 Feb 22 11:47 /sys/bus/usb/devices/usb3 ->
../../../devices/pci:00/:00:1a.0/usb3
lrwxrwxrwx 1 root root 0 Feb 22 11:47 /sys/bus/usb/devices/usb4 ->
../../../devices/pci:00/:00:1d.0/usb4


- HARD DISK DRIVE: tried with two different external USB 3.0 drives but
the info below refer to a 250G Hitachi disk on a 3.0 enclosure (but
similar results with a 2TB Toshiba Canvio Basics):

$lsusb
Bus 004 Device 004: ID 045e:0773 Microsoft Corp.
Bus 004 Device 003: ID 0480:a202 Toshiba America Inc Canvio Basics HDD
Bus 004 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 004 Device 001: ID 1d6b:0002 L

Re: v4.10-rc8 (-rc6) boot regression on Intel desktop, does not boot after cold boots, boots after reboot

2017-02-23 Thread Pavel Machek
On Thu 2017-02-23 17:28:26, Frederic Weisbecker wrote:
> On Tue, Feb 14, 2017 at 08:27:43PM +0100, Pavel Machek wrote:
> > On Tue 2017-02-14 18:59:56, Pavel Machek wrote:
> > > Hi!
> > > 
> > > > > > > Hmm. I moved keyboard between USB ports, and now 4.10-rc6 no 
> > > > > > > longer
> > > > > > > boots. v4.6 works ok. Let me try with keyboard unplugged... no, I
> > > > > > > could not get it to work. I believe v4.9 and some v4.10-rc's 
> > > > > > > worked,
> > > > > > > but I'll have to double check.
> > > > > > 
> > > > > > But all the kernel versions worked when the keyboard was plugged 
> > > > > > into
> > > > > > its original USB port?
> > > > > 
> > > > > Aha. So it looks difference is probably in "where is keyboard plugged
> > > > > in" but in "reboot" vs. "cold boot". I did not do a cold boot in quite
> > > > > a while :-(.
> > > > > 
> > > > > Booting to grub, then hitting ctrl-alt-del is enough to make it work. 
> > > > > Ouch.
> > > > > 
> > > > > It happens with current Linus' tree.
> > > > 
> > > > v4.10-rc6-feb3 : broken
> > > > v4.9 : ok
> > > > (v4.6 : ok)
> > > 
> > > Hmm. It hangs during PCI fixups, and it hangs in v4.10-rc8, too.   
> > > 
> > > With debug patch below, I get
> > > 
> > > ...1d.7: PCI fixup... pass 2
> > > ...1d.7: PCI fixup... pass 3
> > > ...1d.7: PCI fixup... pass 3 done
> > > 
> > > ...followed by hang. So yes, it looks USB related.
> > > 
> > > (Sometimes it hangs with some kind backtrace involving secondary CPU
> > > startup, unfortunately useful info is off screen at that point).
> > 
> > Forgot to say, 1d.7 is EHCI controller.
> > 
> > 00:1d.7 USB controller: Intel Corporation NM10/ICH7 Family USB2 EHCI
> > Controller (rev 01)
> 
> Ok, I should have access soon to a EeePc 1015CX (which seem to have this 
> controller).
> I hope I'll be able to reproduce the issue there. If not, I'm sorry but I'll 
> have to
> burden you again :-)

Go through more mails. It is only reproducible after cold boot. .. so
I doubt it will be easy to reproduce on another machine.

Now... I do have serial port, and I even might have serial cable
somewhere, but Giving how sensitive it is, it is probably going to
go away with console on ttyS...

Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


RE:

2017-02-23 Thread Qin's Yanjun

How are you today and your family? I require your attention and honest
co-operation about some issues which i will really want to discuss with you
which.  Looking forward to read from you soon.  

Qin's


__

Sky Silk, http://aknet.kz

--
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: [Kernel] usbhid 3-2:1.1: couldn't find an input interrupt endpoint

2017-02-23 Thread Cristian
Hello,

lsusb -v; https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1667370

Regards,
--
Cristian




2017-02-23 12:40 GMT-03:00 Alan Stern :
> On Thu, 23 Feb 2017, Greg KH wrote:
>
>> On Tue, Feb 21, 2017 at 01:56:22PM -0300, Cristian wrote:
>> > 2017-02-21 2:04 GMT-03:00 Greg KH :
>> > > On Mon, Feb 20, 2017 at 03:28:37PM -0300, Cristian wrote:
>> > >> Hello,
>> > >>
>> > >> dmesg:
>> > >> [2.465370] usbhid 3-2:1.1: couldn't find an input interrupt endpoint
>> > >
>> > > And does this cause a problem?  Does the device not work?
>> > > What is the output of 'lsusb -v -s3:2' with the device plugged in?
>> >
>> >
>> > caravena@caravena-530U3C-530U4C:~$ lsusb -v -s3:2
>> >
>> > Bus 003 Device 002: ID 046d:c077 Logitech, Inc. M105 Optical Mouse
>> > Couldn't open device, some information will be missing
>> > Device Descriptor:
>> >   bLength18
>> >   bDescriptorType 1
>> >   bcdUSB   2.00
>> >   bDeviceClass0 (Defined at Interface level)
>> >   bDeviceSubClass 0
>> >   bDeviceProtocol 0
>> >   bMaxPacketSize0 8
>> >   idVendor   0x046d Logitech, Inc.
>> >   idProduct  0xc077 M105 Optical Mouse
>> >   bcdDevice   72.00
>> >   iManufacturer   1
>> >   iProduct2
>> >   iSerial 0
>> >   bNumConfigurations  1
>> >   Configuration Descriptor:
>> > bLength 9
>> > bDescriptorType 2
>> > wTotalLength   34
>> > bNumInterfaces  1
>> > bConfigurationValue 1
>> > iConfiguration  0
>> > bmAttributes 0xa0
>> >   (Bus Powered)
>> >   Remote Wakeup
>> > MaxPower  100mA
>> > Interface Descriptor:
>> >   bLength 9
>> >   bDescriptorType 4
>> >   bInterfaceNumber0
>> >   bAlternateSetting   0
>> >   bNumEndpoints   1
>> >   bInterfaceClass 3 Human Interface Device
>> >   bInterfaceSubClass  1 Boot Interface Subclass
>> >   bInterfaceProtocol  2 Mouse
>> >   iInterface  0
>> > HID Device Descriptor:
>> >   bLength 9
>> >   bDescriptorType33
>> >   bcdHID   1.11
>> >   bCountryCode0 Not supported
>> >   bNumDescriptors 1
>> >   bDescriptorType34 Report
>> >   wDescriptorLength  46
>> >  Report Descriptors:
>> >** UNAVAILABLE **
>> >   Endpoint Descriptor:
>> > bLength 7
>> > bDescriptorType 5
>> > bEndpointAddress 0x81  EP 1 IN
>> > bmAttributes3
>> >   Transfer TypeInterrupt
>> >   Synch Type   None
>> >   Usage Type   Data
>> > wMaxPacketSize 0x0004  1x 4 bytes
>> > bInterval  10
>>
>> Your device has an interrupt endpoint in there, odd.
>
> This is not the same device that the original message complained about.
> Compare the vendor and product ID numbers with the dmesg log:
>
> [2.452110] usb 3-2: New USB device found, idVendor=0458, idProduct=0186
> [2.452113] usb 3-2: New USB device strings: Mfr=4, Product=40, 
> SerialNumber=0
> [2.452115] usb 3-2: Product: Wired Mouse
> [2.452117] usb 3-2: Manufacturer: KYE SYSTEMS CORP.
> [2.458338] hidraw: raw HID events driver (C) Jiri Kosina
> [2.465370] usbhid 3-2:1.1: couldn't find an input interrupt endpoint
>
> In order to diagnose the problem, we need to see the "lsusb -v" output
> for the device that's causing the problem.
>
> Alan Stern
>
>> Does it still work properly?  Is this a regression from an older kernel
>> version?  If so, can you use 'git bisect' to track down the offending
>> commit?
>>
>> 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
>>
>



-- 
Cristian
caravena@caravena-530U3C-530U4C:~$ lsusb -v

Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Couldn't open device, some information will be missing
Device Descriptor:
  bLength18
  bDescriptorType 1
  bcdUSB   2.00
  bDeviceClass9 Hub
  bDeviceSubClass 0 Unused
  bDeviceProtocol 1 Single TT
  bMaxPacketSize064
  idVendor   0x8087 Intel Corp.
  idProduct  0x0024 Integrated Rate Matching Hub
  bcdDevice0.00
  iManufacturer   0 
  iProduct0 
  iSerial 0 
  bNumConfigurations  1
  Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength   25
bNumInterfaces  1
bConfigurationValue 1
iConfiguration

Re: v4.10-rc8 (-rc6) boot regression on Intel desktop, does not boot after cold boots, boots after reboot

2017-02-23 Thread Frederic Weisbecker
On Tue, Feb 14, 2017 at 08:27:43PM +0100, Pavel Machek wrote:
> On Tue 2017-02-14 18:59:56, Pavel Machek wrote:
> > Hi!
> > 
> > > > > > Hmm. I moved keyboard between USB ports, and now 4.10-rc6 no longer
> > > > > > boots. v4.6 works ok. Let me try with keyboard unplugged... no, I
> > > > > > could not get it to work. I believe v4.9 and some v4.10-rc's worked,
> > > > > > but I'll have to double check.
> > > > > 
> > > > > But all the kernel versions worked when the keyboard was plugged into
> > > > > its original USB port?
> > > > 
> > > > Aha. So it looks difference is probably in "where is keyboard plugged
> > > > in" but in "reboot" vs. "cold boot". I did not do a cold boot in quite
> > > > a while :-(.
> > > > 
> > > > Booting to grub, then hitting ctrl-alt-del is enough to make it work. 
> > > > Ouch.
> > > > 
> > > > It happens with current Linus' tree.
> > > 
> > > v4.10-rc6-feb3 : broken
> > > v4.9 : ok
> > > (v4.6 : ok)
> > 
> > Hmm. It hangs during PCI fixups, and it hangs in v4.10-rc8, too.   
> > 
> > With debug patch below, I get
> > 
> > ...1d.7: PCI fixup... pass 2
> > ...1d.7: PCI fixup... pass 3
> > ...1d.7: PCI fixup... pass 3 done
> > 
> > ...followed by hang. So yes, it looks USB related.
> > 
> > (Sometimes it hangs with some kind backtrace involving secondary CPU
> > startup, unfortunately useful info is off screen at that point).
> 
> Forgot to say, 1d.7 is EHCI controller.
> 
> 00:1d.7 USB controller: Intel Corporation NM10/ICH7 Family USB2 EHCI
> Controller (rev 01)

Ok, I should have access soon to a EeePc 1015CX (which seem to have this 
controller).
I hope I'll be able to reproduce the issue there. If not, I'm sorry but I'll 
have to
burden you 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


Re: [RFC PATCH] xhci: Use Cached ring during endpoint ring allocation

2017-02-23 Thread Mathias Nyman

On 22.02.2017 17:05, Anurag Kumar Vulisha wrote:

Currently during endpoint initialization, a new endpoint ring is alloacte
using xhci_ring_alloc(), if this function fails to allocate ring a cached
ring(if available) is assigned to endpoint ring.
This patch modifies the code that during endpoint initialization, if cached
ring is available it is assigned to the endpoint ring. If cached rings are
not available then xhci_ring_alloc() is called to allocate a new ring.
Doing so will avoid unncessary memory allocations if cached ring is already
available for use. This also fixes endpoint "Ring expansion failed" error
which occurs due to insufficient memory during ring expansion.

Signed-off-by: Anurag Kumar Vulisha 


Thanks for bringing this to my attention.
Your approach certainly makes more sense than the current way.

I need to check history why this type of ring cache was created in the first 
place.
It's possible that the whole ring cache is not really useful anymore

-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


Re: [Kernel] usbhid 3-2:1.1: couldn't find an input interrupt endpoint

2017-02-23 Thread Alan Stern
On Thu, 23 Feb 2017, Greg KH wrote:

> On Tue, Feb 21, 2017 at 01:56:22PM -0300, Cristian wrote:
> > 2017-02-21 2:04 GMT-03:00 Greg KH :
> > > On Mon, Feb 20, 2017 at 03:28:37PM -0300, Cristian wrote:
> > >> Hello,
> > >>
> > >> dmesg:
> > >> [2.465370] usbhid 3-2:1.1: couldn't find an input interrupt endpoint
> > >
> > > And does this cause a problem?  Does the device not work?
> > > What is the output of 'lsusb -v -s3:2' with the device plugged in?
> > 
> > 
> > caravena@caravena-530U3C-530U4C:~$ lsusb -v -s3:2
> > 
> > Bus 003 Device 002: ID 046d:c077 Logitech, Inc. M105 Optical Mouse
> > Couldn't open device, some information will be missing
> > Device Descriptor:
> >   bLength18
> >   bDescriptorType 1
> >   bcdUSB   2.00
> >   bDeviceClass0 (Defined at Interface level)
> >   bDeviceSubClass 0
> >   bDeviceProtocol 0
> >   bMaxPacketSize0 8
> >   idVendor   0x046d Logitech, Inc.
> >   idProduct  0xc077 M105 Optical Mouse
> >   bcdDevice   72.00
> >   iManufacturer   1
> >   iProduct2
> >   iSerial 0
> >   bNumConfigurations  1
> >   Configuration Descriptor:
> > bLength 9
> > bDescriptorType 2
> > wTotalLength   34
> > bNumInterfaces  1
> > bConfigurationValue 1
> > iConfiguration  0
> > bmAttributes 0xa0
> >   (Bus Powered)
> >   Remote Wakeup
> > MaxPower  100mA
> > Interface Descriptor:
> >   bLength 9
> >   bDescriptorType 4
> >   bInterfaceNumber0
> >   bAlternateSetting   0
> >   bNumEndpoints   1
> >   bInterfaceClass 3 Human Interface Device
> >   bInterfaceSubClass  1 Boot Interface Subclass
> >   bInterfaceProtocol  2 Mouse
> >   iInterface  0
> > HID Device Descriptor:
> >   bLength 9
> >   bDescriptorType33
> >   bcdHID   1.11
> >   bCountryCode0 Not supported
> >   bNumDescriptors 1
> >   bDescriptorType34 Report
> >   wDescriptorLength  46
> >  Report Descriptors:
> >** UNAVAILABLE **
> >   Endpoint Descriptor:
> > bLength 7
> > bDescriptorType 5
> > bEndpointAddress 0x81  EP 1 IN
> > bmAttributes3
> >   Transfer TypeInterrupt
> >   Synch Type   None
> >   Usage Type   Data
> > wMaxPacketSize 0x0004  1x 4 bytes
> > bInterval  10
> 
> Your device has an interrupt endpoint in there, odd.

This is not the same device that the original message complained about.  
Compare the vendor and product ID numbers with the dmesg log:

[2.452110] usb 3-2: New USB device found, idVendor=0458, idProduct=0186
[2.452113] usb 3-2: New USB device strings: Mfr=4, Product=40, 
SerialNumber=0
[2.452115] usb 3-2: Product: Wired Mouse
[2.452117] usb 3-2: Manufacturer: KYE SYSTEMS CORP.
[2.458338] hidraw: raw HID events driver (C) Jiri Kosina
[2.465370] usbhid 3-2:1.1: couldn't find an input interrupt endpoint

In order to diagnose the problem, we need to see the "lsusb -v" output 
for the device that's causing the problem.

Alan Stern

> Does it still work properly?  Is this a regression from an older kernel
> version?  If so, can you use 'git bisect' to track down the offending
> commit?
> 
> 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
> 

--
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: Advanced Format SAT devices show incorrect physical block size

2017-02-23 Thread Pali Rohár
On Monday 30 January 2017 18:43:12 Pali Rohár wrote:
> On Monday 30 January 2017 17:17:03 Alan Stern wrote:
> > On Sun, 29 Jan 2017, Pali Rohár wrote:
> > > On Wednesday 11 January 2017 16:23:29 Alan Stern wrote:
> > > > On Tue, 10 Jan 2017, James Bottomley wrote:
> > > > > On Tue, 2017-01-10 at 16:00 -0500, Alan Stern wrote:
> > > > > > In theory, I suppose we could change the kernel so that it
> > > > > > would default to READ CAPACITY(16) for devices that report a
> > > > > > SCSI level
> > > > > > 
> > > > > > >= 3, or something along those lines.  In general we hesitate
> > > > > > >to
> > > > > > 
> > > > > > make changes of this sort, because they almost always end up
> > > > > > breaking _some_ devices -- and if that happens then the
> > > > > > change is reverted, with no exceptions.  Linus has a very
> > > > > > strict rule about not breaking working systems.
> > > > > 
> > > > > You shouldn't have to change anything: it already does
> > > > > (otherwise how else would we detect physical exponent for
> > > > > proper SCSI devices) see sd.c:sd_try_rc16_first().  It always
> > > > > returns false for USB because you set sdev->try_rc_10_first
> > > > 
> > > > In fact, this approach probably won't work.  See Bugzilla entries
> > > > #43265 and #43391.  The devices in those reports claimed to be
> > > > ANSI level 4, but they failed anyway.
> > > 
> > > Seems those devices return capacity 0x7F0001 or
> > > 0xFF0001 Maybe there is some error pattern?
> > 
> > As far as I can tell, they both reported 0xFF0001.  That's a
> > pattern -- unless somebody really does have a storage device that
> > large (18 exabytes).  For the time being, perhaps we can ignore this
> > possibility.
> > 
> > > > If you guys want to try the quirk flag, you can apply the patch
> > > > below. Then set the usb-storage module parameter
> > > > quirks=::k where  and  are the Vendor and
> > > > Product ID codes for your device (as 4 hex digits).
> > > > 
> > > > In the long run, however, this is not a viable approach.  We'd be
> > > > better off with an explicit blacklist.
> > > 
> > > Ok, so what are next steps? I think that explicit blacklist would
> > > be needed if "bad" devices is less.
> > > 
> > > How many bug reports were there?
> > 
> > I don't know.
> > 
> > Anyway, please try out the patch below.  I don't know if it will be
> > acceptable to the SCSI maintainers, but we should at least make sure
> > it fixes your problem before submitting it.
> 
> I'm not original reporter of this problem.
> 
> Dainius, can you test it?

Just want to remind this patch so it will not be forgotten...

> > Alan Stern
> > 
> > 
> > 
> > 
> > Index: usb-4.x/drivers/scsi/sd.c
> > ===
> > --- usb-4.x.orig/drivers/scsi/sd.c
> > +++ usb-4.x/drivers/scsi/sd.c
> > @@ -2157,6 +2157,13 @@ static int read_capacity_16(struct scsi_
> > return -ENODEV;
> > }
> > 
> > +   /* Some buggy devices report an impossibly large size */
> > +   if (lba >= (1ULL << 54)) {
> > +   sd_printk(KERN_WARNING, sdkp, "Read Capacity(16) returned 
> > excessively large value: %llu", lba);
> > +   sdkp->capacity = 0;
> > +   return -EINVAL;
> > +   }
> > +
> > if ((sizeof(sdkp->capacity) == 4) && (lba >= 0xULL)) {
> > sd_printk(KERN_ERR, sdkp, "Too big for this kernel. Use a "
> > "kernel compiled with support for large block "
> > Index: usb-4.x/drivers/usb/storage/scsiglue.c
> > ===
> > --- usb-4.x.orig/drivers/usb/storage/scsiglue.c
> > +++ usb-4.x/drivers/usb/storage/scsiglue.c
> > @@ -247,8 +247,11 @@ static int slave_configure(struct scsi_d
> >  * Tell the SCSI layer to try READ_CAPACITY_10 first.
> >  * However some USB 3.0 drive enclosures return capacity
> >  * modulo 2TB. Those must use READ_CAPACITY_16
> > +*
> > +* Assume SPC3 or later devices can handle READ_CAPACITY_16.
> >  */
> > -   if (!(us->fflags & US_FL_NEEDS_CAP16))
> > +   if (sdev->scsi_level <= SCSI_SPC_2 &&
> > +   !(us->fflags & US_FL_NEEDS_CAP16))
> > sdev->try_rc_10_first = 1;
> > 
> > /* assume SPC3 or latter devices support sense size > 18 */
> 

-- 
Pali Rohár
pali.ro...@gmail.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: [Kernel] usbhid 3-2:1.1: couldn't find an input interrupt endpoint

2017-02-23 Thread Greg KH
On Tue, Feb 21, 2017 at 01:56:22PM -0300, Cristian wrote:
> 2017-02-21 2:04 GMT-03:00 Greg KH :
> > On Mon, Feb 20, 2017 at 03:28:37PM -0300, Cristian wrote:
> >> Hello,
> >>
> >> dmesg:
> >> [2.465370] usbhid 3-2:1.1: couldn't find an input interrupt endpoint
> >
> > And does this cause a problem?  Does the device not work?
> > What is the output of 'lsusb -v -s3:2' with the device plugged in?
> 
> 
> caravena@caravena-530U3C-530U4C:~$ lsusb -v -s3:2
> 
> Bus 003 Device 002: ID 046d:c077 Logitech, Inc. M105 Optical Mouse
> Couldn't open device, some information will be missing
> Device Descriptor:
>   bLength18
>   bDescriptorType 1
>   bcdUSB   2.00
>   bDeviceClass0 (Defined at Interface level)
>   bDeviceSubClass 0
>   bDeviceProtocol 0
>   bMaxPacketSize0 8
>   idVendor   0x046d Logitech, Inc.
>   idProduct  0xc077 M105 Optical Mouse
>   bcdDevice   72.00
>   iManufacturer   1
>   iProduct2
>   iSerial 0
>   bNumConfigurations  1
>   Configuration Descriptor:
> bLength 9
> bDescriptorType 2
> wTotalLength   34
> bNumInterfaces  1
> bConfigurationValue 1
> iConfiguration  0
> bmAttributes 0xa0
>   (Bus Powered)
>   Remote Wakeup
> MaxPower  100mA
> Interface Descriptor:
>   bLength 9
>   bDescriptorType 4
>   bInterfaceNumber0
>   bAlternateSetting   0
>   bNumEndpoints   1
>   bInterfaceClass 3 Human Interface Device
>   bInterfaceSubClass  1 Boot Interface Subclass
>   bInterfaceProtocol  2 Mouse
>   iInterface  0
> HID Device Descriptor:
>   bLength 9
>   bDescriptorType33
>   bcdHID   1.11
>   bCountryCode0 Not supported
>   bNumDescriptors 1
>   bDescriptorType34 Report
>   wDescriptorLength  46
>  Report Descriptors:
>** UNAVAILABLE **
>   Endpoint Descriptor:
> bLength 7
> bDescriptorType 5
> bEndpointAddress 0x81  EP 1 IN
> bmAttributes3
>   Transfer TypeInterrupt
>   Synch Type   None
>   Usage Type   Data
> wMaxPacketSize 0x0004  1x 4 bytes
> bInterval  10

Your device has an interrupt endpoint in there, odd.

Does it still work properly?  Is this a regression from an older kernel
version?  If so, can you use 'git bisect' to track down the offending
commit?

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 v2 4/4] usb: dwc3: Workaround for super-speed host on dra7 in dual-role mode

2017-02-23 Thread Vivek Gautam



On 02/16/2017 06:36 PM, Roger Quadros wrote:

dra7 OTG core limits the host controller to USB2.0 (high-speed) mode
when we're operating in dual-role.

We work around that by bypassing the OTG core and reading the
extcon framework directly for ID/VBUS events.

Signed-off-by: Roger Quadros 
---
  Documentation/devicetree/bindings/usb/dwc3.txt |   2 +
  drivers/usb/dwc3/core.c| 169 -
  drivers/usb/dwc3/core.h|   5 +
  3 files changed, 170 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
b/Documentation/devicetree/bindings/usb/dwc3.txt
index e3e6983..9955c0d 100644
--- a/Documentation/devicetree/bindings/usb/dwc3.txt
+++ b/Documentation/devicetree/bindings/usb/dwc3.txt
@@ -53,6 +53,8 @@ Optional properties:
   - snps,quirk-frame-length-adjustment: Value for GFLADJ_30MHZ field of GFLADJ
register for post-silicon frame length adjustment when the
fladj_30mhz_sdbnd signal is invalid or incorrect.
+ - extcon: phandle to the USB connector extcon device. If present, extcon
+   device will be used to get USB cable events instead of OTG controller.
  
   -  tx-fifo-resize: determines if the FIFO *has* to be reallocated.
  
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c

index 619fa7c..b02d911 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c


[snip]


@@ -1587,6 +1727,14 @@ static int dwc3_probe(struct platform_device *pdev)
  
  	dwc3_get_properties(dwc);
  
+	if (dev->of_node) {

+   if (of_property_read_bool(dev->of_node, "extcon"))
+   dwc->edev = extcon_get_edev_by_phandle(dev, 0);


Don't we want separate edev's for vbus and id ?
One can have separate pins connected to them and in that case
we can't get the events out of one pin only.


+
+   if (IS_ERR(dwc->edev))
+   return PTR_ERR(dwc->edev);


 Took me a while to get to this. :)

if (IS_ERR(dwc->edev)) {
   ret = PTR_ERR(dwc->edev);
   goto err0;
}

We want to reset the res->start back to its original offset.

Testing this series currently. Will get back with my results.


Regards
Vivek

--
The 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


[PATCH v2 05/14] usb: dwc2: core: Add hibernated flag

2017-02-23 Thread Vardan Mikayelyan
True if core is hibernated.

Signed-off-by: Vardan Mikayelyan 
Signed-off-by: John Youn 
---
 drivers/usb/dwc2/core.h | 2 ++
 drivers/usb/dwc2/platform.c | 1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 60ad2e6..d84d0ce 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -779,6 +779,7 @@ struct dwc2_hregs_backup {
  * @hcd_enabledHost mode sub-driver initialization indicator.
  * @gadget_enabled Peripheral mode sub-driver initialization indicator.
  * @ll_hw_enabled  Status of low-level hardware resources.
+ * @hibernated:True if core is hibernated
  * @phy:The otg phy transceiver structure for phy control.
  * @uphy:   The otg phy transceiver structure for old USB phy
  *  control.
@@ -916,6 +917,7 @@ struct dwc2_hsotg {
unsigned int hcd_enabled:1;
unsigned int gadget_enabled:1;
unsigned int ll_hw_enabled:1;
+   unsigned int hibernated:1;
 
struct phy *phy;
struct usb_phy *uphy;
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index db98463..c4e365a 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -462,6 +462,7 @@ static int dwc2_driver_probe(struct platform_device *dev)
}
 
platform_set_drvdata(dev, hsotg);
+   hsotg->hibernated = 0;
 
dwc2_debugfs_init(hsotg);
 
-- 
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 v2 10/14] usb: dwc2: Add dwc2_enter_hibernation(), dwc2_exit_hibernation()

2017-02-23 Thread Vardan Mikayelyan
These are wrapper functions which are calling device or host
enter/exit hibernation functions.

Signed-off-by: Vardan Mikayelyan 
Signed-off-by: John Youn 
---
 drivers/usb/dwc2/core.c | 38 ++
 drivers/usb/dwc2/core.h |  3 +++
 2 files changed, 41 insertions(+)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index a37dfc2..2c90d8e 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -446,6 +446,44 @@ static bool dwc2_iddig_filter_enabled(struct dwc2_hsotg 
*hsotg)
 }
 
 /*
+ * dwc2_enter_hibernation() - Common function to enter hibernation.
+ *
+ * @hsotg: Programming view of the DWC_otg controller
+ * @is_host: True if core is in host mode.
+ *
+ * Return: 0 if successful, negative error code otherwise
+ */
+int dwc2_enter_hibernation(struct dwc2_hsotg *hsotg, int is_host)
+{
+   if (hsotg->params.power_down != DWC2_POWER_DOWN_PARAM_HIBERNATION)
+   return -ENOTSUPP;
+
+   if (is_host)
+   return dwc2_host_enter_hibernation(hsotg);
+   else
+   return dwc2_gadget_enter_hibernation(hsotg);
+}
+
+/*
+ * dwc2_exit_hibernation() - Common function to exit from hibernation.
+ *
+ * @hsotg: Programming view of the DWC_otg controller
+ * @rem_wakeup: Remote-wakeup, enabled in case of remote-wakeup.
+ * @reset: Enabled in case of restore with reset.
+ * @is_host: True if core is in host mode.
+ *
+ * Return: 0 if successful, negative error code otherwise
+ */
+int dwc2_exit_hibernation(struct dwc2_hsotg *hsotg, int rem_wakeup,
+ int reset, int is_host)
+{
+   if (is_host)
+   return dwc2_host_exit_hibernation(hsotg, rem_wakeup, reset);
+   else
+   return dwc2_gadget_exit_hibernation(hsotg, rem_wakeup, reset);
+}
+
+/*
  * Do core a soft reset of the core.  Be careful with this because it
  * resets all the internal state machines of the core.
  */
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 9d17f4a..a3561e1 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -1112,6 +1112,9 @@ static inline bool dwc2_is_hs_iot(struct dwc2_hsotg 
*hsotg)
 int dwc2_core_reset(struct dwc2_hsotg *hsotg, bool skip_wait);
 int dwc2_enter_partial_power_down(struct dwc2_hsotg *hsotg);
 int dwc2_exit_partial_power_down(struct dwc2_hsotg *hsotg, bool restore);
+int dwc2_enter_hibernation(struct dwc2_hsotg *hsotg, int is_host);
+int dwc2_exit_hibernation(struct dwc2_hsotg *hsotg, int rem_wakeup,
+ int reset, int is_host);
 
 void dwc2_force_mode(struct dwc2_hsotg *hsotg, bool host);
 void dwc2_force_dr_mode(struct dwc2_hsotg *hsotg);
-- 
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 v2 09/14] usb: dwc2: Add host/device hibernation functions

2017-02-23 Thread Vardan Mikayelyan
Add host/device hibernation functions which must be wrapped
by core's  dwc2_enter_hibernation()/dwc2_exit_hibernation()
functions.

Make dwc2_backup_global_registers dwc2_restore_global_register
non-static to use them in both host/gadget sides.

Added function names:
dwc2_gadget_enter_hibernation()
dwc2_gadget_exit_hibernation()
dwc2_host_enter_hibernation()
dwc2_host_exit_hibernation()

Signed-off-by: Vardan Mikayelyan 
Signed-off-by: John Youn 
---
 drivers/usb/dwc2/core.c   |   4 +-
 drivers/usb/dwc2/core.h   |  18 
 drivers/usb/dwc2/gadget.c | 196 ++
 drivers/usb/dwc2/hcd.c| 233 ++
 4 files changed, 449 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index f478cdd..a37dfc2 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -63,7 +63,7 @@
  *
  * @hsotg: Programming view of the DWC_otg controller
  */
-static int dwc2_backup_global_registers(struct dwc2_hsotg *hsotg)
+int dwc2_backup_global_registers(struct dwc2_hsotg *hsotg)
 {
struct dwc2_gregs_backup *gr;
 
@@ -94,7 +94,7 @@ static int dwc2_backup_global_registers(struct dwc2_hsotg 
*hsotg)
  *
  * @hsotg: Programming view of the DWC_otg controller
  */
-static int dwc2_restore_global_registers(struct dwc2_hsotg *hsotg)
+int dwc2_restore_global_registers(struct dwc2_hsotg *hsotg)
 {
struct dwc2_gregs_backup *gr;
 
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 950915b..9d17f4a 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -1131,6 +1131,8 @@ static inline bool dwc2_is_hs_iot(struct dwc2_hsotg 
*hsotg)
 void dwc2_disable_global_interrupts(struct dwc2_hsotg *hcd);
 
 void dwc2_hib_restore_common(struct dwc2_hsotg *hsotg, int rem_wakeup);
+int dwc2_backup_global_registers(struct dwc2_hsotg *hsotg);
+int dwc2_restore_global_registers(struct dwc2_hsotg *hsotg);
 
 /* This function should be called on every hardware interrupt. */
 irqreturn_t dwc2_handle_common_intr(int irq, void *dev);
@@ -1193,6 +1195,9 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg 
*dwc2,
 #define dwc2_is_device_connected(hsotg) (hsotg->connected)
 int dwc2_backup_device_registers(struct dwc2_hsotg *hsotg);
 int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg, int remote_wakeup);
+int dwc2_gadget_enter_hibernation(struct dwc2_hsotg *hsotg);
+int dwc2_gadget_exit_hibernation(struct dwc2_hsotg *hsotg,
+int rem_wakeup, int reset);
 int dwc2_hsotg_tx_fifo_count(struct dwc2_hsotg *hsotg);
 int dwc2_hsotg_tx_fifo_total_depth(struct dwc2_hsotg *hsotg);
 int dwc2_hsotg_tx_fifo_average_depth(struct dwc2_hsotg *hsotg);
@@ -1218,6 +1223,11 @@ static inline int dwc2_backup_device_registers(struct 
dwc2_hsotg *hsotg)
 static inline int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg,
int remote_wakeup)
 { return 0; }
+static inline int dwc2_gadget_enter_hibernation(struct dwc2_hsotg *hsotg)
+{ return 0; }
+static inline int dwc2_gadget_exit_hibernation(struct dwc2_hsotg *hsotg,
+  int rem_wakeup, int reset)
+{ return 0; }
 static inline int dwc2_hsotg_tx_fifo_count(struct dwc2_hsotg *hsotg)
 { return 0; }
 static inline int dwc2_hsotg_tx_fifo_total_depth(struct dwc2_hsotg *hsotg)
@@ -1234,6 +1244,9 @@ static inline int dwc2_hsotg_tx_fifo_average_depth(struct 
dwc2_hsotg *hsotg)
 void dwc2_hcd_start(struct dwc2_hsotg *hsotg);
 int dwc2_backup_host_registers(struct dwc2_hsotg *hsotg);
 int dwc2_restore_host_registers(struct dwc2_hsotg *hsotg);
+int dwc2_host_enter_hibernation(struct dwc2_hsotg *hsotg);
+int dwc2_host_exit_hibernation(struct dwc2_hsotg *hsotg,
+  int rem_wakeup, int reset);
 #else
 static inline int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg)
 { return 0; }
@@ -1250,6 +1263,11 @@ static inline int dwc2_backup_host_registers(struct 
dwc2_hsotg *hsotg)
 { return 0; }
 static inline int dwc2_restore_host_registers(struct dwc2_hsotg *hsotg)
 { return 0; }
+static inline int dwc2_host_enter_hibernation(struct dwc2_hsotg *hsotg)
+{ return 0; }
+static inline int dwc2_host_exit_hibernation(struct dwc2_hsotg *hsotg,
+int rem_wakeup, int reset)
+{ return 0; }
 
 #endif
 
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index fd274a8..e82e1db 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -4870,3 +4870,199 @@ int dwc2_restore_device_registers(struct dwc2_hsotg 
*hsotg, int remote_wakeup)
 
return 0;
 }
+
+/**
+ * dwc2_gadget_enter_hibernation() - Put controller in Hibernation.
+ *
+ * @hsotg: Programming view of the DWC_otg controller
+ *
+ * Return non-zero if failed to enter to hibernation.
+ */
+int dwc2_gadget_enter_hibernation(struct dwc2_hsotg *hsotg)
+{
+   u32 pcgcctl;
+   u32 gpwrdn;
+

[PATCH v2 06/14] usb: dwc2: gadget: Add remote_wakeup_allowed flag

2017-02-23 Thread Vardan Mikayelyan
It will be set once corresponding set_feature command comes.

True if device is allowed to wake-up host by remote-wakeup
signalling.

This is preparation for remote wake-up support implementation,
it will not be implemented until gadget stack provide interface
for bringing remote wake-up signalling.

Signed-off-by: Vardan Mikayelyan 
Signed-off-by: John Youn 
---
 drivers/usb/dwc2/core.h   | 3 +++
 drivers/usb/dwc2/gadget.c | 6 ++
 2 files changed, 9 insertions(+)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index d84d0ce..ace383f 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -897,6 +897,8 @@ struct dwc2_hregs_backup {
  * @ctrl_req:   Request for EP0 control packets.
  * @ep0_state:  EP0 control transfers state
  * @test_mode:  USB test mode requested by the host
+ * @remote_wakeup_allowed: True if device is allowed to wake-up host by
+ *  remote-wakeup signalling
  * @setup_desc_dma:EP0 setup stage desc chain DMA address
  * @setup_desc:EP0 setup stage desc chain pointer
  * @ctrl_in_desc_dma:  EP0 IN data phase desc chain DMA address
@@ -1061,6 +1063,7 @@ struct dwc2_hsotg {
struct usb_gadget gadget;
unsigned int enabled:1;
unsigned int connected:1;
+   unsigned int remote_wakeup_allowed:1;
struct dwc2_hsotg_ep *eps_in[MAX_EPS_CHANNELS];
struct dwc2_hsotg_ep *eps_out[MAX_EPS_CHANNELS];
 #endif /* CONFIG_USB_DWC2_PERIPHERAL || CONFIG_USB_DWC2_DUAL_ROLE */
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 3b082ed..fd274a8 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -1665,6 +1665,10 @@ static int dwc2_hsotg_process_req_feature(struct 
dwc2_hsotg *hsotg,
switch (recip) {
case USB_RECIP_DEVICE:
switch (wValue) {
+   case USB_DEVICE_REMOTE_WAKEUP:
+   hsotg->remote_wakeup_allowed = 1;
+   break;
+
case USB_DEVICE_TEST_MODE:
if ((wIndex & 0xff) != 0)
return -EINVAL;
@@ -4626,6 +4630,8 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg)
hsotg->gadget.max_speed = USB_SPEED_HIGH;
hsotg->gadget.ops = &dwc2_hsotg_gadget_ops;
hsotg->gadget.name = dev_name(dev);
+   hsotg->remote_wakeup_allowed = 0;
+
if (hsotg->dr_mode == USB_DR_MODE_OTG)
hsotg->gadget.is_otg = 1;
else if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL)
-- 
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 v2 08/14] usb: dwc2: Add helper functions for restore routine

2017-02-23 Thread Vardan Mikayelyan
Add common (host/device) helper functions, which will be called while
exiting from hibernation, from both sides.

dwc2_restore_essential_regs()
dwc2_hib_restore_common()

Signed-off-by: Vardan Mikayelyan 
Signed-off-by: John Youn 
---
 drivers/usb/dwc2/core.c | 136 
 drivers/usb/dwc2/core.h |   2 +
 2 files changed, 138 insertions(+)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index 0e61511..f478cdd 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -239,6 +239,142 @@ int dwc2_enter_partial_power_down(struct dwc2_hsotg 
*hsotg)
 }
 
 /**
+ * dwc2_restore_essential_regs() - Restore essiential regs of core.
+ *
+ * @hsotg: Programming view of the DWC_otg controller
+ * @rmode: Restore mode, enabled in case of remote-wakeup.
+ */
+static void dwc2_restore_essential_regs(struct dwc2_hsotg *hsotg, int rmode)
+{
+   u32 pcgcctl;
+   struct dwc2_gregs_backup *gr;
+   struct dwc2_dregs_backup *dr;
+   struct dwc2_hregs_backup *hr;
+   int is_host = dwc2_is_host_mode(hsotg);
+
+   gr = &hsotg->gr_backup;
+   dr = &hsotg->dr_backup;
+   hr = &hsotg->hr_backup;
+
+   dev_dbg(hsotg->dev, "%s: restoring essential regs\n", __func__);
+
+   /* Load restore values for [31:14] bits */
+   pcgcctl = (gr->pcgcctl & 0xc000) | 0x0002;
+   dwc2_writel(pcgcctl, hsotg->regs + PCGCTL);
+
+   /* Umnask global Interrupt in GAHBCFG and restore it */
+   dwc2_writel(gr->gahbcfg | GAHBCFG_GLBL_INTR_EN, hsotg->regs + GAHBCFG);
+
+   /* Clear all pending interupts */
+   dwc2_writel(0x, hsotg->regs + GINTSTS);
+
+   /* Unmask restore done interrupt */
+   dwc2_writel(GINTSTS_RESTOREDONE, hsotg->regs + GINTMSK);
+
+   /* Restore GUSBCFG and HCFG/DCFG */
+   dwc2_writel(gr->gusbcfg, hsotg->regs + GUSBCFG);
+
+   if (is_host) {
+   dwc2_writel(hr->hcfg, hsotg->regs + HCFG);
+   if (rmode)
+   pcgcctl |= 0x200;
+   dwc2_writel(pcgcctl, hsotg->regs + PCGCTL);
+   udelay(10);
+
+   pcgcctl = (gr->pcgcctl & 0xc000) | 0x0002;
+   pcgcctl |= PCGCTL_ESS_REG_RESTORED;
+   dwc2_writel(pcgcctl, hsotg->regs + PCGCTL);
+   udelay(10);
+   } else {
+   dwc2_writel(dr->dcfg, hsotg->regs + DCFG);
+   if (!rmode)
+   pcgcctl |= 0x208;
+   dwc2_writel(pcgcctl, hsotg->regs + PCGCTL);
+   udelay(10);
+
+   pcgcctl |= PCGCTL_ESS_REG_RESTORED;
+   dwc2_writel(pcgcctl, hsotg->regs + PCGCTL);
+   udelay(10);
+   }
+}
+
+/**
+ * dwc2_hib_restore_common() - Common part of restore routine.
+ *
+ * @hsotg: Programming view of the DWC_otg controller
+ * @rem_wakeup: Remote-wakeup, enabled in case of remote-wakeup.
+ */
+void dwc2_hib_restore_common(struct dwc2_hsotg *hsotg, int rem_wakeup)
+{
+   u32 gpwrdn;
+   u32 gintsts;
+   int timeout;
+   int is_host = dwc2_is_host_mode(hsotg);
+
+   /* Switch-on voltage to the core */
+   gpwrdn = dwc2_readl(hsotg->regs + GPWRDN);
+   gpwrdn &= ~GPWRDN_PWRDNSWTCH;
+   dwc2_writel(gpwrdn, hsotg->regs + GPWRDN);
+   udelay(10);
+
+   /* Reset core */
+   gpwrdn = dwc2_readl(hsotg->regs + GPWRDN);
+   gpwrdn &= ~GPWRDN_PWRDNRSTN;
+   dwc2_writel(gpwrdn, hsotg->regs + GPWRDN);
+   udelay(10);
+
+   /* Enable restore from PMU */
+   gpwrdn = dwc2_readl(hsotg->regs + GPWRDN);
+   gpwrdn |= GPWRDN_RESTORE;
+   dwc2_writel(gpwrdn, hsotg->regs + GPWRDN);
+   udelay(10);
+
+   /* Disable Power Down Clamp */
+   gpwrdn = dwc2_readl(hsotg->regs + GPWRDN);
+   gpwrdn &= ~GPWRDN_PWRDNCLMP;
+   dwc2_writel(gpwrdn, hsotg->regs + GPWRDN);
+   udelay(10);
+
+   if (!is_host && rem_wakeup)
+   udelay(70);
+
+   /* Deassert reset core */
+   gpwrdn = dwc2_readl(hsotg->regs + GPWRDN);
+   gpwrdn |= GPWRDN_PWRDNRSTN;
+   dwc2_writel(gpwrdn, hsotg->regs + GPWRDN);
+   udelay(10);
+
+   /* Disable PMU interrupt */
+   gpwrdn = dwc2_readl(hsotg->regs + GPWRDN);
+   gpwrdn &= ~GPWRDN_PMUINTSEL;
+   dwc2_writel(gpwrdn, hsotg->regs + GPWRDN);
+
+   /* Set Restore Essential Regs bit in PCGCCTL register */
+   dwc2_restore_essential_regs(hsotg, rem_wakeup);
+
+   /*
+* Wait For Restore_done Interrupt. This mechanism of polling the
+* interrupt is introduced to avoid any possible race conditions
+*/
+   timeout = 2000;
+   do {
+   gintsts = dwc2_readl(hsotg->regs + GINTSTS);
+   if (!(gintsts & GINTSTS_RESTOREDONE)) {
+   udelay(10);
+   continue;
+   }
+   dwc2_writel(GINTSTS_RESTOREDONE, hsotg->regs + GINTSTS);
+   dev_dbg(hsotg->dev,
+ 

[PATCH v2 07/14] usb: dwc2: Changes in registers backup/restore functions

2017-02-23 Thread Vardan Mikayelyan
Move hptxfsiz to host register's backup/restore functions, not
needed to have it in global register's backup/restore functions.

Add backup for glpmcfg, and read/write for gi2cctl and pcgcctl.
As requires programming guide.

Affected functions:
dwc2_backup_host_registers()
dwc2_restore_host_registers()
dwc2_backup_global_registers()
dwc2_restore_global_registers()

Signed-off-by: Vardan Mikayelyan 
Signed-off-by: John Youn 
---
 drivers/usb/dwc2/core.c | 8 ++--
 drivers/usb/dwc2/core.h | 6 --
 drivers/usb/dwc2/hcd.c  | 2 ++
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index 185d24c..0e61511 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -78,8 +78,10 @@ static int dwc2_backup_global_registers(struct dwc2_hsotg 
*hsotg)
gr->gusbcfg = dwc2_readl(hsotg->regs + GUSBCFG);
gr->grxfsiz = dwc2_readl(hsotg->regs + GRXFSIZ);
gr->gnptxfsiz = dwc2_readl(hsotg->regs + GNPTXFSIZ);
-   gr->hptxfsiz = dwc2_readl(hsotg->regs + HPTXFSIZ);
gr->gdfifocfg = dwc2_readl(hsotg->regs + GDFIFOCFG);
+   gr->glpmcfg = dwc2_readl(hsotg->regs + GLPMCFG);
+   gr->gi2cctl = dwc2_readl(hsotg->regs + GI2CCTL);
+   gr->pcgcctl = dwc2_readl(hsotg->regs + PCGCTL);
 
gr->valid = true;
return 0;
@@ -114,8 +116,10 @@ static int dwc2_restore_global_registers(struct dwc2_hsotg 
*hsotg)
dwc2_writel(gr->gahbcfg, hsotg->regs + GAHBCFG);
dwc2_writel(gr->grxfsiz, hsotg->regs + GRXFSIZ);
dwc2_writel(gr->gnptxfsiz, hsotg->regs + GNPTXFSIZ);
-   dwc2_writel(gr->hptxfsiz, hsotg->regs + HPTXFSIZ);
dwc2_writel(gr->gdfifocfg, hsotg->regs + GDFIFOCFG);
+   dwc2_writel(gr->glpmcfg, hsotg->regs + GLPMCFG);
+   dwc2_writel(gr->pcgcctl, hsotg->regs + PCGCTL);
+   dwc2_writel(gr->gi2cctl, hsotg->regs + GI2CCTL);
 
return 0;
 }
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index ace383f..31ebdfa 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -610,7 +610,7 @@ struct dwc2_hw_params {
  * @grxfsiz:   Backup of GRXFSIZ register
  * @gnptxfsiz: Backup of GNPTXFSIZ register
  * @gi2cctl:   Backup of GI2CCTL register
- * @hptxfsiz:  Backup of HPTXFSIZ register
+ * @glpmcfg:   Backup of GLPMCFG register
  * @gdfifocfg: Backup of GDFIFOCFG register
  * @gpwrdn:Backup of GPWRDN register
  */
@@ -622,7 +622,7 @@ struct dwc2_gregs_backup {
u32 grxfsiz;
u32 gnptxfsiz;
u32 gi2cctl;
-   u32 hptxfsiz;
+   u32 glpmcfg;
u32 pcgcctl;
u32 gdfifocfg;
u32 gpwrdn;
@@ -669,6 +669,7 @@ struct dwc2_dregs_backup {
  * @hcintmsk:  Backup of HCINTMSK register
  * @hptr0: Backup of HPTR0 register
  * @hfir:  Backup of HFIR register
+ * @hptxfsiz:  Backup of HPTXFSIZ register
  */
 struct dwc2_hregs_backup {
u32 hcfg;
@@ -676,6 +677,7 @@ struct dwc2_hregs_backup {
u32 hcintmsk[MAX_EPS_CHANNELS];
u32 hprt0;
u32 hfir;
+   u32 hptxfsiz;
bool valid;
 };
 
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 53d580f..e8adfeb 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -5346,6 +5346,7 @@ int dwc2_backup_host_registers(struct dwc2_hsotg *hsotg)
 
hr->hprt0 = dwc2_read_hprt0(hsotg);
hr->hfir = dwc2_readl(hsotg->regs + HFIR);
+   hr->hptxfsiz = dwc2_readl(hsotg->regs + HPTXFSIZ);
hr->valid = true;
 
return 0;
@@ -5382,6 +5383,7 @@ int dwc2_restore_host_registers(struct dwc2_hsotg *hsotg)
 
dwc2_writel(hr->hprt0, hsotg->regs + HPRT0);
dwc2_writel(hr->hfir, hsotg->regs + HFIR);
+   dwc2_writel(hr->hptxfsiz, hsotg->regs + HPTXFSIZ);
hsotg->frame_number = 0;
 
return 0;
-- 
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 v2 04/14] usb: dwc2: gadget: Fix dwc2_restore_device_registers

2017-02-23 Thread Vardan Mikayelyan
Add parameter remote_wakeup to dwc2_restore_device_registers()
to be able to restore device registers according to programming
guide for dwc-otg. It says that in case of rem_wakeup DCTL must not
be restored here.

Remove setting of DCTL_PWRONPRGDONE from this function, because it
will be done in function responsible for exiting from hibernation.

Signed-off-by: Vardan Mikayelyan 
Signed-off-by: John Youn 
---
 drivers/usb/dwc2/core.c   |  2 +-
 drivers/usb/dwc2/core.h   |  5 +++--
 drivers/usb/dwc2/gadget.c | 16 +++-
 3 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index 7addf69..185d24c 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -162,7 +162,7 @@ int dwc2_exit_partial_power_down(struct dwc2_hsotg *hsotg, 
bool restore)
return ret;
}
} else {
-   ret = dwc2_restore_device_registers(hsotg);
+   ret = dwc2_restore_device_registers(hsotg, 0);
if (ret) {
dev_err(hsotg->dev, "%s: failed to restore 
device registers\n",
__func__);
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 4cb95b3..60ad2e6 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -1183,7 +1183,7 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg 
*dwc2,
 int dwc2_hsotg_set_test_mode(struct dwc2_hsotg *hsotg, int testmode);
 #define dwc2_is_device_connected(hsotg) (hsotg->connected)
 int dwc2_backup_device_registers(struct dwc2_hsotg *hsotg);
-int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg);
+int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg, int remote_wakeup);
 int dwc2_hsotg_tx_fifo_count(struct dwc2_hsotg *hsotg);
 int dwc2_hsotg_tx_fifo_total_depth(struct dwc2_hsotg *hsotg);
 int dwc2_hsotg_tx_fifo_average_depth(struct dwc2_hsotg *hsotg);
@@ -1206,7 +1206,8 @@ static inline int dwc2_hsotg_set_test_mode(struct 
dwc2_hsotg *hsotg,
 #define dwc2_is_device_connected(hsotg) (0)
 static inline int dwc2_backup_device_registers(struct dwc2_hsotg *hsotg)
 { return 0; }
-static inline int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg)
+static inline int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg,
+   int remote_wakeup)
 { return 0; }
 static inline int dwc2_hsotg_tx_fifo_count(struct dwc2_hsotg *hsotg)
 { return 0; }
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 3e969a5..3b082ed 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -4822,11 +4822,13 @@ int dwc2_backup_device_registers(struct dwc2_hsotg 
*hsotg)
  * if controller power were disabled.
  *
  * @hsotg: Programming view of the DWC_otg controller
+ * @remote_wakeup: Indicates whether resume is initiated by Device or Host.
+ *
+ * Return: 0 if successful, negative error code otherwise
  */
-int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg)
+int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg, int remote_wakeup)
 {
struct dwc2_dregs_backup *dr;
-   u32 dctl;
int i;
 
dev_dbg(hsotg->dev, "%s\n", __func__);
@@ -4840,8 +4842,9 @@ int dwc2_restore_device_registers(struct dwc2_hsotg 
*hsotg)
}
dr->valid = false;
 
-   dwc2_writel(dr->dcfg, hsotg->regs + DCFG);
-   dwc2_writel(dr->dctl, hsotg->regs + DCTL);
+   if (!remote_wakeup)
+   dwc2_writel(dr->dctl, hsotg->regs + DCTL);
+
dwc2_writel(dr->daintmsk, hsotg->regs + DAINTMSK);
dwc2_writel(dr->diepmsk, hsotg->regs + DIEPMSK);
dwc2_writel(dr->doepmsk, hsotg->regs + DOEPMSK);
@@ -4859,10 +4862,5 @@ int dwc2_restore_device_registers(struct dwc2_hsotg 
*hsotg)
dwc2_writel(dr->doepdma[i], hsotg->regs + DOEPDMA(i));
}
 
-   /* Set the Power-On Programming done bit */
-   dctl = dwc2_readl(hsotg->regs + DCTL);
-   dctl |= DCTL_PWRONPRGDONE;
-   dwc2_writel(dctl, hsotg->regs + DCTL);
-
return 0;
 }
-- 
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 v2 02/14] usb: dwc2: Add hibernation field into dwc2_hw_params

2017-02-23 Thread Vardan Mikayelyan
Add parameter and it's initialization, needed for hibernation.

Reimplement dwc2_set_param_power_down() to support hibernation too.
Now 'power_down' parameter can be initialized with 0, 1 or 2.
0 - No
1 - Partial power down
2 - Hibernation

Signed-off-by: Vardan Mikayelyan 
Signed-off-by: John Youn 
---
 drivers/usb/dwc2/core.c   |  2 +-
 drivers/usb/dwc2/core.h   | 12 ++--
 drivers/usb/dwc2/hcd.c|  4 ++--
 drivers/usb/dwc2/params.c | 34 ++
 4 files changed, 47 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index e8708fd..fe976eb 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -135,7 +135,7 @@ int dwc2_exit_partial_power_down(struct dwc2_hsotg *hsotg, 
bool restore)
u32 pcgcctl;
int ret = 0;
 
-   if (!hsotg->params.power_down)
+   if (hsotg->params.power_down != DWC2_POWER_DOWN_PARAM_PARTIAL)
return -ENOTSUPP;
 
pcgcctl = dwc2_readl(hsotg->regs + PCGCTL);
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 61c5e56..526d870 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -422,7 +422,8 @@ enum dwc2_ep0_state {
  * power_down in both peripheral and host mode when
  * needed.
  * 0 - No (default)
- * 1 - Yes
+ * 1 - Partial power down
+ * 2 - Hibernation
  * @activate_stm_fs_transceiver: Activate internal transceiver using GGPIO
  * register.
  * 0 - Deactivate the transceiver (default)
@@ -480,7 +481,12 @@ struct dwc2_core_params {
bool reload_ctl;
bool uframe_sched;
bool external_id_pin_ctl;
-   bool power_down;
+
+   int power_down;
+#define DWC2_POWER_DOWN_PARAM_NONE 0
+#define DWC2_POWER_DOWN_PARAM_PARTIAL  1
+#define DWC2_POWER_DOWN_PARAM_HIBERNATION  2
+
bool activate_stm_fs_transceiver;
u16 max_packet_count;
u32 max_transfer_size;
@@ -554,6 +560,7 @@ struct dwc2_core_params {
  *   2 - FS pins shared with UTMI+ pins
  *   3 - FS pins shared with ULPI pins
  * @total_fifo_size:Total internal RAM for FIFOs (bytes)
+ * @hibernationIs hibernation enabled?
  * @utmi_phy_data_width UTMI+ PHY data width
  *   0 - 8 bits
  *   1 - 16 bits
@@ -584,6 +591,7 @@ struct dwc2_hw_params {
unsigned num_dev_perio_in_ep:4;
unsigned total_fifo_size:16;
unsigned power_optimized:1;
+   unsigned hibernation:1;
unsigned utmi_phy_data_width:2;
u32 snpsid;
u32 dev_ep_dirs;
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 604356c..53d580f 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -4396,7 +4396,7 @@ static int _dwc2_hcd_suspend(struct usb_hcd *hcd)
if (hsotg->op_state == OTG_STATE_B_PERIPHERAL)
goto unlock;
 
-   if (!hsotg->params.power_down)
+   if (hsotg->params.power_down != DWC2_POWER_DOWN_PARAM_PARTIAL)
goto skip_power_saving;
 
/*
@@ -4448,7 +4448,7 @@ static int _dwc2_hcd_resume(struct usb_hcd *hcd)
if (hsotg->lx_state != DWC2_L2)
goto unlock;
 
-   if (!hsotg->params.power_down) {
+   if (hsotg->params.power_down != DWC2_POWER_DOWN_PARAM_PARTIAL) {
hsotg->lx_state = DWC2_L0;
goto unlock;
}
diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index 38336e5..baa76bf 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -446,6 +446,38 @@ static void dwc2_check_param_phy_utmi_width(struct 
dwc2_hsotg *hsotg)
dwc2_set_param_phy_utmi_width(hsotg);
 }
 
+static void dwc2_check_param_power_down(struct dwc2_hsotg *hsotg)
+{
+   int param = hsotg->params.power_down;
+
+   switch (param) {
+   case DWC2_POWER_DOWN_PARAM_NONE:
+   break;
+   case DWC2_POWER_DOWN_PARAM_PARTIAL:
+   if (hsotg->hw_params.power_optimized)
+   break;
+   dev_dbg(hsotg->dev,
+   "Partial power down isn't supported by HW\n");
+   param = DWC2_POWER_DOWN_PARAM_NONE;
+   break;
+   case DWC2_POWER_DOWN_PARAM_HIBERNATION:
+   if (hsotg->hw_params.hibernation)
+   break;
+   dev_dbg(hsotg->dev,
+   "Hibernation isn't supported by HW\n");
+   param = DWC2_POWER_DOWN_PARAM_NONE;
+   break;
+   default:
+   dev_err(hsotg->dev,
+   "%s: Invalid parameter power_down=%d\n",
+   __func__, param);
+   param = DWC2_POWER_DOWN_PARAM_NONE;
+   break;
+   }
+
+   hsotg->params.powe

[PATCH v2 03/14] usb: dwc2: gadget: Moved dtxfsiz backup array place

2017-02-23 Thread Vardan Mikayelyan
Moved dtxfsiz from dwc2_gregs_backup to dwc2_dregs_backup,
because it is device register.

Signed-off-by: Vardan Mikayelyan 
Signed-off-by: John Youn 
---
 drivers/usb/dwc2/core.c   | 8 ++--
 drivers/usb/dwc2/core.h   | 4 ++--
 drivers/usb/dwc2/gadget.c | 2 ++
 3 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index fe976eb..7addf69 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -66,7 +66,8 @@
 static int dwc2_backup_global_registers(struct dwc2_hsotg *hsotg)
 {
struct dwc2_gregs_backup *gr;
-   int i;
+
+   dev_dbg(hsotg->dev, "%s\n", __func__);
 
/* Backup global regs */
gr = &hsotg->gr_backup;
@@ -79,8 +80,6 @@ static int dwc2_backup_global_registers(struct dwc2_hsotg 
*hsotg)
gr->gnptxfsiz = dwc2_readl(hsotg->regs + GNPTXFSIZ);
gr->hptxfsiz = dwc2_readl(hsotg->regs + HPTXFSIZ);
gr->gdfifocfg = dwc2_readl(hsotg->regs + GDFIFOCFG);
-   for (i = 0; i < MAX_EPS_CHANNELS; i++)
-   gr->dtxfsiz[i] = dwc2_readl(hsotg->regs + DPTXFSIZN(i));
 
gr->valid = true;
return 0;
@@ -96,7 +95,6 @@ static int dwc2_backup_global_registers(struct dwc2_hsotg 
*hsotg)
 static int dwc2_restore_global_registers(struct dwc2_hsotg *hsotg)
 {
struct dwc2_gregs_backup *gr;
-   int i;
 
dev_dbg(hsotg->dev, "%s\n", __func__);
 
@@ -118,8 +116,6 @@ static int dwc2_restore_global_registers(struct dwc2_hsotg 
*hsotg)
dwc2_writel(gr->gnptxfsiz, hsotg->regs + GNPTXFSIZ);
dwc2_writel(gr->hptxfsiz, hsotg->regs + HPTXFSIZ);
dwc2_writel(gr->gdfifocfg, hsotg->regs + GDFIFOCFG);
-   for (i = 0; i < MAX_EPS_CHANNELS; i++)
-   dwc2_writel(gr->dtxfsiz[i], hsotg->regs + DPTXFSIZN(i));
 
return 0;
 }
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 526d870..4cb95b3 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -612,7 +612,6 @@ struct dwc2_hw_params {
  * @gi2cctl:   Backup of GI2CCTL register
  * @hptxfsiz:  Backup of HPTXFSIZ register
  * @gdfifocfg: Backup of GDFIFOCFG register
- * @dtxfsiz:   Backup of DTXFSIZ registers for each endpoint
  * @gpwrdn:Backup of GPWRDN register
  */
 struct dwc2_gregs_backup {
@@ -626,7 +625,6 @@ struct dwc2_gregs_backup {
u32 hptxfsiz;
u32 pcgcctl;
u32 gdfifocfg;
-   u32 dtxfsiz[MAX_EPS_CHANNELS];
u32 gpwrdn;
bool valid;
 };
@@ -645,6 +643,7 @@ struct dwc2_gregs_backup {
  * @doepctl:   Backup of DOEPCTL register
  * @doeptsiz:  Backup of DOEPTSIZ register
  * @doepdma:   Backup of DOEPDMA register
+ * @dtxfsiz:   Backup of DTXFSIZ registers for each endpoint
  */
 struct dwc2_dregs_backup {
u32 dcfg;
@@ -658,6 +657,7 @@ struct dwc2_dregs_backup {
u32 doepctl[MAX_EPS_CHANNELS];
u32 doeptsiz[MAX_EPS_CHANNELS];
u32 doepdma[MAX_EPS_CHANNELS];
+   u32 dtxfsiz[MAX_EPS_CHANNELS];
bool valid;
 };
 
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 4bd3cab..3e969a5 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -4810,6 +4810,7 @@ int dwc2_backup_device_registers(struct dwc2_hsotg *hsotg)
 
dr->doeptsiz[i] = dwc2_readl(hsotg->regs + DOEPTSIZ(i));
dr->doepdma[i] = dwc2_readl(hsotg->regs + DOEPDMA(i));
+   dr->dtxfsiz[i] = dwc2_readl(hsotg->regs + DPTXFSIZN(i));
}
dr->valid = true;
return 0;
@@ -4850,6 +4851,7 @@ int dwc2_restore_device_registers(struct dwc2_hsotg 
*hsotg)
dwc2_writel(dr->diepctl[i], hsotg->regs + DIEPCTL(i));
dwc2_writel(dr->dieptsiz[i], hsotg->regs + DIEPTSIZ(i));
dwc2_writel(dr->diepdma[i], hsotg->regs + DIEPDMA(i));
+   dwc2_writel(dr->dtxfsiz[i], hsotg->regs + DPTXFSIZN(i));
 
/* Restore OUT EPs */
dwc2_writel(dr->doepctl[i], hsotg->regs + DOEPCTL(i));
-- 
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 v2 11/14] usb: dwc2: Allow entering hibernation from USB_SUSPEND interrupt

2017-02-23 Thread Vardan Mikayelyan
Do changes to allow entering hibernated state from USB_SUSPEND
interrupt. All code is added under if conditions and mustn't impact
existing functionality.

Signed-off-by: Vardan Mikayelyan 
Signed-off-by: John Youn 
---
 drivers/usb/dwc2/core_intr.c | 52 +++-
 1 file changed, 32 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index 0fb8cf6..45c9b57 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -427,32 +427,44 @@ static void dwc2_handle_usb_suspend_intr(struct 
dwc2_hsotg *hsotg)
 * state is active
 */
dsts = dwc2_readl(hsotg->regs + DSTS);
-   dev_dbg(hsotg->dev, "DSTS=0x%0x\n", dsts);
+   dev_dbg(hsotg->dev, "%s: DSTS=0x%0x\n", __func__, dsts);
dev_dbg(hsotg->dev,
-   "DSTS.Suspend Status=%d HWCFG4.Power Optimize=%d\n",
+   "DSTS.Suspend Status=%d HWCFG4.Power Optimize=%d 
HWCFG4.Hibernation=%d\n",
!!(dsts & DSTS_SUSPSTS),
-   hsotg->hw_params.power_optimized);
-   if ((dsts & DSTS_SUSPSTS) && hsotg->hw_params.power_optimized) {
-   /* Ignore suspend request before enumeration */
-   if (!dwc2_is_device_connected(hsotg)) {
-   dev_dbg(hsotg->dev,
-   "ignore suspend request before 
enumeration\n");
-   return;
+   hsotg->hw_params.power_optimized,
+   hsotg->hw_params.hibernation);
+
+   /* Ignore suspend request before enumeration */
+   if (!dwc2_is_device_connected(hsotg)) {
+   dev_dbg(hsotg->dev,
+   "ignore suspend request before enumeration\n");
+   return;
+   }
+   if (dsts & DSTS_SUSPSTS) {
+   if (hsotg->hw_params.power_optimized) {
+   ret = dwc2_enter_partial_power_down(hsotg);
+   if (ret) {
+   if (ret != -ENOTSUPP)
+   dev_err(hsotg->dev,
+   "%s: enter 
partial_power_down failed\n",
+   __func__);
+   goto skip_power_saving;
+   }
+
+   udelay(100);
+
+   /* Ask phy to be suspended */
+   if (!IS_ERR_OR_NULL(hsotg->uphy))
+   usb_phy_set_suspend(hsotg->uphy, true);
}
 
-   ret = dwc2_enter_partial_power_down(hsotg);
-   if (ret) {
-   if (ret != -ENOTSUPP)
+   if (hsotg->hw_params.hibernation) {
+   ret = dwc2_enter_hibernation(hsotg, 0);
+   if (ret && ret != -ENOTSUPP)
dev_err(hsotg->dev,
-   "enter power_down failed\n");
-   goto skip_power_saving;
+   "%s: enter hibernation 
failed\n",
+   __func__);
}
-
-   udelay(100);
-
-   /* Ask phy to be suspended */
-   if (!IS_ERR_OR_NULL(hsotg->uphy))
-   usb_phy_set_suspend(hsotg->uphy, true);
 skip_power_saving:
/*
 * Change to L2 (suspend) state before releasing
-- 
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 v2 14/14] usb: dwc2: Enable power down

2017-02-23 Thread Vardan Mikayelyan
From: John Youn 

Enable the power down option based on the core capability.

Signed-off-by: John Youn 
Signed-off-by: Vardan Mikayelyan 
---
 drivers/usb/dwc2/params.c | 16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index baa76bf..9480b8f 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -238,6 +238,20 @@ static void dwc2_set_param_tx_fifo_sizes(struct dwc2_hsotg 
*hsotg)
p->g_tx_fifo_size[i] = depth_average;
 }
 
+static void dwc2_set_param_power_down(struct dwc2_hsotg *hsotg)
+{
+   int val;
+
+   if (hsotg->hw_params.hibernation)
+   val = 2;
+   else if (hsotg->hw_params.power_optimized)
+   val = 1;
+   else
+   val = 0;
+
+   hsotg->params.power_down = val;
+}
+
 /**
  * dwc2_set_default_params() - Set all core parameters to their
  * auto-detected default values.
@@ -252,6 +266,7 @@ static void dwc2_set_default_params(struct dwc2_hsotg 
*hsotg)
dwc2_set_param_phy_type(hsotg);
dwc2_set_param_speed(hsotg);
dwc2_set_param_phy_utmi_width(hsotg);
+   dwc2_set_param_power_down(hsotg);
p->phy_ulpi_ddr = false;
p->phy_ulpi_ext_vbus = false;
 
@@ -263,7 +278,6 @@ static void dwc2_set_default_params(struct dwc2_hsotg 
*hsotg)
p->reload_ctl = (hw->snpsid >= DWC2_CORE_REV_2_92a);
p->uframe_sched = true;
p->external_id_pin_ctl = false;
-   p->power_down = false;
p->max_packet_count = hw->max_packet_count;
p->max_transfer_size = hw->max_transfer_size;
p->ahbcfg = GAHBCFG_HBSTLEN_INCR4 << GAHBCFG_HBSTLEN_SHIFT;
-- 
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 v2 12/14] usb: dwc2: Add dwc2_handle_gpwrdn_intr() handler

2017-02-23 Thread Vardan Mikayelyan
The GPWRDN interrupts are those that occur in both Host and
Device mode while core is in hibernated state.

Export dwc2_core_init to be able to use it in GPWRDN_IDSTS
interrupt handler.

Here we have duplicated init functions in host and gadget sides
so I have left things as it was(used corresponing functions for
host and gadget), maybe in the future we'll resolve this problem
and will use dwc2_core_init for both sides.

Signed-off-by: Vardan Mikayelyan 
Signed-off-by: John Youn 
---
 drivers/usb/dwc2/core.h  |   3 ++
 drivers/usb/dwc2/core_intr.c | 110 +++
 drivers/usb/dwc2/hcd.c   |   2 +-
 3 files changed, 114 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index a3561e1..263ad53 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -1245,6 +1245,7 @@ static inline int dwc2_hsotg_tx_fifo_average_depth(struct 
dwc2_hsotg *hsotg)
 void dwc2_hcd_connect(struct dwc2_hsotg *hsotg);
 void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg, bool force);
 void dwc2_hcd_start(struct dwc2_hsotg *hsotg);
+int dwc2_core_init(struct dwc2_hsotg *hsotg, bool initial_setup);
 int dwc2_backup_host_registers(struct dwc2_hsotg *hsotg);
 int dwc2_restore_host_registers(struct dwc2_hsotg *hsotg);
 int dwc2_host_enter_hibernation(struct dwc2_hsotg *hsotg);
@@ -1260,6 +1261,8 @@ static inline void dwc2_hcd_connect(struct dwc2_hsotg 
*hsotg) {}
 static inline void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg, bool force) {}
 static inline void dwc2_hcd_start(struct dwc2_hsotg *hsotg) {}
 static inline void dwc2_hcd_remove(struct dwc2_hsotg *hsotg) {}
+static inline int dwc2_core_init(struct dwc2_hsotg *hsotg, bool initial_setup)
+{ return 0; }
 static inline int dwc2_hcd_init(struct dwc2_hsotg *hsotg)
 { return 0; }
 static inline int dwc2_backup_host_registers(struct dwc2_hsotg *hsotg)
diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index 45c9b57..86cbbb9 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -520,6 +520,109 @@ static u32 dwc2_read_common_intr(struct dwc2_hsotg *hsotg)
return 0;
 }
 
+/**
+ * GPWRDN interrupt handler.
+ *
+ * The GPWRDN interrupts are those that occur in both Host and
+ * Device mode while core is in hibernated state.
+ */
+static void dwc2_handle_gpwrdn_intr(struct dwc2_hsotg *hsotg)
+{
+   u32 gpwrdn;
+   int linestate;
+
+   gpwrdn = dwc2_readl(hsotg->regs + GPWRDN);
+   linestate = (gpwrdn & GPWRDN_LINESTATE_MASK) >> GPWRDN_LINESTATE_SHIFT;
+   dev_dbg(hsotg->dev,
+   "%s: dwc2_handle_gpwrdwn_intr called gpwrdn= %08x\n", __func__,
+   gpwrdn);
+
+   if ((gpwrdn & GPWRDN_DISCONN_DET) &&
+   (gpwrdn & GPWRDN_DISCONN_DET_MSK) && !linestate) {
+   u32 gpwrdn_tmp;
+
+   dev_dbg(hsotg->dev, "%s: GPWRDN_DISCONN_DET\n", __func__);
+   /* clear interrupt */
+   dwc2_writel(GPWRDN_DISCONN_DET, hsotg->regs + GPWRDN);
+
+   /* Switch-on voltage to the core */
+   gpwrdn_tmp = dwc2_readl(hsotg->regs + GPWRDN);
+   gpwrdn_tmp &= ~GPWRDN_PWRDNSWTCH;
+   dwc2_writel(gpwrdn_tmp, hsotg->regs + GPWRDN);
+   udelay(10);
+
+   /* Reset core */
+   gpwrdn_tmp = dwc2_readl(hsotg->regs + GPWRDN);
+   gpwrdn_tmp &= ~GPWRDN_PWRDNRSTN;
+   dwc2_writel(gpwrdn_tmp, hsotg->regs + GPWRDN);
+   udelay(10);
+
+   /* Disable Power Down Clamp */
+   gpwrdn_tmp = dwc2_readl(hsotg->regs + GPWRDN);
+   gpwrdn_tmp &= ~GPWRDN_PWRDNCLMP;
+   dwc2_writel(gpwrdn_tmp, hsotg->regs + GPWRDN);
+   udelay(10);
+
+   /* Deassert reset core */
+   gpwrdn_tmp = dwc2_readl(hsotg->regs + GPWRDN);
+   gpwrdn_tmp |= GPWRDN_PWRDNRSTN;
+   dwc2_writel(gpwrdn_tmp, hsotg->regs + GPWRDN);
+   udelay(10);
+
+   /* Disable PMU interrupt */
+   gpwrdn_tmp = dwc2_readl(hsotg->regs + GPWRDN);
+   gpwrdn_tmp &= ~GPWRDN_PMUINTSEL;
+   dwc2_writel(gpwrdn_tmp, hsotg->regs + GPWRDN);
+
+   /* De-assert Wakeup Logic */
+   gpwrdn_tmp = dwc2_readl(hsotg->regs + GPWRDN);
+   gpwrdn_tmp &= ~GPWRDN_PMUACTV;
+   dwc2_writel(gpwrdn_tmp, hsotg->regs + GPWRDN);
+
+   hsotg->hibernated = 0;
+
+   if (gpwrdn & GPWRDN_IDSTS) {
+   hsotg->op_state = OTG_STATE_B_PERIPHERAL;
+   dwc2_core_init(hsotg, false);
+   dwc2_enable_global_interrupts(hsotg);
+   dwc2_hsotg_core_init_disconnected(hsotg, false);
+   dwc2_hsotg_core_connect(hsotg);
+   } else {
+   hsotg->op_state = OTG_STATE_A_HOST;
+
+   /* Init

[PATCH v2 13/14] usb: dwc2: Change hub-control to allow hibernation

2017-02-23 Thread Vardan Mikayelyan
Affected cases:
ClearPortFeature's
 USB_PORT_FEAT_SUSPEND

SetPortFeature's
 USB_PORT_FEAT_SUSPEND
 USB_PORT_FEAT_RESET

Signed-off-by: Vardan Mikayelyan 
Signed-off-by: John Youn 
---
 drivers/usb/dwc2/hcd.c | 16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 0b889a0..636dffc 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -3471,8 +3471,12 @@ static int dwc2_hcd_hub_control(struct dwc2_hsotg 
*hsotg, u16 typereq,
dev_dbg(hsotg->dev,
"ClearPortFeature USB_PORT_FEAT_SUSPEND\n");
 
-   if (hsotg->bus_suspended)
-   dwc2_port_resume(hsotg);
+   if (hsotg->bus_suspended) {
+   if (hsotg->hibernated)
+   dwc2_exit_hibernation(hsotg, 0, 0, 1);
+   else
+   dwc2_port_resume(hsotg);
+   }
break;
 
case USB_PORT_FEAT_POWER:
@@ -3680,7 +3684,10 @@ static int dwc2_hcd_hub_control(struct dwc2_hsotg 
*hsotg, u16 typereq,
"SetPortFeature - USB_PORT_FEAT_SUSPEND\n");
if (windex != hsotg->otg_port)
goto error;
-   dwc2_port_suspend(hsotg, windex);
+   if (hsotg->params.power_down == 2)
+   dwc2_enter_hibernation(hsotg, 1);
+   else
+   dwc2_port_suspend(hsotg, windex);
break;
 
case USB_PORT_FEAT_POWER:
@@ -3692,6 +3699,9 @@ static int dwc2_hcd_hub_control(struct dwc2_hsotg *hsotg, 
u16 typereq,
break;
 
case USB_PORT_FEAT_RESET:
+   if (hsotg->params.power_down == 2 &&
+   hsotg->hibernated)
+   dwc2_exit_hibernation(hsotg, 0, 1, 1);
hprt0 = dwc2_read_hprt0(hsotg);
dev_dbg(hsotg->dev,
"SetPortFeature - USB_PORT_FEAT_RESET\n");
-- 
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 v2 00/14] usb: dwc2: Add hibernation feature support.

2017-02-23 Thread Vardan Mikayelyan
The functions with name hibernation are misnamed originally. They were only
responsible for partial power down and not for hibernation.

This patch set adds the real hibernation support for dwc2 driver and renames
existing functions to power_down.xisting functions to power_down.

Changes in v2:
 -remove "usb: dwc2: Replace msleep with mdelay in dwc2_clear_force_mode()"
  from this series because it is unnescessary after force mode optimizations.

John Youn (1):
  usb: dwc2: Enable power down

Vardan Mikayelyan (13):
  usb: dwc2: Rename hibernation to partial_power_down
  usb: dwc2: Add hibernation field into dwc2_hw_params
  usb: dwc2: gadget: Moved dtxfsiz backup array place
  usb: dwc2: gadget: Fix dwc2_restore_device_registers
  usb: dwc2: core: Add hibernated flag
  usb: dwc2: gadget: Add remote_wakeup_allowed flag
  usb: dwc2: Changes in registers backup/restore functions
  usb: dwc2: Add helper functions for restore routine
  usb: dwc2: Add host/device hibernation functions
  usb: dwc2: Add dwc2_enter_hibernation(), dwc2_exit_hibernation()
  usb: dwc2: Allow entering hibernation from USB_SUSPEND interrupt
  usb: dwc2: Add dwc2_handle_gpwrdn_intr() handler
  usb: dwc2: Change hub-control to allow hibernation

 drivers/usb/dwc2/core.c  | 210 +---
 drivers/usb/dwc2/core.h  |  68 +--
 drivers/usb/dwc2/core_intr.c | 172 ++
 drivers/usb/dwc2/debugfs.c   |   2 +-
 drivers/usb/dwc2/gadget.c| 226 +--
 drivers/usb/dwc2/hcd.c   | 279 ---
 drivers/usb/dwc2/params.c|  50 +++-
 drivers/usb/dwc2/platform.c  |   1 +
 8 files changed, 921 insertions(+), 87 deletions(-)

-- 
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 v2 01/14] usb: dwc2: Rename hibernation to partial_power_down

2017-02-23 Thread Vardan Mikayelyan
No-op change, only rename.

This code was misnamed originally. It was only responsible for partial
power down and not for hibernation.

Rename core_params->hibernation to core_params->power_down,
dwc2_set_param_hibernation() to dwc2_set_param_power_down().

Signed-off-by: Vardan Mikayelyan 
Signed-off-by: John Youn 
---
 drivers/usb/dwc2/core.c  | 14 +++---
 drivers/usb/dwc2/core.h  | 12 ++--
 drivers/usb/dwc2/core_intr.c | 14 +++---
 drivers/usb/dwc2/debugfs.c   |  2 +-
 drivers/usb/dwc2/gadget.c|  6 +++---
 drivers/usb/dwc2/hcd.c   | 26 +-
 drivers/usb/dwc2/params.c|  2 +-
 7 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index 42ac47f..e8708fd 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -125,17 +125,17 @@ static int dwc2_restore_global_registers(struct 
dwc2_hsotg *hsotg)
 }
 
 /**
- * dwc2_exit_hibernation() - Exit controller from Partial Power Down.
+ * dwc2_exit_partial_power_down() - Exit controller from Partial Power Down.
  *
  * @hsotg: Programming view of the DWC_otg controller
  * @restore: Controller registers need to be restored
  */
-int dwc2_exit_hibernation(struct dwc2_hsotg *hsotg, bool restore)
+int dwc2_exit_partial_power_down(struct dwc2_hsotg *hsotg, bool restore)
 {
u32 pcgcctl;
int ret = 0;
 
-   if (!hsotg->params.hibernation)
+   if (!hsotg->params.power_down)
return -ENOTSUPP;
 
pcgcctl = dwc2_readl(hsotg->regs + PCGCTL);
@@ -179,16 +179,16 @@ int dwc2_exit_hibernation(struct dwc2_hsotg *hsotg, bool 
restore)
 }
 
 /**
- * dwc2_enter_hibernation() - Put controller in Partial Power Down.
+ * dwc2_enter_partial_power_down() - Put controller in Partial Power Down.
  *
  * @hsotg: Programming view of the DWC_otg controller
  */
-int dwc2_enter_hibernation(struct dwc2_hsotg *hsotg)
+int dwc2_enter_partial_power_down(struct dwc2_hsotg *hsotg)
 {
u32 pcgcctl;
int ret = 0;
 
-   if (!hsotg->params.hibernation)
+   if (!hsotg->params.power_down)
return -ENOTSUPP;
 
/* Backup all registers */
@@ -217,7 +217,7 @@ int dwc2_enter_hibernation(struct dwc2_hsotg *hsotg)
 
/*
 * Clear any pending interrupts since dwc2 will not be able to
-* clear them after entering hibernation.
+* clear them after entering partial_power_down.
 */
dwc2_writel(0x, hsotg->regs + GINTSTS);
 
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 67ca757..61c5e56 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -417,9 +417,9 @@ enum dwc2_ep0_state {
  *  case.
  *  0 - No (default)
  *  1 - Yes
- * @hibernation:   Specifies whether the controller support hibernation.
- * If hibernation is enabled, the controller will enter
- * hibernation in both peripheral and host mode when
+ * @power_down: Specifies whether the controller support power_down.
+ * If power_down is enabled, the controller will enter
+ * power_down in both peripheral and host mode when
  * needed.
  * 0 - No (default)
  * 1 - Yes
@@ -480,7 +480,7 @@ struct dwc2_core_params {
bool reload_ctl;
bool uframe_sched;
bool external_id_pin_ctl;
-   bool hibernation;
+   bool power_down;
bool activate_stm_fs_transceiver;
u16 max_packet_count;
u32 max_transfer_size;
@@ -1095,8 +1095,8 @@ static inline bool dwc2_is_hs_iot(struct dwc2_hsotg 
*hsotg)
  * and the DWC_otg controller
  */
 int dwc2_core_reset(struct dwc2_hsotg *hsotg, bool skip_wait);
-int dwc2_enter_hibernation(struct dwc2_hsotg *hsotg);
-int dwc2_exit_hibernation(struct dwc2_hsotg *hsotg, bool restore);
+int dwc2_enter_partial_power_down(struct dwc2_hsotg *hsotg);
+int dwc2_exit_partial_power_down(struct dwc2_hsotg *hsotg, bool restore);
 
 void dwc2_force_mode(struct dwc2_hsotg *hsotg, bool host);
 void dwc2_force_dr_mode(struct dwc2_hsotg *hsotg);
diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index b8bcb00..0fb8cf6 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -320,10 +320,10 @@ static void dwc2_handle_session_req_intr(struct 
dwc2_hsotg *hsotg)
 
if (dwc2_is_device_mode(hsotg)) {
if (hsotg->lx_state == DWC2_L2) {
-   ret = dwc2_exit_hibernation(hsotg, true);
+   ret = dwc2_exit_partial_power_down(hsotg, true);
if (ret && (ret != -ENOTSUPP))
dev_err(hsotg->dev,
-   "exit hibernation failed\n");
+   "exit power_down failed\n");
}