• Home
  • Raw
  • Download

Lines Matching +full:has +full:- +full:chip +full:- +full:id

1 // SPDX-License-Identifier: GPL-2.0-only
28 { "tca6416-keys", 16, },
29 { "tca6408-keys", 8, },
54 static int tca6416_write_reg(struct tca6416_keypad_chip *chip, int reg, u16 val) in tca6416_write_reg() argument
58 error = chip->io_size > 8 ? in tca6416_write_reg()
59 i2c_smbus_write_word_data(chip->client, reg << 1, val) : in tca6416_write_reg()
60 i2c_smbus_write_byte_data(chip->client, reg, val); in tca6416_write_reg()
62 dev_err(&chip->client->dev, in tca6416_write_reg()
71 static int tca6416_read_reg(struct tca6416_keypad_chip *chip, int reg, u16 *val) in tca6416_read_reg() argument
75 retval = chip->io_size > 8 ? in tca6416_read_reg()
76 i2c_smbus_read_word_data(chip->client, reg << 1) : in tca6416_read_reg()
77 i2c_smbus_read_byte_data(chip->client, reg); in tca6416_read_reg()
79 dev_err(&chip->client->dev, "%s failed, reg: %d, error: %d\n", in tca6416_read_reg()
88 static void tca6416_keys_scan(struct tca6416_keypad_chip *chip) in tca6416_keys_scan() argument
90 struct input_dev *input = chip->input; in tca6416_keys_scan()
94 error = tca6416_read_reg(chip, TCA6416_INPUT, &reg_val); in tca6416_keys_scan()
98 reg_val &= chip->pinmask; in tca6416_keys_scan()
101 val = reg_val ^ chip->reg_input; in tca6416_keys_scan()
102 chip->reg_input = reg_val; in tca6416_keys_scan()
106 struct tca6416_button *button = &chip->buttons[pin_index]; in tca6416_keys_scan()
107 unsigned int type = button->type ?: EV_KEY; in tca6416_keys_scan()
109 ^ button->active_low; in tca6416_keys_scan()
111 input_event(input, type, button->code, !!state); in tca6416_keys_scan()
115 if (chip->pinmask & (1 << i)) in tca6416_keys_scan()
125 struct tca6416_keypad_chip *chip = dev_id; in tca6416_keys_isr() local
127 tca6416_keys_scan(chip); in tca6416_keys_isr()
134 struct tca6416_keypad_chip *chip = in tca6416_keys_work_func() local
137 tca6416_keys_scan(chip); in tca6416_keys_work_func()
138 schedule_delayed_work(&chip->dwork, msecs_to_jiffies(100)); in tca6416_keys_work_func()
143 struct tca6416_keypad_chip *chip = input_get_drvdata(dev); in tca6416_keys_open() local
145 /* Get initial device state in case it has switches */ in tca6416_keys_open()
146 tca6416_keys_scan(chip); in tca6416_keys_open()
148 if (chip->use_polling) in tca6416_keys_open()
149 schedule_delayed_work(&chip->dwork, msecs_to_jiffies(100)); in tca6416_keys_open()
151 enable_irq(chip->irqnum); in tca6416_keys_open()
158 struct tca6416_keypad_chip *chip = input_get_drvdata(dev); in tca6416_keys_close() local
160 if (chip->use_polling) in tca6416_keys_close()
161 cancel_delayed_work_sync(&chip->dwork); in tca6416_keys_close()
163 disable_irq(chip->irqnum); in tca6416_keys_close()
166 static int tca6416_setup_registers(struct tca6416_keypad_chip *chip) in tca6416_setup_registers() argument
170 error = tca6416_read_reg(chip, TCA6416_OUTPUT, &chip->reg_output); in tca6416_setup_registers()
174 error = tca6416_read_reg(chip, TCA6416_DIRECTION, &chip->reg_direction); in tca6416_setup_registers()
179 error = tca6416_write_reg(chip, TCA6416_DIRECTION, in tca6416_setup_registers()
180 chip->reg_direction | chip->pinmask); in tca6416_setup_registers()
184 error = tca6416_read_reg(chip, TCA6416_DIRECTION, &chip->reg_direction); in tca6416_setup_registers()
188 error = tca6416_read_reg(chip, TCA6416_INPUT, &chip->reg_input); in tca6416_setup_registers()
192 chip->reg_input &= chip->pinmask; in tca6416_setup_registers()
198 const struct i2c_device_id *id) in tca6416_keypad_probe() argument
201 struct tca6416_keypad_chip *chip; in tca6416_keypad_probe() local
207 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE)) { in tca6416_keypad_probe()
208 dev_err(&client->dev, "%s adapter not supported\n", in tca6416_keypad_probe()
209 dev_driver_string(&client->adapter->dev)); in tca6416_keypad_probe()
210 return -ENODEV; in tca6416_keypad_probe()
213 pdata = dev_get_platdata(&client->dev); in tca6416_keypad_probe()
215 dev_dbg(&client->dev, "no platform data\n"); in tca6416_keypad_probe()
216 return -EINVAL; in tca6416_keypad_probe()
219 chip = kzalloc(struct_size(chip, buttons, pdata->nbuttons), GFP_KERNEL); in tca6416_keypad_probe()
221 if (!chip || !input) { in tca6416_keypad_probe()
222 error = -ENOMEM; in tca6416_keypad_probe()
226 chip->client = client; in tca6416_keypad_probe()
227 chip->input = input; in tca6416_keypad_probe()
228 chip->io_size = id->driver_data; in tca6416_keypad_probe()
229 chip->pinmask = pdata->pinmask; in tca6416_keypad_probe()
230 chip->use_polling = pdata->use_polling; in tca6416_keypad_probe()
232 INIT_DELAYED_WORK(&chip->dwork, tca6416_keys_work_func); in tca6416_keypad_probe()
234 input->phys = "tca6416-keys/input0"; in tca6416_keypad_probe()
235 input->name = client->name; in tca6416_keypad_probe()
236 input->dev.parent = &client->dev; in tca6416_keypad_probe()
238 input->open = tca6416_keys_open; in tca6416_keypad_probe()
239 input->close = tca6416_keys_close; in tca6416_keypad_probe()
241 input->id.bustype = BUS_HOST; in tca6416_keypad_probe()
242 input->id.vendor = 0x0001; in tca6416_keypad_probe()
243 input->id.product = 0x0001; in tca6416_keypad_probe()
244 input->id.version = 0x0100; in tca6416_keypad_probe()
247 if (pdata->rep) in tca6416_keypad_probe()
248 __set_bit(EV_REP, input->evbit); in tca6416_keypad_probe()
250 for (i = 0; i < pdata->nbuttons; i++) { in tca6416_keypad_probe()
253 chip->buttons[i] = pdata->buttons[i]; in tca6416_keypad_probe()
254 type = (pdata->buttons[i].type) ?: EV_KEY; in tca6416_keypad_probe()
255 input_set_capability(input, type, pdata->buttons[i].code); in tca6416_keypad_probe()
258 input_set_drvdata(input, chip); in tca6416_keypad_probe()
262 * we can't share this chip with another i2c master. in tca6416_keypad_probe()
264 error = tca6416_setup_registers(chip); in tca6416_keypad_probe()
268 if (!chip->use_polling) { in tca6416_keypad_probe()
269 if (pdata->irq_is_gpio) in tca6416_keypad_probe()
270 chip->irqnum = gpio_to_irq(client->irq); in tca6416_keypad_probe()
272 chip->irqnum = client->irq; in tca6416_keypad_probe()
274 error = request_threaded_irq(chip->irqnum, NULL, in tca6416_keypad_probe()
278 "tca6416-keypad", chip); in tca6416_keypad_probe()
280 dev_dbg(&client->dev, in tca6416_keypad_probe()
282 chip->irqnum, error); in tca6416_keypad_probe()
285 disable_irq(chip->irqnum); in tca6416_keypad_probe()
290 dev_dbg(&client->dev, in tca6416_keypad_probe()
295 i2c_set_clientdata(client, chip); in tca6416_keypad_probe()
296 device_init_wakeup(&client->dev, 1); in tca6416_keypad_probe()
301 if (!chip->use_polling) { in tca6416_keypad_probe()
302 free_irq(chip->irqnum, chip); in tca6416_keypad_probe()
303 enable_irq(chip->irqnum); in tca6416_keypad_probe()
307 kfree(chip); in tca6416_keypad_probe()
313 struct tca6416_keypad_chip *chip = i2c_get_clientdata(client); in tca6416_keypad_remove() local
315 if (!chip->use_polling) { in tca6416_keypad_remove()
316 free_irq(chip->irqnum, chip); in tca6416_keypad_remove()
317 enable_irq(chip->irqnum); in tca6416_keypad_remove()
320 input_unregister_device(chip->input); in tca6416_keypad_remove()
321 kfree(chip); in tca6416_keypad_remove()
330 struct tca6416_keypad_chip *chip = i2c_get_clientdata(client); in tca6416_keypad_suspend() local
333 enable_irq_wake(chip->irqnum); in tca6416_keypad_suspend()
341 struct tca6416_keypad_chip *chip = i2c_get_clientdata(client); in tca6416_keypad_resume() local
344 disable_irq_wake(chip->irqnum); in tca6416_keypad_resume()
355 .name = "tca6416-keypad",