1 // SPDX-License-Identifier: GPL-2.0
3 // Register map access API - AC'97 support
5 // Copyright 2013 Linaro Ltd. All rights reserved.
9 #include <linux/init.h>
11 #include <linux/module.h>
12 #include <linux/regmap.h>
13 #include <linux/slab.h>
15 #include <sound/ac97_codec.h>
17 bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg)
23 case AC97_EXTENDED_ID:
24 case AC97_EXTENDED_STATUS:
25 case AC97_EXTENDED_MID:
26 case AC97_EXTENDED_MSTATUS:
27 case AC97_GPIO_STATUS:
31 case AC97_CODEC_CLASS_REV:
34 case AC97_FUNC_SELECT:
42 EXPORT_SYMBOL_GPL(regmap_ac97_default_volatile);
44 static int regmap_ac97_reg_read(void *context, unsigned int reg,
47 struct snd_ac97 *ac97 = context;
49 *val = ac97->bus->ops->read(ac97, reg);
54 static int regmap_ac97_reg_write(void *context, unsigned int reg,
57 struct snd_ac97 *ac97 = context;
59 ac97->bus->ops->write(ac97, reg, val);
64 static const struct regmap_bus ac97_regmap_bus = {
65 .reg_write = regmap_ac97_reg_write,
66 .reg_read = regmap_ac97_reg_read,
69 struct regmap *__regmap_init_ac97(struct snd_ac97 *ac97,
70 const struct regmap_config *config,
71 struct lock_class_key *lock_key,
72 const char *lock_name)
74 return __regmap_init(&ac97->dev, &ac97_regmap_bus, ac97, config,
77 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)
84 return __devm_regmap_init(&ac97->dev, &ac97_regmap_bus, ac97, config,
87 EXPORT_SYMBOL_GPL(__devm_regmap_init_ac97);
89 MODULE_LICENSE("GPL v2");