lkml.org 
[lkml]   [2017]   [Oct]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.9 005/105] usb: gadget: udc: renesas_usb3: fix Pn_RAMMAP.Pn_MPKT value
    Date
    4.9-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

    commit 73f2f5745f18b4ccfe9484deac4e84a1378d19fd upstream.

    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")
    Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
    Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    drivers/usb/gadget/udc/renesas_usb3.c | 11 ++++++++++-
    1 file changed, 10 insertions(+), 1 deletion(-)

    --- a/drivers/usb/gadget/udc/renesas_usb3.c
    +++ b/drivers/usb/gadget/udc/renesas_usb3.c
    @@ -1569,7 +1569,16 @@ static u32 usb3_calc_ramarea(int ram_siz
    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,

    \
     
     \ /
      Last update: 2017-10-10 22:57    [W:4.071 / U:0.236 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site