18 #include <linux/slab.h>
25 #define usbhsp_addr_offset(p) ((usbhs_pipe_number(p) - 1) * 2)
27 #define usbhsp_flags_set(p, f) ((p)->flags |= USBHS_PIPE_FLAGS_##f)
28 #define usbhsp_flags_clr(p, f) ((p)->flags &= ~USBHS_PIPE_FLAGS_##f)
29 #define usbhsp_flags_has(p, f) ((p)->flags & USBHS_PIPE_FLAGS_##f)
30 #define usbhsp_flags_init(p) do {(p)->flags = 0; } while (0)
35 static char *usbhsp_pipe_name[] = {
75 static void __usbhsp_pipe_xxx_set(
struct usbhs_pipe *pipe,
103 __usbhsp_pipe_xxx_set(pipe, 0,
PIPEBUF, mask, val);
109 static void usbhsp_pipe_maxp_set(
struct usbhs_pipe *pipe,
u16 mask,
u16 val)
117 static void usbhsp_pipe_select(
struct usbhs_pipe *pipe)
139 static int usbhsp_pipe_barrier(
struct usbhs_pipe *pipe)
167 val = usbhsp_pipectrl_get(pipe);
183 val = usbhsp_pipectrl_get(pipe);
193 static void __usbhsp_pid_try_nak_if_stall(
struct usbhs_pipe *pipe)
195 u16 pid = usbhsp_pipectrl_get(pipe);
218 __usbhsp_pid_try_nak_if_stall(pipe);
223 val = usbhsp_pipectrl_get(pipe);
235 __usbhsp_pid_try_nak_if_stall(pipe);
242 u16 pid = usbhsp_pipectrl_get(pipe);
270 static int usbhsp_possible_double_buffer(
struct usbhs_pipe *pipe)
298 int is_double = usbhsp_possible_double_buffer(pipe);
323 dblb = (is_double) ?
DBLB : 0;
333 if (!!is_host ^ !!dir_in)
362 int is_double = usbhsp_possible_double_buffer(pipe);
408 bufnmb_cnt = (buff_size / 64) - 1;
413 bufnmb = pipe_num - 2;
425 dev_dbg(dev,
"pipe : %d : buff_size 0x%x: bufnmb 0x%x\n",
426 pipe_num, buff_size, bufnmb);
428 return (0x1f & bufnmb_cnt) << 10 |
429 (0xff & bufnmb) << 0;
439 dev_err(dev,
"devsel error %d\n", devsel);
444 usbhsp_pipe_barrier(pipe);
448 usbhsp_pipe_select(pipe);
449 usbhsp_pipe_maxp_set(pipe, 0xFFFF,
454 usbhsp_pipe_cfg_set(pipe, 0x000F, epnum);
502 usbhsp_pipectrl_set(pipe, mask, val);
508 usbhsp_pipectrl_set(pipe,
ACLRM, 0);
569 INIT_LIST_HEAD(&pipe->
list);
586 u16 pipecfg, pipebuf;
588 pipe = usbhsp_get_pipe(priv, endpoint_type);
590 dev_err(dev,
"can't get pipe (%s)\n",
591 usbhsp_pipe_name[endpoint_type]);
595 INIT_LIST_HEAD(&pipe->
list);
600 ret = usbhsp_pipe_barrier(pipe);
606 pipecfg = usbhsp_setup_pipecfg(pipe, is_host, dir_in);
607 pipebuf = usbhsp_setup_pipebuff(pipe);
609 usbhsp_pipe_select(pipe);
610 usbhsp_pipe_cfg_set(pipe, 0xFFFF, pipecfg);
611 usbhsp_pipe_buf_set(pipe, 0xFFFF, pipebuf);
615 dev_dbg(dev,
"enable pipe %d : %s (%s)\n",
651 INIT_LIST_HEAD(&pipe->
list);
669 usbhsp_pipectrl_set(pipe,
CCPL,
CCPL);
674 usbhsp_pipe_cfg_set(pipe,
DIR_OUT,
692 dev_err(dev,
"1st PIPE is not DCP\n");
698 dev_err(dev,
"Could not allocate pipe\n");
702 info->
size = pipe_size;
713 dev_dbg(dev,
"pipe %x\t: %s\n",
714 i, usbhsp_pipe_name[pipe_type[i]]);