pcm179x-spi.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * PCM179X ASoC SPI driver
  3. *
  4. * Copyright (c) Amarula Solutions B.V. 2013
  5. *
  6. * Michael Trimarchi <michael@amarulasolutions.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. */
  18. #include <linux/module.h>
  19. #include <linux/of.h>
  20. #include <linux/spi/spi.h>
  21. #include <linux/regmap.h>
  22. #include "pcm179x.h"
  23. static int pcm179x_spi_probe(struct spi_device *spi)
  24. {
  25. struct regmap *regmap;
  26. int ret;
  27. regmap = devm_regmap_init_spi(spi, &pcm179x_regmap_config);
  28. if (IS_ERR(regmap)) {
  29. ret = PTR_ERR(regmap);
  30. dev_err(&spi->dev, "Failed to allocate regmap: %d\n", ret);
  31. return ret;
  32. }
  33. return pcm179x_common_init(&spi->dev, regmap);
  34. }
  35. static int pcm179x_spi_remove(struct spi_device *spi)
  36. {
  37. return pcm179x_common_exit(&spi->dev);
  38. }
  39. static const struct of_device_id pcm179x_of_match[] = {
  40. { .compatible = "ti,pcm1792a", },
  41. { }
  42. };
  43. MODULE_DEVICE_TABLE(of, pcm179x_of_match);
  44. static const struct spi_device_id pcm179x_spi_ids[] = {
  45. { "pcm179x", 0 },
  46. { },
  47. };
  48. MODULE_DEVICE_TABLE(spi, pcm179x_spi_ids);
  49. static struct spi_driver pcm179x_spi_driver = {
  50. .driver = {
  51. .name = "pcm179x",
  52. .of_match_table = of_match_ptr(pcm179x_of_match),
  53. },
  54. .id_table = pcm179x_spi_ids,
  55. .probe = pcm179x_spi_probe,
  56. .remove = pcm179x_spi_remove,
  57. };
  58. module_spi_driver(pcm179x_spi_driver);
  59. MODULE_DESCRIPTION("ASoC PCM179X SPI driver");
  60. MODULE_AUTHOR("Michael Trimarchi <michael@amarulasolutions.com>");
  61. MODULE_LICENSE("GPL");