• Home
  • Raw
  • Download

Lines Matching refs:r8a66597

22 static struct r8a66597 gr8a66597;
47 static void set_devadd(struct r8a66597 *r8a66597, u8 r8a66597_address, in set_devadd() argument
54 usbspd = r8a66597->speed; in set_devadd()
56 r8a66597_write(r8a66597, val, devadd_reg); in set_devadd()
59 static int r8a66597_clock_enable(struct r8a66597 *r8a66597) in r8a66597_clock_enable() argument
66 r8a66597_write(r8a66597, SCKE, SYSCFG0); in r8a66597_clock_enable()
67 tmp = r8a66597_read(r8a66597, SYSCFG0); in r8a66597_clock_enable()
73 r8a66597_write(r8a66597, 0x04, 0x02); in r8a66597_clock_enable()
76 r8a66597_write(r8a66597, USBE, SYSCFG0); in r8a66597_clock_enable()
77 tmp = r8a66597_read(r8a66597, SYSCFG0); in r8a66597_clock_enable()
83 r8a66597_bclr(r8a66597, USBE, SYSCFG0); in r8a66597_clock_enable()
85 r8a66597_mdfy(r8a66597, CONFIG_R8A66597_XTAL, XTAL, SYSCFG0); in r8a66597_clock_enable()
88 r8a66597_bset(r8a66597, XCKE, SYSCFG0); in r8a66597_clock_enable()
91 tmp = r8a66597_read(r8a66597, SYSCFG0); in r8a66597_clock_enable()
109 r8a66597_bset(r8a66597, SUSPM, SUSPMODE0); in r8a66597_clock_enable()
116 static void r8a66597_clock_disable(struct r8a66597 *r8a66597) in r8a66597_clock_disable() argument
119 r8a66597_bclr(r8a66597, SCKE, SYSCFG0); in r8a66597_clock_disable()
122 r8a66597_bclr(r8a66597, PLLC, SYSCFG0); in r8a66597_clock_disable()
123 r8a66597_bclr(r8a66597, XCKE, SYSCFG0); in r8a66597_clock_disable()
124 r8a66597_bclr(r8a66597, USBE, SYSCFG0); in r8a66597_clock_disable()
127 r8a66597_bclr(r8a66597, SUSPM, SUSPMODE0); in r8a66597_clock_disable()
131 r8a66597_bclr(r8a66597, USBE, SYSCFG0); in r8a66597_clock_disable()
137 static void r8a66597_enable_port(struct r8a66597 *r8a66597, int port) in r8a66597_enable_port() argument
142 r8a66597_bset(r8a66597, val, get_syscfg_reg(port)); in r8a66597_enable_port()
143 r8a66597_bset(r8a66597, HSE, get_syscfg_reg(port)); in r8a66597_enable_port()
146 r8a66597_write(r8a66597, BURST | CPU_ADR_RD_WR, get_dmacfg_reg(port)); in r8a66597_enable_port()
150 static void r8a66597_disable_port(struct r8a66597 *r8a66597, int port) in r8a66597_disable_port() argument
154 r8a66597_write(r8a66597, 0, get_intenb_reg(port)); in r8a66597_disable_port()
155 r8a66597_write(r8a66597, 0, get_intsts_reg(port)); in r8a66597_disable_port()
157 r8a66597_port_power(r8a66597, port, 0); in r8a66597_disable_port()
160 tmp = r8a66597_read(r8a66597, SOFCFG) & EDGESTS; in r8a66597_disable_port()
165 r8a66597_bclr(r8a66597, val, get_syscfg_reg(port)); in r8a66597_disable_port()
166 r8a66597_bclr(r8a66597, HSE, get_syscfg_reg(port)); in r8a66597_disable_port()
169 static int enable_controller(struct r8a66597 *r8a66597) in enable_controller() argument
173 ret = r8a66597_clock_enable(r8a66597); in enable_controller()
178 r8a66597_bset(r8a66597, CONFIG_R8A66597_LDRV & LDRV, PINCFG); in enable_controller()
180 r8a66597_bset(r8a66597, USBE, SYSCFG0); in enable_controller()
182 r8a66597_bset(r8a66597, INTL, SOFCFG); in enable_controller()
183 r8a66597_write(r8a66597, 0, INTENB0); in enable_controller()
185 r8a66597_write(r8a66597, 0, get_intenb_reg(port)); in enable_controller()
187 r8a66597_bset(r8a66597, CONFIG_R8A66597_ENDIAN & BIGEND, CFIFOSEL); in enable_controller()
188 r8a66597_bset(r8a66597, CONFIG_R8A66597_ENDIAN & BIGEND, D0FIFOSEL); in enable_controller()
189 r8a66597_bset(r8a66597, CONFIG_R8A66597_ENDIAN & BIGEND, D1FIFOSEL); in enable_controller()
190 r8a66597_bset(r8a66597, TRNENSEL, SOFCFG); in enable_controller()
193 r8a66597_enable_port(r8a66597, port); in enable_controller()
198 static void disable_controller(struct r8a66597 *r8a66597) in disable_controller() argument
202 if (!(r8a66597_read(r8a66597, SYSCFG0) & USBE)) in disable_controller()
205 r8a66597_write(r8a66597, 0, INTENB0); in disable_controller()
206 r8a66597_write(r8a66597, 0, INTSTS0); in disable_controller()
208 r8a66597_write(r8a66597, 0, D0FIFOSEL); in disable_controller()
209 r8a66597_write(r8a66597, 0, D1FIFOSEL); in disable_controller()
210 r8a66597_write(r8a66597, 0, DCPCFG); in disable_controller()
211 r8a66597_write(r8a66597, 0x40, DCPMAXP); in disable_controller()
212 r8a66597_write(r8a66597, 0, DCPCTR); in disable_controller()
215 r8a66597_write(r8a66597, 0, get_devadd_addr(i)); in disable_controller()
217 r8a66597_write(r8a66597, 0, get_pipetre_addr(i)); in disable_controller()
218 r8a66597_write(r8a66597, 0, get_pipetrn_addr(i)); in disable_controller()
221 r8a66597_write(r8a66597, 0, get_pipectr_addr(i)); in disable_controller()
222 r8a66597_write(r8a66597, i, PIPESEL); in disable_controller()
223 r8a66597_write(r8a66597, 0, PIPECFG); in disable_controller()
224 r8a66597_write(r8a66597, 0, PIPEBUF); in disable_controller()
225 r8a66597_write(r8a66597, 0, PIPEMAXP); in disable_controller()
226 r8a66597_write(r8a66597, 0, PIPEPERI); in disable_controller()
230 r8a66597_disable_port(r8a66597, i); in disable_controller()
232 r8a66597_clock_disable(r8a66597); in disable_controller()
235 static void r8a66597_reg_wait(struct r8a66597 *r8a66597, unsigned long reg, in r8a66597_reg_wait() argument
242 tmp = r8a66597_read(r8a66597, reg); in r8a66597_reg_wait()
250 static void pipe_buffer_setting(struct r8a66597 *r8a66597, in pipe_buffer_setting() argument
266 if (r8a66597->pipe_config & (1 << pipenum)) in pipe_buffer_setting()
268 r8a66597->pipe_config |= (1 << pipenum); in pipe_buffer_setting()
270 r8a66597_bset(r8a66597, ACLRM, get_pipectr_addr(pipenum)); in pipe_buffer_setting()
271 r8a66597_bclr(r8a66597, ACLRM, get_pipectr_addr(pipenum)); in pipe_buffer_setting()
272 r8a66597_write(r8a66597, pipenum, PIPESEL); in pipe_buffer_setting()
280 r8a66597_write(r8a66597, val, PIPECFG); in pipe_buffer_setting()
282 r8a66597_write(r8a66597, (8 << 10) | bufnum, PIPEBUF); in pipe_buffer_setting()
283 r8a66597_write(r8a66597, make_devsel(usb_pipedevice(pipe)) | in pipe_buffer_setting()
285 r8a66597_write(r8a66597, 0, PIPEPERI); in pipe_buffer_setting()
286 r8a66597_write(r8a66597, SQCLR, get_pipectr_addr(pipenum)); in pipe_buffer_setting()
289 static int send_setup_packet(struct r8a66597 *r8a66597, struct usb_device *dev, in send_setup_packet() argument
302 r8a66597_write(r8a66597, make_devsel(devsel) | in send_setup_packet()
304 r8a66597_write(r8a66597, ~(SIGN | SACK), INTSTS1); in send_setup_packet()
307 dcpctr = r8a66597_read(r8a66597, DCPCTR); in send_setup_packet()
309 if (readw_poll_timeout(r8a66597->reg + DCPCTR, dcpctr, in send_setup_packet()
318 r8a66597_write(r8a66597, le16_to_cpu(p[i]), setup_addr); in send_setup_packet()
321 r8a66597_write(r8a66597, ~0x0001, BRDYSTS); in send_setup_packet()
322 r8a66597_write(r8a66597, SUREQ, DCPCTR); in send_setup_packet()
325 intsts1 = r8a66597_read(r8a66597, INTSTS1); in send_setup_packet()
342 static int send_bulk_packet(struct r8a66597 *r8a66597, struct usb_device *dev, in send_bulk_packet() argument
351 r8a66597_mdfy(r8a66597, MBW | BULK_OUT_PIPENUM, in send_bulk_packet()
353 r8a66597_reg_wait(r8a66597, CFIFOSEL, CURPIPE, BULK_OUT_PIPENUM); in send_bulk_packet()
354 tmp = r8a66597_read(r8a66597, CFIFOCTR); in send_bulk_packet()
366 r8a66597_write(r8a66597, ~(1 << BULK_OUT_PIPENUM), BEMPSTS); in send_bulk_packet()
368 r8a66597_write_fifo(r8a66597, CFIFO, buf, size); in send_bulk_packet()
369 r8a66597_write(r8a66597, BVAL, CFIFOCTR); in send_bulk_packet()
375 r8a66597_mdfy(r8a66597, PID_BUF, PID, in send_bulk_packet()
378 while (!(r8a66597_read(r8a66597, BEMPSTS) & (1 << BULK_OUT_PIPENUM))) in send_bulk_packet()
381 r8a66597_write(r8a66597, ~(1 << BULK_OUT_PIPENUM), BEMPSTS); in send_bulk_packet()
384 r8a66597_mdfy(r8a66597, PID_NAK, PID, in send_bulk_packet()
390 static int receive_bulk_packet(struct r8a66597 *r8a66597, in receive_bulk_packet() argument
405 r8a66597_mdfy(r8a66597, PID_NAK, PID, in receive_bulk_packet()
407 r8a66597_write(r8a66597, ~(1 << pipenum), BRDYSTS); in receive_bulk_packet()
409 r8a66597_write(r8a66597, TRCLR, get_pipetre_addr(pipenum)); in receive_bulk_packet()
410 r8a66597_write(r8a66597, in receive_bulk_packet()
413 r8a66597_bset(r8a66597, TRENB, get_pipetre_addr(pipenum)); in receive_bulk_packet()
415 r8a66597_mdfy(r8a66597, PID_BUF, PID, in receive_bulk_packet()
419 r8a66597_mdfy(r8a66597, MBW | pipenum, MBW | CURPIPE, CFIFOSEL); in receive_bulk_packet()
420 r8a66597_reg_wait(r8a66597, CFIFOSEL, CURPIPE, pipenum); in receive_bulk_packet()
422 while (!(r8a66597_read(r8a66597, BRDYSTS) & (1 << pipenum))) in receive_bulk_packet()
425 r8a66597_write(r8a66597, ~(1 << pipenum), BRDYSTS); in receive_bulk_packet()
427 tmp = r8a66597_read(r8a66597, CFIFOCTR); in receive_bulk_packet()
439 r8a66597_write(r8a66597, BCLR, CFIFOCTR); in receive_bulk_packet()
441 r8a66597_read_fifo(r8a66597, CFIFO, buf, rcv_len); in receive_bulk_packet()
447 static int receive_control_packet(struct r8a66597 *r8a66597, in receive_control_packet() argument
456 r8a66597_bclr(r8a66597, R8A66597_DIR, DCPCFG); in receive_control_packet()
457 r8a66597_mdfy(r8a66597, 0, ISEL | CURPIPE, CFIFOSEL); in receive_control_packet()
458 r8a66597_reg_wait(r8a66597, CFIFOSEL, CURPIPE, 0); in receive_control_packet()
459 r8a66597_bset(r8a66597, SQSET, DCPCTR); in receive_control_packet()
460 r8a66597_write(r8a66597, BCLR, CFIFOCTR); in receive_control_packet()
461 r8a66597_mdfy(r8a66597, PID_BUF, PID, DCPCTR); in receive_control_packet()
463 while (!(r8a66597_read(r8a66597, BRDYSTS) & 0x0001)) in receive_control_packet()
466 r8a66597_write(r8a66597, ~0x0001, BRDYSTS); in receive_control_packet()
468 r8a66597_mdfy(r8a66597, MBW, MBW | CURPIPE, CFIFOSEL); in receive_control_packet()
469 r8a66597_reg_wait(r8a66597, CFIFOSEL, CURPIPE, 0); in receive_control_packet()
471 tmp = r8a66597_read(r8a66597, CFIFOCTR); in receive_control_packet()
480 r8a66597_mdfy(r8a66597, PID_NAK, PID, DCPCTR); in receive_control_packet()
484 r8a66597_write(r8a66597, BCLR, DCPCTR); in receive_control_packet()
486 r8a66597_read_fifo(r8a66597, CFIFO, buffer, rcv_len); in receive_control_packet()
492 static int send_status_packet(struct r8a66597 *r8a66597, in send_status_packet() argument
495 r8a66597_bset(r8a66597, SQSET, DCPCTR); in send_status_packet()
496 r8a66597_mdfy(r8a66597, PID_NAK, PID, DCPCTR); in send_status_packet()
499 r8a66597_bset(r8a66597, R8A66597_DIR, DCPCFG); in send_status_packet()
500 r8a66597_mdfy(r8a66597, ISEL, ISEL | CURPIPE, CFIFOSEL); in send_status_packet()
501 r8a66597_reg_wait(r8a66597, CFIFOSEL, CURPIPE, 0); in send_status_packet()
502 r8a66597_write(r8a66597, ~BEMP0, BEMPSTS); in send_status_packet()
503 r8a66597_write(r8a66597, BCLR | BVAL, CFIFOCTR); in send_status_packet()
505 r8a66597_bclr(r8a66597, R8A66597_DIR, DCPCFG); in send_status_packet()
506 r8a66597_mdfy(r8a66597, 0, ISEL | CURPIPE, CFIFOSEL); in send_status_packet()
507 r8a66597_reg_wait(r8a66597, CFIFOSEL, CURPIPE, 0); in send_status_packet()
508 r8a66597_write(r8a66597, BCLR, CFIFOCTR); in send_status_packet()
510 r8a66597_mdfy(r8a66597, PID_BUF, PID, DCPCTR); in send_status_packet()
512 while (!(r8a66597_read(r8a66597, BEMPSTS) & 0x0001)) in send_status_packet()
519 static void r8a66597_check_syssts(struct r8a66597 *r8a66597, int port) in r8a66597_check_syssts() argument
526 old_syssts = r8a66597_read(r8a66597, get_syssts_reg(port) & LNST); in r8a66597_check_syssts()
530 syssts = r8a66597_read(r8a66597, get_syssts_reg(port) & LNST); in r8a66597_check_syssts()
540 static void r8a66597_bus_reset(struct r8a66597 *r8a66597, int port) in r8a66597_bus_reset() argument
543 r8a66597_mdfy(r8a66597, USBRST, USBRST | UACT, get_dvstctr_reg(port)); in r8a66597_bus_reset()
545 r8a66597_mdfy(r8a66597, UACT, USBRST | UACT, get_dvstctr_reg(port)); in r8a66597_bus_reset()
549 static int check_usb_device_connecting(struct r8a66597 *r8a66597) in check_usb_device_connecting() argument
556 while (!(r8a66597_read(r8a66597, INTSTS1) & ATTCH)) { in check_usb_device_connecting()
565 r8a66597_check_syssts(r8a66597, 0); in check_usb_device_connecting()
567 r8a66597_bus_reset(r8a66597, 0); in check_usb_device_connecting()
568 r8a66597->speed = get_rh_usb_speed(r8a66597, 0); in check_usb_device_connecting()
570 if (!(r8a66597_read(r8a66597, INTSTS1) & DTCH)) { in check_usb_device_connecting()
571 r8a66597->port_change = USB_PORT_STAT_C_CONNECTION; in check_usb_device_connecting()
572 r8a66597->port_status = USB_PORT_STAT_CONNECTION | in check_usb_device_connecting()
578 r8a66597_write(r8a66597, ~DTCH, INTSTS1); in check_usb_device_connecting()
593 struct r8a66597 *r8a66597 = &gr8a66597; in r8a66597_submit_rh_msg() local
631 *(__u32 *)buffer = cpu_to_le32(r8a66597->port_status | in r8a66597_submit_rh_msg()
632 (r8a66597->port_change << 16)); in r8a66597_submit_rh_msg()
642 r8a66597->port_change &= ~USB_PORT_STAT_C_CONNECTION; in r8a66597_submit_rh_msg()
652 r8a66597_bus_reset(r8a66597, 0); in r8a66597_submit_rh_msg()
760 struct r8a66597 *r8a66597 = &gr8a66597; in submit_bulk_msg() local
767 set_devadd(r8a66597, dev->devnum, dev, 0); in submit_bulk_msg()
769 pipe_buffer_setting(r8a66597, dev, pipe); in submit_bulk_msg()
777 ret = receive_bulk_packet(r8a66597, dev, pipe, buffer, in submit_bulk_msg()
780 ret = send_bulk_packet(r8a66597, dev, pipe, buffer, in submit_bulk_msg()
793 struct r8a66597 *r8a66597 = &gr8a66597; in submit_control_msg() local
798 if (usb_pipedevice(pipe) == r8a66597->rh_devnum) in submit_control_msg()
803 set_devadd(r8a66597, r8a66597_address, dev, 0); in submit_control_msg()
805 if (send_setup_packet(r8a66597, dev, setup) < 0) { in submit_control_msg()
812 if (receive_control_packet(r8a66597, dev, buffer, in submit_control_msg()
816 if (send_status_packet(r8a66597, pipe) < 0) in submit_control_msg()
834 struct r8a66597 *r8a66597 = &gr8a66597; in usb_lowlevel_init() local
838 memset(r8a66597, 0, sizeof(*r8a66597)); in usb_lowlevel_init()
839 r8a66597->reg = CONFIG_R8A66597_BASE_ADDR; in usb_lowlevel_init()
841 disable_controller(r8a66597); in usb_lowlevel_init()
844 enable_controller(r8a66597); in usb_lowlevel_init()
845 r8a66597_port_power(r8a66597, 0 , 1); in usb_lowlevel_init()
848 check_usb_device_connecting(r8a66597); in usb_lowlevel_init()