Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __LINUX_PCF857X_H
0003 #define __LINUX_PCF857X_H
0004 
0005 /**
0006  * struct pcf857x_platform_data - data to set up pcf857x driver
0007  * @gpio_base: number of the chip's first GPIO
0008  * @n_latch: optional bit-inverse of initial register value; if
0009  *  you leave this initialized to zero the driver will act
0010  *  like the chip was just reset
0011  * @setup: optional callback issued once the GPIOs are valid
0012  * @teardown: optional callback issued before the GPIOs are invalidated
0013  * @context: optional parameter passed to setup() and teardown()
0014  *
0015  * In addition to the I2C_BOARD_INFO() state appropriate to each chip,
0016  * the i2c_board_info used with the pcf875x driver must provide its
0017  * platform_data (pointer to one of these structures) with at least
0018  * the gpio_base value initialized.
0019  *
0020  * The @setup callback may be used with the kind of board-specific glue
0021  * which hands the (now-valid) GPIOs to other drivers, or which puts
0022  * devices in their initial states using these GPIOs.
0023  *
0024  * These GPIO chips are only "quasi-bidirectional"; read the chip specs
0025  * to understand the behavior.  They don't have separate registers to
0026  * record which pins are used for input or output, record which output
0027  * values are driven, or provide access to input values.  That must be
0028  * inferred by reading the chip's value and knowing the last value written
0029  * to it.  If you leave n_latch initialized to zero, that last written
0030  * value is presumed to be all ones (as if the chip were just reset).
0031  */
0032 struct pcf857x_platform_data {
0033     unsigned    gpio_base;
0034     unsigned    n_latch;
0035 
0036     int     (*setup)(struct i2c_client *client,
0037                     int gpio, unsigned ngpio,
0038                     void *context);
0039     void        (*teardown)(struct i2c_client *client,
0040                     int gpio, unsigned ngpio,
0041                     void *context);
0042     void        *context;
0043 };
0044 
0045 #endif /* __LINUX_PCF857X_H */