pcm3060-spi.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // PCM3060 SPI driver
  4. //
  5. // Copyright (C) 2018 Kirill Marinushkin <[email protected]>
  6. #include <linux/module.h>
  7. #include <linux/spi/spi.h>
  8. #include <sound/soc.h>
  9. #include "pcm3060.h"
  10. static int pcm3060_spi_probe(struct spi_device *spi)
  11. {
  12. struct pcm3060_priv *priv;
  13. priv = devm_kzalloc(&spi->dev, sizeof(*priv), GFP_KERNEL);
  14. if (!priv)
  15. return -ENOMEM;
  16. spi_set_drvdata(spi, priv);
  17. priv->regmap = devm_regmap_init_spi(spi, &pcm3060_regmap);
  18. if (IS_ERR(priv->regmap))
  19. return PTR_ERR(priv->regmap);
  20. return pcm3060_probe(&spi->dev);
  21. }
  22. static const struct spi_device_id pcm3060_spi_id[] = {
  23. { .name = "pcm3060" },
  24. { },
  25. };
  26. MODULE_DEVICE_TABLE(spi, pcm3060_spi_id);
  27. #ifdef CONFIG_OF
  28. static const struct of_device_id pcm3060_of_match[] = {
  29. { .compatible = "ti,pcm3060" },
  30. { },
  31. };
  32. MODULE_DEVICE_TABLE(of, pcm3060_of_match);
  33. #endif /* CONFIG_OF */
  34. static struct spi_driver pcm3060_spi_driver = {
  35. .driver = {
  36. .name = "pcm3060",
  37. #ifdef CONFIG_OF
  38. .of_match_table = pcm3060_of_match,
  39. #endif /* CONFIG_OF */
  40. },
  41. .id_table = pcm3060_spi_id,
  42. .probe = pcm3060_spi_probe,
  43. };
  44. module_spi_driver(pcm3060_spi_driver);
  45. MODULE_DESCRIPTION("PCM3060 SPI driver");
  46. MODULE_AUTHOR("Kirill Marinushkin <[email protected]>");
  47. MODULE_LICENSE("GPL v2");