Example #1
0
void
ehci_pci_takecontroller(struct ehci_pci_softc *sc, int silent)
{
	u_int32_t cparams, eec, legsup;
	int eecp, i;

	cparams = EREAD4(&sc->sc, EHCI_HCCPARAMS);
	/* Synchronise with the BIOS if it owns the controller. */
	for (eecp = EHCI_HCC_EECP(cparams); eecp != 0;
	    eecp = EHCI_EECP_NEXT(eec)) {
		eec = pci_conf_read(sc->sc_pc, sc->sc_tag, eecp);
		if (EHCI_EECP_ID(eec) != EHCI_EC_LEGSUP)
			continue;
		legsup = eec;
		if (legsup & EHCI_LEGSUP_BIOSOWNED) {
			pci_conf_write(sc->sc_pc, sc->sc_tag, eecp,
			    legsup | EHCI_LEGSUP_OSOWNED);
			DPRINTF(("%s: waiting for BIOS to give up control\n",
			    sc->sc.sc_bus.bdev.dv_xname));
			for (i = 0; i < 5000; i++) {
				legsup = pci_conf_read(sc->sc_pc, sc->sc_tag,
				    eecp);
				if ((legsup & EHCI_LEGSUP_BIOSOWNED) == 0)
					break;
				DELAY(1000);
			}
			if (silent == 0 && (legsup & EHCI_LEGSUP_BIOSOWNED))
				printf("%s: timed out waiting for BIOS\n",
				    sc->sc.sc_bus.bdev.dv_xname);
		}
	}
}
Example #2
0
static void
ehci_pci_takecontroller(device_t self)
{
	ehci_softc_t *sc = device_get_softc(self);
	u_int32_t cparams, eec;
	uint8_t bios_sem;
	int eecp, i;

	cparams = EREAD4(sc, EHCI_HCCPARAMS);

	/* Synchronise with the BIOS if it owns the controller. */
	for (eecp = EHCI_HCC_EECP(cparams); eecp != 0;
	    eecp = EHCI_EECP_NEXT(eec)) {
		eec = pci_read_config(self, eecp, 4);
		if (EHCI_EECP_ID(eec) != EHCI_EC_LEGSUP)
			continue;
		bios_sem = pci_read_config(self, eecp + EHCI_LEGSUP_BIOS_SEM,
		    1);
		if (bios_sem) {
			pci_write_config(self, eecp + EHCI_LEGSUP_OS_SEM, 1, 1);
			printf("%s: waiting for BIOS to give up control\n",
			    device_get_nameunit(sc->sc_bus.bdev));
			for (i = 0; i < 5000; i++) {
				bios_sem = pci_read_config(self, eecp +
				    EHCI_LEGSUP_BIOS_SEM, 1);
				if (bios_sem == 0)
					break;
				DELAY(1000);
			}
			if (bios_sem)
				printf("%s: timed out waiting for BIOS\n",
				    device_get_nameunit(sc->sc_bus.bdev));
		}
	}
}
Example #3
0
void
ehci_pci_givecontroller(struct ehci_pci_softc *sc)
{
	u_int32_t cparams, eec, legsup;
	int eecp;

	cparams = EREAD4(&sc->sc, EHCI_HCCPARAMS);
	for (eecp = EHCI_HCC_EECP(cparams); eecp != 0;
	    eecp = EHCI_EECP_NEXT(eec)) {
		eec = pci_conf_read(sc->sc_pc, sc->sc_tag, eecp);
		if (EHCI_EECP_ID(eec) != EHCI_EC_LEGSUP)
			continue;
		legsup = eec;
		pci_conf_write(sc->sc_pc, sc->sc_tag, eecp,
		    legsup & ~EHCI_LEGSUP_OSOWNED);
	}
}
Example #4
0
static int
ehci_pci_take_controller(device_t self)
{
	ehci_softc_t *sc = device_get_softc(self);
	uint32_t cparams;
	uint32_t eec;
	uint16_t to;
	uint8_t eecp;
	uint8_t bios_sem;

	cparams = EREAD4(sc, EHCI_HCCPARAMS);

	/* Synchronise with the BIOS if it owns the controller. */
	for (eecp = EHCI_HCC_EECP(cparams); eecp != 0;
	    eecp = EHCI_EECP_NEXT(eec)) {
		eec = pci_read_config(self, eecp, 4);
		if (EHCI_EECP_ID(eec) != EHCI_EC_LEGSUP) {
			continue;
		}
		bios_sem = pci_read_config(self, eecp +
		    EHCI_LEGSUP_BIOS_SEM, 1);
		if (bios_sem == 0) {
			continue;
		}
		device_printf(sc->sc_bus.bdev, "waiting for BIOS "
		    "to give up control\n");
		pci_write_config(self, eecp +
		    EHCI_LEGSUP_OS_SEM, 1, 1);
		to = 500;
		while (1) {
			bios_sem = pci_read_config(self, eecp +
			    EHCI_LEGSUP_BIOS_SEM, 1);
			if (bios_sem == 0)
				break;

			if (--to == 0) {
				device_printf(sc->sc_bus.bdev,
				    "timed out waiting for BIOS\n");
				break;
			}
			usb_pause_mtx(NULL, hz / 100);	/* wait 10ms */
		}
	}
	return (0);
}
Example #5
0
static void
ehci_pci_givecontroller(device_t self)
{
#if 0
	ehci_softc_t *sc = device_get_softc(self);
	u_int32_t cparams, eec;
	int eecp;

	cparams = EREAD4(sc, EHCI_HCCPARAMS);
	for (eecp = EHCI_HCC_EECP(cparams); eecp != 0;
	    eecp = EHCI_EECP_NEXT(eec)) {
		eec = pci_read_config(self, eecp, 4);
		if (EHCI_EECP_ID(eec) != EHCI_EC_LEGSUP)
			continue;
		pci_write_config(self, eecp + EHCI_LEGSUP_OS_SEM, 0, 1);
	}
#endif
}