pcm512x-spi.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. { },
  40. };
  41. MODULE_DEVICE_TABLE(spi, pcm512x_spi_id);
  42. static const struct of_device_id pcm512x_of_match[] = {
  43. { .compatible = "ti,pcm5121", },
  44. { .compatible = "ti,pcm5122", },
  45. { }
  46. };
  47. MODULE_DEVICE_TABLE(of, pcm512x_of_match);
  48. static struct spi_driver pcm512x_spi_driver = {
  49. .probe = pcm512x_spi_probe,
  50. .remove = pcm512x_spi_remove,
  51. .id_table = pcm512x_spi_id,
  52. .driver = {
  53. .name = "pcm512x",
  54. .owner = THIS_MODULE,
  55. .of_match_table = pcm512x_of_match,
  56. .pm = &pcm512x_pm_ops,
  57. },
  58. };
  59. module_spi_driver(pcm512x_spi_driver);