aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/renesas_usbhs/pipe.c
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2011-10-11 00:59:46 -0400
committerFelipe Balbi <balbi@ti.com>2011-10-13 13:40:38 -0400
commitf5aa889f725b56934171f9845cf00a17de9cc76c (patch)
treeb46e855a0859294b60c8d605ad9b980e61769cc8 /drivers/usb/renesas_usbhs/pipe.c
parent51b8a0218b885b5e527da776e20022273a838893 (diff)
usb: gadget: renesas_usbhs: remove desc from usbhs_pipe_malloc
Current usbhs_pipe_malloc() used usb_endpoint_descriptor to get necessary information. It was very good for mod_gadget which allocate pipe in runtime, but is not good for mod_host which allocate pipe in initial timing. This patch remove usb_endpoint_descriptor from usbhs_pipe_malloc() Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/renesas_usbhs/pipe.c')
-rw-r--r--drivers/usb/renesas_usbhs/pipe.c69
1 files changed, 34 insertions, 35 deletions
diff --git a/drivers/usb/renesas_usbhs/pipe.c b/drivers/usb/renesas_usbhs/pipe.c
index 3bbbbb403f0..1af19059dd0 100644
--- a/drivers/usb/renesas_usbhs/pipe.c
+++ b/drivers/usb/renesas_usbhs/pipe.c
@@ -311,8 +311,8 @@ static int usbhsp_possible_double_buffer(struct usbhs_pipe *pipe)
311} 311}
312 312
313static u16 usbhsp_setup_pipecfg(struct usbhs_pipe *pipe, 313static u16 usbhsp_setup_pipecfg(struct usbhs_pipe *pipe,
314 const struct usb_endpoint_descriptor *desc, 314 int is_host,
315 int is_host) 315 int dir_in)
316{ 316{
317 u16 type = 0; 317 u16 type = 0;
318 u16 bfre = 0; 318 u16 bfre = 0;
@@ -358,11 +358,11 @@ static u16 usbhsp_setup_pipecfg(struct usbhs_pipe *pipe,
358 cntmd = 0; /* FIXME */ 358 cntmd = 0; /* FIXME */
359 359
360 /* DIR */ 360 /* DIR */
361 if (usb_endpoint_dir_in(desc)) 361 if (dir_in)
362 usbhsp_flags_set(pipe, IS_DIR_HOST); 362 usbhsp_flags_set(pipe, IS_DIR_HOST);
363 363
364 if ((is_host && usb_endpoint_dir_out(desc)) || 364 if ((is_host && !dir_in) ||
365 (!is_host && usb_endpoint_dir_in(desc))) 365 (!is_host && dir_in))
366 dir |= DIR_OUT; 366 dir |= DIR_OUT;
367 367
368 if (!dir) 368 if (!dir)
@@ -374,7 +374,7 @@ static u16 usbhsp_setup_pipecfg(struct usbhs_pipe *pipe,
374 shtnak = SHTNAK; 374 shtnak = SHTNAK;
375 375
376 /* EPNUM */ 376 /* EPNUM */
377 epnum = 0xF & usb_endpoint_num(desc); 377 epnum = 0; /* see usbhs_pipe_config_update() */
378 378
379 return type | 379 return type |
380 bfre | 380 bfre |
@@ -385,19 +385,7 @@ static u16 usbhsp_setup_pipecfg(struct usbhs_pipe *pipe,
385 epnum; 385 epnum;
386} 386}
387 387
388static u16 usbhsp_setup_pipemaxp(struct usbhs_pipe *pipe, 388static u16 usbhsp_setup_pipebuff(struct usbhs_pipe *pipe)
389 const struct usb_endpoint_descriptor *desc,
390 int is_host)
391{
392 /* host should set DEVSEL */
393
394 /* reutn MXPS */
395 return PIPE_MAXP_MASK & usb_endpoint_maxp(desc);
396}
397
398static u16 usbhsp_setup_pipebuff(struct usbhs_pipe *pipe,
399 const struct usb_endpoint_descriptor *desc,
400 int is_host)
401{ 389{
402 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); 390 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
403 struct usbhs_pipe_info *info = usbhs_priv_to_pipeinfo(priv); 391 struct usbhs_pipe_info *info = usbhs_priv_to_pipeinfo(priv);
@@ -473,6 +461,17 @@ static u16 usbhsp_setup_pipebuff(struct usbhs_pipe *pipe,
473 (0xff & bufnmb) << 0; 461 (0xff & bufnmb) << 0;
474} 462}
475 463
464void usbhs_pipe_config_update(struct usbhs_pipe *pipe, u16 epnum, u16 maxp)
465{
466 usbhsp_pipe_barrier(pipe);
467
468 usbhsp_pipe_select(pipe);
469 usbhsp_pipe_maxp_set(pipe, 0xFFFF, maxp);
470
471 if (!usbhs_pipe_is_dcp(pipe))
472 usbhsp_pipe_cfg_set(pipe, 0x000F, epnum);
473}
474
476/* 475/*
477 * pipe control 476 * pipe control
478 */ 477 */
@@ -582,19 +581,20 @@ void usbhs_pipe_init(struct usbhs_priv *priv,
582} 581}
583 582
584struct usbhs_pipe *usbhs_pipe_malloc(struct usbhs_priv *priv, 583struct usbhs_pipe *usbhs_pipe_malloc(struct usbhs_priv *priv,
585 const struct usb_endpoint_descriptor *desc) 584 int endpoint_type,
585 int dir_in)
586{ 586{
587 struct device *dev = usbhs_priv_to_dev(priv); 587 struct device *dev = usbhs_priv_to_dev(priv);
588 struct usbhs_mod *mod = usbhs_mod_get_current(priv); 588 struct usbhs_mod *mod = usbhs_mod_get_current(priv);
589 struct usbhs_pipe *pipe; 589 struct usbhs_pipe *pipe;
590 int is_host = usbhs_mod_is_host(priv, mod); 590 int is_host = usbhs_mod_is_host(priv, mod);
591 int ret; 591 int ret;
592 u16 pipecfg, pipebuf, pipemaxp; 592 u16 pipecfg, pipebuf;
593 593
594 pipe = usbhsp_get_pipe(priv, usb_endpoint_type(desc)); 594 pipe = usbhsp_get_pipe(priv, endpoint_type);
595 if (!pipe) { 595 if (!pipe) {
596 dev_err(dev, "can't get pipe (%s)\n", 596 dev_err(dev, "can't get pipe (%s)\n",
597 usbhsp_pipe_name[usb_endpoint_type(desc)]); 597 usbhsp_pipe_name[endpoint_type]);
598 return NULL; 598 return NULL;
599 } 599 }
600 600
@@ -609,22 +609,25 @@ struct usbhs_pipe *usbhs_pipe_malloc(struct usbhs_priv *priv,
609 return NULL; 609 return NULL;
610 } 610 }
611 611
612 pipecfg = usbhsp_setup_pipecfg(pipe, desc, is_host); 612 pipecfg = usbhsp_setup_pipecfg(pipe, is_host, dir_in);
613 pipebuf = usbhsp_setup_pipebuff(pipe, desc, is_host); 613 pipebuf = usbhsp_setup_pipebuff(pipe);
614 pipemaxp = usbhsp_setup_pipemaxp(pipe, desc, is_host);
615 614
616 usbhsp_pipe_select(pipe); 615 usbhsp_pipe_select(pipe);
617 usbhsp_pipe_cfg_set(pipe, 0xFFFF, pipecfg); 616 usbhsp_pipe_cfg_set(pipe, 0xFFFF, pipecfg);
618 usbhsp_pipe_buf_set(pipe, 0xFFFF, pipebuf); 617 usbhsp_pipe_buf_set(pipe, 0xFFFF, pipebuf);
619 usbhsp_pipe_maxp_set(pipe, 0xFFFF, pipemaxp);
620 618
621 usbhs_pipe_clear_sequence(pipe); 619 usbhs_pipe_clear_sequence(pipe);
622 620
623 dev_dbg(dev, "enable pipe %d : %s (%s)\n", 621 dev_dbg(dev, "enable pipe %d : %s (%s)\n",
624 usbhs_pipe_number(pipe), 622 usbhs_pipe_number(pipe),
625 usbhsp_pipe_name[usb_endpoint_type(desc)], 623 usbhsp_pipe_name[endpoint_type],
626 usbhs_pipe_is_dir_in(pipe) ? "in" : "out"); 624 usbhs_pipe_is_dir_in(pipe) ? "in" : "out");
627 625
626 /*
627 * epnum / maxp are still not set to this pipe.
628 * call usbhs_pipe_config_update() after this function !!
629 */
630
628 return pipe; 631 return pipe;
629} 632}
630 633
@@ -651,16 +654,12 @@ struct usbhs_pipe *usbhs_dcp_malloc(struct usbhs_priv *priv)
651 if (!pipe) 654 if (!pipe)
652 return NULL; 655 return NULL;
653 656
657 INIT_LIST_HEAD(&pipe->list);
658
654 /* 659 /*
655 * dcpcfg : default 660 * call usbhs_pipe_config_update() after this function !!
656 * dcpmaxp : default
657 * pipebuf : nothing to do
658 */ 661 */
659 662
660 usbhsp_pipe_select(pipe);
661 usbhs_pipe_clear_sequence(pipe);
662 INIT_LIST_HEAD(&pipe->list);
663
664 return pipe; 663 return pipe;
665} 664}
666 665