/*
struct pinctrl_state {
struct list_head node;//挂入链表头的节点
const char *name;//该state的名字
struct list_head settings;//属于该状态的所有的settings
};*/
static int xxx_probe(struct platform_device *dev)
{
/*先申请内存、注册创建相关节点*/
/*下面直接进入gpio ctrl部分*/
struct pinctrl_state *xxx_pin_ctrl,*xxx_rst_on,*xxx_rst_off;
xxx_pin_ctrl = devm_pinctrl_get(&pdev->dev); /*Resource managed pinctrl_get()*/
if (IS_ERR(xxx_pin_ctrl)) {
printk("failed\n");
ret = PTR_ERR(xxx_pin_ctrl);
return ret;
}
xxx_rst_on = pinctrl_lookup_state(xxx_pin_ctrl, "gpio_rst_on");
if (IS_ERR(xxx_rst_on)) {
printk("failed\n");
ret = PTR_ERR(xxx_rst_on);
return ret;
}
xxx_rst_off = pinctrl_lookup_state(xxx_pin_ctrl, "gpio_rst_off");
if (IS_ERR(xxx_rst_off)) {
printk("failed\n");
ret = PTR_ERR(xxx_rst_off);
return ret;
}
/*下面就是直接调用gpio5,可以单独封装为一个函数*/
pinctrl_select_state(xxx_pin_ctrl, xxx_rst_on);/*gpio5输出高电平*/
delay(20);
pinctrl_select_state(xxx_pin_ctrl, xxx_rst_off);/*gpio5输出低电平*/
delay(20);
}
static int xxx_remove(struct platform_device *dev){
/*************/
}
#ifdef CONFIG_OF
static const struct of_device_id xxx_gpio_of_id[] = {
{.compatible = "mediatek,gpio_rst",},
{}
};
#endif
static struct platform_driver caotuo_platform_driver = {
.probe = xxx_probe,
.remove = xxx_remove,
.driver = {
.name = my_name,
.owner = THIS_MODULE,
#ifdef CONFIG_OF/*增加宏判断,低版本内核不带dts*/
.of_match_table = xxx_gpio_of_id,
#endif
},
};
static int __init caotuo_init(void)
{
int ret=0;
ret = platform_driver_register(&caotuo_platform_driver);
if (ret) {
printk("failed\n");
return ret;
}
return ret;
}
static void __exit caotuo_exit(void)
{
platform_driver_unregister(&caotuo_platform_driver);
}
module_init(caotuo_init);
module_exit(caotuo_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("xxxx");
MODULE_DESCRIPTION("xxxx");
---------------------
作者:caotuo_csdn
来源:CSDN
原文:https://blog.csdn.net/caotuo_csdn/article/details/79164709
版权声明:本文为博主原创文章,转载请附上博文链接!
阅读(5796) | 评论(0) | 转发(0) |