18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci * 38c2ecf20Sopenharmony_ci * Copyright (C) 2016 Robert Jarzmik <robert.jarzmik@free.fr> 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#ifndef AC97_CONTROLLER_H 78c2ecf20Sopenharmony_ci#define AC97_CONTROLLER_H 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <linux/device.h> 108c2ecf20Sopenharmony_ci#include <linux/list.h> 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#define AC97_BUS_MAX_CODECS 4 138c2ecf20Sopenharmony_ci#define AC97_SLOTS_AVAILABLE_ALL 0xf 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_cistruct ac97_controller_ops; 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci/** 188c2ecf20Sopenharmony_ci * struct ac97_controller - The AC97 controller of the AC-Link 198c2ecf20Sopenharmony_ci * @ops: the AC97 operations. 208c2ecf20Sopenharmony_ci * @controllers: linked list of all existing controllers. 218c2ecf20Sopenharmony_ci * @adap: the shell device ac97-%d, ie. ac97 adapter 228c2ecf20Sopenharmony_ci * @nr: the number of the shell device 238c2ecf20Sopenharmony_ci * @slots_available: the mask of accessible/scanable codecs. 248c2ecf20Sopenharmony_ci * @parent: the device providing the AC97 controller. 258c2ecf20Sopenharmony_ci * @codecs: the 4 possible AC97 codecs (NULL if none found). 268c2ecf20Sopenharmony_ci * @codecs_pdata: platform_data for each codec (NULL if no pdata). 278c2ecf20Sopenharmony_ci * 288c2ecf20Sopenharmony_ci * This structure is internal to AC97 bus, and should not be used by the 298c2ecf20Sopenharmony_ci * controllers themselves, excepting for using @dev. 308c2ecf20Sopenharmony_ci */ 318c2ecf20Sopenharmony_cistruct ac97_controller { 328c2ecf20Sopenharmony_ci const struct ac97_controller_ops *ops; 338c2ecf20Sopenharmony_ci struct list_head controllers; 348c2ecf20Sopenharmony_ci struct device adap; 358c2ecf20Sopenharmony_ci int nr; 368c2ecf20Sopenharmony_ci unsigned short slots_available; 378c2ecf20Sopenharmony_ci struct device *parent; 388c2ecf20Sopenharmony_ci struct ac97_codec_device *codecs[AC97_BUS_MAX_CODECS]; 398c2ecf20Sopenharmony_ci void *codecs_pdata[AC97_BUS_MAX_CODECS]; 408c2ecf20Sopenharmony_ci}; 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci/** 438c2ecf20Sopenharmony_ci * struct ac97_controller_ops - The AC97 operations 448c2ecf20Sopenharmony_ci * @reset: Cold reset of the AC97 AC-Link. 458c2ecf20Sopenharmony_ci * @warm_reset: Warm reset of the AC97 AC-Link. 468c2ecf20Sopenharmony_ci * @read: Read of a single AC97 register. 478c2ecf20Sopenharmony_ci * Returns the register value or a negative error code. 488c2ecf20Sopenharmony_ci * @write: Write of a single AC97 register. 498c2ecf20Sopenharmony_ci * 508c2ecf20Sopenharmony_ci * These are the basic operation an AC97 controller must provide for an AC97 518c2ecf20Sopenharmony_ci * access functions. Amongst these, all but the last 2 are mandatory. 528c2ecf20Sopenharmony_ci * The slot number is also known as the AC97 codec number, between 0 and 3. 538c2ecf20Sopenharmony_ci */ 548c2ecf20Sopenharmony_cistruct ac97_controller_ops { 558c2ecf20Sopenharmony_ci void (*reset)(struct ac97_controller *adrv); 568c2ecf20Sopenharmony_ci void (*warm_reset)(struct ac97_controller *adrv); 578c2ecf20Sopenharmony_ci int (*write)(struct ac97_controller *adrv, int slot, 588c2ecf20Sopenharmony_ci unsigned short reg, unsigned short val); 598c2ecf20Sopenharmony_ci int (*read)(struct ac97_controller *adrv, int slot, unsigned short reg); 608c2ecf20Sopenharmony_ci}; 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_AC97_BUS_NEW) 638c2ecf20Sopenharmony_cistruct ac97_controller *snd_ac97_controller_register( 648c2ecf20Sopenharmony_ci const struct ac97_controller_ops *ops, struct device *dev, 658c2ecf20Sopenharmony_ci unsigned short slots_available, void **codecs_pdata); 668c2ecf20Sopenharmony_civoid snd_ac97_controller_unregister(struct ac97_controller *ac97_ctrl); 678c2ecf20Sopenharmony_ci#else 688c2ecf20Sopenharmony_cistatic inline struct ac97_controller * 698c2ecf20Sopenharmony_cisnd_ac97_controller_register(const struct ac97_controller_ops *ops, 708c2ecf20Sopenharmony_ci struct device *dev, 718c2ecf20Sopenharmony_ci unsigned short slots_available, 728c2ecf20Sopenharmony_ci void **codecs_pdata) 738c2ecf20Sopenharmony_ci{ 748c2ecf20Sopenharmony_ci return ERR_PTR(-ENODEV); 758c2ecf20Sopenharmony_ci} 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_cistatic inline void 788c2ecf20Sopenharmony_cisnd_ac97_controller_unregister(struct ac97_controller *ac97_ctrl) 798c2ecf20Sopenharmony_ci{ 808c2ecf20Sopenharmony_ci} 818c2ecf20Sopenharmony_ci#endif 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci#endif 84