From 4cd2f5998757a41038deb55a0cb8319bdf67575a Mon Sep 17 00:00:00 2001 From: "kuninori.morimoto.gx@renesas.com" Date: Mon, 15 Oct 2012 23:24:19 -0700 Subject: usb: renesas_usbhs: gadget: add usb_gadget_ops :: pullup support This patch adds usbhs_sys_function_pullup() to control D+ line for USB function, and enabled pullup support on mod_gadget. Signed-off-by: Kuninori Morimoto Signed-off-by: Felipe Balbi --- drivers/usb/renesas_usbhs/common.c | 5 +++++ drivers/usb/renesas_usbhs/common.h | 1 + drivers/usb/renesas_usbhs/mod_gadget.c | 11 +++++++++++ 3 files changed, 17 insertions(+) (limited to 'drivers/usb/renesas_usbhs') diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c index 072edc1cc55f..3bf922ab045e 100644 --- a/drivers/usb/renesas_usbhs/common.c +++ b/drivers/usb/renesas_usbhs/common.c @@ -132,6 +132,11 @@ void usbhs_sys_function_ctrl(struct usbhs_priv *priv, int enable) usbhs_bset(priv, SYSCFG, mask, enable ? val : 0); } +void usbhs_sys_function_pullup(struct usbhs_priv *priv, int enable) +{ + usbhs_bset(priv, SYSCFG, DPRPU, enable ? DPRPU : 0); +} + void usbhs_sys_set_test_mode(struct usbhs_priv *priv, u16 mode) { usbhs_write(priv, TESTMODE, mode); diff --git a/drivers/usb/renesas_usbhs/common.h b/drivers/usb/renesas_usbhs/common.h index dddf40a59ded..c69dd2fba360 100644 --- a/drivers/usb/renesas_usbhs/common.h +++ b/drivers/usb/renesas_usbhs/common.h @@ -285,6 +285,7 @@ void usbhs_bset(struct usbhs_priv *priv, u32 reg, u16 mask, u16 data); */ void usbhs_sys_host_ctrl(struct usbhs_priv *priv, int enable); void usbhs_sys_function_ctrl(struct usbhs_priv *priv, int enable); +void usbhs_sys_function_pullup(struct usbhs_priv *priv, int enable); void usbhs_sys_set_test_mode(struct usbhs_priv *priv, u16 mode); /* diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c index 28478ce26c34..dd41f61893ef 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c @@ -883,6 +883,16 @@ static int usbhsg_get_frame(struct usb_gadget *gadget) return usbhs_frame_get_num(priv); } +static int usbhsg_pullup(struct usb_gadget *gadget, int is_on) +{ + struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget); + struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv); + + usbhs_sys_function_pullup(priv, is_on); + + return 0; +} + static int usbhsg_set_selfpowered(struct usb_gadget *gadget, int is_self) { struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget); @@ -900,6 +910,7 @@ static struct usb_gadget_ops usbhsg_gadget_ops = { .set_selfpowered = usbhsg_set_selfpowered, .udc_start = usbhsg_gadget_start, .udc_stop = usbhsg_gadget_stop, + .pullup = usbhsg_pullup, }; static int usbhsg_start(struct usbhs_priv *priv) -- cgit v1.2.3 From 797b4e145cfaaa787d91ab692b0956f799e77b7a Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Oct 2012 00:44:41 -0700 Subject: usb: renesas_usbhs: use devm_request_irq() This patch uses devm_request_irq() instead of request_irq(), and removed free_irq() from driver Signed-off-by: Kuninori Morimoto Signed-off-by: Felipe Balbi --- drivers/usb/renesas_usbhs/mod.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/usb/renesas_usbhs') diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c index 35c5208f3249..2672487f5417 100644 --- a/drivers/usb/renesas_usbhs/mod.c +++ b/drivers/usb/renesas_usbhs/mod.c @@ -151,7 +151,7 @@ int usbhs_mod_probe(struct usbhs_priv *priv) goto mod_init_host_err; /* irq settings */ - ret = request_irq(priv->irq, usbhs_interrupt, + ret = devm_request_irq(dev, priv->irq, usbhs_interrupt, priv->irqflags, dev_name(dev), priv); if (ret) { dev_err(dev, "irq request err\n"); @@ -172,7 +172,6 @@ void usbhs_mod_remove(struct usbhs_priv *priv) { usbhs_mod_host_remove(priv); usbhs_mod_gadget_remove(priv); - free_irq(priv->irq, priv); } /* -- cgit v1.2.3 From 3192fcb234895d9f313e7270702e1dc069d4a73a Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Oct 2012 00:45:07 -0700 Subject: usb: renesas_usbhs: fixup unreadable macro mod.h has irq_bempsts/irq_brdysts to keep each irq status, but it was difficult to find where they were used on renesas_usbhs driver by using "grep irq_xxxx" command, since it used irq_##status macro. This patch fixup them Signed-off-by: Kuninori Morimoto Signed-off-by: Felipe Balbi --- drivers/usb/renesas_usbhs/fifo.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/usb/renesas_usbhs') diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c index 143c4e9e1be4..3818c8290825 100644 --- a/drivers/usb/renesas_usbhs/fifo.c +++ b/drivers/usb/renesas_usbhs/fifo.c @@ -192,8 +192,8 @@ void usbhs_pkt_start(struct usbhs_pipe *pipe) /* * irq enable/disable function */ -#define usbhsf_irq_empty_ctrl(p, e) usbhsf_irq_callback_ctrl(p, bempsts, e) -#define usbhsf_irq_ready_ctrl(p, e) usbhsf_irq_callback_ctrl(p, brdysts, e) +#define usbhsf_irq_empty_ctrl(p, e) usbhsf_irq_callback_ctrl(p, irq_bempsts, e) +#define usbhsf_irq_ready_ctrl(p, e) usbhsf_irq_callback_ctrl(p, irq_brdysts, e) #define usbhsf_irq_callback_ctrl(pipe, status, enable) \ ({ \ struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); \ @@ -202,9 +202,9 @@ void usbhs_pkt_start(struct usbhs_pipe *pipe) if (!mod) \ return; \ if (enable) \ - mod->irq_##status |= status; \ + mod->status |= status; \ else \ - mod->irq_##status &= ~status; \ + mod->status &= ~status; \ usbhs_irq_callback_update(priv, mod); \ }) -- cgit v1.2.3 From 87c2905fd80da736b8f9aa58cbc0c9cf34a11aac Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Oct 2012 00:45:24 -0700 Subject: usb: renesas_usbhs: add DMAEngine support on mod_host This patch enabled dma mapping, and used dma transfer handler on mod_host Signed-off-by: Kuninori Morimoto Signed-off-by: Felipe Balbi --- drivers/usb/renesas_usbhs/mod_host.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'drivers/usb/renesas_usbhs') diff --git a/drivers/usb/renesas_usbhs/mod_host.c b/drivers/usb/renesas_usbhs/mod_host.c index 9b69a1323294..e856b449e28a 100644 --- a/drivers/usb/renesas_usbhs/mod_host.c +++ b/drivers/usb/renesas_usbhs/mod_host.c @@ -681,9 +681,9 @@ static int usbhsh_queue_push(struct usb_hcd *hcd, } if (usb_pipein(urb->pipe)) - pipe->handler = &usbhs_fifo_pio_pop_handler; + pipe->handler = &usbhs_fifo_dma_pop_handler; else - pipe->handler = &usbhs_fifo_pio_push_handler; + pipe->handler = &usbhs_fifo_dma_push_handler; buf = (void *)(urb->transfer_buffer + urb->actual_length); len = urb->transfer_buffer_length - urb->actual_length; @@ -916,6 +916,19 @@ static int usbhsh_dcp_queue_push(struct usb_hcd *hcd, */ static int usbhsh_dma_map_ctrl(struct usbhs_pkt *pkt, int map) { + if (map) { + struct usbhsh_request *ureq = usbhsh_pkt_to_ureq(pkt); + struct urb *urb = ureq->urb; + + /* it can not use scatter/gather */ + if (urb->num_sgs) + return -EINVAL; + + pkt->dma = urb->transfer_dma; + if (!pkt->dma) + return -EINVAL; + } + return 0; } -- cgit v1.2.3 From 984e833c2bb6cba11e7cbc84c0dfb7b43792ff80 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Thu, 1 Nov 2012 00:03:51 +0900 Subject: usb: fix typo in drivers/usb Correct spelling typo in debug messages within drivers/usb. Acked-by: Greg Kroah-Hartman Signed-off-by: Masanari Iida Signed-off-by: Felipe Balbi --- drivers/usb/gadget/fsl_udc_core.c | 2 +- drivers/usb/gadget/tcm_usb_gadget.c | 2 +- drivers/usb/musb/musb_dsps.c | 2 +- drivers/usb/renesas_usbhs/fifo.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/usb/renesas_usbhs') diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c index 6ae70cba0c4a..c19f7f13790b 100644 --- a/drivers/usb/gadget/fsl_udc_core.c +++ b/drivers/usb/gadget/fsl_udc_core.c @@ -2126,7 +2126,7 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, tmp_reg = fsl_readl(&dr_regs->usbintr); t = scnprintf(next, size, - "USB Intrrupt Enable Reg:\n" + "USB Interrupt Enable Reg:\n" "Sleep Enable: %d SOF Received Enable: %d " "Reset Enable: %d\n" "System Error Enable: %d " diff --git a/drivers/usb/gadget/tcm_usb_gadget.c b/drivers/usb/gadget/tcm_usb_gadget.c index 27a2337f9868..4f7f76f00c74 100644 --- a/drivers/usb/gadget/tcm_usb_gadget.c +++ b/drivers/usb/gadget/tcm_usb_gadget.c @@ -1384,7 +1384,7 @@ static struct se_node_acl *usbg_alloc_fabric_acl(struct se_portal_group *se_tpg) nacl = kzalloc(sizeof(struct usbg_nacl), GFP_KERNEL); if (!nacl) { - printk(KERN_ERR "Unable to alocate struct usbg_nacl\n"); + printk(KERN_ERR "Unable to allocate struct usbg_nacl\n"); return NULL; } diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 444346e1e10d..2cb8780d0dae 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -296,7 +296,7 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) * Also, DRVVBUS pulses for SRP (but not at 5V) ... */ if (usbintr & MUSB_INTR_BABBLE) - pr_info("CAUTION: musb: Babble Interrupt Occured\n"); + pr_info("CAUTION: musb: Babble Interrupt Occurred\n"); if (usbintr & ((1 << wrp->drvvbus) << wrp->usb_shift)) { int drvvbus = dsps_readl(reg_base, wrp->status); diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c index 3818c8290825..77f1adc2a4fc 100644 --- a/drivers/usb/renesas_usbhs/fifo.c +++ b/drivers/usb/renesas_usbhs/fifo.c @@ -163,7 +163,7 @@ static int usbhsf_pkt_handler(struct usbhs_pipe *pipe, int type) func = pkt->handler->dma_done; break; default: - dev_err(dev, "unknown pkt hander\n"); + dev_err(dev, "unknown pkt handler\n"); goto __usbhs_pkt_handler_end; } -- cgit v1.2.3 From 24e4c1c30da3926db547aab4ec873afdc60bd3ee Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 6 Nov 2012 00:11:32 -0800 Subject: usb: renesas_usbhs: remove debug information from usbhsh_hub_status_data() Because usbhsh_hub_status_data() will be called many times, there are too many obstructive/useless debug informations if driver has #define DEBUG. Thus, other important dev_dbg() information will hide. This patch removed obstructive/useless dev_dbg(). Signed-off-by: Kuninori Morimoto Signed-off-by: Felipe Balbi --- drivers/usb/renesas_usbhs/mod_host.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'drivers/usb/renesas_usbhs') diff --git a/drivers/usb/renesas_usbhs/mod_host.c b/drivers/usb/renesas_usbhs/mod_host.c index e856b449e28a..33f706387237 100644 --- a/drivers/usb/renesas_usbhs/mod_host.c +++ b/drivers/usb/renesas_usbhs/mod_host.c @@ -1080,8 +1080,6 @@ static void usbhsh_endpoint_disable(struct usb_hcd *hcd, static int usbhsh_hub_status_data(struct usb_hcd *hcd, char *buf) { struct usbhsh_hpriv *hpriv = usbhsh_hcd_to_hpriv(hcd); - struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv); - struct device *dev = usbhs_priv_to_dev(priv); int roothub_id = 1; /* only 1 root hub */ /* @@ -1093,8 +1091,6 @@ static int usbhsh_hub_status_data(struct usb_hcd *hcd, char *buf) else *buf = 0; - dev_dbg(dev, "%s (%02x)\n", __func__, *buf); - return !!(*buf); } -- cgit v1.2.3 From 7b332e5fef480ee14d133d9b83af22d03819368e Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 6 Nov 2012 00:11:53 -0800 Subject: usb: renesas_usbhs: host: add endpoint user counter renesas_usbhs attaches pipe to endpoint when urb was queued, and it will be detached when transfer was done. Multi device controlling was enabled by this behavior. Now renesas_usbhs driver tried to wait until detaching if urb was queued to endpoint which already has been attached to pipe, and it created strange driver behavior. But it can re-use this attached pipe if multi urb was queued. This patch implements it. Signed-off-by: Kuninori Morimoto Signed-off-by: Felipe Balbi --- drivers/usb/renesas_usbhs/mod_host.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'drivers/usb/renesas_usbhs') diff --git a/drivers/usb/renesas_usbhs/mod_host.c b/drivers/usb/renesas_usbhs/mod_host.c index 33f706387237..73c5039f7670 100644 --- a/drivers/usb/renesas_usbhs/mod_host.c +++ b/drivers/usb/renesas_usbhs/mod_host.c @@ -85,6 +85,7 @@ struct usbhsh_ep { struct usbhsh_device *udev; /* attached udev */ struct usb_host_endpoint *ep; struct list_head ep_list; /* list to usbhsh_device */ + unsigned int counter; /* pipe attach counter */ }; #define USBHSH_DEVICE_MAX 10 /* see DEVADDn / DCPMAXP / PIPEMAXP */ @@ -271,8 +272,12 @@ static int usbhsh_pipe_attach(struct usbhsh_hpriv *hpriv, /******************** spin lock ********************/ usbhs_lock(priv, flags); - if (unlikely(usbhsh_uep_to_pipe(uep))) { - dev_err(dev, "uep already has pipe\n"); + /* + * if uep has been attached to pipe, + * reuse it + */ + if (usbhsh_uep_to_pipe(uep)) { + ret = 0; goto usbhsh_pipe_attach_done; } @@ -320,6 +325,9 @@ static int usbhsh_pipe_attach(struct usbhsh_hpriv *hpriv, } usbhsh_pipe_attach_done: + if (0 == ret) + uep->counter++; + usbhs_unlock(priv, flags); /******************** spin unlock ******************/ @@ -341,7 +349,7 @@ static void usbhsh_pipe_detach(struct usbhsh_hpriv *hpriv, if (unlikely(!pipe)) { dev_err(dev, "uep doens't have pipe\n"); - } else { + } else if (1 == uep->counter--) { /* last user */ struct usb_host_endpoint *ep = usbhsh_uep_to_ep(uep); struct usbhsh_device *udev = usbhsh_uep_to_udev(uep); @@ -386,6 +394,7 @@ static int usbhsh_endpoint_attach(struct usbhsh_hpriv *hpriv, /* * init endpoint */ + uep->counter = 0; INIT_LIST_HEAD(&uep->ep_list); list_add_tail(&uep->ep_list, &udev->ep_list_head); @@ -954,7 +963,6 @@ static int usbhsh_urb_enqueue(struct usb_hcd *hcd, struct usb_host_endpoint *ep = urb->ep; struct usbhsh_device *new_udev = NULL; int is_dir_in = usb_pipein(urb->pipe); - int i; int ret; dev_dbg(dev, "%s (%s)\n", __func__, is_dir_in ? "in" : "out"); @@ -1000,13 +1008,7 @@ static int usbhsh_urb_enqueue(struct usb_hcd *hcd, * attach pipe to endpoint * see [image of mod_host] */ - for (i = 0; i < 1024; i++) { - ret = usbhsh_pipe_attach(hpriv, urb); - if (ret < 0) - msleep(100); - else - break; - } + ret = usbhsh_pipe_attach(hpriv, urb); if (ret < 0) { dev_err(dev, "pipe attach failed\n"); goto usbhsh_urb_enqueue_error_free_endpoint; -- cgit v1.2.3 From 1c90ee0b3e30235165180a1a8ee3fb3cbe47d295 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 6 Nov 2012 16:15:09 -0800 Subject: usb: renesas_usbhs: use transfer counter if IN direction bulk pipe received data will break if it was bulk pipe and large data size, because pipe kept BUF PID even though it doesn't have enough buffer. To avoid this issue, renesas_usbhs can use transfer counter. Pipe PID will be NAK if it didn't have enough buffer by this patch. renesas_usbhs has strange address mapping. Thus, it is difficult to calculate transfer counter setting address. This patch use fixed table for it. Signed-off-by: Kuninori Morimoto Signed-off-by: Felipe Balbi --- drivers/usb/renesas_usbhs/fifo.c | 4 ++ drivers/usb/renesas_usbhs/pipe.c | 101 +++++++++++++++++++++++++++++++++++++++ drivers/usb/renesas_usbhs/pipe.h | 1 + 3 files changed, 106 insertions(+) (limited to 'drivers/usb/renesas_usbhs') diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c index 77f1adc2a4fc..72ad3758bd40 100644 --- a/drivers/usb/renesas_usbhs/fifo.c +++ b/drivers/usb/renesas_usbhs/fifo.c @@ -488,6 +488,8 @@ static int usbhsf_pio_try_push(struct usbhs_pkt *pkt, int *is_done) usbhs_pipe_data_sequence(pipe, pkt->sequence); pkt->sequence = -1; /* -1 sequence will be ignored */ + usbhs_pipe_set_trans_count_if_bulk(pipe, pkt->length); + ret = usbhsf_fifo_select(pipe, fifo, 1); if (ret < 0) return 0; @@ -594,6 +596,7 @@ static int usbhsf_prepare_pop(struct usbhs_pkt *pkt, int *is_done) usbhs_pipe_data_sequence(pipe, pkt->sequence); pkt->sequence = -1; /* -1 sequence will be ignored */ + usbhs_pipe_set_trans_count_if_bulk(pipe, pkt->length); usbhs_pipe_enable(pipe); usbhsf_rx_irq_ctrl(pipe, 1); @@ -795,6 +798,7 @@ static void xfer_work(struct work_struct *work) dev_dbg(dev, " %s %d (%d/ %d)\n", fifo->name, usbhs_pipe_number(pipe), pkt->length, pkt->zero); + usbhs_pipe_set_trans_count_if_bulk(pipe, pkt->trans); usbhsf_dma_start(pipe, fifo); dma_async_issue_pending(chan); } diff --git a/drivers/usb/renesas_usbhs/pipe.c b/drivers/usb/renesas_usbhs/pipe.c index 122526cfd32b..7926e1c700f1 100644 --- a/drivers/usb/renesas_usbhs/pipe.c +++ b/drivers/usb/renesas_usbhs/pipe.c @@ -92,6 +92,82 @@ static void usbhsp_pipe_cfg_set(struct usbhs_pipe *pipe, u16 mask, u16 val) __usbhsp_pipe_xxx_set(pipe, DCPCFG, PIPECFG, mask, val); } +/* + * PIPEnTRN/PIPEnTRE functions + */ +static void usbhsp_pipe_trn_set(struct usbhs_pipe *pipe, u16 mask, u16 val) +{ + struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); + struct device *dev = usbhs_priv_to_dev(priv); + int num = usbhs_pipe_number(pipe); + u16 reg; + + /* + * It is impossible to calculate address, + * since PIPEnTRN addresses were mapped randomly. + */ +#define CASE_PIPExTRN(a) \ + case 0x ## a: \ + reg = PIPE ## a ## TRN; \ + break; + + switch (num) { + CASE_PIPExTRN(1); + CASE_PIPExTRN(2); + CASE_PIPExTRN(3); + CASE_PIPExTRN(4); + CASE_PIPExTRN(5); + CASE_PIPExTRN(B); + CASE_PIPExTRN(C); + CASE_PIPExTRN(D); + CASE_PIPExTRN(E); + CASE_PIPExTRN(F); + CASE_PIPExTRN(9); + CASE_PIPExTRN(A); + default: + dev_err(dev, "unknown pipe (%d)\n", num); + return; + } + __usbhsp_pipe_xxx_set(pipe, 0, reg, mask, val); +} + +static void usbhsp_pipe_tre_set(struct usbhs_pipe *pipe, u16 mask, u16 val) +{ + struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); + struct device *dev = usbhs_priv_to_dev(priv); + int num = usbhs_pipe_number(pipe); + u16 reg; + + /* + * It is impossible to calculate address, + * since PIPEnTRE addresses were mapped randomly. + */ +#define CASE_PIPExTRE(a) \ + case 0x ## a: \ + reg = PIPE ## a ## TRE; \ + break; + + switch (num) { + CASE_PIPExTRE(1); + CASE_PIPExTRE(2); + CASE_PIPExTRE(3); + CASE_PIPExTRE(4); + CASE_PIPExTRE(5); + CASE_PIPExTRE(B); + CASE_PIPExTRE(C); + CASE_PIPExTRE(D); + CASE_PIPExTRE(E); + CASE_PIPExTRE(F); + CASE_PIPExTRE(9); + CASE_PIPExTRE(A); + default: + dev_err(dev, "unknown pipe (%d)\n", num); + return; + } + + __usbhsp_pipe_xxx_set(pipe, 0, reg, mask, val); +} + /* * PIPEBUF */ @@ -264,6 +340,31 @@ int usbhs_pipe_is_stall(struct usbhs_pipe *pipe) return (int)(pid == PID_STALL10 || pid == PID_STALL11); } +void usbhs_pipe_set_trans_count_if_bulk(struct usbhs_pipe *pipe, int len) +{ + if (!usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_BULK)) + return; + + /* + * clear and disable transfer counter for IN/OUT pipe + */ + usbhsp_pipe_tre_set(pipe, TRCLR | TRENB, TRCLR); + + /* + * Only IN direction bulk pipe can use transfer count. + * Without using this function, + * received data will break if it was large data size. + * see PIPEnTRN/PIPEnTRE for detail + */ + if (usbhs_pipe_is_dir_in(pipe)) { + int maxp = usbhs_pipe_get_maxpacket(pipe); + + usbhsp_pipe_trn_set(pipe, 0xffff, DIV_ROUND_UP(len, maxp)); + usbhsp_pipe_tre_set(pipe, TRENB, TRENB); /* enable */ + } +} + + /* * pipe setup */ diff --git a/drivers/usb/renesas_usbhs/pipe.h b/drivers/usb/renesas_usbhs/pipe.h index 08786c06dcf1..01b1820eccc5 100644 --- a/drivers/usb/renesas_usbhs/pipe.h +++ b/drivers/usb/renesas_usbhs/pipe.h @@ -88,6 +88,7 @@ void usbhs_pipe_enable(struct usbhs_pipe *pipe); void usbhs_pipe_disable(struct usbhs_pipe *pipe); void usbhs_pipe_stall(struct usbhs_pipe *pipe); int usbhs_pipe_is_stall(struct usbhs_pipe *pipe); +void usbhs_pipe_set_trans_count_if_bulk(struct usbhs_pipe *pipe, int len); void usbhs_pipe_select_fifo(struct usbhs_pipe *pipe, struct usbhs_fifo *fifo); void usbhs_pipe_config_update(struct usbhs_pipe *pipe, u16 devsel, u16 epnum, u16 maxp); -- cgit v1.2.3