Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fc7e286c authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "USB: dwc3-msm: Disable Update xfer for DBM on ep disable or dequeue"

parents e7438561 61c8f617
Loading
Loading
Loading
Loading
+15 −14
Original line number Diff line number Diff line
@@ -256,9 +256,9 @@ static int dwc3_core_reset(struct dwc3 *dwc)

	dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);

	dwc3_notify_event(dwc, DWC3_CONTROLLER_RESET_EVENT);
	dwc3_notify_event(dwc, DWC3_CONTROLLER_RESET_EVENT, 0);

	dwc3_notify_event(dwc, DWC3_CONTROLLER_POST_RESET_EVENT);
	dwc3_notify_event(dwc, DWC3_CONTROLLER_POST_RESET_EVENT, 0);

	return 0;
}
@@ -366,7 +366,7 @@ static void dwc3_free_event_buffers(struct dwc3 *dwc)
		dwc3_free_one_event_buffer(dwc, evt);

	/* free GSI related event buffers */
	dwc3_notify_event(dwc, DWC3_GSI_EVT_BUF_FREE);
	dwc3_notify_event(dwc, DWC3_GSI_EVT_BUF_FREE, 0);
}

/**
@@ -389,7 +389,7 @@ static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length)
	dwc->ev_buf = evt;

	/* alloc GSI related event buffers */
	dwc3_notify_event(dwc, DWC3_GSI_EVT_BUF_ALLOC);
	dwc3_notify_event(dwc, DWC3_GSI_EVT_BUF_ALLOC, 0);
	return 0;
}

@@ -420,7 +420,7 @@ int dwc3_event_buffers_setup(struct dwc3 *dwc)
	dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0);

	/* setup GSI related event buffers */
	dwc3_notify_event(dwc, DWC3_GSI_EVT_BUF_SETUP);
	dwc3_notify_event(dwc, DWC3_GSI_EVT_BUF_SETUP, 0);
	return 0;
}

@@ -442,7 +442,7 @@ static void dwc3_event_buffers_cleanup(struct dwc3 *dwc)
	dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0);

	/* cleanup GSI related event buffers */
	dwc3_notify_event(dwc, DWC3_GSI_EVT_BUF_CLEANUP);
	dwc3_notify_event(dwc, DWC3_GSI_EVT_BUF_CLEANUP, 0);
}

static int dwc3_alloc_scratch_buffers(struct dwc3 *dwc)
@@ -1026,19 +1026,20 @@ void dwc3_post_host_reset_core_init(struct dwc3 *dwc)
	dwc3_gadget_restart(dwc);
}

static void (*notify_event)(struct dwc3 *, unsigned int);
void dwc3_set_notifier(void (*notify)(struct dwc3 *, unsigned int))
static void (*notify_event)(struct dwc3 *, unsigned int, unsigned int);
void dwc3_set_notifier(void (*notify)(struct dwc3 *, unsigned int,
							unsigned int))
{
	notify_event = notify;
}
EXPORT_SYMBOL(dwc3_set_notifier);

