Esempio n. 1
0
/*===========================================================================
  FUNCTION GPIO_IN

  DESCRIPTION
    Reads the the corresponding GPIO register given a GPIO signal type and
    extracts the value for that particular GPIO. This function calculates the
    GPIO register and the mask value required to return the GPIO value.

  DEPENDENCIES
    None.

  RETURN VALUE
    GPIO value at the given GPIO number
===========================================================================*/
GPIO_ValueType gpio_in( GPIO_SignalType gpio_signal )
{
  uint32             gpio_in_register;
  uint32             gpio_mask;
  uint32             gpio_value;
  uint8              gpio_number;

  gpio_number = GPIO_NUMBER(gpio_signal);

  if (gpio_number >= GPIO_NUM_GPIOS)
  {
	  #ifndef BUILD_BOOT_CHAIN
      ERR_FATAL("Invalid GPIO number 0x%x",gpio_number, 0, 0);
	  #endif
	  return;
  }
  gpio_in_register = GPIO_GROUP(gpio_signal);

  gpio_mask        = 1 <<(gpio_number-GPIO_GROUP_START[gpio_in_register]);
  gpio_value       = inpdw(bio_gpio[gpio_in_register].in_addr) & gpio_mask;

  if (gpio_value == 0)
  {
    return GPIO_LOW_VALUE;
  } 
  else
  {
    return GPIO_HIGH_VALUE;
  }
}
Esempio n. 2
0
/*===========================================================================

  FUNCTION GPIO_TRISTATE

  DESCRIPTION
   This function enables/ disables tri-state on specified GPIO.  Writing a value 0 
   (GPIO_TRISTATE_DISABLE) disables the tristate and writing a value 1 (GPIO_TRISTATE_ENABLE) 
   enables tristate.

  DEPENDENCIES
    None.

  RETURN VALUE
    None
===========================================================================*/
void gpio_tristate( GPIO_SignalType gpio_signal, GPIO_TristateType gpio_tristate_value)
{
  uint32             gpio_oe_register;
  uint32             gpio_mask;
  uint8              gpio_number;

  gpio_number = GPIO_NUMBER(gpio_signal);
  if (gpio_number >= GPIO_NUM_GPIOS)
  {
      #ifndef BUILD_BOOT_CHAIN
      ERR_FATAL("Invalid GPIO number 0x%x",gpio_number, 0, 0);
	  #endif
	  return;
  }

  gpio_oe_register = GPIO_GROUP(gpio_signal);
  gpio_mask        = 1 <<(gpio_number-GPIO_GROUP_START[gpio_oe_register]);

  if (gpio_tristate_value == GPIO_TRISTATE_DISABLE)
  {
     BIO_TRISTATE(gpio_oe_register,gpio_mask,gpio_mask);
  } 
  else
  {
     BIO_TRISTATE(gpio_oe_register,gpio_mask,0);
  }
}
Esempio n. 3
0
/*===========================================================================
  FUNCTION GPIO_OUT

  DESCRIPTION
    Outputs the given value to the corresponding GPIO register given a GPIO
    signal type. This function calculates the GPIO register and the mask
    value.

  DEPENDENCIES
    None.

  RETURN VALUE
    None
===========================================================================*/
void gpio_out( GPIO_SignalType gpio_signal, GPIO_ValueType  gpio_value )
{
  uint32 gpio_out_register;
  uint32 gpio_mask;
  uint8  gpio_number;

  gpio_number = GPIO_NUMBER(gpio_signal);

  if (gpio_number >= GPIO_NUM_GPIOS)
  {
    #ifndef BUILD_BOOT_CHAIN
      ERR_FATAL("Invalid GPIO number 0x%x",gpio_number, 0, 0);
	  #endif
	  return;
  }

  gpio_out_register = GPIO_GROUP(gpio_signal);

  gpio_mask = 1 << (gpio_number - GPIO_GROUP_START[gpio_out_register]);
  if (gpio_value == GPIO_LOW_VALUE)
  {
    BIO_OUT(gpio_out_register, gpio_mask, 0);
  } 
  else
  {
    BIO_OUT(gpio_out_register, gpio_mask, gpio_mask);
  }
}
Esempio n. 4
0
/*===========================================================================
  FUNCTION GPIO_TLMM_SHADOW

  DESCRIPTION
    Initializes the shadow registers as per the TLMM configuration
    defined at boot time.

  DEPENDENCIES
    None.

  RETURN VALUE
    None
===========================================================================*/
void gpio_tlmm_shadow(void)
{
  uint32             gpio_number;
  uint32             gpio_oe_register;
  uint32             gpio_mask;
  uint32             gpio_oe_0_value = 0;
  uint32             gpio_oe_1_value = 0;
  uint32             gpio2_oe_0_value = 0;
  uint32             gpio2_oe_1_value = 0;
  GPIO_PolarityType  gpio_polarity;
  GPIO_SignalType    gpio_signal;

  for (gpio_number = 0; gpio_number < GPIO_NUM_GPIOS; gpio_number++ )
  {
    gpio_signal = TLMM_GPIO_CONFIG[gpio_number];

    gpio_configs[gpio_number] = gpio_signal;
    gpio_polarity = GPIO_POLARITY(gpio_signal);
    gpio_oe_register = GPIO_GROUP(gpio_signal);

    if (gpio_polarity == GPIO_OUTPUT)  // pin is under traditional GPIO control
    {
      gpio_mask = 1 << (gpio_number - GPIO_GROUP_START[gpio_oe_register]);
      if (gpio_oe_register == 0)
      {
        gpio_oe_0_value |= gpio_mask;
      }
      else if (gpio_oe_register == 1)
      {
        gpio_oe_1_value |= gpio_mask;
      }
      else if (gpio_oe_register == 2)
      {
        gpio2_oe_0_value |= gpio_mask;
      }
      else if (gpio_oe_register == 3)
      {
        gpio2_oe_1_value |= gpio_mask;
      }
    }
  }

  BIO_UPDATE_TRISTATE_SHADOW(GPIO_REG_0,gpio_oe_0_value);
  BIO_UPDATE_TRISTATE_SHADOW(GPIO_REG_1,gpio_oe_1_value);
  BIO_UPDATE_TRISTATE_SHADOW(GPIO2_REG_0,gpio2_oe_0_value);
  BIO_UPDATE_TRISTATE_SHADOW(GPIO2_REG_1,gpio2_oe_1_value);
}
Esempio n. 5
0
/*===========================================================================

  FUNCTION GPIO_TLMM_CONFIG

  DESCRIPTION
    Configures the GPIO TLMM as per the signal value used for the given GPIO.

  DEPENDENCIES
    None.

  RETURN VALUE
    None
===========================================================================*/
void gpio_tlmm_config(GPIO_SignalType gpio_signal)
{
  GPIO_PolarityType gpio_polarity;
  uint32            gpio_oe_register;
  uint32            gpio_mask;
  uint8             gpio_number;

  gpio_number = GPIO_NUMBER(gpio_signal);

  if (gpio_number >= GPIO_NUM_GPIOS)
  {
    #ifndef BUILD_BOOT_CHAIN
      ERR_FATAL("Invalid GPIO number 0x%x",gpio_number, 0, 0);
	  #endif
	  return;
  }

  gpio_polarity    = GPIO_POLARITY(gpio_signal);
  gpio_oe_register = GPIO_GROUP(gpio_signal);
  gpio_mask        = 1 <<(gpio_number-GPIO_GROUP_START[gpio_oe_register]);

  INTLOCK();  
  if (gpio_oe_register < 2)
  {
    HWIO_OUT(GPIO_PAGE,gpio_number);
    HWIO_OUT(GPIO_CFG,(GPIO_SIGNAL(gpio_signal)<<2) | GPIO_PULL(gpio_signal));
  }
  else
  {
    HWIO_OUT(GPIO2_PAGE,gpio_number);
    HWIO_OUT(GPIO2_CFG,(GPIO_SIGNAL(gpio_signal)<<2) | GPIO_PULL(gpio_signal));
  }
  INTFREE();
  
  if ( gpio_polarity == GPIO_OUTPUT )
  {
    BIO_TRISTATE(gpio_oe_register, gpio_mask, gpio_mask);
  }
  else
  {
    BIO_TRISTATE(gpio_oe_register, gpio_mask, 0);
  }
  gpio_configs[gpio_number] = gpio_signal;
}
Esempio n. 6
0
static const unsigned int i2s_lr_clk_in_pins[]	= { PIN(GPIOAO_10, AO_OFF) };

