blob: b37eeae6e15c895e092e4483568f2dafbb05668b [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,
Laxminath Kasam497a6512018-09-17 16:11:52 +053057};
58
Sudheer Papothid50a5812019-11-21 07:24:42 +053059enum {
60 DMIC_TX = 0,
61 DMIC_VA = 1,
62
63};
64
65enum {
66 DMIC0 = 0,
67 DMIC1,
68 DMIC2,
69 DMIC3,
70 DMIC4,
71 DMIC5,
72 DMIC6,
73 DMIC7,
74 DMIC_MAX
75};
76
Laxminath Kasame562a362018-04-12 00:39:08 +053077struct macro_ops {
Meng Wang15c825d2018-09-06 10:49:18 +080078 int (*init)(struct snd_soc_component *component);
79 int (*exit)(struct snd_soc_component *component);
Laxminath Kasame562a362018-04-12 00:39:08 +053080 u16 num_dais;
81 struct device *dev;
82 struct snd_soc_dai_driver *dai_ptr;
83 int (*mclk_fn)(struct device *dev, bool enable);
Meng Wang15c825d2018-09-06 10:49:18 +080084 int (*event_handler)(struct snd_soc_component *component, u16 event,
Laxminath Kasam497a6512018-09-17 16:11:52 +053085 u32 data);
Meng Wang15c825d2018-09-06 10:49:18 +080086 int (*reg_wake_irq)(struct snd_soc_component *component, u32 data);
Sudheer Papothia3e969d2018-10-27 06:22:10 +053087 int (*set_port_map)(struct snd_soc_component *component, u32 uc,
88 u32 size, void *data);
Sudheer Papothid50a5812019-11-21 07:24:42 +053089 int (*clk_div_get)(struct snd_soc_component *component);
Sudheer Papothif4155002019-12-05 01:36:13 +053090 int (*clk_switch)(struct snd_soc_component *component, int clk_src);
Sudheer Papothi06a4c642019-08-08 05:17:46 +053091 int (*reg_evt_listener)(struct snd_soc_component *component, bool en);
Sudheer Papothifc3adb02019-11-24 10:14:21 +053092 int (*clk_enable)(struct snd_soc_component *c, bool en);
Laxminath Kasame562a362018-04-12 00:39:08 +053093 char __iomem *io_base;
Vidyakumar Athota5d45f4c2019-03-10 22:35:07 -070094 u16 clk_id_req;
95 u16 default_clk_id;
Laxminath Kasame562a362018-04-12 00:39:08 +053096};
97
Vidyakumar Athota5d45f4c2019-03-10 22:35:07 -070098typedef int (*rsc_clk_cb_t)(struct device *dev, u16 event);
99
Laxminath Kasame562a362018-04-12 00:39:08 +0530100#if IS_ENABLED(CONFIG_SND_SOC_BOLERO)
Vidyakumar Athota5d45f4c2019-03-10 22:35:07 -0700101int bolero_register_res_clk(struct device *dev, rsc_clk_cb_t cb);
102void bolero_unregister_res_clk(struct device *dev);
Laxminath Kasame562a362018-04-12 00:39:08 +0530103int bolero_register_macro(struct device *dev, u16 macro_id,
104 struct macro_ops *ops);
105void bolero_unregister_macro(struct device *dev, u16 macro_id);
106struct device *bolero_get_device_ptr(struct device *dev, u16 macro_id);
Vidyakumar Athota5d45f4c2019-03-10 22:35:07 -0700107struct device *bolero_get_rsc_clk_device_ptr(struct device *dev);
Laxminath Kasam21c8b222018-06-21 18:47:22 +0530108int bolero_info_create_codec_entry(
109 struct snd_info_entry *codec_root,
Meng Wang15c825d2018-09-06 10:49:18 +0800110 struct snd_soc_component *component);
111int bolero_register_wake_irq(struct snd_soc_component *component, u32 data);
Laxminath Kasam497a6512018-09-17 16:11:52 +0530112void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n);
Mangesh Kunchamwar920015c2018-11-13 16:16:35 +0530113int bolero_runtime_resume(struct device *dev);
114int bolero_runtime_suspend(struct device *dev);
Sudheer Papothia3e969d2018-10-27 06:22:10 +0530115int bolero_set_port_map(struct snd_soc_component *component, u32 size, void *data);
Sudheer Papothif4155002019-12-05 01:36:13 +0530116int bolero_tx_clk_switch(struct snd_soc_component *component, int clk_src);
Sudheer Papothi06a4c642019-08-08 05:17:46 +0530117int bolero_register_event_listener(struct snd_soc_component *component,
118 bool enable);
Laxminath Kasam069df142019-09-17 23:43:34 +0530119void bolero_wsa_pa_on(struct device *dev);
Aditya Bavanarid577af92019-10-03 21:09:19 +0530120bool bolero_check_core_votes(struct device *dev);
Sudheer Papothifc3adb02019-11-24 10:14:21 +0530121int bolero_tx_mclk_enable(struct snd_soc_component *c, bool enable);
Laxminath Kasamf1623022019-10-11 18:20:19 +0530122int bolero_get_version(struct device *dev);
Sudheer Papothid50a5812019-11-21 07:24:42 +0530123int bolero_dmic_clk_enable(struct snd_soc_component *component,
124 u32 dmic, u32 tx_mode, bool enable);
Laxminath Kasame562a362018-04-12 00:39:08 +0530125#else
Vidyakumar Athota5d45f4c2019-03-10 22:35:07 -0700126static inline int bolero_register_res_clk(struct device *dev, rsc_clk_cb_t cb)
127{
128 return 0;
129}
130static inline void bolero_unregister_res_clk(struct device *dev)
131{
132}
133
Laxminath Kasame562a362018-04-12 00:39:08 +0530134static inline int bolero_register_macro(struct device *dev,
135 u16 macro_id,
136 struct macro_ops *ops)
137{
138 return 0;
139}
140
141static inline void bolero_unregister_macro(struct device *dev, u16 macro_id)
142{
143}
144
145static inline struct device *bolero_get_device_ptr(struct device *dev,
Laxminath Kasam2df2d612018-05-22 15:45:42 +0530146 u16 macro_id)
Laxminath Kasame562a362018-04-12 00:39:08 +0530147{
148 return NULL;
149}
Laxminath Kasam21c8b222018-06-21 18:47:22 +0530150
Laxminath Kasam21c8b222018-06-21 18:47:22 +0530151static int bolero_info_create_codec_entry(
152 struct snd_info_entry *codec_root,
Meng Wang15c825d2018-09-06 10:49:18 +0800153 struct snd_soc_component *component)
Laxminath Kasam21c8b222018-06-21 18:47:22 +0530154{
155 return 0;
156}
Laxminath Kasam497a6512018-09-17 16:11:52 +0530157
158static inline void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n)
159{
160}
Aditya Bavanaric4e96122018-11-14 14:46:38 +0530161
Meng Wang15c825d2018-09-06 10:49:18 +0800162static inline int bolero_register_wake_irq(struct snd_soc_component *component,
Aditya Bavanaric4e96122018-11-14 14:46:38 +0530163 u32 data)
Sudheer Papothia3e969d2018-10-27 06:22:10 +0530164{
165 return 0;
166}
167
Mangesh Kunchamwar920015c2018-11-13 16:16:35 +0530168static inline int bolero_runtime_resume(struct device *dev)
169{
170 return 0;
171}
Sudheer Papothia3e969d2018-10-27 06:22:10 +0530172
Mangesh Kunchamwar920015c2018-11-13 16:16:35 +0530173static int bolero_runtime_suspend(struct device *dev)
Aditya Bavanaric4e96122018-11-14 14:46:38 +0530174{
175 return 0;
176}
Sudheer Papothia3e969d2018-10-27 06:22:10 +0530177
178static inline int bolero_set_port_map(struct snd_soc_component *component,
179 u32 size, void *data)
180{
181 return 0;
182}
Sudheer Papothi6cc7f522019-06-28 11:04:03 +0530183
Sudheer Papothif4155002019-12-05 01:36:13 +0530184static inline int bolero_tx_clk_switch(struct snd_soc_component *component,
185 int clk_src)
Sudheer Papothi6cc7f522019-06-28 11:04:03 +0530186{
187 return 0;
188}
189
Sudheer Papothi06a4c642019-08-08 05:17:46 +0530190static inline int bolero_register_event_listener(
191 struct snd_soc_component *component,
192 bool enable)
193{
194 return 0;
195}
196
Laxminath Kasam069df142019-09-17 23:43:34 +0530197static void bolero_wsa_pa_on(struct device *dev)
198{
199}
Aditya Bavanarid577af92019-10-03 21:09:19 +0530200
201static inline bool bolero_check_core_votes(struct device *dev)
202{
203 return false;
204}
Laxminath Kasamf1623022019-10-11 18:20:19 +0530205
206static int bolero_get_version(struct device *dev)
207{
208 return 0;
209}
Sudheer Papothid50a5812019-11-21 07:24:42 +0530210
211static int bolero_dmic_clk_enable(struct snd_soc_component *component,
212 u32 dmic, u32 tx_mode, bool enable)
213{
214 return 0;
215}
Sudheer Papothifc3adb02019-11-24 10:14:21 +0530216static int bolero_tx_mclk_enable(struct snd_soc_component *c, bool enable)
217{
218 return 0;
219}
Laxminath Kasame562a362018-04-12 00:39:08 +0530220#endif /* CONFIG_SND_SOC_BOLERO */
221#endif /* BOLERO_CDC_H */