pcm179x-spi.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * PCM179X ASoC SPI driver
  4. *
  5. * Copyright (c) Amarula Solutions B.V. 2013
  6. *
  7. * Michael Trimarchi <michael@amarulasolutions.com>
  8. */
  9. #include <linux/module.h>
  10. #include <linux/of.h>
  11. #include <linux/spi/spi.h>
  12. #include <linux/regmap.h>
  13. #include "pcm179x.h"
  14. static int pcm179x_spi_probe(struct spi_device *spi)
  15. {
  16. struct regmap *regmap;
  17. int ret;
  18. regmap = devm_regmap_init_spi(spi, &pcm179x_regmap_config);
  19. if (IS_ERR(regmap)) {
  20. ret = PTR_ERR(regmap);
  21. dev_err(&spi->dev, "Failed to allocate regmap: %d\n", ret);
  22. return ret;
  23. }
  24. return pcm179x_common_init(&spi->dev, regmap);
  25. }
  26. static const struct of_device_id pcm179x_of_match[] = {
  27. { .compatible = "ti,pcm1792a", },
  28. { }
  29. };
  30. MODULE_DEVICE_TABLE(of, pcm179x_of_match);
  31. static const struct spi_device_id pcm179x_spi_ids[] = {
  32. { "pcm179x", 0 },
  33. { },
  34. };
  35. MODULE_DEVICE_TABLE(spi, pcm179x_spi_ids);
  36. static struct spi_driver pcm179x_spi_driver = {
  37. .driver = {
  38. .name = "pcm179x",
  39. .of_match_table = of_match_ptr(pcm179x_of_match),
  40. },
  41. .id_table = pcm179x_spi_ids,
  42. .probe = pcm179x_spi_probe,
  43. };
  44. module_spi_driver(pcm179x_spi_driver);
  45. MODULE_DESCRIPTION("ASoC PCM179X SPI driver");
  46. MODULE_AUTHOR("Michael Trimarchi <michael@amarulasolutions.com>");
  47. MODULE_LICENSE("GPL");