pcm179x-i2c.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 <[email protected]>
  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. {
  16. struct regmap *regmap;
  17. int ret;
  18. regmap = devm_regmap_init_i2c(client, &pcm179x_regmap_config);
  19. if (IS_ERR(regmap)) {
  20. ret = PTR_ERR(regmap);
  21. dev_err(&client->dev, "Failed to allocate regmap: %d\n", ret);
  22. return ret;
  23. }
  24. return pcm179x_common_init(&client->dev, regmap);
  25. }
  26. #ifdef CONFIG_OF
  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. #endif
  33. static const struct i2c_device_id pcm179x_i2c_ids[] = {
  34. { "pcm179x", 0 },
  35. { }
  36. };
  37. MODULE_DEVICE_TABLE(i2c, pcm179x_i2c_ids);
  38. static struct i2c_driver pcm179x_i2c_driver = {
  39. .driver = {
  40. .name = "pcm179x",
  41. .of_match_table = of_match_ptr(pcm179x_of_match),
  42. },
  43. .id_table = pcm179x_i2c_ids,
  44. .probe_new = pcm179x_i2c_probe,
  45. };
  46. module_i2c_driver(pcm179x_i2c_driver);
  47. MODULE_DESCRIPTION("ASoC PCM179X I2C driver");
  48. MODULE_AUTHOR("Jacob Siverskog <[email protected]>");
  49. MODULE_LICENSE("GPL");