• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18 #ifndef __HDMI_REG_AUDIO_PATH_H__
19 #define __HDMI_REG_AUDIO_PATH_H__
20 
21 #include "hi_type.h"
22 
23 typedef union {
24     struct {
25         unsigned int aud_in_en     : 1;  /* [0] */
26         unsigned int aud_mute_en   : 1;  /* [1] */
27         unsigned int aud_layout    : 1;  /* [2] */
28         unsigned int rsv_0         : 1;  /* [3] */
29         unsigned int aud_i2s_en    : 4;  /* [7:4] */
30         unsigned int aud_spdif_en  : 1;  /* [8] */
31         unsigned int aud_src_en    : 1;  /* [9] */
32         unsigned int aud_src_ctrl  : 1;  /* [10] */
33         unsigned int rsv_1         : 1;  /* [11] */
34         unsigned int aud_fifo0_map : 2;  /* [13:12] */
35         unsigned int aud_fifo1_map : 2;  /* [15:14] */
36         unsigned int aud_fifo2_map : 2;  /* [17:16] */
37         unsigned int aud_fifo3_map : 2;  /* [19:18] */
38         unsigned int rsv_2         : 12; /* [31:20] */
39     } bits;
40     unsigned int u32;
41 } tx_audio_ctrl;
42 
43 typedef union {
44     struct {
45         unsigned int i2s_hbra_on     : 1;  /* [0] */
46         unsigned int i2s_1st_shift   : 1;  /* [1] */
47         unsigned int i2s_ws_polarity : 1;  /* [2] */
48         unsigned int i2s_justify     : 1;  /* [3] */
49         unsigned int i2s_data_dir    : 1;  /* [4] */
50         unsigned int i2s_vbit        : 1;  /* [5] */
51         unsigned int rsv_3           : 2;  /* [7:6] */
52         unsigned int i2s_length      : 4;  /* [11:8] */
53         unsigned int i2s_ch_swap     : 4;  /* [15:12] */
54         unsigned int rsv_4           : 16; /* [31:16] */
55     } bits;
56     unsigned int u32;
57 } audio_i2s_ctrl;
58 
59 typedef union {
60     struct {
61         unsigned int spdif_1ui_lock   : 1; /* [0] */
62         unsigned int spdif_2ui_lock   : 1; /* [1] */
63         unsigned int i2s_cbit_order   : 1; /* [2] */
64         unsigned int spdif_fs_ovr_en  : 1; /* [3] */
65         unsigned int spdif_err_thresh : 6; /* [9:4] */
66         unsigned int spdif_size_sw    : 2; /* [11:10] */
67         unsigned int spdif_1ui_max    : 8; /* [19:12] */
68         unsigned int spdif_2ui_max    : 8; /* [27:20] */
69         unsigned int rsv_5            : 4; /* [31:28] */
70     } bits;
71     unsigned int u32;
72 } audio_spdif_ctrl;
73 
74 typedef union {
75     struct {
76         unsigned int chst_byte0_a              : 1; /* [0] */
77         unsigned int chst_byte0_b              : 1; /* [1] */
78         unsigned int chst_byte0_other          : 6; /* [7:2] */
79         unsigned int chst_byte1                : 8; /* [15:8] */
80         unsigned int chst_byte2                : 8; /* [23:16] */
81         unsigned int chst_byte3_fs             : 4; /* [27:24] */
82         unsigned int chst_byte3_clock_accuracy : 4; /* [31:28] */
83     } bits;
84     unsigned int u32;
85 } audio_chst_cfg0;
86 
87 typedef union {
88     struct {
89         unsigned int chst_byte4_length : 4;  /* [3:0] */
90         unsigned int chst_byte4_org_fs : 4;  /* [7:4] */
91         unsigned int chst_byte5_6      : 16; /* [23:8] */
92         unsigned int rsv_6             : 8;  /* [31:24] */
93     } bits;
94     unsigned int u32;
95 } audio_chst_cfg1;
96 
97 typedef union {
98     struct {
99         unsigned int aud_inavailable  : 1; /* [0] */
100         unsigned int aud_spdif_new_fs : 1; /* [1] */
101         unsigned int rsv_7            : 2; /* [3:2] */
102         unsigned int aud_length       : 4; /* [7:4] */
103         unsigned int aud_spdif_fs     : 6; /* [13:8] */
104         unsigned int rsv_8            : 2; /* [15:14] */
105         unsigned int spdif_max_1ui_st : 8; /* [23:16] */
106         unsigned int spdif_max_2ui_st : 8; /* [31:24] */
107     } bits;
108     unsigned int u32;
109 } tx_audio_state;
110 
111 typedef union {
112     struct {
113         unsigned int aud_fifo_test     : 5;  /* [4:0] */
114         unsigned int rsv_9             : 3;  /* [7:5] */
115         unsigned int aud_fifo_hbr_mask : 4;  /* [11:8] */
116         unsigned int rsv_10            : 4;  /* [15:12] */
117         unsigned int aud_fifo_ptr_diff : 6;  /* [21:16] */
118         unsigned int rsv_11            : 10; /* [31:22] */
119     } bits;
120     unsigned int u32;
121 } audio_fifo_ctrl;
122 
123 typedef union {
124     struct {
125         unsigned int acr_cts_req_en    : 1;  /* [0] */
126         unsigned int acr_cts_hw_sw_sel : 1;  /* [1] */
127         unsigned int acr_cts_gen_sel   : 1;  /* [2] */
128         unsigned int acr_cts_flt_en    : 1;  /* [3] */
129         unsigned int acr_use_sw_cts    : 1;  /* [4] */
130         unsigned int acr_cts_ave_en    : 1;  /* [5] */
131         unsigned int rsv_12            : 26; /* [31:6] */
132     } bits;
133     unsigned int u32;
134 } audio_acr_ctrl;
135 
136 typedef union {
137     struct {
138         unsigned int acr_fm_val_sw    : 3; /* [2:0] */
139         unsigned int acr_ave_max      : 5; /* [7:3] */
140         unsigned int acr_cts_thre     : 8; /* [15:8] */
141         unsigned int acr_cts_chg_thre : 8; /* [23:16] */
142         unsigned int rsv_13           : 8; /* [31:24] */
143     } bits;
144     unsigned int u32;
145 } audio_acr_cfg;
146 
147 typedef union {
148     struct {
149         unsigned int acr_n_val_sw : 20; /* [19:0] */
150         unsigned int rsv_14       : 12; /* [31:20] */
151     } bits;
152     unsigned int u32;
153 } acr_n_val_sw;
154 
155 typedef union {
156     struct {
157         unsigned int acr_cts_val_sw : 20; /* [19:0] */
158         unsigned int rsv_15         : 12; /* [31:20] */
159     } bits;
160     unsigned int u32;
161 } acr_cts_val_sw;
162 
163 typedef union {
164     struct {
165         unsigned int acr_cts_val_hw : 20; /* [19:0] */
166         unsigned int rsv_16         : 12; /* [31:20] */
167     } bits;
168     unsigned int u32;
169 } acr_cts_val_hw;
170 
171 typedef struct {
172     volatile tx_audio_ctrl    audio_ctl;    /* 1000 */
173     volatile audio_i2s_ctrl   i2s_ctl;      /* 1004 */
174     volatile audio_spdif_ctrl spdif_ctl;    /* 1008 */
175     volatile audio_chst_cfg0  chst_cfg0;    /* 100C */
176     volatile audio_chst_cfg1  chst_cfg1;    /* 1010 */
177     volatile tx_audio_state   aud_state;    /* 1014 */
178     volatile audio_fifo_ctrl  fifo_ctl;     /* 1018 */
179     unsigned int              reserved_0[9];
180     volatile audio_acr_ctrl   acr_ctl;      /* 1040 */
181     volatile audio_acr_cfg    acr_cfg;      /* 1044 */
182     volatile acr_n_val_sw     acr_sw_n;     /* 1048 */
183     volatile acr_cts_val_sw   acr_sw_cts;   /* 104C */
184     volatile acr_cts_val_hw   acr_hw_cts;   /* 1050 */
185 } hdmi_reg_audio_path;
186 
187 int hdmi_reg_audio_path_regs_init(hi_char *addr);
188 int hdmi_reg_audio_path_regs_deinit(hi_void);
189 int hdmi_reg_aud_in_en_set(unsigned int aud_in_en);
190 int hdmi_reg_aud_mute_en_set(unsigned int aud_mute_en);
191 int hdmi_reg_aud_layout_set(unsigned int aud_layout);
192 int hdmi_reg_aud_i2s_en_set(unsigned int aud_i2s_en);
193 int hdmi_reg_aud_spdif_en_set(unsigned int aud_spdif_en);
194 int hdmi_reg_i2s_hbra_on_set(unsigned int i2s_hbra_on);
195 int hdmi_reg_i2s_1st_shift_set(unsigned int i2s_1st_shift);
196 int hdmi_reg_i2s_ws_polarity_set(unsigned int i2s_ws_polarity);
197 int hdmi_reg_i2s_justify_set(unsigned int i2s_justify);
198 int hdmi_reg_i2s_data_dir_set(unsigned int i2s_data_dir);
199 int hdmi_reg_i2s_vbit_set(unsigned int i2s_vbit);
200 int hdmi_reg_i2s_length_set(unsigned int i2s_length);
201 int hdmi_reg_i2s_ch_swap_set(unsigned int i2s_ch_swap);
202 int hdmi_reg_chst_byte0_aset(unsigned int chst_byte0_a);
203 int hdmi_reg_chst_byte0_bset(unsigned int chst_byte0_b);
204 int hdmi_reg_chst_byte3_fs_set(unsigned int chst_byte3_fs);
205 int hdmi_reg_chst_byte3_clock_accuracy_set(unsigned int chst_byte3_clock_accuracy);
206 int hdmi_reg_chst_byte4_length_set(unsigned int chst_byte4_length);
207 int hdmi_reg_chst_byte4_org_fs_set(unsigned int chst_byte4_org_fs);
208 int hdmi_reg_aud_fifo_test_set(unsigned int aud_fifo_test);
209 int hdmi_reg_aud_fifo_hbr_mask_set(unsigned int aud_fifo_hbr_mask);
210 int hdmi_reg_acr_cts_hw_sw_sel_set(unsigned int acr_cts_hw_sw_sel);
211 int hdmi_reg_acr_n_val_sw_set(unsigned int acr_n_value);
212 hi_u32 hdmi_reg_aud_in_en_get(hi_void);
213 hi_u32 hdmi_reg_aud_mute_en_get(hi_void);
214 hi_u32 hdmi_reg_aud_layout_get(hi_void);
215 hi_u32 hdmi_reg_aud_i2s_en_get(hi_void);
216 hi_u32 hdmi_reg_aud_spdif_en_get(hi_void);
217 hi_u32 hdmi_reg_i2s_hbra_on_get(hi_void);
218 hi_u32 hdmi_reg_chst_byte3_fs_get(hi_void);
219 hi_u32 hdmi_reg_chst_byte4_length_get(hi_void);
220 hi_u32 hdmi_reg_chst_byte4_org_fs_get(hi_void);
221 hi_u32 hdmi_reg_aud_length_get(hi_void);
222 hi_u32 hdmi_reg_aud_spdif_fs_get(hi_void);
223 hi_u32 hdmi_reg_acr_cts_hw_sw_sel_get(hi_void);
224 hi_u32 hdmi_reg_acr_n_val_sw_get(hi_void);
225 hi_u32 hdmi_reg_acr_cts_val_sw_get(hi_void);
226 hi_u32 hdmi_reg_acr_cts_val_hw_get(hi_void);
227 
228 #endif /* __HDMI_REG_AUDIO_PATH_H__ */
229 
230