Beispiel #1
0
void mt_gpio_checkpoint_compare_ext(void)
{
#if defined(GPIO_INIT_DEBUG)
    UINT32 latest[sizeof(gpio_init_value)/((sizeof(UINT32))*(MASK_BIT+1))];
    int idx;

    memset(&latest[0], 0x00, sizeof(latest));
    for (idx = 0; idx < sizeof(gpio_init_value)/((sizeof(UINT32))*(MASK_BIT+1)); idx++)
        latest[idx] = GPIOEXT_RD(gpio_init_value[idx][0]);

    if (memcmp(&latest, &save_ext, sizeof(gpio_init_value)/((sizeof(UINT32))*(MASK_BIT+1)))) {
        GPIODBG("GPIOEXT checkpoint compare fail!!\n");
        GPIODBG("dump checkpoint....\n");
        //mt_gpio_dump(&save_ext);
        GPIODBG("\n\n");
        GPIODBG("dump current state\n");
        //mt_gpio_dump(&latest);
        GPIODBG("\n\n");
        mt_gpio_dump_diff_ext(&save_ext, &latest);
        //WARN_ON(1);
    } else {
        GPIODBG("GPIOEXT checkpoint compare success!!\n");
    }
#endif
}
Beispiel #2
0
/*---------------------------------------------------------------------------*/
int mt_set_gpio_mode_ext(unsigned long pin, unsigned long mode)
{
    u32 pos;
    u32 bit;
    s64 val;
	int ret=0;
    u32 mask = (1L << GPIO_MODE_BITS) - 1;    
    GPIOEXT_REGS *reg = gpioext_reg;
	
	pin -= GPIO_EXTEND_START;    
    pos = pin / MAX_GPIO_MODE_PER_REG;
    bit = pin % MAX_GPIO_MODE_PER_REG;

    val = GPIOEXT_RD(&reg->mode[pos].val);
    if(val < 0){    
		return -ERWRAPPER;
	}

    val &= ~(mask << (GPIO_MODE_BITS*bit));
    val |= (mode << (GPIO_MODE_BITS*bit));
    
    ret = GPIOEXT_WR(&reg->mode[pos].val, val);
	if(ret!=0) return -ERWRAPPER;
    return RSUCCESS;
}
Beispiel #3
0
/*---------------------------------------------------------------------------*/
int mt_get_gpio_pull_enable_ext(unsigned long pin)
{
    u32 pos;
    u32 bit;
    s64 val;
    GPIOEXT_REGS *reg = gpioext_reg;

	pin -= GPIO_EXTEND_START;    
    pos = pin / MAX_GPIO_REG_BITS;
    bit = pin % MAX_GPIO_REG_BITS;

    val = GPIOEXT_RD(&reg->pullen[pos].val);
    if(val < 0) return -ERWRAPPER;
    return (((val & (1L << bit)) != 0)? 1: 0);        
}
Beispiel #4
0
/*---------------------------------------------------------------------------*/
int mt_get_gpio_mode_ext(unsigned long pin)
{
    u32 pos;
    u32 bit;
    s64 val;
    u32 mask = (1L << GPIO_MODE_BITS) - 1;    
    GPIOEXT_REGS *reg = gpioext_reg;

	pin -= GPIO_EXTEND_START;    
    pos = pin / MAX_GPIO_MODE_PER_REG;
    bit = pin % MAX_GPIO_MODE_PER_REG;

    val = GPIOEXT_RD(&reg->mode[pos].val);
    if(val < 0) return -ERWRAPPER;
    
    return ((val >> (GPIO_MODE_BITS*bit)) & mask);
}