how to port 2.6.x driver to 4.x --关于pinctl 和GPIO
来源:互联网 发布:新田县广电网络费用 编辑:程序博客网 时间:2024/05/24 02:15
在2.6.x的代码里面对于PIN脚复用都是在对应的芯片的broad code里面进行配置的,直接调用相关的特有API去设置。如我使用的AT91 MSA9260里面的at91_set_GPIO_periph()用于设置一个PIN为GPIO的模式,at91_set_A_periph() 用于设置一个PIN为A mode。而且每家chip厂商提供的风格和形式都不相同。在3.x之后的代码里面kernel引入了pinctl的驱动,对这些进行了更好的设计:
这些描述是来自kernel的document里面的(pinctrl.txt)根据我的时间,我认为它可以更好的和DTS工作,更好的和GPIO工作,使得GPIO的API更加通用,这样我们自己写的驱动调用GPIO的部分就不用去区别不同的chip厂家了。PINCTRL (PIN CONTROL) subsystem
This document outlines the pin control subsystem in Linux
This subsystem deals with:
- Enumerating and naming controllable pins
- Multiplexing of pins, pads, fingers (etc) see below for details
- Configuration of pins, pads, fingers (etc), such as software-controlled
biasing and driving mode specific pins, such as pull-up/down, open drain,
load capacitance etc.
比如我们配置PINB17为GPIO mode:
然后我们在我们的驱动代码里面只需要调用对应的GPIO 通用接口,如:gpio0 {
pinctrl_gpio0: gpio0-0 {
atmel,pins =
<AT91_PIOB 16 AT91_PERIPH_B GPIO_ACTIVE_LOW/* CAN reset active Low */
AT91_PIOB 17 AT91_PERIPH_B GPIO_ACTIVE_HIGH>;/* CAN Power active High */
};usart2: serial@fffb8000 {
/* ttyS3 -- RS485 */
/* DTR HW/SW enabled/disabled from userspace using ioctl */
linux,rs485-enabled-at-boot-time; /* enable RS485 mode in the bootup */
dtr-gpios = <&pioB 17 0>; /*xxx, the AT91_PIN_PB17 is a dtr control signal. */
status = "okay";
};
这样我们的驱动的代码就不用在意不同的chip厂商不同的实现了。是需要把项目的DTS配置好,代码的移植性可想而知了。gpio_is_valid(int number);
/* set as input or output, returning 0 or negative errno */
int gpio_direction_input(unsigned gpio);
int gpio_direction_output(unsigned gpio, int value);/* GPIO INPUT: return zero or nonzero */
int gpio_get_value(unsigned gpio);
/* GPIO OUTPUT */
void gpio_set_value(unsigned gpio, int value);
Note:kernel里面的document文件时非常有用的资料,特别是在我们从低版本的kernel升级到高版本时,很多变化我们都是可以从这里得到最权威的信息的。
- how to port 2.6.x driver to 4.x --关于pinctl 和GPIO
- how to port 2.6.x driver to 4.x --- DTS
- How to Port rt73 driver to ARM
- How to Port rt73 driver to ARM
- HttpClient 4.x how to use cookies?
- port systemc to mac os x
- How to uninstall CUDA driver and toolkit in Mac OS X?
- ubuntu install NVIDIA driver(Common methods, include how to exit X service)
- GPIO IR How-to
- How to build CZMQ 4.X in Windows.
- How to install OWLNext 6.1x
- How to use pthread in cocos2d-x
- How to play animations in Cocos2d-x?
- Cocos2d-x How to save ScreenShot ?
- How to Install PyQt4 on OS X
- How to port manufacturer ROM
- How I installed the Windows 7 64x C++ driver/mongoDB to work with Visual Studio 2010
- How to Mac OS X speech to text API
- authentication is required (java发送邮件)
- CSS---网页编程(三)网页化妆技术CSS学习、CSS盒子模型
- [BFS]101. Symmetric Tree
- JAVA-练习MyShopping实现商品换购 综合运用嵌套if选择结构 switch选择结构 多重if选择 结构实现商品换购功能
- Apache POI
- how to port 2.6.x driver to 4.x --关于pinctl 和GPIO
- Spark
- 华为称手机流畅度不由单一部件决定
- mysql存储过程学习推荐网址
- 执行cp命令时提示cp: 略过目录
- Android6.0以后 申请敏感权限两次的解决方法
- JS数组合并
- 关于jquery的each()函数
- 新一代Windows系统重磅曝光:全局标签化