1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright(c) 2021-2022 Intel Corporation. All rights reserved. 4 * 5 * Authors: Cezary Rojewski <cezary.rojewski@intel.com> 6 * Amadeusz Slawinski <amadeuszx.slawinski@linux.intel.com> 7 */ 8 9 #ifndef __SOUND_SOC_INTEL_AVS_H 10 #define __SOUND_SOC_INTEL_AVS_H 11 12 #include <linux/device.h> 13 #include <sound/hda_codec.h> 14 15 struct avs_dev; 16 17 struct avs_dsp_ops { 18 int (* const power)(struct avs_dev *, u32, bool); 19 int (* const reset)(struct avs_dev *, u32, bool); 20 int (* const stall)(struct avs_dev *, u32, bool); 21 }; 22 23 #define avs_dsp_op(adev, op, ...) \ 24 ((adev)->spec->dsp_ops->op(adev, ## __VA_ARGS__)) 25 26 #define avs_platattr_test(adev, attr) \ 27 ((adev)->spec->attributes & AVS_PLATATTR_##attr) 28 29 /* Platform specific descriptor */ 30 struct avs_spec { 31 const char *name; 32 33 const struct avs_dsp_ops *const dsp_ops; 34 35 const u32 core_init_mask; /* used during DSP boot */ 36 const u64 attributes; /* bitmask of AVS_PLATATTR_* */ 37 }; 38 39 /* 40 * struct avs_dev - Intel HD-Audio driver data 41 * 42 * @dev: PCI device 43 * @dsp_ba: DSP bar address 44 * @spec: platform-specific descriptor 45 */ 46 struct avs_dev { 47 struct hda_bus base; 48 struct device *dev; 49 50 void __iomem *dsp_ba; 51 const struct avs_spec *spec; 52 }; 53 54 /* from hda_bus to avs_dev */ 55 #define hda_to_avs(hda) container_of(hda, struct avs_dev, base) 56 /* from hdac_bus to avs_dev */ 57 #define hdac_to_avs(hdac) hda_to_avs(to_hda_bus(hdac)) 58 /* from device to avs_dev */ 59 #define to_avs_dev(dev) \ 60 ({ \ 61 struct hdac_bus *__bus = dev_get_drvdata(dev); \ 62 hdac_to_avs(__bus); \ 63 }) 64 65 int avs_dsp_core_power(struct avs_dev *adev, u32 core_mask, bool power); 66 int avs_dsp_core_reset(struct avs_dev *adev, u32 core_mask, bool reset); 67 int avs_dsp_core_stall(struct avs_dev *adev, u32 core_mask, bool stall); 68 int avs_dsp_core_enable(struct avs_dev *adev, u32 core_mask); 69 int avs_dsp_core_disable(struct avs_dev *adev, u32 core_mask); 70 71 #endif /* __SOUND_SOC_INTEL_AVS_H */ 72