2017-11-03 18:28:30 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2017-04-19 19:59:27 +08:00
|
|
|
/*
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
* gadget.c - DesignWare USB3 DRD Controller Gadget Framework Link
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com
|
|
|
|
*
|
|
|
|
* Authors: Felipe Balbi <balbi@ti.com>,
|
|
|
|
* Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/pm_runtime.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/dma-mapping.h>
|
|
|
|
|
|
|
|
#include <linux/usb/ch9.h>
|
|
|
|
#include <linux/usb/gadget.h>
|
|
|
|
|
2014-08-20 05:37:22 +08:00
|
|
|
#include "debug.h"
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
#include "core.h"
|
|
|
|
#include "gadget.h"
|
|
|
|
#include "io.h"
|
|
|
|
|
2018-08-14 15:42:43 +08:00
|
|
|
#define DWC3_ALIGN_FRAME(d, n) (((d)->frame_number + ((d)->interval * (n))) \
|
2018-04-11 15:34:34 +08:00
|
|
|
& ~((d)->interval - 1))
|
|
|
|
|
2012-01-03 00:25:43 +08:00
|
|
|
/**
|
2017-04-19 19:59:27 +08:00
|
|
|
* dwc3_gadget_set_test_mode - enables usb2 test modes
|
2012-01-03 00:25:43 +08:00
|
|
|
* @dwc: pointer to our context structure
|
|
|
|
* @mode: the mode to set (J, K SE0 NAK, Force Enable)
|
|
|
|
*
|
2017-04-19 19:59:27 +08:00
|
|
|
* Caller should take care of locking. This function will return 0 on
|
|
|
|
* success or -EINVAL if wrong Test Selector is passed.
|
2012-01-03 00:25:43 +08:00
|
|
|
*/
|
|
|
|
int dwc3_gadget_set_test_mode(struct dwc3 *dwc, int mode)
|
|
|
|
{
|
|
|
|
u32 reg;
|
|
|
|
|
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
|
|
|
|
reg &= ~DWC3_DCTL_TSTCTRL_MASK;
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case TEST_J:
|
|
|
|
case TEST_K:
|
|
|
|
case TEST_SE0_NAK:
|
|
|
|
case TEST_PACKET:
|
|
|
|
case TEST_FORCE_EN:
|
|
|
|
reg |= mode << 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
dwc3_writel(dwc->regs, DWC3_DCTL, reg);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-04-27 18:35:15 +08:00
|
|
|
/**
|
2017-04-19 19:59:27 +08:00
|
|
|
* dwc3_gadget_get_link_state - gets current state of usb link
|
2012-04-27 18:35:15 +08:00
|
|
|
* @dwc: pointer to our context structure
|
|
|
|
*
|
|
|
|
* Caller should take care of locking. This function will
|
|
|
|
* return the link state on success (>= 0) or -ETIMEDOUT.
|
|
|
|
*/
|
|
|
|
int dwc3_gadget_get_link_state(struct dwc3 *dwc)
|
|
|
|
{
|
|
|
|
u32 reg;
|
|
|
|
|
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_DSTS);
|
|
|
|
|
|
|
|
return DWC3_DSTS_USBLNKST(reg);
|
|
|
|
}
|
|
|
|
|
2012-01-03 00:55:57 +08:00
|
|
|
/**
|
2017-04-19 19:59:27 +08:00
|
|
|
* dwc3_gadget_set_link_state - sets usb link to a particular state
|
2012-01-03 00:55:57 +08:00
|
|
|
* @dwc: pointer to our context structure
|
|
|
|
* @state: the state to put link into
|
|
|
|
*
|
|
|
|
* Caller should take care of locking. This function will
|
2012-02-25 09:32:15 +08:00
|
|
|
* return 0 on success or -ETIMEDOUT.
|
2012-01-03 00:55:57 +08:00
|
|
|
*/
|
|
|
|
int dwc3_gadget_set_link_state(struct dwc3 *dwc, enum dwc3_link_state state)
|
|
|
|
{
|
2012-02-25 09:32:15 +08:00
|
|
|
int retries = 10000;
|
2012-01-03 00:55:57 +08:00
|
|
|
u32 reg;
|
|
|
|
|
2012-04-27 18:10:52 +08:00
|
|
|
/*
|
|
|
|
* Wait until device controller is ready. Only applies to 1.94a and
|
|
|
|
* later RTL.
|
|
|
|
*/
|
|
|
|
if (dwc->revision >= DWC3_REVISION_194A) {
|
|
|
|
while (--retries) {
|
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_DSTS);
|
|
|
|
if (reg & DWC3_DSTS_DCNRD)
|
|
|
|
udelay(5);
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (retries <= 0)
|
|
|
|
return -ETIMEDOUT;
|
|
|
|
}
|
|
|
|
|
2012-01-03 00:55:57 +08:00
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
|
|
|
|
reg &= ~DWC3_DCTL_ULSTCHNGREQ_MASK;
|
|
|
|
|
|
|
|
/* set requested state */
|
|
|
|
reg |= DWC3_DCTL_ULSTCHNGREQ(state);
|
|
|
|
dwc3_writel(dwc->regs, DWC3_DCTL, reg);
|
|
|
|
|
2012-04-27 18:10:52 +08:00
|
|
|
/*
|
|
|
|
* The following code is racy when called from dwc3_gadget_wakeup,
|
|
|
|
* and is not needed, at least on newer versions
|
|
|
|
*/
|
|
|
|
if (dwc->revision >= DWC3_REVISION_194A)
|
|
|
|
return 0;
|
|
|
|
|
2012-01-03 00:55:57 +08:00
|
|
|
/* wait for a change in DSTS */
|
2012-04-27 17:52:01 +08:00
|
|
|
retries = 10000;
|
2012-01-03 00:55:57 +08:00
|
|
|
while (--retries) {
|
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_DSTS);
|
|
|
|
|
|
|
|
if (DWC3_DSTS_USBLNKST(reg) == state)
|
|
|
|
return 0;
|
|
|
|
|
2012-02-25 09:32:15 +08:00
|
|
|
udelay(5);
|
2012-01-03 00:55:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return -ETIMEDOUT;
|
|
|
|
}
|
|
|
|
|
2016-05-20 08:26:05 +08:00
|
|
|
/**
|
2017-04-19 19:59:27 +08:00
|
|
|
* dwc3_ep_inc_trb - increment a trb index.
|
|
|
|
* @index: Pointer to the TRB index to increment.
|
2016-05-20 08:26:05 +08:00
|
|
|
*
|
|
|
|
* The index should never point to the link TRB. After incrementing,
|
|
|
|
* if it is point to the link TRB, wrap around to the beginning. The
|
|
|
|
* link TRB is always at the last TRB entry.
|
|
|
|
*/
|
|
|
|
static void dwc3_ep_inc_trb(u8 *index)
|
2012-01-19 00:04:09 +08:00
|
|
|
{
|
2016-05-20 08:26:05 +08:00
|
|
|
(*index)++;
|
|
|
|
if (*index == (DWC3_TRB_NUM - 1))
|
|
|
|
*index = 0;
|
2016-04-05 18:09:51 +08:00
|
|
|
}
|
2012-01-19 00:04:09 +08:00
|
|
|
|
2017-04-19 19:59:27 +08:00
|
|
|
/**
|
|
|
|
* dwc3_ep_inc_enq - increment endpoint's enqueue pointer
|
|
|
|
* @dep: The endpoint whose enqueue pointer we're incrementing
|
|
|
|
*/
|
2016-05-20 08:26:05 +08:00
|
|
|
static void dwc3_ep_inc_enq(struct dwc3_ep *dep)
|
2016-04-05 18:09:51 +08:00
|
|
|
{
|
2016-05-20 08:26:05 +08:00
|
|
|
dwc3_ep_inc_trb(&dep->trb_enqueue);
|
2016-04-05 18:09:51 +08:00
|
|
|
}
|
2012-01-19 00:04:09 +08:00
|
|
|
|
2017-04-19 19:59:27 +08:00
|
|
|
/**
|
|
|
|
* dwc3_ep_inc_deq - increment endpoint's dequeue pointer
|
|
|
|
* @dep: The endpoint whose enqueue pointer we're incrementing
|
|
|
|
*/
|
2016-05-20 08:26:05 +08:00
|
|
|
static void dwc3_ep_inc_deq(struct dwc3_ep *dep)
|
2016-04-05 18:09:51 +08:00
|
|
|
{
|
2016-05-20 08:26:05 +08:00
|
|
|
dwc3_ep_inc_trb(&dep->trb_dequeue);
|
2012-01-19 00:04:09 +08:00
|
|
|
}
|
|
|
|
|
2018-03-29 10:20:10 +08:00
|
|
|
static void dwc3_gadget_del_and_unmap_request(struct dwc3_ep *dep,
|
2018-03-26 18:14:47 +08:00
|
|
|
struct dwc3_request *req, int status)
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
{
|
|
|
|
struct dwc3 *dwc = dep->dwc;
|
|
|
|
|
|
|
|
list_del(&req->list);
|
2016-10-25 18:47:21 +08:00
|
|
|
req->remaining = 0;
|
2019-01-11 04:39:55 +08:00
|
|
|
req->needs_extra_trb = false;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
|
|
|
if (req->request.status == -EINPROGRESS)
|
|
|
|
req->request.status = status;
|
|
|
|
|
2017-06-29 15:53:31 +08:00
|
|
|
if (req->trb)
|
|
|
|
usb_gadget_unmap_request_by_dev(dwc->sysdev,
|
2018-03-26 18:14:47 +08:00
|
|
|
&req->request, req->direction);
|
2017-06-29 15:53:31 +08:00
|
|
|
|
|
|
|
req->trb = NULL;
|
2014-05-01 06:45:10 +08:00
|
|
|
trace_dwc3_gadget_giveback(req);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2018-03-26 18:14:47 +08:00
|
|
|
if (dep->number > 1)
|
|
|
|
pm_runtime_put(dwc->dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* dwc3_gadget_giveback - call struct usb_request's ->complete callback
|
|
|
|
* @dep: The endpoint to whom the request belongs to
|
|
|
|
* @req: The request we're giving back
|
|
|
|
* @status: completion code for the request
|
|
|
|
*
|
|
|
|
* Must be called with controller's lock held and interrupts disabled. This
|
|
|
|
* function will unmap @req and call its ->complete() callback to notify upper
|
|
|
|
* layers that it has completed.
|
|
|
|
*/
|
|
|
|
void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
|
|
|
|
int status)
|
|
|
|
{
|
|
|
|
struct dwc3 *dwc = dep->dwc;
|
|
|
|
|
|
|
|
dwc3_gadget_del_and_unmap_request(dep, req, status);
|
2019-01-11 18:57:09 +08:00
|
|
|
req->status = DWC3_REQUEST_STATUS_COMPLETED;
|
2018-03-26 18:14:47 +08:00
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
spin_unlock(&dwc->lock);
|
2014-09-25 04:43:19 +08:00
|
|
|
usb_gadget_giveback_request(&dep->endpoint, &req->request);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
spin_lock(&dwc->lock);
|
|
|
|
}
|
|
|
|
|
2017-04-19 19:59:27 +08:00
|
|
|
/**
|
|
|
|
* dwc3_send_gadget_generic_command - issue a generic command for the controller
|
|
|
|
* @dwc: pointer to the controller context
|
|
|
|
* @cmd: the command to be issued
|
|
|
|
* @param: command parameter
|
|
|
|
*
|
|
|
|
* Caller should take care of locking. Issue @cmd with a given @param to @dwc
|
|
|
|
* and wait for its completion.
|
|
|
|
*/
|
2014-09-05 22:47:44 +08:00
|
|
|
int dwc3_send_gadget_generic_command(struct dwc3 *dwc, unsigned cmd, u32 param)
|
2012-04-24 21:19:11 +08:00
|
|
|
{
|
|
|
|
u32 timeout = 500;
|
2016-05-23 19:16:19 +08:00
|
|
|
int status = 0;
|
2016-05-23 19:06:07 +08:00
|
|
|
int ret = 0;
|
2012-04-24 21:19:11 +08:00
|
|
|
u32 reg;
|
|
|
|
|
|
|
|
dwc3_writel(dwc->regs, DWC3_DGCMDPAR, param);
|
|
|
|
dwc3_writel(dwc->regs, DWC3_DGCMD, cmd | DWC3_DGCMD_CMDACT);
|
|
|
|
|
|
|
|
do {
|
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_DGCMD);
|
|
|
|
if (!(reg & DWC3_DGCMD_CMDACT)) {
|
2016-05-23 19:16:19 +08:00
|
|
|
status = DWC3_DGCMD_STATUS(reg);
|
|
|
|
if (status)
|
2016-05-23 19:06:07 +08:00
|
|
|
ret = -EINVAL;
|
|
|
|
break;
|
2012-04-24 21:19:11 +08:00
|
|
|
}
|
2016-11-09 18:01:33 +08:00
|
|
|
} while (--timeout);
|
2016-05-23 19:06:07 +08:00
|
|
|
|
|
|
|
if (!timeout) {
|
|
|
|
ret = -ETIMEDOUT;
|
2016-05-23 19:16:19 +08:00
|
|
|
status = -ETIMEDOUT;
|
2016-05-23 19:06:07 +08:00
|
|
|
}
|
|
|
|
|
2016-05-23 19:16:19 +08:00
|
|
|
trace_dwc3_gadget_generic_cmd(cmd, param, status);
|
|
|
|
|
2016-05-23 19:06:07 +08:00
|
|
|
return ret;
|
2012-04-24 21:19:11 +08:00
|
|
|
}
|
|
|
|
|
2016-04-04 17:46:33 +08:00
|
|
|
static int __dwc3_gadget_wakeup(struct dwc3 *dwc);
|
|
|
|
|
2017-04-19 19:59:27 +08:00
|
|
|
/**
|
|
|
|
* dwc3_send_gadget_ep_cmd - issue an endpoint command
|
|
|
|
* @dep: the endpoint to which the command is going to be issued
|
|
|
|
* @cmd: the command to be issued
|
|
|
|
* @params: parameters to the command
|
|
|
|
*
|
|
|
|
* Caller should handle locking. This function will issue @cmd with given
|
|
|
|
* @params to @dep and wait for its completion.
|
|
|
|
*/
|
2016-04-12 21:42:43 +08:00
|
|
|
int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned cmd,
|
|
|
|
struct dwc3_gadget_ep_cmd_params *params)
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
{
|
2016-09-22 15:56:08 +08:00
|
|
|
const struct usb_endpoint_descriptor *desc = dep->endpoint.desc;
|
2016-04-12 21:42:43 +08:00
|
|
|
struct dwc3 *dwc = dep->dwc;
|
usb: dwc3: gadget: Wait longer for controller to end command processing
DWC3_DEPCMD_ENDTRANSFER has been witnessed to require around 600 iterations
before controller would become idle again after unplugging the USB cable
with AIO reads submitted.
Bump timeout from 500 iterations to 1000 so dwc3_stop_active_transfer does
not receive -ETIMEDOUT and does not WARN:
[ 81.326273] ------------[ cut here ]------------
[ 81.335341] WARNING: CPU: 0 PID: 1874 at drivers/usb/dwc3/gadget.c:2627 dwc3_stop_active_transfer.constprop.23+0x69/0xc0 [dwc3]
[ 81.347094] Modules linked in: usb_f_fs libcomposite configfs bnep btsdio bluetooth ecdh_generic brcmfmac brcmutil dwc3 intel_powerclamp coretemp ulpi kvm_intel udc_core kvm irqbypass crc32_pclmul crc32c_intel pcbc dwc3_pci aesni_intel aes_i586 crypto_simd cryptd ehci_pci ehci_hcd basincove_gpadc industrialio gpio_keys usbcore usb_common
[ 81.378142] CPU: 0 PID: 1874 Comm: irq/34-dwc3 Not tainted 4.14.0-edison+ #119
[ 81.385545] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 542 2015.01.21:18.19.48
[ 81.394548] task: f5b1be00 task.stack: f420a000
[ 81.399219] EIP: dwc3_stop_active_transfer.constprop.23+0x69/0xc0 [dwc3]
[ 81.406086] EFLAGS: 00010086 CPU: 0
[ 81.409672] EAX: 0000001f EBX: f5729800 ECX: c132a2a2 EDX: 00000000
[ 81.416096] ESI: f4054014 EDI: f41cf400 EBP: f420be10 ESP: f420bdf4
[ 81.422521] DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068
[ 81.428061] CR0: 80050033 CR2: b7a3f000 CR3: 01d94000 CR4: 001006d0
[ 81.434483] Call Trace:
[ 81.437063] __dwc3_gadget_ep_disable+0xa3/0x2b0 [dwc3]
[ 81.442438] ? _raw_spin_lock_irqsave+0x32/0x40
[ 81.447135] dwc3_gadget_ep_disable+0xbf/0xe0 [dwc3]
[ 81.452269] usb_ep_disable+0x1c/0xd0 [udc_core]
[ 81.457048] ffs_func_eps_disable.isra.15+0x3b/0x90 [usb_f_fs]
[ 81.463070] ffs_func_set_alt+0x7d/0x310 [usb_f_fs]
[ 81.468132] ffs_func_disable+0x14/0x20 [usb_f_fs]
[ 81.473075] reset_config+0x5b/0x90 [libcomposite]
[ 81.478023] composite_disconnect+0x2b/0x50 [libcomposite]
[ 81.483685] dwc3_disconnect_gadget+0x39/0x50 [dwc3]
[ 81.488808] dwc3_gadget_disconnect_interrupt+0x21b/0x250 [dwc3]
[ 81.495014] dwc3_thread_interrupt+0x2a8/0xf70 [dwc3]
[ 81.500219] ? __schedule+0x78c/0x7e0
[ 81.504027] irq_thread_fn+0x18/0x30
[ 81.507715] ? irq_thread+0xb7/0x180
[ 81.511400] irq_thread+0x111/0x180
[ 81.515000] ? irq_finalize_oneshot+0xe0/0xe0
[ 81.519490] ? wake_threads_waitq+0x30/0x30
[ 81.523806] kthread+0x107/0x110
[ 81.527131] ? disable_percpu_irq+0x50/0x50
[ 81.531439] ? kthread_stop+0x150/0x150
[ 81.535397] ret_from_fork+0x19/0x24
[ 81.539136] Code: 89 d8 c7 45 ec 00 00 00 00 c7 45 f0 00 00 00 00 c7 45 f4 00 00 00 00 e8 56 ef ff ff 85 c0 74 12 50 68 b9 1c 14 f8 e8 64 0f f7 c8 <0f> ff 58 5a 8d 76 00 8b 83 98 00 00 00 c6 83 a0 00 00 00 00 83
[ 81.559295] ---[ end trace f3133eec81a473b8 ]---
Number of iterations measured on 4 consecutive unplugs:
[ 1088.799777] dwc3_send_gadget_ep_cmd(cmd=331016, params={0, 0, 0}) iterated 605 times
[ 1222.024986] dwc3_send_gadget_ep_cmd(cmd=331016, params={0, 0, 0}) iterated 580 times
[ 1317.590452] dwc3_send_gadget_ep_cmd(cmd=331016, params={0, 0, 0}) iterated 598 times
[ 1453.218314] dwc3_send_gadget_ep_cmd(cmd=331016, params={0, 0, 0}) iterated 594 times
Signed-off-by: Vincent Pelletier <plr.vincent@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-11-30 23:31:06 +08:00
|
|
|
u32 timeout = 1000;
|
2018-09-12 03:42:05 +08:00
|
|
|
u32 saved_config = 0;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
u32 reg;
|
|
|
|
|
2016-05-23 19:02:33 +08:00
|
|
|
int cmd_status = 0;
|
2016-04-04 14:11:51 +08:00
|
|
|
int ret = -EINVAL;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2016-04-04 14:19:17 +08:00
|
|
|
/*
|
2018-09-12 03:42:05 +08:00
|
|
|
* When operating in USB 2.0 speeds (HS/FS), if GUSB2PHYCFG.ENBLSLPM or
|
|
|
|
* GUSB2PHYCFG.SUSPHY is set, it must be cleared before issuing an
|
|
|
|
* endpoint command.
|
2016-04-04 14:19:17 +08:00
|
|
|
*
|
2018-09-12 03:42:05 +08:00
|
|
|
* Save and clear both GUSB2PHYCFG.ENBLSLPM and GUSB2PHYCFG.SUSPHY
|
|
|
|
* settings. Restore them after the command is completed.
|
|
|
|
*
|
|
|
|
* DWC_usb3 3.30a and DWC_usb31 1.90a programming guide section 3.2.2
|
2016-04-04 14:19:17 +08:00
|
|
|
*/
|
2016-05-17 19:55:58 +08:00
|
|
|
if (dwc->gadget.speed <= USB_SPEED_HIGH) {
|
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
|
|
|
|
if (unlikely(reg & DWC3_GUSB2PHYCFG_SUSPHY)) {
|
2018-09-12 03:42:05 +08:00
|
|
|
saved_config |= DWC3_GUSB2PHYCFG_SUSPHY;
|
2016-05-17 19:55:58 +08:00
|
|
|
reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
|
|
|
|
}
|
2018-09-12 03:42:05 +08:00
|
|
|
|
|
|
|
if (reg & DWC3_GUSB2PHYCFG_ENBLSLPM) {
|
|
|
|
saved_config |= DWC3_GUSB2PHYCFG_ENBLSLPM;
|
|
|
|
reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (saved_config)
|
|
|
|
dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
|
2016-04-04 14:19:17 +08:00
|
|
|
}
|
|
|
|
|
2016-09-22 17:25:28 +08:00
|
|
|
if (DWC3_DEPCMD_CMD(cmd) == DWC3_DEPCMD_STARTTRANSFER) {
|
2016-04-04 17:46:33 +08:00
|
|
|
int needs_wakeup;
|
|
|
|
|
|
|
|
needs_wakeup = (dwc->link_state == DWC3_LINK_STATE_U1 ||
|
|
|
|
dwc->link_state == DWC3_LINK_STATE_U2 ||
|
|
|
|
dwc->link_state == DWC3_LINK_STATE_U3);
|
|
|
|
|
|
|
|
if (unlikely(needs_wakeup)) {
|
|
|
|
ret = __dwc3_gadget_wakeup(dwc);
|
|
|
|
dev_WARN_ONCE(dwc->dev, ret, "wakeup failed --> %d\n",
|
|
|
|
ret);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:53:39 +08:00
|
|
|
dwc3_writel(dep->regs, DWC3_DEPCMDPAR0, params->param0);
|
|
|
|
dwc3_writel(dep->regs, DWC3_DEPCMDPAR1, params->param1);
|
|
|
|
dwc3_writel(dep->regs, DWC3_DEPCMDPAR2, params->param2);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2016-09-22 15:56:08 +08:00
|
|
|
/*
|
|
|
|
* Synopsys Databook 2.60a states in section 6.3.2.5.6 of that if we're
|
|
|
|
* not relying on XferNotReady, we can make use of a special "No
|
|
|
|
* Response Update Transfer" command where we should clear both CmdAct
|
|
|
|
* and CmdIOC bits.
|
|
|
|
*
|
|
|
|
* With this, we don't need to wait for command completion and can
|
|
|
|
* straight away issue further commands to the endpoint.
|
|
|
|
*
|
|
|
|
* NOTICE: We're making an assumption that control endpoints will never
|
|
|
|
* make use of Update Transfer command. This is a safe assumption
|
|
|
|
* because we can never have more than one request at a time with
|
|
|
|
* Control Endpoints. If anybody changes that assumption, this chunk
|
|
|
|
* needs to be updated accordingly.
|
|
|
|
*/
|
|
|
|
if (DWC3_DEPCMD_CMD(cmd) == DWC3_DEPCMD_UPDATETRANSFER &&
|
|
|
|
!usb_endpoint_xfer_isoc(desc))
|
|
|
|
cmd &= ~(DWC3_DEPCMD_CMDIOC | DWC3_DEPCMD_CMDACT);
|
|
|
|
else
|
|
|
|
cmd |= DWC3_DEPCMD_CMDACT;
|
|
|
|
|
|
|
|
dwc3_writel(dep->regs, DWC3_DEPCMD, cmd);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
do {
|
2016-04-12 21:53:39 +08:00
|
|
|
reg = dwc3_readl(dep->regs, DWC3_DEPCMD);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
if (!(reg & DWC3_DEPCMD_CMDACT)) {
|
2016-05-23 19:02:33 +08:00
|
|
|
cmd_status = DWC3_DEPCMD_STATUS(reg);
|
2016-02-12 23:21:46 +08:00
|
|
|
|
|
|
|
switch (cmd_status) {
|
|
|
|
case 0:
|
|
|
|
ret = 0;
|
|
|
|
break;
|
|
|
|
case DEPEVT_TRANSFER_NO_RESOURCE:
|
|
|
|
ret = -EINVAL;
|
2016-04-04 14:11:51 +08:00
|
|
|
break;
|
2016-02-12 23:21:46 +08:00
|
|
|
case DEPEVT_TRANSFER_BUS_EXPIRY:
|
|
|
|
/*
|
|
|
|
* SW issues START TRANSFER command to
|
|
|
|
* isochronous ep with future frame interval. If
|
|
|
|
* future interval time has already passed when
|
|
|
|
* core receives the command, it will respond
|
|
|
|
* with an error status of 'Bus Expiry'.
|
|
|
|
*
|
|
|
|
* Instead of always returning -EINVAL, let's
|
|
|
|
* give a hint to the gadget driver that this is
|
|
|
|
* the case by returning -EAGAIN.
|
|
|
|
*/
|
|
|
|
ret = -EAGAIN;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
dev_WARN(dwc->dev, "UNKNOWN cmd status\n");
|
|
|
|
}
|
|
|
|
|
2016-04-04 14:11:51 +08:00
|
|
|
break;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
2016-05-23 18:53:34 +08:00
|
|
|
} while (--timeout);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2016-05-23 18:53:34 +08:00
|
|
|
if (timeout == 0) {
|
|
|
|
ret = -ETIMEDOUT;
|
2016-05-23 19:02:33 +08:00
|
|
|
cmd_status = -ETIMEDOUT;
|
2016-05-23 18:53:34 +08:00
|
|
|
}
|
2016-04-04 14:11:51 +08:00
|
|
|
|
2016-05-23 19:02:33 +08:00
|
|
|
trace_dwc3_gadget_ep_cmd(dep, cmd, params, cmd_status);
|
|
|
|
|
2019-01-21 18:58:27 +08:00
|
|
|
if (ret == 0 && DWC3_DEPCMD_CMD(cmd) == DWC3_DEPCMD_STARTTRANSFER) {
|
|
|
|
dep->flags |= DWC3_EP_TRANSFER_STARTED;
|
|
|
|
dwc3_gadget_ep_get_transfer_index(dep);
|
2016-10-21 18:07:09 +08:00
|
|
|
}
|
|
|
|
|
2018-09-12 03:42:05 +08:00
|
|
|
if (saved_config) {
|
2016-04-04 14:19:17 +08:00
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
|
2018-09-12 03:42:05 +08:00
|
|
|
reg |= saved_config;
|
2016-04-04 14:19:17 +08:00
|
|
|
dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
|
|
|
|
}
|
|
|
|
|
2016-04-04 14:11:51 +08:00
|
|
|
return ret;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
|
2016-06-01 08:49:56 +08:00
|
|
|
static int dwc3_send_clear_stall_ep_cmd(struct dwc3_ep *dep)
|
|
|
|
{
|
|
|
|
struct dwc3 *dwc = dep->dwc;
|
|
|
|
struct dwc3_gadget_ep_cmd_params params;
|
|
|
|
u32 cmd = DWC3_DEPCMD_CLEARSTALL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* As of core revision 2.60a the recommended programming model
|
|
|
|
* is to set the ClearPendIN bit when issuing a Clear Stall EP
|
|
|
|
* command for IN endpoints. This is to prevent an issue where
|
|
|
|
* some (non-compliant) hosts may not send ACK TPs for pending
|
|
|
|
* IN transfers due to a mishandled error condition. Synopsys
|
|
|
|
* STAR 9000614252.
|
|
|
|
*/
|
2016-09-09 12:51:27 +08:00
|
|
|
if (dep->direction && (dwc->revision >= DWC3_REVISION_260A) &&
|
|
|
|
(dwc->gadget.speed >= USB_SPEED_SUPER))
|
2016-06-01 08:49:56 +08:00
|
|
|
cmd |= DWC3_DEPCMD_CLEARPENDIN;
|
|
|
|
|
|
|
|
memset(¶ms, 0, sizeof(params));
|
|
|
|
|
2016-04-12 21:42:43 +08:00
|
|
|
return dwc3_send_gadget_ep_cmd(dep, cmd, ¶ms);
|
2016-06-01 08:49:56 +08:00
|
|
|
}
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
static dma_addr_t dwc3_trb_dma_offset(struct dwc3_ep *dep,
|
2012-02-06 17:04:53 +08:00
|
|
|
struct dwc3_trb *trb)
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
{
|
2011-09-30 15:58:45 +08:00
|
|
|
u32 offset = (char *) trb - (char *) dep->trb_pool;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
|
|
|
return dep->trb_pool_dma + offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dwc3_alloc_trb_pool(struct dwc3_ep *dep)
|
|
|
|
{
|
|
|
|
struct dwc3 *dwc = dep->dwc;
|
|
|
|
|
|
|
|
if (dep->trb_pool)
|
|
|
|
return 0;
|
|
|
|
|
2016-11-17 19:43:47 +08:00
|
|
|
dep->trb_pool = dma_alloc_coherent(dwc->sysdev,
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
sizeof(struct dwc3_trb) * DWC3_TRB_NUM,
|
|
|
|
&dep->trb_pool_dma, GFP_KERNEL);
|
|
|
|
if (!dep->trb_pool) {
|
|
|
|
dev_err(dep->dwc->dev, "failed to allocate trb pool for %s\n",
|
|
|
|
dep->name);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dwc3_free_trb_pool(struct dwc3_ep *dep)
|
|
|
|
{
|
|
|
|
struct dwc3 *dwc = dep->dwc;
|
|
|
|
|
2016-11-17 19:43:47 +08:00
|
|
|
dma_free_coherent(dwc->sysdev, sizeof(struct dwc3_trb) * DWC3_TRB_NUM,
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
dep->trb_pool, dep->trb_pool_dma);
|
|
|
|
|
|
|
|
dep->trb_pool = NULL;
|
|
|
|
dep->trb_pool_dma = 0;
|
|
|
|
}
|
|
|
|
|
2018-04-09 17:49:02 +08:00
|
|
|
static int dwc3_gadget_set_xfer_resource(struct dwc3_ep *dep)
|
|
|
|
{
|
|
|
|
struct dwc3_gadget_ep_cmd_params params;
|
|
|
|
|
|
|
|
memset(¶ms, 0x00, sizeof(params));
|
|
|
|
|
|
|
|
params.param0 = DWC3_DEPXFERCFG_NUM_XFER_RES(1);
|
|
|
|
|
|
|
|
return dwc3_send_gadget_ep_cmd(dep, DWC3_DEPCMD_SETTRANSFRESOURCE,
|
|
|
|
¶ms);
|
|
|
|
}
|
2016-02-17 12:10:53 +08:00
|
|
|
|
|
|
|
/**
|
2017-04-19 19:59:27 +08:00
|
|
|
* dwc3_gadget_start_config - configure ep resources
|
2016-02-17 12:10:53 +08:00
|
|
|
* @dep: endpoint that is being enabled
|
|
|
|
*
|
2017-04-19 19:59:27 +08:00
|
|
|
* Issue a %DWC3_DEPCMD_DEPSTARTCFG command to @dep. After the command's
|
|
|
|
* completion, it will set Transfer Resource for all available endpoints.
|
2016-02-17 12:10:53 +08:00
|
|
|
*
|
2017-04-19 19:59:27 +08:00
|
|
|
* The assignment of transfer resources cannot perfectly follow the data book
|
|
|
|
* due to the fact that the controller driver does not have all knowledge of the
|
|
|
|
* configuration in advance. It is given this information piecemeal by the
|
|
|
|
* composite gadget framework after every SET_CONFIGURATION and
|
|
|
|
* SET_INTERFACE. Trying to follow the databook programming model in this
|
|
|
|
* scenario can cause errors. For two reasons:
|
2016-02-17 12:10:53 +08:00
|
|
|
*
|
2017-04-19 19:59:27 +08:00
|
|
|
* 1) The databook says to do %DWC3_DEPCMD_DEPSTARTCFG for every
|
|
|
|
* %USB_REQ_SET_CONFIGURATION and %USB_REQ_SET_INTERFACE (8.1.5). This is
|
|
|
|
* incorrect in the scenario of multiple interfaces.
|
|
|
|
*
|
|
|
|
* 2) The databook does not mention doing more %DWC3_DEPCMD_DEPXFERCFG for new
|
2016-02-17 12:10:53 +08:00
|
|
|
* endpoint on alt setting (8.1.6).
|
|
|
|
*
|
|
|
|
* The following simplified method is used instead:
|
|
|
|
*
|
2017-04-19 19:59:27 +08:00
|
|
|
* All hardware endpoints can be assigned a transfer resource and this setting
|
|
|
|
* will stay persistent until either a core reset or hibernation. So whenever we
|
|
|
|
* do a %DWC3_DEPCMD_DEPSTARTCFG(0) we can go ahead and do
|
|
|
|
* %DWC3_DEPCMD_DEPXFERCFG for every hardware endpoint as well. We are
|
2016-02-17 12:10:53 +08:00
|
|
|
* guaranteed that there are as many transfer resources as endpoints.
|
|
|
|
*
|
2017-04-19 19:59:27 +08:00
|
|
|
* This function is called for each endpoint when it is being enabled but is
|
|
|
|
* triggered only when called for EP0-out, which always happens first, and which
|
|
|
|
* should only happen in one of the above conditions.
|
2016-02-17 12:10:53 +08:00
|
|
|
*/
|
2018-04-09 17:46:47 +08:00
|
|
|
static int dwc3_gadget_start_config(struct dwc3_ep *dep)
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
{
|
|
|
|
struct dwc3_gadget_ep_cmd_params params;
|
2018-04-09 17:46:47 +08:00
|
|
|
struct dwc3 *dwc;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
u32 cmd;
|
2016-02-17 12:10:53 +08:00
|
|
|
int i;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (dep->number)
|
|
|
|
return 0;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
|
|
|
memset(¶ms, 0x00, sizeof(params));
|
2016-02-17 12:10:53 +08:00
|
|
|
cmd = DWC3_DEPCMD_DEPSTARTCFG;
|
2018-04-09 17:46:47 +08:00
|
|
|
dwc = dep->dwc;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2016-04-12 21:42:43 +08:00
|
|
|
ret = dwc3_send_gadget_ep_cmd(dep, cmd, ¶ms);
|
2016-02-17 12:10:53 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
for (i = 0; i < DWC3_ENDPOINTS_NUM; i++) {
|
|
|
|
struct dwc3_ep *dep = dwc->eps[i];
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2016-02-17 12:10:53 +08:00
|
|
|
if (!dep)
|
|
|
|
continue;
|
|
|
|
|
2018-04-09 17:46:47 +08:00
|
|
|
ret = dwc3_gadget_set_xfer_resource(dep);
|
2016-02-17 12:10:53 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-04-09 17:46:47 +08:00
|
|
|
static int dwc3_gadget_set_ep_config(struct dwc3_ep *dep, unsigned int action)
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
{
|
2016-11-10 08:36:28 +08:00
|
|
|
const struct usb_ss_ep_comp_descriptor *comp_desc;
|
|
|
|
const struct usb_endpoint_descriptor *desc;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
struct dwc3_gadget_ep_cmd_params params;
|
2018-04-09 17:46:47 +08:00
|
|
|
struct dwc3 *dwc = dep->dwc;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2016-11-10 08:36:28 +08:00
|
|
|
comp_desc = dep->endpoint.comp_desc;
|
|
|
|
desc = dep->endpoint.desc;
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
memset(¶ms, 0x00, sizeof(params));
|
|
|
|
|
2011-09-30 15:58:51 +08:00
|
|
|
params.param0 = DWC3_DEPCFG_EP_TYPE(usb_endpoint_type(desc))
|
2012-08-31 15:54:07 +08:00
|
|
|
| DWC3_DEPCFG_MAX_PACKET_SIZE(usb_endpoint_maxp(desc));
|
|
|
|
|
|
|
|
/* Burst size is only needed in SuperSpeed mode */
|
2016-02-06 09:08:45 +08:00
|
|
|
if (dwc->gadget.speed >= USB_SPEED_SUPER) {
|
2016-04-26 15:49:07 +08:00
|
|
|
u32 burst = dep->endpoint.maxburst;
|
|
|
|
params.param0 |= DWC3_DEPCFG_BURST_SIZE(burst - 1);
|
2012-08-31 15:54:07 +08:00
|
|
|
}
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2018-04-09 17:40:48 +08:00
|
|
|
params.param0 |= action;
|
|
|
|
if (action == DWC3_DEPCFG_ACTION_RESTORE)
|
2013-12-20 02:38:49 +08:00
|
|
|
params.param2 |= dep->saved_state;
|
|
|
|
|
2016-08-10 21:04:33 +08:00
|
|
|
if (usb_endpoint_xfer_control(desc))
|
|
|
|
params.param1 = DWC3_DEPCFG_XFER_COMPLETE_EN;
|
2016-05-30 18:40:00 +08:00
|
|
|
|
|
|
|
if (dep->number <= 1 || usb_endpoint_xfer_isoc(desc))
|
|
|
|
params.param1 |= DWC3_DEPCFG_XFER_NOT_READY_EN;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2012-01-02 19:35:41 +08:00
|
|
|
if (usb_ss_max_streams(comp_desc) && usb_endpoint_xfer_bulk(desc)) {
|
2011-09-30 15:58:51 +08:00
|
|
|
params.param1 |= DWC3_DEPCFG_STREAM_CAPABLE
|
|
|
|
| DWC3_DEPCFG_STREAM_EVENT_EN;
|
2011-09-30 15:58:47 +08:00
|
|
|
dep->stream_capable = true;
|
|
|
|
}
|
|
|
|
|
2014-09-04 23:28:10 +08:00
|
|
|
if (!usb_endpoint_xfer_control(desc))
|
2011-09-30 15:58:51 +08:00
|
|
|
params.param1 |= DWC3_DEPCFG_XFER_IN_PROGRESS_EN;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We are doing 1:1 mapping for endpoints, meaning
|
|
|
|
* Physical Endpoints 2 maps to Logical Endpoint 2 and
|
|
|
|
* so on. We consider the direction bit as part of the physical
|
|
|
|
* endpoint number. So USB endpoint 0x81 is 0x03.
|
|
|
|
*/
|
2011-09-30 15:58:51 +08:00
|
|
|
params.param1 |= DWC3_DEPCFG_EP_NUMBER(dep->number);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We must use the lower 16 TX FIFOs even though
|
|
|
|
* HW might have more
|
|
|
|
*/
|
|
|
|
if (dep->direction)
|
2011-09-30 15:58:51 +08:00
|
|
|
params.param0 |= DWC3_DEPCFG_FIFO_NUMBER(dep->number >> 1);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
|
|
|
if (desc->bInterval) {
|
2011-09-30 15:58:51 +08:00
|
|
|
params.param1 |= DWC3_DEPCFG_BINTERVAL_M1(desc->bInterval - 1);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
dep->interval = 1 << (desc->bInterval - 1);
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:42:43 +08:00
|
|
|
return dwc3_send_gadget_ep_cmd(dep, DWC3_DEPCMD_SETEPCONFIG, ¶ms);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-04-19 19:59:27 +08:00
|
|
|
* __dwc3_gadget_ep_enable - initializes a hw endpoint
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
* @dep: endpoint to be initialized
|
2018-04-09 17:40:48 +08:00
|
|
|
* @action: one of INIT, MODIFY or RESTORE
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
*
|
2017-04-19 19:59:27 +08:00
|
|
|
* Caller should take care of locking. Execute all necessary commands to
|
|
|
|
* initialize a HW endpoint so it can be used by a gadget driver.
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
*/
|
2018-04-09 17:40:48 +08:00
|
|
|
static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, unsigned int action)
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
{
|
2016-11-10 08:36:28 +08:00
|
|
|
const struct usb_endpoint_descriptor *desc = dep->endpoint.desc;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
struct dwc3 *dwc = dep->dwc;
|
2016-11-10 08:36:28 +08:00
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
u32 reg;
|
2014-05-15 20:53:32 +08:00
|
|
|
int ret;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
|
|
|
if (!(dep->flags & DWC3_EP_ENABLED)) {
|
2018-04-09 17:46:47 +08:00
|
|
|
ret = dwc3_gadget_start_config(dep);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-04-09 17:46:47 +08:00
|
|
|
ret = dwc3_gadget_set_ep_config(dep, action);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (!(dep->flags & DWC3_EP_ENABLED)) {
|
2012-02-06 17:04:53 +08:00
|
|
|
struct dwc3_trb *trb_st_hw;
|
|
|
|
struct dwc3_trb *trb_link;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
|
|
|
dep->type = usb_endpoint_type(desc);
|
|
|
|
dep->flags |= DWC3_EP_ENABLED;
|
|
|
|
|
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_DALEPENA);
|
|
|
|
reg |= DWC3_DALEPENA_EP(dep->number);
|
|
|
|
dwc3_writel(dwc->regs, DWC3_DALEPENA, reg);
|
|
|
|
|
2016-04-05 18:24:36 +08:00
|
|
|
if (usb_endpoint_xfer_control(desc))
|
2016-11-03 19:53:29 +08:00
|
|
|
goto out;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2016-05-20 08:26:08 +08:00
|
|
|
/* Initialize the TRB ring */
|
|
|
|
dep->trb_dequeue = 0;
|
|
|
|
dep->trb_enqueue = 0;
|
|
|
|
memset(dep->trb_pool, 0,
|
|
|
|
sizeof(struct dwc3_trb) * DWC3_TRB_NUM);
|
|
|
|
|
2016-04-05 18:24:36 +08:00
|
|
|
/* Link TRB. The HWO bit is never reset */
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
trb_st_hw = &dep->trb_pool[0];
|
|
|
|
|
2012-02-06 17:04:53 +08:00
|
|
|
trb_link = &dep->trb_pool[DWC3_TRB_NUM - 1];
|
|
|
|
trb_link->bpl = lower_32_bits(dwc3_trb_dma_offset(dep, trb_st_hw));
|
|
|
|
trb_link->bph = upper_32_bits(dwc3_trb_dma_offset(dep, trb_st_hw));
|
|
|
|
trb_link->ctrl |= DWC3_TRBCTL_LINK_TRB;
|
|
|
|
trb_link->ctrl |= DWC3_TRB_CTRL_HWO;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
|
2016-09-29 21:28:56 +08:00
|
|
|
/*
|
|
|
|
* Issue StartTransfer here with no-op TRB so we can always rely on No
|
|
|
|
* Response Update Transfer command.
|
|
|
|
*/
|
2018-12-01 19:13:27 +08:00
|
|
|
if ((usb_endpoint_xfer_bulk(desc) && !dep->stream_capable) ||
|
2018-03-26 18:19:43 +08:00
|
|
|
usb_endpoint_xfer_int(desc)) {
|
2016-09-29 21:28:56 +08:00
|
|
|
struct dwc3_gadget_ep_cmd_params params;
|
|
|
|
struct dwc3_trb *trb;
|
|
|
|
dma_addr_t trb_dma;
|
|
|
|
u32 cmd;
|
|
|
|
|
|
|
|
memset(¶ms, 0, sizeof(params));
|
|
|
|
trb = &dep->trb_pool[0];
|
|
|
|
trb_dma = dwc3_trb_dma_offset(dep, trb);
|
|
|
|
|
|
|
|
params.param0 = upper_32_bits(trb_dma);
|
|
|
|
params.param1 = lower_32_bits(trb_dma);
|
|
|
|
|
|
|
|
cmd = DWC3_DEPCMD_STARTTRANSFER;
|
|
|
|
|
|
|
|
ret = dwc3_send_gadget_ep_cmd(dep, cmd, ¶ms);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-11-03 19:53:29 +08:00
|
|
|
out:
|
|
|
|
trace_dwc3_gadget_ep_enable(dep);
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-02-13 19:00:54 +08:00
|
|
|
static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force,
|
|
|
|
bool interrupt);
|
2011-08-29 19:56:37 +08:00
|
|
|
static void dwc3_remove_requests(struct dwc3 *dwc, struct dwc3_ep *dep)
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
{
|
|
|
|
struct dwc3_request *req;
|
|
|
|
|
2019-02-13 19:00:54 +08:00
|
|
|
dwc3_stop_active_transfer(dep, true, false);
|
2011-08-29 19:56:37 +08:00
|
|
|
|
2016-06-21 15:32:02 +08:00
|
|
|
/* - giveback all requests to gadget driver */
|
|
|
|
while (!list_empty(&dep->started_list)) {
|
|
|
|
req = next_request(&dep->started_list);
|
2012-06-15 14:24:36 +08:00
|
|
|
|
2016-06-21 15:32:02 +08:00
|
|
|
dwc3_gadget_giveback(dep, req, -ESHUTDOWN);
|
2012-02-17 18:10:04 +08:00
|
|
|
}
|
|
|
|
|
2016-03-14 17:01:31 +08:00
|
|
|
while (!list_empty(&dep->pending_list)) {
|
|
|
|
req = next_request(&dep->pending_list);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2011-08-29 19:56:37 +08:00
|
|
|
dwc3_gadget_giveback(dep, req, -ESHUTDOWN);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-04-19 19:59:27 +08:00
|
|
|
* __dwc3_gadget_ep_disable - disables a hw endpoint
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
* @dep: the endpoint to disable
|
|
|
|
*
|
2017-04-19 19:59:27 +08:00
|
|
|
* This function undoes what __dwc3_gadget_ep_enable did and also removes
|
|
|
|
* requests which are currently being processed by the hardware and those which
|
|
|
|
* are not yet scheduled.
|
|
|
|
*
|
2011-08-29 19:56:37 +08:00
|
|
|
* Caller should take care of locking.
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
*/
|
|
|
|
static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep)
|
|
|
|
{
|
|
|
|
struct dwc3 *dwc = dep->dwc;
|
|
|
|
u32 reg;
|
|
|
|
|
2016-11-03 19:53:29 +08:00
|
|
|
trace_dwc3_gadget_ep_disable(dep);
|
2015-07-21 03:46:15 +08:00
|
|
|
|
2011-08-29 19:56:37 +08:00
|
|
|
dwc3_remove_requests(dwc, dep);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2014-04-16 23:30:33 +08:00
|
|
|
/* make sure HW endpoint isn't stalled */
|
|
|
|
if (dep->flags & DWC3_EP_STALL)
|
2014-09-25 03:19:52 +08:00
|
|
|
__dwc3_gadget_ep_set_halt(dep, 0, false);
|
2014-04-16 23:30:33 +08:00
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_DALEPENA);
|
|
|
|
reg &= ~DWC3_DALEPENA_EP(dep->number);
|
|
|
|
dwc3_writel(dwc->regs, DWC3_DALEPENA, reg);
|
|
|
|
|
2011-09-30 15:58:47 +08:00
|
|
|
dep->stream_capable = false;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
dep->type = 0;
|
2019-01-21 19:08:44 +08:00
|
|
|
dep->flags = 0;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2016-11-10 08:36:28 +08:00
|
|
|
/* Clear out the ep descriptors for non-ep0 */
|
|
|
|
if (dep->number > 1) {
|
|
|
|
dep->endpoint.comp_desc = NULL;
|
|
|
|
dep->endpoint.desc = NULL;
|
|
|
|
}
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static int dwc3_gadget_ep0_enable(struct usb_ep *ep,
|
|
|
|
const struct usb_endpoint_descriptor *desc)
|
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dwc3_gadget_ep0_disable(struct usb_ep *ep)
|
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static int dwc3_gadget_ep_enable(struct usb_ep *ep,
|
|
|
|
const struct usb_endpoint_descriptor *desc)
|
|
|
|
{
|
|
|
|
struct dwc3_ep *dep;
|
|
|
|
struct dwc3 *dwc;
|
|
|
|
unsigned long flags;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!ep || !desc || desc->bDescriptorType != USB_DT_ENDPOINT) {
|
|
|
|
pr_debug("dwc3: invalid parameters\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!desc->wMaxPacketSize) {
|
|
|
|
pr_debug("dwc3: missing wMaxPacketSize\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
dep = to_dwc3_ep(ep);
|
|
|
|
dwc = dep->dwc;
|
|
|
|
|
2015-12-11 03:08:20 +08:00
|
|
|
if (dev_WARN_ONCE(dwc->dev, dep->flags & DWC3_EP_ENABLED,
|
|
|
|
"%s is already enabled\n",
|
|
|
|
dep->name))
|
2012-08-15 17:28:29 +08:00
|
|
|
return 0;
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
spin_lock_irqsave(&dwc->lock, flags);
|
2018-04-09 17:40:48 +08:00
|
|
|
ret = __dwc3_gadget_ep_enable(dep, DWC3_DEPCFG_ACTION_INIT);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
spin_unlock_irqrestore(&dwc->lock, flags);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dwc3_gadget_ep_disable(struct usb_ep *ep)
|
|
|
|
{
|
|
|
|
struct dwc3_ep *dep;
|
|
|
|
struct dwc3 *dwc;
|
|
|
|
unsigned long flags;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!ep) {
|
|
|
|
pr_debug("dwc3: invalid parameters\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
dep = to_dwc3_ep(ep);
|
|
|
|
dwc = dep->dwc;
|
|
|
|
|
2015-12-11 03:08:20 +08:00
|
|
|
if (dev_WARN_ONCE(dwc->dev, !(dep->flags & DWC3_EP_ENABLED),
|
|
|
|
"%s is already disabled\n",
|
|
|
|
dep->name))
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&dwc->lock, flags);
|
|
|
|
ret = __dwc3_gadget_ep_disable(dep);
|
|
|
|
spin_unlock_irqrestore(&dwc->lock, flags);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct usb_request *dwc3_gadget_ep_alloc_request(struct usb_ep *ep,
|
2018-03-26 21:09:00 +08:00
|
|
|
gfp_t gfp_flags)
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
{
|
|
|
|
struct dwc3_request *req;
|
|
|
|
struct dwc3_ep *dep = to_dwc3_ep(ep);
|
|
|
|
|
|
|
|
req = kzalloc(sizeof(*req), gfp_flags);
|
2014-07-17 11:45:11 +08:00
|
|
|
if (!req)
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
return NULL;
|
|
|
|
|
2018-05-07 20:19:31 +08:00
|
|
|
req->direction = dep->direction;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
req->epnum = dep->number;
|
|
|
|
req->dep = dep;
|
2019-01-11 18:57:09 +08:00
|
|
|
req->status = DWC3_REQUEST_STATUS_UNKNOWN;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2014-05-01 06:45:10 +08:00
|
|
|
trace_dwc3_alloc_request(req);
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
return &req->request;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dwc3_gadget_ep_free_request(struct usb_ep *ep,
|
|
|
|
struct usb_request *request)
|
|
|
|
{
|
|
|
|
struct dwc3_request *req = to_dwc3_request(request);
|
|
|
|
|
2014-05-01 06:45:10 +08:00
|
|
|
trace_dwc3_free_request(req);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
kfree(req);
|
|
|
|
}
|
|
|
|
|
2018-04-09 18:01:43 +08:00
|
|
|
/**
|
|
|
|
* dwc3_ep_prev_trb - returns the previous TRB in the ring
|
|
|
|
* @dep: The endpoint with the TRB ring
|
|
|
|
* @index: The index of the current TRB in the ring
|
|
|
|
*
|
|
|
|
* Returns the TRB prior to the one pointed to by the index. If the
|
|
|
|
* index is 0, we will wrap backwards, skip the link TRB, and return
|
|
|
|
* the one just before that.
|
|
|
|
*/
|
|
|
|
static struct dwc3_trb *dwc3_ep_prev_trb(struct dwc3_ep *dep, u8 index)
|
|
|
|
{
|
|
|
|
u8 tmp = index;
|
|
|
|
|
|
|
|
if (!tmp)
|
|
|
|
tmp = DWC3_TRB_NUM - 1;
|
|
|
|
|
|
|
|
return &dep->trb_pool[tmp - 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32 dwc3_calc_trbs_left(struct dwc3_ep *dep)
|
|
|
|
{
|
|
|
|
struct dwc3_trb *tmp;
|
|
|
|
u8 trbs_left;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If enqueue & dequeue are equal than it is either full or empty.
|
|
|
|
*
|
|
|
|
* One way to know for sure is if the TRB right before us has HWO bit
|
|
|
|
* set or not. If it has, then we're definitely full and can't fit any
|
|
|
|
* more transfers in our ring.
|
|
|
|
*/
|
|
|
|
if (dep->trb_enqueue == dep->trb_dequeue) {
|
|
|
|
tmp = dwc3_ep_prev_trb(dep, dep->trb_enqueue);
|
|
|
|
if (tmp->ctrl & DWC3_TRB_CTRL_HWO)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return DWC3_TRB_NUM - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
trbs_left = dep->trb_dequeue - dep->trb_enqueue;
|
|
|
|
trbs_left &= (DWC3_TRB_NUM - 1);
|
|
|
|
|
|
|
|
if (dep->trb_dequeue < dep->trb_enqueue)
|
|
|
|
trbs_left--;
|
|
|
|
|
|
|
|
return trbs_left;
|
|
|
|
}
|
2016-08-12 18:13:10 +08:00
|
|
|
|
2017-01-05 20:40:53 +08:00
|
|
|
static void __dwc3_prepare_one_trb(struct dwc3_ep *dep, struct dwc3_trb *trb,
|
|
|
|
dma_addr_t dma, unsigned length, unsigned chain, unsigned node,
|
|
|
|
unsigned stream_id, unsigned short_not_ok, unsigned no_interrupt)
|
2011-11-22 17:37:34 +08:00
|
|
|
{
|
2016-09-22 16:01:01 +08:00
|
|
|
struct dwc3 *dwc = dep->dwc;
|
|
|
|
struct usb_gadget *gadget = &dwc->gadget;
|
|
|
|
enum usb_device_speed speed = gadget->speed;
|
2011-11-22 17:37:34 +08:00
|
|
|
|
2012-02-06 17:04:53 +08:00
|
|
|
trb->size = DWC3_TRB_SIZE_LENGTH(length);
|
|
|
|
trb->bpl = lower_32_bits(dma);
|
|
|
|
trb->bph = upper_32_bits(dma);
|
2011-11-22 17:37:34 +08:00
|
|
|
|
2012-03-13 02:25:24 +08:00
|
|
|
switch (usb_endpoint_type(dep->endpoint.desc)) {
|
2011-11-22 17:37:34 +08:00
|
|
|
case USB_ENDPOINT_XFER_CONTROL:
|
2012-02-06 17:04:53 +08:00
|
|
|
trb->ctrl = DWC3_TRBCTL_CONTROL_SETUP;
|
2011-11-22 17:37:34 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case USB_ENDPOINT_XFER_ISOC:
|
2016-09-22 16:01:01 +08:00
|
|
|
if (!node) {
|
2013-01-14 18:29:37 +08:00
|
|
|
trb->ctrl = DWC3_TRBCTL_ISOCHRONOUS_FIRST;
|
2016-09-22 16:01:01 +08:00
|
|
|
|
2017-07-19 19:37:10 +08:00
|
|
|
/*
|
|
|
|
* USB Specification 2.0 Section 5.9.2 states that: "If
|
|
|
|
* there is only a single transaction in the microframe,
|
|
|
|
* only a DATA0 data packet PID is used. If there are
|
|
|
|
* two transactions per microframe, DATA1 is used for
|
|
|
|
* the first transaction data packet and DATA0 is used
|
|
|
|
* for the second transaction data packet. If there are
|
|
|
|
* three transactions per microframe, DATA2 is used for
|
|
|
|
* the first transaction data packet, DATA1 is used for
|
|
|
|
* the second, and DATA0 is used for the third."
|
|
|
|
*
|
|
|
|
* IOW, we should satisfy the following cases:
|
|
|
|
*
|
|
|
|
* 1) length <= maxpacket
|
|
|
|
* - DATA0
|
|
|
|
*
|
|
|
|
* 2) maxpacket < length <= (2 * maxpacket)
|
|
|
|
* - DATA1, DATA0
|
|
|
|
*
|
|
|
|
* 3) (2 * maxpacket) < length <= (3 * maxpacket)
|
|
|
|
* - DATA2, DATA1, DATA0
|
|
|
|
*/
|
2016-09-22 16:01:01 +08:00
|
|
|
if (speed == USB_SPEED_HIGH) {
|
|
|
|
struct usb_ep *ep = &dep->endpoint;
|
2017-12-06 15:19:04 +08:00
|
|
|
unsigned int mult = 2;
|
2017-07-19 19:37:10 +08:00
|
|
|
unsigned int maxp = usb_endpoint_maxp(ep->desc);
|
|
|
|
|
|
|
|
if (length <= (2 * maxp))
|
|
|
|
mult--;
|
|
|
|
|
|
|
|
if (length <= maxp)
|
|
|
|
mult--;
|
|
|
|
|
|
|
|
trb->size |= DWC3_TRB_SIZE_PCM1(mult);
|
2016-09-22 16:01:01 +08:00
|
|
|
}
|
|
|
|
} else {
|
2013-01-14 18:29:37 +08:00
|
|
|
trb->ctrl = DWC3_TRBCTL_ISOCHRONOUS;
|
2016-09-22 16:01:01 +08:00
|
|
|
}
|
2016-03-10 19:53:27 +08:00
|
|
|
|
|
|
|
/* always enable Interrupt on Missed ISOC */
|
|
|
|
trb->ctrl |= DWC3_TRB_CTRL_ISP_IMI;
|
2011-11-22 17:37:34 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case USB_ENDPOINT_XFER_BULK:
|
|
|
|
case USB_ENDPOINT_XFER_INT:
|
2012-02-06 17:04:53 +08:00
|
|
|
trb->ctrl = DWC3_TRBCTL_NORMAL;
|
2011-11-22 17:37:34 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/*
|
|
|
|
* This is only possible with faulty memory because we
|
|
|
|
* checked it already :)
|
|
|
|
*/
|
2016-10-07 16:20:01 +08:00
|
|
|
dev_WARN(dwc->dev, "Unknown endpoint type %d\n",
|
|
|
|
usb_endpoint_type(dep->endpoint.desc));
|
2011-11-22 17:37:34 +08:00
|
|
|
}
|
|
|
|
|
2018-12-10 18:38:13 +08:00
|
|
|
/*
|
|
|
|
* Enable Continue on Short Packet
|
|
|
|
* when endpoint is not a stream capable
|
|
|
|
*/
|
2016-10-05 19:26:23 +08:00
|
|
|
if (usb_endpoint_dir_out(dep->endpoint.desc)) {
|
2018-12-10 18:38:13 +08:00
|
|
|
if (!dep->stream_capable)
|
|
|
|
trb->ctrl |= DWC3_TRB_CTRL_CSP;
|
2013-12-14 04:19:33 +08:00
|
|
|
|
2017-01-05 20:40:53 +08:00
|
|
|
if (short_not_ok)
|
2016-10-05 19:26:23 +08:00
|
|
|
trb->ctrl |= DWC3_TRB_CTRL_ISP_IMI;
|
|
|
|
}
|
|
|
|
|
2017-01-05 20:40:53 +08:00
|
|
|
if ((!no_interrupt && !chain) ||
|
2018-12-01 19:13:29 +08:00
|
|
|
(dwc3_calc_trbs_left(dep) == 1))
|
2016-10-05 19:26:23 +08:00
|
|
|
trb->ctrl |= DWC3_TRB_CTRL_IOC;
|
2013-12-14 04:19:33 +08:00
|
|
|
|
2013-01-14 18:29:37 +08:00
|
|
|
if (chain)
|
|
|
|
trb->ctrl |= DWC3_TRB_CTRL_CHN;
|
|
|
|
|
2012-03-13 02:25:24 +08:00
|
|
|
if (usb_endpoint_xfer_bulk(dep->endpoint.desc) && dep->stream_capable)
|
2017-01-05 20:40:53 +08:00
|
|
|
trb->ctrl |= DWC3_TRB_CTRL_SID_SOFN(stream_id);
|
2011-11-22 17:37:34 +08:00
|
|
|
|
2012-02-06 17:04:53 +08:00
|
|
|
trb->ctrl |= DWC3_TRB_CTRL_HWO;
|
2014-05-01 06:45:10 +08:00
|
|
|
|
2018-12-01 19:13:29 +08:00
|
|
|
dwc3_ep_inc_enq(dep);
|
|
|
|
|
2014-05-01 06:45:10 +08:00
|
|
|
trace_dwc3_prepare_trb(dep, trb);
|
2011-11-22 17:37:34 +08:00
|
|
|
}
|
|
|
|
|
2017-01-05 20:40:53 +08:00
|
|
|
/**
|
|
|
|
* dwc3_prepare_one_trb - setup one TRB from one request
|
|
|
|
* @dep: endpoint for which this request is prepared
|
|
|
|
* @req: dwc3_request pointer
|
|
|
|
* @chain: should this TRB be chained to the next?
|
|
|
|
* @node: only for isochronous endpoints. First TRB needs different type.
|
|
|
|
*/
|
|
|
|
static void dwc3_prepare_one_trb(struct dwc3_ep *dep,
|
|
|
|
struct dwc3_request *req, unsigned chain, unsigned node)
|
|
|
|
{
|
|
|
|
struct dwc3_trb *trb;
|
2018-03-27 19:05:20 +08:00
|
|
|
unsigned int length;
|
|
|
|
dma_addr_t dma;
|
2017-01-05 20:40:53 +08:00
|
|
|
unsigned stream_id = req->request.stream_id;
|
|
|
|
unsigned short_not_ok = req->request.short_not_ok;
|
|
|
|
unsigned no_interrupt = req->request.no_interrupt;
|
2018-03-27 19:05:20 +08:00
|
|
|
|
|
|
|
if (req->request.num_sgs > 0) {
|
|
|
|
length = sg_dma_len(req->start_sg);
|
|
|
|
dma = sg_dma_address(req->start_sg);
|
|
|
|
} else {
|
|
|
|
length = req->request.length;
|
|
|
|
dma = req->request.dma;
|
|
|
|
}
|
2017-01-05 20:40:53 +08:00
|
|
|
|
|
|
|
trb = &dep->trb_pool[dep->trb_enqueue];
|
|
|
|
|
|
|
|
if (!req->trb) {
|
|
|
|
dwc3_gadget_move_started_request(req);
|
|
|
|
req->trb = trb;
|
|
|
|
req->trb_dma = dwc3_trb_dma_offset(dep, trb);
|
|
|
|
}
|
|
|
|
|
2018-08-01 18:32:07 +08:00
|
|
|
req->num_trbs++;
|
|
|
|
|
2017-01-05 20:40:53 +08:00
|
|
|
__dwc3_prepare_one_trb(dep, trb, dma, length, chain, node,
|
|
|
|
stream_id, short_not_ok, no_interrupt);
|
|
|
|
}
|
|
|
|
|
2016-05-13 17:42:44 +08:00
|
|
|
static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
|
2016-08-24 19:37:22 +08:00
|
|
|
struct dwc3_request *req)
|
2016-05-13 17:42:44 +08:00
|
|
|
{
|
2018-03-27 19:05:20 +08:00
|
|
|
struct scatterlist *sg = req->start_sg;
|
2016-05-13 17:42:44 +08:00
|
|
|
struct scatterlist *s;
|
|
|
|
int i;
|
|
|
|
|
2018-03-27 19:05:21 +08:00
|
|
|
unsigned int remaining = req->request.num_mapped_sgs
|
|
|
|
- req->num_queued_sgs;
|
|
|
|
|
|
|
|
for_each_sg(sg, s, remaining, i) {
|
2017-01-05 20:58:46 +08:00
|
|
|
unsigned int length = req->request.length;
|
|
|
|
unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc);
|
|
|
|
unsigned int rem = length % maxp;
|
2016-05-13 17:42:44 +08:00
|
|
|
unsigned chain = true;
|
|
|
|
|
2016-08-10 21:04:33 +08:00
|
|
|
if (sg_is_last(s))
|
2016-05-13 17:42:44 +08:00
|
|
|
chain = false;
|
|
|
|
|
2017-01-05 20:58:46 +08:00
|
|
|
if (rem && usb_endpoint_dir_out(dep->endpoint.desc) && !chain) {
|
|
|
|
struct dwc3 *dwc = dep->dwc;
|
|
|
|
struct dwc3_trb *trb;
|
|
|
|
|
2018-08-01 18:15:05 +08:00
|
|
|
req->needs_extra_trb = true;
|
2017-01-05 20:58:46 +08:00
|
|
|
|
|
|
|
/* prepare normal TRB */
|
|
|
|
dwc3_prepare_one_trb(dep, req, true, i);
|
|
|
|
|
|
|
|
/* Now prepare one extra TRB to align transfer size */
|
|
|
|
trb = &dep->trb_pool[dep->trb_enqueue];
|
2018-08-01 18:32:07 +08:00
|
|
|
req->num_trbs++;
|
2017-01-05 20:58:46 +08:00
|
|
|
__dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr,
|
2018-08-01 14:37:34 +08:00
|
|
|
maxp - rem, false, 1,
|
2017-01-05 20:58:46 +08:00
|
|
|
req->request.stream_id,
|
|
|
|
req->request.short_not_ok,
|
|
|
|
req->request.no_interrupt);
|
|
|
|
} else {
|
|
|
|
dwc3_prepare_one_trb(dep, req, chain, i);
|
|
|
|
}
|
2016-05-13 17:42:44 +08:00
|
|
|
|
2018-03-27 19:05:20 +08:00
|
|
|
/*
|
|
|
|
* There can be a situation where all sgs in sglist are not
|
|
|
|
* queued because of insufficient trb number. To handle this
|
|
|
|
* case, update start_sg to next sg to be queued, so that
|
|
|
|
* we have free trbs we can continue queuing from where we
|
|
|
|
* previously stopped
|
|
|
|
*/
|
|
|
|
if (chain)
|
|
|
|
req->start_sg = sg_next(s);
|
|
|
|
|
2018-03-27 19:05:21 +08:00
|
|
|
req->num_queued_sgs++;
|
|
|
|
|
2016-08-24 19:37:22 +08:00
|
|
|
if (!dwc3_calc_trbs_left(dep))
|
2016-05-13 17:42:44 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
|
2016-08-24 19:37:22 +08:00
|
|
|
struct dwc3_request *req)
|
2016-05-13 17:42:44 +08:00
|
|
|
{
|
2017-01-05 20:58:46 +08:00
|
|
|
unsigned int length = req->request.length;
|
|
|
|
unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc);
|
|
|
|
unsigned int rem = length % maxp;
|
|
|
|
|
2019-01-22 15:56:51 +08:00
|
|
|
if ((!length || rem) && usb_endpoint_dir_out(dep->endpoint.desc)) {
|
2017-01-05 20:58:46 +08:00
|
|
|
struct dwc3 *dwc = dep->dwc;
|
|
|
|
struct dwc3_trb *trb;
|
|
|
|
|
2018-08-01 18:15:05 +08:00
|
|
|
req->needs_extra_trb = true;
|
2017-01-05 20:58:46 +08:00
|
|
|
|
|
|
|
/* prepare normal TRB */
|
|
|
|
dwc3_prepare_one_trb(dep, req, true, 0);
|
|
|
|
|
|
|
|
/* Now prepare one extra TRB to align transfer size */
|
|
|
|
trb = &dep->trb_pool[dep->trb_enqueue];
|
2018-08-01 18:32:07 +08:00
|
|
|
req->num_trbs++;
|
2017-01-05 20:58:46 +08:00
|
|
|
__dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, maxp - rem,
|
2018-08-01 14:37:34 +08:00
|
|
|
false, 1, req->request.stream_id,
|
2017-01-05 20:58:46 +08:00
|
|
|
req->request.short_not_ok,
|
|
|
|
req->request.no_interrupt);
|
2017-04-07 21:34:38 +08:00
|
|
|
} else if (req->request.zero && req->request.length &&
|
2018-07-28 09:52:41 +08:00
|
|
|
(IS_ALIGNED(req->request.length, maxp))) {
|
2017-04-07 21:34:38 +08:00
|
|
|
struct dwc3 *dwc = dep->dwc;
|
|
|
|
struct dwc3_trb *trb;
|
|
|
|
|
2018-08-01 18:15:05 +08:00
|
|
|
req->needs_extra_trb = true;
|
2017-04-07 21:34:38 +08:00
|
|
|
|
|
|
|
/* prepare normal TRB */
|
|
|
|
dwc3_prepare_one_trb(dep, req, true, 0);
|
|
|
|
|
|
|
|
/* Now prepare one extra TRB to handle ZLP */
|
|
|
|
trb = &dep->trb_pool[dep->trb_enqueue];
|
2018-08-01 18:32:07 +08:00
|
|
|
req->num_trbs++;
|
2017-04-07 21:34:38 +08:00
|
|
|
__dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, 0,
|
2018-08-01 14:37:34 +08:00
|
|
|
false, 1, req->request.stream_id,
|
2017-04-07 21:34:38 +08:00
|
|
|
req->request.short_not_ok,
|
|
|
|
req->request.no_interrupt);
|
2017-01-05 20:58:46 +08:00
|
|
|
} else {
|
|
|
|
dwc3_prepare_one_trb(dep, req, false, 0);
|
|
|
|
}
|
2016-05-13 17:42:44 +08:00
|
|
|
}
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
/*
|
|
|
|
* dwc3_prepare_trbs - setup TRBs from requests
|
|
|
|
* @dep: endpoint for which requests are being prepared
|
|
|
|
*
|
2012-02-16 10:56:56 +08:00
|
|
|
* The function goes through the requests list and sets up TRBs for the
|
|
|
|
* transfers. The function returns once there are no more TRBs available or
|
|
|
|
* it runs out of requests.
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
*/
|
2016-05-12 19:08:34 +08:00
|
|
|
static void dwc3_prepare_trbs(struct dwc3_ep *dep)
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
{
|
2011-11-28 18:25:01 +08:00
|
|
|
struct dwc3_request *req, *n;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
|
|
|
BUILD_BUG_ON_NOT_POWER_OF_2(DWC3_TRB_NUM);
|
|
|
|
|
2016-10-25 18:48:52 +08:00
|
|
|
/*
|
|
|
|
* We can get in a situation where there's a request in the started list
|
|
|
|
* but there weren't enough TRBs to fully kick it in the first time
|
|
|
|
* around, so it has been waiting for more TRBs to be freed up.
|
|
|
|
*
|
|
|
|
* In that case, we should check if we have a request with pending_sgs
|
|
|
|
* in the started list and prepare TRBs for that request first,
|
|
|
|
* otherwise we will prepare TRBs completely out of order and that will
|
|
|
|
* break things.
|
|
|
|
*/
|
|
|
|
list_for_each_entry(req, &dep->started_list, list) {
|
|
|
|
if (req->num_pending_sgs > 0)
|
|
|
|
dwc3_prepare_one_trb_sg(dep, req);
|
|
|
|
|
|
|
|
if (!dwc3_calc_trbs_left(dep))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-14 17:01:31 +08:00
|
|
|
list_for_each_entry_safe(req, n, &dep->pending_list, list) {
|
2017-05-17 18:21:14 +08:00
|
|
|
struct dwc3 *dwc = dep->dwc;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = usb_gadget_map_request_by_dev(dwc->sysdev, &req->request,
|
|
|
|
dep->direction);
|
|
|
|
if (ret)
|
|
|
|
return;
|
|
|
|
|
|
|
|
req->sg = req->request.sg;
|
2018-03-27 19:05:20 +08:00
|
|
|
req->start_sg = req->sg;
|
2018-03-27 19:05:21 +08:00
|
|
|
req->num_queued_sgs = 0;
|
2017-05-17 18:21:14 +08:00
|
|
|
req->num_pending_sgs = req->request.num_mapped_sgs;
|
|
|
|
|
2016-08-12 18:17:27 +08:00
|
|
|
if (req->num_pending_sgs > 0)
|
2016-08-24 19:37:22 +08:00
|
|
|
dwc3_prepare_one_trb_sg(dep, req);
|
2016-05-13 17:42:44 +08:00
|
|
|
else
|
2016-08-24 19:37:22 +08:00
|
|
|
dwc3_prepare_one_trb_linear(dep, req);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2016-08-24 19:37:22 +08:00
|
|
|
if (!dwc3_calc_trbs_left(dep))
|
2016-05-13 17:42:44 +08:00
|
|
|
return;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-05 19:41:34 +08:00
|
|
|
static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep)
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
{
|
|
|
|
struct dwc3_gadget_ep_cmd_params params;
|
|
|
|
struct dwc3_request *req;
|
2016-05-12 21:53:59 +08:00
|
|
|
int starting;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
int ret;
|
|
|
|
u32 cmd;
|
|
|
|
|
2017-09-05 19:28:46 +08:00
|
|
|
if (!dwc3_calc_trbs_left(dep))
|
|
|
|
return 0;
|
|
|
|
|
2018-03-29 16:08:46 +08:00
|
|
|
starting = !(dep->flags & DWC3_EP_TRANSFER_STARTED);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2016-05-12 21:53:59 +08:00
|
|
|
dwc3_prepare_trbs(dep);
|
|
|
|
req = next_request(&dep->started_list);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
if (!req) {
|
|
|
|
dep->flags |= DWC3_EP_PENDING_REQUEST;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(¶ms, 0, sizeof(params));
|
|
|
|
|
2016-05-12 21:53:59 +08:00
|
|
|
if (starting) {
|
2013-01-14 18:29:36 +08:00
|
|
|
params.param0 = upper_32_bits(req->trb_dma);
|
|
|
|
params.param1 = lower_32_bits(req->trb_dma);
|
2017-09-05 19:41:34 +08:00
|
|
|
cmd = DWC3_DEPCMD_STARTTRANSFER;
|
|
|
|
|
2018-12-01 19:13:25 +08:00
|
|
|
if (dep->stream_capable)
|
|
|
|
cmd |= DWC3_DEPCMD_PARAM(req->request.stream_id);
|
|
|
|
|
2017-09-05 19:41:34 +08:00
|
|
|
if (usb_endpoint_xfer_isoc(dep->endpoint.desc))
|
|
|
|
cmd |= DWC3_DEPCMD_PARAM(dep->frame_number);
|
2013-01-14 18:29:36 +08:00
|
|
|
} else {
|
2016-05-30 18:29:35 +08:00
|
|
|
cmd = DWC3_DEPCMD_UPDATETRANSFER |
|
|
|
|
DWC3_DEPCMD_PARAM(dep->resource_index);
|
2013-01-14 18:29:36 +08:00
|
|
|
}
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2016-04-12 21:42:43 +08:00
|
|
|
ret = dwc3_send_gadget_ep_cmd(dep, cmd, ¶ms);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
if (ret < 0) {
|
|
|
|
/*
|
|
|
|
* FIXME we need to iterate over the list of requests
|
|
|
|
* here and stop, unmap, free and del each of the linked
|
2012-02-16 10:56:56 +08:00
|
|
|
* requests instead of what we do now.
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
*/
|
2016-11-09 18:01:32 +08:00
|
|
|
if (req->trb)
|
|
|
|
memset(req->trb, 0, sizeof(struct dwc3_trb));
|
2018-03-26 18:14:47 +08:00
|
|
|
dwc3_gadget_del_and_unmap_request(dep, req, ret);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-10-21 18:07:09 +08:00
|
|
|
static int __dwc3_gadget_get_frame(struct dwc3 *dwc)
|
|
|
|
{
|
|
|
|
u32 reg;
|
|
|
|
|
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_DSTS);
|
|
|
|
return DWC3_DSTS_SOFFN(reg);
|
|
|
|
}
|
|
|
|
|
usb: dwc3: Add workaround for isoc start transfer failure
In DWC_usb31 version 1.70a-ea06 and prior, for highspeed and fullspeed
isochronous IN, BIT[15:14] of the 16-bit microframe number reported by
the XferNotReady event are invalid. The driver uses this number to
schedule the isochronous transfer and passes it to the START TRANSFER
command. Because this number is invalid, the command may fail. If
BIT[15:14] matches the internal 16-bit microframe, the START TRANSFER
command will pass and the transfer will start at the scheduled time, if
it is off by 1, the command will still pass, but the transfer will start
2 seconds in the future. For all other conditions, the START TRANSFER
command will fail with bus-expiry.
In order to workaround this issue, we can test for the correct
combination of BIT[15:14] by sending START TRANSFER commands with
different values of BIT[15:14]: 'b00, 'b01, 'b10, and 'b11. Each
combination is 2^14 uframe apart (or 2 seconds). 4 seconds into the
future will result in a bus-expiry status. As the result, within the 4
possible combinations for BIT[15:14], there will be 2 successful and 2
failure START COMMAND status. One of the 2 successful command status
will result in a 2-second delay start. The smaller BIT[15:14] value is
the correct combination.
Since there are only 4 outcomes and the results are ordered, we can
simply test 2 START TRANSFER commands with BIT[15:14] combinations 'b00
and 'b01 to deduce the smaller successful combination.
Let test0 = test status for combination 'b00 and test1 = test status for
'b01 of BIT[15:14]. The correct combination is as follow:
if test0 fails and test1 passes, BIT[15:14] is 'b01
if test0 fails and test1 fails, BIT[15:14] is 'b10
if test0 passes and test1 fails, BIT[15:14] is 'b11
if test0 passes and test1 passes, BIT[15:14] is 'b00
Synopsys STAR 9001202023: Wrong microframe number for isochronous IN
endpoints.
Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-11-15 14:56:54 +08:00
|
|
|
/**
|
|
|
|
* dwc3_gadget_start_isoc_quirk - workaround invalid frame number
|
|
|
|
* @dep: isoc endpoint
|
|
|
|
*
|
|
|
|
* This function tests for the correct combination of BIT[15:14] from the 16-bit
|
|
|
|
* microframe number reported by the XferNotReady event for the future frame
|
|
|
|
* number to start the isoc transfer.
|
|
|
|
*
|
|
|
|
* In DWC_usb31 version 1.70a-ea06 and prior, for highspeed and fullspeed
|
|
|
|
* isochronous IN, BIT[15:14] of the 16-bit microframe number reported by the
|
|
|
|
* XferNotReady event are invalid. The driver uses this number to schedule the
|
|
|
|
* isochronous transfer and passes it to the START TRANSFER command. Because
|
|
|
|
* this number is invalid, the command may fail. If BIT[15:14] matches the
|
|
|
|
* internal 16-bit microframe, the START TRANSFER command will pass and the
|
|
|
|
* transfer will start at the scheduled time, if it is off by 1, the command
|
|
|
|
* will still pass, but the transfer will start 2 seconds in the future. For all
|
|
|
|
* other conditions, the START TRANSFER command will fail with bus-expiry.
|
|
|
|
*
|
|
|
|
* In order to workaround this issue, we can test for the correct combination of
|
|
|
|
* BIT[15:14] by sending START TRANSFER commands with different values of
|
|
|
|
* BIT[15:14]: 'b00, 'b01, 'b10, and 'b11. Each combination is 2^14 uframe apart
|
|
|
|
* (or 2 seconds). 4 seconds into the future will result in a bus-expiry status.
|
|
|
|
* As the result, within the 4 possible combinations for BIT[15:14], there will
|
|
|
|
* be 2 successful and 2 failure START COMMAND status. One of the 2 successful
|
|
|
|
* command status will result in a 2-second delay start. The smaller BIT[15:14]
|
|
|
|
* value is the correct combination.
|
|
|
|
*
|
|
|
|
* Since there are only 4 outcomes and the results are ordered, we can simply
|
|
|
|
* test 2 START TRANSFER commands with BIT[15:14] combinations 'b00 and 'b01 to
|
|
|
|
* deduce the smaller successful combination.
|
|
|
|
*
|
|
|
|
* Let test0 = test status for combination 'b00 and test1 = test status for 'b01
|
|
|
|
* of BIT[15:14]. The correct combination is as follow:
|
|
|
|
*
|
|
|
|
* if test0 fails and test1 passes, BIT[15:14] is 'b01
|
|
|
|
* if test0 fails and test1 fails, BIT[15:14] is 'b10
|
|
|
|
* if test0 passes and test1 fails, BIT[15:14] is 'b11
|
|
|
|
* if test0 passes and test1 passes, BIT[15:14] is 'b00
|
|
|
|
*
|
|
|
|
* Synopsys STAR 9001202023: Wrong microframe number for isochronous IN
|
|
|
|
* endpoints.
|
|
|
|
*/
|
2018-08-14 15:41:19 +08:00
|
|
|
static int dwc3_gadget_start_isoc_quirk(struct dwc3_ep *dep)
|
usb: dwc3: Add workaround for isoc start transfer failure
In DWC_usb31 version 1.70a-ea06 and prior, for highspeed and fullspeed
isochronous IN, BIT[15:14] of the 16-bit microframe number reported by
the XferNotReady event are invalid. The driver uses this number to
schedule the isochronous transfer and passes it to the START TRANSFER
command. Because this number is invalid, the command may fail. If
BIT[15:14] matches the internal 16-bit microframe, the START TRANSFER
command will pass and the transfer will start at the scheduled time, if
it is off by 1, the command will still pass, but the transfer will start
2 seconds in the future. For all other conditions, the START TRANSFER
command will fail with bus-expiry.
In order to workaround this issue, we can test for the correct
combination of BIT[15:14] by sending START TRANSFER commands with
different values of BIT[15:14]: 'b00, 'b01, 'b10, and 'b11. Each
combination is 2^14 uframe apart (or 2 seconds). 4 seconds into the
future will result in a bus-expiry status. As the result, within the 4
possible combinations for BIT[15:14], there will be 2 successful and 2
failure START COMMAND status. One of the 2 successful command status
will result in a 2-second delay start. The smaller BIT[15:14] value is
the correct combination.
Since there are only 4 outcomes and the results are ordered, we can
simply test 2 START TRANSFER commands with BIT[15:14] combinations 'b00
and 'b01 to deduce the smaller successful combination.
Let test0 = test status for combination 'b00 and test1 = test status for
'b01 of BIT[15:14]. The correct combination is as follow:
if test0 fails and test1 passes, BIT[15:14] is 'b01
if test0 fails and test1 fails, BIT[15:14] is 'b10
if test0 passes and test1 fails, BIT[15:14] is 'b11
if test0 passes and test1 passes, BIT[15:14] is 'b00
Synopsys STAR 9001202023: Wrong microframe number for isochronous IN
endpoints.
Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-11-15 14:56:54 +08:00
|
|
|
{
|
|
|
|
int cmd_status = 0;
|
|
|
|
bool test0;
|
|
|
|
bool test1;
|
|
|
|
|
|
|
|
while (dep->combo_num < 2) {
|
|
|
|
struct dwc3_gadget_ep_cmd_params params;
|
|
|
|
u32 test_frame_number;
|
|
|
|
u32 cmd;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if we can start isoc transfer on the next interval or
|
|
|
|
* 4 uframes in the future with BIT[15:14] as dep->combo_num
|
|
|
|
*/
|
|
|
|
test_frame_number = dep->frame_number & 0x3fff;
|
|
|
|
test_frame_number |= dep->combo_num << 14;
|
|
|
|
test_frame_number += max_t(u32, 4, dep->interval);
|
|
|
|
|
|
|
|
params.param0 = upper_32_bits(dep->dwc->bounce_addr);
|
|
|
|
params.param1 = lower_32_bits(dep->dwc->bounce_addr);
|
|
|
|
|
|
|
|
cmd = DWC3_DEPCMD_STARTTRANSFER;
|
|
|
|
cmd |= DWC3_DEPCMD_PARAM(test_frame_number);
|
|
|
|
cmd_status = dwc3_send_gadget_ep_cmd(dep, cmd, ¶ms);
|
|
|
|
|
|
|
|
/* Redo if some other failure beside bus-expiry is received */
|
|
|
|
if (cmd_status && cmd_status != -EAGAIN) {
|
|
|
|
dep->start_cmd_status = 0;
|
|
|
|
dep->combo_num = 0;
|
2018-08-14 15:41:19 +08:00
|
|
|
return 0;
|
usb: dwc3: Add workaround for isoc start transfer failure
In DWC_usb31 version 1.70a-ea06 and prior, for highspeed and fullspeed
isochronous IN, BIT[15:14] of the 16-bit microframe number reported by
the XferNotReady event are invalid. The driver uses this number to
schedule the isochronous transfer and passes it to the START TRANSFER
command. Because this number is invalid, the command may fail. If
BIT[15:14] matches the internal 16-bit microframe, the START TRANSFER
command will pass and the transfer will start at the scheduled time, if
it is off by 1, the command will still pass, but the transfer will start
2 seconds in the future. For all other conditions, the START TRANSFER
command will fail with bus-expiry.
In order to workaround this issue, we can test for the correct
combination of BIT[15:14] by sending START TRANSFER commands with
different values of BIT[15:14]: 'b00, 'b01, 'b10, and 'b11. Each
combination is 2^14 uframe apart (or 2 seconds). 4 seconds into the
future will result in a bus-expiry status. As the result, within the 4
possible combinations for BIT[15:14], there will be 2 successful and 2
failure START COMMAND status. One of the 2 successful command status
will result in a 2-second delay start. The smaller BIT[15:14] value is
the correct combination.
Since there are only 4 outcomes and the results are ordered, we can
simply test 2 START TRANSFER commands with BIT[15:14] combinations 'b00
and 'b01 to deduce the smaller successful combination.
Let test0 = test status for combination 'b00 and test1 = test status for
'b01 of BIT[15:14]. The correct combination is as follow:
if test0 fails and test1 passes, BIT[15:14] is 'b01
if test0 fails and test1 fails, BIT[15:14] is 'b10
if test0 passes and test1 fails, BIT[15:14] is 'b11
if test0 passes and test1 passes, BIT[15:14] is 'b00
Synopsys STAR 9001202023: Wrong microframe number for isochronous IN
endpoints.
Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-11-15 14:56:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Store the first test status */
|
|
|
|
if (dep->combo_num == 0)
|
|
|
|
dep->start_cmd_status = cmd_status;
|
|
|
|
|
|
|
|
dep->combo_num++;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* End the transfer if the START_TRANSFER command is successful
|
|
|
|
* to wait for the next XferNotReady to test the command again
|
|
|
|
*/
|
|
|
|
if (cmd_status == 0) {
|
2019-02-13 19:00:54 +08:00
|
|
|
dwc3_stop_active_transfer(dep, true, true);
|
2018-08-14 15:41:19 +08:00
|
|
|
return 0;
|
usb: dwc3: Add workaround for isoc start transfer failure
In DWC_usb31 version 1.70a-ea06 and prior, for highspeed and fullspeed
isochronous IN, BIT[15:14] of the 16-bit microframe number reported by
the XferNotReady event are invalid. The driver uses this number to
schedule the isochronous transfer and passes it to the START TRANSFER
command. Because this number is invalid, the command may fail. If
BIT[15:14] matches the internal 16-bit microframe, the START TRANSFER
command will pass and the transfer will start at the scheduled time, if
it is off by 1, the command will still pass, but the transfer will start
2 seconds in the future. For all other conditions, the START TRANSFER
command will fail with bus-expiry.
In order to workaround this issue, we can test for the correct
combination of BIT[15:14] by sending START TRANSFER commands with
different values of BIT[15:14]: 'b00, 'b01, 'b10, and 'b11. Each
combination is 2^14 uframe apart (or 2 seconds). 4 seconds into the
future will result in a bus-expiry status. As the result, within the 4
possible combinations for BIT[15:14], there will be 2 successful and 2
failure START COMMAND status. One of the 2 successful command status
will result in a 2-second delay start. The smaller BIT[15:14] value is
the correct combination.
Since there are only 4 outcomes and the results are ordered, we can
simply test 2 START TRANSFER commands with BIT[15:14] combinations 'b00
and 'b01 to deduce the smaller successful combination.
Let test0 = test status for combination 'b00 and test1 = test status for
'b01 of BIT[15:14]. The correct combination is as follow:
if test0 fails and test1 passes, BIT[15:14] is 'b01
if test0 fails and test1 fails, BIT[15:14] is 'b10
if test0 passes and test1 fails, BIT[15:14] is 'b11
if test0 passes and test1 passes, BIT[15:14] is 'b00
Synopsys STAR 9001202023: Wrong microframe number for isochronous IN
endpoints.
Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-11-15 14:56:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* test0 and test1 are both completed at this point */
|
|
|
|
test0 = (dep->start_cmd_status == 0);
|
|
|
|
test1 = (cmd_status == 0);
|
|
|
|
|
|
|
|
if (!test0 && test1)
|
|
|
|
dep->combo_num = 1;
|
|
|
|
else if (!test0 && !test1)
|
|
|
|
dep->combo_num = 2;
|
|
|
|
else if (test0 && !test1)
|
|
|
|
dep->combo_num = 3;
|
|
|
|
else if (test0 && test1)
|
|
|
|
dep->combo_num = 0;
|
|
|
|
|
|
|
|
dep->frame_number &= 0x3fff;
|
|
|
|
dep->frame_number |= dep->combo_num << 14;
|
|
|
|
dep->frame_number += max_t(u32, 4, dep->interval);
|
|
|
|
|
|
|
|
/* Reinitialize test variables */
|
|
|
|
dep->start_cmd_status = 0;
|
|
|
|
dep->combo_num = 0;
|
|
|
|
|
2018-08-14 15:41:19 +08:00
|
|
|
return __dwc3_gadget_kick_transfer(dep);
|
usb: dwc3: Add workaround for isoc start transfer failure
In DWC_usb31 version 1.70a-ea06 and prior, for highspeed and fullspeed
isochronous IN, BIT[15:14] of the 16-bit microframe number reported by
the XferNotReady event are invalid. The driver uses this number to
schedule the isochronous transfer and passes it to the START TRANSFER
command. Because this number is invalid, the command may fail. If
BIT[15:14] matches the internal 16-bit microframe, the START TRANSFER
command will pass and the transfer will start at the scheduled time, if
it is off by 1, the command will still pass, but the transfer will start
2 seconds in the future. For all other conditions, the START TRANSFER
command will fail with bus-expiry.
In order to workaround this issue, we can test for the correct
combination of BIT[15:14] by sending START TRANSFER commands with
different values of BIT[15:14]: 'b00, 'b01, 'b10, and 'b11. Each
combination is 2^14 uframe apart (or 2 seconds). 4 seconds into the
future will result in a bus-expiry status. As the result, within the 4
possible combinations for BIT[15:14], there will be 2 successful and 2
failure START COMMAND status. One of the 2 successful command status
will result in a 2-second delay start. The smaller BIT[15:14] value is
the correct combination.
Since there are only 4 outcomes and the results are ordered, we can
simply test 2 START TRANSFER commands with BIT[15:14] combinations 'b00
and 'b01 to deduce the smaller successful combination.
Let test0 = test status for combination 'b00 and test1 = test status for
'b01 of BIT[15:14]. The correct combination is as follow:
if test0 fails and test1 passes, BIT[15:14] is 'b01
if test0 fails and test1 fails, BIT[15:14] is 'b10
if test0 passes and test1 fails, BIT[15:14] is 'b11
if test0 passes and test1 passes, BIT[15:14] is 'b00
Synopsys STAR 9001202023: Wrong microframe number for isochronous IN
endpoints.
Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-11-15 14:56:54 +08:00
|
|
|
}
|
|
|
|
|
2018-08-14 15:41:19 +08:00
|
|
|
static int __dwc3_gadget_start_isoc(struct dwc3_ep *dep)
|
2012-05-25 21:24:56 +08:00
|
|
|
{
|
usb: dwc3: Add workaround for isoc start transfer failure
In DWC_usb31 version 1.70a-ea06 and prior, for highspeed and fullspeed
isochronous IN, BIT[15:14] of the 16-bit microframe number reported by
the XferNotReady event are invalid. The driver uses this number to
schedule the isochronous transfer and passes it to the START TRANSFER
command. Because this number is invalid, the command may fail. If
BIT[15:14] matches the internal 16-bit microframe, the START TRANSFER
command will pass and the transfer will start at the scheduled time, if
it is off by 1, the command will still pass, but the transfer will start
2 seconds in the future. For all other conditions, the START TRANSFER
command will fail with bus-expiry.
In order to workaround this issue, we can test for the correct
combination of BIT[15:14] by sending START TRANSFER commands with
different values of BIT[15:14]: 'b00, 'b01, 'b10, and 'b11. Each
combination is 2^14 uframe apart (or 2 seconds). 4 seconds into the
future will result in a bus-expiry status. As the result, within the 4
possible combinations for BIT[15:14], there will be 2 successful and 2
failure START COMMAND status. One of the 2 successful command status
will result in a 2-second delay start. The smaller BIT[15:14] value is
the correct combination.
Since there are only 4 outcomes and the results are ordered, we can
simply test 2 START TRANSFER commands with BIT[15:14] combinations 'b00
and 'b01 to deduce the smaller successful combination.
Let test0 = test status for combination 'b00 and test1 = test status for
'b01 of BIT[15:14]. The correct combination is as follow:
if test0 fails and test1 passes, BIT[15:14] is 'b01
if test0 fails and test1 fails, BIT[15:14] is 'b10
if test0 passes and test1 fails, BIT[15:14] is 'b11
if test0 passes and test1 passes, BIT[15:14] is 'b00
Synopsys STAR 9001202023: Wrong microframe number for isochronous IN
endpoints.
Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-11-15 14:56:54 +08:00
|
|
|
struct dwc3 *dwc = dep->dwc;
|
2018-08-14 15:42:43 +08:00
|
|
|
int ret;
|
|
|
|
int i;
|
usb: dwc3: Add workaround for isoc start transfer failure
In DWC_usb31 version 1.70a-ea06 and prior, for highspeed and fullspeed
isochronous IN, BIT[15:14] of the 16-bit microframe number reported by
the XferNotReady event are invalid. The driver uses this number to
schedule the isochronous transfer and passes it to the START TRANSFER
command. Because this number is invalid, the command may fail. If
BIT[15:14] matches the internal 16-bit microframe, the START TRANSFER
command will pass and the transfer will start at the scheduled time, if
it is off by 1, the command will still pass, but the transfer will start
2 seconds in the future. For all other conditions, the START TRANSFER
command will fail with bus-expiry.
In order to workaround this issue, we can test for the correct
combination of BIT[15:14] by sending START TRANSFER commands with
different values of BIT[15:14]: 'b00, 'b01, 'b10, and 'b11. Each
combination is 2^14 uframe apart (or 2 seconds). 4 seconds into the
future will result in a bus-expiry status. As the result, within the 4
possible combinations for BIT[15:14], there will be 2 successful and 2
failure START COMMAND status. One of the 2 successful command status
will result in a 2-second delay start. The smaller BIT[15:14] value is
the correct combination.
Since there are only 4 outcomes and the results are ordered, we can
simply test 2 START TRANSFER commands with BIT[15:14] combinations 'b00
and 'b01 to deduce the smaller successful combination.
Let test0 = test status for combination 'b00 and test1 = test status for
'b01 of BIT[15:14]. The correct combination is as follow:
if test0 fails and test1 passes, BIT[15:14] is 'b01
if test0 fails and test1 fails, BIT[15:14] is 'b10
if test0 passes and test1 fails, BIT[15:14] is 'b11
if test0 passes and test1 passes, BIT[15:14] is 'b00
Synopsys STAR 9001202023: Wrong microframe number for isochronous IN
endpoints.
Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-11-15 14:56:54 +08:00
|
|
|
|
2016-03-14 17:01:31 +08:00
|
|
|
if (list_empty(&dep->pending_list)) {
|
2012-08-30 14:51:43 +08:00
|
|
|
dep->flags |= DWC3_EP_PENDING_REQUEST;
|
2018-08-14 15:41:19 +08:00
|
|
|
return -EAGAIN;
|
2012-05-25 21:24:56 +08:00
|
|
|
}
|
|
|
|
|
usb: dwc3: Add workaround for isoc start transfer failure
In DWC_usb31 version 1.70a-ea06 and prior, for highspeed and fullspeed
isochronous IN, BIT[15:14] of the 16-bit microframe number reported by
the XferNotReady event are invalid. The driver uses this number to
schedule the isochronous transfer and passes it to the START TRANSFER
command. Because this number is invalid, the command may fail. If
BIT[15:14] matches the internal 16-bit microframe, the START TRANSFER
command will pass and the transfer will start at the scheduled time, if
it is off by 1, the command will still pass, but the transfer will start
2 seconds in the future. For all other conditions, the START TRANSFER
command will fail with bus-expiry.
In order to workaround this issue, we can test for the correct
combination of BIT[15:14] by sending START TRANSFER commands with
different values of BIT[15:14]: 'b00, 'b01, 'b10, and 'b11. Each
combination is 2^14 uframe apart (or 2 seconds). 4 seconds into the
future will result in a bus-expiry status. As the result, within the 4
possible combinations for BIT[15:14], there will be 2 successful and 2
failure START COMMAND status. One of the 2 successful command status
will result in a 2-second delay start. The smaller BIT[15:14] value is
the correct combination.
Since there are only 4 outcomes and the results are ordered, we can
simply test 2 START TRANSFER commands with BIT[15:14] combinations 'b00
and 'b01 to deduce the smaller successful combination.
Let test0 = test status for combination 'b00 and test1 = test status for
'b01 of BIT[15:14]. The correct combination is as follow:
if test0 fails and test1 passes, BIT[15:14] is 'b01
if test0 fails and test1 fails, BIT[15:14] is 'b10
if test0 passes and test1 fails, BIT[15:14] is 'b11
if test0 passes and test1 passes, BIT[15:14] is 'b00
Synopsys STAR 9001202023: Wrong microframe number for isochronous IN
endpoints.
Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-11-15 14:56:54 +08:00
|
|
|
if (!dwc->dis_start_transfer_quirk && dwc3_is_usb31(dwc) &&
|
|
|
|
(dwc->revision <= DWC3_USB31_REVISION_160A ||
|
|
|
|
(dwc->revision == DWC3_USB31_REVISION_170A &&
|
|
|
|
dwc->version_type >= DWC31_VERSIONTYPE_EA01 &&
|
|
|
|
dwc->version_type <= DWC31_VERSIONTYPE_EA06))) {
|
|
|
|
|
2018-08-14 15:41:19 +08:00
|
|
|
if (dwc->gadget.speed <= USB_SPEED_HIGH && dep->direction)
|
|
|
|
return dwc3_gadget_start_isoc_quirk(dep);
|
2012-05-25 21:24:56 +08:00
|
|
|
}
|
|
|
|
|
2018-08-14 15:42:43 +08:00
|
|
|
for (i = 0; i < DWC3_ISOC_MAX_RETRIES; i++) {
|
|
|
|
dep->frame_number = DWC3_ALIGN_FRAME(dep, i + 1);
|
|
|
|
|
|
|
|
ret = __dwc3_gadget_kick_transfer(dep);
|
|
|
|
if (ret != -EAGAIN)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2012-05-25 21:24:56 +08:00
|
|
|
}
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req)
|
|
|
|
{
|
2011-12-19 17:32:34 +08:00
|
|
|
struct dwc3 *dwc = dep->dwc;
|
|
|
|
|
2015-11-17 05:31:21 +08:00
|
|
|
if (!dep->endpoint.desc) {
|
2016-11-03 20:07:51 +08:00
|
|
|
dev_err(dwc->dev, "%s: can't queue to disabled endpoint\n",
|
|
|
|
dep->name);
|
2015-11-17 05:31:21 +08:00
|
|
|
return -ESHUTDOWN;
|
|
|
|
}
|
|
|
|
|
2017-05-17 20:57:45 +08:00
|
|
|
if (WARN(req->dep != dep, "request %pK belongs to '%s'\n",
|
|
|
|
&req->request, req->dep->name))
|
2015-11-17 05:31:21 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
2019-01-11 18:58:52 +08:00
|
|
|
if (WARN(req->status < DWC3_REQUEST_STATUS_COMPLETED,
|
|
|
|
"%s: request %pK already in flight\n",
|
|
|
|
dep->name, &req->request))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2016-05-16 18:14:48 +08:00
|
|
|
pm_runtime_get(dwc->dev);
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
req->request.actual = 0;
|
|
|
|
req->request.status = -EINPROGRESS;
|
|
|
|
|
2015-09-01 22:01:38 +08:00
|
|
|
trace_dwc3_ep_queue(req);
|
|
|
|
|
2016-03-14 17:01:31 +08:00
|
|
|
list_add_tail(&req->list, &dep->pending_list);
|
2019-01-11 18:57:09 +08:00
|
|
|
req->status = DWC3_REQUEST_STATUS_QUEUED;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2016-09-29 20:44:29 +08:00
|
|
|
/*
|
|
|
|
* NOTICE: Isochronous endpoints should NEVER be prestarted. We must
|
|
|
|
* wait for a XferNotReady event so we will know what's the current
|
|
|
|
* (micro-)frame number.
|
|
|
|
*
|
|
|
|
* Without this trick, we are very, very likely gonna get Bus Expiry
|
|
|
|
* errors which will force us issue EndTransfer command.
|
|
|
|
*/
|
|
|
|
if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) {
|
2018-03-29 18:23:53 +08:00
|
|
|
if (!(dep->flags & DWC3_EP_PENDING_REQUEST) &&
|
|
|
|
!(dep->flags & DWC3_EP_TRANSFER_STARTED))
|
|
|
|
return 0;
|
|
|
|
|
2016-10-21 18:07:09 +08:00
|
|
|
if ((dep->flags & DWC3_EP_PENDING_REQUEST)) {
|
2018-03-29 18:23:53 +08:00
|
|
|
if (!(dep->flags & DWC3_EP_TRANSFER_STARTED)) {
|
2018-08-14 15:41:19 +08:00
|
|
|
return __dwc3_gadget_start_isoc(dep);
|
2016-10-21 18:07:09 +08:00
|
|
|
}
|
2016-08-11 19:27:52 +08:00
|
|
|
}
|
2017-09-05 19:32:55 +08:00
|
|
|
}
|
2012-07-26 18:26:50 +08:00
|
|
|
|
2017-09-05 19:41:34 +08:00
|
|
|
return __dwc3_gadget_kick_transfer(dep);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int dwc3_gadget_ep_queue(struct usb_ep *ep, struct usb_request *request,
|
|
|
|
gfp_t gfp_flags)
|
|
|
|
{
|
|
|
|
struct dwc3_request *req = to_dwc3_request(request);
|
|
|
|
struct dwc3_ep *dep = to_dwc3_ep(ep);
|
|
|
|
struct dwc3 *dwc = dep->dwc;
|
|
|
|
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
int ret;
|
|
|
|
|
2014-09-03 14:26:34 +08:00
|
|
|
spin_lock_irqsave(&dwc->lock, flags);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
ret = __dwc3_gadget_ep_queue(dep, req);
|
|
|
|
spin_unlock_irqrestore(&dwc->lock, flags);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-08-01 18:42:29 +08:00
|
|
|
static void dwc3_gadget_ep_skip_trbs(struct dwc3_ep *dep, struct dwc3_request *req)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If request was already started, this means we had to
|
|
|
|
* stop the transfer. With that we also need to ignore
|
|
|
|
* all TRBs used by the request, however TRBs can only
|
|
|
|
* be modified after completion of END_TRANSFER
|
|
|
|
* command. So what we do here is that we wait for
|
|
|
|
* END_TRANSFER completion and only after that, we jump
|
|
|
|
* over TRBs by clearing HWO and incrementing dequeue
|
|
|
|
* pointer.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < req->num_trbs; i++) {
|
|
|
|
struct dwc3_trb *trb;
|
|
|
|
|
|
|
|
trb = req->trb + i;
|
|
|
|
trb->ctrl &= ~DWC3_TRB_CTRL_HWO;
|
|
|
|
dwc3_ep_inc_deq(dep);
|
|
|
|
}
|
2019-02-13 11:39:27 +08:00
|
|
|
|
|
|
|
req->num_trbs = 0;
|
2018-08-01 18:42:29 +08:00
|
|
|
}
|
|
|
|
|
2018-08-01 18:54:25 +08:00
|
|
|
static void dwc3_gadget_ep_cleanup_cancelled_requests(struct dwc3_ep *dep)
|
|
|
|
{
|
|
|
|
struct dwc3_request *req;
|
|
|
|
struct dwc3_request *tmp;
|
|
|
|
|
|
|
|
list_for_each_entry_safe(req, tmp, &dep->cancelled_list, list) {
|
|
|
|
dwc3_gadget_ep_skip_trbs(dep, req);
|
|
|
|
dwc3_gadget_giveback(dep, req, -ECONNRESET);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
|
|
|
|
struct usb_request *request)
|
|
|
|
{
|
|
|
|
struct dwc3_request *req = to_dwc3_request(request);
|
|
|
|
struct dwc3_request *r = NULL;
|
|
|
|
|
|
|
|
struct dwc3_ep *dep = to_dwc3_ep(ep);
|
|
|
|
struct dwc3 *dwc = dep->dwc;
|
|
|
|
|
|
|
|
unsigned long flags;
|
|
|
|
int ret = 0;
|
|
|
|
|
2014-05-01 06:45:10 +08:00
|
|
|
trace_dwc3_ep_dequeue(req);
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
spin_lock_irqsave(&dwc->lock, flags);
|
|
|
|
|
2016-03-14 17:01:31 +08:00
|
|
|
list_for_each_entry(r, &dep->pending_list, list) {
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
if (r == req)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (r != req) {
|
2016-03-14 17:01:31 +08:00
|
|
|
list_for_each_entry(r, &dep->started_list, list) {
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
if (r == req)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (r == req) {
|
|
|
|
/* wait until it is processed */
|
2019-02-13 19:00:54 +08:00
|
|
|
dwc3_stop_active_transfer(dep, true, true);
|
2017-02-17 17:12:44 +08:00
|
|
|
|
|
|
|
if (!r->trb)
|
2018-03-24 01:05:33 +08:00
|
|
|
goto out0;
|
2017-02-17 17:12:44 +08:00
|
|
|
|
2018-08-01 18:54:25 +08:00
|
|
|
dwc3_gadget_move_cancelled_request(req);
|
2019-01-21 19:01:16 +08:00
|
|
|
if (dep->flags & DWC3_EP_TRANSFER_STARTED)
|
|
|
|
goto out0;
|
|
|
|
else
|
|
|
|
goto out1;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
2017-05-17 20:57:45 +08:00
|
|
|
dev_err(dwc->dev, "request %pK was not queued to %s\n",
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
request, ep->name);
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto out0;
|
|
|
|
}
|
|
|
|
|
2019-01-21 19:01:16 +08:00
|
|
|
out1:
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
dwc3_gadget_giveback(dep, req, -ECONNRESET);
|
|
|
|
|
|
|
|
out0:
|
|
|
|
spin_unlock_irqrestore(&dwc->lock, flags);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-09-25 03:19:52 +08:00
|
|
|
int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol)
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
{
|
|
|
|
struct dwc3_gadget_ep_cmd_params params;
|
|
|
|
struct dwc3 *dwc = dep->dwc;
|
|
|
|
int ret;
|
|
|
|
|
2014-09-24 23:48:26 +08:00
|
|
|
if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) {
|
|
|
|
dev_err(dwc->dev, "%s is of Isochronous type\n", dep->name);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
memset(¶ms, 0x00, sizeof(params));
|
|
|
|
|
|
|
|
if (value) {
|
2016-05-30 18:37:02 +08:00
|
|
|
struct dwc3_trb *trb;
|
|
|
|
|
|
|
|
unsigned transfer_in_flight;
|
|
|
|
unsigned started;
|
|
|
|
|
|
|
|
if (dep->number > 1)
|
|
|
|
trb = dwc3_ep_prev_trb(dep, dep->trb_enqueue);
|
|
|
|
else
|
|
|
|
trb = &dwc->ep0_trb[dep->trb_enqueue];
|
|
|
|
|
|
|
|
transfer_in_flight = trb->ctrl & DWC3_TRB_CTRL_HWO;
|
|
|
|
started = !list_empty(&dep->started_list);
|
|
|
|
|
|
|
|
if (!protocol && ((dep->direction && transfer_in_flight) ||
|
|
|
|
(!dep->direction && started))) {
|
2014-09-25 03:19:52 +08:00
|
|
|
return -EAGAIN;
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:42:43 +08:00
|
|
|
ret = dwc3_send_gadget_ep_cmd(dep, DWC3_DEPCMD_SETSTALL,
|
|
|
|
¶ms);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
if (ret)
|
2014-03-07 19:20:22 +08:00
|
|
|
dev_err(dwc->dev, "failed to set STALL on %s\n",
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
dep->name);
|
|
|
|
else
|
|
|
|
dep->flags |= DWC3_EP_STALL;
|
|
|
|
} else {
|
2016-04-12 21:42:43 +08:00
|
|
|
|
2016-06-01 08:49:56 +08:00
|
|
|
ret = dwc3_send_clear_stall_ep_cmd(dep);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
if (ret)
|
2014-03-07 19:20:22 +08:00
|
|
|
dev_err(dwc->dev, "failed to clear STALL on %s\n",
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
dep->name);
|
|
|
|
else
|
2013-11-02 00:05:12 +08:00
|
|
|
dep->flags &= ~(DWC3_EP_STALL | DWC3_EP_WEDGE);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
2011-09-30 15:58:44 +08:00
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dwc3_gadget_ep_set_halt(struct usb_ep *ep, int value)
|
|
|
|
{
|
|
|
|
struct dwc3_ep *dep = to_dwc3_ep(ep);
|
|
|
|
struct dwc3 *dwc = dep->dwc;
|
|
|
|
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&dwc->lock, flags);
|
2014-09-25 03:19:52 +08:00
|
|
|
ret = __dwc3_gadget_ep_set_halt(dep, value, false);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
spin_unlock_irqrestore(&dwc->lock, flags);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dwc3_gadget_ep_set_wedge(struct usb_ep *ep)
|
|
|
|
{
|
|
|
|
struct dwc3_ep *dep = to_dwc3_ep(ep);
|
2012-02-25 09:32:16 +08:00
|
|
|
struct dwc3 *dwc = dep->dwc;
|
|
|
|
unsigned long flags;
|
2014-09-24 23:50:14 +08:00
|
|
|
int ret;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2012-02-25 09:32:16 +08:00
|
|
|
spin_lock_irqsave(&dwc->lock, flags);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
dep->flags |= DWC3_EP_WEDGE;
|
|
|
|
|
2012-06-26 01:10:43 +08:00
|
|
|
if (dep->number == 0 || dep->number == 1)
|
2014-09-24 23:50:14 +08:00
|
|
|
ret = __dwc3_gadget_ep0_set_halt(ep, 1);
|
2012-06-26 01:10:43 +08:00
|
|
|
else
|
2014-09-25 03:19:52 +08:00
|
|
|
ret = __dwc3_gadget_ep_set_halt(dep, 1, false);
|
2014-09-24 23:50:14 +08:00
|
|
|
spin_unlock_irqrestore(&dwc->lock, flags);
|
|
|
|
|
|
|
|
return ret;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static struct usb_endpoint_descriptor dwc3_gadget_ep0_desc = {
|
|
|
|
.bLength = USB_DT_ENDPOINT_SIZE,
|
|
|
|
.bDescriptorType = USB_DT_ENDPOINT,
|
|
|
|
.bmAttributes = USB_ENDPOINT_XFER_CONTROL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct usb_ep_ops dwc3_gadget_ep0_ops = {
|
|
|
|
.enable = dwc3_gadget_ep0_enable,
|
|
|
|
.disable = dwc3_gadget_ep0_disable,
|
|
|
|
.alloc_request = dwc3_gadget_ep_alloc_request,
|
|
|
|
.free_request = dwc3_gadget_ep_free_request,
|
|
|
|
.queue = dwc3_gadget_ep0_queue,
|
|
|
|
.dequeue = dwc3_gadget_ep_dequeue,
|
2012-06-26 01:10:43 +08:00
|
|
|
.set_halt = dwc3_gadget_ep0_set_halt,
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
.set_wedge = dwc3_gadget_ep_set_wedge,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct usb_ep_ops dwc3_gadget_ep_ops = {
|
|
|
|
.enable = dwc3_gadget_ep_enable,
|
|
|
|
.disable = dwc3_gadget_ep_disable,
|
|
|
|
.alloc_request = dwc3_gadget_ep_alloc_request,
|
|
|
|
.free_request = dwc3_gadget_ep_free_request,
|
|
|
|
.queue = dwc3_gadget_ep_queue,
|
|
|
|
.dequeue = dwc3_gadget_ep_dequeue,
|
|
|
|
.set_halt = dwc3_gadget_ep_set_halt,
|
|
|
|
.set_wedge = dwc3_gadget_ep_set_wedge,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static int dwc3_gadget_get_frame(struct usb_gadget *g)
|
|
|
|
{
|
|
|
|
struct dwc3 *dwc = gadget_to_dwc(g);
|
|
|
|
|
2016-10-21 18:07:09 +08:00
|
|
|
return __dwc3_gadget_get_frame(dwc);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
|
2016-04-04 16:24:04 +08:00
|
|
|
static int __dwc3_gadget_wakeup(struct dwc3 *dwc)
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
{
|
2016-08-16 17:22:38 +08:00
|
|
|
int retries;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2016-04-04 16:24:04 +08:00
|
|
|
int ret;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
u32 reg;
|
|
|
|
|
|
|
|
u8 link_state;
|
|
|
|
u8 speed;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* According to the Databook Remote wakeup request should
|
|
|
|
* be issued only when the device is in early suspend state.
|
|
|
|
*
|
|
|
|
* We can check that via USB Link State bits in DSTS register.
|
|
|
|
*/
|
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_DSTS);
|
|
|
|
|
|
|
|
speed = reg & DWC3_DSTS_CONNECTSPD;
|
2016-02-06 09:08:45 +08:00
|
|
|
if ((speed == DWC3_DSTS_SUPERSPEED) ||
|
2016-11-03 20:07:51 +08:00
|
|
|
(speed == DWC3_DSTS_SUPERSPEED_PLUS))
|
2016-05-13 15:19:42 +08:00
|
|
|
return 0;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
|
|
|
link_state = DWC3_DSTS_USBLNKST(reg);
|
|
|
|
|
|
|
|
switch (link_state) {
|
|
|
|
case DWC3_LINK_STATE_RX_DET: /* in HS, means Early Suspend */
|
|
|
|
case DWC3_LINK_STATE_U3: /* in HS, means SUSPEND */
|
|
|
|
break;
|
|
|
|
default:
|
2016-04-04 16:24:04 +08:00
|
|
|
return -EINVAL;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
|
2012-01-03 00:55:57 +08:00
|
|
|
ret = dwc3_gadget_set_link_state(dwc, DWC3_LINK_STATE_RECOV);
|
|
|
|
if (ret < 0) {
|
|
|
|
dev_err(dwc->dev, "failed to put link in Recovery\n");
|
2016-04-04 16:24:04 +08:00
|
|
|
return ret;
|
2012-01-03 00:55:57 +08:00
|
|
|
}
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2012-04-27 18:10:52 +08:00
|
|
|
/* Recent versions do this automatically */
|
|
|
|
if (dwc->revision < DWC3_REVISION_194A) {
|
|
|
|
/* write zeroes to Link Change Request */
|
2012-05-24 15:27:56 +08:00
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
|
2012-04-27 18:10:52 +08:00
|
|
|
reg &= ~DWC3_DCTL_ULSTCHNGREQ_MASK;
|
|
|
|
dwc3_writel(dwc->regs, DWC3_DCTL, reg);
|
|
|
|
}
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2012-02-16 10:56:56 +08:00
|
|
|
/* poll until Link State changes to ON */
|
2016-08-16 17:22:38 +08:00
|
|
|
retries = 20000;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2016-08-16 17:22:38 +08:00
|
|
|
while (retries--) {
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_DSTS);
|
|
|
|
|
|
|
|
/* in HS, means ON */
|
|
|
|
if (DWC3_DSTS_USBLNKST(reg) == DWC3_LINK_STATE_U0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DWC3_DSTS_USBLNKST(reg) != DWC3_LINK_STATE_U0) {
|
|
|
|
dev_err(dwc->dev, "failed to send remote wakeup\n");
|
2016-04-04 16:24:04 +08:00
|
|
|
return -EINVAL;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
|
2016-04-04 16:24:04 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dwc3_gadget_wakeup(struct usb_gadget *g)
|
|
|
|
{
|
|
|
|
struct dwc3 *dwc = gadget_to_dwc(g);
|
|
|
|
unsigned long flags;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&dwc->lock, flags);
|
|
|
|
ret = __dwc3_gadget_wakeup(dwc);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
spin_unlock_irqrestore(&dwc->lock, flags);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dwc3_gadget_set_selfpowered(struct usb_gadget *g,
|
|
|
|
int is_selfpowered)
|
|
|
|
{
|
|
|
|
struct dwc3 *dwc = gadget_to_dwc(g);
|
2012-02-25 09:32:16 +08:00
|
|
|
unsigned long flags;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2012-02-25 09:32:16 +08:00
|
|
|
spin_lock_irqsave(&dwc->lock, flags);
|
2015-01-28 16:32:40 +08:00
|
|
|
g->is_selfpowered = !!is_selfpowered;
|
2012-02-25 09:32:16 +08:00
|
|
|
spin_unlock_irqrestore(&dwc->lock, flags);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-12-20 03:43:19 +08:00
|
|
|
static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend)
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
{
|
|
|
|
u32 reg;
|
2011-08-29 22:46:38 +08:00
|
|
|
u32 timeout = 500;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2016-05-16 18:14:48 +08:00
|
|
|
if (pm_runtime_suspended(dwc->dev))
|
|
|
|
return 0;
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
|
2012-01-19 00:32:29 +08:00
|
|
|
if (is_on) {
|
2012-04-27 18:10:52 +08:00
|
|
|
if (dwc->revision <= DWC3_REVISION_187A) {
|
|
|
|
reg &= ~DWC3_DCTL_TRGTULST_MASK;
|
|
|
|
reg |= DWC3_DCTL_TRGTULST_RX_DET;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dwc->revision >= DWC3_REVISION_194A)
|
|
|
|
reg &= ~DWC3_DCTL_KEEP_CONNECT;
|
|
|
|
reg |= DWC3_DCTL_RUN_STOP;
|
2013-12-20 03:43:19 +08:00
|
|
|
|
|
|
|
if (dwc->has_hibernation)
|
|
|
|
reg |= DWC3_DCTL_KEEP_CONNECT;
|
|
|
|
|
2013-02-08 23:55:58 +08:00
|
|
|
dwc->pullups_connected = true;
|
2012-01-19 00:32:29 +08:00
|
|
|
} else {
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
reg &= ~DWC3_DCTL_RUN_STOP;
|
2013-12-20 03:43:19 +08:00
|
|
|
|
|
|
|
if (dwc->has_hibernation && !suspend)
|
|
|
|
reg &= ~DWC3_DCTL_KEEP_CONNECT;
|
|
|
|
|
2013-02-08 23:55:58 +08:00
|
|
|
dwc->pullups_connected = false;
|
2012-01-19 00:32:29 +08:00
|
|
|
}
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
|
|
|
dwc3_writel(dwc->regs, DWC3_DCTL, reg);
|
|
|
|
|
|
|
|
do {
|
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_DSTS);
|
2016-06-09 21:47:05 +08:00
|
|
|
reg &= DWC3_DSTS_DEVCTRLHLT;
|
|
|
|
} while (--timeout && !(!is_on ^ !reg));
|
2016-06-09 21:31:34 +08:00
|
|
|
|
|
|
|
if (!timeout)
|
|
|
|
return -ETIMEDOUT;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2012-07-02 12:51:55 +08:00
|
|
|
return 0;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
|
|
|
|
{
|
|
|
|
struct dwc3 *dwc = gadget_to_dwc(g);
|
|
|
|
unsigned long flags;
|
2012-07-02 12:51:55 +08:00
|
|
|
int ret;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
|
|
|
is_on = !!is_on;
|
|
|
|
|
2016-10-14 17:11:33 +08:00
|
|
|
/*
|
|
|
|
* Per databook, when we want to stop the gadget, if a control transfer
|
|
|
|
* is still in process, complete it and get the core into setup phase.
|
|
|
|
*/
|
|
|
|
if (!is_on && dwc->ep0state != EP0_SETUP_PHASE) {
|
|
|
|
reinit_completion(&dwc->ep0_in_setup);
|
|
|
|
|
|
|
|
ret = wait_for_completion_timeout(&dwc->ep0_in_setup,
|
|
|
|
msecs_to_jiffies(DWC3_PULL_UP_TIMEOUT));
|
|
|
|
if (ret == 0) {
|
|
|
|
dev_err(dwc->dev, "timed out waiting for SETUP phase\n");
|
|
|
|
return -ETIMEDOUT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
spin_lock_irqsave(&dwc->lock, flags);
|
2013-12-20 03:43:19 +08:00
|
|
|
ret = dwc3_gadget_run_stop(dwc, is_on, false);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
spin_unlock_irqrestore(&dwc->lock, flags);
|
|
|
|
|
2012-07-02 12:51:55 +08:00
|
|
|
return ret;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
|
2013-02-08 21:24:04 +08:00
|
|
|
static void dwc3_gadget_enable_irq(struct dwc3 *dwc)
|
|
|
|
{
|
|
|
|
u32 reg;
|
|
|
|
|
|
|
|
/* Enable all but Start and End of Frame IRQs */
|
|
|
|
reg = (DWC3_DEVTEN_VNDRDEVTSTRCVEDEN |
|
|
|
|
DWC3_DEVTEN_EVNTOVERFLOWEN |
|
|
|
|
DWC3_DEVTEN_CMDCMPLTEN |
|
|
|
|
DWC3_DEVTEN_ERRTICERREN |
|
|
|
|
DWC3_DEVTEN_WKUPEVTEN |
|
|
|
|
DWC3_DEVTEN_CONNECTDONEEN |
|
|
|
|
DWC3_DEVTEN_USBRSTEN |
|
|
|
|
DWC3_DEVTEN_DISCONNEVTEN);
|
|
|
|
|
2016-09-23 16:20:40 +08:00
|
|
|
if (dwc->revision < DWC3_REVISION_250A)
|
|
|
|
reg |= DWC3_DEVTEN_ULSTCNGEN;
|
|
|
|
|
2013-02-08 21:24:04 +08:00
|
|
|
dwc3_writel(dwc->regs, DWC3_DEVTEN, reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dwc3_gadget_disable_irq(struct dwc3 *dwc)
|
|
|
|
{
|
|
|
|
/* mask all interrupts */
|
|
|
|
dwc3_writel(dwc->regs, DWC3_DEVTEN, 0x00);
|
|
|
|
}
|
|
|
|
|
|
|
|
static irqreturn_t dwc3_interrupt(int irq, void *_dwc);
|
2011-06-30 21:57:15 +08:00
|
|
|
static irqreturn_t dwc3_thread_interrupt(int irq, void *_dwc);
|
2013-02-08 21:24:04 +08:00
|
|
|
|
2016-05-13 19:09:59 +08:00
|
|
|
/**
|
2017-04-19 19:59:27 +08:00
|
|
|
* dwc3_gadget_setup_nump - calculate and initialize NUMP field of %DWC3_DCFG
|
|
|
|
* @dwc: pointer to our context structure
|
2016-05-13 19:09:59 +08:00
|
|
|
*
|
|
|
|
* The following looks like complex but it's actually very simple. In order to
|
|
|
|
* calculate the number of packets we can burst at once on OUT transfers, we're
|
|
|
|
* gonna use RxFIFO size.
|
|
|
|
*
|
|
|
|
* To calculate RxFIFO size we need two numbers:
|
|
|
|
* MDWIDTH = size, in bits, of the internal memory bus
|
|
|
|
* RAM2_DEPTH = depth, in MDWIDTH, of internal RAM2 (where RxFIFO sits)
|
|
|
|
*
|
|
|
|
* Given these two numbers, the formula is simple:
|
|
|
|
*
|
|
|
|
* RxFIFO Size = (RAM2_DEPTH * MDWIDTH / 8) - 24 - 16;
|
|
|
|
*
|
|
|
|
* 24 bytes is for 3x SETUP packets
|
|
|
|
* 16 bytes is a clock domain crossing tolerance
|
|
|
|
*
|
|
|
|
* Given RxFIFO Size, NUMP = RxFIFOSize / 1024;
|
|
|
|
*/
|
|
|
|
static void dwc3_gadget_setup_nump(struct dwc3 *dwc)
|
|
|
|
{
|
|
|
|
u32 ram2_depth;
|
|
|
|
u32 mdwidth;
|
|
|
|
u32 nump;
|
|
|
|
u32 reg;
|
|
|
|
|
|
|
|
ram2_depth = DWC3_GHWPARAMS7_RAM2_DEPTH(dwc->hwparams.hwparams7);
|
|
|
|
mdwidth = DWC3_GHWPARAMS0_MDWIDTH(dwc->hwparams.hwparams0);
|
|
|
|
|
|
|
|
nump = ((ram2_depth * mdwidth / 8) - 24 - 16) / 1024;
|
|
|
|
nump = min_t(u32, nump, 16);
|
|
|
|
|
|
|
|
/* update NumP */
|
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_DCFG);
|
|
|
|
reg &= ~DWC3_DCFG_NUMP_MASK;
|
|
|
|
reg |= nump << DWC3_DCFG_NUMP_SHIFT;
|
|
|
|
dwc3_writel(dwc->regs, DWC3_DCFG, reg);
|
|
|
|
}
|
|
|
|
|
2016-05-04 20:49:37 +08:00
|
|
|
static int __dwc3_gadget_start(struct dwc3 *dwc)
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
{
|
|
|
|
struct dwc3_ep *dep;
|
|
|
|
int ret = 0;
|
|
|
|
u32 reg;
|
|
|
|
|
2016-11-15 04:32:43 +08:00
|
|
|
/*
|
|
|
|
* Use IMOD if enabled via dwc->imod_interval. Otherwise, if
|
|
|
|
* the core supports IMOD, disable it.
|
|
|
|
*/
|
|
|
|
if (dwc->imod_interval) {
|
|
|
|
dwc3_writel(dwc->regs, DWC3_DEV_IMOD(0), dwc->imod_interval);
|
|
|
|
dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), DWC3_GEVNTCOUNT_EHB);
|
|
|
|
} else if (dwc3_has_imod(dwc)) {
|
|
|
|
dwc3_writel(dwc->regs, DWC3_DEV_IMOD(0), 0);
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:56:28 +08:00
|
|
|
/*
|
|
|
|
* We are telling dwc3 that we want to use DCFG.NUMP as ACK TP's NUMP
|
|
|
|
* field instead of letting dwc3 itself calculate that automatically.
|
|
|
|
*
|
|
|
|
* This way, we maximize the chances that we'll be able to get several
|
|
|
|
* bursts of data without going through any sort of endpoint throttling.
|
|
|
|
*/
|
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_GRXTHRCFG);
|
2018-03-17 06:34:13 +08:00
|
|
|
if (dwc3_is_usb31(dwc))
|
|
|
|
reg &= ~DWC31_GRXTHRCFG_PKTCNTSEL;
|
|
|
|
else
|
|
|
|
reg &= ~DWC3_GRXTHRCFG_PKTCNTSEL;
|
|
|
|
|
2016-04-28 15:56:28 +08:00
|
|
|
dwc3_writel(dwc->regs, DWC3_GRXTHRCFG, reg);
|
|
|
|
|
2016-05-13 19:09:59 +08:00
|
|
|
dwc3_gadget_setup_nump(dwc);
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
/* Start with SuperSpeed Default */
|
|
|
|
dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512);
|
|
|
|
|
|
|
|
dep = dwc->eps[0];
|
2018-04-09 17:40:48 +08:00
|
|
|
ret = __dwc3_gadget_ep_enable(dep, DWC3_DEPCFG_ACTION_INIT);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
if (ret) {
|
|
|
|
dev_err(dwc->dev, "failed to enable %s\n", dep->name);
|
2016-05-04 20:49:37 +08:00
|
|
|
goto err0;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
dep = dwc->eps[1];
|
2018-04-09 17:40:48 +08:00
|
|
|
ret = __dwc3_gadget_ep_enable(dep, DWC3_DEPCFG_ACTION_INIT);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
if (ret) {
|
|
|
|
dev_err(dwc->dev, "failed to enable %s\n", dep->name);
|
2016-05-04 20:49:37 +08:00
|
|
|
goto err1;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* begin to receive SETUP packets */
|
2011-08-28 03:28:36 +08:00
|
|
|
dwc->ep0state = EP0_SETUP_PHASE;
|
2018-12-26 19:22:00 +08:00
|
|
|
dwc->link_state = DWC3_LINK_STATE_SS_DIS;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
dwc3_ep0_out_start(dwc);
|
|
|
|
|
2013-02-08 21:24:04 +08:00
|
|
|
dwc3_gadget_enable_irq(dwc);
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
return 0;
|
|
|
|
|
2013-06-27 15:00:18 +08:00
|
|
|
err1:
|
2016-05-04 20:49:37 +08:00
|
|
|
__dwc3_gadget_ep_disable(dwc->eps[0]);
|
2013-06-27 15:00:18 +08:00
|
|
|
|
|
|
|
err0:
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-05-04 20:49:37 +08:00
|
|
|
static int dwc3_gadget_start(struct usb_gadget *g,
|
|
|
|
struct usb_gadget_driver *driver)
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
{
|
|
|
|
struct dwc3 *dwc = gadget_to_dwc(g);
|
|
|
|
unsigned long flags;
|
2016-05-04 20:49:37 +08:00
|
|
|
int ret = 0;
|
2013-02-08 21:24:04 +08:00
|
|
|
int irq;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2016-06-10 19:48:38 +08:00
|
|
|
irq = dwc->irq_gadget;
|
2016-05-04 20:49:37 +08:00
|
|
|
ret = request_threaded_irq(irq, dwc3_interrupt, dwc3_thread_interrupt,
|
|
|
|
IRQF_SHARED, "dwc3", dwc->ev_buf);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(dwc->dev, "failed to request irq #%d --> %d\n",
|
|
|
|
irq, ret);
|
|
|
|
goto err0;
|
|
|
|
}
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
spin_lock_irqsave(&dwc->lock, flags);
|
2016-05-04 20:49:37 +08:00
|
|
|
if (dwc->gadget_driver) {
|
|
|
|
dev_err(dwc->dev, "%s is already bound to %s\n",
|
|
|
|
dwc->gadget.name,
|
|
|
|
dwc->gadget_driver->driver.name);
|
|
|
|
ret = -EBUSY;
|
|
|
|
goto err1;
|
|
|
|
}
|
|
|
|
|
|
|
|
dwc->gadget_driver = driver;
|
|
|
|
|
2016-05-16 18:14:48 +08:00
|
|
|
if (pm_runtime_active(dwc->dev))
|
|
|
|
__dwc3_gadget_start(dwc);
|
|
|
|
|
2016-05-04 20:49:37 +08:00
|
|
|
spin_unlock_irqrestore(&dwc->lock, flags);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err1:
|
|
|
|
spin_unlock_irqrestore(&dwc->lock, flags);
|
|
|
|
free_irq(irq, dwc);
|
|
|
|
|
|
|
|
err0:
|
|
|
|
return ret;
|
|
|
|
}
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2016-05-04 20:49:37 +08:00
|
|
|
static void __dwc3_gadget_stop(struct dwc3 *dwc)
|
|
|
|
{
|
2013-02-08 21:24:04 +08:00
|
|
|
dwc3_gadget_disable_irq(dwc);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
__dwc3_gadget_ep_disable(dwc->eps[0]);
|
|
|
|
__dwc3_gadget_ep_disable(dwc->eps[1]);
|
2016-05-04 20:49:37 +08:00
|
|
|
}
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2016-05-04 20:49:37 +08:00
|
|
|
static int dwc3_gadget_stop(struct usb_gadget *g)
|
|
|
|
{
|
|
|
|
struct dwc3 *dwc = gadget_to_dwc(g);
|
|
|
|
unsigned long flags;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2016-05-04 20:49:37 +08:00
|
|
|
spin_lock_irqsave(&dwc->lock, flags);
|
2016-10-31 19:38:36 +08:00
|
|
|
|
|
|
|
if (pm_runtime_suspended(dwc->dev))
|
|
|
|
goto out;
|
|
|
|
|
2016-05-04 20:49:37 +08:00
|
|
|
__dwc3_gadget_stop(dwc);
|
2016-10-31 19:38:36 +08:00
|
|
|
|
|
|
|
out:
|
2016-05-04 20:49:37 +08:00
|
|
|
dwc->gadget_driver = NULL;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
spin_unlock_irqrestore(&dwc->lock, flags);
|
|
|
|
|
2016-05-16 19:17:06 +08:00
|
|
|
free_irq(dwc->irq_gadget, dwc->ev_buf);
|
2013-06-27 15:00:18 +08:00
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2012-04-27 18:10:52 +08:00
|
|
|
|
2019-05-10 15:07:28 +08:00
|
|
|
static void dwc3_gadget_config_params(struct usb_gadget *g,
|
|
|
|
struct usb_dcd_config_params *params)
|
|
|
|
{
|
|
|
|
struct dwc3 *dwc = gadget_to_dwc(g);
|
|
|
|
|
2019-08-20 09:36:06 +08:00
|
|
|
params->besl_baseline = USB_DEFAULT_BESL_UNSPECIFIED;
|
|
|
|
params->besl_deep = USB_DEFAULT_BESL_UNSPECIFIED;
|
|
|
|
|
|
|
|
/* Recommended BESL */
|
|
|
|
if (!dwc->dis_enblslpm_quirk) {
|
2019-08-30 09:00:16 +08:00
|
|
|
/*
|
|
|
|
* If the recommended BESL baseline is 0 or if the BESL deep is
|
|
|
|
* less than 2, Microsoft's Windows 10 host usb stack will issue
|
|
|
|
* a usb reset immediately after it receives the extended BOS
|
|
|
|
* descriptor and the enumeration will fail. To maintain
|
|
|
|
* compatibility with the Windows' usb stack, let's set the
|
|
|
|
* recommended BESL baseline to 1 and clamp the BESL deep to be
|
|
|
|
* within 2 to 15.
|
|
|
|
*/
|
|
|
|
params->besl_baseline = 1;
|
2019-08-20 09:36:06 +08:00
|
|
|
if (dwc->is_utmi_l1_suspend)
|
2019-08-30 09:00:16 +08:00
|
|
|
params->besl_deep =
|
|
|
|
clamp_t(u8, dwc->hird_threshold, 2, 15);
|
2019-08-20 09:36:06 +08:00
|
|
|
}
|
|
|
|
|
2019-05-10 15:07:28 +08:00
|
|
|
/* U1 Device exit Latency */
|
|
|
|
if (dwc->dis_u1_entry_quirk)
|
|
|
|
params->bU1devExitLat = 0;
|
|
|
|
else
|
|
|
|
params->bU1devExitLat = DWC3_DEFAULT_U1_DEV_EXIT_LAT;
|
|
|
|
|
|
|
|
/* U2 Device exit Latency */
|
|
|
|
if (dwc->dis_u2_entry_quirk)
|
|
|
|
params->bU2DevExitLat = 0;
|
|
|
|
else
|
|
|
|
params->bU2DevExitLat =
|
|
|
|
cpu_to_le16(DWC3_DEFAULT_U2_DEV_EXIT_LAT);
|
|
|
|
}
|
|
|
|
|
2017-06-06 21:05:23 +08:00
|
|
|
static void dwc3_gadget_set_speed(struct usb_gadget *g,
|
|
|
|
enum usb_device_speed speed)
|
|
|
|
{
|
|
|
|
struct dwc3 *dwc = gadget_to_dwc(g);
|
|
|
|
unsigned long flags;
|
|
|
|
u32 reg;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&dwc->lock, flags);
|
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_DCFG);
|
|
|
|
reg &= ~(DWC3_DCFG_SPEED_MASK);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* WORKAROUND: DWC3 revision < 2.20a have an issue
|
|
|
|
* which would cause metastability state on Run/Stop
|
|
|
|
* bit if we try to force the IP to USB2-only mode.
|
|
|
|
*
|
|
|
|
* Because of that, we cannot configure the IP to any
|
|
|
|
* speed other than the SuperSpeed
|
|
|
|
*
|
|
|
|
* Refers to:
|
|
|
|
*
|
|
|
|
* STAR#9000525659: Clock Domain Crossing on DCTL in
|
|
|
|
* USB 2.0 Mode
|
|
|
|
*/
|
2017-10-31 21:11:55 +08:00
|
|
|
if (dwc->revision < DWC3_REVISION_220A &&
|
|
|
|
!dwc->dis_metastability_quirk) {
|
2017-06-06 21:05:23 +08:00
|
|
|
reg |= DWC3_DCFG_SUPERSPEED;
|
|
|
|
} else {
|
|
|
|
switch (speed) {
|
|
|
|
case USB_SPEED_LOW:
|
|
|
|
reg |= DWC3_DCFG_LOWSPEED;
|
|
|
|
break;
|
|
|
|
case USB_SPEED_FULL:
|
|
|
|
reg |= DWC3_DCFG_FULLSPEED;
|
|
|
|
break;
|
|
|
|
case USB_SPEED_HIGH:
|
|
|
|
reg |= DWC3_DCFG_HIGHSPEED;
|
|
|
|
break;
|
|
|
|
case USB_SPEED_SUPER:
|
|
|
|
reg |= DWC3_DCFG_SUPERSPEED;
|
|
|
|
break;
|
|
|
|
case USB_SPEED_SUPER_PLUS:
|
2018-03-17 06:35:57 +08:00
|
|
|
if (dwc3_is_usb31(dwc))
|
|
|
|
reg |= DWC3_DCFG_SUPERSPEED_PLUS;
|
|
|
|
else
|
|
|
|
reg |= DWC3_DCFG_SUPERSPEED;
|
2017-06-06 21:05:23 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
dev_err(dwc->dev, "invalid speed (%d)\n", speed);
|
|
|
|
|
|
|
|
if (dwc->revision & DWC3_REVISION_IS_DWC31)
|
|
|
|
reg |= DWC3_DCFG_SUPERSPEED_PLUS;
|
|
|
|
else
|
|
|
|
reg |= DWC3_DCFG_SUPERSPEED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dwc3_writel(dwc->regs, DWC3_DCFG, reg);
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&dwc->lock, flags);
|
|
|
|
}
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
static const struct usb_gadget_ops dwc3_gadget_ops = {
|
|
|
|
.get_frame = dwc3_gadget_get_frame,
|
|
|
|
.wakeup = dwc3_gadget_wakeup,
|
|
|
|
.set_selfpowered = dwc3_gadget_set_selfpowered,
|
|
|
|
.pullup = dwc3_gadget_pullup,
|
|
|
|
.udc_start = dwc3_gadget_start,
|
|
|
|
.udc_stop = dwc3_gadget_stop,
|
2017-06-06 21:05:23 +08:00
|
|
|
.udc_set_speed = dwc3_gadget_set_speed,
|
2019-05-10 15:07:28 +08:00
|
|
|
.get_config_params = dwc3_gadget_config_params,
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
|
2018-04-09 16:06:09 +08:00
|
|
|
static int dwc3_gadget_init_control_endpoint(struct dwc3_ep *dep)
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
{
|
2018-04-09 16:06:09 +08:00
|
|
|
struct dwc3 *dwc = dep->dwc;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2018-04-09 16:06:09 +08:00
|
|
|
usb_ep_set_maxpacket_limit(&dep->endpoint, 512);
|
|
|
|
dep->endpoint.maxburst = 1;
|
|
|
|
dep->endpoint.ops = &dwc3_gadget_ep0_ops;
|
|
|
|
if (!dep->direction)
|
|
|
|
dwc->gadget.ep0 = &dep->endpoint;
|
2017-02-01 04:58:11 +08:00
|
|
|
|
2018-04-09 16:06:09 +08:00
|
|
|
dep->endpoint.caps.type_control = true;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2018-04-09 16:06:09 +08:00
|
|
|
return 0;
|
|
|
|
}
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2018-04-09 16:06:09 +08:00
|
|
|
static int dwc3_gadget_init_in_endpoint(struct dwc3_ep *dep)
|
|
|
|
{
|
|
|
|
struct dwc3 *dwc = dep->dwc;
|
|
|
|
int mdwidth;
|
|
|
|
int kbytes;
|
|
|
|
int size;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2018-04-09 16:06:09 +08:00
|
|
|
mdwidth = DWC3_MDWIDTH(dwc->hwparams.hwparams0);
|
|
|
|
/* MDWIDTH is represented in bits, we need it in bytes */
|
|
|
|
mdwidth /= 8;
|
2011-05-05 21:21:59 +08:00
|
|
|
|
2018-04-09 16:06:09 +08:00
|
|
|
size = dwc3_readl(dwc->regs, DWC3_GTXFIFOSIZ(dep->number >> 1));
|
|
|
|
if (dwc3_is_usb31(dwc))
|
|
|
|
size = DWC31_GTXFIFOSIZ_TXFDEF(size);
|
|
|
|
else
|
|
|
|
size = DWC3_GTXFIFOSIZ_TXFDEF(size);
|
2016-11-10 08:36:28 +08:00
|
|
|
|
2018-04-09 16:06:09 +08:00
|
|
|
/* FIFO Depth is in MDWDITH bytes. Multiply */
|
|
|
|
size *= mdwidth;
|
2016-11-10 08:36:28 +08:00
|
|
|
|
2018-04-09 16:06:09 +08:00
|
|
|
kbytes = size / 1024;
|
|
|
|
if (kbytes == 0)
|
|
|
|
kbytes = 1;
|
2017-01-24 00:01:59 +08:00
|
|
|
|
2018-04-09 16:06:09 +08:00
|
|
|
/*
|
|
|
|
* FIFO sizes account an extra MDWIDTH * (kbytes + 1) bytes for
|
|
|
|
* internal overhead. We don't really know how these are used,
|
|
|
|
* but documentation say it exists.
|
|
|
|
*/
|
|
|
|
size -= mdwidth * (kbytes + 1);
|
|
|
|
size /= kbytes;
|
2017-01-24 00:01:59 +08:00
|
|
|
|
2018-04-09 16:06:09 +08:00
|
|
|
usb_ep_set_maxpacket_limit(&dep->endpoint, size);
|
2017-01-24 00:01:59 +08:00
|
|
|
|
2018-04-09 16:06:09 +08:00
|
|
|
dep->endpoint.max_streams = 15;
|
|
|
|
dep->endpoint.ops = &dwc3_gadget_ep_ops;
|
|
|
|
list_add_tail(&dep->endpoint.ep_list,
|
|
|
|
&dwc->gadget.ep_list);
|
|
|
|
dep->endpoint.caps.type_iso = true;
|
|
|
|
dep->endpoint.caps.type_bulk = true;
|
|
|
|
dep->endpoint.caps.type_int = true;
|
2017-01-24 00:01:59 +08:00
|
|
|
|
2018-04-09 16:06:09 +08:00
|
|
|
return dwc3_alloc_trb_pool(dep);
|
|
|
|
}
|
2017-01-24 00:01:59 +08:00
|
|
|
|
2018-04-09 16:06:09 +08:00
|
|
|
static int dwc3_gadget_init_out_endpoint(struct dwc3_ep *dep)
|
|
|
|
{
|
|
|
|
struct dwc3 *dwc = dep->dwc;
|
2017-01-24 00:01:59 +08:00
|
|
|
|
2018-04-09 16:06:09 +08:00
|
|
|
usb_ep_set_maxpacket_limit(&dep->endpoint, 1024);
|
|
|
|
dep->endpoint.max_streams = 15;
|
|
|
|
dep->endpoint.ops = &dwc3_gadget_ep_ops;
|
|
|
|
list_add_tail(&dep->endpoint.ep_list,
|
|
|
|
&dwc->gadget.ep_list);
|
|
|
|
dep->endpoint.caps.type_iso = true;
|
|
|
|
dep->endpoint.caps.type_bulk = true;
|
|
|
|
dep->endpoint.caps.type_int = true;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2018-04-09 16:06:09 +08:00
|
|
|
return dwc3_alloc_trb_pool(dep);
|
|
|
|
}
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2018-04-09 16:06:09 +08:00
|
|
|
static int dwc3_gadget_init_endpoint(struct dwc3 *dwc, u8 epnum)
|
|
|
|
{
|
|
|
|
struct dwc3_ep *dep;
|
|
|
|
bool direction = epnum & 1;
|
|
|
|
int ret;
|
|
|
|
u8 num = epnum >> 1;
|
2011-11-04 18:32:47 +08:00
|
|
|
|
2018-04-09 16:06:09 +08:00
|
|
|
dep = kzalloc(sizeof(*dep), GFP_KERNEL);
|
|
|
|
if (!dep)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
dep->dwc = dwc;
|
|
|
|
dep->number = epnum;
|
|
|
|
dep->direction = direction;
|
|
|
|
dep->regs = dwc->regs + DWC3_DEP_BASE(epnum);
|
|
|
|
dwc->eps[epnum] = dep;
|
usb: dwc3: Add workaround for isoc start transfer failure
In DWC_usb31 version 1.70a-ea06 and prior, for highspeed and fullspeed
isochronous IN, BIT[15:14] of the 16-bit microframe number reported by
the XferNotReady event are invalid. The driver uses this number to
schedule the isochronous transfer and passes it to the START TRANSFER
command. Because this number is invalid, the command may fail. If
BIT[15:14] matches the internal 16-bit microframe, the START TRANSFER
command will pass and the transfer will start at the scheduled time, if
it is off by 1, the command will still pass, but the transfer will start
2 seconds in the future. For all other conditions, the START TRANSFER
command will fail with bus-expiry.
In order to workaround this issue, we can test for the correct
combination of BIT[15:14] by sending START TRANSFER commands with
different values of BIT[15:14]: 'b00, 'b01, 'b10, and 'b11. Each
combination is 2^14 uframe apart (or 2 seconds). 4 seconds into the
future will result in a bus-expiry status. As the result, within the 4
possible combinations for BIT[15:14], there will be 2 successful and 2
failure START COMMAND status. One of the 2 successful command status
will result in a 2-second delay start. The smaller BIT[15:14] value is
the correct combination.
Since there are only 4 outcomes and the results are ordered, we can
simply test 2 START TRANSFER commands with BIT[15:14] combinations 'b00
and 'b01 to deduce the smaller successful combination.
Let test0 = test status for combination 'b00 and test1 = test status for
'b01 of BIT[15:14]. The correct combination is as follow:
if test0 fails and test1 passes, BIT[15:14] is 'b01
if test0 fails and test1 fails, BIT[15:14] is 'b10
if test0 passes and test1 fails, BIT[15:14] is 'b11
if test0 passes and test1 passes, BIT[15:14] is 'b00
Synopsys STAR 9001202023: Wrong microframe number for isochronous IN
endpoints.
Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2018-11-15 14:56:54 +08:00
|
|
|
dep->combo_num = 0;
|
|
|
|
dep->start_cmd_status = 0;
|
2018-04-09 16:06:09 +08:00
|
|
|
|
|
|
|
snprintf(dep->name, sizeof(dep->name), "ep%u%s", num,
|
|
|
|
direction ? "in" : "out");
|
|
|
|
|
|
|
|
dep->endpoint.name = dep->name;
|
|
|
|
|
|
|
|
if (!(dep->number > 1)) {
|
|
|
|
dep->endpoint.desc = &dwc3_gadget_ep0_desc;
|
|
|
|
dep->endpoint.comp_desc = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (num == 0)
|
|
|
|
ret = dwc3_gadget_init_control_endpoint(dep);
|
|
|
|
else if (direction)
|
|
|
|
ret = dwc3_gadget_init_in_endpoint(dep);
|
|
|
|
else
|
|
|
|
ret = dwc3_gadget_init_out_endpoint(dep);
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2015-07-31 22:00:19 +08:00
|
|
|
|
2018-04-09 16:06:09 +08:00
|
|
|
dep->endpoint.caps.dir_in = direction;
|
|
|
|
dep->endpoint.caps.dir_out = !direction;
|
2015-07-31 22:00:19 +08:00
|
|
|
|
2018-04-09 16:06:09 +08:00
|
|
|
INIT_LIST_HEAD(&dep->pending_list);
|
|
|
|
INIT_LIST_HEAD(&dep->started_list);
|
2018-08-01 18:53:29 +08:00
|
|
|
INIT_LIST_HEAD(&dep->cancelled_list);
|
2018-04-09 16:06:09 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dwc3_gadget_init_endpoints(struct dwc3 *dwc, u8 total)
|
|
|
|
{
|
|
|
|
u8 epnum;
|
|
|
|
|
|
|
|
INIT_LIST_HEAD(&dwc->gadget.ep_list);
|
|
|
|
|
|
|
|
for (epnum = 0; epnum < total; epnum++) {
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = dwc3_gadget_init_endpoint(dwc, epnum);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dwc3_gadget_free_endpoints(struct dwc3 *dwc)
|
|
|
|
{
|
|
|
|
struct dwc3_ep *dep;
|
|
|
|
u8 epnum;
|
|
|
|
|
|
|
|
for (epnum = 0; epnum < DWC3_ENDPOINTS_NUM; epnum++) {
|
|
|
|
dep = dwc->eps[epnum];
|
2011-05-05 21:21:59 +08:00
|
|
|
if (!dep)
|
|
|
|
continue;
|
2013-05-27 17:05:49 +08:00
|
|
|
/*
|
|
|
|
* Physical endpoints 0 and 1 are special; they form the
|
|
|
|
* bi-directional USB endpoint 0.
|
|
|
|
*
|
|
|
|
* For those two physical endpoints, we don't allocate a TRB
|
|
|
|
* pool nor do we add them the endpoints list. Due to that, we
|
|
|
|
* shouldn't do these two operations otherwise we would end up
|
|
|
|
* with all sorts of bugs when removing dwc3.ko.
|
|
|
|
*/
|
|
|
|
if (epnum != 0 && epnum != 1) {
|
|
|
|
dwc3_free_trb_pool(dep);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
list_del(&dep->endpoint.ep_list);
|
2013-05-27 17:05:49 +08:00
|
|
|
}
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
|
|
|
kfree(dep);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------------- */
|
2013-02-26 21:11:05 +08:00
|
|
|
|
2018-03-27 15:53:29 +08:00
|
|
|
static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep,
|
|
|
|
struct dwc3_request *req, struct dwc3_trb *trb,
|
|
|
|
const struct dwc3_event_depevt *event, int status, int chain)
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
{
|
|
|
|
unsigned int count;
|
|
|
|
|
2016-08-12 18:20:32 +08:00
|
|
|
dwc3_ep_inc_deq(dep);
|
2016-10-05 19:24:37 +08:00
|
|
|
|
2014-05-01 06:45:10 +08:00
|
|
|
trace_dwc3_complete_trb(dep, trb);
|
2018-08-01 18:32:07 +08:00
|
|
|
req->num_trbs--;
|
2014-05-01 06:45:10 +08:00
|
|
|
|
2016-08-10 16:13:26 +08:00
|
|
|
/*
|
|
|
|
* If we're in the middle of series of chained TRBs and we
|
|
|
|
* receive a short transfer along the way, DWC3 will skip
|
|
|
|
* through all TRBs including the last TRB in the chain (the
|
|
|
|
* where CHN bit is zero. DWC3 will also avoid clearing HWO
|
|
|
|
* bit and SW has to do it manually.
|
|
|
|
*
|
|
|
|
* We're going to do that here to avoid problems of HW trying
|
|
|
|
* to use bogus TRBs for transfers.
|
|
|
|
*/
|
|
|
|
if (chain && (trb->ctrl & DWC3_TRB_CTRL_HWO))
|
|
|
|
trb->ctrl &= ~DWC3_TRB_CTRL_HWO;
|
|
|
|
|
2018-11-16 11:03:27 +08:00
|
|
|
/*
|
|
|
|
* For isochronous transfers, the first TRB in a service interval must
|
|
|
|
* have the Isoc-First type. Track and report its interval frame number.
|
|
|
|
*/
|
|
|
|
if (usb_endpoint_xfer_isoc(dep->endpoint.desc) &&
|
|
|
|
(trb->ctrl & DWC3_TRBCTL_ISOCHRONOUS_FIRST)) {
|
|
|
|
unsigned int frame_number;
|
|
|
|
|
|
|
|
frame_number = DWC3_TRB_CTRL_GET_SID_SOFN(trb->ctrl);
|
|
|
|
frame_number &= ~(dep->interval - 1);
|
|
|
|
req->request.frame_number = frame_number;
|
|
|
|
}
|
|
|
|
|
2017-01-05 20:58:46 +08:00
|
|
|
/*
|
|
|
|
* If we're dealing with unaligned size OUT transfer, we will be left
|
|
|
|
* with one TRB pending in the ring. We need to manually clear HWO bit
|
|
|
|
* from that TRB.
|
|
|
|
*/
|
2018-08-01 18:15:05 +08:00
|
|
|
|
|
|
|
if (req->needs_extra_trb && !(trb->ctrl & DWC3_TRB_CTRL_CHN)) {
|
2017-01-05 20:58:46 +08:00
|
|
|
trb->ctrl &= ~DWC3_TRB_CTRL_HWO;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-01-14 18:29:37 +08:00
|
|
|
count = trb->size & DWC3_TRB_SIZE_MASK;
|
2016-10-25 18:47:21 +08:00
|
|
|
req->remaining += count;
|
2013-01-14 18:29:37 +08:00
|
|
|
|
2017-03-08 19:56:37 +08:00
|
|
|
if ((trb->ctrl & DWC3_TRB_CTRL_HWO) && status != -ESHUTDOWN)
|
|
|
|
return 1;
|
|
|
|
|
2018-04-06 16:04:21 +08:00
|
|
|
if (event->status & DEPEVT_STATUS_SHORT && !chain)
|
2013-01-14 18:29:37 +08:00
|
|
|
return 1;
|
2016-08-12 18:19:20 +08:00
|
|
|
|
2018-04-06 20:37:30 +08:00
|
|
|
if (event->status & DEPEVT_STATUS_IOC)
|
2013-01-14 18:29:37 +08:00
|
|
|
return 1;
|
2016-08-12 18:19:20 +08:00
|
|
|
|
2013-01-14 18:29:37 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-03-29 18:32:10 +08:00
|
|
|
static int dwc3_gadget_ep_reclaim_trb_sg(struct dwc3_ep *dep,
|
|
|
|
struct dwc3_request *req, const struct dwc3_event_depevt *event,
|
|
|
|
int status)
|
|
|
|
{
|
|
|
|
struct dwc3_trb *trb = &dep->trb_pool[dep->trb_dequeue];
|
|
|
|
struct scatterlist *sg = req->sg;
|
|
|
|
struct scatterlist *s;
|
|
|
|
unsigned int pending = req->num_pending_sgs;
|
|
|
|
unsigned int i;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
for_each_sg(sg, s, pending, i) {
|
|
|
|
trb = &dep->trb_pool[dep->trb_dequeue];
|
|
|
|
|
|
|
|
if (trb->ctrl & DWC3_TRB_CTRL_HWO)
|
|
|
|
break;
|
|
|
|
|
|
|
|
req->sg = sg_next(s);
|
|
|
|
req->num_pending_sgs--;
|
|
|
|
|
|
|
|
ret = dwc3_gadget_ep_reclaim_completed_trb(dep, req,
|
|
|
|
trb, event, status, true);
|
|
|
|
if (ret)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dwc3_gadget_ep_reclaim_trb_linear(struct dwc3_ep *dep,
|
|
|
|
struct dwc3_request *req, const struct dwc3_event_depevt *event,
|
|
|
|
int status)
|
|
|
|
{
|
|
|
|
struct dwc3_trb *trb = &dep->trb_pool[dep->trb_dequeue];
|
|
|
|
|
|
|
|
return dwc3_gadget_ep_reclaim_completed_trb(dep, req, trb,
|
|
|
|
event, status, false);
|
|
|
|
}
|
|
|
|
|
2018-04-06 20:37:30 +08:00
|
|
|
static bool dwc3_gadget_ep_request_completed(struct dwc3_request *req)
|
|
|
|
{
|
|
|
|
return req->request.actual == req->request.length;
|
|
|
|
}
|
|
|
|
|
2018-04-06 20:56:35 +08:00
|
|
|
static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep,
|
|
|
|
const struct dwc3_event_depevt *event,
|
|
|
|
struct dwc3_request *req, int status)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (req->num_pending_sgs)
|
|
|
|
ret = dwc3_gadget_ep_reclaim_trb_sg(dep, req, event,
|
|
|
|
status);
|
|
|
|
else
|
|
|
|
ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event,
|
|
|
|
status);
|
|
|
|
|
2018-08-01 18:15:05 +08:00
|
|
|
if (req->needs_extra_trb) {
|
2018-04-06 20:56:35 +08:00
|
|
|
ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event,
|
|
|
|
status);
|
2018-08-01 18:15:05 +08:00
|
|
|
req->needs_extra_trb = false;
|
2018-04-06 20:56:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
req->request.actual = req->request.length - req->remaining;
|
|
|
|
|
|
|
|
if (!dwc3_gadget_ep_request_completed(req) &&
|
|
|
|
req->num_pending_sgs) {
|
|
|
|
__dwc3_gadget_kick_transfer(dep);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
dwc3_gadget_giveback(dep, req, status);
|
|
|
|
|
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-03-29 16:53:40 +08:00
|
|
|
static void dwc3_gadget_ep_cleanup_completed_requests(struct dwc3_ep *dep,
|
2018-03-27 15:53:29 +08:00
|
|
|
const struct dwc3_event_depevt *event, int status)
|
2013-01-14 18:29:37 +08:00
|
|
|
{
|
2018-04-06 20:49:49 +08:00
|
|
|
struct dwc3_request *req;
|
|
|
|
struct dwc3_request *tmp;
|
2013-01-14 18:29:37 +08:00
|
|
|
|
2018-04-06 20:49:49 +08:00
|
|
|
list_for_each_entry_safe(req, tmp, &dep->started_list, list) {
|
2018-04-06 20:50:29 +08:00
|
|
|
int ret;
|
2016-08-10 16:13:26 +08:00
|
|
|
|
2018-04-06 20:56:35 +08:00
|
|
|
ret = dwc3_gadget_ep_cleanup_completed_request(dep, event,
|
|
|
|
req, status);
|
2018-03-29 17:10:31 +08:00
|
|
|
if (ret)
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
break;
|
2016-08-11 19:38:37 +08:00
|
|
|
}
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
|
2018-03-27 16:26:53 +08:00
|
|
|
static void dwc3_gadget_endpoint_frame_from_event(struct dwc3_ep *dep,
|
|
|
|
const struct dwc3_event_depevt *event)
|
|
|
|
{
|
2018-04-11 15:34:34 +08:00
|
|
|
dep->frame_number = event->parameters;
|
2018-03-27 16:26:53 +08:00
|
|
|
}
|
|
|
|
|
2018-03-27 15:53:29 +08:00
|
|
|
static void dwc3_gadget_endpoint_transfer_in_progress(struct dwc3_ep *dep,
|
|
|
|
const struct dwc3_event_depevt *event)
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
{
|
2018-03-27 15:53:29 +08:00
|
|
|
struct dwc3 *dwc = dep->dwc;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
unsigned status = 0;
|
2018-03-29 17:49:28 +08:00
|
|
|
bool stop = false;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2018-03-27 16:26:53 +08:00
|
|
|
dwc3_gadget_endpoint_frame_from_event(dep, event);
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
if (event->status & DEPEVT_STATUS_BUSERR)
|
|
|
|
status = -ECONNRESET;
|
|
|
|
|
2018-03-29 17:49:28 +08:00
|
|
|
if (event->status & DEPEVT_STATUS_MISSED_ISOC) {
|
|
|
|
status = -EXDEV;
|
2018-04-11 15:32:52 +08:00
|
|
|
|
|
|
|
if (list_empty(&dep->started_list))
|
|
|
|
stop = true;
|
2018-03-29 17:49:28 +08:00
|
|
|
}
|
|
|
|
|
2018-03-29 16:10:45 +08:00
|
|
|
dwc3_gadget_ep_cleanup_completed_requests(dep, event, status);
|
2011-10-14 18:00:30 +08:00
|
|
|
|
2018-03-29 17:49:28 +08:00
|
|
|
if (stop) {
|
2019-02-13 19:00:54 +08:00
|
|
|
dwc3_stop_active_transfer(dep, true, true);
|
2018-03-29 17:49:28 +08:00
|
|
|
dep->flags = DWC3_EP_ENABLED;
|
|
|
|
}
|
|
|
|
|
2011-10-14 18:00:30 +08:00
|
|
|
/*
|
|
|
|
* WORKAROUND: This is the 2nd half of U1/U2 -> U0 workaround.
|
|
|
|
* See dwc3_gadget_linksts_change_interrupt() for 1st half.
|
|
|
|
*/
|
|
|
|
if (dwc->revision < DWC3_REVISION_183A) {
|
|
|
|
u32 reg;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < DWC3_ENDPOINTS_NUM; i++) {
|
2012-08-02 03:08:30 +08:00
|
|
|
dep = dwc->eps[i];
|
2011-10-14 18:00:30 +08:00
|
|
|
|
|
|
|
if (!(dep->flags & DWC3_EP_ENABLED))
|
|
|
|
continue;
|
|
|
|
|
2016-03-14 17:01:31 +08:00
|
|
|
if (!list_empty(&dep->started_list))
|
2011-10-14 18:00:30 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
|
|
|
|
reg |= dwc->u1u2;
|
|
|
|
dwc3_writel(dwc->regs, DWC3_DCTL, reg);
|
|
|
|
|
|
|
|
dwc->u1u2 = 0;
|
|
|
|
}
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
|
2018-03-27 15:53:29 +08:00
|
|
|
static void dwc3_gadget_endpoint_transfer_not_ready(struct dwc3_ep *dep,
|
|
|
|
const struct dwc3_event_depevt *event)
|
2018-03-27 15:47:48 +08:00
|
|
|
{
|
2018-03-27 16:26:53 +08:00
|
|
|
dwc3_gadget_endpoint_frame_from_event(dep, event);
|
2018-08-14 15:41:19 +08:00
|
|
|
(void) __dwc3_gadget_start_isoc(dep);
|
2018-03-27 15:47:48 +08:00
|
|
|
}
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
static void dwc3_endpoint_interrupt(struct dwc3 *dwc,
|
|
|
|
const struct dwc3_event_depevt *event)
|
|
|
|
{
|
|
|
|
struct dwc3_ep *dep;
|
|
|
|
u8 epnum = event->endpoint_number;
|
2016-10-31 19:38:36 +08:00
|
|
|
u8 cmd;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
|
|
|
dep = dwc->eps[epnum];
|
|
|
|
|
2016-12-08 17:57:34 +08:00
|
|
|
if (!(dep->flags & DWC3_EP_ENABLED)) {
|
2019-01-21 19:08:44 +08:00
|
|
|
if (!(dep->flags & DWC3_EP_TRANSFER_STARTED))
|
2016-12-08 17:57:34 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* Handle only EPCMDCMPLT when EP disabled */
|
|
|
|
if (event->endpoint_event != DWC3_DEPEVT_EPCMDCMPLT)
|
|
|
|
return;
|
|
|
|
}
|
2012-06-06 14:19:35 +08:00
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
if (epnum == 0 || epnum == 1) {
|
|
|
|
dwc3_ep0_interrupt(dwc, event);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (event->endpoint_event) {
|
|
|
|
case DWC3_DEPEVT_XFERINPROGRESS:
|
2018-03-27 15:53:29 +08:00
|
|
|
dwc3_gadget_endpoint_transfer_in_progress(dep, event);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
break;
|
|
|
|
case DWC3_DEPEVT_XFERNOTREADY:
|
2018-03-27 15:53:29 +08:00
|
|
|
dwc3_gadget_endpoint_transfer_not_ready(dep, event);
|
2011-09-30 15:58:47 +08:00
|
|
|
break;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
case DWC3_DEPEVT_EPCMDCMPLT:
|
2016-10-31 19:38:36 +08:00
|
|
|
cmd = DEPEVT_PARAMETER_CMD(event->parameters);
|
|
|
|
|
|
|
|
if (cmd == DWC3_DEPCMD_ENDTRANSFER) {
|
2019-01-21 19:08:44 +08:00
|
|
|
dep->flags &= ~DWC3_EP_TRANSFER_STARTED;
|
2018-08-01 18:56:50 +08:00
|
|
|
dwc3_gadget_ep_cleanup_cancelled_requests(dep);
|
2016-10-31 19:38:36 +08:00
|
|
|
}
|
|
|
|
break;
|
2018-03-27 15:41:39 +08:00
|
|
|
case DWC3_DEPEVT_STREAMEVT:
|
2018-03-26 18:26:56 +08:00
|
|
|
case DWC3_DEPEVT_XFERCOMPLETE:
|
2016-10-31 19:38:36 +08:00
|
|
|
case DWC3_DEPEVT_RXTXFIFOEVT:
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dwc3_disconnect_gadget(struct dwc3 *dwc)
|
|
|
|
{
|
|
|
|
if (dwc->gadget_driver && dwc->gadget_driver->disconnect) {
|
|
|
|
spin_unlock(&dwc->lock);
|
|
|
|
dwc->gadget_driver->disconnect(&dwc->gadget);
|
|
|
|
spin_lock(&dwc->lock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-27 00:17:07 +08:00
|
|
|
static void dwc3_suspend_gadget(struct dwc3 *dwc)
|
|
|
|
{
|
2014-03-07 19:19:57 +08:00
|
|
|
if (dwc->gadget_driver && dwc->gadget_driver->suspend) {
|
2014-02-27 00:17:07 +08:00
|
|
|
spin_unlock(&dwc->lock);
|
|
|
|
dwc->gadget_driver->suspend(&dwc->gadget);
|
|
|
|
spin_lock(&dwc->lock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dwc3_resume_gadget(struct dwc3 *dwc)
|
|
|
|
{
|
2014-03-07 19:19:57 +08:00
|
|
|
if (dwc->gadget_driver && dwc->gadget_driver->resume) {
|
2014-02-27 00:17:07 +08:00
|
|
|
spin_unlock(&dwc->lock);
|
|
|
|
dwc->gadget_driver->resume(&dwc->gadget);
|
2015-01-30 00:29:18 +08:00
|
|
|
spin_lock(&dwc->lock);
|
2014-11-06 14:27:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dwc3_reset_gadget(struct dwc3 *dwc)
|
|
|
|
{
|
|
|
|
if (!dwc->gadget_driver)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (dwc->gadget.speed != USB_SPEED_UNKNOWN) {
|
|
|
|
spin_unlock(&dwc->lock);
|
|
|
|
usb_gadget_udc_reset(&dwc->gadget, dwc->gadget_driver);
|
2014-02-27 00:17:07 +08:00
|
|
|
spin_lock(&dwc->lock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-13 19:00:54 +08:00
|
|
|
static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force,
|
|
|
|
bool interrupt)
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
{
|
2018-03-27 15:53:29 +08:00
|
|
|
struct dwc3 *dwc = dep->dwc;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
struct dwc3_gadget_ep_cmd_params params;
|
|
|
|
u32 cmd;
|
|
|
|
int ret;
|
|
|
|
|
2019-01-21 19:08:44 +08:00
|
|
|
if (!(dep->flags & DWC3_EP_TRANSFER_STARTED))
|
2012-06-23 04:53:08 +08:00
|
|
|
return;
|
|
|
|
|
2012-07-06 17:49:10 +08:00
|
|
|
/*
|
|
|
|
* NOTICE: We are violating what the Databook says about the
|
|
|
|
* EndTransfer command. Ideally we would _always_ wait for the
|
|
|
|
* EndTransfer Command Completion IRQ, but that's causing too
|
|
|
|
* much trouble synchronizing between us and gadget driver.
|
|
|
|
*
|
|
|
|
* We have discussed this with the IP Provider and it was
|
|
|
|
* suggested to giveback all requests here, but give HW some
|
|
|
|
* extra time to synchronize with the interconnect. We're using
|
2014-12-24 00:34:43 +08:00
|
|
|
* an arbitrary 100us delay for that.
|
2012-07-06 17:49:10 +08:00
|
|
|
*
|
|
|
|
* Note also that a similar handling was tested by Synopsys
|
|
|
|
* (thanks a lot Paul) and nothing bad has come out of it.
|
|
|
|
* In short, what we're doing is:
|
|
|
|
*
|
|
|
|
* - Issue EndTransfer WITH CMDIOC bit set
|
|
|
|
* - Wait 100us
|
2016-08-23 06:39:13 +08:00
|
|
|
*
|
|
|
|
* As of IP version 3.10a of the DWC_usb3 IP, the controller
|
|
|
|
* supports a mode to work around the above limitation. The
|
|
|
|
* software can poll the CMDACT bit in the DEPCMD register
|
|
|
|
* after issuing a EndTransfer command. This mode is enabled
|
|
|
|
* by writing GUCTL2[14]. This polling is already done in the
|
|
|
|
* dwc3_send_gadget_ep_cmd() function so if the mode is
|
|
|
|
* enabled, the EndTransfer command will have completed upon
|
|
|
|
* returning from this function and we don't need to delay for
|
|
|
|
* 100us.
|
|
|
|
*
|
|
|
|
* This mode is NOT available on the DWC_usb31 IP.
|
2012-07-06 17:49:10 +08:00
|
|
|
*/
|
|
|
|
|
2012-06-23 04:53:08 +08:00
|
|
|
cmd = DWC3_DEPCMD_ENDTRANSFER;
|
2012-04-27 19:17:35 +08:00
|
|
|
cmd |= force ? DWC3_DEPCMD_HIPRI_FORCERM : 0;
|
2019-02-13 19:00:54 +08:00
|
|
|
cmd |= interrupt ? DWC3_DEPCMD_CMDIOC : 0;
|
2012-06-06 17:04:13 +08:00
|
|
|
cmd |= DWC3_DEPCMD_PARAM(dep->resource_index);
|
2012-06-23 04:53:08 +08:00
|
|
|
memset(¶ms, 0, sizeof(params));
|
2016-04-12 21:42:43 +08:00
|
|
|
ret = dwc3_send_gadget_ep_cmd(dep, cmd, ¶ms);
|
2012-06-23 04:53:08 +08:00
|
|
|
WARN_ON_ONCE(ret);
|
2012-06-06 17:04:13 +08:00
|
|
|
dep->resource_index = 0;
|
2016-08-23 06:39:13 +08:00
|
|
|
|
2019-01-21 19:08:44 +08:00
|
|
|
if (dwc3_is_usb31(dwc) || dwc->revision < DWC3_REVISION_310A)
|
2016-08-23 06:39:13 +08:00
|
|
|
udelay(100);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void dwc3_clear_stall_all_ep(struct dwc3 *dwc)
|
|
|
|
{
|
|
|
|
u32 epnum;
|
|
|
|
|
|
|
|
for (epnum = 1; epnum < DWC3_ENDPOINTS_NUM; epnum++) {
|
|
|
|
struct dwc3_ep *dep;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
dep = dwc->eps[epnum];
|
2011-05-05 21:21:59 +08:00
|
|
|
if (!dep)
|
|
|
|
continue;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
|
|
|
if (!(dep->flags & DWC3_EP_STALL))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
dep->flags &= ~DWC3_EP_STALL;
|
|
|
|
|
2016-06-01 08:49:56 +08:00
|
|
|
ret = dwc3_send_clear_stall_ep_cmd(dep);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
WARN_ON_ONCE(ret);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dwc3_gadget_disconnect_interrupt(struct dwc3 *dwc)
|
|
|
|
{
|
2012-05-24 15:30:01 +08:00
|
|
|
int reg;
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
|
|
|
|
reg &= ~DWC3_DCTL_INITU1ENA;
|
|
|
|
dwc3_writel(dwc->regs, DWC3_DCTL, reg);
|
|
|
|
|
|
|
|
reg &= ~DWC3_DCTL_INITU2ENA;
|
|
|
|
dwc3_writel(dwc->regs, DWC3_DCTL, reg);
|
|
|
|
|
|
|
|
dwc3_disconnect_gadget(dwc);
|
|
|
|
|
|
|
|
dwc->gadget.speed = USB_SPEED_UNKNOWN;
|
2011-10-14 20:11:49 +08:00
|
|
|
dwc->setup_packet_pending = false;
|
2014-10-11 04:24:00 +08:00
|
|
|
usb_gadget_set_state(&dwc->gadget, USB_STATE_NOTATTACHED);
|
2016-05-16 18:14:48 +08:00
|
|
|
|
|
|
|
dwc->connected = false;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc)
|
|
|
|
{
|
|
|
|
u32 reg;
|
|
|
|
|
2016-05-16 18:14:48 +08:00
|
|
|
dwc->connected = true;
|
|
|
|
|
2011-10-14 20:11:49 +08:00
|
|
|
/*
|
|
|
|
* WORKAROUND: DWC3 revisions <1.88a have an issue which
|
|
|
|
* would cause a missing Disconnect Event if there's a
|
|
|
|
* pending Setup Packet in the FIFO.
|
|
|
|
*
|
|
|
|
* There's no suggested workaround on the official Bug
|
|
|
|
* report, which states that "unless the driver/application
|
|
|
|
* is doing any special handling of a disconnect event,
|
|
|
|
* there is no functional issue".
|
|
|
|
*
|
|
|
|
* Unfortunately, it turns out that we _do_ some special
|
|
|
|
* handling of a disconnect event, namely complete all
|
|
|
|
* pending transfers, notify gadget driver of the
|
|
|
|
* disconnection, and so on.
|
|
|
|
*
|
|
|
|
* Our suggested workaround is to follow the Disconnect
|
|
|
|
* Event steps here, instead, based on a setup_packet_pending
|
2015-11-17 06:20:34 +08:00
|
|
|
* flag. Such flag gets set whenever we have a SETUP_PENDING
|
|
|
|
* status for EP0 TRBs and gets cleared on XferComplete for the
|
2011-10-14 20:11:49 +08:00
|
|
|
* same endpoint.
|
|
|
|
*
|
|
|
|
* Refers to:
|
|
|
|
*
|
|
|
|
* STAR#9000466709: RTL: Device : Disconnect event not
|
|
|
|
* generated if setup packet pending in FIFO
|
|
|
|
*/
|
|
|
|
if (dwc->revision < DWC3_REVISION_188A) {
|
|
|
|
if (dwc->setup_packet_pending)
|
|
|
|
dwc3_gadget_disconnect_interrupt(dwc);
|
|
|
|
}
|
|
|
|
|
2014-11-06 14:27:53 +08:00
|
|
|
dwc3_reset_gadget(dwc);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
|
|
|
|
reg &= ~DWC3_DCTL_TSTCTRL_MASK;
|
|
|
|
dwc3_writel(dwc->regs, DWC3_DCTL, reg);
|
2012-02-10 18:21:18 +08:00
|
|
|
dwc->test_mode = false;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
dwc3_clear_stall_all_ep(dwc);
|
|
|
|
|
|
|
|
/* Reset device address to zero */
|
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_DCFG);
|
|
|
|
reg &= ~(DWC3_DCFG_DEVADDR_MASK);
|
|
|
|
dwc3_writel(dwc->regs, DWC3_DCFG, reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc)
|
|
|
|
{
|
|
|
|
struct dwc3_ep *dep;
|
|
|
|
int ret;
|
|
|
|
u32 reg;
|
|
|
|
u8 speed;
|
|
|
|
|
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_DSTS);
|
|
|
|
speed = reg & DWC3_DSTS_CONNECTSPD;
|
|
|
|
dwc->speed = speed;
|
|
|
|
|
2016-11-11 09:23:25 +08:00
|
|
|
/*
|
|
|
|
* RAMClkSel is reset to 0 after USB reset, so it must be reprogrammed
|
|
|
|
* each time on Connect Done.
|
|
|
|
*
|
|
|
|
* Currently we always use the reset value. If any platform
|
|
|
|
* wants to set this to a different value, we need to add a
|
|
|
|
* setting and update GCTL.RAMCLKSEL here.
|
|
|
|
*/
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
|
|
|
switch (speed) {
|
2016-05-21 07:34:26 +08:00
|
|
|
case DWC3_DSTS_SUPERSPEED_PLUS:
|
2016-02-06 09:09:13 +08:00
|
|
|
dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512);
|
|
|
|
dwc->gadget.ep0->maxpacket = 512;
|
|
|
|
dwc->gadget.speed = USB_SPEED_SUPER_PLUS;
|
|
|
|
break;
|
2016-05-21 07:34:26 +08:00
|
|
|
case DWC3_DSTS_SUPERSPEED:
|
2011-10-14 19:51:38 +08:00
|
|
|
/*
|
|
|
|
* WORKAROUND: DWC3 revisions <1.90a have an issue which
|
|
|
|
* would cause a missing USB3 Reset event.
|
|
|
|
*
|
|
|
|
* In such situations, we should force a USB3 Reset
|
|
|
|
* event by calling our dwc3_gadget_reset_interrupt()
|
|
|
|
* routine.
|
|
|
|
*
|
|
|
|
* Refers to:
|
|
|
|
*
|
|
|
|
* STAR#9000483510: RTL: SS : USB3 reset event may
|
|
|
|
* not be generated always when the link enters poll
|
|
|
|
*/
|
|
|
|
if (dwc->revision < DWC3_REVISION_190A)
|
|
|
|
dwc3_gadget_reset_interrupt(dwc);
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512);
|
|
|
|
dwc->gadget.ep0->maxpacket = 512;
|
|
|
|
dwc->gadget.speed = USB_SPEED_SUPER;
|
|
|
|
break;
|
2016-05-21 07:34:26 +08:00
|
|
|
case DWC3_DSTS_HIGHSPEED:
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(64);
|
|
|
|
dwc->gadget.ep0->maxpacket = 64;
|
|
|
|
dwc->gadget.speed = USB_SPEED_HIGH;
|
|
|
|
break;
|
2017-01-03 20:32:09 +08:00
|
|
|
case DWC3_DSTS_FULLSPEED:
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(64);
|
|
|
|
dwc->gadget.ep0->maxpacket = 64;
|
|
|
|
dwc->gadget.speed = USB_SPEED_FULL;
|
|
|
|
break;
|
2016-05-21 07:34:26 +08:00
|
|
|
case DWC3_DSTS_LOWSPEED:
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(8);
|
|
|
|
dwc->gadget.ep0->maxpacket = 8;
|
|
|
|
dwc->gadget.speed = USB_SPEED_LOW;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-01-13 10:18:05 +08:00
|
|
|
dwc->eps[1]->endpoint.maxpacket = dwc->gadget.ep0->maxpacket;
|
|
|
|
|
2013-01-14 18:29:31 +08:00
|
|
|
/* Enable USB2 LPM Capability */
|
|
|
|
|
2016-02-06 09:08:45 +08:00
|
|
|
if ((dwc->revision > DWC3_REVISION_194A) &&
|
2016-05-21 07:34:26 +08:00
|
|
|
(speed != DWC3_DSTS_SUPERSPEED) &&
|
|
|
|
(speed != DWC3_DSTS_SUPERSPEED_PLUS)) {
|
2013-01-14 18:29:31 +08:00
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_DCFG);
|
|
|
|
reg |= DWC3_DCFG_LPM_CAP;
|
|
|
|
dwc3_writel(dwc->regs, DWC3_DCFG, reg);
|
|
|
|
|
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
|
|
|
|
reg &= ~(DWC3_DCTL_HIRD_THRES_MASK | DWC3_DCTL_L1_HIBER_EN);
|
|
|
|
|
2019-08-20 09:35:58 +08:00
|
|
|
reg |= DWC3_DCTL_HIRD_THRES(dwc->hird_threshold |
|
|
|
|
(dwc->is_utmi_l1_suspend << 4));
|
2013-01-14 18:29:31 +08:00
|
|
|
|
2014-10-28 19:54:26 +08:00
|
|
|
/*
|
|
|
|
* When dwc3 revisions >= 2.40a, LPM Erratum is enabled and
|
|
|
|
* DCFG.LPMCap is set, core responses with an ACK and the
|
|
|
|
* BESL value in the LPM token is less than or equal to LPM
|
|
|
|
* NYET threshold.
|
|
|
|
*/
|
|
|
|
WARN_ONCE(dwc->revision < DWC3_REVISION_240A
|
|
|
|
&& dwc->has_lpm_erratum,
|
2016-09-17 22:44:17 +08:00
|
|
|
"LPM Erratum not available on dwc3 revisions < 2.40a\n");
|
2014-10-28 19:54:26 +08:00
|
|
|
|
|
|
|
if (dwc->has_lpm_erratum && dwc->revision >= DWC3_REVISION_240A)
|
2019-04-26 04:55:30 +08:00
|
|
|
reg |= DWC3_DCTL_NYET_THRES(dwc->lpm_nyet_threshold);
|
2014-10-28 19:54:26 +08:00
|
|
|
|
2013-12-20 06:37:05 +08:00
|
|
|
dwc3_writel(dwc->regs, DWC3_DCTL, reg);
|
|
|
|
} else {
|
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
|
|
|
|
reg &= ~DWC3_DCTL_HIRD_THRES_MASK;
|
2013-01-14 18:29:31 +08:00
|
|
|
dwc3_writel(dwc->regs, DWC3_DCTL, reg);
|
|
|
|
}
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
dep = dwc->eps[0];
|
2018-04-09 17:40:48 +08:00
|
|
|
ret = __dwc3_gadget_ep_enable(dep, DWC3_DEPCFG_ACTION_MODIFY);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
if (ret) {
|
|
|
|
dev_err(dwc->dev, "failed to enable %s\n", dep->name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dep = dwc->eps[1];
|
2018-04-09 17:40:48 +08:00
|
|
|
ret = __dwc3_gadget_ep_enable(dep, DWC3_DEPCFG_ACTION_MODIFY);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
if (ret) {
|
|
|
|
dev_err(dwc->dev, "failed to enable %s\n", dep->name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Configure PHY via GUSB3PIPECTLn if required.
|
|
|
|
*
|
|
|
|
* Update GTXFIFOSIZn
|
|
|
|
*
|
|
|
|
* In both cases reset values should be sufficient.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dwc3_gadget_wakeup_interrupt(struct dwc3 *dwc)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* TODO take core out of low power mode when that's
|
|
|
|
* implemented.
|
|
|
|
*/
|
|
|
|
|
2014-12-11 13:26:29 +08:00
|
|
|
if (dwc->gadget_driver && dwc->gadget_driver->resume) {
|
|
|
|
spin_unlock(&dwc->lock);
|
|
|
|
dwc->gadget_driver->resume(&dwc->gadget);
|
|
|
|
spin_lock(&dwc->lock);
|
|
|
|
}
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void dwc3_gadget_linksts_change_interrupt(struct dwc3 *dwc,
|
|
|
|
unsigned int evtinfo)
|
|
|
|
{
|
2011-10-14 18:00:30 +08:00
|
|
|
enum dwc3_link_state next = evtinfo & DWC3_LINK_STATE_MASK;
|
2012-09-19 02:39:24 +08:00
|
|
|
unsigned int pwropt;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* WORKAROUND: DWC3 < 2.50a have an issue when configured without
|
|
|
|
* Hibernation mode enabled which would show up when device detects
|
|
|
|
* host-initiated U3 exit.
|
|
|
|
*
|
|
|
|
* In that case, device will generate a Link State Change Interrupt
|
|
|
|
* from U3 to RESUME which is only necessary if Hibernation is
|
|
|
|
* configured in.
|
|
|
|
*
|
|
|
|
* There are no functional changes due to such spurious event and we
|
|
|
|
* just need to ignore it.
|
|
|
|
*
|
|
|
|
* Refers to:
|
|
|
|
*
|
|
|
|
* STAR#9000570034 RTL: SS Resume event generated in non-Hibernation
|
|
|
|
* operational mode
|
|
|
|
*/
|
|
|
|
pwropt = DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1);
|
|
|
|
if ((dwc->revision < DWC3_REVISION_250A) &&
|
|
|
|
(pwropt != DWC3_GHWPARAMS1_EN_PWROPT_HIB)) {
|
|
|
|
if ((dwc->link_state == DWC3_LINK_STATE_U3) &&
|
|
|
|
(next == DWC3_LINK_STATE_RESUME)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2011-10-14 18:00:30 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* WORKAROUND: DWC3 Revisions <1.83a have an issue which, depending
|
|
|
|
* on the link partner, the USB session might do multiple entry/exit
|
|
|
|
* of low power states before a transfer takes place.
|
|
|
|
*
|
|
|
|
* Due to this problem, we might experience lower throughput. The
|
|
|
|
* suggested workaround is to disable DCTL[12:9] bits if we're
|
|
|
|
* transitioning from U1/U2 to U0 and enable those bits again
|
|
|
|
* after a transfer completes and there are no pending transfers
|
|
|
|
* on any of the enabled endpoints.
|
|
|
|
*
|
|
|
|
* This is the first half of that workaround.
|
|
|
|
*
|
|
|
|
* Refers to:
|
|
|
|
*
|
|
|
|
* STAR#9000446952: RTL: Device SS : if U1/U2 ->U0 takes >128us
|
|
|
|
* core send LGO_Ux entering U0
|
|
|
|
*/
|
|
|
|
if (dwc->revision < DWC3_REVISION_183A) {
|
|
|
|
if (next == DWC3_LINK_STATE_U0) {
|
|
|
|
u32 u1u2;
|
|
|
|
u32 reg;
|
|
|
|
|
|
|
|
switch (dwc->link_state) {
|
|
|
|
case DWC3_LINK_STATE_U1:
|
|
|
|
case DWC3_LINK_STATE_U2:
|
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
|
|
|
|
u1u2 = reg & (DWC3_DCTL_INITU2ENA
|
|
|
|
| DWC3_DCTL_ACCEPTU2ENA
|
|
|
|
| DWC3_DCTL_INITU1ENA
|
|
|
|
| DWC3_DCTL_ACCEPTU1ENA);
|
|
|
|
|
|
|
|
if (!dwc->u1u2)
|
|
|
|
dwc->u1u2 = reg & u1u2;
|
|
|
|
|
|
|
|
reg &= ~u1u2;
|
|
|
|
|
|
|
|
dwc3_writel(dwc->regs, DWC3_DCTL, reg);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* do nothing */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-27 00:17:07 +08:00
|
|
|
switch (next) {
|
|
|
|
case DWC3_LINK_STATE_U1:
|
|
|
|
if (dwc->speed == USB_SPEED_SUPER)
|
|
|
|
dwc3_suspend_gadget(dwc);
|
|
|
|
break;
|
|
|
|
case DWC3_LINK_STATE_U2:
|
|
|
|
case DWC3_LINK_STATE_U3:
|
|
|
|
dwc3_suspend_gadget(dwc);
|
|
|
|
break;
|
|
|
|
case DWC3_LINK_STATE_RESUME:
|
|
|
|
dwc3_resume_gadget(dwc);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* do nothing */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-04-23 02:20:12 +08:00
|
|
|
dwc->link_state = next;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
|
2016-05-16 16:43:53 +08:00
|
|
|
static void dwc3_gadget_suspend_interrupt(struct dwc3 *dwc,
|
|
|
|
unsigned int evtinfo)
|
|
|
|
{
|
|
|
|
enum dwc3_link_state next = evtinfo & DWC3_LINK_STATE_MASK;
|
|
|
|
|
|
|
|
if (dwc->link_state != next && next == DWC3_LINK_STATE_U3)
|
|
|
|
dwc3_suspend_gadget(dwc);
|
|
|
|
|
|
|
|
dwc->link_state = next;
|
|
|
|
}
|
|
|
|
|
2014-02-26 04:47:54 +08:00
|
|
|
static void dwc3_gadget_hibernation_interrupt(struct dwc3 *dwc,
|
|
|
|
unsigned int evtinfo)
|
|
|
|
{
|
|
|
|
unsigned int is_ss = evtinfo & BIT(4);
|
|
|
|
|
2017-04-19 19:59:27 +08:00
|
|
|
/*
|
2014-02-26 04:47:54 +08:00
|
|
|
* WORKAROUND: DWC3 revison 2.20a with hibernation support
|
|
|
|
* have a known issue which can cause USB CV TD.9.23 to fail
|
|
|
|
* randomly.
|
|
|
|
*
|
|
|
|
* Because of this issue, core could generate bogus hibernation
|
|
|
|
* events which SW needs to ignore.
|
|
|
|
*
|
|
|
|
* Refers to:
|
|
|
|
*
|
|
|
|
* STAR#9000546576: Device Mode Hibernation: Issue in USB 2.0
|
|
|
|
* Device Fallback from SuperSpeed
|
|
|
|
*/
|
|
|
|
if (is_ss ^ (dwc->speed == USB_SPEED_SUPER))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* enter hibernation here */
|
|
|
|
}
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
static void dwc3_gadget_interrupt(struct dwc3 *dwc,
|
|
|
|
const struct dwc3_event_devt *event)
|
|
|
|
{
|
|
|
|
switch (event->type) {
|
|
|
|
case DWC3_DEVICE_EVENT_DISCONNECT:
|
|
|
|
dwc3_gadget_disconnect_interrupt(dwc);
|
|
|
|
break;
|
|
|
|
case DWC3_DEVICE_EVENT_RESET:
|
|
|
|
dwc3_gadget_reset_interrupt(dwc);
|
|
|
|
break;
|
|
|
|
case DWC3_DEVICE_EVENT_CONNECT_DONE:
|
|
|
|
dwc3_gadget_conndone_interrupt(dwc);
|
|
|
|
break;
|
|
|
|
case DWC3_DEVICE_EVENT_WAKEUP:
|
|
|
|
dwc3_gadget_wakeup_interrupt(dwc);
|
|
|
|
break;
|
2014-02-26 04:47:54 +08:00
|
|
|
case DWC3_DEVICE_EVENT_HIBER_REQ:
|
|
|
|
if (dev_WARN_ONCE(dwc->dev, !dwc->has_hibernation,
|
|
|
|
"unexpected hibernation event\n"))
|
|
|
|
break;
|
|
|
|
|
|
|
|
dwc3_gadget_hibernation_interrupt(dwc, event->event_info);
|
|
|
|
break;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
case DWC3_DEVICE_EVENT_LINK_STATUS_CHANGE:
|
|
|
|
dwc3_gadget_linksts_change_interrupt(dwc, event->event_info);
|
|
|
|
break;
|
|
|
|
case DWC3_DEVICE_EVENT_EOPF:
|
2016-05-16 16:43:53 +08:00
|
|
|
/* It changed to be suspend event for version 2.30a and above */
|
2016-11-03 20:07:51 +08:00
|
|
|
if (dwc->revision >= DWC3_REVISION_230A) {
|
2016-05-16 16:43:53 +08:00
|
|
|
/*
|
|
|
|
* Ignore suspend event until the gadget enters into
|
|
|
|
* USB_STATE_CONFIGURED state.
|
|
|
|
*/
|
|
|
|
if (dwc->gadget.state >= USB_STATE_CONFIGURED)
|
|
|
|
dwc3_gadget_suspend_interrupt(dwc,
|
|
|
|
event->event_info);
|
|
|
|
}
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
break;
|
|
|
|
case DWC3_DEVICE_EVENT_SOF:
|
|
|
|
case DWC3_DEVICE_EVENT_ERRATIC_ERROR:
|
|
|
|
case DWC3_DEVICE_EVENT_CMD_CMPL:
|
|
|
|
case DWC3_DEVICE_EVENT_OVERFLOW:
|
|
|
|
break;
|
|
|
|
default:
|
2015-01-28 03:49:28 +08:00
|
|
|
dev_WARN(dwc->dev, "UNKNOWN IRQ %d\n", event->type);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dwc3_process_event_entry(struct dwc3 *dwc,
|
|
|
|
const union dwc3_event *event)
|
|
|
|
{
|
2016-09-26 18:23:34 +08:00
|
|
|
trace_dwc3_event(event->raw, dwc);
|
2014-05-01 06:45:10 +08:00
|
|
|
|
2017-04-26 18:44:51 +08:00
|
|
|
if (!event->type.is_devspec)
|
|
|
|
dwc3_endpoint_interrupt(dwc, &event->depevt);
|
|
|
|
else if (event->type.type == DWC3_EVENT_TYPE_DEV)
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
dwc3_gadget_interrupt(dwc, &event->devt);
|
2017-04-26 18:44:51 +08:00
|
|
|
else
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
dev_err(dwc->dev, "UNKNOWN IRQ type %d\n", event->raw);
|
|
|
|
}
|
|
|
|
|
2016-03-30 14:39:34 +08:00
|
|
|
static irqreturn_t dwc3_process_event_buf(struct dwc3_event_buffer *evt)
|
2011-06-30 21:57:15 +08:00
|
|
|
{
|
2016-03-30 14:39:34 +08:00
|
|
|
struct dwc3 *dwc = evt->dwc;
|
2011-06-30 21:57:15 +08:00
|
|
|
irqreturn_t ret = IRQ_NONE;
|
2013-06-13 02:25:08 +08:00
|
|
|
int left;
|
2013-06-13 02:11:14 +08:00
|
|
|
u32 reg;
|
2011-06-30 21:57:15 +08:00
|
|
|
|
2013-06-13 02:25:08 +08:00
|
|
|
left = evt->count;
|
2011-06-30 21:57:15 +08:00
|
|
|
|
2013-06-13 02:25:08 +08:00
|
|
|
if (!(evt->flags & DWC3_EVENT_PENDING))
|
|
|
|
return IRQ_NONE;
|
2011-06-30 21:57:15 +08:00
|
|
|
|
2013-06-13 02:25:08 +08:00
|
|
|
while (left > 0) {
|
|
|
|
union dwc3_event event;
|
2011-06-30 21:57:15 +08:00
|
|
|
|
2016-11-15 19:07:02 +08:00
|
|
|
event.raw = *(u32 *) (evt->cache + evt->lpos);
|
2011-06-30 21:57:15 +08:00
|
|
|
|
2013-06-13 02:25:08 +08:00
|
|
|
dwc3_process_event_entry(dwc, &event);
|
2011-06-30 21:57:15 +08:00
|
|
|
|
2013-06-13 02:25:08 +08:00
|
|
|
/*
|
|
|
|
* FIXME we wrap around correctly to the next entry as
|
|
|
|
* almost all entries are 4 bytes in size. There is one
|
|
|
|
* entry which has 12 bytes which is a regular entry
|
|
|
|
* followed by 8 bytes data. ATM I don't know how
|
|
|
|
* things are organized if we get next to the a
|
|
|
|
* boundary so I worry about that once we try to handle
|
|
|
|
* that.
|
|
|
|
*/
|
2016-11-15 19:05:23 +08:00
|
|
|
evt->lpos = (evt->lpos + 4) % evt->length;
|
2013-06-13 02:25:08 +08:00
|
|
|
left -= 4;
|
|
|
|
}
|
2011-06-30 21:57:15 +08:00
|
|
|
|
2013-06-13 02:25:08 +08:00
|
|
|
evt->count = 0;
|
|
|
|
evt->flags &= ~DWC3_EVENT_PENDING;
|
|
|
|
ret = IRQ_HANDLED;
|
2011-06-30 21:57:15 +08:00
|
|
|
|
2013-06-13 02:25:08 +08:00
|
|
|
/* Unmask interrupt */
|
2016-03-30 14:26:24 +08:00
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_GEVNTSIZ(0));
|
2013-06-13 02:25:08 +08:00
|
|
|
reg &= ~DWC3_GEVNTSIZ_INTMASK;
|
2016-03-30 14:26:24 +08:00
|
|
|
dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), reg);
|
2011-06-30 21:57:15 +08:00
|
|
|
|
2016-11-15 04:32:43 +08:00
|
|
|
if (dwc->imod_interval) {
|
|
|
|
dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), DWC3_GEVNTCOUNT_EHB);
|
|
|
|
dwc3_writel(dwc->regs, DWC3_DEV_IMOD(0), dwc->imod_interval);
|
|
|
|
}
|
|
|
|
|
2013-06-13 02:25:08 +08:00
|
|
|
return ret;
|
|
|
|
}
|
2013-06-13 02:11:14 +08:00
|
|
|
|
2016-03-30 14:39:34 +08:00
|
|
|
static irqreturn_t dwc3_thread_interrupt(int irq, void *_evt)
|
2013-06-13 02:25:08 +08:00
|
|
|
{
|
2016-03-30 14:39:34 +08:00
|
|
|
struct dwc3_event_buffer *evt = _evt;
|
|
|
|
struct dwc3 *dwc = evt->dwc;
|
2015-10-13 02:25:44 +08:00
|
|
|
unsigned long flags;
|
2013-06-13 02:25:08 +08:00
|
|
|
irqreturn_t ret = IRQ_NONE;
|
|
|
|
|
2015-10-13 02:25:44 +08:00
|
|
|
spin_lock_irqsave(&dwc->lock, flags);
|
2016-03-30 14:39:34 +08:00
|
|
|
ret = dwc3_process_event_buf(evt);
|
2015-10-13 02:25:44 +08:00
|
|
|
spin_unlock_irqrestore(&dwc->lock, flags);
|
2011-06-30 21:57:15 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-03-30 14:39:34 +08:00
|
|
|
static irqreturn_t dwc3_check_event_buf(struct dwc3_event_buffer *evt)
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
{
|
2016-03-30 14:39:34 +08:00
|
|
|
struct dwc3 *dwc = evt->dwc;
|
2016-11-15 19:07:02 +08:00
|
|
|
u32 amount;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
u32 count;
|
2013-06-13 02:11:14 +08:00
|
|
|
u32 reg;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2016-05-16 18:14:48 +08:00
|
|
|
if (pm_runtime_suspended(dwc->dev)) {
|
|
|
|
pm_runtime_get(dwc->dev);
|
|
|
|
disable_irq_nosync(dwc->irq_gadget);
|
|
|
|
dwc->pending_events = true;
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
2017-05-12 08:26:47 +08:00
|
|
|
/*
|
|
|
|
* With PCIe legacy interrupt, test shows that top-half irq handler can
|
|
|
|
* be called again after HW interrupt deassertion. Check if bottom-half
|
|
|
|
* irq event handler completes before caching new event to prevent
|
|
|
|
* losing events.
|
|
|
|
*/
|
|
|
|
if (evt->flags & DWC3_EVENT_PENDING)
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
|
2016-03-30 14:26:24 +08:00
|
|
|
count = dwc3_readl(dwc->regs, DWC3_GEVNTCOUNT(0));
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
count &= DWC3_GEVNTCOUNT_MASK;
|
|
|
|
if (!count)
|
|
|
|
return IRQ_NONE;
|
|
|
|
|
2011-06-30 21:57:15 +08:00
|
|
|
evt->count = count;
|
|
|
|
evt->flags |= DWC3_EVENT_PENDING;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2013-06-13 02:11:14 +08:00
|
|
|
/* Mask interrupt */
|
2016-03-30 14:26:24 +08:00
|
|
|
reg = dwc3_readl(dwc->regs, DWC3_GEVNTSIZ(0));
|
2013-06-13 02:11:14 +08:00
|
|
|
reg |= DWC3_GEVNTSIZ_INTMASK;
|
2016-03-30 14:26:24 +08:00
|
|
|
dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), reg);
|
2013-06-13 02:11:14 +08:00
|
|
|
|
2016-11-15 19:07:02 +08:00
|
|
|
amount = min(count, evt->length - evt->lpos);
|
|
|
|
memcpy(evt->cache + evt->lpos, evt->buf + evt->lpos, amount);
|
|
|
|
|
|
|
|
if (amount < count)
|
|
|
|
memcpy(evt->cache, evt->buf, count - amount);
|
|
|
|
|
2016-11-15 19:08:59 +08:00
|
|
|
dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), count);
|
|
|
|
|
2011-06-30 21:57:15 +08:00
|
|
|
return IRQ_WAKE_THREAD;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
|
2016-03-30 14:39:34 +08:00
|
|
|
static irqreturn_t dwc3_interrupt(int irq, void *_evt)
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
{
|
2016-03-30 14:39:34 +08:00
|
|
|
struct dwc3_event_buffer *evt = _evt;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2016-03-30 14:39:34 +08:00
|
|
|
return dwc3_check_event_buf(evt);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
|
2016-10-03 16:27:01 +08:00
|
|
|
static int dwc3_gadget_get_irq(struct dwc3 *dwc)
|
|
|
|
{
|
|
|
|
struct platform_device *dwc3_pdev = to_platform_device(dwc->dev);
|
|
|
|
int irq;
|
|
|
|
|
|
|
|
irq = platform_get_irq_byname(dwc3_pdev, "peripheral");
|
|
|
|
if (irq > 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (irq == -EPROBE_DEFER)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
irq = platform_get_irq_byname(dwc3_pdev, "dwc_usb3");
|
|
|
|
if (irq > 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (irq == -EPROBE_DEFER)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
irq = platform_get_irq(dwc3_pdev, 0);
|
|
|
|
if (irq > 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (irq != -EPROBE_DEFER)
|
|
|
|
dev_err(dwc->dev, "missing peripheral IRQ\n");
|
|
|
|
|
|
|
|
if (!irq)
|
|
|
|
irq = -EINVAL;
|
|
|
|
|
|
|
|
out:
|
|
|
|
return irq;
|
|
|
|
}
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
/**
|
2017-04-19 19:59:27 +08:00
|
|
|
* dwc3_gadget_init - initializes gadget related registers
|
2012-02-16 10:56:56 +08:00
|
|
|
* @dwc: pointer to our controller context structure
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
*
|
|
|
|
* Returns 0 on success otherwise negative errno.
|
|
|
|
*/
|
2012-11-20 02:21:48 +08:00
|
|
|
int dwc3_gadget_init(struct dwc3 *dwc)
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
{
|
2016-10-03 16:27:01 +08:00
|
|
|
int ret;
|
|
|
|
int irq;
|
2016-06-10 19:48:38 +08:00
|
|
|
|
2016-10-03 16:27:01 +08:00
|
|
|
irq = dwc3_gadget_get_irq(dwc);
|
|
|
|
if (irq < 0) {
|
|
|
|
ret = irq;
|
|
|
|
goto err0;
|
2016-06-10 19:48:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
dwc->irq_gadget = irq;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2016-11-17 19:43:47 +08:00
|
|
|
dwc->ep0_trb = dma_alloc_coherent(dwc->sysdev,
|
|
|
|
sizeof(*dwc->ep0_trb) * 2,
|
|
|
|
&dwc->ep0_trb_addr, GFP_KERNEL);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
if (!dwc->ep0_trb) {
|
|
|
|
dev_err(dwc->dev, "failed to allocate ep0 trb\n");
|
|
|
|
ret = -ENOMEM;
|
2017-04-07 18:34:21 +08:00
|
|
|
goto err0;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
|
2017-04-07 19:09:13 +08:00
|
|
|
dwc->setup_buf = kzalloc(DWC3_EP0_SETUP_SIZE, GFP_KERNEL);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
if (!dwc->setup_buf) {
|
|
|
|
ret = -ENOMEM;
|
2017-04-07 18:34:21 +08:00
|
|
|
goto err1;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
|
2017-01-05 20:46:52 +08:00
|
|
|
dwc->bounce = dma_alloc_coherent(dwc->sysdev, DWC3_BOUNCE_SIZE,
|
|
|
|
&dwc->bounce_addr, GFP_KERNEL);
|
|
|
|
if (!dwc->bounce) {
|
|
|
|
ret = -ENOMEM;
|
2017-04-07 21:34:38 +08:00
|
|
|
goto err2;
|
2017-01-05 20:46:52 +08:00
|
|
|
}
|
|
|
|
|
2016-10-14 17:11:33 +08:00
|
|
|
init_completion(&dwc->ep0_in_setup);
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
dwc->gadget.ops = &dwc3_gadget_ops;
|
|
|
|
dwc->gadget.speed = USB_SPEED_UNKNOWN;
|
2011-11-28 18:46:59 +08:00
|
|
|
dwc->gadget.sg_supported = true;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
dwc->gadget.name = "dwc3-gadget";
|
2019-04-26 05:28:24 +08:00
|
|
|
dwc->gadget.lpm_capable = true;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2015-11-17 00:47:24 +08:00
|
|
|
/*
|
|
|
|
* FIXME We might be setting max_speed to <SUPER, however versions
|
|
|
|
* <2.20a of dwc3 have an issue with metastability (documented
|
|
|
|
* elsewhere in this driver) which tells us we can't set max speed to
|
|
|
|
* anything lower than SUPER.
|
|
|
|
*
|
|
|
|
* Because gadget.max_speed is only used by composite.c and function
|
|
|
|
* drivers (i.e. it won't go into dwc3's registers) we are allowing this
|
|
|
|
* to happen so we avoid sending SuperSpeed Capability descriptor
|
|
|
|
* together with our BOS descriptor as that could confuse host into
|
|
|
|
* thinking we can handle super speed.
|
|
|
|
*
|
|
|
|
* Note that, in fact, we won't even support GetBOS requests when speed
|
|
|
|
* is less than super speed because we don't have means, yet, to tell
|
|
|
|
* composite.c that we are USB 2.0 + LPM ECN.
|
|
|
|
*/
|
2017-10-31 21:11:55 +08:00
|
|
|
if (dwc->revision < DWC3_REVISION_220A &&
|
|
|
|
!dwc->dis_metastability_quirk)
|
2016-11-03 20:07:51 +08:00
|
|
|
dev_info(dwc->dev, "changing max_speed on rev %08x\n",
|
2015-11-17 00:47:24 +08:00
|
|
|
dwc->revision);
|
|
|
|
|
|
|
|
dwc->gadget.max_speed = dwc->maximum_speed;
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
/*
|
|
|
|
* REVISIT: Here we should clear all pending IRQs to be
|
|
|
|
* sure we're starting from a well known location.
|
|
|
|
*/
|
|
|
|
|
2017-02-01 04:58:11 +08:00
|
|
|
ret = dwc3_gadget_init_endpoints(dwc, dwc->num_eps);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
if (ret)
|
2017-04-07 21:34:38 +08:00
|
|
|
goto err3;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
|
|
|
ret = usb_add_gadget_udc(dwc->dev, &dwc->gadget);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(dwc->dev, "failed to register udc\n");
|
2017-04-07 21:34:38 +08:00
|
|
|
goto err4;
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
|
|
|
|
2019-01-10 23:04:28 +08:00
|
|
|
dwc3_gadget_set_speed(&dwc->gadget, dwc->maximum_speed);
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
return 0;
|
|
|
|
|
2017-04-07 18:34:21 +08:00
|
|
|
err4:
|
2017-04-07 21:34:38 +08:00
|
|
|
dwc3_gadget_free_endpoints(dwc);
|
2015-12-03 00:06:45 +08:00
|
|
|
|
2017-04-07 18:34:21 +08:00
|
|
|
err3:
|
2017-04-07 21:34:38 +08:00
|
|
|
dma_free_coherent(dwc->sysdev, DWC3_BOUNCE_SIZE, dwc->bounce,
|
|
|
|
dwc->bounce_addr);
|
2011-08-28 03:07:53 +08:00
|
|
|
|
2017-04-07 18:34:21 +08:00
|
|
|
err2:
|
2011-12-19 17:32:34 +08:00
|
|
|
kfree(dwc->setup_buf);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
|
2017-04-07 18:34:21 +08:00
|
|
|
err1:
|
2016-11-17 19:43:47 +08:00
|
|
|
dma_free_coherent(dwc->sysdev, sizeof(*dwc->ep0_trb) * 2,
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
dwc->ep0_trb, dwc->ep0_trb_addr);
|
|
|
|
|
|
|
|
err0:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-04-30 19:56:33 +08:00
|
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
void dwc3_gadget_exit(struct dwc3 *dwc)
|
|
|
|
{
|
|
|
|
usb_del_gadget_udc(&dwc->gadget);
|
|
|
|
dwc3_gadget_free_endpoints(dwc);
|
2017-01-05 20:46:52 +08:00
|
|
|
dma_free_coherent(dwc->sysdev, DWC3_BOUNCE_SIZE, dwc->bounce,
|
2017-04-07 21:34:38 +08:00
|
|
|
dwc->bounce_addr);
|
2011-12-19 17:32:34 +08:00
|
|
|
kfree(dwc->setup_buf);
|
2016-11-17 19:43:47 +08:00
|
|
|
dma_free_coherent(dwc->sysdev, sizeof(*dwc->ep0_trb) * 2,
|
2017-04-07 21:34:38 +08:00
|
|
|
dwc->ep0_trb, dwc->ep0_trb_addr);
|
usb: Introduce DesignWare USB3 DRD Driver
The DesignWare USB3 is a highly
configurable IP Core which can be
instantiated as Dual-Role Device (DRD),
Peripheral Only and Host Only (XHCI)
configurations.
Several other parameters can be configured
like amount of FIFO space, amount of TX and
RX endpoints, amount of Host Interrupters,
etc.
The current driver has been validated with
a virtual model of version 1.73a of that core
and with an FPGA burned with version 1.83a
of the DRD core. We have support for PCIe
bus, which is used on FPGA prototyping, and
for the OMAP5, more adaptation (or glue)
layers can be easily added and the driver
is half prepared to handle any possible
configuration the HW engineer has chosen
considering we have the information on
one of the GHWPARAMS registers to do
runtime checking of certain features.
More runtime checks can, and should, be added
in order to make this driver even more flexible
with regards to number of endpoints, FIFO sizes,
transfer types, etc.
While this supports only the device side, for
now, we will add support for Host side (xHCI -
see the updated series Sebastian has sent [1])
and OTG after we have it all stabilized.
[1] http://marc.info/?l=linux-usb&m=131341992020339&w=2
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-19 23:10:58 +08:00
|
|
|
}
|
2012-04-30 19:56:33 +08:00
|
|
|
|
2014-10-07 23:19:23 +08:00
|
|
|
int dwc3_gadget_suspend(struct dwc3 *dwc)
|
2012-04-30 19:56:33 +08:00
|
|
|
{
|
2016-04-12 16:33:29 +08:00
|
|
|
if (!dwc->gadget_driver)
|
|
|
|
return 0;
|
|
|
|
|
2017-02-15 20:16:26 +08:00
|
|
|
dwc3_gadget_run_stop(dwc, false, false);
|
2016-05-04 20:50:27 +08:00
|
|
|
dwc3_disconnect_gadget(dwc);
|
|
|
|
__dwc3_gadget_stop(dwc);
|
2012-04-30 19:56:33 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int dwc3_gadget_resume(struct dwc3 *dwc)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2016-04-12 16:33:29 +08:00
|
|
|
if (!dwc->gadget_driver)
|
|
|
|
return 0;
|
|
|
|
|
2016-05-04 20:50:27 +08:00
|
|
|
ret = __dwc3_gadget_start(dwc);
|
|
|
|
if (ret < 0)
|
2012-04-30 19:56:33 +08:00
|
|
|
goto err0;
|
|
|
|
|
2016-05-04 20:50:27 +08:00
|
|
|
ret = dwc3_gadget_run_stop(dwc, true, false);
|
|
|
|
if (ret < 0)
|
2012-04-30 19:56:33 +08:00
|
|
|
goto err1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err1:
|
2016-05-04 20:50:27 +08:00
|
|
|
__dwc3_gadget_stop(dwc);
|
2012-04-30 19:56:33 +08:00
|
|
|
|
|
|
|
err0:
|
|
|
|
return ret;
|
|
|
|
}
|
2016-05-16 18:14:48 +08:00
|
|
|
|
|
|
|
void dwc3_gadget_process_pending_events(struct dwc3 *dwc)
|
|
|
|
{
|
|
|
|
if (dwc->pending_events) {
|
|
|
|
dwc3_interrupt(dwc->irq_gadget, dwc->ev_buf);
|
|
|
|
dwc->pending_events = false;
|
|
|
|
enable_irq(dwc->irq_gadget);
|
|
|
|
}
|
|
|
|
}
|