WIP FPC-III support
[linux/fpc-iii.git] / drivers / base / regmap / regmap-ac97.c
blobb9f76bdf74a91dded92565e410ef919cacc9f79c
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.
7 #include <linux/clk.h>
8 #include <linux/err.h>
9 #include <linux/init.h>
10 #include <linux/io.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)
19 switch (reg) {
20 case AC97_RESET:
21 case AC97_POWERDOWN:
22 case AC97_INT_PAGING:
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:
28 case AC97_MISC_AFE:
29 case AC97_VENDOR_ID1:
30 case AC97_VENDOR_ID2:
31 case AC97_CODEC_CLASS_REV:
32 case AC97_PCI_SVID:
33 case AC97_PCI_SID:
34 case AC97_FUNC_SELECT:
35 case AC97_FUNC_INFO:
36 case AC97_SENSE_INFO:
37 return true;
38 default:
39 return false;
42 EXPORT_SYMBOL_GPL(regmap_ac97_default_volatile);
44 static int regmap_ac97_reg_read(void *context, unsigned int reg,
45 unsigned int *val)
47 struct snd_ac97 *ac97 = context;
49 *val = ac97->bus->ops->read(ac97, reg);
51 return 0;
54 static int regmap_ac97_reg_write(void *context, unsigned int reg,
55 unsigned int val)
57 struct snd_ac97 *ac97 = context;
59 ac97->bus->ops->write(ac97, reg, val);
61 return 0;
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,
75 lock_key, lock_name);
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,
85 lock_key, lock_name);
87 EXPORT_SYMBOL_GPL(__devm_regmap_init_ac97);
89 MODULE_LICENSE("GPL v2");