usb: renesas_usbhs: fix usbhs_pipe_clear() for DCP PIPE
authorYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Tue, 4 Nov 2014 01:05:45 +0000 (10:05 +0900)
committerFelipe Balbi <balbi@ti.com>
Wed, 5 Nov 2014 19:22:16 +0000 (13:22 -0600)
Since the DCPCTR doesn't have the ACLRM bit, the usbus_pipe_clear()
should not call the usbhsp_pipectrl_set() with ACLRM.
So, this patch fixes this issue to add the usbhs_fifo_clear_dcp()
in fifo.c because the controller needs the CFIFO to clear the
the DCP PIPE.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/renesas_usbhs/fifo.c
drivers/usb/renesas_usbhs/fifo.h
drivers/usb/renesas_usbhs/mod_gadget.c
drivers/usb/renesas_usbhs/mod_host.c
drivers/usb/renesas_usbhs/pipe.c

index 0e079256e53386c299dafcff970075c51f5dfb9a..9b48384c95a7f4c66df3b4ec5e940ea5b9a6dc5f 100644 (file)
@@ -1160,6 +1160,24 @@ static void usbhsf_dma_complete(void *arg)
                        usbhs_pipe_number(pipe), ret);
 }
 
+void usbhs_fifo_clear_dcp(struct usbhs_pipe *pipe)
+{
+       struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
+       struct usbhs_fifo *fifo = usbhsf_get_cfifo(priv); /* CFIFO */
+
+       /* clear DCP FIFO of transmission */
+       if (usbhsf_fifo_select(pipe, fifo, 1) < 0)
+               return;
+       usbhsf_fifo_clear(pipe, fifo);
+       usbhsf_fifo_unselect(pipe, fifo);
+
+       /* clear DCP FIFO of reception */
+       if (usbhsf_fifo_select(pipe, fifo, 0) < 0)
+               return;
+       usbhsf_fifo_clear(pipe, fifo);
+       usbhsf_fifo_unselect(pipe, fifo);
+}
+
 /*
  *             fifo init
  */
index a168a1760fce87ca6e8747491a609e9ed2445b6f..79ad5f971035b8828a49a303a97df6dd4d9cb802 100644 (file)
@@ -74,6 +74,7 @@ int usbhs_fifo_probe(struct usbhs_priv *priv);
 void usbhs_fifo_remove(struct usbhs_priv *priv);
 void usbhs_fifo_init(struct usbhs_priv *priv);
 void usbhs_fifo_quit(struct usbhs_priv *priv);
+void usbhs_fifo_clear_dcp(struct usbhs_pipe *pipe);
 
 /*
  * packet info
index 2457306e0924a62a89f645d25956b83a9650e254..8697e6efcabf92df1ace5b62defa9adcf954ea5c 100644 (file)
@@ -782,9 +782,9 @@ static int usbhsg_try_start(struct usbhs_priv *priv, u32 status)
        /*
         * pipe initialize and enable DCP
         */
+       usbhs_fifo_init(priv);
        usbhs_pipe_init(priv,
                        usbhsg_dma_map_ctrl);
-       usbhs_fifo_init(priv);
 
        /* dcp init instead of usbhsg_ep_enable() */
        dcp->pipe               = usbhs_dcp_malloc(priv);
index 10e1ded9c9ccbe264d44c2ebefe85d3e8472a14f..f0d323125871806f682e4b647e432f816f4c4712 100644 (file)
@@ -1474,9 +1474,9 @@ static int usbhsh_start(struct usbhs_priv *priv)
        /*
         * pipe initialize and enable DCP
         */
+       usbhs_fifo_init(priv);
        usbhs_pipe_init(priv,
                        usbhsh_dma_map_ctrl);
-       usbhs_fifo_init(priv);
        usbhsh_pipe_init_for_host(priv);
 
        /*
index 040bcefcb0402c80116b917ea6595e1d01ed0a4d..007f45abe96cf962ce32298b334ef1ece701aac5 100644 (file)
@@ -618,8 +618,12 @@ void usbhs_pipe_data_sequence(struct usbhs_pipe *pipe, int sequence)
 
 void usbhs_pipe_clear(struct usbhs_pipe *pipe)
 {
-       usbhsp_pipectrl_set(pipe, ACLRM, ACLRM);
-       usbhsp_pipectrl_set(pipe, ACLRM, 0);
+       if (usbhs_pipe_is_dcp(pipe)) {
+               usbhs_fifo_clear_dcp(pipe);
+       } else {
+               usbhsp_pipectrl_set(pipe, ACLRM, ACLRM);
+               usbhsp_pipectrl_set(pipe, ACLRM, 0);
+       }
 }
 
 static struct usbhs_pipe *usbhsp_get_pipe(struct usbhs_priv *priv, u32 type)