FreeBSD/sys/powerpc/mpc85xx/mpc85xx_gpio.c
/* Set a specific output pin's value. */
Set a specific output pin's value.
Set a specific output pin ' s value .
static int
mpc85xx_gpio_pin_set(device_t dev, uint32_t pin, unsigned int value)
{
	struct mpc85xx_gpio_softc *sc = device_get_softc(dev);
	uint32_t outvals;
	uint8_t pinbit;
	if (!VALID_PIN(pin) || value > 1)
		return (EINVAL);
	GPIO_LOCK(sc);
	pinbit = 31 - pin;
	outvals = bus_read_4(sc->out_res, 0);
	outvals &= ~(1 << pinbit);
	outvals |= (value << pinbit);
	bus_write_4(sc->out_res, 0, outvals);
	GPIO_UNLOCK(sc);
	return (0);
}
static int mpc85xx_gpio_pin_set ( device_t dev , uint32_t pin , unsigned int value ) { struct mpc85xx_gpio_softc * sc = device_get_softc ( dev ) ; uint32_t outvals ; uint8_t pinbit ; if ( ! VALID_PIN ( pin ) || value > 1 ) return ( EINVAL ) ; GPIO_LOCK ( sc ) ; pinbit = 31 - pin ; outvals = bus_read_4 ( sc -> out_res , 0 ) ; outvals &= ~ ( 1 << pinbit ) ; outvals |= ( value << pinbit ) ; bus_write_4 ( sc -> out_res , 0 , outvals ) ; GPIO_UNLOCK ( sc ) ; return ( 0 ) ; }
Set a specific output pin's value.
Set a specific output pin ' s value .