Skip to content

Commit

Permalink
usb: gadget: udc: renesas_usb3: fix Pn_RAMMAP.Pn_MPKT value
Browse files Browse the repository at this point in the history
According to the datasheet of R-Car Gen3, the Pn_RAMMAP.Pn_MPKT should
be set to one of 8, 16, 32, 64, 512 and 1024. Otherwise, when a gadget
driver uses an interrupt endpoint, unexpected behavior happens. So,
this patch fixes it.

Fixes: 746bfe6 ("usb: gadget: renesas_usb3: add support for Renesas USB3.0 peripheral controller")
Cc: <stable@vger.kernel.org> # v4.5+
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
  • Loading branch information
Yoshihiro Shimoda authored and Felipe Balbi committed Sep 28, 2017
1 parent 4dcf4ba commit 73f2f57
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion drivers/usb/gadget/udc/renesas_usb3.c
Original file line number Diff line number Diff line change
Expand Up @@ -2054,7 +2054,16 @@ static u32 usb3_calc_ramarea(int ram_size)
static u32 usb3_calc_rammap_val(struct renesas_usb3_ep *usb3_ep,
const struct usb_endpoint_descriptor *desc)
{
return usb3_ep->rammap_val | PN_RAMMAP_MPKT(usb_endpoint_maxp(desc));
int i;
const u32 max_packet_array[] = {8, 16, 32, 64, 512};
u32 mpkt = PN_RAMMAP_MPKT(1024);

for (i = 0; i < ARRAY_SIZE(max_packet_array); i++) {
if (usb_endpoint_maxp(desc) <= max_packet_array[i])
mpkt = PN_RAMMAP_MPKT(max_packet_array[i]);
}

return usb3_ep->rammap_val | mpkt;
}

static int usb3_enable_pipe_n(struct renesas_usb3_ep *usb3_ep,
Expand Down

0 comments on commit 73f2f57

Please sign in to comment.