Linux GPIO Interfaces


That said, if the convention is supported on their platform, drivers should
use it when possible. Platforms must declare GENERIC_GPIO support in their
Kconfig (boolean true), and provide an <asm/gpio.h> file. Drivers that can't
work without standard GPIO calls should have Kconfig entries which depend
on GENERIC_GPIO. The GPIO calls are available, either as "real code" or as
optimized-away stubs, when drivers use the include file:

#include <linux/gpio.h>

Identifying GPIOs
-----------------
GPIOs are identified by unsigned integers in the range 0..MAX_INT. That
reserves "negative" numbers for other purposes like marking signals as
"not available on this board", or indicating faults. Code that doesn't
touch the underlying hardware treats these integers as opaque cookies.

If you want to initialize a structure with an invalid GPIO number, use
some negative number (perhaps "-EINVAL"); that will never be valid. To
test if such number from such a structure could reference a GPIO, you
may use this predicate:

int gpio_is_valid(int number);

A number that's not valid will be rejected by calls which may request
or free GPIOs (see below). Other numbers may also be rejected; for
example, a number might be valid but temporarily unused on a given board.

优质内容筛选与推荐>>
1、LightOJ1282 Leading and Trailing 数学结论
2、过程(栈帧结构是干货)
3、控制语句(if-else+循环+switch)汇编规则
4、Xencentos 系统 处理子机对外发包
5、Java集合类 List Set Map


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号