static void MINIABB_SetGpio(void)
{
    // i2c0 pin setting
    mt_set_gpio_mode(GPIO_I2C0_SCA_PIN, GPIO_I2C0_SCA_PIN_M_SCL);
    mt_set_gpio_mode(GPIO_I2C0_SDA_PIN, GPIO_I2C0_SDA_PIN_M_SDA);

    // miniabb_int pin setting
    mt_set_gpio_mode(GPIO_EOC_PIN, GPIO_EOC_PIN_M_EINT);

    printk("GPIO_SCL[87] Mode:%d\nGPIO_SDA[88] Mode:%d\n"
           ,mt_get_gpio_mode(87),mt_get_gpio_mode(88));

}
static void md_gpio_get(GPIO_PIN pin, char *tag)
{
	pr_debug
	    ("GPIO%d(%s): mode=%d,dir=%d,in=%d,out=%d,pull_en=%d,pull_sel=%d,smt=%d\n",
	     pin, tag, mt_get_gpio_mode(pin), mt_get_gpio_dir(pin),
	     mt_get_gpio_in(pin), mt_get_gpio_out(pin),
	     mt_get_gpio_pull_enable(pin), mt_get_gpio_pull_select(pin),
	     mt_get_gpio_smt(pin));
}
Example #3
0
/*----------------------------------------------------------------------------*/
void gpio_dump_regs(void)
{
    int idx = 0;	
	GPIOMSG("PIN: [MODE] [PULL_SEL] [DIN] [DOUT] [PULL EN] [DIR] [INV] [IES]\n");
    for (idx = 0; idx < MT_GPIO_MAX_PIN; idx++) {
		printk("idx = %3d: %d %d %d %d %d %d %d %d\n",
		   idx,mt_get_gpio_mode(idx), mt_get_gpio_pull_select(idx), mt_get_gpio_in(idx),mt_get_gpio_out(idx),
		   mt_get_gpio_pull_enable(idx),mt_get_gpio_dir(idx),mt_get_gpio_inversion(idx),mt_get_gpio_ies(idx)); 
    }
}
Example #4
0
static irqreturn_t xhci_eint_iddig_isr(int irqnum, void *data)
{
	int ret;
	//schedule_delayed_work(&mtk_xhci_delay_work, mtk_iddig_debounce*HZ/1000);
	/* microseconds */
	ret = schedule_delayed_work_on(0, &mtk_xhci_delaywork, msecs_to_jiffies(mtk_iddig_debounce));
	mtk_xhci_mtk_log("schedule to delayed work, ret(%d), gpio_mode(%d), gpio_pull_enable(%d), gpio_pull_select(%d)\n",
		ret, mt_get_gpio_mode(16), mt_get_gpio_pull_enable(16), mt_get_gpio_pull_select(16));

	disable_irq_nosync(irqnum);
	return IRQ_HANDLED;
}
static u32 SetGPIOMode(u32 pin, u32 mode)    //set GPIO to I2S
{
	u32 temp = -1;
	temp = mt_get_gpio_mode(pin);
	printk("MHL GPIO Mode 1 is %d", temp);
	
	if(temp != mode)
		temp = mt_set_gpio_mode(pin, mode);
	printk("MHL GPIO Mode 2 is %d", temp);
	
	return temp;
}
Example #6
0
INT32
wmt_plat_rst_ctrl (
    ENUM_PIN_STATE state
    )
{
    switch(state)
    {
        case PIN_STA_INIT:
            /*set to gpio output low, disable pull*/
            mt_set_gpio_pull_enable(GPIO_COMBO_RST_PIN, GPIO_PULL_DISABLE);
            mt_set_gpio_dir(GPIO_COMBO_RST_PIN, GPIO_DIR_OUT);
            mt_set_gpio_mode(GPIO_COMBO_RST_PIN, GPIO_MODE_GPIO);
            mt_set_gpio_out(GPIO_COMBO_RST_PIN, GPIO_OUT_ZERO);
            WMT_DBG_FUNC("WMT-PLAT:RST init (out 0) \n");
            break;

        case PIN_STA_OUT_H:
            mt_set_gpio_out(GPIO_COMBO_RST_PIN, GPIO_OUT_ONE);
            WMT_DBG_FUNC("WMT-PLAT:RST (out 1) \n");
            break;

        case PIN_STA_OUT_L:
            mt_set_gpio_out(GPIO_COMBO_RST_PIN, GPIO_OUT_ZERO);
            WMT_DBG_FUNC("WMT-PLAT:RST (out 0) \n");
            break;

        case PIN_STA_IN_L:
        case PIN_STA_DEINIT:
            /*set to gpio input low, pull down enable*/
            mt_set_gpio_mode(GPIO_COMBO_RST_PIN, GPIO_COMBO_RST_PIN_M_GPIO);
            mt_set_gpio_dir(GPIO_COMBO_RST_PIN, GPIO_DIR_IN);
            mt_set_gpio_pull_select(GPIO_COMBO_RST_PIN, GPIO_PULL_DOWN);
            mt_set_gpio_pull_enable(GPIO_COMBO_RST_PIN, GPIO_PULL_ENABLE);
            WMT_DBG_FUNC("WMT-PLAT:RST deinit (in pd) \n");
            break;
		case PIN_STA_SHOW:
				WMT_INFO_FUNC("WMT-PLAT:RST PIN_STA_SHOW start\n");
				WMT_INFO_FUNC("WMT-PLAT:RST Mode(%d)\n", mt_get_gpio_mode(GPIO_COMBO_RST_PIN));
				WMT_INFO_FUNC("WMT-PLAT:RST Dir(%d)\n", mt_get_gpio_dir(GPIO_COMBO_RST_PIN));
				WMT_INFO_FUNC("WMT-PLAT:RST Pull enable(%d)\n", mt_get_gpio_pull_enable(GPIO_COMBO_RST_PIN));
				WMT_INFO_FUNC("WMT-PLAT:RST Pull select(%d)\n", mt_get_gpio_pull_select(GPIO_COMBO_RST_PIN));
				WMT_INFO_FUNC("WMT-PLAT:RST out(%d)\n", mt_get_gpio_out(GPIO_COMBO_RST_PIN));
				WMT_INFO_FUNC("WMT-PLAT:RST PIN_STA_SHOW end\n");
				break;

        default:
            WMT_WARN_FUNC("WMT-PLAT:Warnning, invalid state(%d) on RST\n", state);
            break;
    }

    return 0;
}
static u32 ResetI2S(u32 pin, u32 mode)          //set I2S to GPIO and pull down
{
	u32 temp = -1;
	temp = mt_get_gpio_mode(pin);
	printk("MHL GPIO Mode 3 is %d", temp);
	if(temp == mode)
	{
		temp = mt_set_gpio_mode(pin, GPIO_MODE_00);
		printk("MHL GPIO Mode 4 is %d", temp);
		temp = mt_set_gpio_pull_enable(pin, GPIO_PULL_DISABLE);
	}
	return temp;
}
static int kpd_get_config(void)
{
	int i;
	
	for(i = 0; i < KPD_GPIO_NUM; i++)
	{
		if(mt_get_gpio_mode(kpd_gpio[i].gpio_num) != kpd_gpio[i].gpio_mode)
		{
			printk(KPD_SAY" error default value. gpio_num:%d, gpio_mode:%d\n", kpd_gpio[i].gpio_num, mt_get_gpio_mode(kpd_gpio[i].gpio_num));
			return -1;
		}
	}
	return 0;
}            
Example #9
0
static ssize_t mt_gpio_dump_regs(char *buf, ssize_t bufLen)
{
    int idx = 0, len = 0;
	
	GPIOMSG("PIN: [DIR] [DOUT] [DIN]\n");
    for (idx = 0; idx < 8; idx++) {        
        len += snprintf(buf+len, bufLen-len, "%d: %d %d %d\n",
               idx, mt_get_gpio_dir(idx), mt_get_gpio_out(idx),mt_get_gpio_in(idx)); 
    }
	GPIOMSG("PIN: [MODE] [PULL_SEL] [DIN] [DOUT] [PULL EN] [DIR] [INV]\n");
    for (idx = GPIO_EXTEND_START; idx < MAX_GPIO_PIN; idx++) {        
		len += snprintf(buf+len, bufLen-len, "%d: %d %d %d %d %d %d %d\n",
		   idx,mt_get_gpio_mode(idx), mt_get_gpio_pull_select(idx), mt_get_gpio_in(idx),mt_get_gpio_out(idx),
		   mt_get_gpio_pull_enable(idx),mt_get_gpio_dir(idx),mt_get_gpio_inversion(idx)); 
    }

    return len;
}
Example #10
0
int mtk_xhci_eint_iddig_init(void)
{
	int retval;
	struct device_node *node;
	int iddig_gpio;

	node = of_find_compatible_node(NULL, NULL, "mediatek,USB3_XHCI");
	if(node){
		retval = of_property_read_u32(node, "iddig-gpio-num", &iddig_gpio);
		if(retval){
			mtk_xhci_mtk_log("get iddig-gpio-num failed, retval(%d)!!!\n", retval);
			return retval;
		}

		mtk_xhci_mtk_log("iddig gpio num, %d\n", iddig_gpio);
	}
	else{
		mtk_xhci_mtk_log("cannot get the node\n");
		return -ENODEV;
	}

	INIT_DELAYED_WORK(&mtk_xhci_delaywork, mtk_xhci_mode_switch);

	mtk_idpin_irqnum = mt_gpio_to_irq(iddig_gpio);

	/* microseconds */
	mt_gpio_set_debounce(iddig_gpio, 50);

	retval =
	    request_irq(mtk_idpin_irqnum, xhci_eint_iddig_isr, IRQF_TRIGGER_LOW, "iddig_eint",
			NULL);
	if (retval != 0) {
		mtk_xhci_mtk_log("request_irq fail, ret %d, irqnum %d!!!\n", retval, mtk_idpin_irqnum);
		return retval;
	}
	mtk_xhci_mtk_log("external iddig register done, irqnum = %d, gpio_mode(%d), gpio_pull_enable(%d), gpio_pull_select(%d)\n", 
		mtk_idpin_irqnum, mt_get_gpio_mode(16), mt_get_gpio_pull_enable(16), mt_get_gpio_pull_select(16));

	/* set in-detect and umask the iddig interrupt */
	//enable_irq(mtk_idpin_irqnum);
	return retval;
}
Example #11
0
void inno_chip_reset(void)
{
	mt_set_gpio_mode(GPIO_CMMB_RST_PIN, GPIO_CMMB_RST_PIN_M_GPIO);
	mt_set_gpio_dir(GPIO_CMMB_RST_PIN, GPIO_DIR_OUT);

//	mdelay(1);
	mt_set_gpio_out(GPIO_CMMB_RST_PIN, GPIO_OUT_ZERO); 			 
	mdelay(30);                                                                                  //delay for power to reset  typical:10ms max:50ms
	mt_set_gpio_out(GPIO_CMMB_RST_PIN, GPIO_OUT_ONE); 
//	mt_set_gpio_pull_enable(GPIO_CMMB_RST_PIN, 1);
//	mt_set_gpio_pull_select(GPIO_CMMB_RST_PIN,  1);
	inno_msg("CMMB GPIO RST PIN mode:num:%d, %d,out:%d, dir:%d,pullen:%d,pullup%d",GPIO_CMMB_RST_PIN,mt_get_gpio_mode(GPIO_CMMB_RST_PIN),mt_get_gpio_out(GPIO_CMMB_RST_PIN),mt_get_gpio_dir(GPIO_CMMB_RST_PIN),mt_get_gpio_pull_enable(GPIO_CMMB_RST_PIN),mt_get_gpio_pull_select(GPIO_CMMB_RST_PIN));    	 
	mdelay(30);                                                                                  //delay for waiting system ready typical:10ms max:50ms
}
Example #12
0
void inno_irq_release(void)
{
	mt_eint_mask(CUST_EINT_CMMB_NUM);   
	mt_set_gpio_pull_enable(GPIO_CMMB_EINT_PIN, 1);
	mt_set_gpio_pull_select(GPIO_CMMB_EINT_PIN,  0);
	mt_set_gpio_mode(GPIO_CMMB_EINT_PIN, GPIO_CMMB_EINT_PIN_M_GPIO);                 //set to eint MODE for enable eint function
	inno_msg("CMMB GPIO EINT PIN mode:num:%d, %d, dir:%d,pullen:%d,pullup%d",GPIO_CMMB_EINT_PIN,mt_get_gpio_mode(GPIO_CMMB_EINT_PIN),
			mt_get_gpio_dir(GPIO_CMMB_EINT_PIN),mt_get_gpio_pull_enable(GPIO_CMMB_EINT_PIN),mt_get_gpio_pull_select(GPIO_CMMB_EINT_PIN));    
//	mt_set_gpio_dir(GPIO_CMMB_EINT_PIN, GPIO_DIR_OUT);               // set to input avoid of leak power
}
Example #13
0
/*
 * register irq handler
 * parmaters pass by inno_core
 * @handler		-	if101 irq handler function pointer
 * @irq_type	-	if101 irq type (falling edge detect or rising)
 */
