Lines Matching refs:chip
57 static int tca6416_write_reg(struct tca6416_keypad_chip *chip, int reg, u16 val) in tca6416_write_reg() argument
61 error = chip->io_size > 8 ? in tca6416_write_reg()
62 i2c_smbus_write_word_data(chip->client, reg << 1, val) : in tca6416_write_reg()
63 i2c_smbus_write_byte_data(chip->client, reg, val); in tca6416_write_reg()
65 dev_err(&chip->client->dev, in tca6416_write_reg()
74 static int tca6416_read_reg(struct tca6416_keypad_chip *chip, int reg, u16 *val) in tca6416_read_reg() argument
78 retval = chip->io_size > 8 ? in tca6416_read_reg()
79 i2c_smbus_read_word_data(chip->client, reg << 1) : in tca6416_read_reg()
80 i2c_smbus_read_byte_data(chip->client, reg); in tca6416_read_reg()
82 dev_err(&chip->client->dev, "%s failed, reg: %d, error: %d\n", in tca6416_read_reg()
91 static void tca6416_keys_scan(struct tca6416_keypad_chip *chip) in tca6416_keys_scan() argument
93 struct input_dev *input = chip->input; in tca6416_keys_scan()
97 error = tca6416_read_reg(chip, TCA6416_INPUT, ®_val); in tca6416_keys_scan()
101 reg_val &= chip->pinmask; in tca6416_keys_scan()
104 val = reg_val ^ chip->reg_input; in tca6416_keys_scan()
105 chip->reg_input = reg_val; in tca6416_keys_scan()
109 struct tca6416_button *button = &chip->buttons[pin_index]; in tca6416_keys_scan()
118 if (chip->pinmask & (1 << i)) in tca6416_keys_scan()
128 struct tca6416_keypad_chip *chip = dev_id; in tca6416_keys_isr() local
130 tca6416_keys_scan(chip); in tca6416_keys_isr()
137 struct tca6416_keypad_chip *chip = in tca6416_keys_work_func() local
140 tca6416_keys_scan(chip); in tca6416_keys_work_func()
141 schedule_delayed_work(&chip->dwork, msecs_to_jiffies(100)); in tca6416_keys_work_func()
146 struct tca6416_keypad_chip *chip = input_get_drvdata(dev); in tca6416_keys_open() local
149 tca6416_keys_scan(chip); in tca6416_keys_open()
151 if (chip->use_polling) in tca6416_keys_open()
152 schedule_delayed_work(&chip->dwork, msecs_to_jiffies(100)); in tca6416_keys_open()
154 enable_irq(chip->irqnum); in tca6416_keys_open()
161 struct tca6416_keypad_chip *chip = input_get_drvdata(dev); in tca6416_keys_close() local
163 if (chip->use_polling) in tca6416_keys_close()
164 cancel_delayed_work_sync(&chip->dwork); in tca6416_keys_close()
166 disable_irq(chip->irqnum); in tca6416_keys_close()
169 static int tca6416_setup_registers(struct tca6416_keypad_chip *chip) in tca6416_setup_registers() argument
173 error = tca6416_read_reg(chip, TCA6416_OUTPUT, &chip->reg_output); in tca6416_setup_registers()
177 error = tca6416_read_reg(chip, TCA6416_DIRECTION, &chip->reg_direction); in tca6416_setup_registers()
182 error = tca6416_write_reg(chip, TCA6416_DIRECTION, in tca6416_setup_registers()
183 chip->reg_direction | chip->pinmask); in tca6416_setup_registers()
187 error = tca6416_read_reg(chip, TCA6416_DIRECTION, &chip->reg_direction); in tca6416_setup_registers()
191 error = tca6416_read_reg(chip, TCA6416_INPUT, &chip->reg_input); in tca6416_setup_registers()
195 chip->reg_input &= chip->pinmask; in tca6416_setup_registers()
204 struct tca6416_keypad_chip *chip; in tca6416_keypad_probe() local
222 chip = kzalloc(sizeof(struct tca6416_keypad_chip) + in tca6416_keypad_probe()
226 if (!chip || !input) { in tca6416_keypad_probe()
231 chip->client = client; in tca6416_keypad_probe()
232 chip->input = input; in tca6416_keypad_probe()
233 chip->io_size = id->driver_data; in tca6416_keypad_probe()
234 chip->pinmask = pdata->pinmask; in tca6416_keypad_probe()
235 chip->use_polling = pdata->use_polling; in tca6416_keypad_probe()
237 INIT_DELAYED_WORK(&chip->dwork, tca6416_keys_work_func); in tca6416_keypad_probe()
258 chip->buttons[i] = pdata->buttons[i]; in tca6416_keypad_probe()
263 input_set_drvdata(input, chip); in tca6416_keypad_probe()
269 error = tca6416_setup_registers(chip); in tca6416_keypad_probe()
273 if (!chip->use_polling) { in tca6416_keypad_probe()
275 chip->irqnum = gpio_to_irq(client->irq); in tca6416_keypad_probe()
277 chip->irqnum = client->irq; in tca6416_keypad_probe()
279 error = request_threaded_irq(chip->irqnum, NULL, in tca6416_keypad_probe()
283 "tca6416-keypad", chip); in tca6416_keypad_probe()
287 chip->irqnum, error); in tca6416_keypad_probe()
290 disable_irq(chip->irqnum); in tca6416_keypad_probe()
300 i2c_set_clientdata(client, chip); in tca6416_keypad_probe()
306 if (!chip->use_polling) { in tca6416_keypad_probe()
307 free_irq(chip->irqnum, chip); in tca6416_keypad_probe()
308 enable_irq(chip->irqnum); in tca6416_keypad_probe()
312 kfree(chip); in tca6416_keypad_probe()
318 struct tca6416_keypad_chip *chip = i2c_get_clientdata(client); in tca6416_keypad_remove() local
320 if (!chip->use_polling) { in tca6416_keypad_remove()
321 free_irq(chip->irqnum, chip); in tca6416_keypad_remove()
322 enable_irq(chip->irqnum); in tca6416_keypad_remove()
325 input_unregister_device(chip->input); in tca6416_keypad_remove()
326 kfree(chip); in tca6416_keypad_remove()
335 struct tca6416_keypad_chip *chip = i2c_get_clientdata(client); in tca6416_keypad_suspend() local
338 enable_irq_wake(chip->irqnum); in tca6416_keypad_suspend()
346 struct tca6416_keypad_chip *chip = i2c_get_clientdata(client); in tca6416_keypad_resume() local
349 disable_irq_wake(chip->irqnum); in tca6416_keypad_resume()