Commit 265b70a7 authored by Paul Zimmerman's avatar Paul Zimmerman Committed by Felipe Balbi

usb: dwc3: gadget: add a 'restore' argument to set_ep_config

That argument will be used in later patches when we
have working hibernation support. For now, always
pass it as false.

The idea of this patch is to decrease to size of
following patches and slowly add hibernation building
blocks to the gadget side of dwc3 so that it becomes
very easy to review the actual hibernation code.

[ balbi@ti.com : rewrote patch on top of current
	tree. Added commit log. ]
Signed-off-by: default avatarPaul Zimmerman <paulz@synopsys.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 911f1f88
...@@ -433,7 +433,7 @@ static int dwc3_gadget_start_config(struct dwc3 *dwc, struct dwc3_ep *dep) ...@@ -433,7 +433,7 @@ static int dwc3_gadget_start_config(struct dwc3 *dwc, struct dwc3_ep *dep)
static int dwc3_gadget_set_ep_config(struct dwc3 *dwc, struct dwc3_ep *dep, static int dwc3_gadget_set_ep_config(struct dwc3 *dwc, struct dwc3_ep *dep,
const struct usb_endpoint_descriptor *desc, const struct usb_endpoint_descriptor *desc,
const struct usb_ss_ep_comp_descriptor *comp_desc, const struct usb_ss_ep_comp_descriptor *comp_desc,
bool ignore) bool ignore, bool restore)
{ {
struct dwc3_gadget_ep_cmd_params params; struct dwc3_gadget_ep_cmd_params params;
...@@ -452,6 +452,11 @@ static int dwc3_gadget_set_ep_config(struct dwc3 *dwc, struct dwc3_ep *dep, ...@@ -452,6 +452,11 @@ static int dwc3_gadget_set_ep_config(struct dwc3 *dwc, struct dwc3_ep *dep,
if (ignore) if (ignore)
params.param0 |= DWC3_DEPCFG_IGN_SEQ_NUM; params.param0 |= DWC3_DEPCFG_IGN_SEQ_NUM;
if (restore) {
params.param0 |= DWC3_DEPCFG_ACTION_RESTORE;
params.param2 |= dep->saved_state;
}
params.param1 = DWC3_DEPCFG_XFER_COMPLETE_EN params.param1 = DWC3_DEPCFG_XFER_COMPLETE_EN
| DWC3_DEPCFG_XFER_NOT_READY_EN; | DWC3_DEPCFG_XFER_NOT_READY_EN;
...@@ -510,7 +515,7 @@ static int dwc3_gadget_set_xfer_resource(struct dwc3 *dwc, struct dwc3_ep *dep) ...@@ -510,7 +515,7 @@ static int dwc3_gadget_set_xfer_resource(struct dwc3 *dwc, struct dwc3_ep *dep)
static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
const struct usb_endpoint_descriptor *desc, const struct usb_endpoint_descriptor *desc,
const struct usb_ss_ep_comp_descriptor *comp_desc, const struct usb_ss_ep_comp_descriptor *comp_desc,
bool ignore) bool ignore, bool restore)
{ {
struct dwc3 *dwc = dep->dwc; struct dwc3 *dwc = dep->dwc;
u32 reg; u32 reg;
...@@ -524,7 +529,8 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, ...@@ -524,7 +529,8 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
return ret; return ret;
} }
ret = dwc3_gadget_set_ep_config(dwc, dep, desc, comp_desc, ignore); ret = dwc3_gadget_set_ep_config(dwc, dep, desc, comp_desc, ignore,
restore);
if (ret) if (ret)
return ret; return ret;
...@@ -675,7 +681,7 @@ static int dwc3_gadget_ep_enable(struct usb_ep *ep, ...@@ -675,7 +681,7 @@ static int dwc3_gadget_ep_enable(struct usb_ep *ep,
} }
spin_lock_irqsave(&dwc->lock, flags); spin_lock_irqsave(&dwc->lock, flags);
ret = __dwc3_gadget_ep_enable(dep, desc, ep->comp_desc, false); ret = __dwc3_gadget_ep_enable(dep, desc, ep->comp_desc, false, false);
spin_unlock_irqrestore(&dwc->lock, flags); spin_unlock_irqrestore(&dwc->lock, flags);
return ret; return ret;
...@@ -1565,14 +1571,16 @@ static int dwc3_gadget_start(struct usb_gadget *g, ...@@ -1565,14 +1571,16 @@ static int dwc3_gadget_start(struct usb_gadget *g,
dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512); dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512);
dep = dwc->eps[0]; dep = dwc->eps[0];
ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, false); ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, false,
false);
if (ret) { if (ret) {
dev_err(dwc->dev, "failed to enable %s\n", dep->name); dev_err(dwc->dev, "failed to enable %s\n", dep->name);
goto err2; goto err2;
} }
dep = dwc->eps[1]; dep = dwc->eps[1];
ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, false); ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, false,
false);
if (ret) { if (ret) {
dev_err(dwc->dev, "failed to enable %s\n", dep->name); dev_err(dwc->dev, "failed to enable %s\n", dep->name);
goto err3; goto err3;
...@@ -2276,14 +2284,16 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) ...@@ -2276,14 +2284,16 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc)
} }
dep = dwc->eps[0]; dep = dwc->eps[0];
ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, true); ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, true,
false);
if (ret) { if (ret) {
dev_err(dwc->dev, "failed to enable %s\n", dep->name); dev_err(dwc->dev, "failed to enable %s\n", dep->name);
return; return;
} }
dep = dwc->eps[1]; dep = dwc->eps[1];
ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, true); ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, true,
false);
if (ret) { if (ret) {
dev_err(dwc->dev, "failed to enable %s\n", dep->name); dev_err(dwc->dev, "failed to enable %s\n", dep->name);
return; return;
...@@ -2738,12 +2748,14 @@ int dwc3_gadget_resume(struct dwc3 *dwc) ...@@ -2738,12 +2748,14 @@ int dwc3_gadget_resume(struct dwc3 *dwc)
dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512); dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512);
dep = dwc->eps[0]; dep = dwc->eps[0];
ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, false); ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, false,
false);
if (ret) if (ret)
goto err0; goto err0;
dep = dwc->eps[1]; dep = dwc->eps[1];
ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, false); ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, false,
false);
if (ret) if (ret)
goto err1; goto err1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment