blob: 48f6cd3cd7f6d5dccff488b50acedefb7e0ce7dd [file] [log] [blame]
Meng Wang43bbb872018-12-10 12:32:05 +08001/* SPDX-License-Identifier: GPL-2.0-only */
Sudheer Papothif4155002019-12-05 01:36:13 +05302/* Copyright (c) 2018-2020, 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 {
Sudheer Papothif4155002019-12-05 01:36:13 +053041 CLK_SRC_TX_RCG = 0,
42 CLK_SRC_VA_RCG,
43};
44
45enum {
Laxminath Kasam497a6512018-09-17 16:11:52 +053046 BOLERO_MACRO_EVT_RX_MUTE = 1, /* for RX mute/unmute */
47 BOLERO_MACRO_EVT_IMPED_TRUE, /* for imped true */
48 BOLERO_MACRO_EVT_IMPED_FALSE, /* for imped false */
Laxminath Kasamfb0d6832018-09-22 01:49:52 +053049 BOLERO_MACRO_EVT_SSR_DOWN,
50 BOLERO_MACRO_EVT_SSR_UP,
Aditya Bavanaric4e96122018-11-14 14:46:38 +053051 BOLERO_MACRO_EVT_WAIT_VA_CLK_RESET,
Meng Wang8ef0cc22019-05-08 15:12:56 +080052 BOLERO_MACRO_EVT_CLK_RESET,
Karthikeyan Manic14c27a2019-06-21 14:11:34 -070053 BOLERO_MACRO_EVT_REG_WAKE_IRQ,
Vatsal Buchad06525f2019-10-14 23:14:12 +053054 BOLERO_MACRO_EVT_RX_COMPANDER_SOFT_RST,
Aditya Bavanarib258e092020-01-20 20:38:05 +053055 BOLERO_MACRO_EVT_BCS_CLK_OFF,
56 BOLERO_MACRO_EVT_SSR_GFMUX_UP,
Prasad Kumpatlaefdb3932020-05-13 18:55:32 +053057 BOLERO_MACRO_EVT_PRE_SSR_UP,
Vatsal Bucha8203a062020-07-17 19:13:19 +053058 BOLERO_MACRO_EVT_RX_PA_GAIN_UPDATE,
Vatsal Bucha4b3e5232020-07-14 05:33:06 +053059 BOLERO_MACRO_EVT_HPHL_HD2_ENABLE, /* Enable HD2 cfg for HPHL */
60 BOLERO_MACRO_EVT_HPHR_HD2_ENABLE, /* Enable HD2 cfg for HPHR */
Laxminath Kasam497a6512018-09-17 16:11:52 +053061};
62
Sudheer Papothid50a5812019-11-21 07:24:42 +053063enum {
64 DMIC_TX = 0,
65 DMIC_VA = 1,
66
67};
68
69enum {
70 DMIC0 = 0,
71 DMIC1,
72 DMIC2,
73 DMIC3,
74 DMIC4,
75 DMIC5,
76 DMIC6,
77 DMIC7,
78 DMIC_MAX
79};
80
Laxminath Kasame562a362018-04-12 00:39:08 +053081struct macro_ops {
Meng Wang15c825d2018-09-06 10:49:18 +080082 int (*init)(struct snd_soc_component *component);
83 int (*exit)(struct snd_soc_component *component);
Laxminath Kasame562a362018-04-12 00:39:08 +053084 u16 num_dais;
85 struct device *dev;
86 struct snd_soc_dai_driver *dai_ptr;
87 int (*mclk_fn)(struct device *dev, bool enable);
Meng Wang15c825d2018-09-06 10:49:18 +080088 int (*event_handler)(struct snd_soc_component *component, u16 event,
Laxminath Kasam497a6512018-09-17 16:11:52 +053089 u32 data);
Meng Wang15c825d2018-09-06 10:49:18 +080090 int (*reg_wake_irq)(struct snd_soc_component *component, u32 data);
Sudheer Papothia3e969d2018-10-27 06:22:10 +053091 int (*set_port_map)(struct snd_soc_component *component, u32 uc,
92 u32 size, void *data);
Sudheer Papothid50a5812019-11-21 07:24:42 +053093 int (*clk_div_get)(struct snd_soc_component *component);
Sudheer Papothif4155002019-12-05 01:36:13 +053094 int (*clk_switch)(struct snd_soc_component *component, int clk_src);
Laxminath Kasam2ffc69e2020-06-16 20:15:26 +053095 int (*reg_evt_listener)(struct snd_soc_component *component, bool en);
Sudheer Papothifc3adb02019-11-24 10:14:21 +053096 int (*clk_enable)(struct snd_soc_component *c, bool en);
Laxminath Kasame562a362018-04-12 00:39:08 +053097 char __iomem *io_base;
Vidyakumar Athota5d45f4c2019-03-10 22:35:07 -070098 u16 clk_id_req;
99 u16 default_clk_id;
Laxminath Kasame562a362018-04-12 00:39:08 +0530100};
101
Vidyakumar Athota5d45f4c2019-03-10 22:35:07 -0700102typedef int (*rsc_clk_cb_t)(struct device *dev, u16 event);
103
Laxminath Kasame562a362018-04-12 00:39:08 +0530104#if IS_ENABLED(CONFIG_SND_SOC_BOLERO)
Vidyakumar Athota5d45f4c2019-03-10 22:35:07 -0700105int bolero_register_res_clk(struct device *dev, rsc_clk_cb_t cb);
106void bolero_unregister_res_clk(struct device *dev);
Laxminath Kasam251ce992020-07-01 23:37:33 +0530107bool bolero_is_va_macro_registered(struct device *dev);
Laxminath Kasame562a362018-04-12 00:39:08 +0530108int bolero_register_macro(struct device *dev, u16 macro_id,
109 struct macro_ops *ops);
110void bolero_unregister_macro(struct device *dev, u16 macro_id);
111struct device *bolero_get_device_ptr(struct device *dev, u16 macro_id);
Vidyakumar Athota5d45f4c2019-03-10 22:35:07 -0700112struct device *bolero_get_rsc_clk_device_ptr(struct device *dev);
Laxminath Kasam21c8b222018-06-21 18:47:22 +0530113int bolero_info_create_codec_entry(
114 struct snd_info_entry *codec_root,
Meng Wang15c825d2018-09-06 10:49:18 +0800115 struct snd_soc_component *component);
116int bolero_register_wake_irq(struct snd_soc_component *component, u32 data);
Laxminath Kasam497a6512018-09-17 16:11:52 +0530117void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n);
Mangesh Kunchamwar920015c2018-11-13 16:16:35 +0530118int bolero_runtime_resume(struct device *dev);
119int bolero_runtime_suspend(struct device *dev);
Sudheer Papothia3e969d2018-10-27 06:22:10 +0530120int bolero_set_port_map(struct snd_soc_component *component, u32 size, void *data);
Sudheer Papothif4155002019-12-05 01:36:13 +0530121int bolero_tx_clk_switch(struct snd_soc_component *component, int clk_src);
Sudheer Papothi06a4c642019-08-08 05:17:46 +0530122int bolero_register_event_listener(struct snd_soc_component *component,
Laxminath Kasam2ffc69e2020-06-16 20:15:26 +0530123 bool enable);
Laxminath Kasam2fe71f52020-05-15 00:39:51 +0530124void bolero_wsa_pa_on(struct device *dev, bool adie_lb);
Aditya Bavanarid577af92019-10-03 21:09:19 +0530125bool bolero_check_core_votes(struct device *dev);
Sudheer Papothifc3adb02019-11-24 10:14:21 +0530126int bolero_tx_mclk_enable(struct snd_soc_component *c, bool enable);
Laxminath Kasamf1623022019-10-11 18:20:19 +0530127int bolero_get_version(struct device *dev);
Sudheer Papothid50a5812019-11-21 07:24:42 +0530128int bolero_dmic_clk_enable(struct snd_soc_component *component,
129 u32 dmic, u32 tx_mode, bool enable);
Laxminath Kasame562a362018-04-12 00:39:08 +0530130#else
Vidyakumar Athota5d45f4c2019-03-10 22:35:07 -0700131static inline int bolero_register_res_clk(struct device *dev, rsc_clk_cb_t cb)
132{
133 return 0;
134}
135static inline void bolero_unregister_res_clk(struct device *dev)
136{
137}
138
Laxminath Kasam251ce992020-07-01 23:37:33 +0530139static bool bolero_is_va_macro_registered(struct device *dev)
140{
141 return false;
142}
143
Laxminath Kasame562a362018-04-12 00:39:08 +0530144static inline int bolero_register_macro(struct device *dev,
145 u16 macro_id,
146 struct macro_ops *ops)
147{
148 return 0;
149}
150
151static inline void bolero_unregister_macro(struct device *dev, u16 macro_id)
152{
153}
154
155static inline struct device *bolero_get_device_ptr(struct device *dev,
Laxminath Kasam2df2d612018-05-22 15:45:42 +0530156 u16 macro_id)
Laxminath Kasame562a362018-04-12 00:39:08 +0530157{
158 return NULL;
159}
Laxminath Kasam21c8b222018-06-21 18:47:22 +0530160
Laxminath Kasam21c8b222018-06-21 18:47:22 +0530161static int bolero_info_create_codec_entry(
162 struct snd_info_entry *codec_root,
Meng Wang15c825d2018-09-06 10:49:18 +0800163 struct snd_soc_component *component)
Laxminath Kasam21c8b222018-06-21 18:47:22 +0530164{
165 return 0;
166}
Laxminath Kasam497a6512018-09-17 16:11:52 +0530167
168static inline void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n)
169{
170}
Aditya Bavanaric4e96122018-11-14 14:46:38 +0530171
Meng Wang15c825d2018-09-06 10:49:18 +0800172static inline int bolero_register_wake_irq(struct snd_soc_component *component,
Aditya Bavanaric4e96122018-11-14 14:46:38 +0530173 u32 data)
Sudheer Papothia3e969d2018-10-27 06:22:10 +0530174{
175 return 0;
176}
177
Mangesh Kunchamwar920015c2018-11-13 16:16:35 +0530178static inline int bolero_runtime_resume(struct device *dev)
179{
180 return 0;
181}
Sudheer Papothia3e969d2018-10-27 06:22:10 +0530182
Mangesh Kunchamwar920015c2018-11-13 16:16:35 +0530183static int bolero_runtime_suspend(struct device *dev)
Aditya Bavanaric4e96122018-11-14 14:46:38 +0530184{
185 return 0;
186}
Sudheer Papothia3e969d2018-10-27 06:22:10 +0530187
188static inline int bolero_set_port_map(struct snd_soc_component *component,
189 u32 size, void *data)
190{
191 return 0;
192}
Sudheer Papothi6cc7f522019-06-28 11:04:03 +0530193
Sudheer Papothif4155002019-12-05 01:36:13 +0530194static inline int bolero_tx_clk_switch(struct snd_soc_component *component,
195 int clk_src)
Sudheer Papothi6cc7f522019-06-28 11:04:03 +0530196{
197 return 0;
198}
199
Sudheer Papothi06a4c642019-08-08 05:17:46 +0530200static inline int bolero_register_event_listener(
201 struct snd_soc_component *component,
Laxminath Kasam2ffc69e2020-06-16 20:15:26 +0530202 bool enable)
Sudheer Papothi06a4c642019-08-08 05:17:46 +0530203{
204 return 0;
205}
206
Laxminath Kasam2fe71f52020-05-15 00:39:51 +0530207static void bolero_wsa_pa_on(struct device *dev, bool adie_lb)
Laxminath Kasam069df142019-09-17 23:43:34 +0530208{
209}
Aditya Bavanarid577af92019-10-03 21:09:19 +0530210
211static inline bool bolero_check_core_votes(struct device *dev)
212{
213 return false;
214}
Laxminath Kasamf1623022019-10-11 18:20:19 +0530215
216static int bolero_get_version(struct device *dev)
217{
218 return 0;
219}
Sudheer Papothid50a5812019-11-21 07:24:42 +0530220
221static int bolero_dmic_clk_enable(struct snd_soc_component *component,
222 u32 dmic, u32 tx_mode, bool enable)
223{
224 return 0;
225}
Sudheer Papothifc3adb02019-11-24 10:14:21 +0530226static int bolero_tx_mclk_enable(struct snd_soc_component *c, bool enable)
227{
228 return 0;
229}
Laxminath Kasame562a362018-04-12 00:39:08 +0530230#endif /* CONFIG_SND_SOC_BOLERO */
231#endif /* BOLERO_CDC_H */