pcm512x-i2c.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Driver for the PCM512x CODECs
  4. *
  5. * Author: Mark Brown <[email protected]>
  6. * Copyright 2014 Linaro Ltd
  7. */
  8. #include <linux/init.h>
  9. #include <linux/module.h>
  10. #include <linux/i2c.h>
  11. #include <linux/acpi.h>
  12. #include "pcm512x.h"
  13. static int pcm512x_i2c_probe(struct i2c_client *i2c)
  14. {
  15. struct regmap *regmap;
  16. struct regmap_config config = pcm512x_regmap;
  17. /* msb needs to be set to enable auto-increment of addresses */
  18. config.read_flag_mask = 0x80;
  19. config.write_flag_mask = 0x80;
  20. regmap = devm_regmap_init_i2c(i2c, &config);
  21. if (IS_ERR(regmap))
  22. return PTR_ERR(regmap);
  23. return pcm512x_probe(&i2c->dev, regmap);
  24. }
  25. static void pcm512x_i2c_remove(struct i2c_client *i2c)
  26. {
  27. pcm512x_remove(&i2c->dev);
  28. }
  29. static const struct i2c_device_id pcm512x_i2c_id[] = {
  30. { "pcm5121", },
  31. { "pcm5122", },
  32. { "pcm5141", },
  33. { "pcm5142", },
  34. { }
  35. };
  36. MODULE_DEVICE_TABLE(i2c, pcm512x_i2c_id);
  37. #if defined(CONFIG_OF)
  38. static const struct of_device_id pcm512x_of_match[] = {
  39. { .compatible = "ti,pcm5121", },
  40. { .compatible = "ti,pcm5122", },
  41. { .compatible = "ti,pcm5141", },
  42. { .compatible = "ti,pcm5142", },
  43. { }
  44. };
  45. MODULE_DEVICE_TABLE(of, pcm512x_of_match);
  46. #endif
  47. #ifdef CONFIG_ACPI
  48. static const struct acpi_device_id pcm512x_acpi_match[] = {
  49. { "104C5121", 0 },
  50. { "104C5122", 0 },
  51. { "104C5141", 0 },
  52. { "104C5142", 0 },
  53. { },
  54. };
  55. MODULE_DEVICE_TABLE(acpi, pcm512x_acpi_match);
  56. #endif
  57. static struct i2c_driver pcm512x_i2c_driver = {
  58. .probe_new = pcm512x_i2c_probe,
  59. .remove = pcm512x_i2c_remove,
  60. .id_table = pcm512x_i2c_id,
  61. .driver = {
  62. .name = "pcm512x",
  63. .of_match_table = of_match_ptr(pcm512x_of_match),
  64. .acpi_match_table = ACPI_PTR(pcm512x_acpi_match),
  65. .pm = &pcm512x_pm_ops,
  66. },
  67. };
  68. module_i2c_driver(pcm512x_i2c_driver);
  69. MODULE_DESCRIPTION("ASoC PCM512x codec driver - I2C");
  70. MODULE_AUTHOR("Mark Brown <[email protected]>");
  71. MODULE_LICENSE("GPL v2");