/* poll until we know a device is connected or we autostop */ if (rc == 0)
usb_hcd_poll_rh_status(hcd); return rc;
}
/* Carry out polling-, autostop-, and autoresume-related state changes */ staticint ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, int any_connected, int rhsc_status)
{ int poll_rh = 1; int rhsc_enable;
/* Some broken controllers never turn off RHSC in the interrupt *statusregister.Fortheirsakewewon'tre-enableRHSC *interruptsiftheinterruptbitisalreadyactive.
*/
rhsc_enable = ohci_readl(ohci, &ohci->regs->intrenable) &
OHCI_INTR_RHSC;
switch (ohci->hc_control & OHCI_CTRL_HCFS) { case OHCI_USB_OPER: /* If no status changes are pending, enable RHSC interrupts. */ if (!rhsc_enable && !rhsc_status && !changed) {
rhsc_enable = OHCI_INTR_RHSC;
ohci_writel(ohci, rhsc_enable, &ohci->regs->intrenable);
}
/* Keep on polling until we know a device is connected *andRHSCisenabled,oruntilweautostop.
*/ if (!ohci->autostop) { if (any_connected ||
!device_may_wakeup(&ohci_to_hcd(ohci)
->self.root_hub->dev)) { if (rhsc_enable)
poll_rh = 0;
} else {
ohci->autostop = 1;
ohci->next_statechange = jiffies + HZ;
}
/* if no devices have been attached for one second, autostop */
} else { if (changed || any_connected) {
ohci->autostop = 0;
ohci->next_statechange = jiffies +
STATECHANGE_DELAY;
} elseif (time_after_eq(jiffies,
ohci->next_statechange)
&& !ohci->ed_rm_list
&& !(ohci->hc_control &
OHCI_SCHED_ENABLES)) {
ohci_rh_suspend(ohci, 1); if (rhsc_enable)
poll_rh = 0;
}
} break;
case OHCI_USB_SUSPEND: case OHCI_USB_RESUME: /* if there is a port change, autostart or ask to be resumed */ if (changed) { if (ohci->autostop)
ohci_rh_resume(ohci); else
usb_hcd_resume_root_hub(ohci_to_hcd(ohci));
/* If remote wakeup is disabled, stop polling */
} elseif (!ohci->autostop &&
!ohci_to_hcd(ohci)->self.root_hub->
do_remote_wakeup) {
poll_rh = 0;
} else { /* If no status changes are pending, *enableRHSCinterrupts
*/ if (!rhsc_enable && !rhsc_status) {
rhsc_enable = OHCI_INTR_RHSC;
ohci_writel(ohci, rhsc_enable,
&ohci->regs->intrenable);
} /* Keep polling until RHSC is enabled */ if (rhsc_enable)
poll_rh = 0;
} break;
} return poll_rh;
}
/* Carry out polling-related state changes. *autostopisn'tusedwhenCONFIG_PMisturnedoff.
*/ staticint ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, int any_connected, int rhsc_status)
{ /* If RHSC is enabled, don't poll */ if (ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC) return0;
/* If status changes are pending, continue polling. *Conversely,ifnostatuschangesarependingbuttheRHSC *statusbitwasset,thenRHSCmaybebrokensocontinuepolling.
*/ if (changed || rhsc_status) return1;
/* Clear the RHSC status flag before reading the port statuses */
ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrstatus);
rhsc_status = ohci_readl(ohci, &ohci->regs->intrstatus) &
OHCI_INTR_RHSC;
/* look at each port */ for (i = 0; i < ohci->num_ports; i++) {
u32 status = roothub_portstatus (ohci, i);
/* can't autostop if ports are connected */
any_connected |= (status & RH_PS_CCS);
if (status & (RH_PS_CSC | RH_PS_PESC | RH_PS_PSSC
| RH_PS_OCIC | RH_PS_PRSC)) {
changed = 1; if (i < 7)
buf [0] |= 1 << (i + 1); else
buf [1] |= 1 << (i - 7);
}
}
if (ohci_root_hub_state_changes(ohci, changed,
any_connected, rhsc_status))
set_bit(HCD_FLAG_POLL_RH, &hcd->flags); else
clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
/* start port reset before HNP protocol times out */
status = ohci_readl(ohci, &ohci->regs->roothub.portstatus [port]); if (!(status & RH_PS_CCS)) return -ENODEV;
/* hub_wq will finish the reset later */
ohci_writel(ohci, RH_PS_PRS, &ohci->regs->roothub.portstatus [port]); return0;
}
/* See usb 7.1.7.5: root hubs must issue at least 50 msec reset signaling, *notnecessarilycontinuous...toguardagainstresumesignaling.
*/ #define PORT_RESET_MSEC 50
/* this timer value might be vendor-specific ... */ #define PORT_RESET_HW_MSEC 10
/* called from some task, normally hub_wq */ staticinlineint root_port_reset (struct ohci_hcd *ohci, unsigned port)
{
__hc32 __iomem *portstat = &ohci->regs->roothub.portstatus [port];
u32 temp = 0;
u16 now = ohci_readl(ohci, &ohci->regs->fmnumber);
u16 reset_done = now + PORT_RESET_MSEC; int limit_1 = DIV_ROUND_UP(PORT_RESET_MSEC, PORT_RESET_HW_MSEC);
/* build a "continuous enough" reset signal, with up to *3msecgapbetweenpulses.schedulerHZ==100mustwork; *thismightneedtobedeadline-scheduled.
*/ do { int limit_2;
/* spin until any current reset finishes */
limit_2 = PORT_RESET_HW_MSEC * 2; while (--limit_2 >= 0) {
temp = ohci_readl (ohci, portstat); /* handle e.g. CardBus eject */ if (temp == ~(u32)0) return -ESHUTDOWN; if (!(temp & RH_PS_PRS)) break;
udelay (500);
}
/* timeout (a hardware error) has been observed when *EHCIsetsCFwhilethisdriverisresettingaport; *presumablyotherdisconnectpathsmightdoittoo.
*/ if (limit_2 < 0) {
ohci_dbg(ohci, "port[%d] reset timeout, stat %08x\n",
port, temp); break;
}
if (!(temp & RH_PS_CCS)) break; if (temp & RH_PS_PRSC)
ohci_writel (ohci, RH_PS_PRSC, portstat);
/* start the next reset, sleep till it's probably done */
ohci_writel (ohci, RH_PS_PRS, portstat);
msleep(PORT_RESET_HW_MSEC);
now = ohci_readl(ohci, &ohci->regs->fmnumber);
} while (tick_before(now, reset_done) && --limit_1 >= 0);
/* caller synchronizes using PRSC ... and handles PRS *stillbeingsetwhenthisreturns.
*/
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.