/*/只需一个函数即可
int of_get_named_gpio_flags(struct device_node *np, const char *propname,
int index, enum of_gpio_flags *flags);
//返回值为int类型的gpio口.
//np为设备或设备子节点对象, propname为指定的属性名字, index表示获取属性里的第几个值
// 其中flags一定得注意,按文档里的说明应就是一个int类型的值,但根本就不能为int参数(会导致kernel panic),
// 通过阅读内核里的代码得出, flags的参数应为struct gpio_config类型. 定义在下面文件:
-------------------*/
struct gpio_config {
u32 gpio; /* gpio global index, must be unique */
u32 mul_sel; /* multi sel val: 0 - input, 1 - output... */
u32 pull; /* pull val: 0 - pull up/down disable, 1 - pull up... */
u32 drv_level; /* driver level val: 0 - level 0, 1 - level 1... */
u32 data; /* data val: 0 - low, 1 - high, only vaild when mul_sel is input/output */
};
/*
此处是探针程序的运行
*/
static int samtu_ledtest_probe(struct platform_device *pdev)
{
int ret = -1;
int i;
int gpio;
//char led-str[2][8];
//char ledstr[][] ={"ledgpio1","ledgpio2","ledgpio3"};
struct gpio_config flag;
struct device_node *ledtest_node = pdev->dev.of_node;
printk("---------------------hello this is sam is device,probe-------------------------------\n");
printk("%s-%d: enter\n",__FUNCTION__,__LINE__);
//gpio = of_get_named_gpio_flags(ledtest_node,"ledgpiox",0,(enum of_gpio_flags *)&flag);//在DTS里面的gGPIO,想获取哪一个参数民
for(i=0;i<3;i++){
gpio_set_value(gpio,GPIO_LOW);
printk("--------------------gpio is low ,led is open-------------------------------\n");
printk("%s-%d: exit\n",__FUNCTION__,__LINE__);
}
//return 0;//return ok
}
return 0;//return ok
}
static int samtu_ledtest_remove(struct platform_device *pdev)
{