unsigned ports = temp & RH_A_NDP;  
static int ohci_run (struct ohci_hcd *ohci){  	u32			mask, temp;	int			first = ohci->fminterval == 0;	disable (ohci);	/* boot firmware should have set this up (5.1.1.3.1) */	if (first) {		temp = ohci_readl (ohci, &ohci->regs->fminterval);		ohci->fminterval = temp & 0x3fff;		if (ohci->fminterval != FI)			ohci_dbg (ohci, "fminterval delta %d\n",				ohci->fminterval - FI);		ohci->fminterval |= FSMP (ohci->fminterval) << 16;		/* also: power/overcurrent flags in roothub.a */	}  	/* Reset USB nearly "by the book".  RemoteWakeupConnected	 * saved if boot firmware (BIOS/SMM/...) told us it's connected	 * (for OHCI integrated on mainboard, it normally is)	 */	ohci->hc_control = ohci_readl (ohci, &ohci->regs->control);	ohci_dbg (ohci, "resetting from state '%s', control = 0x%x\n",			hcfs2string (ohci->hc_control & OHCI_CTRL_HCFS),			ohci->hc_control);	if (ohci->hc_control & OHCI_CTRL_RWC			&& !(ohci->flags & OHCI_QUIRK_AMD756))		ohci_to_hcd(ohci)->can_wakeup = 1;	switch (ohci->hc_control & OHCI_CTRL_HCFS) {	case OHCI_USB_OPER:		temp = 0;		break;	case OHCI_USB_SUSPEND:	case OHCI_USB_RESUME:		ohci->hc_control &= OHCI_CTRL_RWC;		ohci->hc_control |= OHCI_USB_RESUME;		temp = 10 /* msec wait */;		break;	// case OHCI_USB_RESET:	default:		ohci->hc_control &= OHCI_CTRL_RWC;		ohci->hc_control |= OHCI_USB_RESET;		temp = 50 /* msec wait */;		break;	}	ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);	// flush the writes	(void) ohci_readl (ohci, &ohci->regs->control);	msleep(temp);	temp = roothub_a (ohci);	if (!(temp & RH_A_NPS)) {		unsigned ports = temp & RH_A_NDP; 		/* power down each port */		for (temp = 0; temp < ports; temp++)			ohci_writel (ohci, RH_PS_LSDA,				&ohci->regs->roothub.portstatus [temp]);	}	// flush those writes	(void) ohci_readl (ohci, &ohci->regs->control);	memset (ohci->hcca, 0, sizeof (struct ohci_hcca));	/* 2msec timelimit here means no irqs/preempt */	spin_lock_irq (&ohci->lock);retry:	/* HC Reset requires max 10 us delay */	ohci_writel (ohci, OHCI_HCR,  &ohci->regs->cmdstatus);	temp = 30;	/* ... allow extra time */	while ((ohci_readl (ohci, &ohci->regs->cmdstatus) & OHCI_HCR) != 0) {		if (--temp == 0) {			spin_unlock_irq (&ohci->lock);			ohci_err (ohci, "USB HC reset timed out!\n");			return -1;		}		udelay (1);	}	/* now we're in the SUSPEND state ... must go OPERATIONAL	 * within 2msec else HC enters RESUME	 *	 * ... but some hardware won't init fmInterval "by the book"	 * (SiS, OPTi ...), so reset again instead.  SiS doesn't need	 * this if we write fmInterval after we're OPERATIONAL.	 * Unclear about ALi, ServerWorks, and others ... this could	 * easily be a longstanding bug in chip init on Linux.	 */	if (ohci->flags & OHCI_QUIRK_INITRESET) {		ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);		// flush those writes		(void) ohci_readl (ohci, &ohci->regs->control);	}	/* Tell the controller where the control and bulk lists are	 * The lists are empty now. */	ohci_writel (ohci, 0, &ohci->regs->ed_controlhead);	ohci_writel (ohci, 0, &ohci->regs->ed_bulkhead);	/* a reset clears this */	ohci_writel (ohci, (u32) ohci->hcca_dma, &ohci->regs->hcca);	periodic_reinit (ohci);	/* some OHCI implementations are finicky about how they init.	 * bogus values here mean not even enumeration could work.	 */	if ((ohci_readl (ohci, &ohci->regs->fminterval) & 0x3fff0000) == 0			|| !ohci_readl (ohci, &ohci->regs->periodicstart)) {		if (!(ohci->flags & OHCI_QUIRK_INITRESET)) {			ohci->flags |= OHCI_QUIRK_INITRESET;			ohci_dbg (ohci, "enabling initreset quirk\n");			goto retry;		}		spin_unlock_irq (&ohci->lock);		ohci_err (ohci, "init err (%08x %04x)\n",			ohci_readl (ohci, &ohci->regs->fminterval),			ohci_readl (ohci, &ohci->regs->periodicstart));		return -EOVERFLOW;	} 	/* start controller operations */	ohci->hc_control &= OHCI_CTRL_RWC; 	ohci->hc_control |= OHCI_CONTROL_INIT | OHCI_USB_OPER; 	ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);	ohci_to_hcd(ohci)->state = HC_STATE_RUNNING;	/* wake on ConnectStatusChange, matching external hubs */	ohci_writel (ohci, RH_HS_DRWE, &ohci->regs->roothub.status);	/* Choose the interrupts we care about now, others later on demand */	mask = OHCI_INTR_INIT;	ohci_writel (ohci, mask, &ohci->regs->intrstatus);	ohci_writel (ohci, mask, &ohci->regs->intrenable);	/* handle root hub init quirks ... */	temp = roothub_a (ohci);	temp &= ~(RH_A_PSM | RH_A_OCPM);	if (ohci->flags & OHCI_QUIRK_SUPERIO) {		/* NSC 87560 and maybe others */		temp |= RH_A_NOCP;		temp &= ~(RH_A_POTPGT | RH_A_NPS);		ohci_writel (ohci, temp, &ohci->regs->roothub.a);	} else if ((ohci->flags & OHCI_QUIRK_AMD756) || distrust_firmware) {		/* hub power always on; required for AMD-756 and some		 * Mac platforms.  ganged overcurrent reporting, if any.		 */		temp |= RH_A_NPS;		ohci_writel (ohci, temp, &ohci->regs->roothub.a);	}	ohci_writel (ohci, RH_HS_LPSC, &ohci->regs->roothub.status);	ohci_writel (ohci, (temp & RH_A_NPS) ? 0 : RH_B_PPCM,						&ohci->regs->roothub.b);	// flush those writes	(void) ohci_readl (ohci, &ohci->regs->control);	spin_unlock_irq (&ohci->lock);	// POTPGT delay is bits 24-31, in 2 ms units.	mdelay ((temp >> 23) & 0x1fe);	ohci_to_hcd(ohci)->state = HC_STATE_RUNNING;	ohci_dump (ohci, 1);	if (ohci_to_hcd(ohci)->self.root_hub == NULL) {		register_reboot_notifier (&ohci->reboot_notifier);		create_debug_files (ohci);	}	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/fdd13b36c4a501d8787a27e54635fbd943f2685d/ohci-hcd.c/clean/drivers/usb/host/ohci-hcd.c