Lines Matching refs:fhci
34 void fhci_start_sof_timer(struct fhci_hcd *fhci) in fhci_start_sof_timer() argument
36 fhci_dbg(fhci, "-> %s\n", __func__); in fhci_start_sof_timer()
39 out_be16(&fhci->pram->frame_num, 0); in fhci_start_sof_timer()
41 out_be16(&fhci->regs->usb_ussft, 0); in fhci_start_sof_timer()
42 setbits8(&fhci->regs->usb_usmod, USB_MODE_SFTE); in fhci_start_sof_timer()
44 fhci_dbg(fhci, "<- %s\n", __func__); in fhci_start_sof_timer()
47 void fhci_stop_sof_timer(struct fhci_hcd *fhci) in fhci_stop_sof_timer() argument
49 fhci_dbg(fhci, "-> %s\n", __func__); in fhci_stop_sof_timer()
51 clrbits8(&fhci->regs->usb_usmod, USB_MODE_SFTE); in fhci_stop_sof_timer()
52 gtm_stop_timer16(fhci->timer); in fhci_stop_sof_timer()
54 fhci_dbg(fhci, "<- %s\n", __func__); in fhci_stop_sof_timer()
59 return be16_to_cpu(in_be16(&usb->fhci->regs->usb_ussft) / 12); in fhci_get_sof_timer_count()
82 struct fhci_hcd *fhci = usb->fhci; in fhci_usb_enable_interrupt() local
86 enable_irq(fhci_to_hcd(fhci)->irq); in fhci_usb_enable_interrupt()
89 out_be16(&usb->fhci->regs->usb_usber, 0xffff); in fhci_usb_enable_interrupt()
90 out_be16(&usb->fhci->regs->usb_usbmr, usb->saved_msk); in fhci_usb_enable_interrupt()
93 enable_irq(fhci->timer->irq); in fhci_usb_enable_interrupt()
95 fhci_info(fhci, "unbalanced USB interrupts nesting\n"); in fhci_usb_enable_interrupt()
102 struct fhci_hcd *fhci = usb->fhci; in fhci_usb_disable_interrupt() local
106 disable_irq_nosync(fhci->timer->irq); in fhci_usb_disable_interrupt()
109 disable_irq_nosync(fhci_to_hcd(fhci)->irq); in fhci_usb_disable_interrupt()
110 out_be16(&usb->fhci->regs->usb_usbmr, 0); in fhci_usb_disable_interrupt()
116 static u32 fhci_usb_enable(struct fhci_hcd *fhci) in fhci_usb_enable() argument
118 struct fhci_usb *usb = fhci->usb_lld; in fhci_usb_enable()
120 out_be16(&usb->fhci->regs->usb_usber, 0xffff); in fhci_usb_enable()
121 out_be16(&usb->fhci->regs->usb_usbmr, usb->saved_msk); in fhci_usb_enable()
122 setbits8(&usb->fhci->regs->usb_usmod, USB_MODE_EN); in fhci_usb_enable()
130 static u32 fhci_usb_disable(struct fhci_hcd *fhci) in fhci_usb_disable() argument
132 struct fhci_usb *usb = fhci->usb_lld; in fhci_usb_disable()
135 fhci_port_disable(fhci); in fhci_usb_disable()
140 fhci_device_disconnected_interrupt(fhci); in fhci_usb_disable()
142 clrbits8(&usb->fhci->regs->usb_usmod, USB_MODE_EN); in fhci_usb_disable()
148 int fhci_ioports_check_bus_state(struct fhci_hcd *fhci) in fhci_ioports_check_bus_state() argument
153 if (!gpiod_get_value(fhci->gpiods[GPIO_USBOE])) in fhci_ioports_check_bus_state()
157 if (gpiod_get_value(fhci->gpiods[GPIO_USBRP])) in fhci_ioports_check_bus_state()
161 if (gpiod_get_value(fhci->gpiods[GPIO_USBRN])) in fhci_ioports_check_bus_state()
167 static void fhci_mem_free(struct fhci_hcd *fhci) in fhci_mem_free() argument
174 list_for_each_entry_safe(ed, next_ed, &fhci->empty_eds, node) { in fhci_mem_free()
179 list_for_each_entry_safe(td, next_td, &fhci->empty_tds, node) { in fhci_mem_free()
184 kfree(fhci->vroot_hub); in fhci_mem_free()
185 fhci->vroot_hub = NULL; in fhci_mem_free()
187 kfree(fhci->hc_list); in fhci_mem_free()
188 fhci->hc_list = NULL; in fhci_mem_free()
191 static int fhci_mem_init(struct fhci_hcd *fhci) in fhci_mem_init() argument
195 fhci->hc_list = kzalloc(sizeof(*fhci->hc_list), GFP_KERNEL); in fhci_mem_init()
196 if (!fhci->hc_list) in fhci_mem_init()
199 INIT_LIST_HEAD(&fhci->hc_list->ctrl_list); in fhci_mem_init()
200 INIT_LIST_HEAD(&fhci->hc_list->bulk_list); in fhci_mem_init()
201 INIT_LIST_HEAD(&fhci->hc_list->iso_list); in fhci_mem_init()
202 INIT_LIST_HEAD(&fhci->hc_list->intr_list); in fhci_mem_init()
203 INIT_LIST_HEAD(&fhci->hc_list->done_list); in fhci_mem_init()
205 fhci->vroot_hub = kzalloc(sizeof(*fhci->vroot_hub), GFP_KERNEL); in fhci_mem_init()
206 if (!fhci->vroot_hub) in fhci_mem_init()
209 INIT_LIST_HEAD(&fhci->empty_eds); in fhci_mem_init()
210 INIT_LIST_HEAD(&fhci->empty_tds); in fhci_mem_init()
213 fhci_tasklet.data = (unsigned long)fhci; in fhci_mem_init()
214 fhci->process_done_task = &fhci_tasklet; in fhci_mem_init()
222 fhci_recycle_empty_td(fhci, td); in fhci_mem_init()
230 fhci_recycle_empty_ed(fhci, ed); in fhci_mem_init()
233 fhci->active_urbs = 0; in fhci_mem_init()
236 fhci_mem_free(fhci); in fhci_mem_init()
244 struct fhci_hcd *fhci; in fhci_usb_free() local
247 fhci = usb->fhci; in fhci_usb_free()
248 fhci_config_transceiver(fhci, FHCI_PORT_POWER_OFF); in fhci_usb_free()
256 static int fhci_usb_init(struct fhci_hcd *fhci) in fhci_usb_init() argument
258 struct fhci_usb *usb = fhci->usb_lld; in fhci_usb_init()
260 memset_io(usb->fhci->pram, 0, FHCI_PRAM_SIZE); in fhci_usb_init()
275 out_be16(&fhci->pram->frame_num, 0); in fhci_usb_init()
278 out_be32(&fhci->pram->rx_state, 0); in fhci_usb_init()
286 out_8(&usb->fhci->regs->usb_usmod, USB_MODE_HOST | USB_MODE_EN); in fhci_usb_init()
289 out_be16(&usb->fhci->regs->usb_usbmr, 0); in fhci_usb_init()
292 out_be16(&usb->fhci->regs->usb_usber, 0xffff); in fhci_usb_init()
303 static struct fhci_usb *fhci_create_lld(struct fhci_hcd *fhci) in fhci_create_lld() argument
312 usb->fhci = fhci; in fhci_create_lld()
313 usb->hc_list = fhci->hc_list; in fhci_create_lld()
314 usb->vroot_hub = fhci->vroot_hub; in fhci_create_lld()
324 struct fhci_hcd *fhci = hcd_to_fhci(hcd); in fhci_start() local
326 ret = fhci_mem_init(fhci); in fhci_start()
328 fhci_err(fhci, "failed to allocate memory\n"); in fhci_start()
332 fhci->usb_lld = fhci_create_lld(fhci); in fhci_start()
333 if (!fhci->usb_lld) { in fhci_start()
334 fhci_err(fhci, "low level driver config failed\n"); in fhci_start()
339 ret = fhci_usb_init(fhci); in fhci_start()
341 fhci_err(fhci, "low level driver initialize failed\n"); in fhci_start()
345 spin_lock_init(&fhci->lock); in fhci_start()
348 fhci->vroot_hub->dev_num = 1; /* this field may be needed to fix */ in fhci_start()
349 fhci->vroot_hub->hub.wHubStatus = 0; in fhci_start()
350 fhci->vroot_hub->hub.wHubChange = 0; in fhci_start()
351 fhci->vroot_hub->port.wPortStatus = 0; in fhci_start()
352 fhci->vroot_hub->port.wPortChange = 0; in fhci_start()
365 fhci_usb_enable(fhci); in fhci_start()
368 fhci_mem_free(fhci); in fhci_start()
374 struct fhci_hcd *fhci = hcd_to_fhci(hcd); in fhci_stop() local
376 fhci_usb_disable_interrupt(fhci->usb_lld); in fhci_stop()
377 fhci_usb_disable(fhci); in fhci_stop()
379 fhci_usb_free(fhci->usb_lld); in fhci_stop()
380 fhci->usb_lld = NULL; in fhci_stop()
381 fhci_mem_free(fhci); in fhci_stop()
387 struct fhci_hcd *fhci = hcd_to_fhci(hcd); in fhci_urb_enqueue() local
439 spin_lock_irqsave(&fhci->lock, flags); in fhci_urb_enqueue()
453 fhci_queue_urb(fhci, urb); in fhci_urb_enqueue()
459 spin_unlock_irqrestore(&fhci->lock, flags); in fhci_urb_enqueue()
466 struct fhci_hcd *fhci = hcd_to_fhci(hcd); in fhci_urb_dequeue() local
467 struct fhci_usb *usb = fhci->usb_lld; in fhci_urb_dequeue()
474 spin_lock_irqsave(&fhci->lock, flags); in fhci_urb_dequeue()
497 fhci_urb_complete_free(fhci, urb); in fhci_urb_dequeue()
501 spin_unlock_irqrestore(&fhci->lock, flags); in fhci_urb_dequeue()
509 struct fhci_hcd *fhci; in fhci_endpoint_disable() local
513 fhci = hcd_to_fhci(hcd); in fhci_endpoint_disable()
514 spin_lock_irqsave(&fhci->lock, flags); in fhci_endpoint_disable()
519 fhci_urb_complete_free(fhci, td->urb); in fhci_endpoint_disable()
521 fhci_recycle_empty_ed(fhci, ed); in fhci_endpoint_disable()
524 spin_unlock_irqrestore(&fhci->lock, flags); in fhci_endpoint_disable()
529 struct fhci_hcd *fhci = hcd_to_fhci(hcd); in fhci_get_frame_number() local
531 return get_frame_num(fhci); in fhci_get_frame_number()
565 struct fhci_hcd *fhci; in of_fhci_probe() local
589 fhci = hcd_to_fhci(hcd); in of_fhci_probe()
610 fhci->regs = hcd->regs; in of_fhci_probe()
629 fhci->pram = cpm_muram_addr(pram_addr); in of_fhci_probe()
634 fhci->gpiods[i] = devm_gpiod_get_index(dev, in of_fhci_probe()
638 fhci->gpiods[i] = devm_gpiod_get_index_optional(dev, in of_fhci_probe()
641 if (IS_ERR(fhci->gpiods[i])) { in of_fhci_probe()
643 i, PTR_ERR(fhci->gpiods[i])); in of_fhci_probe()
646 if (!fhci->gpiods[i]) { in of_fhci_probe()
654 fhci->pins[j] = qe_pin_request(node, j); in of_fhci_probe()
655 if (IS_ERR(fhci->pins[j])) { in of_fhci_probe()
656 ret = PTR_ERR(fhci->pins[j]); in of_fhci_probe()
663 fhci->timer = gtm_get_timer16(); in of_fhci_probe()
664 if (IS_ERR(fhci->timer)) { in of_fhci_probe()
665 ret = PTR_ERR(fhci->timer); in of_fhci_probe()
670 ret = request_irq(fhci->timer->irq, fhci_frame_limit_timer_irq, in of_fhci_probe()
688 fhci->fullspeed_clk = qe_clock_source(sprop); in of_fhci_probe()
689 if (fhci->fullspeed_clk == QE_CLK_DUMMY) { in of_fhci_probe()
698 fhci->lowspeed_clk = qe_clock_source(sprop); in of_fhci_probe()
699 if (fhci->lowspeed_clk == QE_CLK_DUMMY) { in of_fhci_probe()
706 if (fhci->fullspeed_clk == QE_CLK_NONE && in of_fhci_probe()
707 fhci->lowspeed_clk == QE_CLK_NONE) { in of_fhci_probe()
715 fhci_config_transceiver(fhci, FHCI_PORT_POWER_OFF); in of_fhci_probe()
718 if (fhci->fullspeed_clk != QE_CLK_NONE) { in of_fhci_probe()
719 fhci_config_transceiver(fhci, FHCI_PORT_FULL); in of_fhci_probe()
720 qe_usb_clock_set(fhci->fullspeed_clk, USB_CLOCK); in of_fhci_probe()
722 fhci_config_transceiver(fhci, FHCI_PORT_LOW); in of_fhci_probe()
723 qe_usb_clock_set(fhci->lowspeed_clk, USB_CLOCK >> 3); in of_fhci_probe()
727 out_be16(&fhci->regs->usb_usber, 0xffff); in of_fhci_probe()
728 out_be16(&fhci->regs->usb_usbmr, 0); in of_fhci_probe()
736 fhci_dfs_create(fhci); in of_fhci_probe()
744 free_irq(fhci->timer->irq, hcd); in of_fhci_probe()
746 gtm_put_timer16(fhci->timer); in of_fhci_probe()
750 qe_pin_free(fhci->pins[j]); in of_fhci_probe()
763 struct fhci_hcd *fhci = hcd_to_fhci(hcd); in fhci_remove() local
767 free_irq(fhci->timer->irq, hcd); in fhci_remove()
768 gtm_put_timer16(fhci->timer); in fhci_remove()
769 cpm_muram_free(cpm_muram_offset(fhci->pram)); in fhci_remove()
771 qe_pin_free(fhci->pins[j]); in fhci_remove()
772 fhci_dfs_destroy(fhci); in fhci_remove()