mirror of
https://github.com/LuckfoxTECH/luckfox-pico.git
synced 2026-01-19 09:52:31 +01:00
project:build.sh: Added fastboot support; custom modifications to U-Boot and kernel implemented using patches.
project:cfg:BoardConfig_IPC: Added fastboot BoardConfig file and firmware post-scripts, distinguishing between the BoardConfigs for Luckfox Pico Pro and Luckfox Pico Max. project:app: Added fastboot_client and rk_smart_door for quick boot applications; updated rkipc app to adapt to the latest media library. media:samples: Added more usage examples. media:rockit: Fixed bugs; removed support for retrieving data frames from VPSS. media:isp: Updated rkaiq library and related tools to support connection to RKISP_Tuner. sysdrv:Makefile: Added support for compiling drv_ko on Luckfox Pico Ultra W using Ubuntu; added support for custom root filesystem. sysdrv:tools:board: Updated Buildroot optional mirror sources, updated some software versions, and stored device tree files and configuration files that undergo multiple modifications for U-Boot and kernel separately. sysdrv:source:mcu: Used RISC-V MCU SDK with RT-Thread system, mainly for initializing camera AE during quick boot. sysdrv:source:uboot: Added support for fastboot; added high baud rate DDR bin for serial firmware upgrades. sysdrv:source:kernel: Upgraded to version 5.10.160; increased NPU frequency for RV1106G3; added support for fastboot. Signed-off-by: luckfox-eng29 <eng29@luckfox.com>
This commit is contained in:
@@ -97,13 +97,23 @@ static int cdns3_core_init_role(struct cdns3 *cdns)
|
||||
* can be restricted later depending on strap pin configuration.
|
||||
*/
|
||||
if (dr_mode == USB_DR_MODE_UNKNOWN) {
|
||||
if (IS_ENABLED(CONFIG_USB_CDNS3_HOST) &&
|
||||
IS_ENABLED(CONFIG_USB_CDNS3_GADGET))
|
||||
dr_mode = USB_DR_MODE_OTG;
|
||||
else if (IS_ENABLED(CONFIG_USB_CDNS3_HOST))
|
||||
dr_mode = USB_DR_MODE_HOST;
|
||||
else if (IS_ENABLED(CONFIG_USB_CDNS3_GADGET))
|
||||
dr_mode = USB_DR_MODE_PERIPHERAL;
|
||||
if (cdns->version == CDNSP_CONTROLLER_V2) {
|
||||
if (IS_ENABLED(CONFIG_USB_CDNSP_HOST) &&
|
||||
IS_ENABLED(CONFIG_USB_CDNSP_GADGET))
|
||||
dr_mode = USB_DR_MODE_OTG;
|
||||
else if (IS_ENABLED(CONFIG_USB_CDNSP_HOST))
|
||||
dr_mode = USB_DR_MODE_HOST;
|
||||
else if (IS_ENABLED(CONFIG_USB_CDNSP_GADGET))
|
||||
dr_mode = USB_DR_MODE_PERIPHERAL;
|
||||
} else {
|
||||
if (IS_ENABLED(CONFIG_USB_CDNS3_HOST) &&
|
||||
IS_ENABLED(CONFIG_USB_CDNS3_GADGET))
|
||||
dr_mode = USB_DR_MODE_OTG;
|
||||
else if (IS_ENABLED(CONFIG_USB_CDNS3_HOST))
|
||||
dr_mode = USB_DR_MODE_HOST;
|
||||
else if (IS_ENABLED(CONFIG_USB_CDNS3_GADGET))
|
||||
dr_mode = USB_DR_MODE_PERIPHERAL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -55,7 +55,9 @@ struct cdns3_platform_data {
|
||||
* @otg_res: the resource for otg
|
||||
* @otg_v0_regs: pointer to base of v0 otg registers
|
||||
* @otg_v1_regs: pointer to base of v1 otg registers
|
||||
* @otg_cdnsp_regs: pointer to base of CDNSP otg registers
|
||||
* @otg_regs: pointer to base of otg registers
|
||||
* @otg_irq_regs: pointer to interrupt registers
|
||||
* @otg_irq: irq number for otg controller
|
||||
* @dev_irq: irq number for device controller
|
||||
* @wakeup_irq: irq number for wakeup event, it is optional
|
||||
@@ -86,9 +88,12 @@ struct cdns3 {
|
||||
struct resource otg_res;
|
||||
struct cdns3_otg_legacy_regs *otg_v0_regs;
|
||||
struct cdns3_otg_regs *otg_v1_regs;
|
||||
struct cdnsp_otg_regs *otg_cdnsp_regs;
|
||||
struct cdns3_otg_common_regs *otg_regs;
|
||||
struct cdns3_otg_irq_regs *otg_irq_regs;
|
||||
#define CDNS3_CONTROLLER_V0 0
|
||||
#define CDNS3_CONTROLLER_V1 1
|
||||
#define CDNSP_CONTROLLER_V2 2
|
||||
u32 version;
|
||||
bool phyrst_a_enable;
|
||||
|
||||
|
||||
@@ -2,13 +2,12 @@
|
||||
/*
|
||||
* Cadence USBSS DRD Driver.
|
||||
*
|
||||
* Copyright (C) 2018-2019 Cadence.
|
||||
* Copyright (C) 2018-2020 Cadence.
|
||||
* Copyright (C) 2019 Texas Instruments
|
||||
*
|
||||
* Author: Pawel Laszczak <pawell@cadence.com>
|
||||
* Roger Quadros <rogerq@ti.com>
|
||||
*
|
||||
*
|
||||
*/
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/interrupt.h>
|
||||
@@ -28,8 +27,9 @@
|
||||
*
|
||||
* Returns 0 on success otherwise negative errno
|
||||
*/
|
||||
int cdns3_set_mode(struct cdns3 *cdns, enum usb_dr_mode mode)
|
||||
static int cdns3_set_mode(struct cdns3 *cdns, enum usb_dr_mode mode)
|
||||
{
|
||||
u32 __iomem *override_reg;
|
||||
u32 reg;
|
||||
|
||||
switch (mode) {
|
||||
@@ -39,11 +39,24 @@ int cdns3_set_mode(struct cdns3 *cdns, enum usb_dr_mode mode)
|
||||
break;
|
||||
case USB_DR_MODE_OTG:
|
||||
dev_dbg(cdns->dev, "Set controller to OTG mode\n");
|
||||
if (cdns->version == CDNS3_CONTROLLER_V1) {
|
||||
reg = readl(&cdns->otg_v1_regs->override);
|
||||
reg |= OVERRIDE_IDPULLUP;
|
||||
writel(reg, &cdns->otg_v1_regs->override);
|
||||
|
||||
if (cdns->version == CDNSP_CONTROLLER_V2)
|
||||
override_reg = &cdns->otg_cdnsp_regs->override;
|
||||
else if (cdns->version == CDNS3_CONTROLLER_V1)
|
||||
override_reg = &cdns->otg_v1_regs->override;
|
||||
else
|
||||
override_reg = &cdns->otg_v0_regs->ctrl1;
|
||||
|
||||
reg = readl(override_reg);
|
||||
|
||||
if (cdns->version != CDNS3_CONTROLLER_V0)
|
||||
reg |= OVERRIDE_IDPULLUP;
|
||||
else
|
||||
reg |= OVERRIDE_IDPULLUP_V0;
|
||||
|
||||
writel(reg, override_reg);
|
||||
|
||||
if (cdns->version == CDNS3_CONTROLLER_V1) {
|
||||
/*
|
||||
* Enable work around feature built into the
|
||||
* controller to address issue with RX Sensitivity
|
||||
@@ -55,10 +68,6 @@ int cdns3_set_mode(struct cdns3 *cdns, enum usb_dr_mode mode)
|
||||
reg |= PHYRST_CFG_PHYRST_A_ENABLE;
|
||||
writel(reg, &cdns->otg_v1_regs->phyrst_cfg);
|
||||
}
|
||||
} else {
|
||||
reg = readl(&cdns->otg_v0_regs->ctrl1);
|
||||
reg |= OVERRIDE_IDPULLUP_V0;
|
||||
writel(reg, &cdns->otg_v0_regs->ctrl1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -123,7 +132,7 @@ bool cdns3_is_device(struct cdns3 *cdns)
|
||||
*/
|
||||
static void cdns3_otg_disable_irq(struct cdns3 *cdns)
|
||||
{
|
||||
writel(0, &cdns->otg_regs->ien);
|
||||
writel(0, &cdns->otg_irq_regs->ien);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,7 +142,7 @@ static void cdns3_otg_disable_irq(struct cdns3 *cdns)
|
||||
static void cdns3_otg_enable_irq(struct cdns3 *cdns)
|
||||
{
|
||||
writel(OTGIEN_ID_CHANGE_INT | OTGIEN_VBUSVALID_RISE_INT |
|
||||
OTGIEN_VBUSVALID_FALL_INT, &cdns->otg_regs->ien);
|
||||
OTGIEN_VBUSVALID_FALL_INT, &cdns->otg_irq_regs->ien);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,16 +153,21 @@ static void cdns3_otg_enable_irq(struct cdns3 *cdns)
|
||||
*/
|
||||
int cdns3_drd_host_on(struct cdns3 *cdns)
|
||||
{
|
||||
u32 val;
|
||||
u32 val, ready_bit;
|
||||
int ret;
|
||||
|
||||
/* Enable host mode. */
|
||||
writel(OTGCMD_HOST_BUS_REQ | OTGCMD_OTG_DIS,
|
||||
&cdns->otg_regs->cmd);
|
||||
|
||||
if (cdns->version == CDNSP_CONTROLLER_V2)
|
||||
ready_bit = OTGSTS_CDNSP_XHCI_READY;
|
||||
else
|
||||
ready_bit = OTGSTS_CDNS3_XHCI_READY;
|
||||
|
||||
dev_dbg(cdns->dev, "Waiting till Host mode is turned on\n");
|
||||
ret = readl_poll_timeout_atomic(&cdns->otg_regs->sts, val,
|
||||
val & OTGSTS_XHCI_READY, 1, 100000);
|
||||
val & ready_bit, 1, 100000);
|
||||
|
||||
if (ret)
|
||||
dev_err(cdns->dev, "timeout waiting for xhci_ready\n");
|
||||
@@ -189,17 +203,22 @@ void cdns3_drd_host_off(struct cdns3 *cdns)
|
||||
*/
|
||||
int cdns3_drd_gadget_on(struct cdns3 *cdns)
|
||||
{
|
||||
int ret, val;
|
||||
u32 reg = OTGCMD_OTG_DIS;
|
||||
u32 ready_bit;
|
||||
int ret, val;
|
||||
|
||||
/* switch OTG core */
|
||||
writel(OTGCMD_DEV_BUS_REQ | reg, &cdns->otg_regs->cmd);
|
||||
|
||||
dev_dbg(cdns->dev, "Waiting till Device mode is turned on\n");
|
||||
|
||||
if (cdns->version == CDNSP_CONTROLLER_V2)
|
||||
ready_bit = OTGSTS_CDNSP_DEV_READY;
|
||||
else
|
||||
ready_bit = OTGSTS_CDNS3_DEV_READY;
|
||||
|
||||
ret = readl_poll_timeout_atomic(&cdns->otg_regs->sts, val,
|
||||
val & OTGSTS_DEV_READY,
|
||||
1, 100000);
|
||||
val & ready_bit, 1, 100000);
|
||||
if (ret) {
|
||||
dev_err(cdns->dev, "timeout waiting for dev_ready\n");
|
||||
return ret;
|
||||
@@ -244,7 +263,7 @@ static int cdns3_init_otg_mode(struct cdns3 *cdns)
|
||||
|
||||
cdns3_otg_disable_irq(cdns);
|
||||
/* clear all interrupts */
|
||||
writel(~0, &cdns->otg_regs->ivect);
|
||||
writel(~0, &cdns->otg_irq_regs->ivect);
|
||||
|
||||
ret = cdns3_set_mode(cdns, USB_DR_MODE_OTG);
|
||||
if (ret)
|
||||
@@ -313,7 +332,7 @@ static irqreturn_t cdns3_drd_irq(int irq, void *data)
|
||||
if (cdns->in_lpm)
|
||||
return ret;
|
||||
|
||||
reg = readl(&cdns->otg_regs->ivect);
|
||||
reg = readl(&cdns->otg_irq_regs->ivect);
|
||||
|
||||
if (!reg)
|
||||
return IRQ_NONE;
|
||||
@@ -332,7 +351,7 @@ static irqreturn_t cdns3_drd_irq(int irq, void *data)
|
||||
ret = IRQ_WAKE_THREAD;
|
||||
}
|
||||
|
||||
writel(~0, &cdns->otg_regs->ivect);
|
||||
writel(~0, &cdns->otg_irq_regs->ivect);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -347,28 +366,43 @@ int cdns3_drd_init(struct cdns3 *cdns)
|
||||
return PTR_ERR(regs);
|
||||
|
||||
/* Detection of DRD version. Controller has been released
|
||||
* in two versions. Both are similar, but they have same changes
|
||||
* in register maps.
|
||||
* The first register in old version is command register and it's read
|
||||
* only, so driver should read 0 from it. On the other hand, in v1
|
||||
* the first register contains device ID number which is not set to 0.
|
||||
* Driver uses this fact to detect the proper version of
|
||||
* in three versions. All are very similar and are software compatible,
|
||||
* but they have same changes in register maps.
|
||||
* The first register in oldest version is command register and it's
|
||||
* read only. Driver should read 0 from it. On the other hand, in v1
|
||||
* and v2 the first register contains device ID number which is not
|
||||
* set to 0. Driver uses this fact to detect the proper version of
|
||||
* controller.
|
||||
*/
|
||||
cdns->otg_v0_regs = regs;
|
||||
if (!readl(&cdns->otg_v0_regs->cmd)) {
|
||||
cdns->version = CDNS3_CONTROLLER_V0;
|
||||
cdns->otg_v1_regs = NULL;
|
||||
cdns->otg_cdnsp_regs = NULL;
|
||||
cdns->otg_regs = regs;
|
||||
cdns->otg_irq_regs = (struct cdns3_otg_irq_regs *)
|
||||
&cdns->otg_v0_regs->ien;
|
||||
writel(1, &cdns->otg_v0_regs->simulate);
|
||||
dev_dbg(cdns->dev, "DRD version v0 (%08x)\n",
|
||||
readl(&cdns->otg_v0_regs->version));
|
||||
} else {
|
||||
cdns->otg_v0_regs = NULL;
|
||||
cdns->otg_v1_regs = regs;
|
||||
cdns->otg_cdnsp_regs = regs;
|
||||
|
||||
cdns->otg_regs = (void *)&cdns->otg_v1_regs->cmd;
|
||||
cdns->version = CDNS3_CONTROLLER_V1;
|
||||
writel(1, &cdns->otg_v1_regs->simulate);
|
||||
|
||||
if (cdns->otg_cdnsp_regs->did == OTG_CDNSP_DID) {
|
||||
cdns->otg_irq_regs = (struct cdns3_otg_irq_regs *)
|
||||
&cdns->otg_cdnsp_regs->ien;
|
||||
cdns->version = CDNSP_CONTROLLER_V2;
|
||||
} else {
|
||||
cdns->otg_irq_regs = (struct cdns3_otg_irq_regs *)
|
||||
&cdns->otg_v1_regs->ien;
|
||||
writel(1, &cdns->otg_v1_regs->simulate);
|
||||
cdns->version = CDNS3_CONTROLLER_V1;
|
||||
}
|
||||
|
||||
dev_dbg(cdns->dev, "DRD version v1 (ID: %08x, rev: %08x)\n",
|
||||
readl(&cdns->otg_v1_regs->did),
|
||||
readl(&cdns->otg_v1_regs->rid));
|
||||
@@ -378,10 +412,17 @@ int cdns3_drd_init(struct cdns3 *cdns)
|
||||
|
||||
/* Update dr_mode according to STRAP configuration. */
|
||||
cdns->dr_mode = USB_DR_MODE_OTG;
|
||||
if (state == OTGSTS_STRAP_HOST) {
|
||||
|
||||
if ((cdns->version == CDNSP_CONTROLLER_V2 &&
|
||||
state == OTGSTS_CDNSP_STRAP_HOST) ||
|
||||
(cdns->version != CDNSP_CONTROLLER_V2 &&
|
||||
state == OTGSTS_STRAP_HOST)) {
|
||||
dev_dbg(cdns->dev, "Controller strapped to HOST\n");
|
||||
cdns->dr_mode = USB_DR_MODE_HOST;
|
||||
} else if (state == OTGSTS_STRAP_GADGET) {
|
||||
} else if ((cdns->version == CDNSP_CONTROLLER_V2 &&
|
||||
state == OTGSTS_CDNSP_STRAP_GADGET) ||
|
||||
(cdns->version != CDNSP_CONTROLLER_V2 &&
|
||||
state == OTGSTS_STRAP_GADGET)) {
|
||||
dev_dbg(cdns->dev, "Controller strapped to PERIPHERAL\n");
|
||||
cdns->dr_mode = USB_DR_MODE_PERIPHERAL;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Cadence USB3 DRD header file.
|
||||
* Cadence USB3 and USBSSP DRD header file.
|
||||
*
|
||||
* Copyright (C) 2018-2019 Cadence.
|
||||
* Copyright (C) 2018-2020 Cadence.
|
||||
*
|
||||
* Author: Pawel Laszczak <pawell@cadence.com>
|
||||
*/
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <linux/phy/phy.h>
|
||||
#include "core.h"
|
||||
|
||||
/* DRD register interface for version v1. */
|
||||
/* DRD register interface for version v1 of cdns3 driver. */
|
||||
struct cdns3_otg_regs {
|
||||
__le32 did;
|
||||
__le32 rid;
|
||||
@@ -38,7 +38,7 @@ struct cdns3_otg_regs {
|
||||
__le32 ctrl2;
|
||||
};
|
||||
|
||||
/* DRD register interface for version v0. */
|
||||
/* DRD register interface for version v0 of cdns3 driver. */
|
||||
struct cdns3_otg_legacy_regs {
|
||||
__le32 cmd;
|
||||
__le32 sts;
|
||||
@@ -57,14 +57,45 @@ struct cdns3_otg_legacy_regs {
|
||||
__le32 ctrl1;
|
||||
};
|
||||
|
||||
/* DRD register interface for cdnsp driver */
|
||||
struct cdnsp_otg_regs {
|
||||
__le32 did;
|
||||
__le32 rid;
|
||||
__le32 cfgs1;
|
||||
__le32 cfgs2;
|
||||
__le32 cmd;
|
||||
__le32 sts;
|
||||
__le32 state;
|
||||
__le32 ien;
|
||||
__le32 ivect;
|
||||
__le32 tmr;
|
||||
__le32 simulate;
|
||||
__le32 adpbc_sts;
|
||||
__le32 adp_ramp_time;
|
||||
__le32 adpbc_ctrl1;
|
||||
__le32 adpbc_ctrl2;
|
||||
__le32 override;
|
||||
__le32 vbusvalid_dbnc_cfg;
|
||||
__le32 sessvalid_dbnc_cfg;
|
||||
__le32 susp_timing_ctrl;
|
||||
};
|
||||
|
||||
#define OTG_CDNSP_DID 0x0004034E
|
||||
|
||||
/*
|
||||
* Common registers interface for both version of DRD.
|
||||
* Common registers interface for both CDNS3 and CDNSP version of DRD.
|
||||
*/
|
||||
struct cdns3_otg_common_regs {
|
||||
__le32 cmd;
|
||||
__le32 sts;
|
||||
__le32 state;
|
||||
__le32 different1;
|
||||
};
|
||||
|
||||
/*
|
||||
* Interrupt related registers. This registers are mapped in different
|
||||
* location for CDNSP controller.
|
||||
*/
|
||||
struct cdns3_otg_irq_regs {
|
||||
__le32 ien;
|
||||
__le32 ivect;
|
||||
};
|
||||
@@ -92,9 +123,9 @@ struct cdns3_otg_common_regs {
|
||||
#define OTGCMD_DEV_BUS_DROP BIT(8)
|
||||
/* Drop the bus for Host mode*/
|
||||
#define OTGCMD_HOST_BUS_DROP BIT(9)
|
||||
/* Power Down USBSS-DEV. */
|
||||
/* Power Down USBSS-DEV - only for CDNS3.*/
|
||||
#define OTGCMD_DEV_POWER_OFF BIT(11)
|
||||
/* Power Down CDNSXHCI. */
|
||||
/* Power Down CDNSXHCI - only for CDNS3. */
|
||||
#define OTGCMD_HOST_POWER_OFF BIT(12)
|
||||
|
||||
/* OTGIEN - bitmasks */
|
||||
@@ -123,20 +154,31 @@ struct cdns3_otg_common_regs {
|
||||
#define OTGSTS_OTG_NRDY_MASK BIT(11)
|
||||
#define OTGSTS_OTG_NRDY(p) ((p) & OTGSTS_OTG_NRDY_MASK)
|
||||
/*
|
||||
* Value of the strap pins.
|
||||
* Value of the strap pins for:
|
||||
* CDNS3:
|
||||
* 000 - no default configuration
|
||||
* 010 - Controller initiall configured as Host
|
||||
* 100 - Controller initially configured as Device
|
||||
* CDNSP:
|
||||
* 000 - No default configuration.
|
||||
* 010 - Controller initiall configured as Host.
|
||||
* 100 - Controller initially configured as Device.
|
||||
*/
|
||||
#define OTGSTS_STRAP(p) (((p) & GENMASK(14, 12)) >> 12)
|
||||
#define OTGSTS_STRAP_NO_DEFAULT_CFG 0x00
|
||||
#define OTGSTS_STRAP_HOST_OTG 0x01
|
||||
#define OTGSTS_STRAP_HOST 0x02
|
||||
#define OTGSTS_STRAP_GADGET 0x04
|
||||
#define OTGSTS_CDNSP_STRAP_HOST 0x01
|
||||
#define OTGSTS_CDNSP_STRAP_GADGET 0x02
|
||||
|
||||
/* Host mode is turned on. */
|
||||
#define OTGSTS_XHCI_READY BIT(26)
|
||||
#define OTGSTS_CDNS3_XHCI_READY BIT(26)
|
||||
#define OTGSTS_CDNSP_XHCI_READY BIT(27)
|
||||
|
||||
/* "Device mode is turned on .*/
|
||||
#define OTGSTS_DEV_READY BIT(27)
|
||||
#define OTGSTS_CDNS3_DEV_READY BIT(27)
|
||||
#define OTGSTS_CDNSP_DEV_READY BIT(26)
|
||||
|
||||
/* OTGSTATE- bitmasks */
|
||||
#define OTGSTATE_DEV_STATE_MASK GENMASK(2, 0)
|
||||
@@ -152,6 +194,8 @@ struct cdns3_otg_common_regs {
|
||||
#define OVERRIDE_IDPULLUP BIT(0)
|
||||
/* Only for CDNS3_CONTROLLER_V0 version */
|
||||
#define OVERRIDE_IDPULLUP_V0 BIT(24)
|
||||
/* Vbusvalid/Sesvalid override select. */
|
||||
#define OVERRIDE_SESS_VLD_SEL BIT(10)
|
||||
|
||||
/* PHYRST_CFG - bitmasks */
|
||||
#define PHYRST_CFG_PHYRST_A_ENABLE BIT(0)
|
||||
@@ -170,6 +214,5 @@ int cdns3_drd_gadget_on(struct cdns3 *cdns);
|
||||
void cdns3_drd_gadget_off(struct cdns3 *cdns);
|
||||
int cdns3_drd_host_on(struct cdns3 *cdns);
|
||||
void cdns3_drd_host_off(struct cdns3 *cdns);
|
||||
int cdns3_set_mode(struct cdns3 *cdns, enum usb_dr_mode mode);
|
||||
|
||||
#endif /* __LINUX_CDNS3_DRD */
|
||||
|
||||
@@ -352,19 +352,6 @@ static void cdns3_ep_inc_deq(struct cdns3_endpoint *priv_ep)
|
||||
cdns3_ep_inc_trb(&priv_ep->dequeue, &priv_ep->ccs, priv_ep->num_trbs);
|
||||
}
|
||||
|
||||
static void cdns3_move_deq_to_next_trb(struct cdns3_request *priv_req)
|
||||
{
|
||||
struct cdns3_endpoint *priv_ep = priv_req->priv_ep;
|
||||
int current_trb = priv_req->start_trb;
|
||||
|
||||
while (current_trb != priv_req->end_trb) {
|
||||
cdns3_ep_inc_deq(priv_ep);
|
||||
current_trb = priv_ep->dequeue;
|
||||
}
|
||||
|
||||
cdns3_ep_inc_deq(priv_ep);
|
||||
}
|
||||
|
||||
/**
|
||||
* cdns3_allow_enable_l1 - enable/disable permits to transition to L1.
|
||||
* @priv_dev: Extended gadget object
|
||||
@@ -655,9 +642,9 @@ static void cdns3_wa2_remove_old_request(struct cdns3_endpoint *priv_ep)
|
||||
trace_cdns3_wa2(priv_ep, "removes eldest request");
|
||||
|
||||
kfree(priv_req->request.buf);
|
||||
list_del_init(&priv_req->list);
|
||||
cdns3_gadget_ep_free_request(&priv_ep->endpoint,
|
||||
&priv_req->request);
|
||||
list_del_init(&priv_req->list);
|
||||
--priv_ep->wa2_counter;
|
||||
|
||||
if (!chain)
|
||||
@@ -1518,10 +1505,11 @@ static void cdns3_transfer_completed(struct cdns3_device *priv_dev,
|
||||
|
||||
trb = priv_ep->trb_pool + priv_ep->dequeue;
|
||||
|
||||
/* Request was dequeued and TRB was changed to TRB_LINK. */
|
||||
if (TRB_FIELD_TO_TYPE(le32_to_cpu(trb->control)) == TRB_LINK) {
|
||||
/* The TRB was changed as link TRB, and the request was handled at ep_dequeue */
|
||||
while (TRB_FIELD_TO_TYPE(le32_to_cpu(trb->control)) == TRB_LINK) {
|
||||
trace_cdns3_complete_trb(priv_ep, trb);
|
||||
cdns3_move_deq_to_next_trb(priv_req);
|
||||
cdns3_ep_inc_deq(priv_ep);
|
||||
trb = priv_ep->trb_pool + priv_ep->dequeue;
|
||||
}
|
||||
|
||||
if (!request->stream_id) {
|
||||
@@ -1543,7 +1531,8 @@ static void cdns3_transfer_completed(struct cdns3_device *priv_dev,
|
||||
TRB_LEN(le32_to_cpu(trb->length));
|
||||
|
||||
if (priv_req->num_of_trb > 1 &&
|
||||
le32_to_cpu(trb->control) & TRB_SMM)
|
||||
le32_to_cpu(trb->control) & TRB_SMM &&
|
||||
le32_to_cpu(trb->control) & TRB_CHAIN)
|
||||
transfer_end = true;
|
||||
|
||||
cdns3_ep_inc_deq(priv_ep);
|
||||
@@ -1703,6 +1692,7 @@ static int cdns3_check_ep_interrupt_proceed(struct cdns3_endpoint *priv_ep)
|
||||
ep_cfg &= ~EP_CFG_ENABLE;
|
||||
writel(ep_cfg, &priv_dev->regs->ep_cfg);
|
||||
priv_ep->flags &= ~EP_QUIRK_ISO_OUT_EN;
|
||||
priv_ep->flags |= EP_UPDATE_EP_TRBADDR;
|
||||
}
|
||||
cdns3_transfer_completed(priv_dev, priv_ep);
|
||||
} else if (!(priv_ep->flags & EP_STALLED) &&
|
||||
@@ -2293,11 +2283,16 @@ static int cdns3_gadget_ep_enable(struct usb_ep *ep,
|
||||
int ret = 0;
|
||||
int val;
|
||||
|
||||
if (!ep) {
|
||||
pr_debug("usbss: ep not configured?\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
priv_ep = ep_to_cdns3_ep(ep);
|
||||
priv_dev = priv_ep->cdns3_dev;
|
||||
comp_desc = priv_ep->endpoint.comp_desc;
|
||||
|
||||
if (!ep || !desc || desc->bDescriptorType != USB_DT_ENDPOINT) {
|
||||
if (!desc || desc->bDescriptorType != USB_DT_ENDPOINT) {
|
||||
dev_dbg(priv_dev->dev, "usbss: invalid parameters\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -2609,7 +2604,7 @@ int cdns3_gadget_ep_dequeue(struct usb_ep *ep,
|
||||
struct usb_request *request)
|
||||
{
|
||||
struct cdns3_endpoint *priv_ep = ep_to_cdns3_ep(ep);
|
||||
struct cdns3_device *priv_dev = priv_ep->cdns3_dev;
|
||||
struct cdns3_device *priv_dev;
|
||||
struct usb_request *req, *req_temp;
|
||||
struct cdns3_request *priv_req;
|
||||
struct cdns3_trb *link_trb;
|
||||
@@ -2620,6 +2615,8 @@ int cdns3_gadget_ep_dequeue(struct usb_ep *ep,
|
||||
if (!ep || !request || !ep->desc)
|
||||
return -EINVAL;
|
||||
|
||||
priv_dev = priv_ep->cdns3_dev;
|
||||
|
||||
spin_lock_irqsave(&priv_dev->lock, flags);
|
||||
|
||||
priv_req = to_cdns3_request(request);
|
||||
@@ -2697,6 +2694,7 @@ int __cdns3_gadget_ep_clear_halt(struct cdns3_endpoint *priv_ep)
|
||||
struct usb_request *request;
|
||||
struct cdns3_request *priv_req;
|
||||
struct cdns3_trb *trb = NULL;
|
||||
struct cdns3_trb trb_tmp;
|
||||
int ret;
|
||||
int val;
|
||||
|
||||
@@ -2706,8 +2704,10 @@ int __cdns3_gadget_ep_clear_halt(struct cdns3_endpoint *priv_ep)
|
||||
if (request) {
|
||||
priv_req = to_cdns3_request(request);
|
||||
trb = priv_req->trb;
|
||||
if (trb)
|
||||
if (trb) {
|
||||
trb_tmp = *trb;
|
||||
trb->control = trb->control ^ cpu_to_le32(TRB_CYCLE);
|
||||
}
|
||||
}
|
||||
|
||||
writel(EP_CMD_CSTALL | EP_CMD_EPRST, &priv_dev->regs->ep_cmd);
|
||||
@@ -2722,7 +2722,7 @@ int __cdns3_gadget_ep_clear_halt(struct cdns3_endpoint *priv_ep)
|
||||
|
||||
if (request) {
|
||||
if (trb)
|
||||
trb->control = trb->control ^ cpu_to_le32(TRB_CYCLE);
|
||||
*trb = trb_tmp;
|
||||
|
||||
cdns3_rearm_transfer(priv_ep, 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user