162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * mtk-base-afe.h -- Mediatek base afe structure 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (c) 2016 MediaTek Inc. 662306a36Sopenharmony_ci * Author: Garlic Tseng <garlic.tseng@mediatek.com> 762306a36Sopenharmony_ci */ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#ifndef _MTK_BASE_AFE_H_ 1062306a36Sopenharmony_ci#define _MTK_BASE_AFE_H_ 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#include <linux/soc/mediatek/mtk_sip_svc.h> 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci#define MTK_STREAM_NUM (SNDRV_PCM_STREAM_LAST + 1) 1562306a36Sopenharmony_ci#define MTK_SIP_AUDIO_CONTROL MTK_SIP_SMC_CMD(0x517) 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci/* SMC CALL Operations */ 1862306a36Sopenharmony_cienum mtk_audio_smc_call_op { 1962306a36Sopenharmony_ci MTK_AUDIO_SMC_OP_INIT = 0, 2062306a36Sopenharmony_ci MTK_AUDIO_SMC_OP_DRAM_REQUEST, 2162306a36Sopenharmony_ci MTK_AUDIO_SMC_OP_DRAM_RELEASE, 2262306a36Sopenharmony_ci MTK_AUDIO_SMC_OP_SRAM_REQUEST, 2362306a36Sopenharmony_ci MTK_AUDIO_SMC_OP_SRAM_RELEASE, 2462306a36Sopenharmony_ci MTK_AUDIO_SMC_OP_ADSP_REQUEST, 2562306a36Sopenharmony_ci MTK_AUDIO_SMC_OP_ADSP_RELEASE, 2662306a36Sopenharmony_ci MTK_AUDIO_SMC_OP_DOMAIN_SIDEBANDS, 2762306a36Sopenharmony_ci MTK_AUDIO_SMC_OP_BTCVSD_WRITE, 2862306a36Sopenharmony_ci MTK_AUDIO_SMC_OP_BTCVSD_UPDATE_CTRL_CLEAR, 2962306a36Sopenharmony_ci MTK_AUDIO_SMC_OP_BTCVSD_UPDATE_CTRL_UNDERFLOW, 3062306a36Sopenharmony_ci MTK_AUDIO_SMC_OP_NUM 3162306a36Sopenharmony_ci}; 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_cistruct mtk_base_memif_data { 3462306a36Sopenharmony_ci int id; 3562306a36Sopenharmony_ci const char *name; 3662306a36Sopenharmony_ci int reg_ofs_base; 3762306a36Sopenharmony_ci int reg_ofs_cur; 3862306a36Sopenharmony_ci int reg_ofs_end; 3962306a36Sopenharmony_ci int reg_ofs_base_msb; 4062306a36Sopenharmony_ci int reg_ofs_cur_msb; 4162306a36Sopenharmony_ci int reg_ofs_end_msb; 4262306a36Sopenharmony_ci int fs_reg; 4362306a36Sopenharmony_ci int fs_shift; 4462306a36Sopenharmony_ci int fs_maskbit; 4562306a36Sopenharmony_ci int mono_reg; 4662306a36Sopenharmony_ci int mono_shift; 4762306a36Sopenharmony_ci int mono_invert; 4862306a36Sopenharmony_ci int quad_ch_reg; 4962306a36Sopenharmony_ci int quad_ch_mask; 5062306a36Sopenharmony_ci int quad_ch_shift; 5162306a36Sopenharmony_ci int int_odd_flag_reg; 5262306a36Sopenharmony_ci int int_odd_flag_shift; 5362306a36Sopenharmony_ci int enable_reg; 5462306a36Sopenharmony_ci int enable_shift; 5562306a36Sopenharmony_ci int hd_reg; 5662306a36Sopenharmony_ci int hd_shift; 5762306a36Sopenharmony_ci int hd_align_reg; 5862306a36Sopenharmony_ci int hd_align_mshift; 5962306a36Sopenharmony_ci int msb_reg; 6062306a36Sopenharmony_ci int msb_shift; 6162306a36Sopenharmony_ci int msb_end_reg; 6262306a36Sopenharmony_ci int msb_end_shift; 6362306a36Sopenharmony_ci int agent_disable_reg; 6462306a36Sopenharmony_ci int agent_disable_shift; 6562306a36Sopenharmony_ci int ch_num_reg; 6662306a36Sopenharmony_ci int ch_num_shift; 6762306a36Sopenharmony_ci int ch_num_maskbit; 6862306a36Sopenharmony_ci /* playback memif only */ 6962306a36Sopenharmony_ci int pbuf_reg; 7062306a36Sopenharmony_ci int pbuf_mask; 7162306a36Sopenharmony_ci int pbuf_shift; 7262306a36Sopenharmony_ci int minlen_reg; 7362306a36Sopenharmony_ci int minlen_mask; 7462306a36Sopenharmony_ci int minlen_shift; 7562306a36Sopenharmony_ci}; 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_cistruct mtk_base_irq_data { 7862306a36Sopenharmony_ci int id; 7962306a36Sopenharmony_ci int irq_cnt_reg; 8062306a36Sopenharmony_ci int irq_cnt_shift; 8162306a36Sopenharmony_ci int irq_cnt_maskbit; 8262306a36Sopenharmony_ci int irq_fs_reg; 8362306a36Sopenharmony_ci int irq_fs_shift; 8462306a36Sopenharmony_ci int irq_fs_maskbit; 8562306a36Sopenharmony_ci int irq_en_reg; 8662306a36Sopenharmony_ci int irq_en_shift; 8762306a36Sopenharmony_ci int irq_clr_reg; 8862306a36Sopenharmony_ci int irq_clr_shift; 8962306a36Sopenharmony_ci int irq_status_shift; 9062306a36Sopenharmony_ci}; 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_cistruct device; 9362306a36Sopenharmony_cistruct list_head; 9462306a36Sopenharmony_cistruct mtk_base_afe_memif; 9562306a36Sopenharmony_cistruct mtk_base_afe_irq; 9662306a36Sopenharmony_cistruct mtk_base_afe_dai; 9762306a36Sopenharmony_cistruct regmap; 9862306a36Sopenharmony_cistruct snd_pcm_substream; 9962306a36Sopenharmony_cistruct snd_soc_dai; 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_cistruct mtk_base_afe { 10262306a36Sopenharmony_ci void __iomem *base_addr; 10362306a36Sopenharmony_ci struct device *dev; 10462306a36Sopenharmony_ci struct regmap *regmap; 10562306a36Sopenharmony_ci struct mutex irq_alloc_lock; /* dynamic alloc irq lock */ 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_ci unsigned int const *reg_back_up_list; 10862306a36Sopenharmony_ci unsigned int *reg_back_up; 10962306a36Sopenharmony_ci unsigned int reg_back_up_list_num; 11062306a36Sopenharmony_ci 11162306a36Sopenharmony_ci int (*runtime_suspend)(struct device *dev); 11262306a36Sopenharmony_ci int (*runtime_resume)(struct device *dev); 11362306a36Sopenharmony_ci bool suspended; 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_ci struct mtk_base_afe_memif *memif; 11662306a36Sopenharmony_ci int memif_size; 11762306a36Sopenharmony_ci struct mtk_base_afe_irq *irqs; 11862306a36Sopenharmony_ci int irqs_size; 11962306a36Sopenharmony_ci int memif_32bit_supported; 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ci struct list_head sub_dais; 12262306a36Sopenharmony_ci struct snd_soc_dai_driver *dai_drivers; 12362306a36Sopenharmony_ci unsigned int num_dai_drivers; 12462306a36Sopenharmony_ci 12562306a36Sopenharmony_ci const struct snd_pcm_hardware *mtk_afe_hardware; 12662306a36Sopenharmony_ci int (*memif_fs)(struct snd_pcm_substream *substream, 12762306a36Sopenharmony_ci unsigned int rate); 12862306a36Sopenharmony_ci int (*irq_fs)(struct snd_pcm_substream *substream, 12962306a36Sopenharmony_ci unsigned int rate); 13062306a36Sopenharmony_ci int (*get_dai_fs)(struct mtk_base_afe *afe, 13162306a36Sopenharmony_ci int dai_id, unsigned int rate); 13262306a36Sopenharmony_ci int (*get_memif_pbuf_size)(struct snd_pcm_substream *substream); 13362306a36Sopenharmony_ci 13462306a36Sopenharmony_ci int (*request_dram_resource)(struct device *dev); 13562306a36Sopenharmony_ci int (*release_dram_resource)(struct device *dev); 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ci void *platform_priv; 13862306a36Sopenharmony_ci}; 13962306a36Sopenharmony_ci 14062306a36Sopenharmony_cistruct mtk_base_afe_memif { 14162306a36Sopenharmony_ci unsigned int phys_buf_addr; 14262306a36Sopenharmony_ci int buffer_size; 14362306a36Sopenharmony_ci struct snd_pcm_substream *substream; 14462306a36Sopenharmony_ci const struct mtk_base_memif_data *data; 14562306a36Sopenharmony_ci int irq_usage; 14662306a36Sopenharmony_ci int const_irq; 14762306a36Sopenharmony_ci unsigned char *dma_area; 14862306a36Sopenharmony_ci dma_addr_t dma_addr; 14962306a36Sopenharmony_ci size_t dma_bytes; 15062306a36Sopenharmony_ci}; 15162306a36Sopenharmony_ci 15262306a36Sopenharmony_cistruct mtk_base_afe_irq { 15362306a36Sopenharmony_ci const struct mtk_base_irq_data *irq_data; 15462306a36Sopenharmony_ci int irq_occupyed; 15562306a36Sopenharmony_ci}; 15662306a36Sopenharmony_ci 15762306a36Sopenharmony_cistruct mtk_base_afe_dai { 15862306a36Sopenharmony_ci struct snd_soc_dai_driver *dai_drivers; 15962306a36Sopenharmony_ci unsigned int num_dai_drivers; 16062306a36Sopenharmony_ci 16162306a36Sopenharmony_ci const struct snd_kcontrol_new *controls; 16262306a36Sopenharmony_ci unsigned int num_controls; 16362306a36Sopenharmony_ci const struct snd_soc_dapm_widget *dapm_widgets; 16462306a36Sopenharmony_ci unsigned int num_dapm_widgets; 16562306a36Sopenharmony_ci const struct snd_soc_dapm_route *dapm_routes; 16662306a36Sopenharmony_ci unsigned int num_dapm_routes; 16762306a36Sopenharmony_ci 16862306a36Sopenharmony_ci struct list_head list; 16962306a36Sopenharmony_ci}; 17062306a36Sopenharmony_ci 17162306a36Sopenharmony_ci#endif 17262306a36Sopenharmony_ci 173