ssm2602-i2c.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * SSM2602/SSM2603/SSM2604 I2C audio driver
  3. *
  4. * Copyright 2014 Analog Devices Inc.
  5. *
  6. * Licensed under the GPL-2.
  7. */
  8. #include <linux/module.h>
  9. #include <linux/i2c.h>
  10. #include <linux/regmap.h>
  11. #include <sound/soc.h>
  12. #include "ssm2602.h"
  13. /*
  14. * ssm2602 2 wire address is determined by GPIO5
  15. * state during powerup.
  16. * low = 0x1a
  17. * high = 0x1b
  18. */
  19. static int ssm2602_i2c_probe(struct i2c_client *client,
  20. const struct i2c_device_id *id)
  21. {
  22. return ssm2602_probe(&client->dev, id->driver_data,
  23. devm_regmap_init_i2c(client, &ssm2602_regmap_config));
  24. }
  25. static int ssm2602_i2c_remove(struct i2c_client *client)
  26. {
  27. snd_soc_unregister_codec(&client->dev);
  28. return 0;
  29. }
  30. static const struct i2c_device_id ssm2602_i2c_id[] = {
  31. { "ssm2602", SSM2602 },
  32. { "ssm2603", SSM2602 },
  33. { "ssm2604", SSM2604 },
  34. { }
  35. };
  36. MODULE_DEVICE_TABLE(i2c, ssm2602_i2c_id);
  37. static const struct of_device_id ssm2602_of_match[] = {
  38. { .compatible = "adi,ssm2602", },
  39. { .compatible = "adi,ssm2603", },
  40. { .compatible = "adi,ssm2604", },
  41. { }
  42. };
  43. MODULE_DEVICE_TABLE(of, ssm2602_of_match);
  44. static struct i2c_driver ssm2602_i2c_driver = {
  45. .driver = {
  46. .name = "ssm2602",
  47. .of_match_table = ssm2602_of_match,
  48. },
  49. .probe = ssm2602_i2c_probe,
  50. .remove = ssm2602_i2c_remove,
  51. .id_table = ssm2602_i2c_id,
  52. };
  53. module_i2c_driver(ssm2602_i2c_driver);
  54. MODULE_DESCRIPTION("ASoC SSM2602/SSM2603/SSM2604 I2C driver");
  55. MODULE_AUTHOR("Cliff Cai");
  56. MODULE_LICENSE("GPL");