regmap-ac97.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // Register map access API - AC'97 support
  4. //
  5. // Copyright 2013 Linaro Ltd. All rights reserved.
  6. #include <linux/clk.h>
  7. #include <linux/err.h>
  8. #include <linux/init.h>
  9. #include <linux/io.h>
  10. #include <linux/module.h>
  11. #include <linux/regmap.h>
  12. #include <linux/slab.h>
  13. #include <sound/ac97_codec.h>
  14. bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg)
  15. {
  16. switch (reg) {
  17. case AC97_RESET:
  18. case AC97_POWERDOWN:
  19. case AC97_INT_PAGING:
  20. case AC97_EXTENDED_ID:
  21. case AC97_EXTENDED_STATUS:
  22. case AC97_EXTENDED_MID:
  23. case AC97_EXTENDED_MSTATUS:
  24. case AC97_GPIO_STATUS:
  25. case AC97_MISC_AFE:
  26. case AC97_VENDOR_ID1:
  27. case AC97_VENDOR_ID2:
  28. case AC97_CODEC_CLASS_REV:
  29. case AC97_PCI_SVID:
  30. case AC97_PCI_SID:
  31. case AC97_FUNC_SELECT:
  32. case AC97_FUNC_INFO:
  33. case AC97_SENSE_INFO:
  34. return true;
  35. default:
  36. return false;
  37. }
  38. }
  39. EXPORT_SYMBOL_GPL(regmap_ac97_default_volatile);
  40. static int regmap_ac97_reg_read(void *context, unsigned int reg,
  41. unsigned int *val)
  42. {
  43. struct snd_ac97 *ac97 = context;
  44. *val = ac97->bus->ops->read(ac97, reg);
  45. return 0;
  46. }
  47. static int regmap_ac97_reg_write(void *context, unsigned int reg,
  48. unsigned int val)
  49. {
  50. struct snd_ac97 *ac97 = context;
  51. ac97->bus->ops->write(ac97, reg, val);
  52. return 0;
  53. }
  54. static const struct regmap_bus ac97_regmap_bus = {
  55. .reg_write = regmap_ac97_reg_write,
  56. .reg_read = regmap_ac97_reg_read,
  57. };
  58. struct regmap *__regmap_init_ac97(struct snd_ac97 *ac97,
  59. const struct regmap_config *config,
  60. struct lock_class_key *lock_key,
  61. const char *lock_name)
  62. {
  63. return __regmap_init(&ac97->dev, &ac97_regmap_bus, ac97, config,
  64. lock_key, lock_name);
  65. }
  66. EXPORT_SYMBOL_GPL(__regmap_init_ac97);
  67. struct regmap *__devm_regmap_init_ac97(struct snd_ac97 *ac97,
  68. const struct regmap_config *config,
  69. struct lock_class_key *lock_key,
  70. const char *lock_name)
  71. {
  72. return __devm_regmap_init(&ac97->dev, &ac97_regmap_bus, ac97, config,
  73. lock_key, lock_name);
  74. }
  75. EXPORT_SYMBOL_GPL(__devm_regmap_init_ac97);
  76. MODULE_LICENSE("GPL v2");