FreeBSD/sys/arm/ti/ti_pinmux.c
/**
 *	ti_pinmux_padconf_get_gpiomode - gets the current GPIO mode of the pin
 *	@gpio: the GPIO pin number (0-195)
 *	@state: upon return will contain the state
 *
 *
 *
 *	LOCKING:
 *	Internally locks it's own context.
 *
 *	RETURNS:
 *	0 on success.
 *	EINVAL if pin requested is outside valid range or not configured as GPIO.
 */
gets the current GPIO mode of the pin
@gpio: the GPIO pin number (0-195)
@state: upon return will contain the state



Internally locks it's own context.

0 on success.
EINVAL if pin requested is outside valid range or not configured as GPIO.
gets the current GPIO mode of the pin @gpio : the GPIO pin number ( 0 - 195 ) @state : upon return will contain the state Internally locks it ' s own context . 0 on success . EINVAL if pin requested is outside valid range or not configured as GPIO .
int
ti_pinmux_padconf_get_gpiomode(uint32_t gpio, unsigned int *state)
{
	const struct ti_pinmux_padconf *padconf;
	uint16_t reg_val;
	if (!ti_pinmux_sc)
		return (ENXIO);
	padconf = ti_pinmux_dev.padconf;
	while (padconf->ballname != NULL) {
		if (padconf->gpio_pin == gpio)
			break;
		padconf++;
	}
	if (padconf->ballname == NULL)
		return (EINVAL);
	reg_val = ti_pinmux_read_2(ti_pinmux_sc, padconf->reg_off);
	if ((reg_val & ti_pinmux_dev.padconf_muxmode_mask) != padconf->gpio_mode)
		return (EINVAL);
	if (state)
		*state = (reg_val & ti_pinmux_dev.padconf_sate_mask);
	return (0);
}
int ti_pinmux_padconf_get_gpiomode ( uint32_t gpio , unsigned int * state ) { const struct ti_pinmux_padconf * padconf ; uint16_t reg_val ; if ( ! ti_pinmux_sc ) return ( ENXIO ) ; padconf = ti_pinmux_dev . padconf ; while ( padconf -> ballname != NULL ) { if ( padconf -> gpio_pin == gpio ) break ; padconf ++ ; } if ( padconf -> ballname == NULL ) return ( EINVAL ) ; reg_val = ti_pinmux_read_2 ( ti_pinmux_sc , padconf -> reg_off ) ; if ( ( reg_val & ti_pinmux_dev . padconf_muxmode_mask ) != padconf -> gpio_mode ) return ( EINVAL ) ; if ( state ) * state = ( reg_val & ti_pinmux_dev . padconf_sate_mask ) ; return ( 0 ) ; }
ti_pinmux_padconf_get_gpiomode - gets the current GPIO mode of the pin
      @gpio: the GPIO pin number (0-195)
      @state: upon return will contain the state
ti_pinmux_padconf_get_gpiomode - gets the current GPIO mode of the pin @gpio : the GPIO pin number ( 0 - 195 ) @state : upon return will contain the state
/* find the gpio pin in the padconf array */ /* read the current register settings */ /* check to make sure the pins is configured as GPIO in the first state */ /* read and store the reset of the state, i.e. pull-up, pull-down, etc */