[PATCH 1/5] usb: xhci: dbc: make DbC modular, introducing dbc_function structure

2019-06-06 Thread Prabhat Chand Pandey
This patch introduces the dbc_function structure as a first step in
making DbC modular and capable in exposing different user interfaces using
different "functions", which may implement the callbacks exposed here
according to the driver's need.

Only one "function" can be registered at a time.
The generic way to enable a DbC function would be, using sys-fs:

Locate the directory for PCI enumerated XHCI host controller in the
sysfs path.
e.g.: cd /sys/bus/pci/devices/:00:14.0
$ echo "enable" > dbc

This is done AFTER the function is selected at build time. Only 1 function
can be selected at a time.

Signed-off-by: Rajaram Regupathy 
Signed-off-by: Abhilash K V 
Signed-off-by: Prabhat Chand Pandey 
Acked-by: Mathias Nyman 
---
 drivers/usb/host/xhci-dbgcap.c | 159 ++---
 drivers/usb/host/xhci-dbgcap.h |  32 ++-
 2 files changed, 138 insertions(+), 53 deletions(-)

diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c
index 52e32644a4b2..96adc53b0fdb 100644
--- a/drivers/usb/host/xhci-dbgcap.c
+++ b/drivers/usb/host/xhci-dbgcap.c
@@ -9,11 +9,14 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "xhci.h"
 #include "xhci-trace.h"
 #include "xhci-dbgcap.h"
 
+static struct dbc_function *dbc_registered_func;
+
 static inline void *
 dbc_dma_alloc_coherent(struct xhci_hcd *xhci, size_t size,
   dma_addr_t *dma_handle, gfp_t flags)
@@ -35,41 +38,42 @@ dbc_dma_free_coherent(struct xhci_hcd *xhci, size_t size,
  size, cpu_addr, dma_handle);
 }
 
