wm8731-i2c.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * wm8731-i2c.c -- WM8731 ALSA SoC Audio driver I2C code
  4. *
  5. * Copyright 2005 Openedhand Ltd.
  6. * Copyright 2006-12 Wolfson Microelectronics, plc
  7. *
  8. * Author: Richard Purdie <[email protected]>
  9. *
  10. * Based on wm8753.c by Liam Girdwood
  11. */
  12. #include <linux/i2c.h>
  13. #include <linux/module.h>
  14. #include <linux/of_device.h>
  15. #include "wm8731.h"
  16. static const struct of_device_id wm8731_of_match[] = {
  17. { .compatible = "wlf,wm8731", },
  18. { }
  19. };
  20. MODULE_DEVICE_TABLE(of, wm8731_of_match);
  21. static int wm8731_i2c_probe(struct i2c_client *i2c)
  22. {
  23. struct wm8731_priv *wm8731;
  24. int ret;
  25. wm8731 = devm_kzalloc(&i2c->dev, sizeof(struct wm8731_priv),
  26. GFP_KERNEL);
  27. if (wm8731 == NULL)
  28. return -ENOMEM;
  29. i2c_set_clientdata(i2c, wm8731);
  30. wm8731->regmap = devm_regmap_init_i2c(i2c, &wm8731_regmap);
  31. if (IS_ERR(wm8731->regmap)) {
  32. ret = PTR_ERR(wm8731->regmap);
  33. dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
  34. ret);
  35. return ret;
  36. }
  37. return wm8731_init(&i2c->dev, wm8731);
  38. }
  39. static const struct i2c_device_id wm8731_i2c_id[] = {
  40. { "wm8731", 0 },
  41. { }
  42. };
  43. MODULE_DEVICE_TABLE(i2c, wm8731_i2c_id);
  44. static struct i2c_driver wm8731_i2c_driver = {
  45. .driver = {
  46. .name = "wm8731",
  47. .of_match_table = wm8731_of_match,
  48. },
  49. .probe_new = wm8731_i2c_probe,
  50. .id_table = wm8731_i2c_id,
  51. };
  52. module_i2c_driver(wm8731_i2c_driver);
  53. MODULE_DESCRIPTION("ASoC WM8731 driver - I2C");
  54. MODULE_AUTHOR("Richard Purdie");
  55. MODULE_LICENSE("GPL");