blob: ed437dd4318ed00b35a281d85081c710870cb9fc [file] [log] [blame]
Meng Wang43bbb872018-12-10 12:32:05 +08001/* SPDX-License-Identifier: GPL-2.0-only */
Vidyakumar Athota5d45f4c2019-03-10 22:35:07 -07002/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
Laxminath Kasame562a362018-04-12 00:39:08 +05303 */
4
5#ifndef BOLERO_CDC_H
6#define BOLERO_CDC_H
7
8#include <sound/soc.h>
9#include <linux/regmap.h>
10
Laxminath Kasamf1623022019-10-11 18:20:19 +053011#define BOLERO_VERSION_1_0 0x0001
12#define BOLERO_VERSION_1_1 0x0002
13#define BOLERO_VERSION_1_2 0x0003
14#define BOLERO_VERSION_2_0 0x0004
15#define BOLERO_VERSION_2_1 0x0005
16
Laxminath Kasame562a362018-04-12 00:39:08 +053017enum {
18 START_MACRO,
19 TX_MACRO = START_MACRO,
20 RX_MACRO,
21 WSA_MACRO,
22 VA_MACRO,
23 MAX_MACRO
24};
25
Laxminath Kasam2df2d612018-05-22 15:45:42 +053026enum mclk_mux {
27 MCLK_MUX0,
28 MCLK_MUX1,
29 MCLK_MUX_MAX
30};
31
Laxminath Kasam497a6512018-09-17 16:11:52 +053032enum {
33 BOLERO_ADC0 = 1,
34 BOLERO_ADC1,
35 BOLERO_ADC2,
36 BOLERO_ADC3,
37 BOLERO_ADC_MAX
38};
39
40enum {
41 BOLERO_MACRO_EVT_RX_MUTE = 1, /* for RX mute/unmute */
42 BOLERO_MACRO_EVT_IMPED_TRUE, /* for imped true */
43 BOLERO_MACRO_EVT_IMPED_FALSE, /* for imped false */
Laxminath Kasamfb0d6832018-09-22 01:49:52 +053044 BOLERO_MACRO_EVT_SSR_DOWN,
45 BOLERO_MACRO_EVT_SSR_UP,
Aditya Bavanaric4e96122018-11-14 14:46:38 +053046 BOLERO_MACRO_EVT_WAIT_VA_CLK_RESET,
Meng Wang8ef0cc22019-05-08 15:12:56 +080047 BOLERO_MACRO_EVT_CLK_RESET,
Karthikeyan Manic14c27a2019-06-21 14:11:34 -070048 BOLERO_MACRO_EVT_REG_WAKE_IRQ,
Vatsal Buchad06525f2019-10-14 23:14:12 +053049 BOLERO_MACRO_EVT_RX_COMPANDER_SOFT_RST,
50 BOLERO_MACRO_EVT_BCS_CLK_OFF
Laxminath Kasam497a6512018-09-17 16:11:52 +053051};
52
Sudheer Papothid50a5812019-11-21 07:24:42 +053053enum {
54 DMIC_TX = 0,
55 DMIC_VA = 1,
56
57};
58
59enum {
60 DMIC0 = 0,
61 DMIC1,
62 DMIC2,
63 DMIC3,
64 DMIC4,
65 DMIC5,
66 DMIC6,
67 DMIC7,
68 DMIC_MAX
69};
70
Laxminath Kasame562a362018-04-12 00:39:08 +053071struct macro_ops {
Meng Wang15c825d2018-09-06 10:49:18 +080072 int (*init)(struct snd_soc_component *component);
73 int (*exit)(struct snd_soc_component *component);
Laxminath Kasame562a362018-04-12 00:39:08 +053074 u16 num_dais;
75 struct device *dev;
76 struct snd_soc_dai_driver *dai_ptr;
77 int (*mclk_fn)(struct device *dev, bool enable);
Meng Wang15c825d2018-09-06 10:49:18 +080078 int (*event_handler)(struct snd_soc_component *component, u16 event,
Laxminath Kasam497a6512018-09-17 16:11:52 +053079 u32 data);
Meng Wang15c825d2018-09-06 10:49:18 +080080 int (*reg_wake_irq)(struct snd_soc_component *component, u32 data);
Sudheer Papothia3e969d2018-10-27 06:22:10 +053081 int (*set_port_map)(struct snd_soc_component *component, u32 uc,
82 u32 size, void *data);
Sudheer Papothi6cc7f522019-06-28 11:04:03 +053083 int (*clk_switch)(struct snd_soc_component *component);
Sudheer Papothid50a5812019-11-21 07:24:42 +053084 int (*clk_div_get)(struct snd_soc_component *component);
Sudheer Papothi06a4c642019-08-08 05:17:46 +053085 int (*reg_evt_listener)(struct snd_soc_component *component, bool en);
Laxminath Kasame562a362018-04-12 00:39:08 +053086 char __iomem *io_base;
Vidyakumar Athota5d45f4c2019-03-10 22:35:07 -070087 u16 clk_id_req;
88 u16 default_clk_id;
Laxminath Kasame562a362018-04-12 00:39:08 +053089};
90
Vidyakumar Athota5d45f4c2019-03-10 22:35:07 -070091typedef int (*rsc_clk_cb_t)(struct device *dev, u16 event);
92
Laxminath Kasame562a362018-04-12 00:39:08 +053093#if IS_ENABLED(CONFIG_SND_SOC_BOLERO)
Vidyakumar Athota5d45f4c2019-03-10 22:35:07 -070094int bolero_register_res_clk(struct device *dev, rsc_clk_cb_t cb);
95void bolero_unregister_res_clk(struct device *dev);
Laxminath Kasame562a362018-04-12 00:39:08 +053096int bolero_register_macro(struct device *dev, u16 macro_id,
97 struct macro_ops *ops);
98void bolero_unregister_macro(struct device *dev, u16 macro_id);
99struct device *bolero_get_device_ptr(struct device *dev, u16 macro_id);
Vidyakumar Athota5d45f4c2019-03-10 22:35:07 -0700100struct device *bolero_get_rsc_clk_device_ptr(struct device *dev);
Laxminath Kasam21c8b222018-06-21 18:47:22 +0530101int bolero_info_create_codec_entry(
102 struct snd_info_entry *codec_root,
Meng Wang15c825d2018-09-06 10:49:18 +0800103 struct snd_soc_component *component);
104int bolero_register_wake_irq(struct snd_soc_component *component, u32 data);
Laxminath Kasam497a6512018-09-17 16:11:52 +0530105void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n);
Mangesh Kunchamwar920015c2018-11-13 16:16:35 +0530106int bolero_runtime_resume(struct device *dev);
107int bolero_runtime_suspend(struct device *dev);
Sudheer Papothia3e969d2018-10-27 06:22:10 +0530108int bolero_set_port_map(struct snd_soc_component *component, u32 size, void *data);
Sudheer Papothi6cc7f522019-06-28 11:04:03 +0530109int bolero_tx_clk_switch(struct snd_soc_component *component);
Sudheer Papothi06a4c642019-08-08 05:17:46 +0530110int bolero_register_event_listener(struct snd_soc_component *component,
111 bool enable);
Laxminath Kasam069df142019-09-17 23:43:34 +0530112void bolero_wsa_pa_on(struct device *dev);
Aditya Bavanarid577af92019-10-03 21:09:19 +0530113bool bolero_check_core_votes(struct device *dev);
Laxminath Kasamf1623022019-10-11 18:20:19 +0530114int bolero_get_version(struct device *dev);
Sudheer Papothid50a5812019-11-21 07:24:42 +0530115int bolero_dmic_clk_enable(struct snd_soc_component *component,
116 u32 dmic, u32 tx_mode, bool enable);
Laxminath Kasame562a362018-04-12 00:39:08 +0530117#else
Vidyakumar Athota5d45f4c2019-03-10 22:35:07 -0700118static inline int bolero_register_res_clk(struct device *dev, rsc_clk_cb_t cb)
119{
120 return 0;
121}
122static inline void bolero_unregister_res_clk(struct device *dev)
123{
124}
125
Laxminath Kasame562a362018-04-12 00:39:08 +0530126static inline int bolero_register_macro(struct device *dev,
127 u16 macro_id,
128 struct macro_ops *ops)
129{
130 return 0;
131}
132
133static inline void bolero_unregister_macro(struct device *dev, u16 macro_id)
134{
135}
136
137static inline struct device *bolero_get_device_ptr(struct device *dev,
Laxminath Kasam2df2d612018-05-22 15:45:42 +0530138 u16 macro_id)
Laxminath Kasame562a362018-04-12 00:39:08 +0530139{
140 return NULL;
141}
Laxminath Kasam21c8b222018-06-21 18:47:22 +0530142
Laxminath Kasam21c8b222018-06-21 18:47:22 +0530143static int bolero_info_create_codec_entry(
144 struct snd_info_entry *codec_root,
Meng Wang15c825d2018-09-06 10:49:18 +0800145 struct snd_soc_component *component)
Laxminath Kasam21c8b222018-06-21 18:47:22 +0530146{
147 return 0;
148}
Laxminath Kasam497a6512018-09-17 16:11:52 +0530149
150static inline void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n)
151{
152}
Aditya Bavanaric4e96122018-11-14 14:46:38 +0530153
Meng Wang15c825d2018-09-06 10:49:18 +0800154static inline int bolero_register_wake_irq(struct snd_soc_component *component,
Aditya Bavanaric4e96122018-11-14 14:46:38 +0530155 u32 data)
Sudheer Papothia3e969d2018-10-27 06:22:10 +0530156{
157 return 0;
158}
159
Mangesh Kunchamwar920015c2018-11-13 16:16:35 +0530160static inline int bolero_runtime_resume(struct device *dev)
161{
162 return 0;
163}
Sudheer Papothia3e969d2018-10-27 06:22:10 +0530164
Mangesh Kunchamwar920015c2018-11-13 16:16:35 +0530165static int bolero_runtime_suspend(struct device *dev)
Aditya Bavanaric4e96122018-11-14 14:46:38 +0530166{
167 return 0;
168}
Sudheer Papothia3e969d2018-10-27 06:22:10 +0530169
170static inline int bolero_set_port_map(struct snd_soc_component *component,
171 u32 size, void *data)
172{
173 return 0;
174}
Sudheer Papothi6cc7f522019-06-28 11:04:03 +0530175
176static inline int bolero_tx_clk_switch(struct snd_soc_component *component)
177{
178 return 0;
179}
180
Sudheer Papothi06a4c642019-08-08 05:17:46 +0530181static inline int bolero_register_event_listener(
182 struct snd_soc_component *component,
183 bool enable)
184{
185 return 0;
186}
187
Laxminath Kasam069df142019-09-17 23:43:34 +0530188static void bolero_wsa_pa_on(struct device *dev)
189{
190}
Aditya Bavanarid577af92019-10-03 21:09:19 +0530191
192static inline bool bolero_check_core_votes(struct device *dev)
193{
194 return false;
195}
Laxminath Kasamf1623022019-10-11 18:20:19 +0530196
197static int bolero_get_version(struct device *dev)
198{
199 return 0;
200}
Sudheer Papothid50a5812019-11-21 07:24:42 +0530201
202static int bolero_dmic_clk_enable(struct snd_soc_component *component,
203 u32 dmic, u32 tx_mode, bool enable)
204{
205 return 0;
206}
Laxminath Kasame562a362018-04-12 00:39:08 +0530207#endif /* CONFIG_SND_SOC_BOLERO */
208#endif /* BOLERO_CDC_H */