diff options
author | Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> | 2017-09-25 04:01:24 -0400 |
---|---|---|
committer | Felipe Balbi <felipe.balbi@linux.intel.com> | 2017-09-28 05:31:47 -0400 |
commit | 73f2f5745f18b4ccfe9484deac4e84a1378d19fd (patch) | |
tree | ffcd384768940c4a5961b74c2a192154b182e7b9 | |
parent | 4dcf4bab4a409e81284b8202137e4a85b96b34de (diff) |
usb: gadget: udc: renesas_usb3: fix Pn_RAMMAP.Pn_MPKT value
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: 746bfe63bba3 ("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>
-rw-r--r-- | drivers/usb/gadget/udc/renesas_usb3.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c index 555c105e82df..7e0c53492356 100644 --- a/drivers/usb/gadget/udc/renesas_usb3.c +++ b/drivers/usb/gadget/udc/renesas_usb3.c | |||
@@ -2054,7 +2054,16 @@ static u32 usb3_calc_ramarea(int ram_size) | |||
2054 | static u32 usb3_calc_rammap_val(struct renesas_usb3_ep *usb3_ep, | 2054 | static u32 usb3_calc_rammap_val(struct renesas_usb3_ep *usb3_ep, |
2055 | const struct usb_endpoint_descriptor *desc) | 2055 | const struct usb_endpoint_descriptor *desc) |
2056 | { | 2056 | { |
2057 | return usb3_ep->rammap_val | PN_RAMMAP_MPKT(usb_endpoint_maxp(desc)); | 2057 | int i; |
2058 | const u32 max_packet_array[] = {8, 16, 32, 64, 512}; | ||
2059 | u32 mpkt = PN_RAMMAP_MPKT(1024); | ||
2060 | |||
2061 | for (i = 0; i < ARRAY_SIZE(max_packet_array); i++) { | ||
2062 | if (usb_endpoint_maxp(desc) <= max_packet_array[i]) | ||
2063 | mpkt = PN_RAMMAP_MPKT(max_packet_array[i]); | ||
2064 | } | ||
2065 | |||
2066 | return usb3_ep->rammap_val | mpkt; | ||
2058 | } | 2067 | } |
2059 | 2068 | ||
2060 | static int usb3_enable_pipe_n(struct renesas_usb3_ep *usb3_ep, | 2069 | static int usb3_enable_pipe_n(struct renesas_usb3_ep *usb3_ep, |