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