1 /* SPDX-License-Identifier: GPL-2.0 !! 1 /* >> 2 * Copyright (C) 2016 Robert Jarzmik <robert.jarzmik@free.fr> 2 * 3 * 3 * Copyright (C) 2016 Robert Jarzmik <robert.j !! 4 * This program is free software; you can redistribute it and/or modify >> 5 * it under the terms of the GNU General Public License version 2 as >> 6 * published by the Free Software Foundation. 4 */ 7 */ 5 << 6 #ifndef AC97_CONTROLLER_H 8 #ifndef AC97_CONTROLLER_H 7 #define AC97_CONTROLLER_H 9 #define AC97_CONTROLLER_H 8 10 9 #include <linux/device.h> 11 #include <linux/device.h> 10 #include <linux/list.h> 12 #include <linux/list.h> 11 13 12 #define AC97_BUS_MAX_CODECS 4 14 #define AC97_BUS_MAX_CODECS 4 13 #define AC97_SLOTS_AVAILABLE_ALL 0xf 15 #define AC97_SLOTS_AVAILABLE_ALL 0xf 14 16 15 struct ac97_controller_ops; 17 struct ac97_controller_ops; 16 18 17 /** 19 /** 18 * struct ac97_controller - The AC97 controlle 20 * struct ac97_controller - The AC97 controller of the AC-Link 19 * @ops: the AC97 operations. 21 * @ops: the AC97 operations. 20 * @controllers: linked list of all exi 22 * @controllers: linked list of all existing controllers. 21 * @adap: the shell device ac97- 23 * @adap: the shell device ac97-%d, ie. ac97 adapter 22 * @nr: the number of the shel 24 * @nr: the number of the shell device 23 * @slots_available: the mask of accessible 25 * @slots_available: the mask of accessible/scanable codecs. 24 * @parent: the device providing t 26 * @parent: the device providing the AC97 controller. 25 * @codecs: the 4 possible AC97 co 27 * @codecs: the 4 possible AC97 codecs (NULL if none found). 26 * @codecs_pdata: platform_data for each 28 * @codecs_pdata: platform_data for each codec (NULL if no pdata). 27 * 29 * 28 * This structure is internal to AC97 bus, and 30 * This structure is internal to AC97 bus, and should not be used by the 29 * controllers themselves, excepting for using 31 * controllers themselves, excepting for using @dev. 30 */ 32 */ 31 struct ac97_controller { 33 struct ac97_controller { 32 const struct ac97_controller_ops *ops; 34 const struct ac97_controller_ops *ops; 33 struct list_head controllers; 35 struct list_head controllers; 34 struct device adap; 36 struct device adap; 35 int nr; 37 int nr; 36 unsigned short slots_available; 38 unsigned short slots_available; 37 struct device *parent; 39 struct device *parent; 38 struct ac97_codec_device *codecs[AC97_ 40 struct ac97_codec_device *codecs[AC97_BUS_MAX_CODECS]; 39 void *codecs_pdata[AC97_BUS_MAX_CODECS 41 void *codecs_pdata[AC97_BUS_MAX_CODECS]; 40 }; 42 }; 41 43 42 /** 44 /** 43 * struct ac97_controller_ops - The AC97 opera 45 * struct ac97_controller_ops - The AC97 operations 44 * @reset: Cold reset of the AC97 AC-Link 46 * @reset: Cold reset of the AC97 AC-Link. 45 * @warm_reset: Warm reset of the AC97 AC-Link 47 * @warm_reset: Warm reset of the AC97 AC-Link. 46 * @read: Read of a single AC97 register 48 * @read: Read of a single AC97 register. 47 * Returns the register value or 49 * Returns the register value or a negative error code. 48 * @write: Write of a single AC97 registe 50 * @write: Write of a single AC97 register. 49 * 51 * 50 * These are the basic operation an AC97 contr 52 * These are the basic operation an AC97 controller must provide for an AC97 51 * access functions. Amongst these, all but th 53 * access functions. Amongst these, all but the last 2 are mandatory. 52 * The slot number is also known as the AC97 c 54 * The slot number is also known as the AC97 codec number, between 0 and 3. 53 */ 55 */ 54 struct ac97_controller_ops { 56 struct ac97_controller_ops { 55 void (*reset)(struct ac97_controller * 57 void (*reset)(struct ac97_controller *adrv); 56 void (*warm_reset)(struct ac97_control 58 void (*warm_reset)(struct ac97_controller *adrv); 57 int (*write)(struct ac97_controller *a 59 int (*write)(struct ac97_controller *adrv, int slot, 58 unsigned short reg, unsig 60 unsigned short reg, unsigned short val); 59 int (*read)(struct ac97_controller *ad 61 int (*read)(struct ac97_controller *adrv, int slot, unsigned short reg); 60 }; 62 }; 61 63 62 #if IS_ENABLED(CONFIG_AC97_BUS_NEW) 64 #if IS_ENABLED(CONFIG_AC97_BUS_NEW) 63 struct ac97_controller *snd_ac97_controller_re 65 struct ac97_controller *snd_ac97_controller_register( 64 const struct ac97_controller_ops *ops, 66 const struct ac97_controller_ops *ops, struct device *dev, 65 unsigned short slots_available, void * 67 unsigned short slots_available, void **codecs_pdata); 66 void snd_ac97_controller_unregister(struct ac9 68 void snd_ac97_controller_unregister(struct ac97_controller *ac97_ctrl); 67 #else 69 #else 68 static inline struct ac97_controller * 70 static inline struct ac97_controller * 69 snd_ac97_controller_register(const struct ac97 71 snd_ac97_controller_register(const struct ac97_controller_ops *ops, 70 struct device *de 72 struct device *dev, 71 unsigned short sl 73 unsigned short slots_available, 72 void **codecs_pda 74 void **codecs_pdata) 73 { 75 { 74 return ERR_PTR(-ENODEV); 76 return ERR_PTR(-ENODEV); 75 } 77 } 76 78 77 static inline void 79 static inline void 78 snd_ac97_controller_unregister(struct ac97_con 80 snd_ac97_controller_unregister(struct ac97_controller *ac97_ctrl) 79 { 81 { 80 } 82 } 81 #endif 83 #endif 82 84 83 #endif 85 #endif 84 86
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.