blob: 85fe6303434f984a578c13728f72d8567175271e
1 | /* |
2 | * sound/soc/amlogic/auge/tdm_hw.h |
3 | * |
4 | * Copyright (C) 2017 Amlogic, Inc. All rights reserved. |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation; either version 2 of the License, or |
9 | * (at your option) any later version. |
10 | * |
11 | * This program is distributed in the hope that it will be useful, but WITHOUT |
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
14 | * more details. |
15 | * |
16 | */ |
17 | |
18 | #ifndef __AML_TDM_HW_H__ |
19 | #define __AML_TDM_HW_H__ |
20 | |
21 | #include "audio_io.h" |
22 | #include "regs.h" |
23 | |
24 | // TODO: fix me, now based by tl1 |
25 | enum tdmin_src { |
26 | PAD_TDMINA_DIN = 0, |
27 | PAD_TDMINB_DIN = 1, |
28 | PAD_TDMINC_DIN = 2, |
29 | PAD_TDMINA_D = 3, |
30 | PAD_TDMINB_D = 4, |
31 | PAD_TDMINC_D = 5, |
32 | HDMIRX_I2S = 6, |
33 | ACODEC_ADC = 7, |
34 | TDMOUTA = 13, |
35 | TDMOUTB = 14, |
36 | TDMOUTC = 15, |
37 | }; |
38 | |
39 | struct pcm_setting { |
40 | unsigned int pcm_mode; |
41 | unsigned int sysclk; |
42 | unsigned int sysclk_bclk_ratio; |
43 | unsigned int bclk; |
44 | unsigned int bclk_lrclk_ratio; |
45 | unsigned int lrclk; |
46 | unsigned int tx_mask; |
47 | unsigned int rx_mask; |
48 | unsigned int slots; |
49 | unsigned int slot_width; |
50 | unsigned int pcm_width; |
51 | unsigned int lane_mask_out; |
52 | unsigned int lane_mask_in; |
53 | /* lane oe (out pad) mask */ |
54 | unsigned int lane_oe_mask_out; |
55 | unsigned int lane_oe_mask_in; |
56 | /* lane in selected from out, for intrenal loopback */ |
57 | unsigned int lane_lb_mask_in; |
58 | |
59 | /* eco or sclk_ws_inv */ |
60 | bool sclk_ws_inv; |
61 | }; |
62 | |
63 | extern void aml_tdm_enable( |
64 | struct aml_audio_controller *actrl, |
65 | int stream, int index, |
66 | bool is_enable); |
67 | |
68 | extern void aml_tdm_arb_config( |
69 | struct aml_audio_controller *actrl); |
70 | |
71 | extern void aml_tdm_fifo_reset( |
72 | struct aml_audio_controller *actrl, |
73 | int stream, int index); |
74 | |
75 | extern int tdmout_get_frddr_type(int bitwidth); |
76 | |
77 | extern void aml_tdm_fifo_ctrl( |
78 | struct aml_audio_controller *actrl, |
79 | int bitwidth, int stream, |
80 | int index, unsigned int fifo_id); |
81 | |
82 | extern void aml_tdm_set_format( |
83 | struct aml_audio_controller *actrl, |
84 | struct pcm_setting *p_config, |
85 | unsigned int clk_sel, |
86 | unsigned int index, |
87 | unsigned int fmt, |
88 | unsigned int capture_active, |
89 | unsigned int playback_active); |
90 | |
91 | extern void aml_update_tdmin_skew(struct aml_audio_controller *actrl, |
92 | int idx, int skew); |
93 | |
94 | extern void aml_update_tdmin_rev_ws(struct aml_audio_controller *actrl, |
95 | int idx, int is_rev); |
96 | |
97 | extern void aml_tdm_set_slot_out( |
98 | struct aml_audio_controller *actrl, |
99 | int index, int slots, int slot_width, |
100 | int force_oe, int oe_val); |
101 | |
102 | extern void aml_tdm_set_slot_in( |
103 | struct aml_audio_controller *actrl, |
104 | int index, int in_src, int slot_width); |
105 | |
106 | extern void aml_update_tdmin_src( |
107 | struct aml_audio_controller *actrl, |
108 | int index, int in_src); |
109 | |
110 | extern void tdmin_set_chnum_en( |
111 | struct aml_audio_controller *actrl, |
112 | int index, bool enable); |
113 | |
114 | extern void aml_tdm_set_channel_mask( |
115 | struct aml_audio_controller *actrl, |
116 | int stream, int index, int lanes, int mask); |
117 | |
118 | extern void aml_tdm_set_lane_channel_swap( |
119 | struct aml_audio_controller *actrl, |
120 | int stream, int index, int swap); |
121 | |
122 | extern void aml_tdm_set_bclk_ratio( |
123 | struct aml_audio_controller *actrl, |
124 | int clk_sel, int lrclk_hi, int bclk_ratio); |
125 | |
126 | extern void aml_tdm_set_lrclkdiv( |
127 | struct aml_audio_controller *actrl, |
128 | int clk_sel, int ratio); |
129 | |
130 | extern void tdm_enable(int tdm_index, int is_enable); |
131 | |
132 | extern void tdm_fifo_enable(int tdm_index, int is_enable); |
133 | |
134 | extern void aml_tdmout_select_aed(bool enable, int tdmout_id); |
135 | |
136 | extern void aml_tdmout_get_aed_info(int tdmout_id, |
137 | int *bitwidth, int *frddrtype); |
138 | |
139 | extern void aml_tdm_clk_pad_select( |
140 | struct aml_audio_controller *actrl, |
141 | int mpad, int mclk_sel, |
142 | int tdm_index, int clk_sel); |
143 | |
144 | extern void i2s_to_hdmitx_ctrl(int tdm_index); |
145 | void aml_tdm_mute_playback( |
146 | struct aml_audio_controller *actrl, |
147 | int index, |
148 | bool mute); |
149 | void aml_tdm_mute_capture( |
150 | struct aml_audio_controller *actrl, |
151 | int tdm_index, |
152 | bool mute); |
153 | #endif |
154 |