Linux Audio

Check our new training course

Linux kernel drivers training

Mar 31-Apr 9, 2025, special US time zones
Register
Loading...
v6.8
 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
 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>
14
15#include <sound/ac97_codec.h>
16
17bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg)
18{
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;
40	}
41}
42EXPORT_SYMBOL_GPL(regmap_ac97_default_volatile);
43
44static int regmap_ac97_reg_read(void *context, unsigned int reg,
45	unsigned int *val)
46{
47	struct snd_ac97 *ac97 = context;
48
49	*val = ac97->bus->ops->read(ac97, reg);
50
51	return 0;
52}
53
54static int regmap_ac97_reg_write(void *context, unsigned int reg,
55	unsigned int val)
56{
57	struct snd_ac97 *ac97 = context;
58
59	ac97->bus->ops->write(ac97, reg, val);
60
61	return 0;
62}
63
64static const struct regmap_bus ac97_regmap_bus = {
65	.reg_write = regmap_ac97_reg_write,
66	.reg_read = regmap_ac97_reg_read,
67};
68
69struct 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)
73{
74	return __regmap_init(&ac97->dev, &ac97_regmap_bus, ac97, config,
75			     lock_key, lock_name);
76}
77EXPORT_SYMBOL_GPL(__regmap_init_ac97);
78
79struct 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}
87EXPORT_SYMBOL_GPL(__devm_regmap_init_ac97);
88
89MODULE_LICENSE("GPL v2");
v4.10.11
  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
 19#include <linux/clk.h>
 20#include <linux/err.h>
 21#include <linux/init.h>
 22#include <linux/io.h>
 23#include <linux/module.h>
 24#include <linux/regmap.h>
 25#include <linux/slab.h>
 26
 27#include <sound/ac97_codec.h>
 28
 29bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg)
 30{
 31	switch (reg) {
 32	case AC97_RESET:
 33	case AC97_POWERDOWN:
 34	case AC97_INT_PAGING:
 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:
 40	case AC97_MISC_AFE:
 41	case AC97_VENDOR_ID1:
 42	case AC97_VENDOR_ID2:
 43	case AC97_CODEC_CLASS_REV:
 44	case AC97_PCI_SVID:
 45	case AC97_PCI_SID:
 46	case AC97_FUNC_SELECT:
 47	case AC97_FUNC_INFO:
 48	case AC97_SENSE_INFO:
 49		return true;
 50	default:
 51		return false;
 52	}
 53}
 54EXPORT_SYMBOL_GPL(regmap_ac97_default_volatile);
 55
 56static int regmap_ac97_reg_read(void *context, unsigned int reg,
 57	unsigned int *val)
 58{
 59	struct snd_ac97 *ac97 = context;
 60
 61	*val = ac97->bus->ops->read(ac97, reg);
 62
 63	return 0;
 64}
 65
 66static int regmap_ac97_reg_write(void *context, unsigned int reg,
 67	unsigned int val)
 68{
 69	struct snd_ac97 *ac97 = context;
 70
 71	ac97->bus->ops->write(ac97, reg, val);
 72
 73	return 0;
 74}
 75
 76static const struct regmap_bus ac97_regmap_bus = {
 77	.reg_write = regmap_ac97_reg_write,
 78	.reg_read = regmap_ac97_reg_read,
 79};
 80
 81struct regmap *__regmap_init_ac97(struct snd_ac97 *ac97,
 82				  const struct regmap_config *config,
 83				  struct lock_class_key *lock_key,
 84				  const char *lock_name)
 85{
 86	return __regmap_init(&ac97->dev, &ac97_regmap_bus, ac97, config,
 87			     lock_key, lock_name);
 88}
 89EXPORT_SYMBOL_GPL(__regmap_init_ac97);
 90
 91struct regmap *__devm_regmap_init_ac97(struct snd_ac97 *ac97,
 92				       const struct regmap_config *config,
 93				       struct lock_class_key *lock_key,
 94				       const char *lock_name)
 95{
 96	return __devm_regmap_init(&ac97->dev, &ac97_regmap_bus, ac97, config,
 97				  lock_key, lock_name);
 98}
 99EXPORT_SYMBOL_GPL(__devm_regmap_init_ac97);
100
101MODULE_LICENSE("GPL v2");