OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [or1ksim/] [peripheral/] [gpio.c] - Diff between revs 1564 and 1649

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 1564 Rev 1649
Line 45... Line 45...
static void gpio_external_clock( unsigned long value, struct gpio_device *gpio );
static void gpio_external_clock( unsigned long value, struct gpio_device *gpio );
static void gpio_device_clock( struct gpio_device *gpio );
static void gpio_device_clock( struct gpio_device *gpio );
static void gpio_clock( void *dat );
static void gpio_clock( void *dat );
 
 
/* Initialize all parameters and state */
/* Initialize all parameters and state */
void gpio_reset( void *dat )
static void gpio_reset( void *dat )
{
{
  struct gpio_device *gpio = dat;
  struct gpio_device *gpio = dat;
 
 
  if ( gpio->baseaddr != 0 ) {
  if ( gpio->baseaddr != 0 ) {
    /* Possibly connect to VAPI */
    /* Possibly connect to VAPI */
Line 60... Line 60...
  SCHED_ADD(gpio_clock, dat, 1);
  SCHED_ADD(gpio_clock, dat, 1);
}
}
 
 
 
 
/* Dump status */
/* Dump status */
void gpio_status( void *dat )
static void gpio_status( void *dat )
{
{
  struct gpio_device *gpio = dat;
  struct gpio_device *gpio = dat;
 
 
  if ( gpio->baseaddr == 0 )
  if ( gpio->baseaddr == 0 )
    return;
    return;
Line 80... Line 80...
  PRINTF( "RGPIO_INTS   : 0x%08lX\n", gpio->curr.ints );
  PRINTF( "RGPIO_INTS   : 0x%08lX\n", gpio->curr.ints );
}
}
 
 
 
 
/* Wishbone read */
/* Wishbone read */
uint32_t gpio_read32( oraddr_t addr, void *dat )
static uint32_t gpio_read32( oraddr_t addr, void *dat )
{
{
  struct gpio_device *gpio = dat;
  struct gpio_device *gpio = dat;
 
 
  switch( addr ) {
  switch( addr ) {
  case RGPIO_IN: return gpio->curr.in | gpio->curr.out;
  case RGPIO_IN: return gpio->curr.in | gpio->curr.out;
Line 100... Line 100...
  return 0;
  return 0;
}
}
 
 
 
 
/* Wishbone write */
/* Wishbone write */
void gpio_write32( oraddr_t addr, uint32_t value, void *dat )
static void gpio_write32( oraddr_t addr, uint32_t value, void *dat )
{
{
  struct gpio_device *gpio = dat;
  struct gpio_device *gpio = dat;
 
 
  switch( addr ) {
  switch( addr ) {
  case RGPIO_IN: TRACE( "GPIO: Cannot write to RGPIO_IN\n" ); break;
  case RGPIO_IN: TRACE( "GPIO: Cannot write to RGPIO_IN\n" ); break;
Line 118... Line 118...
  }
  }
}
}
 
 
 
 
/* Input from "outside world" */
/* Input from "outside world" */
void gpio_vapi_read( unsigned long id, unsigned long data, void *dat )
static void gpio_vapi_read( unsigned long id, unsigned long data, void *dat )
{
{
  unsigned which;
  unsigned which;
  struct gpio_device *gpio = dat;
  struct gpio_device *gpio = dat;
 
 
  TRACE( "GPIO: id %08lx, data %08lx\n", id, data );
  TRACE( "GPIO: id %08lx, data %08lx\n", id, data );
Line 186... Line 186...
    if ( gpio->curr.ctrl & RGPIO_CTRL_ECLK )
    if ( gpio->curr.ctrl & RGPIO_CTRL_ECLK )
      gpio_device_clock( gpio );
      gpio_device_clock( gpio );
}
}
 
 
/* Report an interrupt to the sim */
/* Report an interrupt to the sim */
void gpio_do_int( void *dat )
static void gpio_do_int( void *dat )
{
{
  struct gpio_device *gpio = dat;
  struct gpio_device *gpio = dat;
 
 
  report_interrupt( gpio->irq );
  report_interrupt( gpio->irq );
}
}
Line 237... Line 237...
  /* Switch to values for next clock */
  /* Switch to values for next clock */
  memcpy( &(gpio->curr), &(gpio->next), sizeof(gpio->curr) );
  memcpy( &(gpio->curr), &(gpio->next), sizeof(gpio->curr) );
}
}
 
 
/*---------------------------------------------------[ GPIO configuration ]---*/
/*---------------------------------------------------[ GPIO configuration ]---*/
void gpio_baseaddr(union param_val val, void *dat)
static void gpio_baseaddr(union param_val val, void *dat)
{
{
  struct gpio_device *gpio = dat;
  struct gpio_device *gpio = dat;
  gpio->baseaddr = val.addr_val;
  gpio->baseaddr = val.addr_val;
}
}
 
 
void gpio_irq(union param_val val, void *dat)
static void gpio_irq(union param_val val, void *dat)
{
{
  struct gpio_device *gpio = dat;
  struct gpio_device *gpio = dat;
  gpio->irq = val.int_val;
  gpio->irq = val.int_val;
}
}
 
 
void gpio_base_vapi_id(union param_val val, void *dat)
static void gpio_base_vapi_id(union param_val val, void *dat)
{
{
  struct gpio_device *gpio = dat;
  struct gpio_device *gpio = dat;
  gpio->base_vapi_id = val.int_val;
  gpio->base_vapi_id = val.int_val;
}
}
 
 
void gpio_enabled(union param_val val, void *dat)
static void gpio_enabled(union param_val val, void *dat)
{
{
  struct gpio_device *gpio = dat;
  struct gpio_device *gpio = dat;
  gpio->enabled = val.int_val;
  gpio->enabled = val.int_val;
}
}
 
 
void *gpio_sec_start(void)
static void *gpio_sec_start(void)
{
{
  struct gpio_device *new = malloc(sizeof(struct gpio_device));
  struct gpio_device *new = malloc(sizeof(struct gpio_device));
 
 
  if(!new) {
  if(!new) {
    fprintf(stderr, "Peripheral gpio: Run out of memory\n");
    fprintf(stderr, "Peripheral gpio: Run out of memory\n");
Line 279... Line 279...
  new->enabled = 1;
  new->enabled = 1;
 
 
  return new;
  return new;
}
}
 
 
void gpio_sec_end(void *dat)
static void gpio_sec_end(void *dat)
{
{
  struct gpio_device *gpio = dat;
  struct gpio_device *gpio = dat;
  struct mem_ops ops;
  struct mem_ops ops;
 
 
  if(!gpio->enabled) {
  if(!gpio->enabled) {

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.