码迷,mamicode.com
首页 > 系统相关 > 详细

Linux GPIO Interfaces

时间:2016-01-06 19:40:32      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:

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.

Linux GPIO Interfaces

标签:

原文地址:http://www.cnblogs.com/lwp513/p/5106453.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!