cs35l41_hda_spi.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // CS35l41 HDA SPI driver
  4. //
  5. // Copyright 2021 Cirrus Logic, Inc.
  6. //
  7. // Author: Lucas Tanure <[email protected]>
  8. #include <linux/mod_devicetable.h>
  9. #include <linux/module.h>
  10. #include <linux/spi/spi.h>
  11. #include "cs35l41_hda.h"
  12. static int cs35l41_hda_spi_probe(struct spi_device *spi)
  13. {
  14. const char *device_name;
  15. /*
  16. * Compare against the device name so it works for SPI, normal ACPI
  17. * and for ACPI by serial-multi-instantiate matching cases.
  18. */
  19. if (strstr(dev_name(&spi->dev), "CSC3551"))
  20. device_name = "CSC3551";
  21. else
  22. return -ENODEV;
  23. return cs35l41_hda_probe(&spi->dev, device_name, spi->chip_select, spi->irq,
  24. devm_regmap_init_spi(spi, &cs35l41_regmap_spi));
  25. }
  26. static void cs35l41_hda_spi_remove(struct spi_device *spi)
  27. {
  28. cs35l41_hda_remove(&spi->dev);
  29. }
  30. static const struct spi_device_id cs35l41_hda_spi_id[] = {
  31. { "cs35l41-hda", 0 },
  32. {}
  33. };
  34. static const struct acpi_device_id cs35l41_acpi_hda_match[] = {
  35. { "CSC3551", 0 },
  36. {}
  37. };
  38. MODULE_DEVICE_TABLE(acpi, cs35l41_acpi_hda_match);
  39. static struct spi_driver cs35l41_spi_driver = {
  40. .driver = {
  41. .name = "cs35l41-hda",
  42. .acpi_match_table = cs35l41_acpi_hda_match,
  43. .pm = &cs35l41_hda_pm_ops,
  44. },
  45. .id_table = cs35l41_hda_spi_id,
  46. .probe = cs35l41_hda_spi_probe,
  47. .remove = cs35l41_hda_spi_remove,
  48. };
  49. module_spi_driver(cs35l41_spi_driver);
  50. MODULE_DESCRIPTION("HDA CS35L41 driver");
  51. MODULE_IMPORT_NS(SND_HDA_SCODEC_CS35L41);
  52. MODULE_AUTHOR("Lucas Tanure <[email protected]>");
  53. MODULE_LICENSE("GPL");