diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2011-10-11 00:59:46 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2011-10-13 13:40:38 -0400 |
commit | f5aa889f725b56934171f9845cf00a17de9cc76c (patch) | |
tree | b46e855a0859294b60c8d605ad9b980e61769cc8 /drivers/usb/renesas_usbhs | |
parent | 51b8a0218b885b5e527da776e20022273a838893 (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')
-rw-r--r-- | drivers/usb/renesas_usbhs/mod_gadget.c | 10 | ||||
-rw-r--r-- | drivers/usb/renesas_usbhs/pipe.c | 69 | ||||
-rw-r--r-- | drivers/usb/renesas_usbhs/pipe.h | 4 |
3 files changed, 45 insertions, 38 deletions
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c index c5c9ee5abb7a..5a697b76ff12 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c | |||
@@ -483,11 +483,18 @@ static int usbhsg_ep_enable(struct usb_ep *ep, | |||
483 | return 0; | 483 | return 0; |
484 | } | 484 | } |
485 | 485 | ||
486 | pipe = usbhs_pipe_malloc(priv, desc); | 486 | pipe = usbhs_pipe_malloc(priv, |
487 | usb_endpoint_type(desc), | ||
488 | usb_endpoint_dir_in(desc)); | ||
487 | if (pipe) { | 489 | if (pipe) { |
488 | uep->pipe = pipe; | 490 | uep->pipe = pipe; |
489 | pipe->mod_private = uep; | 491 | pipe->mod_private = uep; |
490 | 492 | ||
493 | /* set epnum / maxp */ | ||
494 | usbhs_pipe_config_update(pipe, | ||
495 | usb_endpoint_num(desc), | ||
496 | usb_endpoint_maxp(desc)); | ||
497 | |||
491 | /* | 498 | /* |
492 | * usbhs_fifo_dma_push/pop_handler try to | 499 | * usbhs_fifo_dma_push/pop_handler try to |
493 | * use dmaengine if possible. | 500 | * use dmaengine if possible. |
@@ -667,6 +674,7 @@ static int usbhsg_try_start(struct usbhs_priv *priv, u32 status) | |||
667 | /* dcp init */ | 674 | /* dcp init */ |
668 | dcp->pipe = usbhs_dcp_malloc(priv); | 675 | dcp->pipe = usbhs_dcp_malloc(priv); |
669 | dcp->pipe->mod_private = dcp; | 676 | dcp->pipe->mod_private = dcp; |
677 | usbhs_pipe_config_update(dcp->pipe, 0, 64); | ||
670 | 678 | ||
671 | /* | 679 | /* |
672 | * system config enble | 680 | * system config enble |
diff --git a/drivers/usb/renesas_usbhs/pipe.c b/drivers/usb/renesas_usbhs/pipe.c index 3bbbbb403f01..1af19059dd02 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 | ||
313 | static u16 usbhsp_setup_pipecfg(struct usbhs_pipe *pipe, | 313 | static 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 | ||
388 | static u16 usbhsp_setup_pipemaxp(struct usbhs_pipe *pipe, | 388 | static 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 | |||
398 | static 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 | ||
464 | void 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 | ||
584 | struct usbhs_pipe *usbhs_pipe_malloc(struct usbhs_priv *priv, | 583 | struct 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 | ||
diff --git a/drivers/usb/renesas_usbhs/pipe.h b/drivers/usb/renesas_usbhs/pipe.h index 41534cb0e734..46707b5ecb75 100644 --- a/drivers/usb/renesas_usbhs/pipe.h +++ b/drivers/usb/renesas_usbhs/pipe.h | |||
@@ -76,8 +76,7 @@ void usbhs_usbreq_set_val(struct usbhs_priv *priv, struct usb_ctrlrequest *req); | |||
76 | * pipe control | 76 | * pipe control |
77 | */ | 77 | */ |
78 | struct usbhs_pipe | 78 | struct usbhs_pipe |
79 | *usbhs_pipe_malloc(struct usbhs_priv *priv, | 79 | *usbhs_pipe_malloc(struct usbhs_priv *priv, int endpoint_type, int dir_in); |
80 | const struct usb_endpoint_descriptor *desc); | ||
81 | int usbhs_pipe_probe(struct usbhs_priv *priv); | 80 | int usbhs_pipe_probe(struct usbhs_priv *priv); |
82 | void usbhs_pipe_remove(struct usbhs_priv *priv); | 81 | void usbhs_pipe_remove(struct usbhs_priv *priv); |
83 | int usbhs_pipe_is_dir_in(struct usbhs_pipe *pipe); | 82 | int usbhs_pipe_is_dir_in(struct usbhs_pipe *pipe); |
@@ -93,6 +92,7 @@ void usbhs_pipe_enable(struct usbhs_pipe *pipe); | |||
93 | void usbhs_pipe_disable(struct usbhs_pipe *pipe); | 92 | void usbhs_pipe_disable(struct usbhs_pipe *pipe); |
94 | void usbhs_pipe_stall(struct usbhs_pipe *pipe); | 93 | void usbhs_pipe_stall(struct usbhs_pipe *pipe); |
95 | void usbhs_pipe_select_fifo(struct usbhs_pipe *pipe, struct usbhs_fifo *fifo); | 94 | void usbhs_pipe_select_fifo(struct usbhs_pipe *pipe, struct usbhs_fifo *fifo); |
95 | void usbhs_pipe_config_update(struct usbhs_pipe *pipe, u16 epnum, u16 maxp); | ||
96 | 96 | ||
97 | #define usbhs_pipe_to_priv(p) ((p)->priv) | 97 | #define usbhs_pipe_to_priv(p) ((p)->priv) |
98 | #define usbhs_pipe_number(p) (int)((p) - (p)->priv->pipe_info.pipe) | 98 | #define usbhs_pipe_number(p) (int)((p) - (p)->priv->pipe_info.pipe) |