Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

static int iomux_config_mux ( iomux_pin_name_t  pin,
iomux_pin_cfg_t  config 
) [static]

This function is used to configure a pin through the IOMUX module.

Parameters:
pin a pin number as defined in iomux_pin_name_t
config a configuration as defined in iomux_pin_cfg_t
Returns:
0 if successful; Non-zero otherwise

Definition at line 59 of file iomux.c.

References IOMUX_CONFIG_GPIO, IOMUXSW_MUX_CTL, and IOMUXSW_MUX_END.

{
      u32 ret = 0;
      u32 pin_index = PIN_TO_IOMUX_INDEX(pin);
      void *mux_reg = IOMUXSW_MUX_CTL + PIN_TO_IOMUX_MUX(pin);
      u32 mux_data = 0;
      u8 *rp;

      BUG_ON((mux_reg > IOMUXSW_MUX_END) || (mux_reg < IOMUXSW_MUX_CTL));
      spin_lock(&gpio_mux_lock);

      if (config == IOMUX_CONFIG_GPIO) {
            mux_data = PIN_TO_ALT_GPIO(pin);
      } else {
            mux_data = config;
      }

      __raw_writel(mux_data, mux_reg);

      /*
       * Log a warning if a pin changes ownership
       */
      rp = iomux_pin_res_table + pin_index;
      if ((mux_data & *rp) && (*rp != mux_data)) {
            /*
             * Don't call printk if we're tweaking the console uart or
             * we'll deadlock.
             */
            printk(KERN_ERR "iomux_config_mux: Warning: iomux pin"
                   " config changed, pin=%p, "
                   " prev=0x%x new=0x%x\n", mux_reg, *rp, mux_data);
            ret = -EINVAL;
      }
      *rp = mux_data;
      spin_unlock(&gpio_mux_lock);
      return ret;
}


Generated by  Doxygen 1.6.0   Back to index