adau1781-i2c.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Driver for ADAU1381/ADAU1781 CODEC
  4. *
  5. * Copyright 2014 Analog Devices Inc.
  6. * Author: Lars-Peter Clausen <lars@metafoo.de>
  7. */
  8. #include <linux/i2c.h>
  9. #include <linux/mod_devicetable.h>
  10. #include <linux/module.h>
  11. #include <linux/regmap.h>
  12. #include <sound/soc.h>
  13. #include "adau1781.h"
  14. static int adau1781_i2c_probe(struct i2c_client *client,
  15. const struct i2c_device_id *id)
  16. {
  17. struct regmap_config config;
  18. config = adau1781_regmap_config;
  19. config.val_bits = 8;
  20. config.reg_bits = 16;
  21. return adau1781_probe(&client->dev,
  22. devm_regmap_init_i2c(client, &config),
  23. id->driver_data, NULL);
  24. }
  25. static int adau1781_i2c_remove(struct i2c_client *client)
  26. {
  27. adau17x1_remove(&client->dev);
  28. return 0;
  29. }
  30. static const struct i2c_device_id adau1781_i2c_ids[] = {
  31. { "adau1381", ADAU1381 },
  32. { "adau1781", ADAU1781 },
  33. { }
  34. };
  35. MODULE_DEVICE_TABLE(i2c, adau1781_i2c_ids);
  36. #if defined(CONFIG_OF)
  37. static const struct of_device_id adau1781_i2c_dt_ids[] = {
  38. { .compatible = "adi,adau1381", },
  39. { .compatible = "adi,adau1781", },
  40. { },
  41. };
  42. MODULE_DEVICE_TABLE(of, adau1781_i2c_dt_ids);
  43. #endif
  44. static struct i2c_driver adau1781_i2c_driver = {
  45. .driver = {
  46. .name = "adau1781",
  47. .of_match_table = of_match_ptr(adau1781_i2c_dt_ids),
  48. },
  49. .probe = adau1781_i2c_probe,
  50. .remove = adau1781_i2c_remove,
  51. .id_table = adau1781_i2c_ids,
  52. };
  53. module_i2c_driver(adau1781_i2c_driver);
  54. MODULE_DESCRIPTION("ASoC ADAU1381/ADAU1781 CODEC I2C driver");
  55. MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
  56. MODULE_LICENSE("GPL");