Lines Matching +full:io +full:- +full:expander
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Driver for keys on TCA6416 I2C IO expander
29 { "tca6416-keys", 16, },
30 { "tca6408-keys", 8, },
52 error = chip->io_size > 8 ? in tca6416_write_reg()
53 i2c_smbus_write_word_data(chip->client, reg << 1, val) : in tca6416_write_reg()
54 i2c_smbus_write_byte_data(chip->client, reg, val); in tca6416_write_reg()
56 dev_err(&chip->client->dev, in tca6416_write_reg()
69 retval = chip->io_size > 8 ? in tca6416_read_reg()
70 i2c_smbus_read_word_data(chip->client, reg << 1) : in tca6416_read_reg()
71 i2c_smbus_read_byte_data(chip->client, reg); in tca6416_read_reg()
73 dev_err(&chip->client->dev, "%s failed, reg: %d, error: %d\n", in tca6416_read_reg()
92 reg_val &= chip->pinmask; in tca6416_keys_scan()
95 val = reg_val ^ chip->reg_input; in tca6416_keys_scan()
96 chip->reg_input = reg_val; in tca6416_keys_scan()
100 struct tca6416_button *button = &chip->buttons[pin_index]; in tca6416_keys_scan()
101 unsigned int type = button->type ?: EV_KEY; in tca6416_keys_scan()
103 ^ button->active_low; in tca6416_keys_scan()
105 input_event(input, type, button->code, !!state); in tca6416_keys_scan()
109 if (chip->pinmask & (1 << i)) in tca6416_keys_scan()
128 if (!chip->use_polling) { in tca6416_keys_open()
131 enable_irq(chip->client->irq); in tca6416_keys_open()
141 if (!chip->use_polling) in tca6416_keys_close()
142 disable_irq(chip->client->irq); in tca6416_keys_close()
149 error = tca6416_read_reg(chip, TCA6416_OUTPUT, &chip->reg_output); in tca6416_setup_registers()
153 error = tca6416_read_reg(chip, TCA6416_DIRECTION, &chip->reg_direction); in tca6416_setup_registers()
159 chip->reg_direction | chip->pinmask); in tca6416_setup_registers()
163 error = tca6416_read_reg(chip, TCA6416_DIRECTION, &chip->reg_direction); in tca6416_setup_registers()
167 error = tca6416_read_reg(chip, TCA6416_INPUT, &chip->reg_input); in tca6416_setup_registers()
171 chip->reg_input &= chip->pinmask; in tca6416_setup_registers()
186 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE)) { in tca6416_keypad_probe()
187 dev_err(&client->dev, "%s adapter not supported\n", in tca6416_keypad_probe()
188 dev_driver_string(&client->adapter->dev)); in tca6416_keypad_probe()
189 return -ENODEV; in tca6416_keypad_probe()
192 pdata = dev_get_platdata(&client->dev); in tca6416_keypad_probe()
194 dev_dbg(&client->dev, "no platform data\n"); in tca6416_keypad_probe()
195 return -EINVAL; in tca6416_keypad_probe()
198 chip = devm_kzalloc(&client->dev, in tca6416_keypad_probe()
199 struct_size(chip, buttons, pdata->nbuttons), in tca6416_keypad_probe()
202 return -ENOMEM; in tca6416_keypad_probe()
204 input = devm_input_allocate_device(&client->dev); in tca6416_keypad_probe()
206 return -ENOMEM; in tca6416_keypad_probe()
208 chip->client = client; in tca6416_keypad_probe()
209 chip->input = input; in tca6416_keypad_probe()
210 chip->io_size = id->driver_data; in tca6416_keypad_probe()
211 chip->pinmask = pdata->pinmask; in tca6416_keypad_probe()
212 chip->use_polling = pdata->use_polling; in tca6416_keypad_probe()
214 input->phys = "tca6416-keys/input0"; in tca6416_keypad_probe()
215 input->name = client->name; in tca6416_keypad_probe()
217 input->open = tca6416_keys_open; in tca6416_keypad_probe()
218 input->close = tca6416_keys_close; in tca6416_keypad_probe()
220 input->id.bustype = BUS_HOST; in tca6416_keypad_probe()
221 input->id.vendor = 0x0001; in tca6416_keypad_probe()
222 input->id.product = 0x0001; in tca6416_keypad_probe()
223 input->id.version = 0x0100; in tca6416_keypad_probe()
226 if (pdata->rep) in tca6416_keypad_probe()
227 __set_bit(EV_REP, input->evbit); in tca6416_keypad_probe()
229 for (i = 0; i < pdata->nbuttons; i++) { in tca6416_keypad_probe()
232 chip->buttons[i] = pdata->buttons[i]; in tca6416_keypad_probe()
233 type = (pdata->buttons[i].type) ?: EV_KEY; in tca6416_keypad_probe()
234 input_set_capability(input, type, pdata->buttons[i].code); in tca6416_keypad_probe()
247 if (chip->use_polling) { in tca6416_keypad_probe()
250 dev_err(&client->dev, "Failed to setup polling\n"); in tca6416_keypad_probe()
256 error = devm_request_threaded_irq(&client->dev, client->irq, in tca6416_keypad_probe()
261 "tca6416-keypad", input); in tca6416_keypad_probe()
263 dev_dbg(&client->dev, in tca6416_keypad_probe()
265 client->irq, error); in tca6416_keypad_probe()
272 dev_dbg(&client->dev, in tca6416_keypad_probe()
284 .name = "tca6416-keypad",
304 MODULE_DESCRIPTION("Keypad driver over tca6416 IO expander");