Line 148... |
Line 148... |
printf( "gpio_read32( 0x%08lX ): Not in registered range(s)\n", addr );
|
printf( "gpio_read32( 0x%08lX ): Not in registered range(s)\n", addr );
|
return 0;
|
return 0;
|
}
|
}
|
|
|
switch( addr ) {
|
switch( addr ) {
|
case RGPIO_IN: gpio->next.ctrl &= ~RGPIO_CTRL_INT; return gpio->curr.in;
|
case RGPIO_IN: gpio->next.ctrl &= ~RGPIO_CTRL_INT; return gpio->curr.in | gpio->curr.out;
|
case RGPIO_OUT: return gpio->curr.out;
|
case RGPIO_OUT: return gpio->curr.out;
|
case RGPIO_OE: return gpio->curr.oe;
|
case RGPIO_OE: return gpio->curr.oe;
|
case RGPIO_INTE: return gpio->curr.inte;
|
case RGPIO_INTE: return gpio->curr.inte;
|
case RGPIO_PTRIG: return gpio->curr.ptrig;
|
case RGPIO_PTRIG: return gpio->curr.ptrig;
|
case RGPIO_AUX: return gpio->curr.aux;
|
case RGPIO_AUX: return gpio->curr.aux;
|
Line 234... |
Line 234... |
}
|
}
|
|
|
/* Clock as handld by one device. */
|
/* Clock as handld by one device. */
|
void gpio_device_clock( struct gpio_device *gpio )
|
void gpio_device_clock( struct gpio_device *gpio )
|
{
|
{
|
|
/* Calculate new inputs and outputs */
|
|
gpio->next.in &= ~gpio->next.oe; /* Only input bits */
|
|
/* Replace requested output bits with aux input */
|
|
gpio->next.out = (gpio->next.out & ~gpio->next.aux) | (gpio->auxiliary_inputs & gpio->next.aux);
|
|
gpio->next.out &= gpio->next.oe; /* Only output-enabled bits */
|
|
|
/* If any outputs changed, notify the world (i.e. vapi) */
|
/* If any outputs changed, notify the world (i.e. vapi) */
|
gpio->next.out = ((gpio->next.out & ~gpio->next.aux) | (gpio->auxiliary_inputs & gpio->next.aux)) & gpio->next.oe;
|
|
if ( gpio->next.out != gpio->curr.out )
|
if ( gpio->next.out != gpio->curr.out )
|
if ( gpio->vapi_ids[GPIO_VAPI_DATA] != 0 )
|
if ( gpio->vapi_ids[GPIO_VAPI_DATA] != 0 )
|
vapi_send( gpio->vapi_ids[GPIO_VAPI_DATA], gpio->next.out );
|
vapi_send( gpio->vapi_ids[GPIO_VAPI_DATA], gpio->next.out );
|
|
|
/* Check if any inputs changed */
|
/* If any inputs changed and interrupt enabled, generate interrupt */
|
gpio->next.in &= ~gpio->next.oe;
|
|
if ( (gpio->next.in != gpio->curr.in) && (gpio->next.ctrl & RGPIO_CTRL_INTE) ) {
|
if ( (gpio->next.in != gpio->curr.in) && (gpio->next.ctrl & RGPIO_CTRL_INTE) ) {
|
unsigned changed_bits = gpio->next.in ^ gpio->curr.in; /* inputs that have changed */
|
unsigned changed_bits = gpio->next.in ^ gpio->curr.in; /* inputs that have changed */
|
unsigned set_bits = changed_bits & gpio->next.in; /* inputs that have been set */
|
unsigned set_bits = changed_bits & gpio->next.in; /* inputs that have been set */
|
unsigned cleared_bits = changed_bits & gpio->curr.in; /* inputs that have been cleared */
|
unsigned cleared_bits = changed_bits & gpio->curr.in; /* inputs that have been cleared */
|
unsigned relevant_bits = (gpio->next.ptrig & set_bits) | (~gpio->next.ptrig & cleared_bits);
|
unsigned relevant_bits = (gpio->next.ptrig & set_bits) | (~gpio->next.ptrig & cleared_bits);
|