Lines Matching full:hcd
18 * For USB HCD implementation.
63 #include <linux/usb/hcd.h>
66 #include <linux/platform_data/max3421-hcd.h>
140 * SPI-thread without acquiring the HCD lock:
341 hcd_to_max3421(struct usb_hcd *hcd) in hcd_to_max3421() argument
343 return (struct max3421_hcd *) hcd->hcd_priv; in hcd_to_max3421()
353 spi_rd8(struct usb_hcd *hcd, unsigned int reg) in spi_rd8() argument
355 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in spi_rd8()
356 struct spi_device *spi = to_spi_device(hcd->self.controller); in spi_rd8()
379 spi_wr8(struct usb_hcd *hcd, unsigned int reg, u8 val) in spi_wr8() argument
381 struct spi_device *spi = to_spi_device(hcd->self.controller); in spi_wr8()
382 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in spi_wr8()
403 spi_rd_buf(struct usb_hcd *hcd, unsigned int reg, void *buf, size_t len) in spi_rd_buf() argument
405 struct spi_device *spi = to_spi_device(hcd->self.controller); in spi_rd_buf()
406 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in spi_rd_buf()
429 spi_wr_buf(struct usb_hcd *hcd, unsigned int reg, void *buf, size_t len) in spi_wr_buf() argument
431 struct spi_device *spi = to_spi_device(hcd->self.controller); in spi_wr_buf()
432 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in spi_wr_buf()
469 max3421_set_speed(struct usb_hcd *hcd, struct usb_device *dev) in max3421_set_speed() argument
471 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_set_speed()
486 spi_wr8(hcd, MAX3421_REG_MODE, max3421_hcd->mode); in max3421_set_speed()
492 * Caller must NOT hold HCD spinlock.
495 max3421_set_address(struct usb_hcd *hcd, struct usb_device *dev, int epnum, in max3421_set_address() argument
498 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_set_address()
512 u8 hrsl = spi_rd8(hcd, MAX3421_REG_HRSL); in max3421_set_address()
517 /* no locking: HCD (i.e., we) own toggles, don't we? */ in max3421_set_address()
528 spi_wr8(hcd, MAX3421_REG_HCTL, hctl); in max3421_set_address()
536 spi_wr8(hcd, MAX3421_REG_PERADDR, dev->devnum); in max3421_set_address()
540 max3421_ctrl_setup(struct usb_hcd *hcd, struct urb *urb) in max3421_ctrl_setup() argument
542 spi_wr_buf(hcd, MAX3421_REG_SUDFIFO, urb->setup_packet, 8); in max3421_ctrl_setup()
547 max3421_transfer_in(struct usb_hcd *hcd, struct urb *urb) in max3421_transfer_in() argument
549 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_transfer_in()
558 max3421_transfer_out(struct usb_hcd *hcd, struct urb *urb, int fast_retransmit) in max3421_transfer_out() argument
560 struct spi_device *spi = to_spi_device(hcd->self.controller); in max3421_transfer_out()
561 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_transfer_out()
571 spi_wr8(hcd, MAX3421_REG_SNDBC, 0); in max3421_transfer_out()
572 spi_wr8(hcd, MAX3421_REG_SNDFIFO, ((u8 *) src)[0]); in max3421_transfer_out()
573 spi_wr8(hcd, MAX3421_REG_SNDBC, max3421_hcd->curr_len); in max3421_transfer_out()
594 spi_wr_buf(hcd, MAX3421_REG_SNDFIFO, src, max3421_hcd->curr_len); in max3421_transfer_out()
595 spi_wr8(hcd, MAX3421_REG_SNDBC, max3421_hcd->curr_len); in max3421_transfer_out()
601 * Caller must NOT hold HCD spinlock.
604 max3421_next_transfer(struct usb_hcd *hcd, int fast_retransmit) in max3421_next_transfer() argument
606 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_next_transfer()
618 cmd = max3421_ctrl_setup(hcd, urb); in max3421_next_transfer()
623 cmd = max3421_transfer_in(hcd, urb); in max3421_next_transfer()
625 cmd = max3421_transfer_out(hcd, urb, fast_retransmit); in max3421_next_transfer()
645 spi_wr8(hcd, MAX3421_REG_HXFR, cmd); in max3421_next_transfer()
659 * o Caller must NOT hold HCD spinlock.
664 max3421_select_and_start_urb(struct usb_hcd *hcd) in max3421_select_and_start_urb() argument
666 struct spi_device *spi = to_spi_device(hcd->self.controller); in max3421_select_and_start_urb()
667 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_select_and_start_urb()
788 max3421_set_address(hcd, urb->dev, epnum, force_toggles); in max3421_select_and_start_urb()
789 max3421_set_speed(hcd, urb->dev); in max3421_select_and_start_urb()
790 max3421_next_transfer(hcd, 0); in max3421_select_and_start_urb()
797 * Caller must NOT hold HCD spinlock.
800 max3421_check_unlink(struct usb_hcd *hcd) in max3421_check_unlink() argument
802 struct spi_device *spi = to_spi_device(hcd->self.controller); in max3421_check_unlink()
803 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_check_unlink()
818 usb_hcd_unlink_urb_from_ep(hcd, urb); in max3421_check_unlink()
821 usb_hcd_giveback_urb(hcd, urb, 0); in max3421_check_unlink()
831 * Caller must NOT hold HCD spinlock.
834 max3421_slow_retransmit(struct usb_hcd *hcd) in max3421_slow_retransmit() argument
836 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_slow_retransmit()
846 * Caller must NOT hold HCD spinlock.
849 max3421_recv_data_available(struct usb_hcd *hcd) in max3421_recv_data_available() argument
851 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_recv_data_available()
856 rcvbc = spi_rd8(hcd, MAX3421_REG_RCVBC); in max3421_recv_data_available()
870 spi_rd_buf(hcd, MAX3421_REG_RCVFIFO, dst, transfer_size); in max3421_recv_data_available()
876 spi_wr8(hcd, MAX3421_REG_HIRQ, BIT(MAX3421_HI_RCVDAV_BIT)); in max3421_recv_data_available()
880 max3421_handle_error(struct usb_hcd *hcd, u8 hrsl) in max3421_handle_error() argument
882 struct spi_device *spi = to_spi_device(hcd->self.controller); in max3421_handle_error()
883 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_handle_error()
925 spi_wr8(hcd, MAX3421_REG_HCTL, in max3421_handle_error()
937 max3421_slow_retransmit(hcd); in max3421_handle_error()
958 max3421_next_transfer(hcd, 1); in max3421_handle_error()
961 max3421_slow_retransmit(hcd); in max3421_handle_error()
965 spi_wr8(hcd, MAX3421_REG_SNDBC, 0); in max3421_handle_error()
969 * Caller must NOT hold HCD spinlock.
972 max3421_transfer_in_done(struct usb_hcd *hcd, struct urb *urb) in max3421_transfer_in_done() argument
974 struct spi_device *spi = to_spi_device(hcd->self.controller); in max3421_transfer_in_done()
975 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_transfer_in_done()
1013 * Caller must NOT hold HCD spinlock.
1016 max3421_transfer_out_done(struct usb_hcd *hcd, struct urb *urb) in max3421_transfer_out_done() argument
1018 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_transfer_out_done()
1040 * Caller must NOT hold HCD spinlock.
1043 max3421_host_transfer_done(struct usb_hcd *hcd) in max3421_host_transfer_done() argument
1045 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_host_transfer_done()
1054 hrsl = spi_rd8(hcd, MAX3421_REG_HRSL); in max3421_host_transfer_done()
1064 max3421_handle_error(hcd, hrsl); in max3421_host_transfer_done()
1081 urb_done = max3421_transfer_in_done(hcd, urb); in max3421_host_transfer_done()
1083 urb_done = max3421_transfer_out_done(hcd, urb); in max3421_host_transfer_done()
1102 max3421_next_transfer(hcd, 0); in max3421_host_transfer_done()
1106 * Caller must NOT hold HCD spinlock.
1109 max3421_detect_conn(struct usb_hcd *hcd) in max3421_detect_conn() argument
1111 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_detect_conn()
1117 hrsl = spi_rd8(hcd, MAX3421_REG_HRSL); in max3421_detect_conn()
1148 spi_wr8(hcd, MAX3421_REG_MODE, max3421_hcd->mode); in max3421_detect_conn()
1168 struct usb_hcd *hcd = dev_id; in max3421_irq_handler() local
1169 struct spi_device *spi = to_spi_device(hcd->self.controller); in max3421_irq_handler()
1170 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_irq_handler()
1183 dump_eps(struct usb_hcd *hcd) in dump_eps() argument
1185 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in dump_eps()
1224 max3421_handle_irqs(struct usb_hcd *hcd) in max3421_handle_irqs() argument
1226 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_handle_irqs()
1236 hirq = spi_rd8(hcd, MAX3421_REG_HIRQ); in max3421_handle_irqs()
1241 spi_wr8(hcd, MAX3421_REG_HIRQ, in max3421_handle_irqs()
1252 max3421_recv_data_available(hcd); in max3421_handle_irqs()
1255 max3421_host_transfer_done(hcd); in max3421_handle_irqs()
1258 max3421_detect_conn(hcd); in max3421_handle_irqs()
1261 * Now process interrupts that may affect HCD state in max3421_handle_irqs()
1309 dump_eps(hcd); in max3421_handle_irqs()
1317 max3421_reset_hcd(struct usb_hcd *hcd) in max3421_reset_hcd() argument
1319 struct spi_device *spi = to_spi_device(hcd->self.controller); in max3421_reset_hcd()
1320 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_reset_hcd()
1324 spi_wr8(hcd, MAX3421_REG_USBCTL, BIT(MAX3421_USBCTL_CHIPRES_BIT)); in max3421_reset_hcd()
1326 spi_wr8(hcd, MAX3421_REG_USBCTL, 0); in max3421_reset_hcd()
1329 if (spi_rd8(hcd, MAX3421_REG_USBIRQ) in max3421_reset_hcd()
1348 spi_wr8(hcd, MAX3421_REG_MODE, max3421_hcd->mode); in max3421_reset_hcd()
1352 spi_wr8(hcd, MAX3421_REG_HCTL, BIT(MAX3421_HCTL_FRMRST_BIT)); in max3421_reset_hcd()
1355 spi_wr8(hcd, MAX3421_REG_HCTL, BIT(MAX3421_HCTL_SAMPLEBUS_BIT)); in max3421_reset_hcd()
1356 max3421_detect_conn(hcd); in max3421_reset_hcd()
1362 spi_wr8(hcd, MAX3421_REG_HIEN, max3421_hcd->hien); in max3421_reset_hcd()
1365 spi_wr8(hcd, MAX3421_REG_CPUCTL, BIT(MAX3421_CPUCTL_IE_BIT)); in max3421_reset_hcd()
1370 max3421_urb_done(struct usb_hcd *hcd) in max3421_urb_done() argument
1372 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_urb_done()
1385 usb_hcd_unlink_urb_from_ep(hcd, urb); in max3421_urb_done()
1388 /* must be called without the HCD spinlock: */ in max3421_urb_done()
1389 usb_hcd_giveback_urb(hcd, urb, status); in max3421_urb_done()
1397 struct usb_hcd *hcd = dev_id; in max3421_spi_thread() local
1398 struct spi_device *spi = to_spi_device(hcd->self.controller); in max3421_spi_thread()
1399 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_spi_thread()
1403 spi_wr8(hcd, MAX3421_REG_PINCTL, in max3421_spi_thread()
1408 max3421_hcd->rev = spi_rd8(hcd, MAX3421_REG_REVISION); in max3421_spi_thread()
1425 spi_wr8(hcd, MAX3421_REG_HIEN, max3421_hcd->hien); in max3421_spi_thread()
1437 i_worked |= max3421_urb_done(hcd); in max3421_spi_thread()
1438 else if (max3421_handle_irqs(hcd)) in max3421_spi_thread()
1441 i_worked |= max3421_select_and_start_urb(hcd); in max3421_spi_thread()
1444 /* reset the HCD: */ in max3421_spi_thread()
1445 i_worked |= max3421_reset_hcd(hcd); in max3421_spi_thread()
1448 spi_wr8(hcd, MAX3421_REG_HCTL, in max3421_spi_thread()
1453 i_worked |= max3421_check_unlink(hcd); in max3421_spi_thread()
1460 u8 val = spi_rd8(hcd, MAX3421_REG_IOPINS1); in max3421_spi_thread()
1464 spi_wr8(hcd, MAX3421_REG_IOPINS1 + i, val); in max3421_spi_thread()
1476 max3421_reset_port(struct usb_hcd *hcd) in max3421_reset_port() argument
1478 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_reset_port()
1489 max3421_reset(struct usb_hcd *hcd) in max3421_reset() argument
1491 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_reset()
1493 hcd->self.sg_tablesize = 0; in max3421_reset()
1494 hcd->speed = HCD_USB2; in max3421_reset()
1495 hcd->self.root_hub->speed = USB_SPEED_FULL; in max3421_reset()
1502 max3421_start(struct usb_hcd *hcd) in max3421_start() argument
1504 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_start()
1511 hcd->power_budget = POWER_BUDGET; in max3421_start()
1512 hcd->state = HC_STATE_RUNNING; in max3421_start()
1513 hcd->uses_new_polling = 1; in max3421_start()
1518 max3421_stop(struct usb_hcd *hcd) in max3421_stop() argument
1523 max3421_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags) in max3421_urb_enqueue() argument
1525 struct spi_device *spi = to_spi_device(hcd->self.controller); in max3421_urb_enqueue()
1526 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_urb_enqueue()
1561 retval = usb_hcd_link_urb_to_ep(hcd, urb); in max3421_urb_enqueue()
1574 max3421_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) in max3421_urb_dequeue() argument
1576 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_urb_dequeue()
1586 retval = usb_hcd_check_unlink_urb(hcd, urb, status); in max3421_urb_dequeue()
1596 max3421_endpoint_disable(struct usb_hcd *hcd, struct usb_host_endpoint *ep) in max3421_endpoint_disable() argument
1598 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_endpoint_disable()
1617 max3421_get_frame_number(struct usb_hcd *hcd) in max3421_get_frame_number() argument
1619 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_get_frame_number()
1628 max3421_hub_status_data(struct usb_hcd *hcd, char *buf) in max3421_hub_status_data() argument
1630 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_hub_status_data()
1635 if (!HCD_HW_ACCESSIBLE(hcd)) in max3421_hub_status_data()
1641 dev_dbg(hcd->self.controller, in max3421_hub_status_data()
1646 usb_hcd_resume_root_hub(hcd); in max3421_hub_status_data()
1673 max3421_gpout_set_value(struct usb_hcd *hcd, u8 pin_number, u8 value) in max3421_gpout_set_value() argument
1675 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_gpout_set_value()
1694 max3421_hub_control(struct usb_hcd *hcd, u16 type_req, u16 value, u16 index, in max3421_hub_control() argument
1697 struct spi_device *spi = to_spi_device(hcd->self.controller); in max3421_hub_control()
1698 struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd); in max3421_hub_control()
1715 dev_dbg(hcd->self.controller, "power-off\n"); in max3421_hub_control()
1716 max3421_gpout_set_value(hcd, pdata->vbus_gpout, in max3421_hub_control()
1764 dev_dbg(hcd->self.controller, "power-on\n"); in max3421_hub_control()
1766 max3421_gpout_set_value(hcd, pdata->vbus_gpout, in max3421_hub_control()
1770 max3421_reset_port(hcd); in max3421_hub_control()
1780 dev_dbg(hcd->self.controller, in max3421_hub_control()
1792 max3421_bus_suspend(struct usb_hcd *hcd) in max3421_bus_suspend() argument
1798 max3421_bus_resume(struct usb_hcd *hcd) in max3421_bus_resume() argument
1848 struct usb_hcd *hcd = NULL; in max3421_probe() local
1892 hcd = usb_create_hcd(&max3421_hcd_desc, &spi->dev, in max3421_probe()
1894 if (!hcd) { in max3421_probe()
1895 dev_err(&spi->dev, "failed to create HCD structure\n"); in max3421_probe()
1898 set_bit(HCD_FLAG_POLL_RH, &hcd->flags); in max3421_probe()
1899 max3421_hcd = hcd_to_max3421(hcd); in max3421_probe()
1911 max3421_hcd->spi_thread = kthread_run(max3421_spi_thread, hcd, in max3421_probe()
1919 retval = usb_add_hcd(hcd, 0, 0); in max3421_probe()
1921 dev_err(&spi->dev, "failed to add HCD\n"); in max3421_probe()
1926 IRQF_TRIGGER_LOW, "max3421", hcd); in max3421_probe()
1939 if (hcd) { in max3421_probe()
1944 usb_put_hcd(hcd); in max3421_probe()
1953 struct usb_hcd *hcd = NULL; in max3421_remove() local
1958 hcd = max3421_to_hcd(max3421_hcd); in max3421_remove()
1959 if (hcd->self.controller == &spi->dev) in max3421_remove()
1963 dev_err(&spi->dev, "no MAX3421 HCD found for SPI device %p\n", in max3421_remove()
1968 usb_remove_hcd(hcd); in max3421_remove()
1977 free_irq(spi->irq, hcd); in max3421_remove()
1979 usb_put_hcd(hcd); in max3421_remove()
1993 .name = "max3421-hcd",