cs35l41_hda_i2c.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // CS35l41 HDA I2C 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/i2c.h>
  11. #include "cs35l41_hda.h"
  12. static int cs35l41_hda_i2c_probe(struct i2c_client *clt, const struct i2c_device_id *id)
  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(&clt->dev), "CLSA0100"))
  20. device_name = "CLSA0100";
  21. else if (strstr(dev_name(&clt->dev), "CLSA0101"))
  22. device_name = "CLSA0101";
  23. else if (strstr(dev_name(&clt->dev), "CSC3551"))
  24. device_name = "CSC3551";
  25. else
  26. return -ENODEV;
  27. return cs35l41_hda_probe(&clt->dev, device_name, clt->addr, clt->irq,
  28. devm_regmap_init_i2c(clt, &cs35l41_regmap_i2c));
  29. }
  30. static void cs35l41_hda_i2c_remove(struct i2c_client *clt)
  31. {
  32. cs35l41_hda_remove(&clt->dev);
  33. }
  34. static const struct i2c_device_id cs35l41_hda_i2c_id[] = {
  35. { "cs35l41-hda", 0 },
  36. {}
  37. };
  38. static const struct acpi_device_id cs35l41_acpi_hda_match[] = {
  39. {"CLSA0100", 0 },
  40. {"CLSA0101", 0 },
  41. {"CSC3551", 0 },
  42. {}
  43. };
  44. MODULE_DEVICE_TABLE(acpi, cs35l41_acpi_hda_match);
  45. static struct i2c_driver cs35l41_i2c_driver = {
  46. .driver = {
  47. .name = "cs35l41-hda",
  48. .acpi_match_table = cs35l41_acpi_hda_match,
  49. .pm = &cs35l41_hda_pm_ops,
  50. },
  51. .id_table = cs35l41_hda_i2c_id,
  52. .probe = cs35l41_hda_i2c_probe,
  53. .remove = cs35l41_hda_i2c_remove,
  54. };
  55. module_i2c_driver(cs35l41_i2c_driver);
  56. MODULE_DESCRIPTION("HDA CS35L41 driver");
  57. MODULE_IMPORT_NS(SND_HDA_SCODEC_CS35L41);
  58. MODULE_AUTHOR("Lucas Tanure <[email protected]>");
  59. MODULE_LICENSE("GPL");