cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

regmap-ac97.c (2072B)


      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");