cs42xx8-i2c.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Cirrus Logic CS42448/CS42888 Audio CODEC DAI I2C driver
  3. *
  4. * Copyright (C) 2014 Freescale Semiconductor, Inc.
  5. *
  6. * Author: Nicolin Chen <Guangyu.Chen@freescale.com>
  7. *
  8. * This file is licensed under the terms of the GNU General Public License
  9. * version 2. This program is licensed "as is" without any warranty of any
  10. * kind, whether express or implied.
  11. */
  12. #include <linux/i2c.h>
  13. #include <linux/module.h>
  14. #include <linux/pm_runtime.h>
  15. #include <sound/soc.h>
  16. #include "cs42xx8.h"
  17. static int cs42xx8_i2c_probe(struct i2c_client *i2c,
  18. const struct i2c_device_id *id)
  19. {
  20. int ret = cs42xx8_probe(&i2c->dev,
  21. devm_regmap_init_i2c(i2c, &cs42xx8_regmap_config));
  22. if (ret)
  23. return ret;
  24. pm_runtime_enable(&i2c->dev);
  25. pm_request_idle(&i2c->dev);
  26. return 0;
  27. }
  28. static int cs42xx8_i2c_remove(struct i2c_client *i2c)
  29. {
  30. snd_soc_unregister_codec(&i2c->dev);
  31. pm_runtime_disable(&i2c->dev);
  32. return 0;
  33. }
  34. static struct i2c_device_id cs42xx8_i2c_id[] = {
  35. {"cs42448", (kernel_ulong_t)&cs42448_data},
  36. {"cs42888", (kernel_ulong_t)&cs42888_data},
  37. {}
  38. };
  39. MODULE_DEVICE_TABLE(i2c, cs42xx8_i2c_id);
  40. static struct i2c_driver cs42xx8_i2c_driver = {
  41. .driver = {
  42. .name = "cs42xx8",
  43. .pm = &cs42xx8_pm,
  44. .of_match_table = cs42xx8_of_match,
  45. },
  46. .probe = cs42xx8_i2c_probe,
  47. .remove = cs42xx8_i2c_remove,
  48. .id_table = cs42xx8_i2c_id,
  49. };
  50. module_i2c_driver(cs42xx8_i2c_driver);
  51. MODULE_DESCRIPTION("Cirrus Logic CS42448/CS42888 ALSA SoC Codec I2C Driver");
  52. MODULE_AUTHOR("Freescale Semiconductor, Inc.");
  53. MODULE_LICENSE("GPL");