blob: 2c5fe03adc3877b1eeaa38a064e5191116fecc5d
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 | void aml_tdmout_enable_gain(int tdmout_id, int en); |
75 | |
76 | extern int tdmout_get_frddr_type(int bitwidth); |
77 | |
78 | extern void aml_tdm_fifo_ctrl( |
79 | struct aml_audio_controller *actrl, |
80 | int bitwidth, int stream, |
81 | int index, unsigned int fifo_id); |
82 | |
83 | extern void aml_tdm_set_format( |
84 | struct aml_audio_controller *actrl, |
85 | struct pcm_setting *p_config, |
86 | unsigned int clk_sel, |
87 | unsigned int index, |
88 | unsigned int fmt, |
89 | unsigned int capture_active, |
90 | unsigned int playback_active); |
91 | |
92 | extern void aml_update_tdmin_skew(struct aml_audio_controller *actrl, |
93 | int idx, int skew); |
94 | |
95 | extern void aml_update_tdmin_rev_ws(struct aml_audio_controller *actrl, |
96 | int idx, int is_rev); |
97 | |
98 | extern void aml_tdm_set_slot_out( |
99 | struct aml_audio_controller *actrl, |
100 | int index, int slots, int slot_width, |
101 | int force_oe, int oe_val); |
102 | |
103 | extern void aml_tdm_set_slot_in( |
104 | struct aml_audio_controller *actrl, |
105 | int index, int in_src, int slot_width); |
106 | |
107 | extern void aml_update_tdmin_src( |
108 | struct aml_audio_controller *actrl, |
109 | int index, int in_src); |
110 | |
111 | extern void tdmin_set_chnum_en( |
112 | struct aml_audio_controller *actrl, |
113 | int index, bool enable); |
114 | |
115 | extern void aml_tdm_set_channel_mask( |
116 | struct aml_audio_controller *actrl, |
117 | int stream, int index, int lanes, int mask); |
118 | |
119 | extern void aml_tdm_set_lane_channel_swap( |
120 | struct aml_audio_controller *actrl, |
121 | int stream, int index, int swap); |
122 | |
123 | extern void aml_tdm_set_bclk_ratio( |
124 | struct aml_audio_controller *actrl, |
125 | int clk_sel, int lrclk_hi, int bclk_ratio); |
126 | |
127 | extern void aml_tdm_set_lrclkdiv( |
128 | struct aml_audio_controller *actrl, |
129 | int clk_sel, int ratio); |
130 | |
131 | extern void tdm_enable(int tdm_index, int is_enable); |
132 | |
133 | extern void tdm_fifo_enable(int tdm_index, int is_enable); |
134 | |
135 | extern void aml_tdmout_select_aed(bool enable, int tdmout_id); |
136 | |
137 | extern void aml_tdmout_get_aed_info(int tdmout_id, |
138 | int *bitwidth, int *frddrtype); |
139 | |
140 | extern void aml_tdm_clk_pad_select( |
141 | struct aml_audio_controller *actrl, |
142 | int mpad, int mclk_sel, |
143 | int tdm_index, int clk_sel); |
144 | |
145 | extern void i2s_to_hdmitx_ctrl(int tdm_index); |
146 | void aml_tdm_mute_playback( |
147 | struct aml_audio_controller *actrl, |
148 | int index, |
149 | bool mute); |
150 | void aml_tdm_mute_capture( |
151 | struct aml_audio_controller *actrl, |
152 | int tdm_index, |
153 | bool mute); |
154 | #endif |
155 |