int inno_irq_setup(void (*interrupthandler)(void ))
{
	mt_set_gpio_mode(GPIO_CMMB_EINT_PIN, GPIO_CMMB_EINT_PIN_M_EINT);                 //set to eint MODE for enable eint function
	mt_set_gpio_dir(GPIO_CMMB_EINT_PIN, GPIO_DIR_IN); 
#if 1
	mt_set_gpio_pull_enable(GPIO_CMMB_EINT_PIN, 1);
	mt_set_gpio_pull_select(GPIO_CMMB_EINT_PIN,  1);
#endif
	inno_msg("CMMB GPIO EINT PIN mode:num:%d, %d, dir:%d,pullen:%d,pullup%d",GPIO_CMMB_EINT_PIN,mt_get_gpio_mode(GPIO_CMMB_EINT_PIN),
			mt_get_gpio_dir(GPIO_CMMB_EINT_PIN),mt_get_gpio_pull_enable(GPIO_CMMB_EINT_PIN),mt_get_gpio_pull_select(GPIO_CMMB_EINT_PIN));    
	// rename the functions mt65xx_eint_xx by mt_eint_xx   rui
	mt_eint_registration(CUST_EINT_CMMB_NUM, EINTF_TRIGGER_FALLING, interrupthandler, 0);         // 0:auto mask is no
	mt_eint_unmask(CUST_EINT_CMMB_NUM);   
	//    mt_eint_mask(CUST_EINT_CMMB_NUM);   
	return 0;
}
void mt_gpio_self_test(void)
{
    int i, val;
    for (i = 0; i < MT_GPIO_EXT_MAX; i++)
    {
        s32 res,old;
        GPIOMSG("GPIO-%3d test\n", i);
        /*direction test*/
        old = mt_get_gpio_dir(i);
        if (old == 0 || old == 1) {
            GPIOLOG(" dir old = %d\n", old);
        } else {
            GPIOERR(" test dir fail: %d\n", old);
            break;
        }
        if ((res = mt_set_gpio_dir(i, GPIO_DIR_OUT)) != RSUCCESS) {
            GPIOERR(" set dir out fail: %d\n", res);
            break;
        } else if ((res = mt_get_gpio_dir(i)) != GPIO_DIR_OUT) {
            GPIOERR(" get dir out fail: %d\n", res);
            break;
        } else {
            /*output test*/
            s32 out = mt_get_gpio_out(i);
            if (out != 0 && out != 1) {
                GPIOERR(" get out fail = %d\n", old);
                break;
            } 
            for (val = 0; val < GPIO_OUT_MAX; val++) {
                if ((res = mt_set_gpio_out(i,0)) != RSUCCESS) {
                    GPIOERR(" set out[%d] fail: %d\n", val, res);
                    break;
                } else if ((res = mt_get_gpio_out(i)) != 0) {
                    GPIOERR(" get out[%d] fail: %d\n", val, res);
                    break;
                }
            }
            if ((res = mt_set_gpio_out(i,out)) != RSUCCESS)
            {
                GPIOERR(" restore out fail: %d\n", res);
                break;
            }
        }
            
        if ((res = mt_set_gpio_dir(i, GPIO_DIR_IN)) != RSUCCESS) {
            GPIOERR(" set dir in fail: %d\n", res);
            break;
        } else if ((res = mt_get_gpio_dir(i)) != GPIO_DIR_IN) {
            GPIOERR(" get dir in fail: %d\n", res);
            break;
        } else {
            GPIOLOG(" input data = %d\n", res);
        }
        
        if ((res = mt_set_gpio_dir(i, old)) != RSUCCESS) {
            GPIOERR(" restore dir fail: %d\n", res);
            break;
        }
        for (val = 0; val < GPIO_PULL_EN_MAX; val++) {
            if ((res = mt_set_gpio_pull_enable(i,val)) != RSUCCESS) {
                GPIOERR(" set pullen[%d] fail: %d\n", val, res);
                break;
            } else if ((res = mt_get_gpio_pull_enable(i)) != val) {
                GPIOERR(" get pullen[%d] fail: %d\n", val, res);
                break;
            }
        }        
        if ((res = mt_set_gpio_pull_enable(i, old)) != RSUCCESS) {
            GPIOERR(" restore pullen fail: %d\n", res);
            break;
        }

        /*pull select test*/
        old = mt_get_gpio_pull_select(i);
        if (old == 0 || old == 1)
            GPIOLOG(" pullsel old = %d\n", old);
        else {
            GPIOERR(" pullsel fail: %d\n", old);
            break;
        }
        for (val = 0; val < GPIO_PULL_MAX; val++) {
            if ((res = mt_set_gpio_pull_select(i,val)) != RSUCCESS) {
                GPIOERR(" set pullsel[%d] fail: %d\n", val, res);
                break;
            } else if ((res = mt_get_gpio_pull_select(i)) != val) {
                GPIOERR(" get pullsel[%d] fail: %d\n", val, res);
                break;
            }
        } 
        if ((res = mt_set_gpio_pull_select(i, old)) != RSUCCESS)
        {
            GPIOERR(" restore pullsel fail: %d\n", res);
            break;
        }     

        /*data inversion*/
        old = mt_get_gpio_inversion(i);
        if (old == 0 || old == 1)
            GPIOLOG(" inv old = %d\n", old);
        else {
            GPIOERR(" inv fail: %d\n", old);
            break;
        }
        for (val = 0; val < GPIO_DATA_INV_MAX; val++) {
            if ((res = mt_set_gpio_inversion(i,val)) != RSUCCESS) {
                GPIOERR(" set inv[%d] fail: %d\n", val, res);
                break;
            } else if ((res = mt_get_gpio_inversion(i)) != val) {
                GPIOERR(" get inv[%d] fail: %d\n", val, res);
                break;
            }
        } 
        if ((res = mt_set_gpio_inversion(i, old)) != RSUCCESS) {
            GPIOERR(" restore inv fail: %d\n", res);
            break;
        }     

        /*mode control*/
//		if((i<=GPIOEXT6) || (i >= GPIOEXT9)){
        old = mt_get_gpio_mode(i);
        if ((old >= GPIO_MODE_00) && (val < GPIO_MODE_MAX))
        {
            GPIOLOG(" mode old = %d\n", old);
        }
        else
        {
            GPIOERR(" get mode fail: %d\n", old);
            break;
        }
        for (val = 0; val < GPIO_MODE_MAX; val++) {
            if ((res = mt_set_gpio_mode(i, val)) != RSUCCESS) {
                GPIOERR("set mode[%d] fail: %d\n", val, res);
                break;
            } else if ((res = mt_get_gpio_mode(i)) != val) {
                GPIOERR("get mode[%d] fail: %d\n", val, res);
                break;
            }            
        }        
        if ((res = mt_set_gpio_mode(i,old)) != RSUCCESS) {
            GPIOERR(" restore mode fail: %d\n", res);
            break;
        }   
//		}    
    }
    GPIOLOG("GPIO test done\n");
}
Example #15
0
/*---------------------------------------------------------------------------*/
static long mt_gpio_ioctl(struct file *file, 
                             unsigned int cmd, unsigned long arg)
{
    struct mt_gpio_obj_t *obj = mt_gpio;
    long res;
    unsigned long pin;

    GPIOFUC();

    if (obj == NULL) {
        GPIOERR("NULL pointer");
        return -EFAULT;
    }

    switch(cmd) 
    {
        case GPIO_IOCQMODE:
        {
            pin = (unsigned long)arg;
            res = GIO_INVALID_OBJ(obj) ? (-EACCES) : mt_get_gpio_mode(pin);
            break;
        }
        case GPIO_IOCTMODE0:
        {
            pin = (unsigned long)arg;
            res = GIO_INVALID_OBJ(obj) ? (-EACCES) : mt_set_gpio_mode(pin, GPIO_MODE_00);
            break;
        }
        case GPIO_IOCTMODE1:      
        {
            pin = (unsigned long)arg;
            res = GIO_INVALID_OBJ(obj) ? (-EACCES) : mt_set_gpio_mode(pin, GPIO_MODE_01);
            break;
        }
        case GPIO_IOCTMODE2:      
        {
            pin = (unsigned long)arg;
            res = GIO_INVALID_OBJ(obj) ? (-EACCES) : mt_set_gpio_mode(pin, GPIO_MODE_02);
            break;
        }
        case GPIO_IOCTMODE3:      
        {
            pin = (unsigned long)arg;
            res = GIO_INVALID_OBJ(obj) ? (-EACCES) : mt_set_gpio_mode(pin, GPIO_MODE_03);
            break;
        }
        case GPIO_IOCQDIR:        
        {
            pin = (unsigned long)arg;
            res = GIO_INVALID_OBJ(obj) ? (-EACCES) : mt_get_gpio_dir(pin);
            break;
        }
        case GPIO_IOCSDIRIN:      
        {
            pin = (unsigned long)arg;
            res = GIO_INVALID_OBJ(obj) ? (-EACCES) : mt_set_gpio_dir(pin, GPIO_DIR_IN);
            break;
        }
        case GPIO_IOCSDIROUT:     
        {
            pin = (unsigned long)arg;
            res = GIO_INVALID_OBJ(obj) ? (-EACCES) : mt_set_gpio_dir(pin, GPIO_DIR_OUT);
            break;
        }
        case GPIO_IOCQPULLEN:       
        {
            pin = (unsigned long)arg;
            res = GIO_INVALID_OBJ(obj) ? (-EACCES) : mt_get_gpio_pull_enable(pin);
            break;
        }
        case GPIO_IOCSPULLENABLE:
        {
            pin = (unsigned long)arg;
            res = GIO_INVALID_OBJ(obj) ? (-EACCES) : mt_set_gpio_pull_enable(pin, TRUE);
            break;
        }
        case GPIO_IOCSPULLDISABLE:
        {
            pin = (unsigned long)arg;
            res = GIO_INVALID_OBJ(obj) ? (-EACCES) : mt_set_gpio_pull_enable(pin, FALSE);
            break;
        }
        case GPIO_IOCQPULL:
        {
            pin = (unsigned long)arg;
            res = GIO_INVALID_OBJ(obj) ? (-EACCES) : mt_get_gpio_pull_select(pin);
            break;
        }
        case GPIO_IOCSPULLDOWN:
        {
            pin = (unsigned long)arg;
            res = GIO_INVALID_OBJ(obj) ? (-EACCES) : mt_set_gpio_pull_select(pin, GPIO_PULL_DOWN);
            break;
        }
        case GPIO_IOCSPULLUP:
        {
            pin = (unsigned long)arg;
            res = GIO_INVALID_OBJ(obj) ? (-EACCES) : mt_set_gpio_pull_select(pin, GPIO_PULL_UP);
            break;
        }
        case GPIO_IOCQINV:        
        {
            pin = (unsigned long)arg;
            res = GIO_INVALID_OBJ(obj) ? (-EACCES) : mt_get_gpio_inversion(pin);
            break;
        }
        case GPIO_IOCSINVENABLE:
        {
            pin = (unsigned long)arg;
            res = GIO_INVALID_OBJ(obj) ? (-EACCES) : mt_set_gpio_inversion(pin, TRUE);
            break;
        }
        case GPIO_IOCSINVDISABLE: 
        {
            pin = (unsigned long)arg;
            res = GIO_INVALID_OBJ(obj) ? (-EACCES) : mt_set_gpio_inversion(pin, FALSE);
            break;
        }
        case GPIO_IOCQDATAIN:     
        {
            pin = (unsigned long)arg;
            res = GIO_INVALID_OBJ(obj) ? (-EFAULT) : mt_get_gpio_in(pin);
            break;
        }
        case GPIO_IOCQDATAOUT:    
        {
            pin = (unsigned long)arg;
            res = GIO_INVALID_OBJ(obj) ? (-EACCES) : mt_get_gpio_out(pin);
            break;
        }
        case GPIO_IOCSDATALOW:    
        {
            pin = (unsigned long)arg;
            res = GIO_INVALID_OBJ(obj) ? (-EACCES) : mt_set_gpio_out(pin, GPIO_OUT_ZERO);
            break;
        }
        case GPIO_IOCSDATAHIGH:   
        {
            pin = (unsigned long)arg;
            res = GIO_INVALID_OBJ(obj) ? (-EACCES) : mt_set_gpio_out(pin, GPIO_OUT_ONE);
            break;
        }
        default:
        {
            res = -EPERM;
            break;
        }
    }

    if (res == -EACCES)
        GPIOERR(" cmd = 0x%8X, invalid pointer\n", cmd);
    else if (res < 0)
        GPIOERR(" cmd = 0x%8X, err = %ld\n", cmd, res);
    return res;
}
/*
 * Set and Reset SPI GPIO pins 
 *
 * Parameter:
 *		enable <in>		: Set and Reset SPI GPIO pins 
 *
 * Example:
 *		INNO_SPI_Init(1);	// Set SPI GPIO pins 
 *		INNO_SPI_Init(0);	// Reset SPI GPIO pins 
 */
