pcm512x-spi.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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/spi/spi.h>
  19. #include "pcm512x.h"
  20. static int pcm512x_spi_probe(struct spi_device *spi)
  21. {
  22. struct regmap *regmap;
  23. int ret;
  24. regmap = devm_regmap_init_spi(spi, &pcm512x_regmap);
  25. if (IS_ERR(regmap)) {
  26. ret = PTR_ERR(regmap);
  27. return ret;
  28. }
  29. return pcm512x_probe(&spi->dev, regmap);
  30. }
  31. static int pcm512x_spi_remove(struct spi_device *spi)
  32. {
  33. pcm512x_remove(&spi->dev);
  34. return 0;
  35. }
  36. static const struct spi_device_id pcm512x_spi_id[] = {
  37. { "pcm5121", },
  38. { "pcm5122", },
  39. { "pcm5141", },
  40. { "pcm5142", },
  41. { },
  42. };
  43. MODULE_DEVICE_TABLE(spi, pcm512x_spi_id);
  44. static const struct of_device_id pcm512x_of_match[] = {
  45. { .compatible = "ti,pcm5121", },
  46. { .compatible = "ti,pcm5122", },
  47. { .compatible = "ti,pcm5141", },
  48. { .compatible = "ti,pcm5142", },
  49. { }
  50. };
  51. MODULE_DEVICE_TABLE(of, pcm512x_of_match);
  52. static struct spi_driver pcm512x_spi_driver = {
  53. .probe = pcm512x_spi_probe,
  54. .remove = pcm512x_spi_remove,
  55. .id_table = pcm512x_spi_id,
  56. .driver = {
  57. .name = "pcm512x",
  58. .of_match_table = pcm512x_of_match,
  59. .pm = &pcm512x_pm_ops,
  60. },
  61. };
  62. module_spi_driver(pcm512x_spi_driver);
  63. MODULE_DESCRIPTION("ASoC PCM512x codec driver - SPI");
  64. MODULE_AUTHOR("Mark Brown <broonie@kernel.org>");
  65. MODULE_LICENSE("GPL v2");