/* bank DIF */
static const unsigned int eth_rxd1_pins[]	= { PIN(DIF_0_P, 0) };
static const unsigned int eth_rxd0_pins[]	= { PIN(DIF_0_N, 0) };
static const unsigned int eth_rx_dv_pins[]	= { PIN(DIF_1_P, 0) };
static const unsigned int eth_rx_clk_pins[]	= { PIN(DIF_1_N, 0) };
static const unsigned int eth_txd0_1_pins[]	= { PIN(DIF_2_P, 0) };
static const unsigned int eth_txd1_1_pins[]	= { PIN(DIF_2_N, 0) };
static const unsigned int eth_tx_en_pins[]	= { PIN(DIF_3_P, 0) };
static const unsigned int eth_ref_clk_pins[]	= { PIN(DIF_3_N, 0) };
static const unsigned int eth_mdc_pins[]	= { PIN(DIF_4_P, 0) };
static const unsigned int eth_mdio_en_pins[]	= { PIN(DIF_4_N, 0) };

static struct meson_pmx_group meson8b_cbus_groups[] = {
	GPIO_GROUP(GPIOX_0, 0),
	GPIO_GROUP(GPIOX_1, 0),
	GPIO_GROUP(GPIOX_2, 0),
	GPIO_GROUP(GPIOX_3, 0),
	GPIO_GROUP(GPIOX_4, 0),
	GPIO_GROUP(GPIOX_5, 0),
	GPIO_GROUP(GPIOX_6, 0),
	GPIO_GROUP(GPIOX_7, 0),
	GPIO_GROUP(GPIOX_8, 0),
	GPIO_GROUP(GPIOX_9, 0),
	GPIO_GROUP(GPIOX_10, 0),
	GPIO_GROUP(GPIOX_11, 0),
	GPIO_GROUP(GPIOX_16, 0),
	GPIO_GROUP(GPIOX_17, 0),
	GPIO_GROUP(GPIOX_18, 0),
	GPIO_GROUP(GPIOX_19, 0),
Esempio n. 7
0
/*===========================================================================

  FUNCTION GPIO_INIT

  DESCRIPTION
    Initializes GPIO TLMM as per the TLMM configuration defined at boot time.

  DEPENDENCIES
    None.

  RETURN VALUE
    None
===========================================================================*/
void gpio_init(void)
{
  uint32            gpio_number;
  uint32            gpio_mask;
  uint32            gpio_oe_register;
  uint32            gpio_oe_0_value = 0;
  uint32            gpio_oe_1_value = 0;
  uint32            gpio_oe_2_value = 0;
  uint32            gpio_oe_3_value = 0;
  GPIO_PolarityType gpio_polarity;
  GPIO_SignalType   gpio_signal;
  
  for (gpio_number=0; gpio_number < GPIO_NUM_GPIOS; gpio_number++ )
  {
    gpio_signal       = TLMM_GPIO_CONFIG[gpio_number];
#ifndef CUST_EDITION
    // Configure GPIO # 30 for PA_R1 in Pedro 2.0
    if ( gpio_number == 30 && VERSION_GET_VERSION_ID() == 1 ) {
      gpio_signal = MSM2_PA_R1;
    }
#endif
    gpio_polarity     = GPIO_POLARITY(gpio_signal);
    gpio_oe_register  = GPIO_GROUP(gpio_signal);

    if (GPIO_SIGNAL(gpio_signal) == 0 && gpio_polarity == GPIO_OUTPUT)  // pin is under traditional GPIO control
    {
      gpio_mask = 1 << (gpio_number - GPIO_GROUP_START[gpio_oe_register]);

      if (gpio_oe_register == 0)
      {
        /* Group 0: GPIO numbers from 12, 14-30 are used GPIO_XXX_0
         * GPIO_XXX_0:
         *      Bit [30:14] -- GPIO[30:14]
         *      Bit [13]    -- reserved
         *      Bit [12]    -- GPIO[12]
         *      Bit [11:0]  -- reserve
         */
        gpio_oe_0_value |= gpio_mask;
      }
      else if (gpio_oe_register == 1)
      {
        /* Group 1: GPIO numbers from 34-41, 53, 55-62 are used GPIO_XXX_1
         * GPIO_XXX_1:
         *      Bit [30:23] -- GPIO[62:55]
         *      Bit [22]    -- reserved
         *      Bit [21]    -- GPIO[53]
         *      Bit [20:10] -- reserved
         *      Bit [9:2]   -- GPIO[41:34]
         *      Bit [1:0]   -- reserved
         */
        gpio_oe_1_value |= gpio_mask;
      }
      else if (gpio_oe_register == 2)
      {
        /* Group 2: GPIO numbers from 0-11, 13, 31 are used GPIO2_XXX_0
         * GPIO2_XXX_0:
         *      Bit [31]    -- GPIO[31]
         *      Bit [30:14] -- reserved
         *      Bit [13]    -- GPIO[13]
         *      Bit [29:12] -- reserved
         *      Bit [11-0]  -- GPIO[11:0]
         */
        gpio_oe_2_value |= gpio_mask;
      }
      else if (gpio_oe_register == 3)
      {
        /* Group 3: GPIO numbers from 32-33, 42-52, 54 are used GPIO2_XXX_1
         * GPIO2_XXX_1:
         *      Bit [22]    -- GPIO[54]
         *      Bit [21]    -- reserved
         *      Bit [20:10] -- GPIO[52:42]
         *      Bit [9:2]   -- reserved
         *      Bit [1:0]   -- GPIO[33:32]
         */
        gpio_oe_3_value |= gpio_mask;
      }
    }

    if (gpio_oe_register < 2)
    {
      HWIO_OUT(GPIO_PAGE,gpio_number);
      HWIO_OUT(GPIO_CFG, (GPIO_SIGNAL(gpio_signal)<<2) | GPIO_PULL(gpio_signal));
    } 
    else
    {
      HWIO_OUT(GPIO2_PAGE,gpio_number);
      HWIO_OUT(GPIO2_CFG, (GPIO_SIGNAL(gpio_signal)<<2) | GPIO_PULL(gpio_signal));
    }
  }

  HWIO_OUT(GPIO_OE_0,gpio_oe_0_value);
  HWIO_OUT(GPIO_OE_1,gpio_oe_1_value);
  HWIO_OUT(GPIO2_OE_0,gpio_oe_2_value);
  HWIO_OUT(GPIO2_OE_1,gpio_oe_3_value);
}
Esempio n. 8
0
static const unsigned int pwm_ao_b_pins[]	= { GPIOAO_9 };
static const unsigned int pwm_ao_b_6_pins[]	= { GPIOAO_6 };

static const unsigned int i2s_out_ch23_ao_pins[] = { GPIOAO_8 };
static const unsigned int i2s_out_ch45_ao_pins[] = { GPIOAO_9 };
static const unsigned int i2s_out_ch67_ao_pins[] = { GPIO_TEST_N };

static const unsigned int spdif_out_ao_6_pins[] = { GPIOAO_6 };
static const unsigned int spdif_out_ao_9_pins[] = { GPIOAO_9 };

static const unsigned int ao_cec_pins[]		= { GPIOAO_8 };
static const unsigned int ee_cec_pins[]		= { GPIOAO_8 };

static struct meson_pmx_group meson_gxl_periphs_groups[] = {
	GPIO_GROUP(GPIOZ_0),
	GPIO_GROUP(GPIOZ_1),
	GPIO_GROUP(GPIOZ_2),
	GPIO_GROUP(GPIOZ_3),
	GPIO_GROUP(GPIOZ_4),
	GPIO_GROUP(GPIOZ_5),
	GPIO_GROUP(GPIOZ_6),
	GPIO_GROUP(GPIOZ_7),
	GPIO_GROUP(GPIOZ_8),
	GPIO_GROUP(GPIOZ_9),
	GPIO_GROUP(GPIOZ_10),
	GPIO_GROUP(GPIOZ_11),
	GPIO_GROUP(GPIOZ_12),
	GPIO_GROUP(GPIOZ_13),
	GPIO_GROUP(GPIOZ_14),
	GPIO_GROUP(GPIOZ_15),
Esempio n. 9
0
};

static const unsigned int uart_tx_ao_a_pins[]	= { PIN(GPIOAO_0, 0) };
static const unsigned int uart_rx_ao_a_pins[]	= { PIN(GPIOAO_1, 0) };
static const unsigned int uart_cts_ao_a_pins[]	= { PIN(GPIOAO_2, 0) };
static const unsigned int uart_rts_ao_a_pins[]	= { PIN(GPIOAO_3, 0) };
static const unsigned int uart_tx_ao_b_pins[]	= { PIN(GPIOAO_0, 0) };
static const unsigned int uart_rx_ao_b_pins[]	= { PIN(GPIOAO_1, 0),
						    PIN(GPIOAO_5, 0) };
static const unsigned int uart_cts_ao_b_pins[]	= { PIN(GPIOAO_2, 0) };
static const unsigned int uart_rts_ao_b_pins[]	= { PIN(GPIOAO_3, 0) };

static const unsigned int remote_input_ao_pins[] = {PIN(GPIOAO_7, 0) };

static struct meson_pmx_group meson_gxl_periphs_groups[] = {
	GPIO_GROUP(GPIOZ_0, EE_OFF),
	GPIO_GROUP(GPIOZ_1, EE_OFF),
	GPIO_GROUP(GPIOZ_2, EE_OFF),
	GPIO_GROUP(GPIOZ_3, EE_OFF),
	GPIO_GROUP(GPIOZ_4, EE_OFF),
	GPIO_GROUP(GPIOZ_5, EE_OFF),
	GPIO_GROUP(GPIOZ_6, EE_OFF),
	GPIO_GROUP(GPIOZ_7, EE_OFF),
	GPIO_GROUP(GPIOZ_8, EE_OFF),
	GPIO_GROUP(GPIOZ_9, EE_OFF),
	GPIO_GROUP(GPIOZ_10, EE_OFF),
	GPIO_GROUP(GPIOZ_11, EE_OFF),
	GPIO_GROUP(GPIOZ_12, EE_OFF),
	GPIO_GROUP(GPIOZ_13, EE_OFF),
	GPIO_GROUP(GPIOZ_14, EE_OFF),
	GPIO_GROUP(GPIOZ_15, EE_OFF),