Lines Matching refs:gpio
7 * Based on gpio-tpic2810.c
12 #include <linux/gpio/driver.h>
44 static int pca9570_read(struct pca9570 *gpio, u8 *value)
46 struct i2c_client *client = to_i2c_client(gpio->chip.parent);
49 if (gpio->chip_data->command != 0)
50 ret = i2c_smbus_read_byte_data(client, gpio->chip_data->command);
61 static int pca9570_write(struct pca9570 *gpio, u8 value)
63 struct i2c_client *client = to_i2c_client(gpio->chip.parent);
65 if (gpio->chip_data->command != 0)
66 return i2c_smbus_write_byte_data(client, gpio->chip_data->command, value);
80 struct pca9570 *gpio = gpiochip_get_data(chip);
84 ret = pca9570_read(gpio, &buffer);
93 struct pca9570 *gpio = gpiochip_get_data(chip);
97 mutex_lock(&gpio->lock);
99 buffer = gpio->out;
105 ret = pca9570_write(gpio, buffer);
109 gpio->out = buffer;
112 mutex_unlock(&gpio->lock);
117 struct pca9570 *gpio;
119 gpio = devm_kzalloc(&client->dev, sizeof(*gpio), GFP_KERNEL);
120 if (!gpio)
123 gpio->chip.label = client->name;
124 gpio->chip.parent = &client->dev;
125 gpio->chip.owner = THIS_MODULE;
126 gpio->chip.get_direction = pca9570_get_direction;
127 gpio->chip.get = pca9570_get;
128 gpio->chip.set = pca9570_set;
129 gpio->chip.base = -1;
130 gpio->chip_data = device_get_match_data(&client->dev);
131 gpio->chip.ngpio = gpio->chip_data->ngpio;
132 gpio->chip.can_sleep = true;
134 mutex_init(&gpio->lock);
137 pca9570_read(gpio, &gpio->out);
139 i2c_set_clientdata(client, gpio);
141 return devm_gpiochip_add_data(&client->dev, &gpio->chip, gpio);