Lines Matching full:hcd
21 #include <linux/usb/hcd.h>
32 #include "isp1760-hcd.h"
39 typedef void (packet_enqueue)(struct usb_hcd *hcd, struct isp1760_qh *qh,
42 static inline struct isp1760_hcd *hcd_to_priv(struct usb_hcd *hcd) in hcd_to_priv() argument
44 return *(struct isp1760_hcd **)hcd->hcd_priv; in hcd_to_priv()
126 /* the rest is HCD-private */
337 static void alloc_mem(struct usb_hcd *hcd, struct isp1760_qtd *qtd) in alloc_mem() argument
339 struct isp1760_hcd *priv = hcd_to_priv(hcd); in alloc_mem()
357 static void free_mem(struct usb_hcd *hcd, struct isp1760_qtd *qtd) in free_mem() argument
359 struct isp1760_hcd *priv = hcd_to_priv(hcd); in free_mem()
374 dev_err(hcd->self.controller, "%s: Invalid pointer: %08x\n", in free_mem()
380 static int handshake(struct usb_hcd *hcd, u32 reg, in handshake() argument
386 ret = readl_poll_timeout_atomic(hcd->regs + reg, result, in handshake()
396 static int ehci_reset(struct usb_hcd *hcd) in ehci_reset() argument
398 struct isp1760_hcd *priv = hcd_to_priv(hcd); in ehci_reset()
400 u32 command = reg_read32(hcd->regs, HC_USBCMD); in ehci_reset()
403 reg_write32(hcd->regs, HC_USBCMD, command); in ehci_reset()
404 hcd->state = HC_STATE_HALT; in ehci_reset()
407 return handshake(hcd, HC_USBCMD, CMD_RESET, 0, 250 * 1000); in ehci_reset()
433 static int priv_init(struct usb_hcd *hcd) in priv_init() argument
435 struct isp1760_hcd *priv = hcd_to_priv(hcd); in priv_init()
451 hcc_params = reg_read32(hcd->regs, HC_HCCPARAMS); in priv_init()
461 static int isp1760_hc_setup(struct usb_hcd *hcd) in isp1760_hc_setup() argument
463 struct isp1760_hcd *priv = hcd_to_priv(hcd); in isp1760_hc_setup()
467 reg_write32(hcd->regs, HC_SCRATCH_REG, 0xdeadbabe); in isp1760_hc_setup()
469 scratch = reg_read32(hcd->regs, HC_CHIP_ID_REG); in isp1760_hc_setup()
470 scratch = reg_read32(hcd->regs, HC_SCRATCH_REG); in isp1760_hc_setup()
472 dev_err(hcd->self.controller, "Scratch test failed.\n"); in isp1760_hc_setup()
484 reg_write32(hcd->regs, HC_BUFFER_STATUS_REG, 0); in isp1760_hc_setup()
485 reg_write32(hcd->regs, HC_ATL_PTD_SKIPMAP_REG, NO_TRANSFER_ACTIVE); in isp1760_hc_setup()
486 reg_write32(hcd->regs, HC_INT_PTD_SKIPMAP_REG, NO_TRANSFER_ACTIVE); in isp1760_hc_setup()
487 reg_write32(hcd->regs, HC_ISO_PTD_SKIPMAP_REG, NO_TRANSFER_ACTIVE); in isp1760_hc_setup()
489 result = ehci_reset(hcd); in isp1760_hc_setup()
496 hwmode = reg_read32(hcd->regs, HC_HW_MODE_CTRL) & ~ALL_ATX_RESET; in isp1760_hc_setup()
497 reg_write32(hcd->regs, HC_HW_MODE_CTRL, hwmode | ALL_ATX_RESET); in isp1760_hc_setup()
499 reg_write32(hcd->regs, HC_HW_MODE_CTRL, hwmode); in isp1760_hc_setup()
501 reg_write32(hcd->regs, HC_INTERRUPT_ENABLE, INTERRUPT_ENABLE_MASK); in isp1760_hc_setup()
503 priv->hcs_params = reg_read32(hcd->regs, HC_HCSPARAMS); in isp1760_hc_setup()
505 return priv_init(hcd); in isp1760_hc_setup()
667 static void isp1760_urb_done(struct usb_hcd *hcd, struct urb *urb) in isp1760_urb_done() argument
671 struct isp1760_hcd *priv = hcd_to_priv(hcd); in isp1760_urb_done()
686 /* complete() can reenter this HCD */ in isp1760_urb_done()
687 usb_hcd_unlink_urb_from_ep(hcd, urb); in isp1760_urb_done()
689 usb_hcd_giveback_urb(hcd, urb, urb->status); in isp1760_urb_done()
717 static void start_bus_transfer(struct usb_hcd *hcd, u32 ptd_offset, int slot, in start_bus_transfer() argument
722 struct isp1760_hcd *priv = hcd_to_priv(hcd); in start_bus_transfer()
733 priv->atl_done_map |= reg_read32(hcd->regs, in start_bus_transfer()
737 priv->int_done_map |= reg_read32(hcd->regs, in start_bus_transfer()
747 ptd_write(hcd->regs, ptd_offset, slot, ptd); in start_bus_transfer()
750 skip_map = reg_read32(hcd->regs, HC_ATL_PTD_SKIPMAP_REG); in start_bus_transfer()
752 reg_write32(hcd->regs, HC_ATL_PTD_SKIPMAP_REG, skip_map); in start_bus_transfer()
754 skip_map = reg_read32(hcd->regs, HC_INT_PTD_SKIPMAP_REG); in start_bus_transfer()
756 reg_write32(hcd->regs, HC_INT_PTD_SKIPMAP_REG, skip_map); in start_bus_transfer()
766 static void collect_qtds(struct usb_hcd *hcd, struct isp1760_qh *qh, in collect_qtds() argument
786 mem_reads8(hcd->regs, qtd->payload_addr, in collect_qtds()
808 free_mem(hcd, qtd); in collect_qtds()
829 static void enqueue_qtds(struct usb_hcd *hcd, struct isp1760_qh *qh) in enqueue_qtds() argument
831 struct isp1760_hcd *priv = hcd_to_priv(hcd); in enqueue_qtds()
869 alloc_mem(hcd, qtd); in enqueue_qtds()
876 mem_writes8(hcd->regs, qtd->payload_addr, in enqueue_qtds()
886 dev_dbg(hcd->self.controller, "%s: No slot " in enqueue_qtds()
896 start_bus_transfer(hcd, ptd_offset, free_slot, in enqueue_qtds()
908 static void schedule_ptds(struct usb_hcd *hcd) in schedule_ptds() argument
917 if (!hcd) { in schedule_ptds()
922 priv = hcd_to_priv(hcd); in schedule_ptds()
930 collect_qtds(hcd, qh, &urb_list); in schedule_ptds()
938 isp1760_urb_done(hcd, urb_listitem->urb); in schedule_ptds()
969 enqueue_qtds(hcd, qh); in schedule_ptds()
977 static int check_int_transfer(struct usb_hcd *hcd, struct ptd *ptd, in check_int_transfer() argument
996 dev_dbg(hcd->self.controller, "%s: underrun " in check_int_transfer()
1002 dev_dbg(hcd->self.controller, "%s: transaction " in check_int_transfer()
1009 dev_dbg(hcd->self.controller, "%s: babble " in check_int_transfer()
1024 static int check_atl_transfer(struct usb_hcd *hcd, struct ptd *ptd, in check_atl_transfer() argument
1036 dev_dbg(hcd->self.controller, "%s: ptd error:\n" in check_atl_transfer()
1048 dev_dbg(hcd->self.controller, "PID error; reloading ptd\n"); in check_atl_transfer()
1064 static void handle_done_ptds(struct usb_hcd *hcd) in handle_done_ptds() argument
1066 struct isp1760_hcd *priv = hcd_to_priv(hcd); in handle_done_ptds()
1077 skip_map = reg_read32(hcd->regs, HC_INT_PTD_SKIPMAP_REG); in handle_done_ptds()
1079 skip_map = reg_read32(hcd->regs, HC_ATL_PTD_SKIPMAP_REG); in handle_done_ptds()
1097 ptd_read(hcd->regs, INT_PTD_OFFSET, slot, &ptd); in handle_done_ptds()
1098 state = check_int_transfer(hcd, &ptd, in handle_done_ptds()
1112 ptd_read(hcd->regs, ATL_PTD_OFFSET, slot, &ptd); in handle_done_ptds()
1113 state = check_atl_transfer(hcd, &ptd, in handle_done_ptds()
1183 dev_err(hcd->self.controller, in handle_done_ptds()
1193 start_bus_transfer(hcd, ptd_offset, slot, slots, qtd, in handle_done_ptds()
1199 schedule_ptds(hcd); in handle_done_ptds()
1202 static irqreturn_t isp1760_irq(struct usb_hcd *hcd) in isp1760_irq() argument
1204 struct isp1760_hcd *priv = hcd_to_priv(hcd); in isp1760_irq()
1210 if (!(hcd->state & HC_STATE_RUNNING)) in isp1760_irq()
1213 imask = reg_read32(hcd->regs, HC_INTERRUPT_REG); in isp1760_irq()
1216 reg_write32(hcd->regs, HC_INTERRUPT_REG, imask); /* Clear */ in isp1760_irq()
1218 priv->int_done_map |= reg_read32(hcd->regs, HC_INT_PTD_DONEMAP_REG); in isp1760_irq()
1219 priv->atl_done_map |= reg_read32(hcd->regs, HC_ATL_PTD_DONEMAP_REG); in isp1760_irq()
1221 handle_done_ptds(hcd); in isp1760_irq()
1262 struct usb_hcd *hcd = errata2_timer_hcd; in errata2_function() local
1263 struct isp1760_hcd *priv = hcd_to_priv(hcd); in errata2_function()
1274 ptd_read(hcd->regs, ATL_PTD_OFFSET, slot, &ptd); in errata2_function()
1281 handle_done_ptds(hcd); in errata2_function()
1289 static int isp1760_run(struct usb_hcd *hcd) in isp1760_run() argument
1296 hcd->uses_new_polling = 1; in isp1760_run()
1298 hcd->state = HC_STATE_RUNNING; in isp1760_run()
1301 reg_write32(hcd->regs, HC_ATL_IRQ_MASK_AND_REG, 0); in isp1760_run()
1302 reg_write32(hcd->regs, HC_ATL_IRQ_MASK_OR_REG, 0xffffffff); in isp1760_run()
1303 reg_write32(hcd->regs, HC_INT_IRQ_MASK_AND_REG, 0); in isp1760_run()
1304 reg_write32(hcd->regs, HC_INT_IRQ_MASK_OR_REG, 0xffffffff); in isp1760_run()
1305 reg_write32(hcd->regs, HC_ISO_IRQ_MASK_AND_REG, 0); in isp1760_run()
1306 reg_write32(hcd->regs, HC_ISO_IRQ_MASK_OR_REG, 0xffffffff); in isp1760_run()
1309 temp = reg_read32(hcd->regs, HC_HW_MODE_CTRL); in isp1760_run()
1310 reg_write32(hcd->regs, HC_HW_MODE_CTRL, temp | HW_GLOBAL_INTR_EN); in isp1760_run()
1312 command = reg_read32(hcd->regs, HC_USBCMD); in isp1760_run()
1315 reg_write32(hcd->regs, HC_USBCMD, command); in isp1760_run()
1317 retval = handshake(hcd, HC_USBCMD, CMD_RUN, CMD_RUN, 250 * 1000); in isp1760_run()
1327 reg_write32(hcd->regs, HC_CONFIGFLAG, FLAG_CF); in isp1760_run()
1329 retval = handshake(hcd, HC_CONFIGFLAG, FLAG_CF, FLAG_CF, 250 * 1000); in isp1760_run()
1334 errata2_timer_hcd = hcd; in isp1760_run()
1339 chipid = reg_read32(hcd->regs, HC_CHIP_ID_REG); in isp1760_run()
1340 dev_info(hcd->self.controller, "USB ISP %04x HW rev. %d started\n", in isp1760_run()
1346 reg_write32(hcd->regs, HC_ATL_PTD_LASTPTD_REG, 0x80000000); in isp1760_run()
1347 reg_write32(hcd->regs, HC_INT_PTD_LASTPTD_REG, 0x80000000); in isp1760_run()
1348 reg_write32(hcd->regs, HC_ISO_PTD_LASTPTD_REG, 0x00000001); in isp1760_run()
1349 reg_write32(hcd->regs, HC_ATL_PTD_SKIPMAP_REG, 0xffffffff); in isp1760_run()
1350 reg_write32(hcd->regs, HC_INT_PTD_SKIPMAP_REG, 0xffffffff); in isp1760_run()
1351 reg_write32(hcd->regs, HC_ISO_PTD_SKIPMAP_REG, 0xffffffff); in isp1760_run()
1352 reg_write32(hcd->regs, HC_BUFFER_STATUS_REG, in isp1760_run()
1388 static void packetize_urb(struct usb_hcd *hcd, in packetize_urb() argument
1402 dev_err(hcd->self.controller, in packetize_urb()
1489 static int isp1760_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, in isp1760_urb_enqueue() argument
1492 struct isp1760_hcd *priv = hcd_to_priv(hcd); in isp1760_urb_enqueue()
1514 dev_err(hcd->self.controller, "%s: isochronous USB packets " in isp1760_urb_enqueue()
1519 dev_err(hcd->self.controller, "%s: unknown pipe type\n", in isp1760_urb_enqueue()
1527 packetize_urb(hcd, urb, &new_qtds, mem_flags); in isp1760_urb_enqueue()
1534 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { in isp1760_urb_enqueue()
1539 retval = usb_hcd_link_urb_to_ep(hcd, urb); in isp1760_urb_enqueue()
1560 usb_hcd_unlink_urb_from_ep(hcd, urb); in isp1760_urb_enqueue()
1569 schedule_ptds(hcd); in isp1760_urb_enqueue()
1576 static void kill_transfer(struct usb_hcd *hcd, struct urb *urb, in kill_transfer() argument
1579 struct isp1760_hcd *priv = hcd_to_priv(hcd); in kill_transfer()
1587 skip_map = reg_read32(hcd->regs, HC_ATL_PTD_SKIPMAP_REG); in kill_transfer()
1589 reg_write32(hcd->regs, HC_ATL_PTD_SKIPMAP_REG, skip_map); in kill_transfer()
1593 skip_map = reg_read32(hcd->regs, HC_INT_PTD_SKIPMAP_REG); in kill_transfer()
1595 reg_write32(hcd->regs, HC_INT_PTD_SKIPMAP_REG, skip_map); in kill_transfer()
1607 static void dequeue_urb_from_qtd(struct usb_hcd *hcd, struct isp1760_qh *qh, in dequeue_urb_from_qtd() argument
1626 kill_transfer(hcd, urb, qh); in dequeue_urb_from_qtd()
1638 static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, in isp1760_urb_dequeue() argument
1641 struct isp1760_hcd *priv = hcd_to_priv(hcd); in isp1760_urb_dequeue()
1648 retval = usb_hcd_check_unlink_urb(hcd, urb, status); in isp1760_urb_dequeue()
1660 dequeue_urb_from_qtd(hcd, qh, qtd); in isp1760_urb_dequeue()
1666 schedule_ptds(hcd); in isp1760_urb_dequeue()
1673 static void isp1760_endpoint_disable(struct usb_hcd *hcd, in isp1760_endpoint_disable() argument
1676 struct isp1760_hcd *priv = hcd_to_priv(hcd); in isp1760_endpoint_disable()
1699 schedule_ptds(hcd); in isp1760_endpoint_disable()
1705 static int isp1760_hub_status_data(struct usb_hcd *hcd, char *buf) in isp1760_hub_status_data() argument
1707 struct isp1760_hcd *priv = hcd_to_priv(hcd); in isp1760_hub_status_data()
1714 if (!HC_IS_RUNNING(hcd->state)) in isp1760_hub_status_data()
1722 temp = reg_read32(hcd->regs, HC_PORTSC1); in isp1760_hub_status_data()
1727 reg_write32(hcd->regs, HC_PORTSC1, temp); in isp1760_hub_status_data()
1784 static int check_reset_complete(struct usb_hcd *hcd, int index, in check_reset_complete() argument
1793 dev_info(hcd->self.controller, in check_reset_complete()
1799 reg_write32(hcd->regs, HC_PORTSC1, port_status); in check_reset_complete()
1802 dev_info(hcd->self.controller, "port %d high speed\n", in check_reset_complete()
1808 static int isp1760_hub_control(struct usb_hcd *hcd, u16 typeReq, in isp1760_hub_control() argument
1811 struct isp1760_hcd *priv = hcd_to_priv(hcd); in isp1760_hub_control()
1840 temp = reg_read32(hcd->regs, HC_PORTSC1); in isp1760_hub_control()
1851 reg_write32(hcd->regs, HC_PORTSC1, temp & ~PORT_PE); in isp1760_hub_control()
1865 reg_write32(hcd->regs, HC_PORTSC1, in isp1760_hub_control()
1876 reg_write32(hcd->regs, HC_PORTSC1, in isp1760_hub_control()
1880 reg_write32(hcd->regs, HC_PORTSC1, temp | PORT_CSC); in isp1760_hub_control()
1891 reg_read32(hcd->regs, HC_USBCMD); in isp1760_hub_control()
1906 temp = reg_read32(hcd->regs, HC_PORTSC1); in isp1760_hub_control()
1915 dev_err(hcd->self.controller, "Port resume should be skipped.\n"); in isp1760_hub_control()
1923 mod_timer(&hcd->rh_timer, priv->reset_done); in isp1760_hub_control()
1933 temp = reg_read32(hcd->regs, HC_PORTSC1); in isp1760_hub_control()
1934 reg_write32(hcd->regs, HC_PORTSC1, in isp1760_hub_control()
1936 retval = handshake(hcd, HC_PORTSC1, in isp1760_hub_control()
1939 dev_err(hcd->self.controller, in isp1760_hub_control()
1956 reg_write32(hcd->regs, HC_PORTSC1, temp & ~PORT_RESET); in isp1760_hub_control()
1960 retval = handshake(hcd, HC_PORTSC1, in isp1760_hub_control()
1963 dev_err(hcd->self.controller, "port %d reset error %d\n", in isp1760_hub_control()
1969 temp = check_reset_complete(hcd, wIndex, in isp1760_hub_control()
1970 reg_read32(hcd->regs, HC_PORTSC1)); in isp1760_hub_control()
1979 dev_err(hcd->self.controller, "PORT_OWNER is set\n"); in isp1760_hub_control()
2012 temp = reg_read32(hcd->regs, HC_PORTSC1); in isp1760_hub_control()
2019 reg_write32(hcd->regs, HC_PORTSC1, temp | PORT_PE); in isp1760_hub_control()
2027 reg_write32(hcd->regs, HC_PORTSC1, temp | PORT_SUSPEND); in isp1760_hub_control()
2031 reg_write32(hcd->regs, HC_PORTSC1, in isp1760_hub_control()
2055 reg_write32(hcd->regs, HC_PORTSC1, temp); in isp1760_hub_control()
2060 reg_read32(hcd->regs, HC_USBCMD); in isp1760_hub_control()
2072 static int isp1760_get_frame(struct usb_hcd *hcd) in isp1760_get_frame() argument
2074 struct isp1760_hcd *priv = hcd_to_priv(hcd); in isp1760_get_frame()
2077 fr = reg_read32(hcd->regs, HC_FRINDEX); in isp1760_get_frame()
2081 static void isp1760_stop(struct usb_hcd *hcd) in isp1760_stop() argument
2083 struct isp1760_hcd *priv = hcd_to_priv(hcd); in isp1760_stop()
2088 isp1760_hub_control(hcd, ClearPortFeature, USB_PORT_FEAT_POWER, 1, in isp1760_stop()
2093 ehci_reset(hcd); in isp1760_stop()
2095 temp = reg_read32(hcd->regs, HC_HW_MODE_CTRL); in isp1760_stop()
2096 reg_write32(hcd->regs, HC_HW_MODE_CTRL, temp &= ~HW_GLOBAL_INTR_EN); in isp1760_stop()
2099 reg_write32(hcd->regs, HC_CONFIGFLAG, 0); in isp1760_stop()
2102 static void isp1760_shutdown(struct usb_hcd *hcd) in isp1760_shutdown() argument
2106 isp1760_stop(hcd); in isp1760_shutdown()
2107 temp = reg_read32(hcd->regs, HC_HW_MODE_CTRL); in isp1760_shutdown()
2108 reg_write32(hcd->regs, HC_HW_MODE_CTRL, temp &= ~HW_GLOBAL_INTR_EN); in isp1760_shutdown()
2110 command = reg_read32(hcd->regs, HC_USBCMD); in isp1760_shutdown()
2112 reg_write32(hcd->regs, HC_USBCMD, command); in isp1760_shutdown()
2115 static void isp1760_clear_tt_buffer_complete(struct usb_hcd *hcd, in isp1760_clear_tt_buffer_complete() argument
2118 struct isp1760_hcd *priv = hcd_to_priv(hcd); in isp1760_clear_tt_buffer_complete()
2127 schedule_ptds(hcd); in isp1760_clear_tt_buffer_complete()
2133 .description = "isp1760-hcd",
2189 struct usb_hcd *hcd; in isp1760_hcd_register() local
2192 hcd = usb_create_hcd(&isp1760_hc_driver, dev, dev_name(dev)); in isp1760_hcd_register()
2193 if (!hcd) in isp1760_hcd_register()
2196 *(struct isp1760_hcd **)hcd->hcd_priv = priv; in isp1760_hcd_register()
2198 priv->hcd = hcd; in isp1760_hcd_register()
2202 hcd->irq = irq; in isp1760_hcd_register()
2203 hcd->regs = regs; in isp1760_hcd_register()
2204 hcd->rsrc_start = mem->start; in isp1760_hcd_register()
2205 hcd->rsrc_len = resource_size(mem); in isp1760_hcd_register()
2208 hcd->cant_recv_wakeups = 1; in isp1760_hcd_register()
2210 ret = usb_add_hcd(hcd, irq, irqflags); in isp1760_hcd_register()
2214 device_wakeup_enable(hcd->self.controller); in isp1760_hcd_register()
2219 usb_put_hcd(hcd); in isp1760_hcd_register()
2225 if (!priv->hcd) in isp1760_hcd_unregister()
2228 usb_remove_hcd(priv->hcd); in isp1760_hcd_unregister()
2229 usb_put_hcd(priv->hcd); in isp1760_hcd_unregister()