Lines Matching refs:ctrl

122 static int ehci_get_port_speed(struct ehci_ctrl *ctrl, uint32_t reg)  in ehci_get_port_speed()  argument
127 static void ehci_set_usbmode(struct ehci_ctrl *ctrl) in ehci_set_usbmode() argument
132 reg_ptr = (uint32_t *)((u8 *)&ctrl->hcor->or_usbcmd + USBMODE); in ehci_set_usbmode()
143 static void ehci_powerup_fixup(struct ehci_ctrl *ctrl, uint32_t *status_reg, in ehci_powerup_fixup() argument
149 static uint32_t *ehci_get_portsc_register(struct ehci_ctrl *ctrl, int port) in ehci_get_portsc_register() argument
151 int max_ports = HCS_N_PORTS(ehci_readl(&ctrl->hccr->cr_hcsparams)); in ehci_get_portsc_register()
160 return (uint32_t *)&ctrl->hcor->or_portsc[port]; in ehci_get_portsc_register()
179 static int ehci_reset(struct ehci_ctrl *ctrl) in ehci_reset() argument
184 cmd = ehci_readl(&ctrl->hcor->or_usbcmd); in ehci_reset()
186 ehci_writel(&ctrl->hcor->or_usbcmd, cmd); in ehci_reset()
187 ret = handshake((uint32_t *)&ctrl->hcor->or_usbcmd, in ehci_reset()
195 ctrl->ops.set_usb_mode(ctrl); in ehci_reset()
198 cmd = ehci_readl(&ctrl->hcor->or_txfilltuning); in ehci_reset()
201 ehci_writel(&ctrl->hcor->or_txfilltuning, cmd); in ehci_reset()
207 static int ehci_shutdown(struct ehci_ctrl *ctrl) in ehci_shutdown() argument
211 int max_ports = HCS_N_PORTS(ehci_readl(&ctrl->hccr->cr_hcsparams)); in ehci_shutdown()
213 cmd = ehci_readl(&ctrl->hcor->or_usbcmd); in ehci_shutdown()
218 ehci_writel(&ctrl->hcor->or_usbcmd, cmd); in ehci_shutdown()
219 ret = handshake(&ctrl->hcor->or_usbsts, STS_ASS | STS_PSS, 0, in ehci_shutdown()
224 reg = ehci_readl(&ctrl->hcor->or_portsc[i]); in ehci_shutdown()
226 ehci_writel(&ctrl->hcor->or_portsc[i], reg); in ehci_shutdown()
230 ehci_writel(&ctrl->hcor->or_usbcmd, cmd); in ehci_shutdown()
231 ret = handshake(&ctrl->hcor->or_usbsts, STS_HALT, STS_HALT, in ehci_shutdown()
316 struct ehci_ctrl *ctrl = ehci_get_ctrl(dev); in ehci_submit_async() local
407 qh->qh_link = cpu_to_hc32(virt_to_phys(&ctrl->qh_list) | QH_LINK_TYPE_QH); in ehci_submit_async()
540 ctrl->qh_list.qh_link = cpu_to_hc32(virt_to_phys(qh) | QH_LINK_TYPE_QH); in ehci_submit_async()
543 flush_dcache_range((unsigned long)&ctrl->qh_list, in ehci_submit_async()
544 ALIGN_END_ADDR(struct QH, &ctrl->qh_list, 1)); in ehci_submit_async()
549 usbsts = ehci_readl(&ctrl->hcor->or_usbsts); in ehci_submit_async()
550 ehci_writel(&ctrl->hcor->or_usbsts, (usbsts & 0x3f)); in ehci_submit_async()
553 cmd = ehci_readl(&ctrl->hcor->or_usbcmd); in ehci_submit_async()
556 ehci_writel(&ctrl->hcor->or_usbcmd, cmd); in ehci_submit_async()
558 ret = handshake((uint32_t *)&ctrl->hcor->or_usbsts, STS_ASS, STS_ASS, in ehci_submit_async()
572 invalidate_dcache_range((unsigned long)&ctrl->qh_list, in ehci_submit_async()
573 ALIGN_END_ADDR(struct QH, &ctrl->qh_list, 1)); in ehci_submit_async()
586 ctrl->qh_list.qh_link = cpu_to_hc32(virt_to_phys(&ctrl->qh_list) | QH_LINK_TYPE_QH); in ehci_submit_async()
587 flush_dcache_range((unsigned long)&ctrl->qh_list, in ehci_submit_async()
588 ALIGN_END_ADDR(struct QH, &ctrl->qh_list, 1)); in ehci_submit_async()
639 dev->devnum, ehci_readl(&ctrl->hcor->or_usbsts), in ehci_submit_async()
640 ehci_readl(&ctrl->hcor->or_portsc[0]), in ehci_submit_async()
641 ehci_readl(&ctrl->hcor->or_portsc[1])); in ehci_submit_async()
663 struct ehci_ctrl *ctrl = ehci_get_ctrl(dev); in ehci_submit_root() local
678 status_reg = ctrl->ops.get_portsc_register(ctrl, port - 1); in ehci_submit_root()
734 srcptr = &ctrl->hub; in ehci_submit_root()
735 srclen = ctrl->hub.bLength; in ehci_submit_root()
744 ctrl->rootdev = le16_to_cpu(req->value); in ehci_submit_root()
773 switch (ctrl->ops.get_port_speed(ctrl, reg)) { in ehci_submit_root()
794 if (ctrl->portreset & (1 << port)) in ehci_submit_root()
809 if (HCS_PPC(ehci_readl(&ctrl->hccr->cr_hcsparams))) { in ehci_submit_root()
835 ctrl->ops.powerup_fixup(ctrl, status_reg, &reg); in ehci_submit_root()
855 ctrl->portreset |= 1 << port; in ehci_submit_root()
864 ehci_shutdown(ctrl); in ehci_submit_root()
874 (void) ehci_readl(&ctrl->hcor->or_usbcmd); in ehci_submit_root()
887 if (HCS_PPC(ehci_readl(&ctrl->hccr->cr_hcsparams))) in ehci_submit_root()
897 ctrl->portreset &= ~(1 << port); in ehci_submit_root()
905 (void) ehci_readl(&ctrl->hcor->or_usbcmd); in ehci_submit_root()
940 static void ehci_setup_ops(struct ehci_ctrl *ctrl, const struct ehci_ops *ops) in ehci_setup_ops() argument
943 ctrl->ops = default_ehci_ops; in ehci_setup_ops()
945 ctrl->ops = *ops; in ehci_setup_ops()
946 if (!ctrl->ops.set_usb_mode) in ehci_setup_ops()
947 ctrl->ops.set_usb_mode = ehci_set_usbmode; in ehci_setup_ops()
948 if (!ctrl->ops.get_port_speed) in ehci_setup_ops()
949 ctrl->ops.get_port_speed = ehci_get_port_speed; in ehci_setup_ops()
950 if (!ctrl->ops.powerup_fixup) in ehci_setup_ops()
951 ctrl->ops.powerup_fixup = ehci_powerup_fixup; in ehci_setup_ops()
952 if (!ctrl->ops.get_portsc_register) in ehci_setup_ops()
953 ctrl->ops.get_portsc_register = in ehci_setup_ops()
961 struct ehci_ctrl *ctrl = &ehcic[index]; in ehci_set_controller_priv() local
963 ctrl->priv = priv; in ehci_set_controller_priv()
964 ehci_setup_ops(ctrl, ops); in ehci_set_controller_priv()
973 static int ehci_common_init(struct ehci_ctrl *ctrl, uint tweaks) in ehci_common_init() argument
982 if (ehci_readl(&ctrl->hccr->cr_hccparams) & 1) in ehci_common_init()
983 ehci_writel(&ctrl->hcor->or_ctrldssegment, 0); in ehci_common_init()
985 qh_list = &ctrl->qh_list; in ehci_common_init()
1001 ehci_writel(&ctrl->hcor->or_asynclistaddr, virt_to_phys(qh_list)); in ehci_common_init()
1007 ctrl->periodic_schedules = 0; in ehci_common_init()
1008 periodic = &ctrl->periodic_queue; in ehci_common_init()
1026 if (ctrl->periodic_list == NULL) in ehci_common_init()
1027 ctrl->periodic_list = memalign(4096, 1024 * 4); in ehci_common_init()
1029 if (!ctrl->periodic_list) in ehci_common_init()
1032 ctrl->periodic_list[i] = cpu_to_hc32((unsigned long)periodic in ehci_common_init()
1036 flush_dcache_range((unsigned long)ctrl->periodic_list, in ehci_common_init()
1037 ALIGN_END_ADDR(uint32_t, ctrl->periodic_list, in ehci_common_init()
1041 ehci_writel(&ctrl->hcor->or_periodiclistbase, in ehci_common_init()
1042 (unsigned long)ctrl->periodic_list); in ehci_common_init()
1044 reg = ehci_readl(&ctrl->hccr->cr_hcsparams); in ehci_common_init()
1056 memcpy(&ctrl->hub, &descriptor, sizeof(struct usb_hub_descriptor)); in ehci_common_init()
1059 cmd = ehci_readl(&ctrl->hcor->or_usbcmd); in ehci_common_init()
1066 ehci_writel(&ctrl->hcor->or_usbcmd, cmd); in ehci_common_init()
1070 cmd = ehci_readl(&ctrl->hcor->or_configflag); in ehci_common_init()
1072 ehci_writel(&ctrl->hcor->or_configflag, cmd); in ehci_common_init()
1076 cmd = ehci_readl(&ctrl->hcor->or_usbcmd); in ehci_common_init()
1078 reg = HC_VERSION(ehci_readl(&ctrl->hccr->cr_capbase)); in ehci_common_init()
1093 struct ehci_ctrl *ctrl = &ehcic[index]; in usb_lowlevel_init() local
1101 ctrl->ops = default_ehci_ops; in usb_lowlevel_init()
1103 rc = ehci_hcd_init(index, init, &ctrl->hccr, &ctrl->hcor); in usb_lowlevel_init()
1106 if (!ctrl->hccr || !ctrl->hcor) in usb_lowlevel_init()
1112 if (ehci_reset(ctrl)) in usb_lowlevel_init()
1116 rc = ehci_hcd_init(index, init, &ctrl->hccr, &ctrl->hcor); in usb_lowlevel_init()
1123 rc = ehci_common_init(ctrl, tweaks); in usb_lowlevel_init()
1127 ctrl->rootdev = 0; in usb_lowlevel_init()
1149 struct ehci_ctrl *ctrl = ehci_get_ctrl(dev); in _ehci_submit_control_msg() local
1156 if (usb_pipedevice(pipe) == ctrl->rootdev) { in _ehci_submit_control_msg()
1157 if (!ctrl->rootdev) in _ehci_submit_control_msg()
1176 enable_periodic(struct ehci_ctrl *ctrl) in enable_periodic() argument
1179 struct ehci_hcor *hcor = ctrl->hcor; in enable_periodic()
1197 disable_periodic(struct ehci_ctrl *ctrl) in disable_periodic() argument
1200 struct ehci_hcor *hcor = ctrl->hcor; in disable_periodic()
1220 struct ehci_ctrl *ctrl = ehci_get_ctrl(dev); in _ehci_create_int_queue() local
1343 if (ctrl->periodic_schedules > 0) { in _ehci_create_int_queue()
1344 if (disable_periodic(ctrl) < 0) { in _ehci_create_int_queue()
1351 struct QH *list = &ctrl->periodic_queue; in _ehci_create_int_queue()
1360 if (enable_periodic(ctrl) < 0) { in _ehci_create_int_queue()
1364 ctrl->periodic_schedules++; in _ehci_create_int_queue()
1424 struct ehci_ctrl *ctrl = ehci_get_ctrl(dev); in _ehci_destroy_int_queue() local
1428 if (disable_periodic(ctrl) < 0) { in _ehci_destroy_int_queue()
1432 ctrl->periodic_schedules--; in _ehci_destroy_int_queue()
1434 struct QH *cur = &ctrl->periodic_queue; in _ehci_destroy_int_queue()
1454 if (ctrl->periodic_schedules > 0) { in _ehci_destroy_int_queue()
1455 result = enable_periodic(ctrl); in _ehci_destroy_int_queue()
1611 struct ehci_ctrl *ctrl = dev_get_priv(dev); in ehci_register() local
1615 dev->name, ctrl, hccr, hcor, init); in ehci_register()
1617 if (!ctrl || !hccr || !hcor) in ehci_register()
1622 ehci_setup_ops(ctrl, ops); in ehci_register()
1623 ctrl->hccr = hccr; in ehci_register()
1624 ctrl->hcor = hcor; in ehci_register()
1625 ctrl->priv = ctrl; in ehci_register()
1627 ctrl->init = init; in ehci_register()
1628 if (ctrl->init == USB_INIT_DEVICE) in ehci_register()
1631 ret = ehci_reset(ctrl); in ehci_register()
1635 if (ctrl->ops.init_after_reset) { in ehci_register()
1636 ret = ctrl->ops.init_after_reset(ctrl); in ehci_register()
1641 ret = ehci_common_init(ctrl, tweaks); in ehci_register()
1647 free(ctrl); in ehci_register()
1654 struct ehci_ctrl *ctrl = dev_get_priv(dev); in ehci_deregister() local
1656 if (ctrl->init == USB_INIT_DEVICE) in ehci_deregister()
1659 ehci_shutdown(ctrl); in ehci_deregister()