/* SPDX-License-Identifier: GPL-2.01*2* Copyright (C) 2016 Robert Jarzmik <[email protected]>3*/45#ifndef AC97_CONTROLLER_H6#define AC97_CONTROLLER_H78#include <linux/device.h>9#include <linux/list.h>1011#define AC97_BUS_MAX_CODECS 412#define AC97_SLOTS_AVAILABLE_ALL 0xf1314struct ac97_controller_ops;1516/**17* struct ac97_controller - The AC97 controller of the AC-Link18* @ops: the AC97 operations.19* @controllers: linked list of all existing controllers.20* @adap: the shell device ac97-%d, ie. ac97 adapter21* @nr: the number of the shell device22* @slots_available: the mask of accessible/scanable codecs.23* @parent: the device providing the AC97 controller.24* @codecs: the 4 possible AC97 codecs (NULL if none found).25* @codecs_pdata: platform_data for each codec (NULL if no pdata).26*27* This structure is internal to AC97 bus, and should not be used by the28* controllers themselves, excepting for using @dev.29*/30struct ac97_controller {31const struct ac97_controller_ops *ops;32struct list_head controllers;33struct device adap;34int nr;35unsigned short slots_available;36struct device *parent;37struct ac97_codec_device *codecs[AC97_BUS_MAX_CODECS];38void *codecs_pdata[AC97_BUS_MAX_CODECS];39};4041/**42* struct ac97_controller_ops - The AC97 operations43* @reset: Cold reset of the AC97 AC-Link.44* @warm_reset: Warm reset of the AC97 AC-Link.45* @read: Read of a single AC97 register.46* Returns the register value or a negative error code.47* @write: Write of a single AC97 register.48*49* These are the basic operation an AC97 controller must provide for an AC9750* access functions. Amongst these, all but the last 2 are mandatory.51* The slot number is also known as the AC97 codec number, between 0 and 3.52*/53struct ac97_controller_ops {54void (*reset)(struct ac97_controller *adrv);55void (*warm_reset)(struct ac97_controller *adrv);56int (*write)(struct ac97_controller *adrv, int slot,57unsigned short reg, unsigned short val);58int (*read)(struct ac97_controller *adrv, int slot, unsigned short reg);59};6061#if IS_ENABLED(CONFIG_AC97_BUS_NEW)62struct ac97_controller *snd_ac97_controller_register(63const struct ac97_controller_ops *ops, struct device *dev,64unsigned short slots_available, void **codecs_pdata);65void snd_ac97_controller_unregister(struct ac97_controller *ac97_ctrl);66#else67static inline struct ac97_controller *68snd_ac97_controller_register(const struct ac97_controller_ops *ops,69struct device *dev,70unsigned short slots_available,71void **codecs_pdata)72{73return ERR_PTR(-ENODEV);74}7576static inline void77snd_ac97_controller_unregister(struct ac97_controller *ac97_ctrl)78{79}80#endif8182#endif838485