Exemple #1
0
static int setup_tx(int new_out_pin)
{
	int ret;
    user_gpio_set_t* pinstate;
    struct sunxi_gpio_chip* sgpio = container_of(gpiochip,struct sunxi_gpio_chip,chip);
    dprintk("addresses: gpiochip: %lx, sgpio: %lx",(unsigned long int) gpiochip,(unsigned long int) sgpio);
    if (gpio_out_pin==new_out_pin)
        return 0; //do not set up, pin not changed

    if (gpio_out_pin!=0) {   //we had tx pin setup.  Free it so others can use it!
        dprintk(": trying to free old out pin index %d: %s\n",gpio_out_pin,gpiochip->names[TX_OFFSET_GPIOCHIP]);
        gpio_free(gpio_out_pin);
    }
    gpio_out_pin=new_out_pin;
    if (gpio_out_pin==0) {
        return 0; // do not set up, TX disabled
    }
    dprintk(": trying to claim new out pin index %d: %s\n",gpio_out_pin,gpiochip->names[TX_OFFSET_GPIOCHIP]);
    ret = gpio_request(gpio_out_pin,LIRC_DRIVER_NAME "ir/out");
    if (ret){
        printk(KERN_ALERT LIRC_DRIVER_NAME
               ": cant claim gpio pin %d with code %d\n", gpio_out_pin,ret);
        ret = -ENODEV;
        goto exit_disable_tx;
    }
    gpiochip->direction_output(gpiochip, TX_OFFSET_GPIOCHIP, 1);
    gpiochip->set(gpiochip, TX_OFFSET_GPIOCHIP, invert);
    pinstate=kzalloc(sizeof(user_gpio_set_t),GFP_KERNEL);

    //dprintk("pin:address %lx, pin_name: %s, pin handler: %d",(unsigned long int) &(sgpio->data[TX_OFFSET_GPIOCHIP]),
    // 		sgpio->data[TX_OFFSET_GPIOCHIP].pin_name,sgpio->data[TX_OFFSET_GPIOCHIP].gpio_handler);
    ret=gpio_get_one_pin_status(sgpio->data[TX_OFFSET_GPIOCHIP].gpio_handler, pinstate, sgpio->data[TX_OFFSET_GPIOCHIP].pin_name, true);
    if(pinstate && !ret) {
    	pr_info("Maximum load on '%s' is %d mA\n", gpiochip->names[TX_OFFSET_GPIOCHIP], 10+10*pinstate->drv_level);
    	kfree(pinstate);
    }
    else
    	printk(KERN_ALERT LIRC_DRIVER_NAME ": something might have gone wrong, return from pin status query: %d",ret);
    return 0;  // successfully set up

exit_disable_tx:
    // cannot claim new pin
    gpio_out_pin = 0; // disable tx
    return ret;
}
Exemple #2
0
int get_gpio_member_value( u32 gpio_hd , char *name , int member_name )
{
	user_gpio_set_t  gpio_info[1];
	int  ret;
    GPIO_SW_DEBUG("fetch gpio_hd is %x \n",gpio_hd);
	GPIO_SW_DEBUG("fetch name is %s \n",name);
    ret = gpio_get_one_pin_status(gpio_hd, gpio_info, name, 1);
    if(ret < 0){
        GPIO_SW_DEBUG("fetch gpio infomation fail \n");
	}
	else{
        GPIO_SW_DEBUG("fetch gpio infomation ok \n");
	}
	GPIO_SW_DEBUG("fetch ret0 is %d \n",ret);
	switch ( member_name )
		{
		case mul_sel_1:
		ret = gpio_info->mul_sel;
		break;
		case pull_2:	
		ret = gpio_info->pull;
		break;
		case drv_level_3:		
		ret = gpio_info->drv_level;
		break;
		case data_4:
		ret = gpio_info->data;
		break;
		case port_5:
		ret = gpio_info->port;
		break;
		case port_num_6:
		ret = gpio_info->port_num;
		break;	
		}
	return ret;

}