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

Commit 76b35fa8 authored by Chandana Kishori Chiluveru's avatar Chandana Kishori Chiluveru
Browse files

usb: f_gsi: Report Function Remote Wake capabilities



Add support for sending Function Wake capabilities in
response to GET_STATUS from the host. GET_STATUS addressed
to an Interface allows the device to report if it is capable
of doing a Function Remote Wake. Windows8/10 MBIM hosts request
this information before enabling Suspend in SS mode.

Change-Id: Ic0a6db57b2b46804a82847de511feb433a3dfca6
Signed-off-by: default avatarDevdutt Patnaik <dpatnaik@codeaurora.org>
Signed-off-by: default avatarChandana Kishori Chiluveru <cchiluve@codeaurora.org>
parent 3f60b750
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -43,6 +43,8 @@ MODULE_PARM_DESC(enable_dwc3_u1u2, "Enable support for U1U2 low power modes");
static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep);
static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
		struct dwc3_ep *dep, struct dwc3_request *req);
static int dwc3_ep0_delegate_req(struct dwc3 *dwc,
		struct usb_ctrlrequest *ctrl);

static void dwc3_ep0_prepare_one_trb(struct dwc3_ep *dep,
		dma_addr_t buf_dma, u32 len, u32 type, bool chain)
@@ -332,12 +334,14 @@ static struct dwc3_ep *dwc3_wIndex_to_dep(struct dwc3 *dwc, __le16 wIndex_le)
static void dwc3_ep0_status_cmpl(struct usb_ep *ep, struct usb_request *req)
{
}

/*
 * ch 9.4.5
 */
static int dwc3_ep0_handle_status(struct dwc3 *dwc,
		struct usb_ctrlrequest *ctrl)
{
	int ret;
	struct dwc3_ep		*dep;
	u32			recip;
	u32			value;
@@ -377,7 +381,8 @@ static int dwc3_ep0_handle_status(struct dwc3 *dwc,
		 * Function Remote Wake Capable	D0
		 * Function Remote Wakeup	D1
		 */
		break;
		ret = dwc3_ep0_delegate_req(dwc, ctrl);
		return ret;

	case USB_RECIP_ENDPOINT:
		dep = dwc3_wIndex_to_dep(dwc, ctrl->wIndex);
@@ -538,6 +543,9 @@ static int dwc3_ep0_handle_intf(struct dwc3 *dwc,
		 * For now, we're not doing anything, just making sure we return
		 * 0 so USB Command Verifier tests pass without any errors.
		 */
		ret = dwc3_ep0_delegate_req(dwc, ctrl);
		if (ret)
			return ret;
		break;
	default:
		ret = -EINVAL;
+9 −0
Original line number Diff line number Diff line
@@ -2342,6 +2342,14 @@ static void gsi_resume(struct usb_function *f)
	log_event_dbg("%s: completed", __func__);
}

static int gsi_get_status(struct usb_function *f)
{
	unsigned int remote_wakeup_en_status = f->func_wakeup_allowed ? 1 : 0;

	return (remote_wakeup_en_status << FUNC_WAKEUP_ENABLE_SHIFT) |
		(1 << FUNC_WAKEUP_CAPABLE_SHIFT);
}

static int gsi_func_suspend(struct usb_function *f, u8 options)
{
	bool func_wakeup_allowed;
@@ -3002,6 +3010,7 @@ static int gsi_bind_config(struct f_gsi *gsi)
	gsi->function.disable = gsi_disable;
	gsi->function.free_func = gsi_free_func;
	gsi->function.suspend = gsi_suspend;
	gsi->function.get_status = gsi_get_status;
	gsi->function.func_suspend = gsi_func_suspend;
	gsi->function.resume = gsi_resume;

+3 −0
Original line number Diff line number Diff line
@@ -45,6 +45,9 @@
#define FUNC_SUSPEND_OPT_SUSP_MASK BIT(0)
#define FUNC_SUSPEND_OPT_RW_EN_MASK BIT(1)

#define FUNC_WAKEUP_CAPABLE_SHIFT  0
#define FUNC_WAKEUP_ENABLE_SHIFT   1

/*
 * USB function drivers should return USB_GADGET_DELAYED_STATUS if they
 * wish to delay the data/status stages of the control transfer till they