int dwc3_notify_event(struct dwc3 *dwc, unsigned int event)
int dwc3_notify_event(struct dwc3 *dwc, unsigned int event, unsigned int value)
{
	int ret = 0;

	if (dwc->notify_event)
		dwc->notify_event(dwc, event);
		dwc->notify_event(dwc, event, value);
	else
		ret = -ENODEV;

@@ -1459,7 +1460,7 @@ static int dwc3_runtime_suspend(struct device *dev)
	int		ret;

	/* Check if platform glue driver handling PM, if not then handle here */
	if (!dwc3_notify_event(dwc, DWC3_CORE_PM_RESUME_EVENT))
	if (!dwc3_notify_event(dwc, DWC3_CORE_PM_RESUME_EVENT, 0))
		return 0;

	ret = dwc3_suspend_common(dwc);
@@ -1477,7 +1478,7 @@ static int dwc3_runtime_resume(struct device *dev)
	int		ret;

	/* Check if platform glue driver handling PM, if not then handle here */
	if (!dwc3_notify_event(dwc, DWC3_CORE_PM_RESUME_EVENT))
	if (!dwc3_notify_event(dwc, DWC3_CORE_PM_RESUME_EVENT, 0))
		return 0;

	device_init_wakeup(dev, false);
@@ -1533,7 +1534,7 @@ static int dwc3_suspend(struct device *dev)
	int		ret;

	/* Check if platform glue driver handling PM, if not then handle here */
	if (!dwc3_notify_event(dwc, DWC3_CORE_PM_SUSPEND_EVENT))
	if (!dwc3_notify_event(dwc, DWC3_CORE_PM_SUSPEND_EVENT, 0))
		return 0;

	ret = dwc3_suspend_common(dwc);
@@ -1551,7 +1552,7 @@ static int dwc3_resume(struct device *dev)
	int		ret;

	/* Check if platform glue driver handling PM, if not then handle here */
	if (!dwc3_notify_event(dwc, DWC3_CORE_PM_RESUME_EVENT))
	if (!dwc3_notify_event(dwc, DWC3_CORE_PM_RESUME_EVENT, 0))
		return 0;

	pinctrl_pm_select_default_state(dev);
+20 −16
Original line number Diff line number Diff line
@@ -830,12 +830,13 @@ struct dwc3_scratchpad_array {
#define DWC3_CONTROLLER_NOTIFY_OTG_EVENT		6
#define DWC3_CONTROLLER_SET_CURRENT_DRAW_EVENT		7
#define DWC3_CONTROLLER_RESTART_USB_SESSION		8
#define DWC3_CONTROLLER_NOTIFY_DISABLE_UPDXFER		9

/* USB GSI event buffer related notification */
#define DWC3_GSI_EVT_BUF_ALLOC			9
#define DWC3_GSI_EVT_BUF_SETUP			10
#define DWC3_GSI_EVT_BUF_CLEANUP		11
#define DWC3_GSI_EVT_BUF_FREE			12
#define DWC3_GSI_EVT_BUF_ALLOC			10
#define DWC3_GSI_EVT_BUF_SETUP			11
#define DWC3_GSI_EVT_BUF_CLEANUP		12
#define DWC3_GSI_EVT_BUF_FREE			13

#define MAX_INTR_STATS				10

@@ -1081,7 +1082,7 @@ struct dwc3 {
	const char		*hsphy_interface;

	unsigned		connected:1;
	void (*notify_event)(struct dwc3 *, unsigned int);
	void (*notify_event)(struct dwc3 *, unsigned int, unsigned int);
	struct work_struct	wakeup_work;

	unsigned		delayed_status:1;
@@ -1416,6 +1417,9 @@ int dwc3_event_buffers_setup(struct dwc3 *dwc);
void dwc3_usb3_phy_suspend(struct dwc3 *dwc, int suspend);

extern void dwc3_set_notifier(
		void (*notify)(struct dwc3 *dwc3, unsigned int event));
extern int dwc3_notify_event(struct dwc3 *dwc3, unsigned int event);
	void (*notify)(struct dwc3 *dwc3, unsigned int event,
						unsigned int value));
extern int dwc3_notify_event(struct dwc3 *dwc3, unsigned int event,
							unsigned int value);

#endif /* __DRIVERS_USB_DWC3_CORE_H */
+36 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ enum dbm_reg {
	DBM_HW_TRB2_EP,
	DBM_HW_TRB3_EP,
	DBM_PIPE_CFG,
	DBM_DISABLE_UPDXFER,
	DBM_SOFT_RESET,
	DBM_GEN_CFG,
	DBM_GEVNTADR_LSB,
@@ -103,6 +104,7 @@ static const struct dbm_reg_data dbm_1_5_regtable[] = {
	[DBM_HW_TRB2_EP]	= { 0x0240, 0x4 },
	[DBM_HW_TRB3_EP]	= { 0x0250, 0x4 },
	[DBM_PIPE_CFG]		= { 0x0274, 0x0 },
	[DBM_DISABLE_UPDXFER]	= { 0x0298, 0x0 },
	[DBM_SOFT_RESET]	= { 0x020C, 0x0 },
	[DBM_GEN_CFG]		= { 0x0210, 0x0 },
	[DBM_GEVNTADR_LSB]	= { 0x0260, 0x0 },
@@ -291,6 +293,7 @@ int dbm_ep_config(struct dbm *dbm, u8 usb_ep, u8 bam_pipe, bool producer,
{
	int dbm_ep;
	u32 ep_cfg;
	u32 data;

	if (!dbm) {
		pr_err("%s: dbm pointer is NULL!\n", __func__);
@@ -334,6 +337,10 @@ int dbm_ep_config(struct dbm *dbm, u8 usb_ep, u8 bam_pipe, bool producer,

	msm_dbm_write_ep_reg_field(dbm, DBM_EP_CFG, dbm_ep, DBM_EN_EP, 1);

	data = msm_dbm_read_reg(dbm, DBM_DISABLE_UPDXFER);
	data &= ~(0x1 << dbm_ep);
	msm_dbm_write_reg(dbm, DBM_DISABLE_UPDXFER, data);

	return dbm_ep;
}

@@ -433,6 +440,35 @@ int dbm_event_buffer_config(struct dbm *dbm, u32 addr_lo, u32 addr_hi, int size)
	return 0;
}

/**
 * Disable update xfer before queueing stop xfer command to USB3 core.
 *
 * @usb_ep - USB physical EP number.
 *
 */
int dwc3_dbm_disable_update_xfer(struct dbm *dbm, u8 usb_ep)
{
	u32 data;
	int dbm_ep;

	if (!dbm) {
		pr_err("%s: dbm pointer is NULL!\n", __func__);
		return -EPERM;
	}

	dbm_ep = find_matching_dbm_ep(dbm, usb_ep);

	if (dbm_ep < 0) {
		pr_err("usb ep index %d has no corresponding dbm ep\n", usb_ep);
		return -ENODEV;
	}

	data = msm_dbm_read_reg(dbm, DBM_DISABLE_UPDXFER);
	data |= (0x1 << dbm_ep);
	msm_dbm_write_reg(dbm, DBM_DISABLE_UPDXFER, data);

	return 0;
}

int dbm_data_fifo_config(struct dbm *dbm, u8 dep_num, unsigned long addr,
				u32 size, u8 dst_pipe_idx)
+1 −0
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ int dbm_event_buffer_config(struct dbm *dbm, u32 addr_lo, u32 addr_hi,
				int size);
int dbm_data_fifo_config(struct dbm *dbm, u8 dep_num, unsigned long addr,
				u32 size, u8 dst_pipe_idx);
int dwc3_dbm_disable_update_xfer(struct dbm *dbm, u8 usb_ep);
void dbm_set_speed(struct dbm *dbm, bool speed);
void dbm_enable(struct dbm *dbm);
int dbm_ep_soft_reset(struct dbm *dbm, u8 usb_ep, bool enter_reset);
+17 −2
Original line number Diff line number Diff line
@@ -289,7 +289,8 @@ struct dwc3_msm {

static void dwc3_pwr_event_handler(struct dwc3_msm *mdwc);
static int dwc3_msm_gadget_vbus_draw(struct dwc3_msm *mdwc, unsigned int mA);
static void dwc3_msm_notify_event(struct dwc3 *dwc, unsigned int event);
static void dwc3_msm_notify_event(struct dwc3 *dwc, unsigned int event,
						unsigned int value);
static int dwc3_restart_usb_host_mode(struct notifier_block *nb,
					unsigned long event, void *ptr);

@@ -441,6 +442,16 @@ static inline bool dwc3_msm_is_superspeed(struct dwc3_msm *mdwc)
	return dwc3_msm_is_dev_superspeed(mdwc);
}

static int dwc3_msm_dbm_disable_updxfer(struct dwc3 *dwc, u8 usb_ep)
{
	struct dwc3_msm *mdwc = dev_get_drvdata(dwc->dev->parent);

	dev_dbg(mdwc->dev, "%s\n", __func__);
	dwc3_dbm_disable_update_xfer(mdwc->dbm, usb_ep);

	return 0;
}

#if IS_ENABLED(CONFIG_USB_DWC3_GADGET) || IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE)
/**
 * Configure the DBM with the BAM's data fifo.
@@ -1817,7 +1828,8 @@ static void dwc3_msm_vbus_draw_work(struct work_struct *w)
	dwc3_msm_gadget_vbus_draw(mdwc, dwc->vbus_draw);
}

static void dwc3_msm_notify_event(struct dwc3 *dwc, unsigned int event)
static void dwc3_msm_notify_event(struct dwc3 *dwc, unsigned int event,
							unsigned int value)
{
	struct dwc3_msm *mdwc = dev_get_drvdata(dwc->dev->parent);
	struct dwc3_event_buffer *evt;
@@ -2004,6 +2016,9 @@ static void dwc3_msm_notify_event(struct dwc3 *dwc, unsigned int event)
							evt->buf, evt->dma);
		}
		break;
	case DWC3_CONTROLLER_NOTIFY_DISABLE_UPDXFER:
		dwc3_msm_dbm_disable_updxfer(dwc, value);
		break;
	default:
		dev_dbg(mdwc->dev, "unknown dwc3 event\n");
		break;
Loading