Lines Matching +full:pinephone +full:- +full:keyboard

1 // SPDX-License-Identifier: GPL-2.0-only
3 // Copyright (C) 2021-2022 Samuel Holland <samuel@sholland.org>
18 #define DRV_NAME "pinephone-keyboard"
160 struct i2c_client *client = adap->algo_data; in ppkb_adap_smbus_xfer()
165 buf[1] = data->byte; in ppkb_adap_smbus_xfer()
183 return -EIO; in ppkb_adap_smbus_xfer()
190 data->byte = ret; in ppkb_adap_smbus_xfer()
209 unsigned short *keymap = ppkb->input->keycode; in ppkb_update()
211 u8 *old_buf = ppkb->buf[!ppkb->buf_swap]; in ppkb_update()
212 u8 *new_buf = ppkb->buf[ppkb->buf_swap]; in ppkb_update()
214 struct device *dev = &client->dev; in ppkb_update()
223 crc = crc8(ppkb->crc_table, &new_buf[1], PPKB_COLS, CRC8_INIT_VALUE); in ppkb_update()
229 ppkb->buf_swap = !ppkb->buf_swap; in ppkb_update()
252 fn_state = value ? ppkb->fn_pressed : ppkb->fn_state[col] & mask; in ppkb_update()
254 ppkb->fn_state[col] ^= mask; in ppkb_update()
259 input_event(ppkb->input, EV_MSC, MSC_SCAN, code); in ppkb_update()
260 input_report_key(ppkb->input, keymap[code], value); in ppkb_update()
262 ppkb->fn_pressed = value; in ppkb_update()
265 input_sync(ppkb->input); in ppkb_update()
279 struct device *dev = &client->dev; in ppkb_set_scan()
323 struct device *dev = &client->dev; in ppkb_probe()
339 error = ret < 0 ? ret : -EIO; in ppkb_probe()
348 return -ENODEV; in ppkb_probe()
359 dev_err(dev, "Unexpected keyboard size %ux%u\n", in ppkb_probe()
361 return -EINVAL; in ppkb_probe()
371 return -ENOMEM; in ppkb_probe()
375 i2c_bus = of_get_child_by_name(dev->of_node, "i2c"); in ppkb_probe()
377 ppkb->adapter.owner = THIS_MODULE; in ppkb_probe()
378 ppkb->adapter.algo = &ppkb_adap_algo; in ppkb_probe()
379 ppkb->adapter.algo_data = client; in ppkb_probe()
380 ppkb->adapter.dev.parent = dev; in ppkb_probe()
381 ppkb->adapter.dev.of_node = i2c_bus; in ppkb_probe()
382 strscpy(ppkb->adapter.name, DRV_NAME, sizeof(ppkb->adapter.name)); in ppkb_probe()
384 error = devm_i2c_add_adapter(dev, &ppkb->adapter); in ppkb_probe()
391 crc8_populate_msb(ppkb->crc_table, PPKB_CRC8_POLYNOMIAL); in ppkb_probe()
393 ppkb->input = devm_input_allocate_device(dev); in ppkb_probe()
394 if (!ppkb->input) in ppkb_probe()
395 return -ENOMEM; in ppkb_probe()
397 input_set_drvdata(ppkb->input, client); in ppkb_probe()
399 ppkb->input->name = "PinePhone Keyboard"; in ppkb_probe()
400 ppkb->input->phys = DRV_NAME "/input0"; in ppkb_probe()
401 ppkb->input->id.bustype = BUS_I2C; in ppkb_probe()
402 ppkb->input->open = ppkb_open; in ppkb_probe()
403 ppkb->input->close = ppkb_close; in ppkb_probe()
405 input_set_capability(ppkb->input, EV_MSC, MSC_SCAN); in ppkb_probe()
406 __set_bit(EV_REP, ppkb->input->evbit); in ppkb_probe()
410 ppkb->input); in ppkb_probe()
416 error = input_register_device(ppkb->input); in ppkb_probe()
422 error = devm_request_threaded_irq(dev, client->irq, in ppkb_probe()
424 IRQF_ONESHOT, client->name, client); in ppkb_probe()
434 { .compatible = "pine64,pinephone-keyboard" },
449 MODULE_DESCRIPTION("Pine64 PinePhone keyboard driver");