diff options
author | David Brownell <dbrownell@users.sourceforge.net> | 2008-02-05 01:28:24 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-05 12:44:13 -0500 |
commit | 15fae37d9f5f21571a9618d8353164b6ddfea6f6 (patch) | |
tree | 13b4fb5479cf3a9522c6673cc6ccae20b6658e55 /include/linux | |
parent | 1c44f5f16fee880b294f8068354bfb9dddf1349b (diff) |
gpiolib: pcf857x i2c gpio expander support
This is a new-style I2C driver for most common 8 and 16 bit I2C based
"quasi-bidirectional" GPIO expanders: pcf8574 or pcf8575, and several
compatible models (mostly faster, supporting I2C at up to 1 MHz).
The driver exposes the GPIO signals using the platform-neutral GPIO
programming interface, so they are easily accessed by other kernel code. The
lack of such a flexible kernel API has been a big factor in the proliferation
of board-specific drivers for these chips... stuff that rarely makes it
upstream since it's so ugly. This driver will let such boards use standard
calls.
Since it's a new-style driver, these devices must be configured as part of
board-specific init. That eliminates the need for error-prone manual
configuration of module parameters, and makes compatibility with legacy
drivers (pcf8574.c, pc8575.c) for these chips easier (there's a clear
either/or disjunction).
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Acked-by: Jean Delvare <khali@linux-fr.org>
Cc: Eric Miao <eric.miao@marvell.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Haavard Skinnemoen <hskinnemoen@atmel.com>
Cc: Philipp Zabel <philipp.zabel@gmail.com>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Ben Gardner <bgardner@wabtec.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/i2c/pcf857x.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/include/linux/i2c/pcf857x.h b/include/linux/i2c/pcf857x.h new file mode 100644 index 000000000000..ba8ea6e16476 --- /dev/null +++ b/include/linux/i2c/pcf857x.h | |||
@@ -0,0 +1,45 @@ | |||
1 | #ifndef __LINUX_PCF857X_H | ||
2 | #define __LINUX_PCF857X_H | ||
3 | |||
4 | /** | ||
5 | * struct pcf857x_platform_data - data to set up pcf857x driver | ||
6 | * @gpio_base: number of the chip's first GPIO | ||
7 | * @n_latch: optional bit-inverse of initial register value; if | ||
8 | * you leave this initialized to zero the driver will act | ||
9 | * like the chip was just reset | ||
10 | * @setup: optional callback issued once the GPIOs are valid | ||
11 | * @teardown: optional callback issued before the GPIOs are invalidated | ||
12 | * @context: optional parameter passed to setup() and teardown() | ||
13 | * | ||
14 | * In addition to the I2C_BOARD_INFO() state appropriate to each chip, | ||
15 | * the i2c_board_info used with the pcf875x driver must provide the | ||
16 | * chip "type" ("pcf8574", "pcf8574a", "pcf8575", "pcf8575c") and its | ||
17 | * platform_data (pointer to one of these structures) with at least | ||
18 | * the gpio_base value initialized. | ||
19 | * | ||
20 | * The @setup callback may be used with the kind of board-specific glue | ||
21 | * which hands the (now-valid) GPIOs to other drivers, or which puts | ||
22 | * devices in their initial states using these GPIOs. | ||
23 | * | ||
24 | * These GPIO chips are only "quasi-bidirectional"; read the chip specs | ||
25 | * to understand the behavior. They don't have separate registers to | ||
26 | * record which pins are used for input or output, record which output | ||
27 | * values are driven, or provide access to input values. That must be | ||
28 | * inferred by reading the chip's value and knowing the last value written | ||
29 | * to it. If you leave n_latch initialized to zero, that last written | ||
30 | * value is presumed to be all ones (as if the chip were just reset). | ||
31 | */ | ||
32 | struct pcf857x_platform_data { | ||
33 | unsigned gpio_base; | ||
34 | unsigned n_latch; | ||
35 | |||
36 | int (*setup)(struct i2c_client *client, | ||
37 | int gpio, unsigned ngpio, | ||
38 | void *context); | ||
39 | int (*teardown)(struct i2c_client *client, | ||
40 | int gpio, unsigned ngpio, | ||
41 | void *context); | ||
42 | void *context; | ||
43 | }; | ||
44 | |||
45 | #endif /* __LINUX_PCF857X_H */ | ||