tlv320aic32x4-spi.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * linux/sound/soc/codecs/tlv320aic32x4-spi.c
  3. *
  4. * Copyright 2011 NW Digital Radio
  5. *
  6. * Author: Jeremy McDermond <nh6z@nh6z.net>
  7. *
  8. * Based on sound/soc/codecs/wm8974 and TI driver for kernel 2.6.27.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. */
  20. #include <linux/spi/spi.h>
  21. #include <linux/module.h>
  22. #include <linux/of.h>
  23. #include <linux/regmap.h>
  24. #include <sound/soc.h>
  25. #include "tlv320aic32x4.h"
  26. static int aic32x4_spi_probe(struct spi_device *spi)
  27. {
  28. struct regmap *regmap;
  29. struct regmap_config config;
  30. config = aic32x4_regmap_config;
  31. config.reg_bits = 7;
  32. config.pad_bits = 1;
  33. config.val_bits = 8;
  34. config.read_flag_mask = 0x01;
  35. regmap = devm_regmap_init_spi(spi, &config);
  36. return aic32x4_probe(&spi->dev, regmap);
  37. }
  38. static int aic32x4_spi_remove(struct spi_device *spi)
  39. {
  40. return aic32x4_remove(&spi->dev);
  41. }
  42. static const struct spi_device_id aic32x4_spi_id[] = {
  43. { "tlv320aic32x4", 0 },
  44. { /* sentinel */ }
  45. };
  46. MODULE_DEVICE_TABLE(spi, aic32x4_spi_id);
  47. static const struct of_device_id aic32x4_of_id[] = {
  48. { .compatible = "ti,tlv320aic32x4", },
  49. { /* senitel */ }
  50. };
  51. MODULE_DEVICE_TABLE(of, aic32x4_of_id);
  52. static struct spi_driver aic32x4_spi_driver = {
  53. .driver = {
  54. .name = "tlv320aic32x4",
  55. .owner = THIS_MODULE,
  56. .of_match_table = aic32x4_of_id,
  57. },
  58. .probe = aic32x4_spi_probe,
  59. .remove = aic32x4_spi_remove,
  60. .id_table = aic32x4_spi_id,
  61. };
  62. module_spi_driver(aic32x4_spi_driver);
  63. MODULE_DESCRIPTION("ASoC TLV320AIC32x4 codec driver SPI");
  64. MODULE_AUTHOR("Jeremy McDermond <nh6z@nh6z.net>");
  65. MODULE_LICENSE("GPL");