goodix_berlin_i2c.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Goodix Berlin Touchscreen Driver
  4. *
  5. * Copyright (C) 2020 - 2021 Goodix, Inc.
  6. * Copyright (C) 2023 Linaro Ltd.
  7. *
  8. * Based on goodix_ts_berlin driver.
  9. */
  10. #include <linux/i2c.h>
  11. #include <linux/kernel.h>
  12. #include <linux/module.h>
  13. #include <linux/regmap.h>
  14. #include <linux/input.h>
  15. #include "goodix_berlin.h"
  16. #define I2C_MAX_TRANSFER_SIZE 256
  17. static const struct regmap_config goodix_berlin_i2c_regmap_conf = {
  18. .reg_bits = 32,
  19. .val_bits = 8,
  20. .max_raw_read = I2C_MAX_TRANSFER_SIZE,
  21. .max_raw_write = I2C_MAX_TRANSFER_SIZE,
  22. };
  23. /* vendor & product left unassigned here, should probably be updated from fw info */
  24. static const struct input_id goodix_berlin_i2c_input_id = {
  25. .bustype = BUS_I2C,
  26. };
  27. static int goodix_berlin_i2c_probe(struct i2c_client *client)
  28. {
  29. struct regmap *regmap;
  30. int error;
  31. regmap = devm_regmap_init_i2c(client, &goodix_berlin_i2c_regmap_conf);
  32. if (IS_ERR(regmap))
  33. return PTR_ERR(regmap);
  34. error = goodix_berlin_probe(&client->dev, client->irq,
  35. &goodix_berlin_i2c_input_id, regmap);
  36. if (error)
  37. return error;
  38. return 0;
  39. }
  40. static const struct i2c_device_id goodix_berlin_i2c_id[] = {
  41. { "gt9916" },
  42. { }
  43. };
  44. MODULE_DEVICE_TABLE(i2c, goodix_berlin_i2c_id);
  45. static const struct of_device_id goodix_berlin_i2c_of_match[] = {
  46. { .compatible = "goodix,gt9916", },
  47. { }
  48. };
  49. MODULE_DEVICE_TABLE(of, goodix_berlin_i2c_of_match);
  50. static struct i2c_driver goodix_berlin_i2c_driver = {
  51. .driver = {
  52. .name = "goodix-berlin-i2c",
  53. .of_match_table = goodix_berlin_i2c_of_match,
  54. .pm = pm_sleep_ptr(&goodix_berlin_pm_ops),
  55. .dev_groups = goodix_berlin_groups,
  56. },
  57. .probe = goodix_berlin_i2c_probe,
  58. .id_table = goodix_berlin_i2c_id,
  59. };
  60. module_i2c_driver(goodix_berlin_i2c_driver);
  61. MODULE_LICENSE("GPL");
  62. MODULE_DESCRIPTION("Goodix Berlin I2C Touchscreen driver");
  63. MODULE_AUTHOR("Neil Armstrong <neil.armstrong@linaro.org>");