115fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell#ifndef __LINUX_PCF857X_H
215fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell#define __LINUX_PCF857X_H
315fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell
415fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell/**
515fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell * struct pcf857x_platform_data - data to set up pcf857x driver
615fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell * @gpio_base: number of the chip's first GPIO
715fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell * @n_latch: optional bit-inverse of initial register value; if
815fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell *	you leave this initialized to zero the driver will act
915fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell *	like the chip was just reset
1015fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell * @setup: optional callback issued once the GPIOs are valid
1115fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell * @teardown: optional callback issued before the GPIOs are invalidated
1215fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell * @context: optional parameter passed to setup() and teardown()
1315fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell *
1415fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell * In addition to the I2C_BOARD_INFO() state appropriate to each chip,
15eb8a79080984eb9819406a55e4dd17043c380a09Jean Delvare * the i2c_board_info used with the pcf875x driver must provide its
1615fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell * platform_data (pointer to one of these structures) with at least
1715fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell * the gpio_base value initialized.
1815fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell *
1915fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell * The @setup callback may be used with the kind of board-specific glue
2015fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell * which hands the (now-valid) GPIOs to other drivers, or which puts
2115fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell * devices in their initial states using these GPIOs.
2215fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell *
2315fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell * These GPIO chips are only "quasi-bidirectional"; read the chip specs
2415fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell * to understand the behavior.  They don't have separate registers to
2515fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell * record which pins are used for input or output, record which output
2615fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell * values are driven, or provide access to input values.  That must be
2715fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell * inferred by reading the chip's value and knowing the last value written
2815fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell * to it.  If you leave n_latch initialized to zero, that last written
2915fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell * value is presumed to be all ones (as if the chip were just reset).
3015fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell */
3115fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownellstruct pcf857x_platform_data {
3215fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell	unsigned	gpio_base;
3315fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell	unsigned	n_latch;
3415fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell
3515fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell	int		(*setup)(struct i2c_client *client,
3615fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell					int gpio, unsigned ngpio,
3715fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell					void *context);
3815fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell	int		(*teardown)(struct i2c_client *client,
3915fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell					int gpio, unsigned ngpio,
4015fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell					void *context);
4115fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell	void		*context;
4215fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell};
4315fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell
4415fae37d9f5f21571a9618d8353164b6ddfea6f6David Brownell#endif /* __LINUX_PCF857X_H */
45