tlv320aic32x4-spi.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* SPDX-License-Identifier: GPL-2.0
  2. *
  3. * Copyright 2011-2019 NW Digital Radio
  4. *
  5. * Author: Annaliese McDermond <nh6z@nh6z.net>
  6. *
  7. * Based on sound/soc/codecs/wm8974 and TI driver for kernel 2.6.27.
  8. *
  9. */
  10. #include <linux/spi/spi.h>
  11. #include <linux/module.h>
  12. #include <linux/of.h>
  13. #include <linux/regmap.h>
  14. #include <sound/soc.h>
  15. #include "tlv320aic32x4.h"
  16. static int aic32x4_spi_probe(struct spi_device *spi)
  17. {
  18. struct regmap *regmap;
  19. struct regmap_config config;
  20. config = aic32x4_regmap_config;
  21. config.reg_bits = 7;
  22. config.pad_bits = 1;
  23. config.val_bits = 8;
  24. config.read_flag_mask = 0x01;
  25. regmap = devm_regmap_init_spi(spi, &config);
  26. return aic32x4_probe(&spi->dev, regmap);
  27. }
  28. static int aic32x4_spi_remove(struct spi_device *spi)
  29. {
  30. return aic32x4_remove(&spi->dev);
  31. }
  32. static const struct spi_device_id aic32x4_spi_id[] = {
  33. { "tlv320aic32x4", 0 },
  34. { "tlv320aic32x6", 1 },
  35. { /* sentinel */ }
  36. };
  37. MODULE_DEVICE_TABLE(spi, aic32x4_spi_id);
  38. static const struct of_device_id aic32x4_of_id[] = {
  39. { .compatible = "ti,tlv320aic32x4", },
  40. { .compatible = "ti,tlv320aic32x6", },
  41. { /* senitel */ }
  42. };
  43. MODULE_DEVICE_TABLE(of, aic32x4_of_id);
  44. static struct spi_driver aic32x4_spi_driver = {
  45. .driver = {
  46. .name = "tlv320aic32x4",
  47. .owner = THIS_MODULE,
  48. .of_match_table = aic32x4_of_id,
  49. },
  50. .probe = aic32x4_spi_probe,
  51. .remove = aic32x4_spi_remove,
  52. .id_table = aic32x4_spi_id,
  53. };
  54. module_spi_driver(aic32x4_spi_driver);
  55. MODULE_DESCRIPTION("ASoC TLV320AIC32x4 codec driver SPI");
  56. MODULE_AUTHOR("Annaliese McDermond <nh6z@nh6z.net>");
  57. MODULE_LICENSE("GPL");