tlv320aic3x-spi.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* SPDX-License-Identifier: GPL-2.0
  2. *
  3. * ALSA SoC TLV320AIC3x codec driver SPI interface
  4. *
  5. * Author: Arun KS, <[email protected]>
  6. * Copyright: (C) 2008 Mistral Solutions Pvt Ltd.,
  7. *
  8. * Based on sound/soc/codecs/wm8731.c by Richard Purdie
  9. *
  10. */
  11. #include <linux/spi/spi.h>
  12. #include <linux/module.h>
  13. #include <linux/of.h>
  14. #include <linux/regmap.h>
  15. #include <sound/soc.h>
  16. #include "tlv320aic3x.h"
  17. static int aic3x_spi_probe(struct spi_device *spi)
  18. {
  19. struct regmap *regmap;
  20. struct regmap_config config;
  21. const struct spi_device_id *id = spi_get_device_id(spi);
  22. config = aic3x_regmap;
  23. config.reg_bits = 7;
  24. config.pad_bits = 1;
  25. config.val_bits = 8;
  26. config.read_flag_mask = 0x01;
  27. dev_dbg(&spi->dev, "probing tlv320aic3x spi device\n");
  28. regmap = devm_regmap_init_spi(spi, &config);
  29. return aic3x_probe(&spi->dev, regmap, id->driver_data);
  30. }
  31. static void aic3x_spi_remove(struct spi_device *spi)
  32. {
  33. aic3x_remove(&spi->dev);
  34. }
  35. static const struct spi_device_id aic3x_spi_id[] = {
  36. { "tlv320aic3x", AIC3X_MODEL_3X },
  37. { "tlv320aic33", AIC3X_MODEL_33 },
  38. { "tlv320aic3007", AIC3X_MODEL_3007 },
  39. { "tlv320aic3104", AIC3X_MODEL_3104 },
  40. { "tlv320aic3106", AIC3X_MODEL_3106 },
  41. { }
  42. };
  43. MODULE_DEVICE_TABLE(spi, aic3x_spi_id);
  44. static const struct of_device_id aic3x_of_id[] = {
  45. { .compatible = "ti,tlv320aic3x", },
  46. { .compatible = "ti,tlv320aic33" },
  47. { .compatible = "ti,tlv320aic3007" },
  48. { .compatible = "ti,tlv320aic3104" },
  49. { .compatible = "ti,tlv320aic3106" },
  50. {},
  51. };
  52. MODULE_DEVICE_TABLE(of, aic3x_of_id);
  53. static struct spi_driver aic3x_spi_driver = {
  54. .driver = {
  55. .name = "tlv320aic3x",
  56. .owner = THIS_MODULE,
  57. .of_match_table = aic3x_of_id,
  58. },
  59. .probe = aic3x_spi_probe,
  60. .remove = aic3x_spi_remove,
  61. .id_table = aic3x_spi_id,
  62. };
  63. module_spi_driver(aic3x_spi_driver);
  64. MODULE_DESCRIPTION("ASoC TLV320AIC3x codec driver SPI");
  65. MODULE_AUTHOR("Arun KS <[email protected]>");
  66. MODULE_LICENSE("GPL");