regmap-ac97.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Register map access API - AC'97 support
  3. *
  4. * Copyright 2013 Linaro Ltd. All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <linux/clk.h>
  19. #include <linux/err.h>
  20. #include <linux/init.h>
  21. #include <linux/io.h>
  22. #include <linux/module.h>
  23. #include <linux/regmap.h>
  24. #include <linux/slab.h>
  25. #include <sound/ac97_codec.h>
  26. bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg)
  27. {
  28. switch (reg) {
  29. case AC97_RESET:
  30. case AC97_POWERDOWN:
  31. case AC97_INT_PAGING:
  32. case AC97_EXTENDED_ID:
  33. case AC97_EXTENDED_STATUS:
  34. case AC97_EXTENDED_MID:
  35. case AC97_EXTENDED_MSTATUS:
  36. case AC97_GPIO_STATUS:
  37. case AC97_MISC_AFE:
  38. case AC97_VENDOR_ID1:
  39. case AC97_VENDOR_ID2:
  40. case AC97_CODEC_CLASS_REV:
  41. case AC97_PCI_SVID:
  42. case AC97_PCI_SID:
  43. case AC97_FUNC_SELECT:
  44. case AC97_FUNC_INFO:
  45. case AC97_SENSE_INFO:
  46. return true;
  47. default:
  48. return false;
  49. }
  50. }
  51. EXPORT_SYMBOL_GPL(regmap_ac97_default_volatile);
  52. static int regmap_ac97_reg_read(void *context, unsigned int reg,
  53. unsigned int *val)
  54. {
  55. struct snd_ac97 *ac97 = context;
  56. *val = ac97->bus->ops->read(ac97, reg);
  57. return 0;
  58. }
  59. static int regmap_ac97_reg_write(void *context, unsigned int reg,
  60. unsigned int val)
  61. {
  62. struct snd_ac97 *ac97 = context;
  63. ac97->bus->ops->write(ac97, reg, val);
  64. return 0;
  65. }
  66. static const struct regmap_bus ac97_regmap_bus = {
  67. .reg_write = regmap_ac97_reg_write,
  68. .reg_read = regmap_ac97_reg_read,
  69. };
  70. struct regmap *__regmap_init_ac97(struct snd_ac97 *ac97,
  71. const struct regmap_config *config,
  72. struct lock_class_key *lock_key,
  73. const char *lock_name)
  74. {
  75. return __regmap_init(&ac97->dev, &ac97_regmap_bus, ac97, config,
  76. lock_key, lock_name);
  77. }
  78. EXPORT_SYMBOL_GPL(__regmap_init_ac97);
  79. struct regmap *__devm_regmap_init_ac97(struct snd_ac97 *ac97,
  80. const struct regmap_config *config,
  81. struct lock_class_key *lock_key,
  82. const char *lock_name)
  83. {
  84. return __devm_regmap_init(&ac97->dev, &ac97_regmap_bus, ac97, config,
  85. lock_key, lock_name);
  86. }
  87. EXPORT_SYMBOL_GPL(__devm_regmap_init_ac97);
  88. MODULE_LICENSE("GPL v2");