wm8731-spi.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * wm8731.c -- WM8731 ALSA SoC Audio driver
  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/spi/spi.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_spi_probe(struct spi_device *spi)
  22. {
  23. struct wm8731_priv *wm8731;
  24. int ret;
  25. wm8731 = devm_kzalloc(&spi->dev, sizeof(*wm8731), GFP_KERNEL);
  26. if (wm8731 == NULL)
  27. return -ENOMEM;
  28. spi_set_drvdata(spi, wm8731);
  29. wm8731->regmap = devm_regmap_init_spi(spi, &wm8731_regmap);
  30. if (IS_ERR(wm8731->regmap)) {
  31. ret = PTR_ERR(wm8731->regmap);
  32. dev_err(&spi->dev, "Failed to allocate register map: %d\n",
  33. ret);
  34. return ret;
  35. }
  36. return wm8731_init(&spi->dev, wm8731);
  37. }
  38. static struct spi_driver wm8731_spi_driver = {
  39. .driver = {
  40. .name = "wm8731",
  41. .of_match_table = wm8731_of_match,
  42. },
  43. .probe = wm8731_spi_probe,
  44. };
  45. module_spi_driver(wm8731_spi_driver);
  46. MODULE_DESCRIPTION("ASoC WM8731 driver - SPI");
  47. MODULE_AUTHOR("Richard Purdie");
  48. MODULE_LICENSE("GPL");