Meng Wang | 43bbb87 | 2018-12-10 12:32:05 +0800 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Sudheer Papothi | f415500 | 2019-12-05 01:36:13 +0530 | [diff] [blame] | 2 | /* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 3 | */ |
| 4 | |
| 5 | #ifndef BOLERO_CDC_H |
| 6 | #define BOLERO_CDC_H |
| 7 | |
| 8 | #include <sound/soc.h> |
| 9 | #include <linux/regmap.h> |
| 10 | |
Laxminath Kasam | f162302 | 2019-10-11 18:20:19 +0530 | [diff] [blame] | 11 | #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 Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 17 | enum { |
| 18 | START_MACRO, |
| 19 | TX_MACRO = START_MACRO, |
| 20 | RX_MACRO, |
| 21 | WSA_MACRO, |
| 22 | VA_MACRO, |
| 23 | MAX_MACRO |
| 24 | }; |
| 25 | |
Laxminath Kasam | 2df2d61 | 2018-05-22 15:45:42 +0530 | [diff] [blame] | 26 | enum mclk_mux { |
| 27 | MCLK_MUX0, |
| 28 | MCLK_MUX1, |
| 29 | MCLK_MUX_MAX |
| 30 | }; |
| 31 | |
Laxminath Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame] | 32 | enum { |
| 33 | BOLERO_ADC0 = 1, |
| 34 | BOLERO_ADC1, |
| 35 | BOLERO_ADC2, |
| 36 | BOLERO_ADC3, |
| 37 | BOLERO_ADC_MAX |
| 38 | }; |
| 39 | |
| 40 | enum { |
Sudheer Papothi | f415500 | 2019-12-05 01:36:13 +0530 | [diff] [blame] | 41 | CLK_SRC_TX_RCG = 0, |
| 42 | CLK_SRC_VA_RCG, |
| 43 | }; |
| 44 | |
| 45 | enum { |
Laxminath Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame] | 46 | 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 Kasam | fb0d683 | 2018-09-22 01:49:52 +0530 | [diff] [blame] | 49 | BOLERO_MACRO_EVT_SSR_DOWN, |
| 50 | BOLERO_MACRO_EVT_SSR_UP, |
Aditya Bavanari | c4e9612 | 2018-11-14 14:46:38 +0530 | [diff] [blame] | 51 | BOLERO_MACRO_EVT_WAIT_VA_CLK_RESET, |
Meng Wang | 8ef0cc2 | 2019-05-08 15:12:56 +0800 | [diff] [blame] | 52 | BOLERO_MACRO_EVT_CLK_RESET, |
Karthikeyan Mani | c14c27a | 2019-06-21 14:11:34 -0700 | [diff] [blame] | 53 | BOLERO_MACRO_EVT_REG_WAKE_IRQ, |
Vatsal Bucha | d06525f | 2019-10-14 23:14:12 +0530 | [diff] [blame] | 54 | BOLERO_MACRO_EVT_RX_COMPANDER_SOFT_RST, |
Aditya Bavanari | b258e09 | 2020-01-20 20:38:05 +0530 | [diff] [blame^] | 55 | BOLERO_MACRO_EVT_BCS_CLK_OFF, |
| 56 | BOLERO_MACRO_EVT_SSR_GFMUX_UP, |
Laxminath Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame] | 57 | }; |
| 58 | |
Sudheer Papothi | d50a581 | 2019-11-21 07:24:42 +0530 | [diff] [blame] | 59 | enum { |
| 60 | DMIC_TX = 0, |
| 61 | DMIC_VA = 1, |
| 62 | |
| 63 | }; |
| 64 | |
| 65 | enum { |
| 66 | DMIC0 = 0, |
| 67 | DMIC1, |
| 68 | DMIC2, |
| 69 | DMIC3, |
| 70 | DMIC4, |
| 71 | DMIC5, |
| 72 | DMIC6, |
| 73 | DMIC7, |
| 74 | DMIC_MAX |
| 75 | }; |
| 76 | |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 77 | struct macro_ops { |
Meng Wang | 15c825d | 2018-09-06 10:49:18 +0800 | [diff] [blame] | 78 | int (*init)(struct snd_soc_component *component); |
| 79 | int (*exit)(struct snd_soc_component *component); |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 80 | 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 Wang | 15c825d | 2018-09-06 10:49:18 +0800 | [diff] [blame] | 84 | int (*event_handler)(struct snd_soc_component *component, u16 event, |
Laxminath Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame] | 85 | u32 data); |
Meng Wang | 15c825d | 2018-09-06 10:49:18 +0800 | [diff] [blame] | 86 | int (*reg_wake_irq)(struct snd_soc_component *component, u32 data); |
Sudheer Papothi | a3e969d | 2018-10-27 06:22:10 +0530 | [diff] [blame] | 87 | int (*set_port_map)(struct snd_soc_component *component, u32 uc, |
| 88 | u32 size, void *data); |
Sudheer Papothi | d50a581 | 2019-11-21 07:24:42 +0530 | [diff] [blame] | 89 | int (*clk_div_get)(struct snd_soc_component *component); |
Sudheer Papothi | f415500 | 2019-12-05 01:36:13 +0530 | [diff] [blame] | 90 | int (*clk_switch)(struct snd_soc_component *component, int clk_src); |
Sudheer Papothi | 06a4c64 | 2019-08-08 05:17:46 +0530 | [diff] [blame] | 91 | int (*reg_evt_listener)(struct snd_soc_component *component, bool en); |
Sudheer Papothi | fc3adb0 | 2019-11-24 10:14:21 +0530 | [diff] [blame] | 92 | int (*clk_enable)(struct snd_soc_component *c, bool en); |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 93 | char __iomem *io_base; |
Vidyakumar Athota | 5d45f4c | 2019-03-10 22:35:07 -0700 | [diff] [blame] | 94 | u16 clk_id_req; |
| 95 | u16 default_clk_id; |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 96 | }; |
| 97 | |
Vidyakumar Athota | 5d45f4c | 2019-03-10 22:35:07 -0700 | [diff] [blame] | 98 | typedef int (*rsc_clk_cb_t)(struct device *dev, u16 event); |
| 99 | |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 100 | #if IS_ENABLED(CONFIG_SND_SOC_BOLERO) |
Vidyakumar Athota | 5d45f4c | 2019-03-10 22:35:07 -0700 | [diff] [blame] | 101 | int bolero_register_res_clk(struct device *dev, rsc_clk_cb_t cb); |
| 102 | void bolero_unregister_res_clk(struct device *dev); |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 103 | int bolero_register_macro(struct device *dev, u16 macro_id, |
| 104 | struct macro_ops *ops); |
| 105 | void bolero_unregister_macro(struct device *dev, u16 macro_id); |
| 106 | struct device *bolero_get_device_ptr(struct device *dev, u16 macro_id); |
Vidyakumar Athota | 5d45f4c | 2019-03-10 22:35:07 -0700 | [diff] [blame] | 107 | struct device *bolero_get_rsc_clk_device_ptr(struct device *dev); |
Laxminath Kasam | 21c8b22 | 2018-06-21 18:47:22 +0530 | [diff] [blame] | 108 | int bolero_info_create_codec_entry( |
| 109 | struct snd_info_entry *codec_root, |
Meng Wang | 15c825d | 2018-09-06 10:49:18 +0800 | [diff] [blame] | 110 | struct snd_soc_component *component); |
| 111 | int bolero_register_wake_irq(struct snd_soc_component *component, u32 data); |
Laxminath Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame] | 112 | void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n); |
Mangesh Kunchamwar | 920015c | 2018-11-13 16:16:35 +0530 | [diff] [blame] | 113 | int bolero_runtime_resume(struct device *dev); |
| 114 | int bolero_runtime_suspend(struct device *dev); |
Sudheer Papothi | a3e969d | 2018-10-27 06:22:10 +0530 | [diff] [blame] | 115 | int bolero_set_port_map(struct snd_soc_component *component, u32 size, void *data); |
Sudheer Papothi | f415500 | 2019-12-05 01:36:13 +0530 | [diff] [blame] | 116 | int bolero_tx_clk_switch(struct snd_soc_component *component, int clk_src); |
Sudheer Papothi | 06a4c64 | 2019-08-08 05:17:46 +0530 | [diff] [blame] | 117 | int bolero_register_event_listener(struct snd_soc_component *component, |
| 118 | bool enable); |
Laxminath Kasam | 069df14 | 2019-09-17 23:43:34 +0530 | [diff] [blame] | 119 | void bolero_wsa_pa_on(struct device *dev); |
Aditya Bavanari | d577af9 | 2019-10-03 21:09:19 +0530 | [diff] [blame] | 120 | bool bolero_check_core_votes(struct device *dev); |
Sudheer Papothi | fc3adb0 | 2019-11-24 10:14:21 +0530 | [diff] [blame] | 121 | int bolero_tx_mclk_enable(struct snd_soc_component *c, bool enable); |
Laxminath Kasam | f162302 | 2019-10-11 18:20:19 +0530 | [diff] [blame] | 122 | int bolero_get_version(struct device *dev); |
Sudheer Papothi | d50a581 | 2019-11-21 07:24:42 +0530 | [diff] [blame] | 123 | int bolero_dmic_clk_enable(struct snd_soc_component *component, |
| 124 | u32 dmic, u32 tx_mode, bool enable); |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 125 | #else |
Vidyakumar Athota | 5d45f4c | 2019-03-10 22:35:07 -0700 | [diff] [blame] | 126 | static inline int bolero_register_res_clk(struct device *dev, rsc_clk_cb_t cb) |
| 127 | { |
| 128 | return 0; |
| 129 | } |
| 130 | static inline void bolero_unregister_res_clk(struct device *dev) |
| 131 | { |
| 132 | } |
| 133 | |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 134 | static inline int bolero_register_macro(struct device *dev, |
| 135 | u16 macro_id, |
| 136 | struct macro_ops *ops) |
| 137 | { |
| 138 | return 0; |
| 139 | } |
| 140 | |
| 141 | static inline void bolero_unregister_macro(struct device *dev, u16 macro_id) |
| 142 | { |
| 143 | } |
| 144 | |
| 145 | static inline struct device *bolero_get_device_ptr(struct device *dev, |
Laxminath Kasam | 2df2d61 | 2018-05-22 15:45:42 +0530 | [diff] [blame] | 146 | u16 macro_id) |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 147 | { |
| 148 | return NULL; |
| 149 | } |
Laxminath Kasam | 21c8b22 | 2018-06-21 18:47:22 +0530 | [diff] [blame] | 150 | |
Laxminath Kasam | 21c8b22 | 2018-06-21 18:47:22 +0530 | [diff] [blame] | 151 | static int bolero_info_create_codec_entry( |
| 152 | struct snd_info_entry *codec_root, |
Meng Wang | 15c825d | 2018-09-06 10:49:18 +0800 | [diff] [blame] | 153 | struct snd_soc_component *component) |
Laxminath Kasam | 21c8b22 | 2018-06-21 18:47:22 +0530 | [diff] [blame] | 154 | { |
| 155 | return 0; |
| 156 | } |
Laxminath Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame] | 157 | |
| 158 | static inline void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n) |
| 159 | { |
| 160 | } |
Aditya Bavanari | c4e9612 | 2018-11-14 14:46:38 +0530 | [diff] [blame] | 161 | |
Meng Wang | 15c825d | 2018-09-06 10:49:18 +0800 | [diff] [blame] | 162 | static inline int bolero_register_wake_irq(struct snd_soc_component *component, |
Aditya Bavanari | c4e9612 | 2018-11-14 14:46:38 +0530 | [diff] [blame] | 163 | u32 data) |
Sudheer Papothi | a3e969d | 2018-10-27 06:22:10 +0530 | [diff] [blame] | 164 | { |
| 165 | return 0; |
| 166 | } |
| 167 | |
Mangesh Kunchamwar | 920015c | 2018-11-13 16:16:35 +0530 | [diff] [blame] | 168 | static inline int bolero_runtime_resume(struct device *dev) |
| 169 | { |
| 170 | return 0; |
| 171 | } |
Sudheer Papothi | a3e969d | 2018-10-27 06:22:10 +0530 | [diff] [blame] | 172 | |
Mangesh Kunchamwar | 920015c | 2018-11-13 16:16:35 +0530 | [diff] [blame] | 173 | static int bolero_runtime_suspend(struct device *dev) |
Aditya Bavanari | c4e9612 | 2018-11-14 14:46:38 +0530 | [diff] [blame] | 174 | { |
| 175 | return 0; |
| 176 | } |
Sudheer Papothi | a3e969d | 2018-10-27 06:22:10 +0530 | [diff] [blame] | 177 | |
| 178 | static inline int bolero_set_port_map(struct snd_soc_component *component, |
| 179 | u32 size, void *data) |
| 180 | { |
| 181 | return 0; |
| 182 | } |
Sudheer Papothi | 6cc7f52 | 2019-06-28 11:04:03 +0530 | [diff] [blame] | 183 | |
Sudheer Papothi | f415500 | 2019-12-05 01:36:13 +0530 | [diff] [blame] | 184 | static inline int bolero_tx_clk_switch(struct snd_soc_component *component, |
| 185 | int clk_src) |
Sudheer Papothi | 6cc7f52 | 2019-06-28 11:04:03 +0530 | [diff] [blame] | 186 | { |
| 187 | return 0; |
| 188 | } |
| 189 | |
Sudheer Papothi | 06a4c64 | 2019-08-08 05:17:46 +0530 | [diff] [blame] | 190 | static inline int bolero_register_event_listener( |
| 191 | struct snd_soc_component *component, |
| 192 | bool enable) |
| 193 | { |
| 194 | return 0; |
| 195 | } |
| 196 | |
Laxminath Kasam | 069df14 | 2019-09-17 23:43:34 +0530 | [diff] [blame] | 197 | static void bolero_wsa_pa_on(struct device *dev) |
| 198 | { |
| 199 | } |
Aditya Bavanari | d577af9 | 2019-10-03 21:09:19 +0530 | [diff] [blame] | 200 | |
| 201 | static inline bool bolero_check_core_votes(struct device *dev) |
| 202 | { |
| 203 | return false; |
| 204 | } |
Laxminath Kasam | f162302 | 2019-10-11 18:20:19 +0530 | [diff] [blame] | 205 | |
| 206 | static int bolero_get_version(struct device *dev) |
| 207 | { |
| 208 | return 0; |
| 209 | } |
Sudheer Papothi | d50a581 | 2019-11-21 07:24:42 +0530 | [diff] [blame] | 210 | |
| 211 | static int bolero_dmic_clk_enable(struct snd_soc_component *component, |
| 212 | u32 dmic, u32 tx_mode, bool enable) |
| 213 | { |
| 214 | return 0; |
| 215 | } |
Sudheer Papothi | fc3adb0 | 2019-11-24 10:14:21 +0530 | [diff] [blame] | 216 | static int bolero_tx_mclk_enable(struct snd_soc_component *c, bool enable) |
| 217 | { |
| 218 | return 0; |
| 219 | } |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 220 | #endif /* CONFIG_SND_SOC_BOLERO */ |
| 221 | #endif /* BOLERO_CDC_H */ |