Beispiel #1
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 #2
0
void mt_gpio_set_default_ext(void)
{
#if 0
	GPIOEXT_REGS *pReg = (GPIOEXT_REGS*)(GPIOEXT_BASE);
    int idx;
    u32 val;

    for (idx = 0; idx < sizeof(pReg->dir)/sizeof(pReg->dir[0]); idx++){
		val = gpioext_init_dir_data[idx];
        GPIOEXT_WR(&pReg->dir[idx],val);
    }

    for (idx = 0; idx < sizeof(pReg->pullen)/sizeof(pReg->pullen[0]); idx++){
		val = gpioext_init_pullen_data[idx];
        GPIOEXT_WR(&pReg->pullen[idx],val);
    }

    for (idx = 0; idx < sizeof(pReg->pullsel)/sizeof(pReg->pullsel[0]); idx++){
		val = gpioext_init_pullsel_data[idx];
        GPIOEXT_WR(&pReg->pullsel[idx],val);
    }

    for (idx = 0; idx < sizeof(pReg->dinv)/sizeof(pReg->dinv[0]); idx++) {
		val = gpioext_init_dinv_data[idx];
        GPIOEXT_WR(&pReg->dinv[idx],val);
    }

    for (idx = 0; idx < sizeof(pReg->dout)/sizeof(pReg->dout[0]); idx++) {
		val = gpioext_init_dout_data[idx];
        GPIOEXT_WR(&pReg->dout[idx],val);
    }

    for (idx = 0; idx < sizeof(pReg->mode)/sizeof(pReg->mode[0]); idx++) {
		val = gpioext_init_mode_data[idx];
        GPIOEXT_WR(&pReg->mode[idx],val);
    }

    GPIOVER("mt_gpio_set_default_ext() done\n");
#endif
}