Line 15... |
Line 15... |
|
|
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
*/
|
*/
|
|
#include <string.h>
|
|
|
|
#include "abstract.h"
|
#include "gpio.h"
|
#include "gpio.h"
|
#include "gpio_i.h"
|
#include "gpio_i.h"
|
#include "sim-config.h"
|
#include "sim-config.h"
|
#include "pic.h"
|
#include "pic.h"
|
#include "vapi.h"
|
#include "vapi.h"
|
|
#include "debug.h"
|
|
|
static struct gpio_device gpios[MAX_GPIOS];
|
static struct gpio_device gpios[MAX_GPIOS];
|
|
|
static void gpio_vapi_read( unsigned long id, unsigned long data );
|
static void gpio_vapi_read( unsigned long id, unsigned long data );
|
static unsigned long gpio_read32( unsigned long addr );
|
static unsigned long gpio_read32( unsigned long addr );
|
Line 37... |
Line 40... |
|
|
/* Initialize all parameters and state */
|
/* Initialize all parameters and state */
|
void gpio_reset( void )
|
void gpio_reset( void )
|
{
|
{
|
static int first_time = 1;
|
static int first_time = 1;
|
unsigned i, j;
|
unsigned i;
|
|
|
if ( first_time ) {
|
if ( first_time ) {
|
memset( gpios, 0, sizeof(gpios) );
|
memset( gpios, 0, sizeof(gpios) );
|
first_time = 0;
|
first_time = 0;
|
}
|
}
|
Line 78... |
Line 81... |
struct gpio_device *gpio = &(gpios[i]);
|
struct gpio_device *gpio = &(gpios[i]);
|
|
|
if ( gpio->baseaddr == 0 )
|
if ( gpio->baseaddr == 0 )
|
continue;
|
continue;
|
|
|
PRINTF( "\nGPIO %u at 0x%08X:\n", i, gpio->baseaddr );
|
PRINTF( "\nGPIO %u at 0x%08lX:\n", i, gpio->baseaddr );
|
PRINTF( "RGPIO_IN : 0x%08lX\n", gpio->curr.in );
|
PRINTF( "RGPIO_IN : 0x%08lX\n", gpio->curr.in );
|
PRINTF( "RGPIO_OUT : 0x%08lX\n", gpio->curr.out );
|
PRINTF( "RGPIO_OUT : 0x%08lX\n", gpio->curr.out );
|
PRINTF( "RGPIO_OE : 0x%08lX\n", gpio->curr.oe );
|
PRINTF( "RGPIO_OE : 0x%08lX\n", gpio->curr.oe );
|
PRINTF( "RGPIO_INTE : 0x%08lX\n", gpio->curr.inte );
|
PRINTF( "RGPIO_INTE : 0x%08lX\n", gpio->curr.inte );
|
PRINTF( "RGPIO_PTRIG : 0x%08lX\n", gpio->curr.ptrig );
|
PRINTF( "RGPIO_PTRIG : 0x%08lX\n", gpio->curr.ptrig );
|
Line 119... |
Line 122... |
|
|
|
|
/* Find device by vapi id */
|
/* Find device by vapi id */
|
struct gpio_device *gpio_find_vapi_device( unsigned long id, unsigned *which )
|
struct gpio_device *gpio_find_vapi_device( unsigned long id, unsigned *which )
|
{
|
{
|
unsigned i, j;
|
unsigned i;
|
|
|
for ( i = 0; i < config.ngpios; ++ i )
|
for ( i = 0; i < config.ngpios; ++ i )
|
if ( (id >= gpios[i].base_vapi_id) && (id < gpios[i].base_vapi_id + GPIO_NUM_VAPI_IDS) ) {
|
if ( (id >= gpios[i].base_vapi_id) && (id < gpios[i].base_vapi_id + GPIO_NUM_VAPI_IDS) ) {
|
*which = id - gpios[i].base_vapi_id;
|
*which = id - gpios[i].base_vapi_id;
|
return &(gpios[i]);
|
return &(gpios[i]);
|