INNO_RET INNO_SPI_GPIO_Set(int enable)
{
	mutex_lock(&inno_spi_mutex);
	if(enable)
		{
			mt_set_gpio_mode(GPIO_SPI_CS_PIN, GPIO_SPI_CS_PIN_M_SPI_CS);
			mt_set_gpio_pull_enable(GPIO_SPI_CS_PIN, GPIO_PULL_ENABLE);
			mt_set_gpio_pull_select(GPIO_SPI_CS_PIN, GPIO_PULL_UP);
			
			mt_set_gpio_mode(GPIO_SPI_SCK_PIN, GPIO_SPI_SCK_PIN_M_SPI_CK);
			mt_set_gpio_pull_enable(GPIO_SPI_SCK_PIN, GPIO_PULL_ENABLE);
			mt_set_gpio_pull_select(GPIO_SPI_SCK_PIN, GPIO_PULL_DOWN);
			
			mt_set_gpio_mode(GPIO_SPI_MISO_PIN, GPIO_SPI_MISO_PIN_M_SPI_MI);
			mt_set_gpio_pull_enable(GPIO_SPI_MISO_PIN, GPIO_PULL_ENABLE);
			mt_set_gpio_pull_select(GPIO_SPI_MISO_PIN, GPIO_PULL_DOWN);
			
			mt_set_gpio_mode(GPIO_SPI_MOSI_PIN, GPIO_SPI_MOSI_PIN_M_SPI_MO);
			mt_set_gpio_pull_enable(GPIO_SPI_MOSI_PIN, GPIO_PULL_ENABLE);
			mt_set_gpio_pull_select(GPIO_SPI_MOSI_PIN, GPIO_PULL_DOWN);
			inno_msg("CMMB GPIO CS SPI PIN mode:num:%d, %d,out:%d, dir:%d,pullen:%d,pullup%d",GPIO_SPI_CS_PIN,mt_get_gpio_mode(GPIO_SPI_CS_PIN),mt_get_gpio_out(GPIO_SPI_CS_PIN),
			mt_get_gpio_dir(GPIO_SPI_CS_PIN),mt_get_gpio_pull_enable(GPIO_SPI_CS_PIN),mt_get_gpio_pull_select(GPIO_SPI_CS_PIN));    
		}
	else
		{
			mt_set_gpio_mode(GPIO_SPI_CS_PIN, GPIO_SPI_CS_PIN_M_GPIO);
			mt_set_gpio_dir(GPIO_SPI_CS_PIN, GPIO_DIR_IN);
			mt_set_gpio_pull_enable(GPIO_SPI_CS_PIN, GPIO_PULL_DISABLE);
			
			mt_set_gpio_mode(GPIO_SPI_SCK_PIN, GPIO_SPI_SCK_PIN_M_GPIO);
			mt_set_gpio_dir(GPIO_SPI_SCK_PIN, GPIO_DIR_IN);
			mt_set_gpio_pull_enable(GPIO_SPI_SCK_PIN, GPIO_PULL_DISABLE);
			
			mt_set_gpio_mode(GPIO_SPI_MISO_PIN, GPIO_SPI_MISO_PIN_M_GPIO);
			mt_set_gpio_dir(GPIO_SPI_MISO_PIN, GPIO_DIR_IN);
			mt_set_gpio_pull_enable(GPIO_SPI_MISO_PIN, GPIO_PULL_DISABLE);
			
			mt_set_gpio_mode(GPIO_SPI_MOSI_PIN, GPIO_SPI_MOSI_PIN_M_GPIO);
			mt_set_gpio_dir(GPIO_SPI_MOSI_PIN, GPIO_DIR_IN);
			mt_set_gpio_pull_enable(GPIO_SPI_MOSI_PIN, GPIO_PULL_DISABLE);
		}
	
	mutex_unlock(&inno_spi_mutex);
	return INNO_NO_ERROR;
	
}
Example #17
0
/*
 * register irq handler
 * parmaters pass by inno_core
 * @handler		-	if101 irq handler function pointer
 * @irq_type	-	if101 irq type (falling edge detect or rising)
 */
