Lines Matching refs:fhci
35 void fhci_start_sof_timer(struct fhci_hcd *fhci) in fhci_start_sof_timer() argument
37 fhci_dbg(fhci, "-> %s\n", __func__); in fhci_start_sof_timer()
40 out_be16(&fhci->pram->frame_num, 0); in fhci_start_sof_timer()
42 out_be16(&fhci->regs->usb_ussft, 0); in fhci_start_sof_timer()
43 setbits8(&fhci->regs->usb_usmod, USB_MODE_SFTE); in fhci_start_sof_timer()
45 fhci_dbg(fhci, "<- %s\n", __func__); in fhci_start_sof_timer()
48 void fhci_stop_sof_timer(struct fhci_hcd *fhci) in fhci_stop_sof_timer() argument
50 fhci_dbg(fhci, "-> %s\n", __func__); in fhci_stop_sof_timer()
52 clrbits8(&fhci->regs->usb_usmod, USB_MODE_SFTE); in fhci_stop_sof_timer()
53 gtm_stop_timer16(fhci->timer); in fhci_stop_sof_timer()
55 fhci_dbg(fhci, "<- %s\n", __func__); in fhci_stop_sof_timer()
60 return be16_to_cpu(in_be16(&usb->fhci->regs->usb_ussft) / 12); in fhci_get_sof_timer_count()
83 struct fhci_hcd *fhci = usb->fhci; in fhci_usb_enable_interrupt() local
87 enable_irq(fhci_to_hcd(fhci)->irq); in fhci_usb_enable_interrupt()
90 out_be16(&usb->fhci->regs->usb_usber, 0xffff); in fhci_usb_enable_interrupt()
91 out_be16(&usb->fhci->regs->usb_usbmr, usb->saved_msk); in fhci_usb_enable_interrupt()
94 enable_irq(fhci->timer->irq); in fhci_usb_enable_interrupt()
96 fhci_info(fhci, "unbalanced USB interrupts nesting\n"); in fhci_usb_enable_interrupt()
103 struct fhci_hcd *fhci = usb->fhci; in fhci_usb_disable_interrupt() local
107 disable_irq_nosync(fhci->timer->irq); in fhci_usb_disable_interrupt()
110 disable_irq_nosync(fhci_to_hcd(fhci)->irq); in fhci_usb_disable_interrupt()
111 out_be16(&usb->fhci->regs->usb_usbmr, 0); in fhci_usb_disable_interrupt()
117 static u32 fhci_usb_enable(struct fhci_hcd *fhci) in fhci_usb_enable() argument
119 struct fhci_usb *usb = fhci->usb_lld; in fhci_usb_enable()
121 out_be16(&usb->fhci->regs->usb_usber, 0xffff); in fhci_usb_enable()
122 out_be16(&usb->fhci->regs->usb_usbmr, usb->saved_msk); in fhci_usb_enable()
123 setbits8(&usb->fhci->regs->usb_usmod, USB_MODE_EN); in fhci_usb_enable()
131 static u32 fhci_usb_disable(struct fhci_hcd *fhci) in fhci_usb_disable() argument
133 struct fhci_usb *usb = fhci->usb_lld; in fhci_usb_disable()
136 fhci_port_disable(fhci); in fhci_usb_disable()
141 fhci_device_disconnected_interrupt(fhci); in fhci_usb_disable()
143 clrbits8(&usb->fhci->regs->usb_usmod, USB_MODE_EN); in fhci_usb_disable()
149 int fhci_ioports_check_bus_state(struct fhci_hcd *fhci) in fhci_ioports_check_bus_state() argument
154 if (!gpiod_get_value(fhci->gpiods[GPIO_USBOE])) in fhci_ioports_check_bus_state()
158 if (gpiod_get_value(fhci->gpiods[GPIO_USBRP])) in fhci_ioports_check_bus_state()
162 if (gpiod_get_value(fhci->gpiods[GPIO_USBRN])) in fhci_ioports_check_bus_state()
168 static void fhci_mem_free(struct fhci_hcd *fhci) in fhci_mem_free() argument
175 list_for_each_entry_safe(ed, next_ed, &fhci->empty_eds, node) { in fhci_mem_free()
180 list_for_each_entry_safe(td, next_td, &fhci->empty_tds, node) { in fhci_mem_free()
185 kfree(fhci->vroot_hub); in fhci_mem_free()
186 fhci->vroot_hub = NULL; in fhci_mem_free()
188 kfree(fhci->hc_list); in fhci_mem_free()
189 fhci->hc_list = NULL; in fhci_mem_free()
192 static int fhci_mem_init(struct fhci_hcd *fhci) in fhci_mem_init() argument
196 fhci->hc_list = kzalloc(sizeof(*fhci->hc_list), GFP_KERNEL); in fhci_mem_init()
197 if (!fhci->hc_list) in fhci_mem_init()
200 INIT_LIST_HEAD(&fhci->hc_list->ctrl_list); in fhci_mem_init()
201 INIT_LIST_HEAD(&fhci->hc_list->bulk_list); in fhci_mem_init()
202 INIT_LIST_HEAD(&fhci->hc_list->iso_list); in fhci_mem_init()
203 INIT_LIST_HEAD(&fhci->hc_list->intr_list); in fhci_mem_init()
204 INIT_LIST_HEAD(&fhci->hc_list->done_list); in fhci_mem_init()
206 fhci->vroot_hub = kzalloc(sizeof(*fhci->vroot_hub), GFP_KERNEL); in fhci_mem_init()
207 if (!fhci->vroot_hub) in fhci_mem_init()
210 INIT_LIST_HEAD(&fhci->empty_eds); in fhci_mem_init()
211 INIT_LIST_HEAD(&fhci->empty_tds); in fhci_mem_init()
214 fhci_tasklet.data = (unsigned long)fhci; in fhci_mem_init()
215 fhci->process_done_task = &fhci_tasklet; in fhci_mem_init()
223 fhci_recycle_empty_td(fhci, td); in fhci_mem_init()
231 fhci_recycle_empty_ed(fhci, ed); in fhci_mem_init()
234 fhci->active_urbs = 0; in fhci_mem_init()
237 fhci_mem_free(fhci); in fhci_mem_init()
245 struct fhci_hcd *fhci; in fhci_usb_free() local
248 fhci = usb->fhci; in fhci_usb_free()
249 fhci_config_transceiver(fhci, FHCI_PORT_POWER_OFF); in fhci_usb_free()
257 static int fhci_usb_init(struct fhci_hcd *fhci) in fhci_usb_init() argument
259 struct fhci_usb *usb = fhci->usb_lld; in fhci_usb_init()
261 memset_io(usb->fhci->pram, 0, FHCI_PRAM_SIZE); in fhci_usb_init()
276 out_be16(&fhci->pram->frame_num, 0); in fhci_usb_init()
279 out_be32(&fhci->pram->rx_state, 0); in fhci_usb_init()
287 out_8(&usb->fhci->regs->usb_usmod, USB_MODE_HOST | USB_MODE_EN); in fhci_usb_init()
290 out_be16(&usb->fhci->regs->usb_usbmr, 0); in fhci_usb_init()
293 out_be16(&usb->fhci->regs->usb_usber, 0xffff); in fhci_usb_init()
304 static struct fhci_usb *fhci_create_lld(struct fhci_hcd *fhci) in fhci_create_lld() argument
313 usb->fhci = fhci; in fhci_create_lld()
314 usb->hc_list = fhci->hc_list; in fhci_create_lld()
315 usb->vroot_hub = fhci->vroot_hub; in fhci_create_lld()
325 struct fhci_hcd *fhci = hcd_to_fhci(hcd); in fhci_start() local
327 ret = fhci_mem_init(fhci); in fhci_start()
329 fhci_err(fhci, "failed to allocate memory\n"); in fhci_start()
333 fhci->usb_lld = fhci_create_lld(fhci); in fhci_start()
334 if (!fhci->usb_lld) { in fhci_start()
335 fhci_err(fhci, "low level driver config failed\n"); in fhci_start()
340 ret = fhci_usb_init(fhci); in fhci_start()
342 fhci_err(fhci, "low level driver initialize failed\n"); in fhci_start()
346 spin_lock_init(&fhci->lock); in fhci_start()
349 fhci->vroot_hub->dev_num = 1; /* this field may be needed to fix */ in fhci_start()
350 fhci->vroot_hub->hub.wHubStatus = 0; in fhci_start()
351 fhci->vroot_hub->hub.wHubChange = 0; in fhci_start()
352 fhci->vroot_hub->port.wPortStatus = 0; in fhci_start()
353 fhci->vroot_hub->port.wPortChange = 0; in fhci_start()
366 fhci_usb_enable(fhci); in fhci_start()
369 fhci_mem_free(fhci); in fhci_start()
375 struct fhci_hcd *fhci = hcd_to_fhci(hcd); in fhci_stop() local
377 fhci_usb_disable_interrupt(fhci->usb_lld); in fhci_stop()
378 fhci_usb_disable(fhci); in fhci_stop()
380 fhci_usb_free(fhci->usb_lld); in fhci_stop()
381 fhci->usb_lld = NULL; in fhci_stop()
382 fhci_mem_free(fhci); in fhci_stop()
388 struct fhci_hcd *fhci = hcd_to_fhci(hcd); in fhci_urb_enqueue() local
440 spin_lock_irqsave(&fhci->lock, flags); in fhci_urb_enqueue()
454 fhci_queue_urb(fhci, urb); in fhci_urb_enqueue()
460 spin_unlock_irqrestore(&fhci->lock, flags); in fhci_urb_enqueue()
467 struct fhci_hcd *fhci = hcd_to_fhci(hcd); in fhci_urb_dequeue() local
468 struct fhci_usb *usb = fhci->usb_lld; in fhci_urb_dequeue()
475 spin_lock_irqsave(&fhci->lock, flags); in fhci_urb_dequeue()
498 fhci_urb_complete_free(fhci, urb); in fhci_urb_dequeue()
502 spin_unlock_irqrestore(&fhci->lock, flags); in fhci_urb_dequeue()
510 struct fhci_hcd *fhci; in fhci_endpoint_disable() local
514 fhci = hcd_to_fhci(hcd); in fhci_endpoint_disable()
515 spin_lock_irqsave(&fhci->lock, flags); in fhci_endpoint_disable()
520 fhci_urb_complete_free(fhci, td->urb); in fhci_endpoint_disable()
522 fhci_recycle_empty_ed(fhci, ed); in fhci_endpoint_disable()
525 spin_unlock_irqrestore(&fhci->lock, flags); in fhci_endpoint_disable()
530 struct fhci_hcd *fhci = hcd_to_fhci(hcd); in fhci_get_frame_number() local
532 return get_frame_num(fhci); in fhci_get_frame_number()
566 struct fhci_hcd *fhci; in of_fhci_probe() local
590 fhci = hcd_to_fhci(hcd); in of_fhci_probe()
611 fhci->regs = hcd->regs; in of_fhci_probe()
630 fhci->pram = cpm_muram_addr(pram_addr); in of_fhci_probe()
635 fhci->gpiods[i] = devm_gpiod_get_index(dev, in of_fhci_probe()
639 fhci->gpiods[i] = devm_gpiod_get_index_optional(dev, in of_fhci_probe()
642 if (IS_ERR(fhci->gpiods[i])) { in of_fhci_probe()
644 i, PTR_ERR(fhci->gpiods[i])); in of_fhci_probe()
647 if (!fhci->gpiods[i]) { in of_fhci_probe()
655 fhci->pins[j] = qe_pin_request(dev, j); in of_fhci_probe()
656 if (IS_ERR(fhci->pins[j])) { in of_fhci_probe()
657 ret = PTR_ERR(fhci->pins[j]); in of_fhci_probe()
664 fhci->timer = gtm_get_timer16(); in of_fhci_probe()
665 if (IS_ERR(fhci->timer)) { in of_fhci_probe()
666 ret = PTR_ERR(fhci->timer); in of_fhci_probe()
671 ret = request_irq(fhci->timer->irq, fhci_frame_limit_timer_irq, in of_fhci_probe()
689 fhci->fullspeed_clk = qe_clock_source(sprop); in of_fhci_probe()
690 if (fhci->fullspeed_clk == QE_CLK_DUMMY) { in of_fhci_probe()
699 fhci->lowspeed_clk = qe_clock_source(sprop); in of_fhci_probe()
700 if (fhci->lowspeed_clk == QE_CLK_DUMMY) { in of_fhci_probe()
707 if (fhci->fullspeed_clk == QE_CLK_NONE && in of_fhci_probe()
708 fhci->lowspeed_clk == QE_CLK_NONE) { in of_fhci_probe()
716 fhci_config_transceiver(fhci, FHCI_PORT_POWER_OFF); in of_fhci_probe()
719 if (fhci->fullspeed_clk != QE_CLK_NONE) { in of_fhci_probe()
720 fhci_config_transceiver(fhci, FHCI_PORT_FULL); in of_fhci_probe()
721 qe_usb_clock_set(fhci->fullspeed_clk, USB_CLOCK); in of_fhci_probe()
723 fhci_config_transceiver(fhci, FHCI_PORT_LOW); in of_fhci_probe()
724 qe_usb_clock_set(fhci->lowspeed_clk, USB_CLOCK >> 3); in of_fhci_probe()
728 out_be16(&fhci->regs->usb_usber, 0xffff); in of_fhci_probe()
729 out_be16(&fhci->regs->usb_usbmr, 0); in of_fhci_probe()
737 fhci_dfs_create(fhci); in of_fhci_probe()
745 free_irq(fhci->timer->irq, hcd); in of_fhci_probe()
747 gtm_put_timer16(fhci->timer); in of_fhci_probe()
751 qe_pin_free(fhci->pins[j]); in of_fhci_probe()
764 struct fhci_hcd *fhci = hcd_to_fhci(hcd); in fhci_remove() local
768 free_irq(fhci->timer->irq, hcd); in fhci_remove()
769 gtm_put_timer16(fhci->timer); in fhci_remove()
770 cpm_muram_free(cpm_muram_offset(fhci->pram)); in fhci_remove()
772 qe_pin_free(fhci->pins[j]); in fhci_remove()
773 fhci_dfs_destroy(fhci); in fhci_remove()