[PATCH] usb: dwc3: omap: squash include/linux/platform_data/dwc3-omap.h

2019-07-21 Thread Masahiro Yamada
This enum is only used in drivers/usb/dwc3/dwc3-omap3.c

Signed-off-by: Masahiro Yamada 
---

 drivers/usb/dwc3/dwc3-omap.c|  7 +++-
 include/linux/platform_data/dwc3-omap.h | 43 -
 2 files changed, 6 insertions(+), 44 deletions(-)
 delete mode 100644 include/linux/platform_data/dwc3-omap.h

diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index ed8b86517675..4f51523a07ac 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -14,7 +14,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -106,6 +105,12 @@
 #define USBOTGSS_UTMI_OTG_CTRL_SESSVALID   BIT(2)
 #define USBOTGSS_UTMI_OTG_CTRL_VBUSVALID   BIT(1)
 
+enum dwc3_omap_utmi_mode {
+   DWC3_OMAP_UTMI_MODE_UNKNOWN = 0,
+   DWC3_OMAP_UTMI_MODE_HW,
+   DWC3_OMAP_UTMI_MODE_SW,
+};
+
 struct dwc3_omap {
struct device   *dev;
 
diff --git a/include/linux/platform_data/dwc3-omap.h 
b/include/linux/platform_data/dwc3-omap.h
deleted file mode 100644
index 1d36ca874cc8..
--- a/include/linux/platform_data/dwc3-omap.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * dwc3-omap.h - OMAP Specific Glue layer, header.
- *
- * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com
- * All rights reserved.
- *
- * Author: Felipe Balbi 
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *notice, this list of conditions, and the following disclaimer,
- *without modification.
- * 2. Redistributions in binary form must reproduce the above copyright
- *notice, this list of conditions and the following disclaimer in the
- *documentation and/or other materials provided with the distribution.
- * 3. The names of the above-listed copyright holders may not be used
- *to endorse or promote products derived from this software without
- *specific prior written permission.
- *
- * ALTERNATIVELY, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2, as published by the Free
- * Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-enum dwc3_omap_utmi_mode {
-   DWC3_OMAP_UTMI_MODE_UNKNOWN = 0,
-   DWC3_OMAP_UTMI_MODE_HW,
-   DWC3_OMAP_UTMI_MODE_SW,
-};
-- 
2.17.1



Re: [PATCH v2 0/2] usbip: Implement SG support

2019-07-21 Thread Suwan Kim
On Fri, Jul 19, 2019 at 04:04:20PM -0600, shuah wrote:
> On 7/5/19 10:43 AM, Suwan Kim wrote:
> > There are bugs on vhci with usb 3.0 storage device. Originally, vhci
> > doesn't supported SG, so USB storage driver on vhci breaks SG list
> > into multiple URBs and it causes error that a transfer got terminated
> > too early because the transfer length for one of the URBs was not
> > divisible by the maxpacket size.
> > 
> > To support SG, vhci doesn't map and unmap URB for DMA to use native
> > SG list (urb->num_sgs). In DMA mapping function of vhci, it sets
> > URB_DMA_MAP_SG flag in urb->transfer_flags if URB has SG list and
> > this flag will tell the stub driver to use SG list.
> > 
> > In this patch, vhci basically support SG and it sends each SG list
> > entry to the stub driver. Then, the stub driver sees the total length
> > of the buffer and allocates SG table and pages according to the total
> > buffer length calling sgl_alloc(). After the stub driver receives
> > completed URB, it again sends each SG list entry to vhci.
> > 
> > If HCD of the server doesn't support SG, the stub driver breaks a
> > single SG reqeust into several URBs and submit them to the server's
> > HCD. When all the split URBs are completed, the stub driver
> > reassembles the URBs into a single return command and sends it to
> > vhci.
> > 
> > Alan fixed vhci bug with the USB 3.0 storage device by modifying
> > USB storage driver.
> > ("usb-storage: Set virt_boundary_mask to avoid SG overflows")
> > But the fundamental solution of it is to add SG support to vhci.
> > 
> > This patch works well with the USB 3.0 storage devices without Alan's
> > patch, and we can revert Alan's patch if it causes some troubles.
> > 
> > Suwan Kim (2):
> >usbip: Skip DMA mapping and unmapping for urb at vhci
> >usbip: Implement SG support to vhci
> > 
> >   drivers/usb/usbip/stub.h |   7 +-
> >   drivers/usb/usbip/stub_main.c|  52 +---
> >   drivers/usb/usbip/stub_rx.c  | 207 ++-
> >   drivers/usb/usbip/stub_tx.c  | 108 +++-
> >   drivers/usb/usbip/usbip_common.c |  60 +++--
> >   drivers/usb/usbip/vhci_hcd.c |  29 -
> >   drivers/usb/usbip/vhci_tx.c  |  49 ++--
> >   7 files changed, 391 insertions(+), 121 deletions(-)
> > 
> 
> Hi Suwan,
> 
> I have been traveling and would like to test this series before I ask
> Greg to pick it up.
> 
> Just a quick note that I will get to this early next week.

Ok. Thank you for reviewing the patch, Shuah.
Please let me know if you have any problems reviewing the patch :)

Regards

Suwan Kim


[PATCH 1/2] usb: host: oxu210hp-hcd: remove include/linux/oxu210hp.h

2019-07-21 Thread Masahiro Yamada
struct oxu210hp_platform_data is defined, but not used at all.

