usb: ci_udc: set correct ep type in ep_enable()
The Endpoint Type in ENDPTCTRL register should be correctly set
according to endpoint descriptor, not fixed to bulk. Otherwise,
unexpected behaviors may happen.
Fixes: 26cc5129ee ("USB: gadaget: add Marvell controller support")
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
Link: https://patch.msgid.link/20260522075512.1291485-1-ye.li@nxp.com
Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
This commit is contained in:
committed by
Mattijs Korpershoek
parent
ee3ab69888
commit
eed2ed7588
@@ -333,16 +333,16 @@ static void request_complete_list(struct usb_ep *ep, struct list_head *list, int
|
||||
}
|
||||
}
|
||||
|
||||
static void ep_enable(int num, int in, int maxpacket)
|
||||
static void ep_enable(int num, int in, int type, int maxpacket)
|
||||
{
|
||||
struct ci_udc *udc = (struct ci_udc *)controller.ctrl->hcor;
|
||||
unsigned n;
|
||||
|
||||
n = readl(&udc->epctrl[num]);
|
||||
if (in)
|
||||
n |= (CTRL_TXE | CTRL_TXR | CTRL_TXT_BULK);
|
||||
n |= (CTRL_TXE | CTRL_TXR | CTRL_TXT(type));
|
||||
else
|
||||
n |= (CTRL_RXE | CTRL_RXR | CTRL_RXT_BULK);
|
||||
n |= (CTRL_RXE | CTRL_RXR | CTRL_RXT(type));
|
||||
|
||||
if (num != 0) {
|
||||
struct ept_queue_head *head = ci_get_qh(num, in);
|
||||
@@ -357,7 +357,7 @@ static int ci_ep_enable(struct usb_ep *ep,
|
||||
const struct usb_endpoint_descriptor *desc)
|
||||
{
|
||||
struct ci_ep *ci_ep = container_of(ep, struct ci_ep, ep);
|
||||
int num, in;
|
||||
int num, in, type;
|
||||
num = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
|
||||
in = (desc->bEndpointAddress & USB_DIR_IN) != 0;
|
||||
|
||||
@@ -366,6 +366,7 @@ static int ci_ep_enable(struct usb_ep *ep,
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
type = usb_endpoint_type(desc);
|
||||
ci_ep->desc = desc;
|
||||
ep->desc = desc;
|
||||
|
||||
@@ -380,7 +381,7 @@ static int ci_ep_enable(struct usb_ep *ep,
|
||||
ep->maxpacket = max;
|
||||
}
|
||||
}
|
||||
ep_enable(num, in, ep->maxpacket);
|
||||
ep_enable(num, in, type, ep->maxpacket);
|
||||
DBG("%s: num=%d maxpacket=%d\n", __func__, num, ep->maxpacket);
|
||||
return 0;
|
||||
}
|
||||
@@ -783,7 +784,7 @@ static void handle_setup(void)
|
||||
struct ept_queue_head *head;
|
||||
struct usb_ctrlrequest r;
|
||||
int status = 0;
|
||||
int num, in, _num, _in, i;
|
||||
int num, in, _num, _in, i, type;
|
||||
char *buf;
|
||||
|
||||
ci_req = controller.ep0_req;
|
||||
@@ -837,8 +838,9 @@ static void handle_setup(void)
|
||||
& USB_ENDPOINT_NUMBER_MASK;
|
||||
in = (ep->desc->bEndpointAddress
|
||||
& USB_DIR_IN) != 0;
|
||||
type = usb_endpoint_type(ep->desc);
|
||||
if ((num == _num) && (in == _in)) {
|
||||
ep_enable(num, in, ep->ep.maxpacket);
|
||||
ep_enable(num, in, type, ep->ep.maxpacket);
|
||||
usb_ep_queue(controller.gadget.ep0,
|
||||
req, 0);
|
||||
break;
|
||||
|
||||
@@ -74,8 +74,8 @@ struct ci_udc {
|
||||
#define CTRL_TXR (1 << 22)
|
||||
#define CTRL_RXE (1 << 7)
|
||||
#define CTRL_RXR (1 << 6)
|
||||
#define CTRL_TXT_BULK (2 << 18)
|
||||
#define CTRL_RXT_BULK (2 << 2)
|
||||
#define CTRL_TXT(t) ((t) << 18)
|
||||
#define CTRL_RXT(t) ((t) << 2)
|
||||
|
||||
struct ci_req {
|
||||
struct usb_request req;
|
||||
|
||||
Reference in New Issue
Block a user