2 * Register map access API - AC'97 support
4 * Copyright 2013 Linaro Ltd. All rights reserved.
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.
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
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/>.
19 #include <linux/clk.h>
20 #include <linux/err.h>
21 #include <linux/init.h>
23 #include <linux/module.h>
24 #include <linux/regmap.h>
25 #include <linux/slab.h>
27 #include <sound/ac97_codec.h>
29 bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg)
35 case AC97_EXTENDED_ID:
36 case AC97_EXTENDED_STATUS:
37 case AC97_EXTENDED_MID:
38 case AC97_EXTENDED_MSTATUS:
39 case AC97_GPIO_STATUS:
43 case AC97_CODEC_CLASS_REV:
46 case AC97_FUNC_SELECT:
54 EXPORT_SYMBOL_GPL(regmap_ac97_default_volatile);
56 static int regmap_ac97_reg_read(void *context, unsigned int reg,
59 struct snd_ac97 *ac97 = context;
61 *val = ac97->bus->ops->read(ac97, reg);
66 static int regmap_ac97_reg_write(void *context, unsigned int reg,
69 struct snd_ac97 *ac97 = context;
71 ac97->bus->ops->write(ac97, reg, val);
76 static const struct regmap_bus ac97_regmap_bus = {
77 .reg_write = regmap_ac97_reg_write,
78 .reg_read = regmap_ac97_reg_read,
82 * regmap_init_ac97(): Initialise AC'97 register map
84 * @ac97: Device that will be interacted with
85 * @config: Configuration for register map
87 * The return value will be an ERR_PTR() on error or a valid pointer to
90 struct regmap *regmap_init_ac97(struct snd_ac97 *ac97,
91 const struct regmap_config *config)
93 return regmap_init(&ac97->dev, &ac97_regmap_bus, ac97, config);
95 EXPORT_SYMBOL_GPL(regmap_init_ac97);
98 * devm_regmap_init_ac97(): Initialise AC'97 register map
100 * @ac97: Device that will be interacted with
101 * @config: Configuration for register map
103 * The return value will be an ERR_PTR() on error or a valid pointer
104 * to a struct regmap. The regmap will be automatically freed by the
105 * device management code.
107 struct regmap *devm_regmap_init_ac97(struct snd_ac97 *ac97,
108 const struct regmap_config *config)
110 return devm_regmap_init(&ac97->dev, &ac97_regmap_bus, ac97, config);
112 EXPORT_SYMBOL_GPL(devm_regmap_init_ac97);
114 MODULE_LICENSE("GPL v2");