Lines Matching refs:ehci
20 static void ehci_set_command_bit(struct ehci_hcd *ehci, u32 bit) in ehci_set_command_bit() argument
22 ehci->command |= bit; in ehci_set_command_bit()
23 ehci_writel(ehci, ehci->command, &ehci->regs->command); in ehci_set_command_bit()
26 ehci_readl(ehci, &ehci->regs->command); in ehci_set_command_bit()
30 static void ehci_clear_command_bit(struct ehci_hcd *ehci, u32 bit) in ehci_clear_command_bit() argument
32 ehci->command &= ~bit; in ehci_clear_command_bit()
33 ehci_writel(ehci, ehci->command, &ehci->regs->command); in ehci_clear_command_bit()
36 ehci_readl(ehci, &ehci->regs->command); in ehci_clear_command_bit()
84 static void ehci_enable_event(struct ehci_hcd *ehci, unsigned event, in ehci_enable_event() argument
87 ktime_t *timeout = &ehci->hr_timeouts[event]; in ehci_enable_event()
92 ehci->enabled_hrtimer_events |= (1 << event); in ehci_enable_event()
95 if (event < ehci->next_hrtimer_event) { in ehci_enable_event()
96 ehci->next_hrtimer_event = event; in ehci_enable_event()
97 hrtimer_start_range_ns(&ehci->hrtimer, *timeout, in ehci_enable_event()
104 static void ehci_poll_ASS(struct ehci_hcd *ehci) in ehci_poll_ASS() argument
109 if (ehci->rh_state != EHCI_RH_RUNNING) in ehci_poll_ASS()
112 want = (ehci->command & CMD_ASE) ? STS_ASS : 0; in ehci_poll_ASS()
113 actual = ehci_readl(ehci, &ehci->regs->status) & STS_ASS; in ehci_poll_ASS()
118 if (ehci->ASS_poll_count++ < 2) { in ehci_poll_ASS()
119 ehci_enable_event(ehci, EHCI_HRTIMER_POLL_ASS, true); in ehci_poll_ASS()
122 ehci_dbg(ehci, "Waited too long for the async schedule status (%x/%x), giving up\n", in ehci_poll_ASS()
125 ehci->ASS_poll_count = 0; in ehci_poll_ASS()
129 if (ehci->async_count > 0) in ehci_poll_ASS()
130 ehci_set_command_bit(ehci, CMD_ASE); in ehci_poll_ASS()
133 if (ehci->async_count == 0) { in ehci_poll_ASS()
136 ehci_enable_event(ehci, EHCI_HRTIMER_DISABLE_ASYNC, in ehci_poll_ASS()
143 static void ehci_disable_ASE(struct ehci_hcd *ehci) in ehci_disable_ASE() argument
145 ehci_clear_command_bit(ehci, CMD_ASE); in ehci_disable_ASE()
150 static void ehci_poll_PSS(struct ehci_hcd *ehci) in ehci_poll_PSS() argument
155 if (ehci->rh_state != EHCI_RH_RUNNING) in ehci_poll_PSS()
158 want = (ehci->command & CMD_PSE) ? STS_PSS : 0; in ehci_poll_PSS()
159 actual = ehci_readl(ehci, &ehci->regs->status) & STS_PSS; in ehci_poll_PSS()
164 if (ehci->PSS_poll_count++ < 2) { in ehci_poll_PSS()
165 ehci_enable_event(ehci, EHCI_HRTIMER_POLL_PSS, true); in ehci_poll_PSS()
168 ehci_dbg(ehci, "Waited too long for the periodic schedule status (%x/%x), giving up\n", in ehci_poll_PSS()
171 ehci->PSS_poll_count = 0; in ehci_poll_PSS()
175 if (ehci->periodic_count > 0) in ehci_poll_PSS()
176 ehci_set_command_bit(ehci, CMD_PSE); in ehci_poll_PSS()
179 if (ehci->periodic_count == 0) { in ehci_poll_PSS()
182 ehci_enable_event(ehci, EHCI_HRTIMER_DISABLE_PERIODIC, in ehci_poll_PSS()
189 static void ehci_disable_PSE(struct ehci_hcd *ehci) in ehci_disable_PSE() argument
191 ehci_clear_command_bit(ehci, CMD_PSE); in ehci_disable_PSE()
196 static void ehci_handle_controller_death(struct ehci_hcd *ehci) in ehci_handle_controller_death() argument
198 if (!(ehci_readl(ehci, &ehci->regs->status) & STS_HALT)) { in ehci_handle_controller_death()
201 if (ehci->died_poll_count++ < 5) { in ehci_handle_controller_death()
203 ehci_enable_event(ehci, EHCI_HRTIMER_POLL_DEAD, true); in ehci_handle_controller_death()
206 ehci_warn(ehci, "Waited too long for the controller to stop, giving up\n"); in ehci_handle_controller_death()
210 ehci->rh_state = EHCI_RH_HALTED; in ehci_handle_controller_death()
211 ehci_writel(ehci, 0, &ehci->regs->configured_flag); in ehci_handle_controller_death()
212 ehci_writel(ehci, 0, &ehci->regs->intr_enable); in ehci_handle_controller_death()
213 ehci_work(ehci); in ehci_handle_controller_death()
214 end_unlink_async(ehci); in ehci_handle_controller_death()
220 static void ehci_handle_start_intr_unlinks(struct ehci_hcd *ehci) in ehci_handle_start_intr_unlinks() argument
222 bool stopped = (ehci->rh_state < EHCI_RH_RUNNING); in ehci_handle_start_intr_unlinks()
231 while (!list_empty(&ehci->intr_unlink_wait)) { in ehci_handle_start_intr_unlinks()
234 qh = list_first_entry(&ehci->intr_unlink_wait, in ehci_handle_start_intr_unlinks()
237 ehci->intr_unlink_wait_cycle)) in ehci_handle_start_intr_unlinks()
240 start_unlink_intr(ehci, qh); in ehci_handle_start_intr_unlinks()
244 if (!list_empty(&ehci->intr_unlink_wait)) { in ehci_handle_start_intr_unlinks()
245 ehci_enable_event(ehci, EHCI_HRTIMER_START_UNLINK_INTR, true); in ehci_handle_start_intr_unlinks()
246 ++ehci->intr_unlink_wait_cycle; in ehci_handle_start_intr_unlinks()
251 static void ehci_handle_intr_unlinks(struct ehci_hcd *ehci) in ehci_handle_intr_unlinks() argument
253 bool stopped = (ehci->rh_state < EHCI_RH_RUNNING); in ehci_handle_intr_unlinks()
262 ehci->intr_unlinking = true; in ehci_handle_intr_unlinks()
263 while (!list_empty(&ehci->intr_unlink)) { in ehci_handle_intr_unlinks()
266 qh = list_first_entry(&ehci->intr_unlink, struct ehci_qh, in ehci_handle_intr_unlinks()
268 if (!stopped && qh->unlink_cycle == ehci->intr_unlink_cycle) in ehci_handle_intr_unlinks()
271 end_unlink_intr(ehci, qh); in ehci_handle_intr_unlinks()
275 if (!list_empty(&ehci->intr_unlink)) { in ehci_handle_intr_unlinks()
276 ehci_enable_event(ehci, EHCI_HRTIMER_UNLINK_INTR, true); in ehci_handle_intr_unlinks()
277 ++ehci->intr_unlink_cycle; in ehci_handle_intr_unlinks()
279 ehci->intr_unlinking = false; in ehci_handle_intr_unlinks()
284 static void start_free_itds(struct ehci_hcd *ehci) in start_free_itds() argument
286 if (!(ehci->enabled_hrtimer_events & BIT(EHCI_HRTIMER_FREE_ITDS))) { in start_free_itds()
287 ehci->last_itd_to_free = list_entry( in start_free_itds()
288 ehci->cached_itd_list.prev, in start_free_itds()
290 ehci->last_sitd_to_free = list_entry( in start_free_itds()
291 ehci->cached_sitd_list.prev, in start_free_itds()
293 ehci_enable_event(ehci, EHCI_HRTIMER_FREE_ITDS, true); in start_free_itds()
298 static void end_free_itds(struct ehci_hcd *ehci) in end_free_itds() argument
303 if (ehci->rh_state < EHCI_RH_RUNNING) { in end_free_itds()
304 ehci->last_itd_to_free = NULL; in end_free_itds()
305 ehci->last_sitd_to_free = NULL; in end_free_itds()
308 list_for_each_entry_safe(itd, n, &ehci->cached_itd_list, itd_list) { in end_free_itds()
310 dma_pool_free(ehci->itd_pool, itd, itd->itd_dma); in end_free_itds()
311 if (itd == ehci->last_itd_to_free) in end_free_itds()
314 list_for_each_entry_safe(sitd, sn, &ehci->cached_sitd_list, sitd_list) { in end_free_itds()
316 dma_pool_free(ehci->sitd_pool, sitd, sitd->sitd_dma); in end_free_itds()
317 if (sitd == ehci->last_sitd_to_free) in end_free_itds()
321 if (!list_empty(&ehci->cached_itd_list) || in end_free_itds()
322 !list_empty(&ehci->cached_sitd_list)) in end_free_itds()
323 start_free_itds(ehci); in end_free_itds()
328 static void ehci_iaa_watchdog(struct ehci_hcd *ehci) in ehci_iaa_watchdog() argument
338 if (!ehci->iaa_in_progress || ehci->rh_state != EHCI_RH_RUNNING) in ehci_iaa_watchdog()
347 cmd = ehci_readl(ehci, &ehci->regs->command); in ehci_iaa_watchdog()
356 status = ehci_readl(ehci, &ehci->regs->status); in ehci_iaa_watchdog()
358 COUNT(ehci->stats.lost_iaa); in ehci_iaa_watchdog()
359 ehci_writel(ehci, STS_IAA, &ehci->regs->status); in ehci_iaa_watchdog()
362 ehci_dbg(ehci, "IAA watchdog: status %x cmd %x\n", status, cmd); in ehci_iaa_watchdog()
363 end_unlink_async(ehci); in ehci_iaa_watchdog()
368 static void turn_on_io_watchdog(struct ehci_hcd *ehci) in turn_on_io_watchdog() argument
371 if (ehci->rh_state != EHCI_RH_RUNNING || in turn_on_io_watchdog()
372 (ehci->enabled_hrtimer_events & in turn_on_io_watchdog()
380 if (ehci->isoc_count > 0 || (ehci->need_io_watchdog && in turn_on_io_watchdog()
381 ehci->async_count + ehci->intr_count > 0)) in turn_on_io_watchdog()
382 ehci_enable_event(ehci, EHCI_HRTIMER_IO_WATCHDOG, true); in turn_on_io_watchdog()
407 struct ehci_hcd *ehci = container_of(t, struct ehci_hcd, hrtimer); in ehci_hrtimer_func() local
413 spin_lock_irqsave(&ehci->lock, flags); in ehci_hrtimer_func()
415 events = ehci->enabled_hrtimer_events; in ehci_hrtimer_func()
416 ehci->enabled_hrtimer_events = 0; in ehci_hrtimer_func()
417 ehci->next_hrtimer_event = EHCI_HRTIMER_NO_EVENT; in ehci_hrtimer_func()
425 if (now.tv64 >= ehci->hr_timeouts[e].tv64) in ehci_hrtimer_func()
426 event_handlers[e](ehci); in ehci_hrtimer_func()
428 ehci_enable_event(ehci, e, false); in ehci_hrtimer_func()
431 spin_unlock_irqrestore(&ehci->lock, flags); in ehci_hrtimer_func()