Lines Matching refs:m66592
34 static void disable_controller(struct m66592 *m66592);
44 static inline u16 get_usb_speed(struct m66592 *m66592) in get_usb_speed() argument
46 return (m66592_read(m66592, M66592_DVSTCTR) & M66592_RHST); in get_usb_speed()
49 static void enable_pipe_irq(struct m66592 *m66592, u16 pipenum, in enable_pipe_irq() argument
54 tmp = m66592_read(m66592, M66592_INTENB0); in enable_pipe_irq()
55 m66592_bclr(m66592, M66592_BEMPE | M66592_NRDYE | M66592_BRDYE, in enable_pipe_irq()
57 m66592_bset(m66592, (1 << pipenum), reg); in enable_pipe_irq()
58 m66592_write(m66592, tmp, M66592_INTENB0); in enable_pipe_irq()
61 static void disable_pipe_irq(struct m66592 *m66592, u16 pipenum, in disable_pipe_irq() argument
66 tmp = m66592_read(m66592, M66592_INTENB0); in disable_pipe_irq()
67 m66592_bclr(m66592, M66592_BEMPE | M66592_NRDYE | M66592_BRDYE, in disable_pipe_irq()
69 m66592_bclr(m66592, (1 << pipenum), reg); in disable_pipe_irq()
70 m66592_write(m66592, tmp, M66592_INTENB0); in disable_pipe_irq()
73 static void m66592_usb_connect(struct m66592 *m66592) in m66592_usb_connect() argument
75 m66592_bset(m66592, M66592_CTRE, M66592_INTENB0); in m66592_usb_connect()
76 m66592_bset(m66592, M66592_WDST | M66592_RDST | M66592_CMPL, in m66592_usb_connect()
78 m66592_bset(m66592, M66592_BEMPE | M66592_BRDYE, M66592_INTENB0); in m66592_usb_connect()
80 m66592_bset(m66592, M66592_DPRPU, M66592_SYSCFG); in m66592_usb_connect()
83 static void m66592_usb_disconnect(struct m66592 *m66592) in m66592_usb_disconnect() argument
84 __releases(m66592->lock) in m66592_usb_disconnect()
85 __acquires(m66592->lock) in m66592_usb_disconnect()
87 m66592_bclr(m66592, M66592_CTRE, M66592_INTENB0); in m66592_usb_disconnect()
88 m66592_bclr(m66592, M66592_WDST | M66592_RDST | M66592_CMPL, in m66592_usb_disconnect()
90 m66592_bclr(m66592, M66592_BEMPE | M66592_BRDYE, M66592_INTENB0); in m66592_usb_disconnect()
91 m66592_bclr(m66592, M66592_DPRPU, M66592_SYSCFG); in m66592_usb_disconnect()
93 m66592->gadget.speed = USB_SPEED_UNKNOWN; in m66592_usb_disconnect()
94 spin_unlock(&m66592->lock); in m66592_usb_disconnect()
95 m66592->driver->disconnect(&m66592->gadget); in m66592_usb_disconnect()
96 spin_lock(&m66592->lock); in m66592_usb_disconnect()
98 disable_controller(m66592); in m66592_usb_disconnect()
99 INIT_LIST_HEAD(&m66592->ep[0].queue); in m66592_usb_disconnect()
102 static inline u16 control_reg_get_pid(struct m66592 *m66592, u16 pipenum) in control_reg_get_pid() argument
108 pid = m66592_read(m66592, M66592_DCPCTR) & M66592_PID; in control_reg_get_pid()
111 pid = m66592_read(m66592, offset) & M66592_PID; in control_reg_get_pid()
118 static inline void control_reg_set_pid(struct m66592 *m66592, u16 pipenum, in control_reg_set_pid() argument
124 m66592_mdfy(m66592, pid, M66592_PID, M66592_DCPCTR); in control_reg_set_pid()
127 m66592_mdfy(m66592, pid, M66592_PID, offset); in control_reg_set_pid()
132 static inline void pipe_start(struct m66592 *m66592, u16 pipenum) in pipe_start() argument
134 control_reg_set_pid(m66592, pipenum, M66592_PID_BUF); in pipe_start()
137 static inline void pipe_stop(struct m66592 *m66592, u16 pipenum) in pipe_stop() argument
139 control_reg_set_pid(m66592, pipenum, M66592_PID_NAK); in pipe_stop()
142 static inline void pipe_stall(struct m66592 *m66592, u16 pipenum) in pipe_stall() argument
144 control_reg_set_pid(m66592, pipenum, M66592_PID_STALL); in pipe_stall()
147 static inline u16 control_reg_get(struct m66592 *m66592, u16 pipenum) in control_reg_get() argument
153 ret = m66592_read(m66592, M66592_DCPCTR); in control_reg_get()
156 ret = m66592_read(m66592, offset); in control_reg_get()
163 static inline void control_reg_sqclr(struct m66592 *m66592, u16 pipenum) in control_reg_sqclr() argument
167 pipe_stop(m66592, pipenum); in control_reg_sqclr()
170 m66592_bset(m66592, M66592_SQCLR, M66592_DCPCTR); in control_reg_sqclr()
173 m66592_bset(m66592, M66592_SQCLR, offset); in control_reg_sqclr()
178 static inline int get_buffer_size(struct m66592 *m66592, u16 pipenum) in get_buffer_size() argument
184 tmp = m66592_read(m66592, M66592_DCPCFG); in get_buffer_size()
188 tmp = m66592_read(m66592, M66592_DCPMAXP); in get_buffer_size()
192 m66592_write(m66592, pipenum, M66592_PIPESEL); in get_buffer_size()
193 tmp = m66592_read(m66592, M66592_PIPECFG); in get_buffer_size()
195 tmp = m66592_read(m66592, M66592_PIPEBUF); in get_buffer_size()
198 tmp = m66592_read(m66592, M66592_PIPEMAXP); in get_buffer_size()
206 static inline void pipe_change(struct m66592 *m66592, u16 pipenum) in pipe_change() argument
208 struct m66592_ep *ep = m66592->pipenum2ep[pipenum]; in pipe_change()
214 m66592_mdfy(m66592, pipenum, M66592_CURPIPE, ep->fifosel); in pipe_change()
218 if (m66592->pdata->on_chip) in pipe_change()
223 m66592_bset(m66592, mbw, ep->fifosel); in pipe_change()
226 static int pipe_buffer_setting(struct m66592 *m66592, in pipe_buffer_setting() argument
235 m66592_write(m66592, info->pipe, M66592_PIPESEL); in pipe_buffer_setting()
271 m66592_write(m66592, pipecfg, M66592_PIPECFG); in pipe_buffer_setting()
272 m66592_write(m66592, (buf_bsize << 10) | (bufnum), M66592_PIPEBUF); in pipe_buffer_setting()
273 m66592_write(m66592, info->maxpacket, M66592_PIPEMAXP); in pipe_buffer_setting()
276 m66592_write(m66592, info->interval, M66592_PIPEPERI); in pipe_buffer_setting()
281 static void pipe_buffer_release(struct m66592 *m66592, in pipe_buffer_release() argument
288 m66592->bulk--; in pipe_buffer_release()
290 m66592->interrupt--; in pipe_buffer_release()
292 m66592->isochronous--; in pipe_buffer_release()
294 m66592->bulk--; in pipe_buffer_release()
302 struct m66592 *m66592 = ep->m66592; in pipe_initialize() local
305 m66592_mdfy(m66592, 0, M66592_CURPIPE, ep->fifosel); in pipe_initialize()
307 m66592_write(m66592, M66592_ACLRM, ep->pipectr); in pipe_initialize()
308 m66592_write(m66592, 0, ep->pipectr); in pipe_initialize()
309 m66592_write(m66592, M66592_SQCLR, ep->pipectr); in pipe_initialize()
311 m66592_mdfy(m66592, ep->pipenum, M66592_CURPIPE, ep->fifosel); in pipe_initialize()
315 if (m66592->pdata->on_chip) in pipe_initialize()
320 m66592_bset(m66592, mbw, ep->fifosel); in pipe_initialize()
324 static void m66592_ep_setting(struct m66592 *m66592, struct m66592_ep *ep, in m66592_ep_setting() argument
329 if (m66592->num_dma == 0) { in m66592_ep_setting()
330 m66592->num_dma++; in m66592_ep_setting()
336 } else if (!m66592->pdata->on_chip && m66592->num_dma == 1) { in m66592_ep_setting()
337 m66592->num_dma++; in m66592_ep_setting()
361 m66592->pipenum2ep[pipenum] = ep; in m66592_ep_setting()
362 m66592->epaddr2ep[desc->bEndpointAddress&USB_ENDPOINT_NUMBER_MASK] = ep; in m66592_ep_setting()
368 struct m66592 *m66592 = ep->m66592; in m66592_ep_release() local
375 m66592->num_dma--; in m66592_ep_release()
384 struct m66592 *m66592 = ep->m66592; in alloc_pipe_config() local
396 if (m66592->bulk >= M66592_MAX_NUM_BULK) { in alloc_pipe_config()
397 if (m66592->isochronous >= M66592_MAX_NUM_ISOC) { in alloc_pipe_config()
402 + m66592->isochronous; in alloc_pipe_config()
403 counter = &m66592->isochronous; in alloc_pipe_config()
406 info.pipe = M66592_BASE_PIPENUM_BULK + m66592->bulk; in alloc_pipe_config()
407 counter = &m66592->bulk; in alloc_pipe_config()
413 if (m66592->interrupt >= M66592_MAX_NUM_INT) { in alloc_pipe_config()
417 info.pipe = M66592_BASE_PIPENUM_INT + m66592->interrupt; in alloc_pipe_config()
419 counter = &m66592->interrupt; in alloc_pipe_config()
422 if (m66592->isochronous >= M66592_MAX_NUM_ISOC) { in alloc_pipe_config()
426 info.pipe = M66592_BASE_PIPENUM_ISOC + m66592->isochronous; in alloc_pipe_config()
428 counter = &m66592->isochronous; in alloc_pipe_config()
444 ret = pipe_buffer_setting(m66592, &info); in alloc_pipe_config()
451 if ((counter == &m66592->isochronous) && info.type == M66592_BULK) in alloc_pipe_config()
452 m66592->bulk++; in alloc_pipe_config()
454 m66592_ep_setting(m66592, ep, desc, info.pipe, dma); in alloc_pipe_config()
462 struct m66592 *m66592 = ep->m66592; in free_pipe_config() local
467 pipe_buffer_release(m66592, &info); in free_pipe_config()
474 static void pipe_irq_enable(struct m66592 *m66592, u16 pipenum) in pipe_irq_enable() argument
476 enable_irq_ready(m66592, pipenum); in pipe_irq_enable()
477 enable_irq_nrdy(m66592, pipenum); in pipe_irq_enable()
480 static void pipe_irq_disable(struct m66592 *m66592, u16 pipenum) in pipe_irq_disable() argument
482 disable_irq_ready(m66592, pipenum); in pipe_irq_disable()
483 disable_irq_nrdy(m66592, pipenum); in pipe_irq_disable()
487 static void control_end(struct m66592 *m66592, unsigned ccpl) in control_end() argument
489 m66592->ep[0].internal_ccpl = ccpl; in control_end()
490 pipe_start(m66592, 0); in control_end()
491 m66592_bset(m66592, M66592_CCPL, M66592_DCPCTR); in control_end()
496 struct m66592 *m66592 = ep->m66592; in start_ep0_write() local
498 pipe_change(m66592, ep->pipenum); in start_ep0_write()
499 m66592_mdfy(m66592, M66592_ISEL | M66592_PIPE0, in start_ep0_write()
502 m66592_write(m66592, M66592_BCLR, ep->fifoctr); in start_ep0_write()
504 m66592_bset(m66592, M66592_BVAL, ep->fifoctr); in start_ep0_write()
505 pipe_start(m66592, 0); in start_ep0_write()
508 m66592_write(m66592, ~M66592_BEMP0, M66592_BEMPSTS); in start_ep0_write()
515 struct m66592 *m66592 = ep->m66592; in start_packet_write() local
518 pipe_change(m66592, ep->pipenum); in start_packet_write()
519 disable_irq_empty(m66592, ep->pipenum); in start_packet_write()
520 pipe_start(m66592, ep->pipenum); in start_packet_write()
522 tmp = m66592_read(m66592, ep->fifoctr); in start_packet_write()
524 pipe_irq_enable(m66592, ep->pipenum); in start_packet_write()
531 struct m66592 *m66592 = ep->m66592; in start_packet_read() local
535 m66592_mdfy(m66592, M66592_PIPE0, in start_packet_read()
538 m66592_write(m66592, M66592_BCLR, ep->fifoctr); in start_packet_read()
539 pipe_start(m66592, pipenum); in start_packet_read()
540 pipe_irq_enable(m66592, pipenum); in start_packet_read()
543 m66592_bset(m66592, M66592_TRCLR, ep->fifosel); in start_packet_read()
544 pipe_change(m66592, pipenum); in start_packet_read()
545 m66592_bset(m66592, M66592_TRENB, ep->fifosel); in start_packet_read()
546 m66592_write(m66592, in start_packet_read()
551 pipe_start(m66592, pipenum); /* trigger once */ in start_packet_read()
552 pipe_irq_enable(m66592, pipenum); in start_packet_read()
568 ctsq = m66592_read(ep->m66592, M66592_INTSTS0) & M66592_CTSQ; in start_ep0()
579 control_end(ep->m66592, 0); in start_ep0()
587 static void init_controller(struct m66592 *m66592) in init_controller() argument
591 if (m66592->pdata->on_chip) { in init_controller()
592 if (m66592->pdata->endian) in init_controller()
597 m66592_bset(m66592, M66592_HSE, M66592_SYSCFG); /* High spd */ in init_controller()
598 m66592_bclr(m66592, M66592_USBE, M66592_SYSCFG); in init_controller()
599 m66592_bclr(m66592, M66592_DPRPU, M66592_SYSCFG); in init_controller()
600 m66592_bset(m66592, M66592_USBE, M66592_SYSCFG); in init_controller()
603 m66592_bset(m66592, 0x8000, M66592_DVSTCTR); in init_controller()
604 m66592_bset(m66592, 0x1000, M66592_TESTMODE); in init_controller()
605 m66592_bclr(m66592, 0x8000, M66592_DVSTCTR); in init_controller()
607 m66592_bset(m66592, M66592_INTL, M66592_INTENB1); in init_controller()
609 m66592_write(m66592, 0, M66592_CFBCFG); in init_controller()
610 m66592_write(m66592, 0, M66592_D0FBCFG); in init_controller()
611 m66592_bset(m66592, endian, M66592_CFBCFG); in init_controller()
612 m66592_bset(m66592, endian, M66592_D0FBCFG); in init_controller()
616 if (m66592->pdata->endian) in init_controller()
621 if (m66592->pdata->vif) in init_controller()
626 switch (m66592->pdata->xtal) { in init_controller()
641 switch (m66592->irq_trigger) { in init_controller()
653 m66592_bset(m66592, in init_controller()
656 m66592_bset(m66592, M66592_HSE, M66592_SYSCFG); /* High spd */ in init_controller()
657 m66592_mdfy(m66592, clock & M66592_XTAL, M66592_XTAL, in init_controller()
659 m66592_bclr(m66592, M66592_USBE, M66592_SYSCFG); in init_controller()
660 m66592_bclr(m66592, M66592_DPRPU, M66592_SYSCFG); in init_controller()
661 m66592_bset(m66592, M66592_USBE, M66592_SYSCFG); in init_controller()
663 m66592_bset(m66592, M66592_XCKE, M66592_SYSCFG); in init_controller()
667 m66592_bset(m66592, M66592_RCKE | M66592_PLLC, M66592_SYSCFG); in init_controller()
671 m66592_bset(m66592, M66592_SCKE, M66592_SYSCFG); in init_controller()
673 m66592_bset(m66592, irq_sense & M66592_INTL, M66592_INTENB1); in init_controller()
674 m66592_write(m66592, M66592_BURST | M66592_CPU_ADR_RD_WR, in init_controller()
679 static void disable_controller(struct m66592 *m66592) in disable_controller() argument
681 m66592_bclr(m66592, M66592_UTST, M66592_TESTMODE); in disable_controller()
682 if (!m66592->pdata->on_chip) { in disable_controller()
683 m66592_bclr(m66592, M66592_SCKE, M66592_SYSCFG); in disable_controller()
685 m66592_bclr(m66592, M66592_PLLC, M66592_SYSCFG); in disable_controller()
687 m66592_bclr(m66592, M66592_RCKE, M66592_SYSCFG); in disable_controller()
689 m66592_bclr(m66592, M66592_XCKE, M66592_SYSCFG); in disable_controller()
693 static void m66592_start_xclock(struct m66592 *m66592) in m66592_start_xclock() argument
697 if (!m66592->pdata->on_chip) { in m66592_start_xclock()
698 tmp = m66592_read(m66592, M66592_SYSCFG); in m66592_start_xclock()
700 m66592_bset(m66592, M66592_XCKE, M66592_SYSCFG); in m66592_start_xclock()
707 __releases(m66592->lock) in transfer_complete()
708 __acquires(m66592->lock) in transfer_complete()
720 if (ep->m66592->gadget.speed == USB_SPEED_UNKNOWN) in transfer_complete()
728 spin_unlock(&ep->m66592->lock); in transfer_complete()
730 spin_lock(&ep->m66592->lock); in transfer_complete()
747 struct m66592 *m66592 = ep->m66592; in irq_ep0_write() local
749 pipe_change(m66592, pipenum); in irq_ep0_write()
750 m66592_bset(m66592, M66592_ISEL, ep->fifosel); in irq_ep0_write()
754 tmp = m66592_read(m66592, ep->fifoctr); in irq_ep0_write()
764 bufsize = get_buffer_size(m66592, pipenum); in irq_ep0_write()
771 m66592_write_fifo(m66592, ep, buf, size); in irq_ep0_write()
773 m66592_bset(m66592, M66592_BVAL, ep->fifoctr); in irq_ep0_write()
783 disable_irq_ready(m66592, pipenum); in irq_ep0_write()
784 disable_irq_empty(m66592, pipenum); in irq_ep0_write()
786 disable_irq_ready(m66592, pipenum); in irq_ep0_write()
787 enable_irq_empty(m66592, pipenum); in irq_ep0_write()
789 pipe_start(m66592, pipenum); in irq_ep0_write()
799 struct m66592 *m66592 = ep->m66592; in irq_packet_write() local
801 pipe_change(m66592, pipenum); in irq_packet_write()
802 tmp = m66592_read(m66592, ep->fifoctr); in irq_packet_write()
804 pipe_stop(m66592, pipenum); in irq_packet_write()
805 pipe_irq_disable(m66592, pipenum); in irq_packet_write()
811 bufsize = get_buffer_size(m66592, pipenum); in irq_packet_write()
817 m66592_write_fifo(m66592, ep, buf, size); in irq_packet_write()
822 m66592_bset(m66592, M66592_BVAL, ep->fifoctr); in irq_packet_write()
831 disable_irq_ready(m66592, pipenum); in irq_packet_write()
832 enable_irq_empty(m66592, pipenum); in irq_packet_write()
834 disable_irq_empty(m66592, pipenum); in irq_packet_write()
835 pipe_irq_enable(m66592, pipenum); in irq_packet_write()
846 struct m66592 *m66592 = ep->m66592; in irq_packet_read() local
849 pipe_change(m66592, pipenum); in irq_packet_read()
850 tmp = m66592_read(m66592, ep->fifoctr); in irq_packet_read()
853 pipe_stop(m66592, pipenum); in irq_packet_read()
854 pipe_irq_disable(m66592, pipenum); in irq_packet_read()
861 bufsize = get_buffer_size(m66592, pipenum); in irq_packet_read()
877 pipe_stop(m66592, pipenum); in irq_packet_read()
878 pipe_irq_disable(m66592, pipenum); in irq_packet_read()
885 m66592_write(m66592, M66592_BCLR, ep->fifoctr); in irq_packet_read()
887 m66592_read_fifo(m66592, ep->fifoaddr, buf, size); in irq_packet_read()
894 static void irq_pipe_ready(struct m66592 *m66592, u16 status, u16 enb) in irq_pipe_ready() argument
902 m66592_write(m66592, ~M66592_BRDY0, M66592_BRDYSTS); in irq_pipe_ready()
903 m66592_mdfy(m66592, M66592_PIPE0, M66592_CURPIPE, in irq_pipe_ready()
906 ep = &m66592->ep[0]; in irq_pipe_ready()
913 m66592_write(m66592, ~check, M66592_BRDYSTS); in irq_pipe_ready()
914 ep = m66592->pipenum2ep[pipenum]; in irq_pipe_ready()
926 static void irq_pipe_empty(struct m66592 *m66592, u16 status, u16 enb) in irq_pipe_empty() argument
935 m66592_write(m66592, ~M66592_BEMP0, M66592_BEMPSTS); in irq_pipe_empty()
937 ep = &m66592->ep[0]; in irq_pipe_empty()
944 m66592_write(m66592, ~check, M66592_BEMPSTS); in irq_pipe_empty()
945 tmp = control_reg_get(m66592, pipenum); in irq_pipe_empty()
947 disable_irq_empty(m66592, pipenum); in irq_pipe_empty()
948 pipe_irq_disable(m66592, pipenum); in irq_pipe_empty()
949 pipe_stop(m66592, pipenum); in irq_pipe_empty()
950 ep = m66592->pipenum2ep[pipenum]; in irq_pipe_empty()
962 static void get_status(struct m66592 *m66592, struct usb_ctrlrequest *ctrl) in get_status() argument
963 __releases(m66592->lock) in get_status()
964 __acquires(m66592->lock) in get_status()
979 ep = m66592->epaddr2ep[w_index & USB_ENDPOINT_NUMBER_MASK]; in get_status()
980 pid = control_reg_get_pid(m66592, ep->pipenum); in get_status()
987 pipe_stall(m66592, 0); in get_status()
991 m66592->ep0_data = cpu_to_le16(status); in get_status()
992 m66592->ep0_req->buf = &m66592->ep0_data; in get_status()
993 m66592->ep0_req->length = 2; in get_status()
995 spin_unlock(&m66592->lock); in get_status()
996 m66592_queue(m66592->gadget.ep0, m66592->ep0_req, GFP_KERNEL); in get_status()
997 spin_lock(&m66592->lock); in get_status()
1000 static void clear_feature(struct m66592 *m66592, struct usb_ctrlrequest *ctrl) in clear_feature() argument
1004 control_end(m66592, 1); in clear_feature()
1007 control_end(m66592, 1); in clear_feature()
1014 ep = m66592->epaddr2ep[w_index & USB_ENDPOINT_NUMBER_MASK]; in clear_feature()
1015 pipe_stop(m66592, ep->pipenum); in clear_feature()
1016 control_reg_sqclr(m66592, ep->pipenum); in clear_feature()
1018 control_end(m66592, 1); in clear_feature()
1028 pipe_start(m66592, ep->pipenum); in clear_feature()
1032 pipe_stall(m66592, 0); in clear_feature()
1037 static void set_feature(struct m66592 *m66592, struct usb_ctrlrequest *ctrl) in set_feature() argument
1046 control_end(m66592, 1); in set_feature()
1049 tmp = m66592_read(m66592, M66592_INTSTS0) & in set_feature()
1055 m66592_bset(m66592, in set_feature()
1060 pipe_stall(m66592, 0); in set_feature()
1065 control_end(m66592, 1); in set_feature()
1071 ep = m66592->epaddr2ep[w_index & USB_ENDPOINT_NUMBER_MASK]; in set_feature()
1072 pipe_stall(m66592, ep->pipenum); in set_feature()
1074 control_end(m66592, 1); in set_feature()
1078 pipe_stall(m66592, 0); in set_feature()
1084 static int setup_packet(struct m66592 *m66592, struct usb_ctrlrequest *ctrl) in setup_packet() argument
1091 m66592_write(m66592, ~M66592_VALID, M66592_INTSTS0); in setup_packet()
1094 p[i] = m66592_read(m66592, offset + i*2); in setup_packet()
1100 get_status(m66592, ctrl); in setup_packet()
1103 clear_feature(m66592, ctrl); in setup_packet()
1106 set_feature(m66592, ctrl); in setup_packet()
1117 static void m66592_update_usb_speed(struct m66592 *m66592) in m66592_update_usb_speed() argument
1119 u16 speed = get_usb_speed(m66592); in m66592_update_usb_speed()
1123 m66592->gadget.speed = USB_SPEED_HIGH; in m66592_update_usb_speed()
1126 m66592->gadget.speed = USB_SPEED_FULL; in m66592_update_usb_speed()
1129 m66592->gadget.speed = USB_SPEED_UNKNOWN; in m66592_update_usb_speed()
1134 static void irq_device_state(struct m66592 *m66592) in irq_device_state() argument
1138 dvsq = m66592_read(m66592, M66592_INTSTS0) & M66592_DVSQ; in irq_device_state()
1139 m66592_write(m66592, ~M66592_DVST, M66592_INTSTS0); in irq_device_state()
1142 usb_gadget_udc_reset(&m66592->gadget, m66592->driver); in irq_device_state()
1143 m66592_update_usb_speed(m66592); in irq_device_state()
1145 if (m66592->old_dvsq == M66592_DS_CNFG && dvsq != M66592_DS_CNFG) in irq_device_state()
1146 m66592_update_usb_speed(m66592); in irq_device_state()
1148 && m66592->gadget.speed == USB_SPEED_UNKNOWN) in irq_device_state()
1149 m66592_update_usb_speed(m66592); in irq_device_state()
1151 m66592->old_dvsq = dvsq; in irq_device_state()
1154 static void irq_control_stage(struct m66592 *m66592) in irq_control_stage() argument
1155 __releases(m66592->lock) in irq_control_stage()
1156 __acquires(m66592->lock) in irq_control_stage()
1161 ctsq = m66592_read(m66592, M66592_INTSTS0) & M66592_CTSQ; in irq_control_stage()
1162 m66592_write(m66592, ~M66592_CTRT, M66592_INTSTS0); in irq_control_stage()
1168 ep = &m66592->ep[0]; in irq_control_stage()
1177 if (setup_packet(m66592, &ctrl)) { in irq_control_stage()
1178 spin_unlock(&m66592->lock); in irq_control_stage()
1179 if (m66592->driver->setup(&m66592->gadget, &ctrl) < 0) in irq_control_stage()
1180 pipe_stall(m66592, 0); in irq_control_stage()
1181 spin_lock(&m66592->lock); in irq_control_stage()
1186 control_end(m66592, 0); in irq_control_stage()
1196 struct m66592 *m66592 = _m66592; in m66592_irq() local
1202 spin_lock(&m66592->lock); in m66592_irq()
1204 intsts0 = m66592_read(m66592, M66592_INTSTS0); in m66592_irq()
1205 intenb0 = m66592_read(m66592, M66592_INTENB0); in m66592_irq()
1207 if (m66592->pdata->on_chip && !intsts0 && !intenb0) { in m66592_irq()
1213 m66592_start_xclock(m66592); in m66592_irq()
1214 intsts0 = m66592_read(m66592, M66592_INTSTS0); in m66592_irq()
1215 intenb0 = m66592_read(m66592, M66592_INTENB0); in m66592_irq()
1218 savepipe = m66592_read(m66592, M66592_CFIFOSEL); in m66592_irq()
1222 u16 brdysts = m66592_read(m66592, M66592_BRDYSTS); in m66592_irq()
1223 u16 bempsts = m66592_read(m66592, M66592_BEMPSTS); in m66592_irq()
1224 u16 brdyenb = m66592_read(m66592, M66592_BRDYENB); in m66592_irq()
1225 u16 bempenb = m66592_read(m66592, M66592_BEMPENB); in m66592_irq()
1228 m66592_write(m66592, 0xffff & ~M66592_VBINT, in m66592_irq()
1230 m66592_start_xclock(m66592); in m66592_irq()
1233 m66592->old_vbus = m66592_read(m66592, M66592_INTSTS0) in m66592_irq()
1235 m66592->scount = M66592_MAX_SAMPLING; in m66592_irq()
1237 mod_timer(&m66592->timer, in m66592_irq()
1241 irq_device_state(m66592); in m66592_irq()
1245 irq_pipe_ready(m66592, brdysts, brdyenb); in m66592_irq()
1249 irq_pipe_empty(m66592, bempsts, bempenb); in m66592_irq()
1253 irq_control_stage(m66592); in m66592_irq()
1256 m66592_write(m66592, savepipe, M66592_CFIFOSEL); in m66592_irq()
1258 spin_unlock(&m66592->lock); in m66592_irq()
1264 struct m66592 *m66592 = from_timer(m66592, t, timer); in m66592_timer() local
1268 spin_lock_irqsave(&m66592->lock, flags); in m66592_timer()
1269 tmp = m66592_read(m66592, M66592_SYSCFG); in m66592_timer()
1271 m66592_bset(m66592, M66592_RCKE | M66592_PLLC, M66592_SYSCFG); in m66592_timer()
1273 m66592_bset(m66592, M66592_SCKE, M66592_SYSCFG); in m66592_timer()
1275 if (m66592->scount > 0) { in m66592_timer()
1276 tmp = m66592_read(m66592, M66592_INTSTS0) & M66592_VBSTS; in m66592_timer()
1277 if (tmp == m66592->old_vbus) { in m66592_timer()
1278 m66592->scount--; in m66592_timer()
1279 if (m66592->scount == 0) { in m66592_timer()
1281 m66592_usb_connect(m66592); in m66592_timer()
1283 m66592_usb_disconnect(m66592); in m66592_timer()
1285 mod_timer(&m66592->timer, in m66592_timer()
1289 m66592->scount = M66592_MAX_SAMPLING; in m66592_timer()
1290 m66592->old_vbus = tmp; in m66592_timer()
1291 mod_timer(&m66592->timer, in m66592_timer()
1295 spin_unlock_irqrestore(&m66592->lock, flags); in m66592_timer()
1319 spin_lock_irqsave(&ep->m66592->lock, flags); in m66592_disable()
1321 spin_unlock_irqrestore(&ep->m66592->lock, flags); in m66592_disable()
1324 pipe_irq_disable(ep->m66592, ep->pipenum); in m66592_disable()
1361 if (ep->m66592->gadget.speed == USB_SPEED_UNKNOWN) in m66592_queue()
1364 spin_lock_irqsave(&ep->m66592->lock, flags); in m66592_queue()
1380 spin_unlock_irqrestore(&ep->m66592->lock, flags); in m66592_queue()
1394 spin_lock_irqsave(&ep->m66592->lock, flags); in m66592_dequeue()
1397 spin_unlock_irqrestore(&ep->m66592->lock, flags); in m66592_dequeue()
1408 spin_lock_irqsave(&ep->m66592->lock, flags); in m66592_set_halt()
1413 pipe_stall(ep->m66592, ep->pipenum); in m66592_set_halt()
1416 pipe_stop(ep->m66592, ep->pipenum); in m66592_set_halt()
1418 spin_unlock_irqrestore(&ep->m66592->lock, flags); in m66592_set_halt()
1428 spin_lock_irqsave(&ep->m66592->lock, flags); in m66592_fifo_flush()
1430 pipe_stop(ep->m66592, ep->pipenum); in m66592_fifo_flush()
1431 m66592_bclr(ep->m66592, M66592_BCLR, ep->fifoctr); in m66592_fifo_flush()
1433 spin_unlock_irqrestore(&ep->m66592->lock, flags); in m66592_fifo_flush()
1454 struct m66592 *m66592 = to_m66592(g); in m66592_udc_start() local
1457 m66592->driver = driver; in m66592_udc_start()
1459 m66592_bset(m66592, M66592_VBSE | M66592_URST, M66592_INTENB0); in m66592_udc_start()
1460 if (m66592_read(m66592, M66592_INTSTS0) & M66592_VBSTS) { in m66592_udc_start()
1461 m66592_start_xclock(m66592); in m66592_udc_start()
1463 m66592->old_vbus = m66592_read(m66592, in m66592_udc_start()
1465 m66592->scount = M66592_MAX_SAMPLING; in m66592_udc_start()
1466 mod_timer(&m66592->timer, jiffies + msecs_to_jiffies(50)); in m66592_udc_start()
1474 struct m66592 *m66592 = to_m66592(g); in m66592_udc_stop() local
1476 m66592_bclr(m66592, M66592_VBSE | M66592_URST, M66592_INTENB0); in m66592_udc_stop()
1478 init_controller(m66592); in m66592_udc_stop()
1479 disable_controller(m66592); in m66592_udc_stop()
1481 m66592->driver = NULL; in m66592_udc_stop()
1489 struct m66592 *m66592 = gadget_to_m66592(_gadget); in m66592_get_frame() local
1490 return m66592_read(m66592, M66592_FRMNUM) & 0x03FF; in m66592_get_frame()
1495 struct m66592 *m66592 = gadget_to_m66592(gadget); in m66592_pullup() local
1498 spin_lock_irqsave(&m66592->lock, flags); in m66592_pullup()
1500 m66592_bset(m66592, M66592_DPRPU, M66592_SYSCFG); in m66592_pullup()
1502 m66592_bclr(m66592, M66592_DPRPU, M66592_SYSCFG); in m66592_pullup()
1503 spin_unlock_irqrestore(&m66592->lock, flags); in m66592_pullup()
1517 struct m66592 *m66592 = platform_get_drvdata(pdev); in m66592_remove() local
1519 usb_del_gadget_udc(&m66592->gadget); in m66592_remove()
1521 timer_shutdown_sync(&m66592->timer); in m66592_remove()
1522 iounmap(m66592->reg); in m66592_remove()
1523 free_irq(platform_get_irq(pdev, 0), m66592); in m66592_remove()
1524 m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req); in m66592_remove()
1525 if (m66592->pdata->on_chip) { in m66592_remove()
1526 clk_disable(m66592->clk); in m66592_remove()
1527 clk_put(m66592->clk); in m66592_remove()
1529 kfree(m66592); in m66592_remove()
1540 struct m66592 *m66592 = NULL; in m66592_probe() local
1574 m66592 = kzalloc(sizeof(struct m66592), GFP_KERNEL); in m66592_probe()
1575 if (m66592 == NULL) { in m66592_probe()
1580 m66592->pdata = dev_get_platdata(&pdev->dev); in m66592_probe()
1581 m66592->irq_trigger = ires->flags & IRQF_TRIGGER_MASK; in m66592_probe()
1583 spin_lock_init(&m66592->lock); in m66592_probe()
1584 platform_set_drvdata(pdev, m66592); in m66592_probe()
1586 m66592->gadget.ops = &m66592_gadget_ops; in m66592_probe()
1587 m66592->gadget.max_speed = USB_SPEED_HIGH; in m66592_probe()
1588 m66592->gadget.name = udc_name; in m66592_probe()
1590 timer_setup(&m66592->timer, m66592_timer, 0); in m66592_probe()
1591 m66592->reg = reg; in m66592_probe()
1594 udc_name, m66592); in m66592_probe()
1600 if (m66592->pdata->on_chip) { in m66592_probe()
1602 m66592->clk = clk_get(&pdev->dev, clk_name); in m66592_probe()
1603 if (IS_ERR(m66592->clk)) { in m66592_probe()
1606 ret = PTR_ERR(m66592->clk); in m66592_probe()
1609 clk_enable(m66592->clk); in m66592_probe()
1612 INIT_LIST_HEAD(&m66592->gadget.ep_list); in m66592_probe()
1613 m66592->gadget.ep0 = &m66592->ep[0].ep; in m66592_probe()
1614 INIT_LIST_HEAD(&m66592->gadget.ep0->ep_list); in m66592_probe()
1616 struct m66592_ep *ep = &m66592->ep[i]; in m66592_probe()
1619 INIT_LIST_HEAD(&m66592->ep[i].ep.ep_list); in m66592_probe()
1620 list_add_tail(&m66592->ep[i].ep.ep_list, in m66592_probe()
1621 &m66592->gadget.ep_list); in m66592_probe()
1623 ep->m66592 = m66592; in m66592_probe()
1640 usb_ep_set_maxpacket_limit(&m66592->ep[0].ep, 64); in m66592_probe()
1641 m66592->ep[0].pipenum = 0; in m66592_probe()
1642 m66592->ep[0].fifoaddr = M66592_CFIFO; in m66592_probe()
1643 m66592->ep[0].fifosel = M66592_CFIFOSEL; in m66592_probe()
1644 m66592->ep[0].fifoctr = M66592_CFIFOCTR; in m66592_probe()
1645 m66592->ep[0].fifotrn = 0; in m66592_probe()
1646 m66592->ep[0].pipectr = get_pipectr_addr(0); in m66592_probe()
1647 m66592->pipenum2ep[0] = &m66592->ep[0]; in m66592_probe()
1648 m66592->epaddr2ep[0] = &m66592->ep[0]; in m66592_probe()
1650 m66592->ep0_req = m66592_alloc_request(&m66592->ep[0].ep, GFP_KERNEL); in m66592_probe()
1651 if (m66592->ep0_req == NULL) { in m66592_probe()
1655 m66592->ep0_req->complete = nop_completion; in m66592_probe()
1657 init_controller(m66592); in m66592_probe()
1659 ret = usb_add_gadget_udc(&pdev->dev, &m66592->gadget); in m66592_probe()
1667 m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req); in m66592_probe()
1668 m66592->ep0_req = NULL; in m66592_probe()
1670 if (m66592->pdata->on_chip) { in m66592_probe()
1671 clk_disable(m66592->clk); in m66592_probe()
1672 clk_put(m66592->clk); in m66592_probe()
1675 free_irq(ires->start, m66592); in m66592_probe()
1677 if (m66592) { in m66592_probe()
1678 if (m66592->ep0_req) in m66592_probe()
1679 m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req); in m66592_probe()
1680 kfree(m66592); in m66592_probe()