1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */ 2*4882a593Smuzhiyun #ifndef __LINUX_PCF857X_H 3*4882a593Smuzhiyun #define __LINUX_PCF857X_H 4*4882a593Smuzhiyun 5*4882a593Smuzhiyun /** 6*4882a593Smuzhiyun * struct pcf857x_platform_data - data to set up pcf857x driver 7*4882a593Smuzhiyun * @gpio_base: number of the chip's first GPIO 8*4882a593Smuzhiyun * @n_latch: optional bit-inverse of initial register value; if 9*4882a593Smuzhiyun * you leave this initialized to zero the driver will act 10*4882a593Smuzhiyun * like the chip was just reset 11*4882a593Smuzhiyun * @setup: optional callback issued once the GPIOs are valid 12*4882a593Smuzhiyun * @teardown: optional callback issued before the GPIOs are invalidated 13*4882a593Smuzhiyun * @context: optional parameter passed to setup() and teardown() 14*4882a593Smuzhiyun * 15*4882a593Smuzhiyun * In addition to the I2C_BOARD_INFO() state appropriate to each chip, 16*4882a593Smuzhiyun * the i2c_board_info used with the pcf875x driver must provide its 17*4882a593Smuzhiyun * platform_data (pointer to one of these structures) with at least 18*4882a593Smuzhiyun * the gpio_base value initialized. 19*4882a593Smuzhiyun * 20*4882a593Smuzhiyun * The @setup callback may be used with the kind of board-specific glue 21*4882a593Smuzhiyun * which hands the (now-valid) GPIOs to other drivers, or which puts 22*4882a593Smuzhiyun * devices in their initial states using these GPIOs. 23*4882a593Smuzhiyun * 24*4882a593Smuzhiyun * These GPIO chips are only "quasi-bidirectional"; read the chip specs 25*4882a593Smuzhiyun * to understand the behavior. They don't have separate registers to 26*4882a593Smuzhiyun * record which pins are used for input or output, record which output 27*4882a593Smuzhiyun * values are driven, or provide access to input values. That must be 28*4882a593Smuzhiyun * inferred by reading the chip's value and knowing the last value written 29*4882a593Smuzhiyun * to it. If you leave n_latch initialized to zero, that last written 30*4882a593Smuzhiyun * value is presumed to be all ones (as if the chip were just reset). 31*4882a593Smuzhiyun */ 32*4882a593Smuzhiyun struct pcf857x_platform_data { 33*4882a593Smuzhiyun unsigned gpio_base; 34*4882a593Smuzhiyun unsigned n_latch; 35*4882a593Smuzhiyun 36*4882a593Smuzhiyun int (*setup)(struct i2c_client *client, 37*4882a593Smuzhiyun int gpio, unsigned ngpio, 38*4882a593Smuzhiyun void *context); 39*4882a593Smuzhiyun int (*teardown)(struct i2c_client *client, 40*4882a593Smuzhiyun int gpio, unsigned ngpio, 41*4882a593Smuzhiyun void *context); 42*4882a593Smuzhiyun void *context; 43*4882a593Smuzhiyun }; 44*4882a593Smuzhiyun 45*4882a593Smuzhiyun #endif /* __LINUX_PCF857X_H */ 46