blob: 60cb609a9790083e372a79210ca772bc4450069c [file] [log] [blame]
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * mtk-base-afe.h -- Mediatek base afe structure
4 *
5 * Copyright (c) 2016 MediaTek Inc.
6 * Author: Garlic Tseng <garlic.tseng@mediatek.com>
7 */
8
9#ifndef _MTK_BASE_AFE_H_
10#define _MTK_BASE_AFE_H_
11
12#define MTK_STREAM_NUM (SNDRV_PCM_STREAM_LAST + 1)
13
14struct mtk_base_memif_data {
15 int id;
16 const char *name;
17 int reg_ofs_base;
18 int reg_ofs_cur;
19 int fs_reg;
20 int fs_shift;
21 int fs_maskbit;
22 int mono_reg;
23 int mono_shift;
24 int enable_reg;
25 int enable_shift;
26 int hd_reg;
David Brazdil0f672f62019-12-10 10:32:29 +000027 int hd_align_reg;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000028 int hd_shift;
David Brazdil0f672f62019-12-10 10:32:29 +000029 int hd_align_mshift;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000030 int msb_reg;
31 int msb_shift;
32 int agent_disable_reg;
33 int agent_disable_shift;
34};
35
36struct mtk_base_irq_data {
37 int id;
38 int irq_cnt_reg;
39 int irq_cnt_shift;
40 int irq_cnt_maskbit;
41 int irq_fs_reg;
42 int irq_fs_shift;
43 int irq_fs_maskbit;
44 int irq_en_reg;
45 int irq_en_shift;
46 int irq_clr_reg;
47 int irq_clr_shift;
48};
49
50struct device;
51struct list_head;
52struct mtk_base_afe_memif;
53struct mtk_base_afe_irq;
54struct mtk_base_afe_dai;
55struct regmap;
56struct snd_pcm_substream;
57struct snd_soc_dai;
58
59struct mtk_base_afe {
60 void __iomem *base_addr;
61 struct device *dev;
62 struct regmap *regmap;
63 struct mutex irq_alloc_lock; /* dynamic alloc irq lock */
64
65 unsigned int const *reg_back_up_list;
66 unsigned int *reg_back_up;
67 unsigned int reg_back_up_list_num;
68
69 int (*runtime_suspend)(struct device *dev);
70 int (*runtime_resume)(struct device *dev);
71 bool suspended;
72
73 struct mtk_base_afe_memif *memif;
74 int memif_size;
75 struct mtk_base_afe_irq *irqs;
76 int irqs_size;
77
78 struct list_head sub_dais;
79 struct snd_soc_dai_driver *dai_drivers;
80 unsigned int num_dai_drivers;
81
82 const struct snd_pcm_hardware *mtk_afe_hardware;
83 int (*memif_fs)(struct snd_pcm_substream *substream,
84 unsigned int rate);
85 int (*irq_fs)(struct snd_pcm_substream *substream,
86 unsigned int rate);
87
88 void *platform_priv;
89};
90
91struct mtk_base_afe_memif {
92 unsigned int phys_buf_addr;
93 int buffer_size;
94 struct snd_pcm_substream *substream;
95 const struct mtk_base_memif_data *data;
96 int irq_usage;
97 int const_irq;
98};
99
100struct mtk_base_afe_irq {
101 const struct mtk_base_irq_data *irq_data;
102 int irq_occupyed;
103};
104
105struct mtk_base_afe_dai {
106 struct snd_soc_dai_driver *dai_drivers;
107 unsigned int num_dai_drivers;
108
109 const struct snd_kcontrol_new *controls;
110 unsigned int num_controls;
111 const struct snd_soc_dapm_widget *dapm_widgets;
112 unsigned int num_dapm_widgets;
113 const struct snd_soc_dapm_route *dapm_routes;
114 unsigned int num_dapm_routes;
115
116 struct list_head list;
117};
118
119#endif
120