mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-26 22:24:09 +08:00
15fae37d9f
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>
46 lines
1.8 KiB
C
46 lines
1.8 KiB
C
#ifndef __LINUX_PCF857X_H
|
|
#define __LINUX_PCF857X_H
|
|
|
|
/**
|
|
* struct pcf857x_platform_data - data to set up pcf857x driver
|
|
* @gpio_base: number of the chip's first GPIO
|
|
* @n_latch: optional bit-inverse of initial register value; if
|
|
* you leave this initialized to zero the driver will act
|
|
* like the chip was just reset
|
|
* @setup: optional callback issued once the GPIOs are valid
|
|
* @teardown: optional callback issued before the GPIOs are invalidated
|
|
* @context: optional parameter passed to setup() and teardown()
|
|
*
|
|
* In addition to the I2C_BOARD_INFO() state appropriate to each chip,
|
|
* the i2c_board_info used with the pcf875x driver must provide the
|
|
* chip "type" ("pcf8574", "pcf8574a", "pcf8575", "pcf8575c") and its
|
|
* platform_data (pointer to one of these structures) with at least
|
|
* the gpio_base value initialized.
|
|
*
|
|
* The @setup callback may be used with the kind of board-specific glue
|
|
* which hands the (now-valid) GPIOs to other drivers, or which puts
|
|
* devices in their initial states using these GPIOs.
|
|
*
|
|
* These GPIO chips are only "quasi-bidirectional"; read the chip specs
|
|
* to understand the behavior. They don't have separate registers to
|
|
* record which pins are used for input or output, record which output
|
|
* values are driven, or provide access to input values. That must be
|
|
* inferred by reading the chip's value and knowing the last value written
|
|
* to it. If you leave n_latch initialized to zero, that last written
|
|
* value is presumed to be all ones (as if the chip were just reset).
|
|
*/
|
|
struct pcf857x_platform_data {
|
|
unsigned gpio_base;
|
|
unsigned n_latch;
|
|
|
|
int (*setup)(struct i2c_client *client,
|
|
int gpio, unsigned ngpio,
|
|
void *context);
|
|
int (*teardown)(struct i2c_client *client,
|
|
int gpio, unsigned ngpio,
|
|
void *context);
|
|
void *context;
|
|
};
|
|
|
|
#endif /* __LINUX_PCF857X_H */
|