Lines Matching refs:ehci

11 static void ehci_set_command_bit(struct ehci_hcd *ehci, u32 bit)  in ehci_set_command_bit()  argument
13 ehci->command |= bit; in ehci_set_command_bit()
14 ehci_writel(ehci, ehci->command, &ehci->regs->command); in ehci_set_command_bit()
17 ehci_readl(ehci, &ehci->regs->command); in ehci_set_command_bit()
21 static void ehci_clear_command_bit(struct ehci_hcd *ehci, u32 bit) in ehci_clear_command_bit() argument
23 ehci->command &= ~bit; in ehci_clear_command_bit()
24 ehci_writel(ehci, ehci->command, &ehci->regs->command); in ehci_clear_command_bit()
27 ehci_readl(ehci, &ehci->regs->command); in ehci_clear_command_bit()
76 static void ehci_enable_event(struct ehci_hcd *ehci, unsigned event, in ehci_enable_event() argument
79 ktime_t *timeout = &ehci->hr_timeouts[event]; in ehci_enable_event()
83 ehci->enabled_hrtimer_events |= (1 << event); in ehci_enable_event()
86 if (event < ehci->next_hrtimer_event) { in ehci_enable_event()
87 ehci->next_hrtimer_event = event; in ehci_enable_event()
88 hrtimer_start_range_ns(&ehci->hrtimer, *timeout, in ehci_enable_event()
95 static void ehci_poll_ASS(struct ehci_hcd *ehci) in ehci_poll_ASS() argument
100 if (ehci->rh_state != EHCI_RH_RUNNING) in ehci_poll_ASS()
103 want = (ehci->command & CMD_ASE) ? STS_ASS : 0; in ehci_poll_ASS()
104 actual = ehci_readl(ehci, &ehci->regs->status) & STS_ASS; in ehci_poll_ASS()
109 if (ehci->ASS_poll_count++ < 2) { in ehci_poll_ASS()
110 ehci_enable_event(ehci, EHCI_HRTIMER_POLL_ASS, true); in ehci_poll_ASS()
113 ehci_dbg(ehci, "Waited too long for the async schedule status (%x/%x), giving up\n", in ehci_poll_ASS()
116 ehci->ASS_poll_count = 0; in ehci_poll_ASS()
120 if (ehci->async_count > 0) in ehci_poll_ASS()
121 ehci_set_command_bit(ehci, CMD_ASE); in ehci_poll_ASS()
124 if (ehci->async_count == 0) { in ehci_poll_ASS()
127 ehci_enable_event(ehci, EHCI_HRTIMER_DISABLE_ASYNC, in ehci_poll_ASS()
134 static void ehci_disable_ASE(struct ehci_hcd *ehci) in ehci_disable_ASE() argument
136 ehci_clear_command_bit(ehci, CMD_ASE); in ehci_disable_ASE()
141 static void ehci_poll_PSS(struct ehci_hcd *ehci) in ehci_poll_PSS() argument
146 if (ehci->rh_state != EHCI_RH_RUNNING) in ehci_poll_PSS()
149 want = (ehci->command & CMD_PSE) ? STS_PSS : 0; in ehci_poll_PSS()
150 actual = ehci_readl(ehci, &ehci->regs->status) & STS_PSS; in ehci_poll_PSS()
155 if (ehci->PSS_poll_count++ < 2) { in ehci_poll_PSS()
156 ehci_enable_event(ehci, EHCI_HRTIMER_POLL_PSS, true); in ehci_poll_PSS()
159 ehci_dbg(ehci, "Waited too long for the periodic schedule status (%x/%x), giving up\n", in ehci_poll_PSS()
162 ehci->PSS_poll_count = 0; in ehci_poll_PSS()
166 if (ehci->periodic_count > 0) in ehci_poll_PSS()
167 ehci_set_command_bit(ehci, CMD_PSE); in ehci_poll_PSS()
170 if (ehci->periodic_count == 0) { in ehci_poll_PSS()
173 ehci_enable_event(ehci, EHCI_HRTIMER_DISABLE_PERIODIC, in ehci_poll_PSS()
180 static void ehci_disable_PSE(struct ehci_hcd *ehci) in ehci_disable_PSE() argument
182 ehci_clear_command_bit(ehci, CMD_PSE); in ehci_disable_PSE()
187 static void ehci_handle_controller_death(struct ehci_hcd *ehci) in ehci_handle_controller_death() argument
189 if (!(ehci_readl(ehci, &ehci->regs->status) & STS_HALT)) { in ehci_handle_controller_death()
192 if (ehci->died_poll_count++ < 5) { in ehci_handle_controller_death()
194 ehci_enable_event(ehci, EHCI_HRTIMER_POLL_DEAD, true); in ehci_handle_controller_death()
197 ehci_warn(ehci, "Waited too long for the controller to stop, giving up\n"); in ehci_handle_controller_death()
201 ehci->rh_state = EHCI_RH_HALTED; in ehci_handle_controller_death()
202 ehci_writel(ehci, 0, &ehci->regs->configured_flag); in ehci_handle_controller_death()
203 ehci_writel(ehci, 0, &ehci->regs->intr_enable); in ehci_handle_controller_death()
204 ehci_work(ehci); in ehci_handle_controller_death()
205 end_unlink_async(ehci); in ehci_handle_controller_death()
211 static void ehci_handle_start_intr_unlinks(struct ehci_hcd *ehci) in ehci_handle_start_intr_unlinks() argument
213 bool stopped = (ehci->rh_state < EHCI_RH_RUNNING); in ehci_handle_start_intr_unlinks()
222 while (!list_empty(&ehci->intr_unlink_wait)) { in ehci_handle_start_intr_unlinks()
225 qh = list_first_entry(&ehci->intr_unlink_wait, in ehci_handle_start_intr_unlinks()
228 ehci->intr_unlink_wait_cycle)) in ehci_handle_start_intr_unlinks()
232 start_unlink_intr(ehci, qh); in ehci_handle_start_intr_unlinks()
236 if (!list_empty(&ehci->intr_unlink_wait)) { in ehci_handle_start_intr_unlinks()
237 ehci_enable_event(ehci, EHCI_HRTIMER_START_UNLINK_INTR, true); in ehci_handle_start_intr_unlinks()
238 ++ehci->intr_unlink_wait_cycle; in ehci_handle_start_intr_unlinks()
243 static void ehci_handle_intr_unlinks(struct ehci_hcd *ehci) in ehci_handle_intr_unlinks() argument
245 bool stopped = (ehci->rh_state < EHCI_RH_RUNNING); in ehci_handle_intr_unlinks()
254 ehci->intr_unlinking = true; in ehci_handle_intr_unlinks()
255 while (!list_empty(&ehci->intr_unlink)) { in ehci_handle_intr_unlinks()
258 qh = list_first_entry(&ehci->intr_unlink, struct ehci_qh, in ehci_handle_intr_unlinks()
260 if (!stopped && qh->unlink_cycle == ehci->intr_unlink_cycle) in ehci_handle_intr_unlinks()
263 end_unlink_intr(ehci, qh); in ehci_handle_intr_unlinks()
267 if (!list_empty(&ehci->intr_unlink)) { in ehci_handle_intr_unlinks()
268 ehci_enable_event(ehci, EHCI_HRTIMER_UNLINK_INTR, true); in ehci_handle_intr_unlinks()
269 ++ehci->intr_unlink_cycle; in ehci_handle_intr_unlinks()
271 ehci->intr_unlinking = false; in ehci_handle_intr_unlinks()
276 static void start_free_itds(struct ehci_hcd *ehci) in start_free_itds() argument
278 if (!(ehci->enabled_hrtimer_events & BIT(EHCI_HRTIMER_FREE_ITDS))) { in start_free_itds()
279 ehci->last_itd_to_free = list_entry( in start_free_itds()
280 ehci->cached_itd_list.prev, in start_free_itds()
282 ehci->last_sitd_to_free = list_entry( in start_free_itds()
283 ehci->cached_sitd_list.prev, in start_free_itds()
285 ehci_enable_event(ehci, EHCI_HRTIMER_FREE_ITDS, true); in start_free_itds()
290 static void end_free_itds(struct ehci_hcd *ehci) in end_free_itds() argument
295 if (ehci->rh_state < EHCI_RH_RUNNING) { in end_free_itds()
296 ehci->last_itd_to_free = NULL; in end_free_itds()
297 ehci->last_sitd_to_free = NULL; in end_free_itds()
300 list_for_each_entry_safe(itd, n, &ehci->cached_itd_list, itd_list) { in end_free_itds()
302 dma_pool_free(ehci->itd_pool, itd, itd->itd_dma); in end_free_itds()
303 if (itd == ehci->last_itd_to_free) in end_free_itds()
306 list_for_each_entry_safe(sitd, sn, &ehci->cached_sitd_list, sitd_list) { in end_free_itds()
308 dma_pool_free(ehci->sitd_pool, sitd, sitd->sitd_dma); in end_free_itds()
309 if (sitd == ehci->last_sitd_to_free) in end_free_itds()
313 if (!list_empty(&ehci->cached_itd_list) || in end_free_itds()
314 !list_empty(&ehci->cached_sitd_list)) in end_free_itds()
315 start_free_itds(ehci); in end_free_itds()
320 static void ehci_iaa_watchdog(struct ehci_hcd *ehci) in ehci_iaa_watchdog() argument
330 if (!ehci->iaa_in_progress || ehci->rh_state != EHCI_RH_RUNNING) in ehci_iaa_watchdog()
339 cmd = ehci_readl(ehci, &ehci->regs->command); in ehci_iaa_watchdog()
348 status = ehci_readl(ehci, &ehci->regs->status); in ehci_iaa_watchdog()
350 INCR(ehci->stats.lost_iaa); in ehci_iaa_watchdog()
351 ehci_writel(ehci, STS_IAA, &ehci->regs->status); in ehci_iaa_watchdog()
354 ehci_dbg(ehci, "IAA watchdog: status %x cmd %x\n", status, cmd); in ehci_iaa_watchdog()
355 end_iaa_cycle(ehci); in ehci_iaa_watchdog()
360 static void turn_on_io_watchdog(struct ehci_hcd *ehci) in turn_on_io_watchdog() argument
363 if (ehci->rh_state != EHCI_RH_RUNNING || in turn_on_io_watchdog()
364 (ehci->enabled_hrtimer_events & in turn_on_io_watchdog()
372 if (ehci->isoc_count > 0 || (ehci->need_io_watchdog && in turn_on_io_watchdog()
373 ehci->async_count + ehci->intr_count > 0)) in turn_on_io_watchdog()
374 ehci_enable_event(ehci, EHCI_HRTIMER_IO_WATCHDOG, true); in turn_on_io_watchdog()
400 struct ehci_hcd *ehci = container_of(t, struct ehci_hcd, hrtimer); in ehci_hrtimer_func() local
406 spin_lock_irqsave(&ehci->lock, flags); in ehci_hrtimer_func()
408 events = ehci->enabled_hrtimer_events; in ehci_hrtimer_func()
409 ehci->enabled_hrtimer_events = 0; in ehci_hrtimer_func()
410 ehci->next_hrtimer_event = EHCI_HRTIMER_NO_EVENT; in ehci_hrtimer_func()
418 if (ktime_compare(now, ehci->hr_timeouts[e]) >= 0) in ehci_hrtimer_func()
419 event_handlers[e](ehci); in ehci_hrtimer_func()
421 ehci_enable_event(ehci, e, false); in ehci_hrtimer_func()
424 spin_unlock_irqrestore(&ehci->lock, flags); in ehci_hrtimer_func()