pcm179x-i2c.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * PCM179X ASoC I2C driver
  4. *
  5. * Copyright (c) Teenage Engineering AB 2016
  6. *
  7. * Jacob Siverskog <jacob@teenage.engineering>
  8. */
  9. #include <linux/module.h>
  10. #include <linux/of.h>
  11. #include <linux/i2c.h>
  12. #include <linux/regmap.h>
  13. #include "pcm179x.h"
  14. static int pcm179x_i2c_probe(struct i2c_client *client,
  15. const struct i2c_device_id *id)
  16. {
  17. struct regmap *regmap;
  18. int ret;
  19. regmap = devm_regmap_init_i2c(client, &pcm179x_regmap_config);
  20. if (IS_ERR(regmap)) {
  21. ret = PTR_ERR(regmap);
  22. dev_err(&client->dev, "Failed to allocate regmap: %d\n", ret);
  23. return ret;
  24. }
  25. return pcm179x_common_init(&client->dev, regmap);
  26. }
  27. static const struct of_device_id pcm179x_of_match[] = {
  28. { .compatible = "ti,pcm1792a", },
  29. { }
  30. };
  31. MODULE_DEVICE_TABLE(of, pcm179x_of_match);
  32. static const struct i2c_device_id pcm179x_i2c_ids[] = {
  33. { "pcm179x", 0 },
  34. { }
  35. };
  36. MODULE_DEVICE_TABLE(i2c, pcm179x_i2c_ids);
  37. static struct i2c_driver pcm179x_i2c_driver = {
  38. .driver = {
  39. .name = "pcm179x",
  40. .of_match_table = of_match_ptr(pcm179x_of_match),
  41. },
  42. .id_table = pcm179x_i2c_ids,
  43. .probe = pcm179x_i2c_probe,
  44. };
  45. module_i2c_driver(pcm179x_i2c_driver);
  46. MODULE_DESCRIPTION("ASoC PCM179X I2C driver");
  47. MODULE_AUTHOR("Jacob Siverskog <jacob@teenage.engineering>");
  48. MODULE_LICENSE("GPL");