$ git grep oxu210hp_platform_data
include/linux/oxu210hp.h:struct oxu210hp_platform_data {

include/linux/oxu210hp.h exists just for defining an unused structure,
so it can go away.

Signed-off-by: Masahiro Yamada 
---

 drivers/usb/host/oxu210hp.h | 2 --
 include/linux/oxu210hp.h| 8 
 2 files changed, 10 deletions(-)
 delete mode 100644 include/linux/oxu210hp.h

diff --git a/drivers/usb/host/oxu210hp.h b/drivers/usb/host/oxu210hp.h
index 437044147862..67ebea4993b6 100644
--- a/drivers/usb/host/oxu210hp.h
+++ b/drivers/usb/host/oxu210hp.h
@@ -444,5 +444,3 @@ enum ehci_timer_action {
TIMER_ASYNC_SHRINK,
TIMER_ASYNC_OFF,
 };
-
-#include 
diff --git a/include/linux/oxu210hp.h b/include/linux/oxu210hp.h
deleted file mode 100644
index 94cd25165c08..
--- a/include/linux/oxu210hp.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* platform data for the OXU210HP HCD */
-
-struct oxu210hp_platform_data {
-   unsigned int bus16:1;
-   unsigned int use_hcd_otg:1;
-   unsigned int use_hcd_sph:1;
-};
-- 
2.17.1



[PATCH 2/2] usb: host: oxu210hp-hcd: squash oxu210hp.h into oxu210hp-hcd.c

2019-07-21 Thread Masahiro Yamada
The header, oxu210hp.h is only included from oxu210hp-hcd.c
so squash it.

When I moved the code, I also fixed the following warnings from
scripts/checkpatch.pl:

drivers/usb/host/oxu210hp-hcd.c:117: warning: __packed is preferred over 
__attribute__((packed))
drivers/usb/host/oxu210hp-hcd.c:196: warning: __packed is preferred over 
__attribute__((packed))
drivers/usb/host/oxu210hp-hcd.c:221: warning: __packed is preferred over 
__attribute__((packed))
drivers/usb/host/oxu210hp-hcd.c:266: warning: __aligned(size) is preferred over 
__attribute__((aligned(size)))
drivers/usb/host/oxu210hp-hcd.c:336: warning: Prefer 'unsigned int' to bare use 
of 'unsigned'
drivers/usb/host/oxu210hp-hcd.c:354: warning: __aligned(size) is preferred over 
__attribute__((aligned(size)))
drivers/usb/host/oxu210hp-hcd.c:385: warning: __aligned(size) is preferred over 
__attribute__((aligned(size)))
drivers/usb/host/oxu210hp-hcd.c:393: warning: __aligned(size) is preferred over 
__attribute__((aligned(size)))
drivers/usb/host/oxu210hp-hcd.c:429: warning: Prefer 'unsigned int' to bare use 
of 'unsigned'
drivers/usb/host/oxu210hp-hcd.c:432: warning: Prefer 'unsigned int' to bare use 
of 'unsigned'
drivers/usb/host/oxu210hp-hcd.c:436: warning: Prefer 'unsigned int' to bare use 
of 'unsigned'
drivers/usb/host/oxu210hp-hcd.c:451: warning: Prefer 'unsigned int' to bare use 
of 'unsigned'
drivers/usb/host/oxu210hp-hcd.c:461: warning: Prefer 'unsigned int' to bare use 
of 'unsigned'
drivers/usb/host/oxu210hp-hcd.c:467: warning: please, no space before tabs

Signed-off-by: Masahiro Yamada 
---

 drivers/usb/host/oxu210hp-hcd.c | 443 ++-
 drivers/usb/host/oxu210hp.h | 446 
 2 files changed, 441 insertions(+), 448 deletions(-)
 delete mode 100644 drivers/usb/host/oxu210hp.h

diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c
index 47c5515a9ce4..09cc19df798e 100644
--- a/drivers/usb/host/oxu210hp-hcd.c
+++ b/drivers/usb/host/oxu210hp-hcd.c
@@ -31,10 +31,449 @@
 #include 
 #include 
 
-#include "oxu210hp.h"
-
 #define DRIVER_VERSION "0.0.50"
 
+#define OXU_DEVICEID   0x00
+   #define OXU_REV_MASK0x
+   #define OXU_REV_SHIFT   16
+   #define OXU_REV_21000x2100
+   #define OXU_BO_SHIFT8
+   #define OXU_BO_MASK (0x3 << OXU_BO_SHIFT)
+   #define OXU_MAJ_REV_SHIFT   4
+   #define OXU_MAJ_REV_MASK(0xf << OXU_MAJ_REV_SHIFT)
+   #define OXU_MIN_REV_SHIFT   0
+   #define OXU_MIN_REV_MASK(0xf << OXU_MIN_REV_SHIFT)
+#define OXU_HOSTIFCONFIG   0x04
+#define OXU_SOFTRESET  0x08
+   #define OXU_SRESET  (1 << 0)
+
+#define OXU_PIOBURSTREADCTRL   0x0C
+
+#define OXU_CHIPIRQSTATUS  0x10
+#define OXU_CHIPIRQEN_SET  0x14
+#define OXU_CHIPIRQEN_CLR  0x18
+   #define OXU_USBSPHLPWUI 0x0080
+   #define OXU_USBOTGLPWUI 0x0040
+   #define OXU_USBSPHI 0x0002
+   #define OXU_USBOTGI 0x0001
+
+#define OXU_CLKCTRL_SET0x1C
+   #define OXU_SYSCLKEN0x0008
+   #define OXU_USBSPHCLKEN 0x0002
+   #define OXU_USBOTGCLKEN 0x0001
+
+#define OXU_ASO0x68
+   #define OXU_SPHPOEN 0x0100
+   #define OXU_OVRCCURPUPDEN   0x0800
+   #define OXU_ASO_OP  (1 << 10)
+   #define OXU_COMPARATOR  0x04000
+
+#define OXU_USBMODE0x1A8
+   #define OXU_VBPS0x0020
+   #define OXU_ES_LITTLE   0x
+   #define OXU_CM_HOST_ONLY0x0003
+
+/*
+ * Proper EHCI structs & defines
+ */
+
+/* Magic numbers that can affect system performance */
+#define EHCI_TUNE_CERR 3   /* 0-3 qtd retries; 0 == don't stop */
+#define EHCI_TUNE_RL_HS4   /* nak throttle; see 4.9 */
+#define EHCI_TUNE_RL_TT0
+#define EHCI_TUNE_MULT_HS  1   /* 1-3 transactions/uframe; 4.10.3 */
+#define EHCI_TUNE_MULT_TT  1
+#define EHCI_TUNE_FLS  2   /* (small) 256 frame schedule */
+
+struct oxu_hcd;
+
+/* EHCI register interface, corresponds to EHCI Revision 0.95 specification */
+
+/* Section 2.2 Host Controller Capability Registers */
+struct ehci_caps {
+   /* these fields are specified as 8 and 16 bit registers,
+* but some hosts can't perform 8 or 16 bit PCI accesses.
+*/
+   u32 hc_capbase;
+#define HC_LENGTH(p)   (((p)>>00)&0x00ff)  /* bits 7:0 */
+#define HC_VERSION(p)  (((p)>>16)&0x)  /* bits 31:16 */
+   u32 hcs_params; /* HCSPARAMS - offset 0x4 */
+#define HCS_DEBUG_PORT(p)  (((p)>>20)&0xf) /* bits 23:20, debug port? */
+#define HCS_INDICATOR(p)   

RE: [PATCH 1/3] usb: common: Add usb_get_dr_mode_from_string and usb_dr_mode_to_string.

2019-07-21 Thread Pawel Laszczak
Hi,

>>Pawel Laszczak  writes:
> diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
> index 69f1b6328532..c156817672c4 100644
> --- a/include/linux/usb/otg.h
> +++ b/include/linux/usb/otg.h
> @@ -129,4 +129,20 @@ enum usb_dr_mode {
>   */
>  extern enum usb_dr_mode usb_get_dr_mode(struct device *dev);
>
> +/**
> + * usb_get_dr_mode_from_string - Convert string to dual role mode.
> + * @str: Pointer to the given string
> + *
> + * The function gets string and returns the correspondig enum 
> usb_dr_mode.
> + */
> +extern enum usb_dr_mode usb_get_dr_mode_from_string(const char *str);
> +
> +/**
> + * usb_dr_mode_to_string - Convert dual role mode to string.
> + * @dr_mode: Pointer to the given dual role mode
> + *
> + * The function gets enum usb_dr_mode, and returns the correspondig 
> string.
> + */
> +extern const char *usb_dr_mode_to_string(const enum usb_dr_mode dr_mode);
> +
>  #endif /* __LINUX_USB_OTG_H */

Still missing the stubs I mentioned. Did you try compiling with and
without common enabled?

>>> Sorry, I thought that I send answer yesterday but it's look like I prepared 
>>> the answer but
>>> I  forgot to send.
>>>
>>> In /drivers/usb/Kconfig we have:
>>>
>>> config USB
>>> tristate "Support for Host-side USB"
>>> depends on USB_ARCH_HAS_HCD
>>> select USB_COMMON
>>>
>>> and in /drivers/usb/gadget/Kconfig we have:
>>>
>>> menuconfig USB_GADGET
>>> tristate "USB Gadget Support"
>>> select USB_COMMON
>>>
>>> I think that it should cover all cases.
>>>
>>> Am I right ?
>>
>>Run a few tens of randconfig builds and see if you ever catch any
>>problem. I think randconfig can produce a defconfig where USB=n
>>USB_GADGET=n and USB_COMMON=y.
>
>Ok, I will test it, but I think that it should work.
>The same situation we have for example with: usb_otg_state_string or 
>usb_ep_type_string.
>

I've been testing it with USB=n USB_GADGET=n and USB_COMMON=y and also only 
with CONFIG_USB_COMMON=y. 
Also I've tested this patch with different default configuration together with 
CDNS3 driver which use these functions. 
I've test It mainly with x86 and arm architecture. 
So far I've not found any issue. 

Cheers,
Pawell



Re: USB Modem support for Droid 4

2019-07-21 Thread Pavel Machek
On Fri 2019-07-19 19:27:48, Greg KH wrote:
> On Thu, Jul 18, 2019 at 10:17:13PM +0200, Pavel Machek wrote:
> > From: Tony Lindgren 
> > 
> > Droid starts to have useful support in linux-next. Modem is tricky to
> > play with, but this is enough to get basic support.
> > 
> > Signed-off-by: Pavel Machek 
> 
> No signed-off-by from Tony?
> 
> And no [PATCH] in the subject?

I was relaying patch. You'll get better one directly from Tony,
"soon". :-)

Best regards,   Pavel
-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany


signature.asc
Description: Digital signature


[PATCH v10 6/6] usb:cdns3 Fix for stuck packets in on-chip OUT buffer.

2019-07-21 Thread Pawel Laszczak
Controller for OUT endpoints has shared on-chip buffers for all incoming
packets, including ep0out. It's FIFO buffer, so packets must be handled
by DMA in correct order. If the first packet in the buffer will not be
handled, then the following packets directed for other endpoints and
functions will be blocked.

Additionally the packets directed to one endpoint can block entire on-chip
buffers. In this case transfer to other endpoints also will blocked.

To resolve this issue after raising the descriptor missing interrupt
driver prepares internal usb_request object and use it to arm DMA
transfer.

The problematic situation was observed in case when endpoint has
been enabled but no usb_request were queued. Driver try detects
such endpoints and will use this workaround only for these endpoint.

Driver use limited number of buffer. This number can be set by macro
CDNS_WA2_NUM_BUFFERS.

Such blocking situation was observed on ACM gadget. For this function
host send OUT data packet but ACM function is not prepared for
this packet. It's cause that buffer placed in on chip memory block
transfer to other endpoints.

Issue has been fixed for DEV_VER_V2 version of controller.

Signed-off-by: Pawel Laszczak 
---
 drivers/usb/cdns3/gadget.c | 338 -
 drivers/usb/cdns3/gadget.h |  13 ++
 2 files changed, 349 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
index 291f08be56fe..a42e832b3c6a 100644
--- a/drivers/usb/cdns3/gadget.c
+++ b/drivers/usb/cdns3/gadget.c
@@ -28,6 +28,32 @@
  *
  * Issue has been fixed in DEV_VER_V3 version of controller.
  *
+ * Work around 2:
+ * Controller for OUT endpoints has shared on-chip buffers for all incoming
+ * packets, including ep0out. It's FIFO buffer, so packets must be handle by 
DMA
+ * in correct order. If the first packet in the buffer will not be handled,
+ * then the following packets directed for other endpoints and  functions
+ * will be blocked.
+ * Additionally the packets directed to one endpoint can block entire on-chip
+ * buffers. In this case transfer to other endpoints also will blocked.
+ *
+ * To resolve this issue after raising the descriptor missing interrupt
+ * driver prepares internal usb_request object and use it to arm DMA transfer.
+ *
+ * The problematic situation was observed in case when endpoint has been 
enabled
+ * but no usb_request were queued. Driver try detects such endpoints and will
+ * use this workaround only for these endpoint.
+ *
+ * Driver use limited number of buffer. This number can be set by macro
+ * CDNS3_WA2_NUM_BUFFERS.
+ *
+ * Such blocking situation was observed on ACM gadget. For this function
+ * host send OUT data packet but ACM function is not prepared for this packet.
+ * It's cause that buffer placed in on chip memory block transfer to other
+ * endpoints.
+ *
+ * Issue has been fixed in DEV_VER_V2 version of controller.
+ *
  */
 
 #include 
@@ -99,6 +125,17 @@ struct cdns3_aligned_buf *cdns3_next_align_buf(struct 
list_head *list)
return list_first_entry_or_null(list, struct cdns3_aligned_buf, list);
 }
 
+/**
+ * cdns3_next_priv_request - returns next request from list
+ * @list: list containing requests
+ *
+ * Returns request or NULL if no requests in list
+ */
+struct cdns3_request *cdns3_next_priv_request(struct list_head *list)
+{
+   return list_first_entry_or_null(list, struct cdns3_request, list);
+}
+
 /**
  * select_ep - selects endpoint
  * @priv_dev:  extended gadget object
@@ -337,6 +374,254 @@ static int cdns3_start_all_request(struct cdns3_device 
*priv_dev,
return ret;
 }
 
+/*
+ * WA2: Set flag for all not ISOC OUT endpoints. If this flag is set
+ * driver try to detect whether endpoint need additional internal
+ * buffer for unblocking on-chip FIFO buffer. This flag will be cleared
+ * if before first DESCMISS interrupt the DMA will be armed.
+ */
+#define cdns3_wa2_enable_detection(priv_dev, ep_priv, reg) do { \
+   if (!priv_ep->dir && priv_ep->type != USB_ENDPOINT_XFER_ISOC) { \
+   priv_ep->flags |= EP_QUIRK_EXTRA_BUF_DET; \
+   (reg) |= EP_STS_EN_DESCMISEN; \
+   } } while (0)
+
+/**
+ * cdns3_wa2_descmiss_copy_data copy data from internal requests to
+ * request queued by class driver.
+ * @priv_ep: extended endpoint object
+ * @request: request object
+ */
+static void cdns3_wa2_descmiss_copy_data(struct cdns3_endpoint *priv_ep,
+struct usb_request *request)
+{
+   struct usb_request *descmiss_req;
+   struct cdns3_request *descmiss_priv_req;
+
+   while (!list_empty(&priv_ep->wa2_descmiss_req_list)) {
+   int chunk_end;
+   int length;
+
+   descmiss_priv_req =
+   
cdns3_next_priv_request(&priv_ep->wa2_descmiss_req_list);
+   descmiss_req = &descmiss_priv_req->request;
+
+   /* driver can't touch pending request */
+ 

[PATCH v10 3/6] usb:common Patch simplify usb_decode_set_clear_feature function.

2019-07-21 Thread Pawel Laszczak
Patch adds usb_decode_test_mode and usb_decode_device_feature functions,
which allow to make more readable and simplify the
usb_decode_set_clear_feature function.

Signed-off-by: Pawel Laszczak 
---
 drivers/usb/common/debug.c | 89 ++
 1 file changed, 43 insertions(+), 46 deletions(-)

diff --git a/drivers/usb/common/debug.c b/drivers/usb/common/debug.c
index d5a469bc67a3..60a9f70a0904 100644
--- a/drivers/usb/common/debug.c
+++ b/drivers/usb/common/debug.c
@@ -30,58 +30,55 @@ static void usb_decode_get_status(__u8 bRequestType, __u16 
wIndex,
}
 }
 
-static void usb_decode_set_clear_feature(__u8 bRequestType, __u8 bRequest,
-__u16 wValue, __u16 wIndex,
-char *str, size_t size)
+static const char *usb_decode_device_feature(u16 wValue)
+{
+   switch (wValue) {
+   case USB_DEVICE_SELF_POWERED:
+   return "Self Powered";
+   case USB_DEVICE_REMOTE_WAKEUP:
+   return "Remote Wakeup";
+   case USB_DEVICE_TEST_MODE:
+   return "Test Mode";
+   case USB_DEVICE_U1_ENABLE:
+   return "U1 Enable";
+   case USB_DEVICE_U2_ENABLE:
+   return "U2 Enable";
+   case USB_DEVICE_LTM_ENABLE:
+   return "LTM Enable";
+   default:
+   return "UNKNOWN";
+   }
+}
+
+static const char *usb_decode_test_mode(u16 wIndex)
+{
+   switch (wIndex) {
+   case TEST_J:
+   return ": TEST_J";
+   case TEST_K:
+   return ": TEST_K";
+   case TEST_SE0_NAK:
+   return ": TEST_SE0_NAK";
+   case TEST_PACKET:
+   return ": TEST_PACKET";
+   case TEST_FORCE_EN:
+   return ": TEST_FORCE_EN";
+   default:
+   return ": UNKNOWN";
+   }
+}
+
+static void usb_decode_set_clear_feature(__u8 bRequestType,
+__u8 bRequest, __u16 wValue,
+__u16 wIndex, char *str, size_t size)
 {
switch (bRequestType & USB_RECIP_MASK) {
case USB_RECIP_DEVICE:
snprintf(str, size, "%s Device Feature(%s%s)",
 bRequest == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set",
-({char *s;
-   switch (wValue) {
-   case USB_DEVICE_SELF_POWERED:
-   s = "Self Powered";
-   break;
-   case USB_DEVICE_REMOTE_WAKEUP:
-   s = "Remote Wakeup";
-   break;
-   case USB_DEVICE_TEST_MODE:
-   s = "Test Mode";
-   break;
-   case USB_DEVICE_U1_ENABLE:
-   s = "U1 Enable";
-   break;
-   case USB_DEVICE_U2_ENABLE:
-   s = "U2 Enable";
-   break;
-   case USB_DEVICE_LTM_ENABLE:
-   s = "LTM Enable";
-   break;
-   default:
-   s = "UNKNOWN";
-   } s; }),
+usb_decode_device_feature(wValue),
 wValue == USB_DEVICE_TEST_MODE ?
-({ char *s;
-   switch (wIndex) {
-   case TEST_J:
-   s = ": TEST_J";
-   break;
-   case TEST_K:
-   s = ": TEST_K";
-   break;
-   case TEST_SE0_NAK:
-   s = ": TEST_SE0_NAK";
-   break;
-   case TEST_PACKET:
-   s = ": TEST_PACKET";
-   break;
-   case TEST_FORCE_EN:
-   s = ": TEST_FORCE_EN";
-   break;
-   default:
-   s = ": UNKNOWN";
-   } s; }) : "");
+usb_decode_test_mode(wIndex) : "");
break;
case USB_RECIP_INTERFACE:
snprintf(str, size, "%s Interface Feature(%s)",
-- 
2.17.1



[PATCH v10 4/6] usb:common Simplify usb_decode_get_set_descriptor function.

2019-07-21 Thread Pawel Laszczak
Patch moves switch responsible for decoding descriptor type
outside snprintf. It improves code readability a little.

Signed-off-by: Pawel Laszczak 
---
 drivers/usb/common/debug.c | 113 +++--
 1 file changed, 58 insertions(+), 55 deletions(-)

diff --git a/drivers/usb/common/debug.c b/drivers/usb/common/debug.c
index 60a9f70a0904..92a986aeaa5d 100644
--- a/drivers/usb/common/debug.c
+++ b/drivers/usb/common/debug.c
@@ -105,62 +105,65 @@ static void usb_decode_get_set_descriptor(__u8 
bRequestType, __u8 bRequest,
  __u16 wValue, __u16 wIndex,
  __u16 wLength, char *str, size_t size)
 {
+   char *s;
+
+   switch (wValue >> 8) {
+   case USB_DT_DEVICE:
+   s = "Device";
+   break;
+   case USB_DT_CONFIG:
+   s = "Configuration";
+   break;
+   case USB_DT_STRING:
+   s = "String";
+   break;
+   case USB_DT_INTERFACE:
+   s = "Interface";
+   break;
+   case USB_DT_ENDPOINT:
+   s = "Endpoint";
+   break;
+   case USB_DT_DEVICE_QUALIFIER:
+   s = "Device Qualifier";
+   break;
+   case USB_DT_OTHER_SPEED_CONFIG:
+   s = "Other Speed Config";
+   break;
+   case USB_DT_INTERFACE_POWER:
+   s = "Interface Power";
+   break;
+   case USB_DT_OTG:
+   s = "OTG";
+   break;
+   case USB_DT_DEBUG:
+   s = "Debug";
+   break;
+   case USB_DT_INTERFACE_ASSOCIATION:
+   s = "Interface Association";
+   break;
+   case USB_DT_BOS:
+   s = "BOS";
+   break;
+   case USB_DT_DEVICE_CAPABILITY:
+   s = "Device Capability";
+   break;
+   case USB_DT_PIPE_USAGE:
+   s = "Pipe Usage";
+   break;
+   case USB_DT_SS_ENDPOINT_COMP:
+   s = "SS Endpoint Companion";
+   break;
+   case USB_DT_SSP_ISOC_ENDPOINT_COMP:
+   s = "SSP Isochronous Endpoint Companion";
+   break;
+   default:
+   s = "UNKNOWN";
+   break;
+   }
+
snprintf(str, size, "%s %s Descriptor(Index = %d, Length = %d)",
-bRequest == USB_REQ_GET_DESCRIPTOR ? "Get" : "Set",
-({ char *s;
-   switch (wValue >> 8) {
-   case USB_DT_DEVICE:
-   s = "Device";
-   break;
-   case USB_DT_CONFIG:
-   s = "Configuration";
-   break;
-   case USB_DT_STRING:
-   s = "String";
-   break;
-   case USB_DT_INTERFACE:
-   s = "Interface";
-   break;
-   case USB_DT_ENDPOINT:
-   s = "Endpoint";
-   break;
-   case USB_DT_DEVICE_QUALIFIER:
-   s = "Device Qualifier";
-   break;
-   case USB_DT_OTHER_SPEED_CONFIG:
-   s = "Other Speed Config";
-   break;
-   case USB_DT_INTERFACE_POWER:
-   s = "Interface Power";
-   break;
-   case USB_DT_OTG:
-   s = "OTG";
-   break;
-   case USB_DT_DEBUG:
-   s = "Debug";
-   break;
-   case USB_DT_INTERFACE_ASSOCIATION:
-   s = "Interface Association";
-   break;
-   case USB_DT_BOS:
-   s = "BOS";
-   break;
-   case USB_DT_DEVICE_CAPABILITY:
-   s = "Device Capability";
-   break;
-   case USB_DT_PIPE_USAGE:
-   s = "Pipe Usage";
-   break;
-   case USB_DT_SS_ENDPOINT_COMP:
-   s = "SS Endpoint Companion";
-   break;
-   case USB_DT_SSP_ISOC_ENDPOINT_COMP:
-   s = "SSP Isochronous Endpoint Companion";
-   break;
-   default:
-   s = "UNKNOWN";
-   break;
-   } s; }), wValue & 0xff, wLength);
+   bR

[PATCH v10 2/6] usb:common Separated decoding functions from dwc3 driver.

2019-07-21 Thread Pawel Laszczak
Patch moves some decoding functions from driver/usb/dwc3/debug.h driver
to driver/usb/common/debug.c file. These moved functions include:
dwc3_decode_get_status
dwc3_decode_set_clear_feature
dwc3_decode_set_address
dwc3_decode_get_set_descriptor
dwc3_decode_get_configuration
dwc3_decode_set_configuration
dwc3_decode_get_intf
dwc3_decode_set_intf
dwc3_decode_synch_frame
dwc3_decode_set_sel
dwc3_decode_set_isoch_delay
dwc3_decode_ctrl

These functions are used also in inroduced cdns3 driver.

All functions prefixes were changed from dwc3 to usb.
Also, function's parameters has been extended according to the name
of fields in standard SETUP packet.
Additionally, patch adds usb_decode_ctrl function to
include/linux/usb/ch9.h file.

Signed-off-by: Pawel Laszczak 
---
 drivers/usb/common/Makefile |   1 +
 drivers/usb/common/debug.c  | 268 
 drivers/usb/dwc3/debug.h| 252 -
 drivers/usb/dwc3/trace.h|   2 +-
 include/linux/usb/ch9.h |  27 
 5 files changed, 297 insertions(+), 253 deletions(-)
 create mode 100644 drivers/usb/common/debug.c

diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile
index 0a7c45e85481..76f3e80623db 100644
--- a/drivers/usb/common/Makefile
+++ b/drivers/usb/common/Makefile
@@ -5,6 +5,7 @@
 
 obj-$(CONFIG_USB_COMMON) += usb-common.o
 usb-common-y += common.o
+usb-common-$(CONFIG_TRACING) += debug.o
 usb-common-$(CONFIG_USB_LED_TRIG) += led.o
 
 obj-$(CONFIG_USB_OTG_FSM) += usb-otg-fsm.o
diff --git a/drivers/usb/common/debug.c b/drivers/usb/common/debug.c
new file mode 100644
index ..d5a469bc67a3
--- /dev/null
+++ b/drivers/usb/common/debug.c
@@ -0,0 +1,268 @@
+// SPDX-License-Identifier: GPL-2.0
+/**
+ * Common USB debugging functions
+ *
+ * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com
+ *
+ * Authors: Felipe Balbi ,
+ * Sebastian Andrzej Siewior 
+ */
+
+#include 
+
+static void usb_decode_get_status(__u8 bRequestType, __u16 wIndex,
+ __u16 wLength, char *str, size_t size)
+{
+   switch (bRequestType & USB_RECIP_MASK) {
+   case USB_RECIP_DEVICE:
+   snprintf(str, size, "Get Device Status(Length = %d)", wLength);
+   break;
+   case USB_RECIP_INTERFACE:
+   snprintf(str, size,
+"Get Interface Status(Intf = %d, Length = %d)",
+wIndex, wLength);
+   break;
+   case USB_RECIP_ENDPOINT:
+   snprintf(str, size, "Get Endpoint Status(ep%d%s)",
+wIndex & ~USB_DIR_IN,
+wIndex & USB_DIR_IN ? "in" : "out");
+   break;
+   }
+}
+
+static void usb_decode_set_clear_feature(__u8 bRequestType, __u8 bRequest,
+__u16 wValue, __u16 wIndex,
+char *str, size_t size)
+{
+   switch (bRequestType & USB_RECIP_MASK) {
+   case USB_RECIP_DEVICE:
+   snprintf(str, size, "%s Device Feature(%s%s)",
+bRequest == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set",
+({char *s;
+   switch (wValue) {
+   case USB_DEVICE_SELF_POWERED:
+   s = "Self Powered";
+   break;
+   case USB_DEVICE_REMOTE_WAKEUP:
+   s = "Remote Wakeup";
+   break;
+   case USB_DEVICE_TEST_MODE:
+   s = "Test Mode";
+   break;
+   case USB_DEVICE_U1_ENABLE:
+   s = "U1 Enable";
+   break;
+   case USB_DEVICE_U2_ENABLE:
+   s = "U2 Enable";
+   break;
+   case USB_DEVICE_LTM_ENABLE:
+   s = "LTM Enable";
+   break;
+   default:
+   s = "UNKNOWN";
+   } s; }),
+wValue == USB_DEVICE_TEST_MODE ?
+({ char *s;
+   switch (wIndex) {
+   case TEST_J:
+   s = ": TEST_J";
+   break;
+   case TEST_K:
+   s = ": TEST_K";
+   break;
+   case TEST_SE0_NAK:
+  

[PATCH v10 0/6] Introduced new Cadence USBSS DRD Driver.

2019-07-21 Thread Pawel Laszczak
This patch introduce new Cadence USBSS DRD driver to linux kernel.

The Cadence USBSS DRD Controller is a highly configurable IP Core which
can be instantiated as Dual-Role Device (DRD), Peripheral Only and
Host Only (XHCI)configurations.

The current driver has been validated with FPGA burned. We have support
for PCIe bus, which is used on FPGA prototyping.

The host side of USBSS-DRD controller is compliance with XHCI
specification, so it works with standard XHCI Linux driver.

Change since v9:
- Removed duplicated cdns3_mode array. The same array is defined in 
  drivers/usb/common/common.c. It required some change in common API.
  the appropirate patch was posted separately.
- Replaced generic cdns3_dbg with serparate trace events.
- Replaced cdns3_handshake with readl_poll_timeout_atomic function
- Added threaded irq handler for handling DRD/OTG irq instead workqueue.
- Removed support for debug_disable. It's no longer neeeded. 
- Moved mode attribute under usb root.
- Changed DRD switching role implementation. This version of the driver uses
  common roles interface.
- removed not implemented cdns3_idle_role_start and cdns3_exit_role_start.
- Added support for DRD/OTG irq for Cadence platform.
- Fixed bug in cdns3_mode_show/cdns3_mode_write with changing mode. There was a 
problem with switching mode. 
- Added support for PM suspend/resume.
- Simplified cdns3/Makefile file.

Change since v8:
- Fixed compilation error by moving drivers/usb/gadget/debug.c back to
  drivers/usb/common/debug.c. The previous version caused compilation
  error when dwc3 or cdns3 driver was built-in kernel and libcomposite
  was built as module.
 
Change since v7:
- Updated dt-binding.
- Simplified debugfs file as suggested by Heikki Krogerus.
- Changed some dev_info to dev_dbg.
- Added support for additional PHY. Now driver can use both USB2 PHY
  and USB3 PHY.
- Fixed issue in algorithm checking the number of allocated on-chip buffers.
- Moved common code form drivers/usb/common/debug.c to
  drivers/usb/gadget/debug.c.
- Removed warning generated by sh4-linux-gcc compiler for trace.h file.
- L1 issue: moved resuming after setting DRDY. It should protect against 
  potential racing.
- LPM packet acknowledge has been disabled during control transfer.
- Aded setting AXI Non-Secure mode in DMA_AXI_CTRL register. 

Change since v6:
- Fixed issue with L1 support. Controller has issue with hardware 
  resuming from L1 state. It was fixed in software. 
- Fixed issues related with Transfer Ring Size equal 2. 
- Fixed issue with removing cdns3.ko module. Issue appeared on the latest 
  version of kernel.
- Added separate interrupt resources for host, device and otg. It was 
  added mainly for compatibility with TI J721e platforms. 
- Added enabling ISO OUT just before arming endpoint. It's recommended by 
  controller specification.
- Added support for 0x0002450d controller version. This version allows to set 
  DMULT mode per endpoint. It also fixes WA1 issue.
- Added support for separate interrupt line for Device and OTG/DRD.
- Removed drd_update_mode from drd_init, 'desired_dr_mode' is not yet correctly
  set based on enabled drivers and dr_mode in DT.
- Added phy power on/off.
- Added setting dma and coherent mask to 32-bits, because controller can do
  only 32-bit access.
- Added Idle state for Type-C for platform TI J721e as suggested by Roger. 
- Improved the flow according with Figure 24 from Software OTG Control user
  guide as sugested by Roger.

Change since v5:
- Fixed controller issue with handling SETUP that has occurred on 0x0002450C
  controller version. In some case EP_STS_SETUP is reported but SETUP
  packet has not been copied yet to system memory. This bug caused that
  driver started handling the previous SETUP packet.
- Added handling ZLP for EP0.
- Removed unused cdns3_gadget_ep0_giveback function.
- Fixed issue with disabling endpoint. Added waiting for clearing EP_STS_DBUSY
  bit between disabling endpoint and calling EP_CMD_EPRST command.
  EP_CMD_EPRST command can be called only when DMA is stopped.
- Fixed issue: EP_CFG_TDL_CHK is currently supported only for OUT direction,
  It was enabled for both IN/OUT direction.
- Improved resetting of interrupt in cdns3_device_irq_handler.
- Fixed issue with ISOC IN transfer in cdns3_ep_run_transfer function. In some
  cases driver set incorrect Cycle Bit in TRBs.
- Fixed issue in function cdns3_ep_onchip_buffer_reserve. Driver assigned 
  incorrect value to priv_dev->out_mem_is_allocated field.

Change since v5:
- fixed compilation error.

Changes since v4:
- fixed issue: with choosing incorrect dr_mode in cdns3_core_init_role.
- speed up DRD timings by adding an appropriate entry to OTGSIMULATE
  register in cdns3_drd_init function.
- added detecting transition to DEV_IDLE/H_IDLE state instead using
  usleep_range in cdns3_drd_switch_gadget and cdns3_drd_switch_host functions.
- fixed issue with setting incorrect burst and mult field during endpoint
  configurati

[PATCH v10 1/6] dt-bindings: add binding for USBSS-DRD controller.

2019-07-21 Thread Pawel Laszczak
This patch aim at documenting USB related dt-bindings for the
Cadence USBSS-DRD controller.

Signed-off-by: Pawel Laszczak 
Reviewed-by: Rob Herring 
---
 .../devicetree/bindings/usb/cdns-usb3.txt | 45 +++
 1 file changed, 45 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/cdns-usb3.txt

diff --git a/Documentation/devicetree/bindings/usb/cdns-usb3.txt 
b/Documentation/devicetree/bindings/usb/cdns-usb3.txt
new file mode 100644
index ..b7dc606d37b5
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/cdns-usb3.txt
@@ -0,0 +1,45 @@
+Binding for the Cadence USBSS-DRD controller
+
+Required properties:
+ - reg: Physical base address and size of the controller's register areas.
+Controller has 3 different regions:
+- HOST registers area
+- DEVICE registers area
+- OTG/DRD registers area
+ - reg-names - register memory area names:
+   "xhci" - for HOST registers space
+   "dev" - for DEVICE registers space
+   "otg" - for OTG/DRD registers space
+ - compatible: Should contain: "cdns,usb3"
+ - interrupts: Interrupts used by cdns3 controller:
+   "host" - interrupt used by XHCI driver.
+   "peripheral" - interrupt used by device driver
+   "otg" - interrupt used by DRD/OTG  part of driver
+
+Optional properties:
+ - maximum-speed : valid arguments are "super-speed", "high-speed" and
+   "full-speed"; refer to usb/generic.txt
+ - dr_mode: Should be one of "host", "peripheral" or "otg".
+ - phys: reference to the USB PHY
+ - phy-names: from the *Generic PHY* bindings;
+   Supported names are:
+   - cdns3,usb2-phy
+   - cdns3,usb3-phy
+
+ - cdns,on-chip-buff-size : size of memory intended as internal memory for 
endpoints
+   buffers expressed in KB
+
+Example:
+   usb@f300 {
+   compatible = "cdns,usb3";
+   interrupts = ,
+   ,
+   ;
+   interrupt-names = "host", "peripheral", "otg";
+   reg = <0xf300 0x1>, /* memory area for HOST 
registers */
+   <0xf301 0x1>,   /* memory area for DEVICE 
registers */
+   <0xf302 0x1>;   /* memory area for OTG/DRD 
registers */
+   reg-names = "xhci", "dev", "otg";
+   phys = <&usb2_phy>, <&usb3_phy>;
+   phy-names = "cdns3,usb2-phy", "cnds3,usb3-phy";
+   };
-- 
2.17.1



Re: [PATCH v10 0/6] Introduced new Cadence USBSS DRD Driver.

2019-07-21 Thread Pavel Machek
Hi!

> This patch introduce new Cadence USBSS DRD driver to linux kernel.
> 
> The Cadence USBSS DRD Controller is a highly configurable IP Core which
> can be instantiated as Dual-Role Device (DRD), Peripheral Only and
> Host Only (XHCI)configurations.

I see you are using debugfs to select between DRD, peripheral-onlyh and XHCI... 

Is that good idea?

This is at least 3rd driver needing that capability, and debugfs does not
sound like a good match.

Pavel


Re: [PATCH v10 2/6] usb:common Separated decoding functions from dwc3 driver.

2019-07-21 Thread Joe Perches
On Sun, 2019-07-21 at 19:32 +0100, Pawel Laszczak wrote:
> Patch moves some decoding functions from driver/usb/dwc3/debug.h driver
> to driver/usb/common/debug.c file. These moved functions include:
[]
> diff --git a/drivers/usb/common/debug.c b/drivers/usb/common/debug.c
[]
> +static void usb_decode_set_clear_feature(__u8 bRequestType, __u8 bRequest,
> +  __u16 wValue, __u16 wIndex,
> +  char *str, size_t size)

It's probably not necessary to use Hungarian
when moving these functions into generic code.

> +{
> + switch (bRequestType & USB_RECIP_MASK) {
> + case USB_RECIP_DEVICE:
> + snprintf(str, size, "%s Device Feature(%s%s)",
> +  bRequest == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set",
> +  ({char *s;
> + switch (wValue) {
> + case USB_DEVICE_SELF_POWERED:
> + s = "Self Powered";
> + break;
> + case USB_DEVICE_REMOTE_WAKEUP:
> + s = "Remote Wakeup";
> + break;
> + case USB_DEVICE_TEST_MODE:
> + s = "Test Mode";
> + break;
> + case USB_DEVICE_U1_ENABLE:
> + s = "U1 Enable";
> + break;
> + case USB_DEVICE_U2_ENABLE:
> + s = "U2 Enable";
> + break;
> + case USB_DEVICE_LTM_ENABLE:
> + s = "LTM Enable";
> + break;
> + default:
> + s = "UNKNOWN";
> + } s; }),
> +  wValue == USB_DEVICE_TEST_MODE ?
> +  ({ char *s;
> + switch (wIndex) {
> + case TEST_J:
> + s = ": TEST_J";
> + break;
> + case TEST_K:
> + s = ": TEST_K";
> + break;
> + case TEST_SE0_NAK:
> + s = ": TEST_SE0_NAK";
> + break;
> + case TEST_PACKET:
> + s = ": TEST_PACKET";
> + break;
> + case TEST_FORCE_EN:
> + s = ": TEST_FORCE_EN";
> + break;
> + default:
> + s = ": UNKNOWN";
> + } s; }) : "");

I always find this sort of embedded switch/case char *
statement expressions difficult to read and think it's
better to use separate lookup functions.

I would much prefer something like:

static const char *usb_device_mode_desc(u16 mode)
{
switch (mode) {
case USB_DEVICE_SELF_POWERED:
return "Self Powered";
case USB_DEVICE_REMOTE_WAKEUP:
return "Remote Wakeup";
case USB_DEVICE_TEST_MODE:
return "Test Mode";
case USB_DEVICE_U1_ENABLE:
return "U1 Enable";
case USB_DEVICE_U2_ENABLE:
return "U2 Enable";
case USB_DEVICE_LTM_ENABLE:
return "LTM Enable";
}
return "UNKNOWN";
}

snprintf(str, size, "%s Device Feature(%s%s)",
>bRequest == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set",
 usb_device_mode_desc(wValue),
 etc...);


etc...





Re: [PATCH v10 3/6] usb:common Patch simplify usb_decode_set_clear_feature function.

2019-07-21 Thread Joe Perches
On Sun, 2019-07-21 at 19:32 +0100, Pawel Laszczak wrote:
> Patch adds usb_decode_test_mode and usb_decode_device_feature functions,
> which allow to make more readable and simplify the
> usb_decode_set_clear_feature function.

  I need to read entire patch series before
commenting more I guess...

> Signed-off-by: Pawel Laszczak 
> ---
>  drivers/usb/common/debug.c | 89 ++
>  1 file changed, 43 insertions(+), 46 deletions(-)
> 
> diff --git a/drivers/usb/common/debug.c b/drivers/usb/common/debug.c
[]
> +static const char *usb_decode_device_feature(u16 wValue)

I believe this is still unnecessary hungarian.

> +{
> + switch (wValue) {
> + case USB_DEVICE_SELF_POWERED:
> + return "Self Powered";
> + case USB_DEVICE_REMOTE_WAKEUP:
> + return "Remote Wakeup";
> + case USB_DEVICE_TEST_MODE:
> + return "Test Mode";
> + case USB_DEVICE_U1_ENABLE:
> + return "U1 Enable";
> + case USB_DEVICE_U2_ENABLE:
> + return "U2 Enable";
> + case USB_DEVICE_LTM_ENABLE:
> + return "LTM Enable";
> + default:
> + return "UNKNOWN";
> + }
> +}

But yeah, exactly like this... ;)




typec class users

2019-07-21 Thread Peter Bowen
The typec class claims to provide comprehensive info about ports,
cables, and plugs.  While there is code to register cables and plugs, I
can't find any users of these APIs.

I'd like to write some userland tools that help debug issues with Type-C
(e.g. wrong cable type).  However none of drivers seem to use the typec
cable or plug interface.  Are there any known drivers that use these APIs?

Thanks,
Peter


Re: [PATCH v10 2/6] usb:common Separated decoding functions from dwc3 driver.

2019-07-21 Thread Alan Stern
On Sun, 21 Jul 2019, Joe Perches wrote:

> On Sun, 2019-07-21 at 19:32 +0100, Pawel Laszczak wrote:
> > Patch moves some decoding functions from driver/usb/dwc3/debug.h driver
> > to driver/usb/common/debug.c file. These moved functions include:
> []
> > diff --git a/drivers/usb/common/debug.c b/drivers/usb/common/debug.c
> []
> > +static void usb_decode_set_clear_feature(__u8 bRequestType, __u8 bRequest,
> > +__u16 wValue, __u16 wIndex,
> > +char *str, size_t size)
> 
> It's probably not necessary to use Hungarian
> when moving these functions into generic code.

In fact, these are the well known and commonly accepted names for these
data values, as given in the USB specification and used in many other
places in the Linux USB stack.  See for example the definition of
struct usb_ctrlrequest in include/uapi/linux/usb/ch9.h.

Changing them here would only make the code less readable.

Alan Stern



Re: [PATCH v10 2/6] usb:common Separated decoding functions from dwc3 driver.

2019-07-21 Thread Joe Perches
On Sun, 2019-07-21 at 16:45 -0400, Alan Stern wrote:
> On Sun, 21 Jul 2019, Joe Perches wrote:
> 
> > On Sun, 2019-07-21 at 19:32 +0100, Pawel Laszczak wrote:
> > > Patch moves some decoding functions from driver/usb/dwc3/debug.h driver
> > > to driver/usb/common/debug.c file. These moved functions include:
> > []
> > > diff --git a/drivers/usb/common/debug.c b/drivers/usb/common/debug.c
> > []
> > > +static void usb_decode_set_clear_feature(__u8 bRequestType, __u8 
> > > bRequest,
> > > +__u16 wValue, __u16 wIndex,
> > > +char *str, size_t size)
> > 
> > It's probably not necessary to use Hungarian
> > when moving these functions into generic code.
> 
> In fact, these are the well known and commonly accepted names for these
> data values, as given in the USB specification and used in many other
> places in the Linux USB stack.  See for example the definition of
> struct usb_ctrlrequest in include/uapi/linux/usb/ch9.h.
>
> Changing them here would only make the code less readable.

Perhaps, but these have already been converted from
the __le types, so perhaps not.  It might be more
sensible to convert the __u16 uses to u16 and avoid
the __le16 names.

cheers, Joe