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()
328 struct device *dev = &client->dev; in ppkb_probe()
357 error = ret < 0 ? ret : -EIO; in ppkb_probe()
366 return -ENODEV; in ppkb_probe()
377 dev_err(dev, "Unexpected keyboard size %ux%u\n", in ppkb_probe()
379 return -EINVAL; in ppkb_probe()
389 return -ENOMEM; in ppkb_probe()
393 i2c_bus = of_get_child_by_name(dev->of_node, "i2c"); in ppkb_probe()
395 ppkb->adapter.owner = THIS_MODULE; in ppkb_probe()
396 ppkb->adapter.algo = &ppkb_adap_algo; in ppkb_probe()
397 ppkb->adapter.algo_data = client; in ppkb_probe()
398 ppkb->adapter.dev.parent = dev; in ppkb_probe()
399 ppkb->adapter.dev.of_node = i2c_bus; in ppkb_probe()
400 strscpy(ppkb->adapter.name, DRV_NAME, sizeof(ppkb->adapter.name)); in ppkb_probe()
402 error = devm_i2c_add_adapter(dev, &ppkb->adapter); in ppkb_probe()
409 crc8_populate_msb(ppkb->crc_table, PPKB_CRC8_POLYNOMIAL); in ppkb_probe()
411 ppkb->input = devm_input_allocate_device(dev); in ppkb_probe()
412 if (!ppkb->input) in ppkb_probe()
413 return -ENOMEM; in ppkb_probe()
415 input_set_drvdata(ppkb->input, client); in ppkb_probe()
417 ppkb->input->name = "PinePhone Keyboard"; in ppkb_probe()
418 ppkb->input->phys = DRV_NAME "/input0"; in ppkb_probe()
419 ppkb->input->id.bustype = BUS_I2C; in ppkb_probe()
420 ppkb->input->open = ppkb_open; in ppkb_probe()
421 ppkb->input->close = ppkb_close; in ppkb_probe()
423 input_set_capability(ppkb->input, EV_MSC, MSC_SCAN); in ppkb_probe()
424 __set_bit(EV_REP, ppkb->input->evbit); in ppkb_probe()
428 ppkb->input); in ppkb_probe()
434 error = input_register_device(ppkb->input); in ppkb_probe()
440 error = devm_request_threaded_irq(dev, client->irq, in ppkb_probe()
442 IRQF_ONESHOT, client->name, client); in ppkb_probe()
452 { .compatible = "pine64,pinephone-keyboard" },
467 MODULE_DESCRIPTION("Pine64 PinePhone keyboard driver");