int inno_irq_setup(void (*interrupthandler)(void ))
{
	mt_set_gpio_mode(GPIO_CMMB_EINT_PIN, GPIO_CMMB_EINT_PIN_M_EINT);                 //set to eint MODE for enable eint function
	mt_set_gpio_dir(GPIO_CMMB_EINT_PIN, GPIO_DIR_IN); 
#if 1
	mt_set_gpio_pull_enable(GPIO_CMMB_EINT_PIN, 1);
	mt_set_gpio_pull_select(GPIO_CMMB_EINT_PIN,  1);
#endif
	inno_msg("CMMB GPIO EINT PIN mode:num:%d, %d, dir:%d,pullen:%d,pullup%d",GPIO_CMMB_EINT_PIN,mt_get_gpio_mode(GPIO_CMMB_EINT_PIN),
			mt_get_gpio_dir(GPIO_CMMB_EINT_PIN),mt_get_gpio_pull_enable(GPIO_CMMB_EINT_PIN),mt_get_gpio_pull_select(GPIO_CMMB_EINT_PIN));    

	mt65xx_eint_set_sens(CUST_EINT_CMMB_NUM, CUST_EINT_EDGE_SENSITIVE);
	mt65xx_eint_registration(CUST_EINT_CMMB_NUM, CUST_EINT_DEBOUNCE_DISABLE, CUST_EINT_POLARITY_LOW, interrupthandler, 0);         // 0:auto mask is no
	mt65xx_eint_unmask(CUST_EINT_CMMB_NUM);   
	//    mt65xx_eint_mask(CUST_EINT_CMMB_NUM);   
	return 0;
}
Example #18
0
static inline int get_lcm_gpio_mode(unsigned int GPIO)
{
	return mt_get_gpio_mode(GPIO);
}