pcm512x-i2c.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Driver for the PCM512x CODECs
  3. *
  4. * Author: Mark Brown <broonie@linaro.org>
  5. * Copyright 2014 Linaro Ltd
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * version 2 as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. */
  16. #include <linux/init.h>
  17. #include <linux/module.h>
  18. #include <linux/i2c.h>
  19. #include "pcm512x.h"
  20. static int pcm512x_i2c_probe(struct i2c_client *i2c,
  21. const struct i2c_device_id *id)
  22. {
  23. struct regmap *regmap;
  24. struct regmap_config config = pcm512x_regmap;
  25. /* msb needs to be set to enable auto-increment of addresses */
  26. config.read_flag_mask = 0x80;
  27. config.write_flag_mask = 0x80;
  28. regmap = devm_regmap_init_i2c(i2c, &config);
  29. if (IS_ERR(regmap))
  30. return PTR_ERR(regmap);
  31. return pcm512x_probe(&i2c->dev, regmap);
  32. }
  33. static int pcm512x_i2c_remove(struct i2c_client *i2c)
  34. {
  35. pcm512x_remove(&i2c->dev);
  36. return 0;
  37. }
  38. static const struct i2c_device_id pcm512x_i2c_id[] = {
  39. { "pcm5121", },
  40. { "pcm5122", },
  41. { }
  42. };
  43. MODULE_DEVICE_TABLE(i2c, pcm512x_i2c_id);
  44. static const struct of_device_id pcm512x_of_match[] = {
  45. { .compatible = "ti,pcm5121", },
  46. { .compatible = "ti,pcm5122", },
  47. { }
  48. };
  49. MODULE_DEVICE_TABLE(of, pcm512x_of_match);
  50. static struct i2c_driver pcm512x_i2c_driver = {
  51. .probe = pcm512x_i2c_probe,
  52. .remove = pcm512x_i2c_remove,
  53. .id_table = pcm512x_i2c_id,
  54. .driver = {
  55. .name = "pcm512x",
  56. .owner = THIS_MODULE,
  57. .of_match_table = pcm512x_of_match,
  58. .pm = &pcm512x_pm_ops,
  59. },
  60. };
  61. module_i2c_driver(pcm512x_i2c_driver);
  62. MODULE_DESCRIPTION("ASoC PCM512x codec driver - I2C");
  63. MODULE_AUTHOR("Mark Brown <broonie@linaro.org>");
  64. MODULE_LICENSE("GPL v2");