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 | |
| 11 | enum { |
| 12 | START_MACRO, |
| 13 | TX_MACRO = START_MACRO, |
| 14 | RX_MACRO, |
| 15 | WSA_MACRO, |
| 16 | VA_MACRO, |
| 17 | MAX_MACRO |
| 18 | }; |
| 19 | |
Laxminath Kasam | 2df2d61 | 2018-05-22 15:45:42 +0530 | [diff] [blame] | 20 | enum mclk_mux { |
| 21 | MCLK_MUX0, |
| 22 | MCLK_MUX1, |
| 23 | MCLK_MUX_MAX |
| 24 | }; |
| 25 | |
Laxminath Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame] | 26 | enum { |
| 27 | BOLERO_ADC0 = 1, |
| 28 | BOLERO_ADC1, |
| 29 | BOLERO_ADC2, |
| 30 | BOLERO_ADC3, |
| 31 | BOLERO_ADC_MAX |
| 32 | }; |
| 33 | |
| 34 | enum { |
| 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 Kasam | fb0d683 | 2018-09-22 01:49:52 +0530 | [diff] [blame] | 38 | BOLERO_MACRO_EVT_SSR_DOWN, |
| 39 | BOLERO_MACRO_EVT_SSR_UP, |
Aditya Bavanari | c4e9612 | 2018-11-14 14:46:38 +0530 | [diff] [blame] | 40 | BOLERO_MACRO_EVT_WAIT_VA_CLK_RESET, |
Meng Wang | 8ef0cc2 | 2019-05-08 15:12:56 +0800 | [diff] [blame] | 41 | BOLERO_MACRO_EVT_CLK_RESET, |
Karthikeyan Mani | c14c27a | 2019-06-21 14:11:34 -0700 | [diff] [blame] | 42 | BOLERO_MACRO_EVT_REG_WAKE_IRQ, |
| 43 | BOLERO_MACRO_EVT_RX_COMPANDER_SOFT_RST |
Laxminath Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame] | 44 | }; |
| 45 | |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 46 | struct macro_ops { |
Meng Wang | 15c825d | 2018-09-06 10:49:18 +0800 | [diff] [blame] | 47 | int (*init)(struct snd_soc_component *component); |
| 48 | int (*exit)(struct snd_soc_component *component); |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 49 | 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 Wang | 15c825d | 2018-09-06 10:49:18 +0800 | [diff] [blame] | 53 | int (*event_handler)(struct snd_soc_component *component, u16 event, |
Laxminath Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame] | 54 | u32 data); |
Meng Wang | 15c825d | 2018-09-06 10:49:18 +0800 | [diff] [blame] | 55 | int (*reg_wake_irq)(struct snd_soc_component *component, u32 data); |
Sudheer Papothi | a3e969d | 2018-10-27 06:22:10 +0530 | [diff] [blame] | 56 | int (*set_port_map)(struct snd_soc_component *component, u32 uc, |
| 57 | u32 size, void *data); |
Sudheer Papothi | 6cc7f52 | 2019-06-28 11:04:03 +0530 | [diff] [blame] | 58 | int (*clk_switch)(struct snd_soc_component *component); |
Sudheer Papothi | 06a4c64 | 2019-08-08 05:17:46 +0530 | [diff] [blame^] | 59 | int (*reg_evt_listener)(struct snd_soc_component *component, bool en); |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 60 | char __iomem *io_base; |
Vidyakumar Athota | 5d45f4c | 2019-03-10 22:35:07 -0700 | [diff] [blame] | 61 | u16 clk_id_req; |
| 62 | u16 default_clk_id; |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 63 | }; |
| 64 | |
Vidyakumar Athota | 5d45f4c | 2019-03-10 22:35:07 -0700 | [diff] [blame] | 65 | typedef int (*rsc_clk_cb_t)(struct device *dev, u16 event); |
| 66 | |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 67 | #if IS_ENABLED(CONFIG_SND_SOC_BOLERO) |
Vidyakumar Athota | 5d45f4c | 2019-03-10 22:35:07 -0700 | [diff] [blame] | 68 | int bolero_register_res_clk(struct device *dev, rsc_clk_cb_t cb); |
| 69 | void bolero_unregister_res_clk(struct device *dev); |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 70 | int bolero_register_macro(struct device *dev, u16 macro_id, |
| 71 | struct macro_ops *ops); |
| 72 | void bolero_unregister_macro(struct device *dev, u16 macro_id); |
| 73 | struct device *bolero_get_device_ptr(struct device *dev, u16 macro_id); |
Vidyakumar Athota | 5d45f4c | 2019-03-10 22:35:07 -0700 | [diff] [blame] | 74 | struct device *bolero_get_rsc_clk_device_ptr(struct device *dev); |
Laxminath Kasam | 21c8b22 | 2018-06-21 18:47:22 +0530 | [diff] [blame] | 75 | int bolero_info_create_codec_entry( |
| 76 | struct snd_info_entry *codec_root, |
Meng Wang | 15c825d | 2018-09-06 10:49:18 +0800 | [diff] [blame] | 77 | struct snd_soc_component *component); |
| 78 | int bolero_register_wake_irq(struct snd_soc_component *component, u32 data); |
Laxminath Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame] | 79 | void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n); |
Mangesh Kunchamwar | 920015c | 2018-11-13 16:16:35 +0530 | [diff] [blame] | 80 | int bolero_runtime_resume(struct device *dev); |
| 81 | int bolero_runtime_suspend(struct device *dev); |
Sudheer Papothi | a3e969d | 2018-10-27 06:22:10 +0530 | [diff] [blame] | 82 | 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] | 83 | int bolero_tx_clk_switch(struct snd_soc_component *component); |
Sudheer Papothi | 06a4c64 | 2019-08-08 05:17:46 +0530 | [diff] [blame^] | 84 | int bolero_register_event_listener(struct snd_soc_component *component, |
| 85 | bool enable); |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 86 | #else |
Vidyakumar Athota | 5d45f4c | 2019-03-10 22:35:07 -0700 | [diff] [blame] | 87 | static inline int bolero_register_res_clk(struct device *dev, rsc_clk_cb_t cb) |
| 88 | { |
| 89 | return 0; |
| 90 | } |
| 91 | static inline void bolero_unregister_res_clk(struct device *dev) |
| 92 | { |
| 93 | } |
| 94 | |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 95 | static inline int bolero_register_macro(struct device *dev, |
| 96 | u16 macro_id, |
| 97 | struct macro_ops *ops) |
| 98 | { |
| 99 | return 0; |
| 100 | } |
| 101 | |
| 102 | static inline void bolero_unregister_macro(struct device *dev, u16 macro_id) |
| 103 | { |
| 104 | } |
| 105 | |
| 106 | static inline struct device *bolero_get_device_ptr(struct device *dev, |
Laxminath Kasam | 2df2d61 | 2018-05-22 15:45:42 +0530 | [diff] [blame] | 107 | u16 macro_id) |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 108 | { |
| 109 | return NULL; |
| 110 | } |
Laxminath Kasam | 21c8b22 | 2018-06-21 18:47:22 +0530 | [diff] [blame] | 111 | |
Laxminath Kasam | 21c8b22 | 2018-06-21 18:47:22 +0530 | [diff] [blame] | 112 | static int bolero_info_create_codec_entry( |
| 113 | struct snd_info_entry *codec_root, |
Meng Wang | 15c825d | 2018-09-06 10:49:18 +0800 | [diff] [blame] | 114 | struct snd_soc_component *component) |
Laxminath Kasam | 21c8b22 | 2018-06-21 18:47:22 +0530 | [diff] [blame] | 115 | { |
| 116 | return 0; |
| 117 | } |
Laxminath Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame] | 118 | |
| 119 | static inline void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n) |
| 120 | { |
| 121 | } |
Aditya Bavanari | c4e9612 | 2018-11-14 14:46:38 +0530 | [diff] [blame] | 122 | |
Meng Wang | 15c825d | 2018-09-06 10:49:18 +0800 | [diff] [blame] | 123 | static inline int bolero_register_wake_irq(struct snd_soc_component *component, |
Aditya Bavanari | c4e9612 | 2018-11-14 14:46:38 +0530 | [diff] [blame] | 124 | u32 data) |
Sudheer Papothi | a3e969d | 2018-10-27 06:22:10 +0530 | [diff] [blame] | 125 | { |
| 126 | return 0; |
| 127 | } |
| 128 | |
Mangesh Kunchamwar | 920015c | 2018-11-13 16:16:35 +0530 | [diff] [blame] | 129 | static inline int bolero_runtime_resume(struct device *dev) |
| 130 | { |
| 131 | return 0; |
| 132 | } |
Sudheer Papothi | a3e969d | 2018-10-27 06:22:10 +0530 | [diff] [blame] | 133 | |
Mangesh Kunchamwar | 920015c | 2018-11-13 16:16:35 +0530 | [diff] [blame] | 134 | static int bolero_runtime_suspend(struct device *dev) |
Aditya Bavanari | c4e9612 | 2018-11-14 14:46:38 +0530 | [diff] [blame] | 135 | { |
| 136 | return 0; |
| 137 | } |
Sudheer Papothi | a3e969d | 2018-10-27 06:22:10 +0530 | [diff] [blame] | 138 | |
| 139 | static inline int bolero_set_port_map(struct snd_soc_component *component, |
| 140 | u32 size, void *data) |
| 141 | { |
| 142 | return 0; |
| 143 | } |
Sudheer Papothi | 6cc7f52 | 2019-06-28 11:04:03 +0530 | [diff] [blame] | 144 | |
| 145 | static inline int bolero_tx_clk_switch(struct snd_soc_component *component) |
| 146 | { |
| 147 | return 0; |
| 148 | } |
| 149 | |
Sudheer Papothi | 06a4c64 | 2019-08-08 05:17:46 +0530 | [diff] [blame^] | 150 | static inline int bolero_register_event_listener( |
| 151 | struct snd_soc_component *component, |
| 152 | bool enable) |
| 153 | { |
| 154 | return 0; |
| 155 | } |
| 156 | |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 157 | #endif /* CONFIG_SND_SOC_BOLERO */ |
| 158 | #endif /* BOLERO_CDC_H */ |