示例#1
0
static int
gpioiic_reset(device_t dev, u_char speed, u_char addr, u_char *oldaddr)
{
	struct gpioiic_softc		*sc = device_get_softc(dev);

	GPIOBUS_LOCK_BUS(sc->sc_busdev);
	GPIOBUS_ACQUIRE_BUS(sc->sc_busdev, sc->sc_dev);

	gpioiic_reset_bus(sc->sc_dev);

	GPIOBUS_RELEASE_BUS(sc->sc_busdev, sc->sc_dev);
	GPIOBUS_UNLOCK_BUS(sc->sc_busdev);

	return (IIC_ENOADDR);
}
示例#2
0
文件: gpioled.c 项目: Lxg1582/freebsd
static void 
gpioled_control(void *priv, int onoff)
{
	int error;
	struct gpioled_softc *sc;

	sc = (struct gpioled_softc *)priv;
	GPIOLED_LOCK(sc);
	error = GPIOBUS_ACQUIRE_BUS(sc->sc_busdev, sc->sc_dev,
	    GPIOBUS_DONTWAIT);
	if (error != 0) {
		GPIOLED_UNLOCK(sc);
		return;
	}
	error = GPIOBUS_PIN_SETFLAGS(sc->sc_busdev, sc->sc_dev,
	    GPIOLED_PIN, GPIO_PIN_OUTPUT);
	if (error == 0)
		GPIOBUS_PIN_SET(sc->sc_busdev, sc->sc_dev, GPIOLED_PIN,
		    onoff ? GPIO_PIN_HIGH : GPIO_PIN_LOW);
	GPIOBUS_RELEASE_BUS(sc->sc_busdev, sc->sc_dev);
	GPIOLED_UNLOCK(sc);
}
示例#3
0
文件: gpioiic.c 项目: Alkzndr/freebsd
static int
gpioiic_callback(device_t dev, int index, caddr_t data)
{
	struct gpioiic_softc	*sc = device_get_softc(dev);
	int			error = 0;

	switch (index) {
	case IIC_REQUEST_BUS:
		GPIOBUS_LOCK_BUS(sc->sc_busdev);
		GPIOBUS_ACQUIRE_BUS(sc->sc_busdev, sc->sc_dev);
		GPIOBUS_UNLOCK_BUS(sc->sc_busdev);
		break;
	case IIC_RELEASE_BUS:
		GPIOBUS_LOCK_BUS(sc->sc_busdev);
		GPIOBUS_RELEASE_BUS(sc->sc_busdev, sc->sc_dev);
		GPIOBUS_UNLOCK_BUS(sc->sc_busdev);
		break;
	default:
		error = EINVAL;
	}

	return (error);
}