Lines Matching refs:pipe

42 char *usbhs_pipe_name(struct usbhs_pipe *pipe)  in usbhs_pipe_name()  argument
44 return usbhsp_pipe_name[usbhs_pipe_type(pipe)]; in usbhs_pipe_name()
50 static void usbhsp_pipectrl_set(struct usbhs_pipe *pipe, u16 mask, u16 val) in usbhsp_pipectrl_set() argument
52 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); in usbhsp_pipectrl_set()
53 int offset = usbhsp_addr_offset(pipe); in usbhsp_pipectrl_set()
55 if (usbhs_pipe_is_dcp(pipe)) in usbhsp_pipectrl_set()
61 static u16 usbhsp_pipectrl_get(struct usbhs_pipe *pipe) in usbhsp_pipectrl_get() argument
63 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); in usbhsp_pipectrl_get()
64 int offset = usbhsp_addr_offset(pipe); in usbhsp_pipectrl_get()
66 if (usbhs_pipe_is_dcp(pipe)) in usbhsp_pipectrl_get()
75 static void __usbhsp_pipe_xxx_set(struct usbhs_pipe *pipe, in __usbhsp_pipe_xxx_set() argument
79 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); in __usbhsp_pipe_xxx_set()
81 if (usbhs_pipe_is_dcp(pipe)) in __usbhsp_pipe_xxx_set()
87 static u16 __usbhsp_pipe_xxx_get(struct usbhs_pipe *pipe, in __usbhsp_pipe_xxx_get() argument
90 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); in __usbhsp_pipe_xxx_get()
92 if (usbhs_pipe_is_dcp(pipe)) in __usbhsp_pipe_xxx_get()
101 static void usbhsp_pipe_cfg_set(struct usbhs_pipe *pipe, u16 mask, u16 val) in usbhsp_pipe_cfg_set() argument
103 __usbhsp_pipe_xxx_set(pipe, DCPCFG, PIPECFG, mask, val); in usbhsp_pipe_cfg_set()
106 static u16 usbhsp_pipe_cfg_get(struct usbhs_pipe *pipe) in usbhsp_pipe_cfg_get() argument
108 return __usbhsp_pipe_xxx_get(pipe, DCPCFG, PIPECFG); in usbhsp_pipe_cfg_get()
114 static void usbhsp_pipe_trn_set(struct usbhs_pipe *pipe, u16 mask, u16 val) in usbhsp_pipe_trn_set() argument
116 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); in usbhsp_pipe_trn_set()
118 int num = usbhs_pipe_number(pipe); in usbhsp_pipe_trn_set()
147 __usbhsp_pipe_xxx_set(pipe, 0, reg, mask, val); in usbhsp_pipe_trn_set()
150 static void usbhsp_pipe_tre_set(struct usbhs_pipe *pipe, u16 mask, u16 val) in usbhsp_pipe_tre_set() argument
152 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); in usbhsp_pipe_tre_set()
154 int num = usbhs_pipe_number(pipe); in usbhsp_pipe_tre_set()
184 __usbhsp_pipe_xxx_set(pipe, 0, reg, mask, val); in usbhsp_pipe_tre_set()
190 static void usbhsp_pipe_buf_set(struct usbhs_pipe *pipe, u16 mask, u16 val) in usbhsp_pipe_buf_set() argument
192 if (usbhs_pipe_is_dcp(pipe)) in usbhsp_pipe_buf_set()
195 __usbhsp_pipe_xxx_set(pipe, 0, PIPEBUF, mask, val); in usbhsp_pipe_buf_set()
201 static void usbhsp_pipe_maxp_set(struct usbhs_pipe *pipe, u16 mask, u16 val) in usbhsp_pipe_maxp_set() argument
203 __usbhsp_pipe_xxx_set(pipe, DCPMAXP, PIPEMAXP, mask, val); in usbhsp_pipe_maxp_set()
209 static void usbhsp_pipe_select(struct usbhs_pipe *pipe) in usbhsp_pipe_select() argument
211 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); in usbhsp_pipe_select()
228 usbhs_write(priv, PIPESEL, 0xF & usbhs_pipe_number(pipe)); in usbhsp_pipe_select()
231 static int usbhsp_pipe_barrier(struct usbhs_pipe *pipe) in usbhsp_pipe_barrier() argument
233 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); in usbhsp_pipe_barrier()
256 usbhs_pipe_disable(pipe); in usbhsp_pipe_barrier()
259 val = usbhsp_pipectrl_get(pipe); in usbhsp_pipe_barrier()
271 int usbhs_pipe_is_accessible(struct usbhs_pipe *pipe) in usbhs_pipe_is_accessible() argument
275 val = usbhsp_pipectrl_get(pipe); in usbhs_pipe_is_accessible()
285 static void __usbhsp_pid_try_nak_if_stall(struct usbhs_pipe *pipe) in __usbhsp_pid_try_nak_if_stall() argument
287 u16 pid = usbhsp_pipectrl_get(pipe); in __usbhsp_pid_try_nak_if_stall()
297 usbhsp_pipectrl_set(pipe, PID_MASK, PID_STALL10); in __usbhsp_pid_try_nak_if_stall()
300 usbhsp_pipectrl_set(pipe, PID_MASK, PID_NAK); in __usbhsp_pid_try_nak_if_stall()
304 void usbhs_pipe_disable(struct usbhs_pipe *pipe) in usbhs_pipe_disable() argument
310 __usbhsp_pid_try_nak_if_stall(pipe); in usbhs_pipe_disable()
312 usbhsp_pipectrl_set(pipe, PID_MASK, PID_NAK); in usbhs_pipe_disable()
315 val = usbhsp_pipectrl_get(pipe); in usbhs_pipe_disable()
324 void usbhs_pipe_enable(struct usbhs_pipe *pipe) in usbhs_pipe_enable() argument
327 __usbhsp_pid_try_nak_if_stall(pipe); in usbhs_pipe_enable()
329 usbhsp_pipectrl_set(pipe, PID_MASK, PID_BUF); in usbhs_pipe_enable()
332 void usbhs_pipe_stall(struct usbhs_pipe *pipe) in usbhs_pipe_stall() argument
334 u16 pid = usbhsp_pipectrl_get(pipe); in usbhs_pipe_stall()
344 usbhsp_pipectrl_set(pipe, PID_MASK, PID_STALL10); in usbhs_pipe_stall()
347 usbhsp_pipectrl_set(pipe, PID_MASK, PID_STALL11); in usbhs_pipe_stall()
352 int usbhs_pipe_is_stall(struct usbhs_pipe *pipe) in usbhs_pipe_is_stall() argument
354 u16 pid = usbhsp_pipectrl_get(pipe) & PID_MASK; in usbhs_pipe_is_stall()
359 void usbhs_pipe_set_trans_count_if_bulk(struct usbhs_pipe *pipe, int len) in usbhs_pipe_set_trans_count_if_bulk() argument
361 if (!usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_BULK)) in usbhs_pipe_set_trans_count_if_bulk()
367 usbhsp_pipe_tre_set(pipe, TRCLR | TRENB, TRCLR); in usbhs_pipe_set_trans_count_if_bulk()
375 if (usbhs_pipe_is_dir_in(pipe)) { in usbhs_pipe_set_trans_count_if_bulk()
376 int maxp = usbhs_pipe_get_maxpacket(pipe); in usbhs_pipe_set_trans_count_if_bulk()
378 usbhsp_pipe_trn_set(pipe, 0xffff, DIV_ROUND_UP(len, maxp)); in usbhs_pipe_set_trans_count_if_bulk()
379 usbhsp_pipe_tre_set(pipe, TRENB, TRENB); /* enable */ in usbhs_pipe_set_trans_count_if_bulk()
387 static int usbhsp_possible_double_buffer(struct usbhs_pipe *pipe) in usbhsp_possible_double_buffer() argument
392 if (usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_BULK) || in usbhsp_possible_double_buffer()
393 usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_ISOC)) in usbhsp_possible_double_buffer()
399 static u16 usbhsp_setup_pipecfg(struct usbhs_pipe *pipe, in usbhsp_setup_pipecfg() argument
415 int is_double = usbhsp_possible_double_buffer(pipe); in usbhsp_setup_pipecfg()
417 if (usbhs_pipe_is_dcp(pipe)) in usbhsp_setup_pipecfg()
430 type = type_array[usbhs_pipe_type(pipe)]; in usbhsp_setup_pipecfg()
433 if (usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_ISOC) || in usbhsp_setup_pipecfg()
434 usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_BULK)) in usbhsp_setup_pipecfg()
438 if (usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_ISOC) || in usbhsp_setup_pipecfg()
439 usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_BULK)) in usbhsp_setup_pipecfg()
443 if (usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_BULK)) in usbhsp_setup_pipecfg()
448 usbhsp_flags_set(pipe, IS_DIR_HOST); in usbhsp_setup_pipecfg()
454 usbhsp_flags_set(pipe, IS_DIR_IN); in usbhsp_setup_pipecfg()
457 if (usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_BULK) && in usbhsp_setup_pipecfg()
473 static u16 usbhsp_setup_pipebuff(struct usbhs_pipe *pipe) in usbhsp_setup_pipebuff() argument
475 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); in usbhsp_setup_pipebuff()
478 int pipe_num = usbhs_pipe_number(pipe); in usbhsp_setup_pipebuff()
479 int is_double = usbhsp_possible_double_buffer(pipe); in usbhsp_setup_pipebuff()
517 if (usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_CONTROL)) in usbhsp_setup_pipebuff()
519 else if (usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_INT)) in usbhsp_setup_pipebuff()
529 if (usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_INT)) { in usbhsp_setup_pipebuff()
549 void usbhs_pipe_config_update(struct usbhs_pipe *pipe, u16 devsel, in usbhs_pipe_config_update() argument
553 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); in usbhs_pipe_config_update()
561 usbhsp_pipe_barrier(pipe); in usbhs_pipe_config_update()
563 pipe->maxp = maxp; in usbhs_pipe_config_update()
565 usbhsp_pipe_select(pipe); in usbhs_pipe_config_update()
566 usbhsp_pipe_maxp_set(pipe, 0xFFFF, in usbhs_pipe_config_update()
570 if (!usbhs_pipe_is_dcp(pipe)) in usbhs_pipe_config_update()
571 usbhsp_pipe_cfg_set(pipe, 0x000F, epnum); in usbhs_pipe_config_update()
577 int usbhs_pipe_get_maxpacket(struct usbhs_pipe *pipe) in usbhs_pipe_get_maxpacket() argument
584 return pipe->maxp; in usbhs_pipe_get_maxpacket()
587 int usbhs_pipe_is_dir_in(struct usbhs_pipe *pipe) in usbhs_pipe_is_dir_in() argument
589 return usbhsp_flags_has(pipe, IS_DIR_IN); in usbhs_pipe_is_dir_in()
592 int usbhs_pipe_is_dir_host(struct usbhs_pipe *pipe) in usbhs_pipe_is_dir_host() argument
594 return usbhsp_flags_has(pipe, IS_DIR_HOST); in usbhs_pipe_is_dir_host()
597 int usbhs_pipe_is_running(struct usbhs_pipe *pipe) in usbhs_pipe_is_running() argument
599 return usbhsp_flags_has(pipe, IS_RUNNING); in usbhs_pipe_is_running()
602 void usbhs_pipe_running(struct usbhs_pipe *pipe, int running) in usbhs_pipe_running() argument
605 usbhsp_flags_set(pipe, IS_RUNNING); in usbhs_pipe_running()
607 usbhsp_flags_clr(pipe, IS_RUNNING); in usbhs_pipe_running()
610 void usbhs_pipe_data_sequence(struct usbhs_pipe *pipe, int sequence) in usbhs_pipe_data_sequence() argument
632 usbhsp_pipectrl_set(pipe, mask, val); in usbhs_pipe_data_sequence()
635 static int usbhs_pipe_get_data_sequence(struct usbhs_pipe *pipe) in usbhs_pipe_get_data_sequence() argument
637 return !!(usbhsp_pipectrl_get(pipe) & SQMON); in usbhs_pipe_get_data_sequence()
640 void usbhs_pipe_clear(struct usbhs_pipe *pipe) in usbhs_pipe_clear() argument
642 if (usbhs_pipe_is_dcp(pipe)) { in usbhs_pipe_clear()
643 usbhs_fifo_clear_dcp(pipe); in usbhs_pipe_clear()
645 usbhsp_pipectrl_set(pipe, ACLRM, ACLRM); in usbhs_pipe_clear()
646 usbhsp_pipectrl_set(pipe, ACLRM, 0); in usbhs_pipe_clear()
650 void usbhs_pipe_config_change_bfre(struct usbhs_pipe *pipe, int enable) in usbhs_pipe_config_change_bfre() argument
654 if (usbhs_pipe_is_dcp(pipe)) in usbhs_pipe_config_change_bfre()
657 usbhsp_pipe_select(pipe); in usbhs_pipe_config_change_bfre()
659 if (!(enable ^ !!(usbhsp_pipe_cfg_get(pipe) & BFRE))) in usbhs_pipe_config_change_bfre()
662 sequence = usbhs_pipe_get_data_sequence(pipe); in usbhs_pipe_config_change_bfre()
663 usbhsp_pipe_cfg_set(pipe, BFRE, enable ? BFRE : 0); in usbhs_pipe_config_change_bfre()
664 usbhs_pipe_clear(pipe); in usbhs_pipe_config_change_bfre()
665 usbhs_pipe_data_sequence(pipe, sequence); in usbhs_pipe_config_change_bfre()
670 struct usbhs_pipe *pos, *pipe; in usbhsp_get_pipe() local
676 pipe = NULL; in usbhsp_get_pipe()
683 pipe = pos; in usbhsp_get_pipe()
687 if (!pipe) in usbhsp_get_pipe()
693 usbhsp_flags_init(pipe); in usbhsp_get_pipe()
694 usbhsp_flags_set(pipe, IS_USED); in usbhsp_get_pipe()
696 return pipe; in usbhsp_get_pipe()
699 static void usbhsp_put_pipe(struct usbhs_pipe *pipe) in usbhsp_put_pipe() argument
701 usbhsp_flags_init(pipe); in usbhsp_put_pipe()
708 struct usbhs_pipe *pipe; in usbhs_pipe_init() local
724 usbhs_for_each_pipe_with_dcp(pipe, priv, i) { in usbhs_pipe_init()
725 if (usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_INT)) in usbhs_pipe_init()
728 usbhsp_flags_init(pipe); in usbhs_pipe_init()
729 pipe->fifo = NULL; in usbhs_pipe_init()
730 pipe->mod_private = NULL; in usbhs_pipe_init()
731 INIT_LIST_HEAD(&pipe->list); in usbhs_pipe_init()
734 usbhs_pipe_clear(pipe); in usbhs_pipe_init()
745 struct usbhs_pipe *pipe; in usbhs_pipe_malloc() local
750 pipe = usbhsp_get_pipe(priv, endpoint_type); in usbhs_pipe_malloc()
751 if (!pipe) { in usbhs_pipe_malloc()
757 INIT_LIST_HEAD(&pipe->list); in usbhs_pipe_malloc()
759 usbhs_pipe_disable(pipe); in usbhs_pipe_malloc()
762 ret = usbhsp_pipe_barrier(pipe); in usbhs_pipe_malloc()
764 dev_err(dev, "pipe setup failed %d\n", usbhs_pipe_number(pipe)); in usbhs_pipe_malloc()
768 pipecfg = usbhsp_setup_pipecfg(pipe, is_host, dir_in); in usbhs_pipe_malloc()
769 pipebuf = usbhsp_setup_pipebuff(pipe); in usbhs_pipe_malloc()
771 usbhsp_pipe_select(pipe); in usbhs_pipe_malloc()
772 usbhsp_pipe_cfg_set(pipe, 0xFFFF, pipecfg); in usbhs_pipe_malloc()
773 usbhsp_pipe_buf_set(pipe, 0xFFFF, pipebuf); in usbhs_pipe_malloc()
774 usbhs_pipe_clear(pipe); in usbhs_pipe_malloc()
776 usbhs_pipe_sequence_data0(pipe); in usbhs_pipe_malloc()
779 usbhs_pipe_number(pipe), in usbhs_pipe_malloc()
780 usbhs_pipe_name(pipe), in usbhs_pipe_malloc()
781 usbhs_pipe_is_dir_in(pipe) ? "in" : "out"); in usbhs_pipe_malloc()
788 return pipe; in usbhs_pipe_malloc()
791 void usbhs_pipe_free(struct usbhs_pipe *pipe) in usbhs_pipe_free() argument
793 usbhsp_put_pipe(pipe); in usbhs_pipe_free()
796 void usbhs_pipe_select_fifo(struct usbhs_pipe *pipe, struct usbhs_fifo *fifo) in usbhs_pipe_select_fifo() argument
798 if (pipe->fifo) in usbhs_pipe_select_fifo()
799 pipe->fifo->pipe = NULL; in usbhs_pipe_select_fifo()
801 pipe->fifo = fifo; in usbhs_pipe_select_fifo()
804 fifo->pipe = pipe; in usbhs_pipe_select_fifo()
813 struct usbhs_pipe *pipe; in usbhs_dcp_malloc() local
815 pipe = usbhsp_get_pipe(priv, USB_ENDPOINT_XFER_CONTROL); in usbhs_dcp_malloc()
816 if (!pipe) in usbhs_dcp_malloc()
819 INIT_LIST_HEAD(&pipe->list); in usbhs_dcp_malloc()
825 return pipe; in usbhs_dcp_malloc()
828 void usbhs_dcp_control_transfer_done(struct usbhs_pipe *pipe) in usbhs_dcp_control_transfer_done() argument
830 struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); in usbhs_dcp_control_transfer_done()
832 WARN_ON(!usbhs_pipe_is_dcp(pipe)); in usbhs_dcp_control_transfer_done()
834 usbhs_pipe_enable(pipe); in usbhs_dcp_control_transfer_done()
837 usbhsp_pipectrl_set(pipe, CCPL, CCPL); in usbhs_dcp_control_transfer_done()
840 void usbhs_dcp_dir_for_host(struct usbhs_pipe *pipe, int dir_out) in usbhs_dcp_dir_for_host() argument
842 usbhsp_pipe_cfg_set(pipe, DIR_OUT, in usbhs_dcp_dir_for_host()
852 struct usbhs_pipe *pipe; in usbhs_pipe_probe() local
864 info->pipe = kzalloc(sizeof(struct usbhs_pipe) * pipe_size, GFP_KERNEL); in usbhs_pipe_probe()
865 if (!info->pipe) { in usbhs_pipe_probe()
875 usbhs_for_each_pipe_with_dcp(pipe, priv, i) { in usbhs_pipe_probe()
876 pipe->priv = priv; in usbhs_pipe_probe()
878 usbhs_pipe_type(pipe) = in usbhs_pipe_probe()
892 kfree(info->pipe); in usbhs_pipe_remove()