-static u32 xhci_dbc_populate_strings(struct dbc_str_descs *strings)
+static u32 xhci_dbc_populate_strings(struct dbc_str_descs *strings,
+   struct dbc_function *func)
 {
struct usb_string_descriptor*s_desc;
u32 string_length;
 
/* Serial string: */
s_desc = (struct usb_string_descriptor *)strings->serial;
-   utf8s_to_utf16s(DBC_STRING_SERIAL, strlen(DBC_STRING_SERIAL),
+   utf8s_to_utf16s(func->string.serial, strlen(func->string.serial),
UTF16_LITTLE_ENDIAN, (wchar_t *)s_desc->wData,
DBC_MAX_STRING_LENGTH);
 
-   s_desc->bLength = (strlen(DBC_STRING_SERIAL) + 1) * 2;
+   s_desc->bLength = (strlen(func->string.serial) + 1) * 2;
s_desc->bDescriptorType = USB_DT_STRING;
string_length   = s_desc->bLength;
string_length   <<= 8;
 
/* Product string: */
s_desc = (struct usb_string_descriptor *)strings->product;
-   utf8s_to_utf16s(DBC_STRING_PRODUCT, strlen(DBC_STRING_PRODUCT),
+   utf8s_to_utf16s(func->string.product, strlen(func->string.product),
UTF16_LITTLE_ENDIAN, (wchar_t *)s_desc->wData,
DBC_MAX_STRING_LENGTH);
 
-   s_desc->bLength = (strlen(DBC_STRING_PRODUCT) + 1) * 2;
+   s_desc->bLength = (strlen(func->string.product) + 1) * 2;
s_desc->bDescriptorType = USB_DT_STRING;
string_length   += s_desc->bLength;
string_length   <<= 8;
 
/* Manufacture string: */
s_desc = (struct usb_string_descriptor *)strings->manufacturer;
-   utf8s_to_utf16s(DBC_STRING_MANUFACTURER,
-   strlen(DBC_STRING_MANUFACTURER),
+   utf8s_to_utf16s(func->string.manufacturer,
+   strlen(func->string.manufacturer),
UTF16_LITTLE_ENDIAN, (wchar_t *)s_desc->wData,
DBC_MAX_STRING_LENGTH);
 
-   s_desc->bLength = (strlen(DBC_STRING_MANUFACTURER) + 1) * 2;
+   s_desc->bLength = (strlen(func->string.manufacturer) + 1) * 2;
s_desc->bDescriptorType = USB_DT_STRING;
string_length   += s_desc->bLength;
string_length   <<= 8;
@@ -84,7 +88,9 @@ static u32 xhci_dbc_populate_strings(struct dbc_str_descs 
*strings)
return string_length;
 }
 
-static void xhci_dbc_init_contexts(struct xhci_hcd *xhci, u32 string_length)
+static void xhci_dbc_init_contexts(struct xhci_hcd *xhci,
+   struct dbc_function *func,
+   u32 string_length)
 {
struct xhci_dbc *dbc;
struct dbc_info_context *info;
@@ -124,10 +130,10 @@ static void xhci_dbc_init_contexts(struct xhci_hcd *xhci, 
u32 string_length)
/* Set DbC context and info registers: */
xhci_write_64(xhci, dbc->ctx->dma, &dbc->regs->dccp);
 
-   dev_info = cpu_to_le32((DBC_VENDOR_ID << 16) | DBC_PROTOCOL);
+   dev_info = cpu_to_le32((func->vid << 16) | func->protocol);
writel(dev_info, &dbc->

[PATCH 4/5] usb: xhci: dbc: Add a dbc raw driver to provide a raw interface on DbC

2019-06-06 Thread Prabhat Chand Pandey
From: Abhilash K V 

This patch provides a raw device interface on xhci Debug capability.
This abstracts dbc functionality to user space inorder to facilitate
various frameworks to utilize xhci debug capability.

It helps to render the target as an usb debug class device on host and
establish an usb connection by providing two bulk endpoints.

[don't dynamically allocate tiny space for name only -Mathias]
Signed-off-by: Rajaram Regupathy 
Signed-off-by: Prabhat Chand Pandey 
Signed-off-by: Abhilash K V 
Acked-by: Mathias Nyman 
---
 drivers/usb/host/Kconfig   |   9 +
 drivers/usb/host/Makefile  |   1 +
 drivers/usb/host/xhci-dbgraw.c | 365 +
 3 files changed, 375 insertions(+)
 create mode 100644 drivers/usb/host/xhci-dbgraw.c

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index c29ed8a61dcb..0f801977cd1e 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -48,6 +48,15 @@ config USB_XHCI_DBGCAP_TTY
  debug capability. This will expose a /dev/ttyDBC* device node on 
device
  which may be used by the usb-debug driver on the debug host.
  If unsure, say 'N'.
+
+config USB_XHCI_DBGCAP_RAW
+   tristate "xHCI DbC raw driver support"
+   depends on USB_XHCI_HCD && USB_XHCI_DBGCAP
+   help
+ Say 'Y' to enable the support for the raw driver interface to xHCI
+ debug capability. This will expose a device node corresponding to
+ 1 bulk IN and 1 bulk OUT endpoints to be presented to debug host.
+ If unsure, say 'N'.
 endchoice
 
 config USB_XHCI_PCI
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index b21b0ea9e966..a4aee6a5daf0 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -20,6 +20,7 @@ ifneq ($(CONFIG_USB_XHCI_DBGCAP), )
 endif
 
 obj-$(CONFIG_USB_XHCI_DBGCAP_TTY) += xhci-dbgtty.o
+obj-$(CONFIG_USB_XHCI_DBGCAP_RAW) += xhci-dbgraw.o
 
 ifneq ($(CONFIG_USB_XHCI_MTK), )
xhci-hcd-y += xhci-mtk-sch.o
diff --git a/drivers/usb/host/xhci-dbgraw.c b/drivers/usb/host/xhci-dbgraw.c
new file mode 100644
index ..f7ca4b089dbd
--- /dev/null
+++ b/drivers/usb/host/xhci-dbgraw.c
@@ -0,0 +1,365 @@
+// SPDX-License-Identifier: GPL-2.0+
+/**
+ * Raw DbC for xHCI debug capability
+ *
+ * Copyright (C) 2019 Intel Corporation
+ *
+ * Author: Rajaram Regupathy 
+ * Author: Abhilash K V 
+ * Author: Prabhat Chand Pandey 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "xhci.h"
+#include "xhci-dbgcap.h"
+
+#define DBC_XHCI_MINORS 8
+#define DBC_STR_FUNC_RAW"RAW"
+#define DBC_RAW_BULK_BUFFER_SIZE  (SZ_64K)
+
+static DEFINE_IDR(dbc_minors);
+
+struct dbc_dev {
+   struct mutex dev_excl;
+   struct mutex read_excl;
+   struct mutex write_excl;
+
+   wait_queue_head_t read_wq;
+   wait_queue_head_t write_wq;
+
+   int error;
+   bool in_use;
+   char name[16];
+   struct xhci_dbc *dbc;
+   struct miscdevice misc_dev;
+};
+
+static void xhci_dbc_free_req(struct dbc_ep *dep, struct dbc_request *req)
+{
+   kfree(req->buf);
+   dbc_free_request(dep, req);
+}
+
+struct dbc_request *xhci_dbc_alloc_requests(struct dbc_ep *dep,
+   void (*fn)(struct xhci_hcd *, struct dbc_request *))
+{
+   struct dbc_request *req;
+
+   req = dbc_alloc_request(dep, GFP_KERNEL);
+   if (!req)
+   return req;
+
+   req->length = DBC_RAW_BULK_BUFFER_SIZE;
+   req->buf = kmalloc(req->length, GFP_KERNEL);
+   if (!req->buf)
+   xhci_dbc_free_req(dep, req);
+
+   req->complete = fn;
+
+   return req;
+}
+
+static void dbc_complete_in(struct xhci_hcd *xhci,
+   struct dbc_request *req)
+{
+   struct xhci_dbc *dbc = (struct xhci_dbc *) xhci->dbc;
+   struct dbc_dev *dev = (struct dbc_dev *) dbc->func_priv;
+
+   if (req->status)
+   dev->error = req->status;
+
+   wake_up(&dev->write_wq);
+}
+
+static void dbc_complete_out(struct xhci_hcd *xhci,
+   struct dbc_request *req)
+{
+   struct xhci_dbc *dbc = (struct xhci_dbc *) xhci->dbc;
+   struct dbc_dev *dev = (struct dbc_dev *) dbc->func_priv;
+
+   if (req->status)
+   dev->error = req->status;
+
+   wake_up(&dev->read_wq);
+}
+
+static ssize_t dbc_read(struct file *fp, char __user *buf,
+   size_t count, loff_t *pos)
+{
+   int status = 0;
+   struct dbc_dev *dev = (struct dbc_dev *) fp->private_data;
+   struct xhci_dbc   *dbc = dev->dbc;
+   struct dbc_request *req;
+   struct dbc_port   *port = &dbc->port;
+   int r = count, xfer;
+   int ret;
+
+   if (dbc->state != DS_CONFIGURED)
+   return -EAGAIN;
+
+   

[PATCH 0/5] usb: xhci: dbc: make modular and add RAW interface

2019-06-06 Thread Prabhat Chand Pandey
This patch-set adds the following features to dbc driver:

- show the active dbc function and dbc descriptors, allowing
  user space to dynamically modify the descriptors.

- modularize dbc core to enable it to expose different function
  interfaces, till now only TTY interface was exposed.

- use the new framework to expose RAW interface that can be
  used by any user-space application to directly read from and 
  write into dbc bulk end-points.


Abhilash K V (1):
  usb: xhci: dbc: Add a dbc raw driver to provide a raw interface on DbC

K V, Abhilash (1):
  usb: xhci: dbc: Provide sysfs option to configure dbc descriptors

Prabhat Chand Pandey (3):
  usb: xhci: dbc: make DbC modular, introducing dbc_function structure
  usb: xhci: dbc: DbC TTY driver to use new interface
  usb: xhci: dbc: Document describe about dbc raw interface

 .../testing/sysfs-bus-pci-drivers-xhci_hcd| 112 
 Documentation/usb/dbc_raw.rst | 136 +
 Documentation/usb/index.rst   |  16 +
 drivers/usb/host/Kconfig  |  24 +-
 drivers/usb/host/Makefile |   5 +-
 drivers/usb/host/xhci-dbgcap.c| 498 --
 drivers/usb/host/xhci-dbgcap.h|  36 +-
 drivers/usb/host/xhci-dbgraw.c| 365 +
 drivers/usb/host/xhci-dbgtty.c|  81 ++-
 9 files changed, 1206 insertions(+), 67 deletions(-)
 create mode 100644 Documentation/usb/dbc_raw.rst
 create mode 100644 Documentation/usb/index.rst
 create mode 100644 drivers/usb/host/xhci-dbgraw.c

-- 
2.21.0



[PATCH 2/5] usb: xhci: dbc: DbC TTY driver to use new interface

2019-06-06 Thread Prabhat Chand Pandey
Change DbC TTY driver to use the new modular interface exposed by the DbC
core. This will allow other function drivers with a different interface
also to use DbC.

[no need to add running number to tty driver name, remove it. -Mathias]
Signed-off-by: Rajaram Regupathy 
Signed-off-by: Abhilash K V 
Signed-off-by: Prabhat Chand Pandey 
Acked-by: Mathias Nyman 
---
 drivers/usb/host/Kconfig   | 15 ++-
 drivers/usb/host/Makefile  |  4 +-
 drivers/usb/host/xhci-dbgcap.h |  4 --
 drivers/usb/host/xhci-dbgtty.c | 81 ++
 4 files changed, 90 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index d809671c5fea..c29ed8a61dcb 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -30,13 +30,26 @@ config USB_XHCI_HCD
 if USB_XHCI_HCD
 config USB_XHCI_DBGCAP
bool "xHCI support for debug capability"
-   depends on TTY
---help---
  Say 'Y' to enable the support for the xHCI debug capability. Make
  sure that your xHCI host supports the extended debug capability and
  you want a TTY serial device based on the xHCI debug capability
  before enabling this option. If unsure, say 'N'.
 
+choice
+   prompt "Select function for debug capability"
+   depends on USB_XHCI_DBGCAP
+
+config USB_XHCI_DBGCAP_TTY
+   tristate "xHCI DbC tty driver support"
+   depends on USB_XHCI_HCD && USB_XHCI_DBGCAP && TTY
+   help
+ Say 'Y' to enable the support for the tty driver interface to xHCI
+ debug capability. This will expose a /dev/ttyDBC* device node on 
device
+ which may be used by the usb-debug driver on the debug host.
+ If unsure, say 'N'.
+endchoice
+
 config USB_XHCI_PCI
tristate
depends on USB_PCI
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 84514f71ae44..b21b0ea9e966 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -16,9 +16,11 @@ xhci-hcd-y += xhci-ring.o xhci-hub.o xhci-dbg.o
 xhci-hcd-y += xhci-trace.o
 
 ifneq ($(CONFIG_USB_XHCI_DBGCAP), )
-   xhci-hcd-y += xhci-dbgcap.o xhci-dbgtty.o
+   xhci-hcd-y += xhci-dbgcap.o
 endif
 
+obj-$(CONFIG_USB_XHCI_DBGCAP_TTY) += xhci-dbgtty.o
+
 ifneq ($(CONFIG_USB_XHCI_MTK), )
xhci-hcd-y += xhci-mtk-sch.o
 endif
diff --git a/drivers/usb/host/xhci-dbgcap.h b/drivers/usb/host/xhci-dbgcap.h
index b4d5622a9030..302e6ca72370 100644
--- a/drivers/usb/host/xhci-dbgcap.h
+++ b/drivers/usb/host/xhci-dbgcap.h
@@ -218,10 +218,6 @@ static inline struct dbc_ep *get_out_ep(struct xhci_hcd 
*xhci)
 #ifdef CONFIG_USB_XHCI_DBGCAP
 int xhci_dbc_init(struct xhci_hcd *xhci);
 void xhci_dbc_exit(struct xhci_hcd *xhci);
-int xhci_dbc_tty_register_driver(struct xhci_hcd *xhci);
-void xhci_dbc_tty_unregister_driver(void);
-int xhci_dbc_tty_register_device(struct xhci_hcd *xhci);
-void xhci_dbc_tty_unregister_device(struct xhci_hcd *xhci);
 struct dbc_request *dbc_alloc_request(struct dbc_ep *dep, gfp_t gfp_flags);
 void xhci_dbc_flush_reqests(struct xhci_dbc *dbc);
 void dbc_free_request(struct dbc_ep *dep, struct dbc_request *req);
diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c
index aff79ff5aba4..f75a95006c51 100644
--- a/drivers/usb/host/xhci-dbgtty.c
+++ b/drivers/usb/host/xhci-dbgtty.c
@@ -7,13 +7,15 @@
  * Author: Lu Baolu 
  */
 
+#include 
 #include 
 #include 
 #include 
-
 #include "xhci.h"
 #include "xhci-dbgcap.h"
 
+#define DBC_STR_FUNC_TTY"TTY"
+
 static unsigned int
 dbc_send_packet(struct dbc_port *port, char *packet, unsigned int size)
 {
@@ -279,12 +281,11 @@ static const struct tty_operations dbc_tty_ops = {
.unthrottle = dbc_tty_unthrottle,
 };
 
-static struct tty_driver *dbc_tty_driver;
-
-int xhci_dbc_tty_register_driver(struct xhci_hcd *xhci)
+static int xhci_dbc_tty_register_driver(struct xhci_hcd *xhci)
 {
int status;
struct xhci_dbc *dbc = xhci->dbc;
+   struct tty_driver   *dbc_tty_driver;
 
dbc_tty_driver = tty_alloc_driver(1, TTY_DRIVER_REAL_RAW |
  TTY_DRIVER_DYNAMIC_DEV);
@@ -296,7 +297,6 @@ int xhci_dbc_tty_register_driver(struct xhci_hcd *xhci)
 
dbc_tty_driver->driver_name = "dbc_serial";
dbc_tty_driver->name = "ttyDBC";
-
dbc_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
dbc_tty_driver->subtype = SERIAL_TYPE_NORMAL;
dbc_tty_driver->init_termios = tty_std_termios;
@@ -315,16 +315,19 @@ int xhci_dbc_tty_register_driver(struct xhci_hcd *xhci)
put_tty_driver(dbc_tty_driver);
dbc_tty_driver = NULL;
}
+   dbc->func_priv = dbc_tty_driver;
 
return status;
 }
 
-v

[PATCH 3/5] usb: xhci: dbc: Provide sysfs option to configure dbc descriptors

2019-06-06 Thread Prabhat Chand Pandey
From: "K V, Abhilash" 

Show the active dbc function and dbc descriptors, allowing
user space to dynamically modify the descriptors

The DBC specific sysfs attributes are separated into two groups,
in the first group there are dbc & dbc_function sysfs attributes and in
second group all other DBC descriptor specific sysfs attributes.

First group of attributes will be populated at the time of dbc_init and
second group of attributes will only be populated when "dbc" attribute
value is set to "enable".

Whenever "dbc" attribute value will be "disable" then second group
of attributes will be removed.

Signed-off-by: Rajaram Regupathy 
Signed-off-by: Gururaj K 
Signed-off-by: K V, Abhilash 
Signed-off-by: Prabhat Chand Pandey 
Acked-by: Mathias Nyman 
---
 .../testing/sysfs-bus-pci-drivers-xhci_hcd| 112 ++
 drivers/usb/host/xhci-dbgcap.c| 339 ++
 2 files changed, 451 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-pci-drivers-xhci_hcd 
b/Documentation/ABI/testing/sysfs-bus-pci-drivers-xhci_hcd
index 0088aba4caa8..b46b6afc6c4a 100644
--- a/Documentation/ABI/testing/sysfs-bus-pci-drivers-xhci_hcd
+++ b/Documentation/ABI/testing/sysfs-bus-pci-drivers-xhci_hcd
@@ -23,3 +23,115 @@ Description:
Reading this attribute gives the state of the DbC. It
can be one of the following states: disabled, enabled,
initialized, connected, configured and stalled.
+
+What:  /sys/bus/pci/drivers/xhci_hcd/.../dbc_function
+Date:  June 2018
+Contact:   Rajaram Regupathy 
+Description:
+   xHCI USB host controllers provide Debug Capability (Dbc)
+   as an extended feature. When configured Dbc presents a
+   debug device which is fully compliant with the USB
+   framework.
+
+   This framework can be utilized to provide various interfaces.
+   By Default, it is configured to provide a serial Interface.
+
+   This attribute lets us configure the interface provided
+   by Dbc functionality. By Default, this attribute value
+   is "TTY" corresponding to the the serial interface. Other
+   values can be supported in future to provide a varied
+   interface to use DbC.
+
+   Reading this attribute gives the interface which is
+   currently configured with DbC. If it is "TTY" then serial
+   interface is configured.
+
+What:  /sys/bus/pci/drivers/xhci_hcd/.../dbc_manufacturer
+Date:  June 2018
+Contact:   Rajaram Regupathy 
+Description:
+   xHCI USB host controllers provide Debug Capability (Dbc)
+   as an extended feature. When configured Dbc presents a
+   debug device which is fully compliant with the USB
+   framework.
+   This attribute lets us change the manufacturer name as
+   presented by the debug device in the USB Manufacturer String
+   descriptor. The default value is "Linux Foundation".
+
+What:  /sys/bus/pci/drivers/xhci_hcd/.../dbc_product
+Date:  June 2018
+Contact:   Rajaram Regupathy 
+Description:
+   xHCI USB host controllers provide Debug Capability (Dbc)
+   as an extended feature. When configured Dbc presents a
+   debug device which is fully compliant with the USB
+   framework.
+   This attribute lets us change the product name as
+   presented by the debug device in the USB Product String
+   descriptor. The default value is "Linux USB Debug Target".
+
+What:  /sys/bus/pci/drivers/xhci_hcd/.../dbc_serial
+Date:  June 2018
+Contact:   Rajaram Regupathy 
+Description:
+   xHCI USB host controllers provide Debug Capability (Dbc)
+   as an extended feature. When configured Dbc presents a
+   debug device which is fully compliant with the USB
+   framework.
+   This attribute lets us change the serial number as
+   presented by the debug device in the USB Serial Number String
+   descriptor. The default value is "0001".
+
+What:  /sys/bus/pci/drivers/xhci_hcd/.../dbc_protocol
+Date:  June 2018
+Contact:   Rajaram Regupathy 
+Description:
+   xHCI USB host controllers provide Debug Capability (Dbc)
+   as an extended feature. When configured Dbc presents a
+   debug device which is fully compliant with the USB
+   framework.
+   This attribute lets us change the bInterfaceProtocol field as
+   presented by the debug device in the USB Interface descriptor.
+
+   The default value is  1  (GNU Remote Debug command).
+ 

[PATCH 5/5] usb: xhci: dbc: Document describe about dbc raw interface

2019-06-06 Thread Prabhat Chand Pandey
This patch have explaination about the new DBC interface called
dbc raw interface. This cover the capability, target setup and
use case info.

Signed-off-by: Prabhat Chand Pandey 
---
 Documentation/usb/dbc_raw.rst | 136 ++
 Documentation/usb/index.rst   |  16 
 2 files changed, 152 insertions(+)
 create mode 100644 Documentation/usb/dbc_raw.rst
 create mode 100644 Documentation/usb/index.rst

diff --git a/Documentation/usb/dbc_raw.rst b/Documentation/usb/dbc_raw.rst
new file mode 100644
index ..b7d472a478f5
--- /dev/null
+++ b/Documentation/usb/dbc_raw.rst
@@ -0,0 +1,136 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+==
+This described about DBC RAW Interface
+==
+
+:Author: Prabhat Chand Pandey 
+
+Content
+
+
+- DBC Overview
+- Motivation
+- DBC RAW Capabilities
+- Target Build Setup
+- Target Test Setup
+- Host Target Connection
+- Experiment Test Result
+- DBC TTY Use Cases
+- DBC RAW Use Cases
+- Conclusion
+
+DBC Overview
+-
+xDBC stands for the USB Debug capability provided extensible Host Controller
+Interface. Universal Serial Bus is a host controlled Bus. Host Controller is
+a hardware whose functionality is to manage usb bus and usb host ports. It is
+responsible for initiating and managing all usb transfers. Extensible Host
+Controller Interface (xHCI) is a register-level interface which provides a
+mechanism by which the host controller (xHC) can communicate with the Operating
+System of the host computer. In addition to exposing register interfaces
+essential for proper functioning of the xHC it also supports many extended
+capabilities which can optionally be implemented by xHC.
+
+It includes Extended Power Management Capability, I/O Virtualization capability
+USB Legacy support capability among many others. USB Debug Capability is one of
+the main extended capabilities supported by xHCI.
+
+This functionality enables low-level system debug over USB. The xHCI debug
+capabilities (xDBC) provides a means of connecting two systems where the system
+is a Debug Host and the other is a Debug target. This is achieved through
+emulating a debug device by using xDBC on the debug target. The debug device
+presented by the debug target can be used by debug host for low level system
+debugging of target.
+
+Motivation
+---
+In this patch-set we learn the requirement of new DBC interface called DBC RAW,
+which can be used for platform debugging, large data transfer with 
comparatively
+10x faster data rate than DBC TTY and it have all the USB specific error 
handling
+mechanism enabled which DBC TTY doesn't have.
+
+DBC RAW Capabilities
+-
+* Current transfer rate of up to 25.4 MB/s from host to target (using Blocking 
APIs).
+* Current transfer rate of up to 28.8 MB/s from target to host (using Blocking 
APIs).
+* Have further scope of improvement in transfer rate of up to USB 3.x speed.
+* This interface can bind with multiple target xHCI (i.e. /dev/dbc_raw0, raw1 
etc).
+* It helps to render the target as an usb debug class device on host and 
establish
+  an usb connection by providing two bulk endpoints.
+* It has support to handle halt bit and send STALL packet.
+
+Target Build Setup
+---
+* Make sure to use Kernel of version >= 4.13.
+* Enable USB_XHCI_DBGCAP in Kernel menuconfig.
+   Device Drivers  ---> USB support  ---> xHCI support for debug 
capability [Y]
+* Enable DBC RAW in kernel menuconfig.
+   Device Drivers  ---> USB support  ---> Select function for debug 
capability
+   (xHCI DbC raw driver 
support)
+* Build Image.
+
+Target Test Setup
+--
+* Flash binary with above changes in the target board.
+* Cross check the current DBC function interface, it should be RAW in this case
+  otherwise TTY, below is the sysfs entry for the dbc_function (it's a read 
only file,
+  switching b/w RAW and TTY is only possible at build time):
+   root@target:/ # cat /sys/bus/pci/devices/\:00\:14.0/dbc_function
+   RWA
+* Enable DBC with the following command:
+   root@target:/ # echo enable > /sys/bus/pci/devices/\:00\:14.0/dbc
+
+Host Target Connection
+---
+* Connect Type A to Type A cable between Target and Host.
+* Make sure it is an usb 3.0 cable.
+* At this point debug device should be enumerated on Host side.
+* On Target side dbc sysfs attribute should change to configured state and
+  dbc_raw0 character device should appear under dev directory.
+
+   On Target-:
+   root@target:/ # cat /sys/bus/pci/devices/\:00\:14.0/dbc
+   configured
+
+   Target dmesg-:
+   [   32.420018] xhci_hcd :00:14.0: DbC connected
+   [   32.676014] xhci_hcd :00:14.0: DbC configured
+
+   Host dmesg-:
+   [