cs35l41_hda_spi.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 <tanureal@opensource.cirrus.com>
  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_get_chipselect(spi, 0), spi->irq,
  24. devm_regmap_init_spi(spi, &cs35l41_regmap_spi), 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. MODULE_DEVICE_TABLE(spi, cs35l41_hda_spi_id);
  35. static const struct acpi_device_id cs35l41_acpi_hda_match[] = {
  36. { "CSC3551", 0 },
  37. {}
  38. };
  39. MODULE_DEVICE_TABLE(acpi, cs35l41_acpi_hda_match);
  40. static struct spi_driver cs35l41_spi_driver = {
  41. .driver = {
  42. .name = "cs35l41-hda",
  43. .acpi_match_table = cs35l41_acpi_hda_match,
  44. .pm = &cs35l41_hda_pm_ops,
  45. },
  46. .id_table = cs35l41_hda_spi_id,
  47. .probe = cs35l41_hda_spi_probe,
  48. .remove = cs35l41_hda_spi_remove,
  49. };
  50. module_spi_driver(cs35l41_spi_driver);
  51. MODULE_DESCRIPTION("HDA CS35L41 driver");
  52. MODULE_IMPORT_NS("SND_HDA_SCODEC_CS35L41");
  53. MODULE_AUTHOR("Lucas Tanure <tanureal@opensource.cirrus.com>");
  54. MODULE_LICENSE("GPL");