usb: renesas_usbhs: add support for USB-DMAC

Some Renesas SoCs have the USB-DMAC. It is able to terminate transfers
when a short packet is received, even if less bytes than the transfer
counter size have been received. Also, it is able to send a short
packet even if the packet size is not multiples of 8bytes.

Since the previous code has used the interruption of USBHS controller
when receiving packets even if this driver has used a dmac, a lot of
interruptions has happened. This patch will reduce such interruptions.

This patch allows to use the USB-DMAC on R-Car H2 and M2.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
This commit is contained in:
Yoshihiro Shimoda
2015-03-12 15:35:20 +09:00
committed by Felipe Balbi
parent 9b53d9af7a
commit ab330cf388
7 changed files with 228 additions and 6 deletions

View File

@@ -84,6 +84,17 @@ static void __usbhsp_pipe_xxx_set(struct usbhs_pipe *pipe,
usbhs_bset(priv, pipe_reg, mask, val);
}
static u16 __usbhsp_pipe_xxx_get(struct usbhs_pipe *pipe,
u16 dcp_reg, u16 pipe_reg)
{
struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
if (usbhs_pipe_is_dcp(pipe))
return usbhs_read(priv, dcp_reg);
else
return usbhs_read(priv, pipe_reg);
}
/*
* DCPCFG/PIPECFG functions
*/
@@ -92,6 +103,11 @@ static void usbhsp_pipe_cfg_set(struct usbhs_pipe *pipe, u16 mask, u16 val)
__usbhsp_pipe_xxx_set(pipe, DCPCFG, PIPECFG, mask, val);
}
static u16 usbhsp_pipe_cfg_get(struct usbhs_pipe *pipe)
{
return __usbhsp_pipe_xxx_get(pipe, DCPCFG, PIPECFG);
}
/*
* PIPEnTRN/PIPEnTRE functions
*/
@@ -616,6 +632,11 @@ void usbhs_pipe_data_sequence(struct usbhs_pipe *pipe, int sequence)
usbhsp_pipectrl_set(pipe, mask, val);
}
static int usbhs_pipe_get_data_sequence(struct usbhs_pipe *pipe)
{
return !!(usbhsp_pipectrl_get(pipe) & SQMON);
}
void usbhs_pipe_clear(struct usbhs_pipe *pipe)
{
if (usbhs_pipe_is_dcp(pipe)) {
@@ -626,6 +647,24 @@ void usbhs_pipe_clear(struct usbhs_pipe *pipe)
}
}
void usbhs_pipe_config_change_bfre(struct usbhs_pipe *pipe, int enable)
{
int sequence;
if (usbhs_pipe_is_dcp(pipe))
return;
usbhsp_pipe_select(pipe);
/* check if the driver needs to change the BFRE value */
if (!(enable ^ !!(usbhsp_pipe_cfg_get(pipe) & BFRE)))
return;
sequence = usbhs_pipe_get_data_sequence(pipe);
usbhsp_pipe_cfg_set(pipe, BFRE, enable ? BFRE : 0);
usbhs_pipe_clear(pipe);
usbhs_pipe_data_sequence(pipe, sequence);
}
static struct usbhs_pipe *usbhsp_get_pipe(struct usbhs_priv *priv, u32 type)
{
struct usbhs_pipe *pos, *pipe;