Lines Matching refs:ehci

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