blob: 8a74e79f542e01834686dbd70d62ad04f95c5559 [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
11enum {
12 START_MACRO,
13 TX_MACRO = START_MACRO,
14 RX_MACRO,
15 WSA_MACRO,
16 VA_MACRO,
17 MAX_MACRO
18};
19
Laxminath Kasam2df2d612018-05-22 15:45:42 +053020enum mclk_mux {
21 MCLK_MUX0,
22 MCLK_MUX1,
23 MCLK_MUX_MAX
24};
25
Laxminath Kasam497a6512018-09-17 16:11:52 +053026enum {
27 BOLERO_ADC0 = 1,
28 BOLERO_ADC1,
29 BOLERO_ADC2,
30 BOLERO_ADC3,
31 BOLERO_ADC_MAX
32};
33
34enum {
35 BOLERO_MACRO_EVT_RX_MUTE = 1, /* for RX mute/unmute */
36 BOLERO_MACRO_EVT_IMPED_TRUE, /* for imped true */
37 BOLERO_MACRO_EVT_IMPED_FALSE, /* for imped false */
Laxminath Kasamfb0d6832018-09-22 01:49:52 +053038 BOLERO_MACRO_EVT_SSR_DOWN,
39 BOLERO_MACRO_EVT_SSR_UP,
Aditya Bavanaric4e96122018-11-14 14:46:38 +053040 BOLERO_MACRO_EVT_WAIT_VA_CLK_RESET,
Meng Wang8ef0cc22019-05-08 15:12:56 +080041 BOLERO_MACRO_EVT_CLK_RESET,
Karthikeyan Manic14c27a2019-06-21 14:11:34 -070042 BOLERO_MACRO_EVT_REG_WAKE_IRQ,
43 BOLERO_MACRO_EVT_RX_COMPANDER_SOFT_RST
Laxminath Kasam497a6512018-09-17 16:11:52 +053044};
45
Laxminath Kasame562a362018-04-12 00:39:08 +053046struct macro_ops {
Meng Wang15c825d2018-09-06 10:49:18 +080047 int (*init)(struct snd_soc_component *component);
48 int (*exit)(struct snd_soc_component *component);
Laxminath Kasame562a362018-04-12 00:39:08 +053049 u16 num_dais;
50 struct device *dev;
51 struct snd_soc_dai_driver *dai_ptr;
52 int (*mclk_fn)(struct device *dev, bool enable);
Meng Wang15c825d2018-09-06 10:49:18 +080053 int (*event_handler)(struct snd_soc_component *component, u16 event,
Laxminath Kasam497a6512018-09-17 16:11:52 +053054 u32 data);
Meng Wang15c825d2018-09-06 10:49:18 +080055 int (*reg_wake_irq)(struct snd_soc_component *component, u32 data);
Sudheer Papothia3e969d2018-10-27 06:22:10 +053056 int (*set_port_map)(struct snd_soc_component *component, u32 uc,
57 u32 size, void *data);
Sudheer Papothi6cc7f522019-06-28 11:04:03 +053058 int (*clk_switch)(struct snd_soc_component *component);
Sudheer Papothi06a4c642019-08-08 05:17:46 +053059 int (*reg_evt_listener)(struct snd_soc_component *component, bool en);
Laxminath Kasame562a362018-04-12 00:39:08 +053060 char __iomem *io_base;
Vidyakumar Athota5d45f4c2019-03-10 22:35:07 -070061 u16 clk_id_req;
62 u16 default_clk_id;
Laxminath Kasame562a362018-04-12 00:39:08 +053063};
64
Vidyakumar Athota5d45f4c2019-03-10 22:35:07 -070065typedef int (*rsc_clk_cb_t)(struct device *dev, u16 event);
66
Laxminath Kasame562a362018-04-12 00:39:08 +053067#if IS_ENABLED(CONFIG_SND_SOC_BOLERO)
Vidyakumar Athota5d45f4c2019-03-10 22:35:07 -070068int bolero_register_res_clk(struct device *dev, rsc_clk_cb_t cb);
69void bolero_unregister_res_clk(struct device *dev);
Laxminath Kasame562a362018-04-12 00:39:08 +053070int bolero_register_macro(struct device *dev, u16 macro_id,
71 struct macro_ops *ops);
72void bolero_unregister_macro(struct device *dev, u16 macro_id);
73struct device *bolero_get_device_ptr(struct device *dev, u16 macro_id);
Vidyakumar Athota5d45f4c2019-03-10 22:35:07 -070074struct device *bolero_get_rsc_clk_device_ptr(struct device *dev);
Laxminath Kasam21c8b222018-06-21 18:47:22 +053075int bolero_info_create_codec_entry(
76 struct snd_info_entry *codec_root,
Meng Wang15c825d2018-09-06 10:49:18 +080077 struct snd_soc_component *component);
78int bolero_register_wake_irq(struct snd_soc_component *component, u32 data);
Laxminath Kasam497a6512018-09-17 16:11:52 +053079void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n);
Mangesh Kunchamwar920015c2018-11-13 16:16:35 +053080int bolero_runtime_resume(struct device *dev);
81int bolero_runtime_suspend(struct device *dev);
Sudheer Papothia3e969d2018-10-27 06:22:10 +053082int bolero_set_port_map(struct snd_soc_component *component, u32 size, void *data);
Sudheer Papothi6cc7f522019-06-28 11:04:03 +053083int bolero_tx_clk_switch(struct snd_soc_component *component);
Sudheer Papothi06a4c642019-08-08 05:17:46 +053084int bolero_register_event_listener(struct snd_soc_component *component,
85 bool enable);
Laxminath Kasame562a362018-04-12 00:39:08 +053086#else
Vidyakumar Athota5d45f4c2019-03-10 22:35:07 -070087static inline int bolero_register_res_clk(struct device *dev, rsc_clk_cb_t cb)
88{
89 return 0;
90}
91static inline void bolero_unregister_res_clk(struct device *dev)
92{
93}
94
Laxminath Kasame562a362018-04-12 00:39:08 +053095static inline int bolero_register_macro(struct device *dev,
96 u16 macro_id,
97 struct macro_ops *ops)
98{
99 return 0;
100}
101
102static inline void bolero_unregister_macro(struct device *dev, u16 macro_id)
103{
104}
105
106static inline struct device *bolero_get_device_ptr(struct device *dev,
Laxminath Kasam2df2d612018-05-22 15:45:42 +0530107 u16 macro_id)
Laxminath Kasame562a362018-04-12 00:39:08 +0530108{
109 return NULL;
110}
Laxminath Kasam21c8b222018-06-21 18:47:22 +0530111
Laxminath Kasam21c8b222018-06-21 18:47:22 +0530112static int bolero_info_create_codec_entry(
113 struct snd_info_entry *codec_root,
Meng Wang15c825d2018-09-06 10:49:18 +0800114 struct snd_soc_component *component)
Laxminath Kasam21c8b222018-06-21 18:47:22 +0530115{
116 return 0;
117}
Laxminath Kasam497a6512018-09-17 16:11:52 +0530118
119static inline void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n)
120{
121}
Aditya Bavanaric4e96122018-11-14 14:46:38 +0530122
Meng Wang15c825d2018-09-06 10:49:18 +0800123static inline int bolero_register_wake_irq(struct snd_soc_component *component,
Aditya Bavanaric4e96122018-11-14 14:46:38 +0530124 u32 data)
Sudheer Papothia3e969d2018-10-27 06:22:10 +0530125{
126 return 0;
127}
128
Mangesh Kunchamwar920015c2018-11-13 16:16:35 +0530129static inline int bolero_runtime_resume(struct device *dev)
130{
131 return 0;
132}
Sudheer Papothia3e969d2018-10-27 06:22:10 +0530133
Mangesh Kunchamwar920015c2018-11-13 16:16:35 +0530134static int bolero_runtime_suspend(struct device *dev)
Aditya Bavanaric4e96122018-11-14 14:46:38 +0530135{
136 return 0;
137}
Sudheer Papothia3e969d2018-10-27 06:22:10 +0530138
139static inline int bolero_set_port_map(struct snd_soc_component *component,
140 u32 size, void *data)
141{
142 return 0;
143}
Sudheer Papothi6cc7f522019-06-28 11:04:03 +0530144
145static inline int bolero_tx_clk_switch(struct snd_soc_component *component)
146{
147 return 0;
148}
149
Sudheer Papothi06a4c642019-08-08 05:17:46 +0530150static inline int bolero_register_event_listener(
151 struct snd_soc_component *component,
152 bool enable)
153{
154 return 0;
155}
156
Laxminath Kasame562a362018-04-12 00:39:08 +0530157#endif /* CONFIG_SND_SOC_BOLERO */
158#endif /* BOLERO_CDC_H */