Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2018, The Linux Foundation. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #ifndef BOLERO_CDC_H |
| 14 | #define BOLERO_CDC_H |
| 15 | |
| 16 | #include <sound/soc.h> |
| 17 | #include <linux/regmap.h> |
| 18 | |
| 19 | enum { |
| 20 | START_MACRO, |
| 21 | TX_MACRO = START_MACRO, |
| 22 | RX_MACRO, |
| 23 | WSA_MACRO, |
| 24 | VA_MACRO, |
| 25 | MAX_MACRO |
| 26 | }; |
| 27 | |
Laxminath Kasam | 2df2d61 | 2018-05-22 15:45:42 +0530 | [diff] [blame] | 28 | enum mclk_mux { |
| 29 | MCLK_MUX0, |
| 30 | MCLK_MUX1, |
| 31 | MCLK_MUX_MAX |
| 32 | }; |
| 33 | |
Laxminath Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame] | 34 | enum { |
| 35 | BOLERO_ADC0 = 1, |
| 36 | BOLERO_ADC1, |
| 37 | BOLERO_ADC2, |
| 38 | BOLERO_ADC3, |
| 39 | BOLERO_ADC_MAX |
| 40 | }; |
| 41 | |
| 42 | enum { |
| 43 | BOLERO_MACRO_EVT_RX_MUTE = 1, /* for RX mute/unmute */ |
| 44 | BOLERO_MACRO_EVT_IMPED_TRUE, /* for imped true */ |
| 45 | BOLERO_MACRO_EVT_IMPED_FALSE, /* for imped false */ |
Laxminath Kasam | fb0d683 | 2018-09-22 01:49:52 +0530 | [diff] [blame] | 46 | BOLERO_MACRO_EVT_SSR_DOWN, |
| 47 | BOLERO_MACRO_EVT_SSR_UP, |
Aditya Bavanari | c4e9612 | 2018-11-14 14:46:38 +0530 | [diff] [blame^] | 48 | BOLERO_MACRO_EVT_WAIT_VA_CLK_RESET, |
| 49 | BOLERO_MACRO_EVT_REG_WAKE_IRQ |
Laxminath Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame] | 50 | }; |
| 51 | |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 52 | struct macro_ops { |
| 53 | int (*init)(struct snd_soc_codec *codec); |
| 54 | int (*exit)(struct snd_soc_codec *codec); |
| 55 | u16 num_dais; |
| 56 | struct device *dev; |
| 57 | struct snd_soc_dai_driver *dai_ptr; |
| 58 | int (*mclk_fn)(struct device *dev, bool enable); |
Laxminath Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame] | 59 | int (*event_handler)(struct snd_soc_codec *codec, u16 event, |
| 60 | u32 data); |
Aditya Bavanari | c4e9612 | 2018-11-14 14:46:38 +0530 | [diff] [blame^] | 61 | int (*reg_wake_irq)(struct snd_soc_codec *codec, u32 data); |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 62 | char __iomem *io_base; |
| 63 | }; |
| 64 | |
| 65 | #if IS_ENABLED(CONFIG_SND_SOC_BOLERO) |
| 66 | int bolero_register_macro(struct device *dev, u16 macro_id, |
| 67 | struct macro_ops *ops); |
| 68 | void bolero_unregister_macro(struct device *dev, u16 macro_id); |
| 69 | struct device *bolero_get_device_ptr(struct device *dev, u16 macro_id); |
Laxminath Kasam | 2df2d61 | 2018-05-22 15:45:42 +0530 | [diff] [blame] | 70 | int bolero_request_clock(struct device *dev, u16 macro_id, |
| 71 | enum mclk_mux mclk_mux_id, |
| 72 | bool enable); |
Laxminath Kasam | 21c8b22 | 2018-06-21 18:47:22 +0530 | [diff] [blame] | 73 | int bolero_info_create_codec_entry( |
| 74 | struct snd_info_entry *codec_root, |
| 75 | struct snd_soc_codec *codec); |
Aditya Bavanari | c4e9612 | 2018-11-14 14:46:38 +0530 | [diff] [blame^] | 76 | int bolero_register_wake_irq(struct snd_soc_codec *codec, u32 data); |
Laxminath Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame] | 77 | void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n); |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 78 | #else |
| 79 | static inline int bolero_register_macro(struct device *dev, |
| 80 | u16 macro_id, |
| 81 | struct macro_ops *ops) |
| 82 | { |
| 83 | return 0; |
| 84 | } |
| 85 | |
| 86 | static inline void bolero_unregister_macro(struct device *dev, u16 macro_id) |
| 87 | { |
| 88 | } |
| 89 | |
| 90 | static inline struct device *bolero_get_device_ptr(struct device *dev, |
Laxminath Kasam | 2df2d61 | 2018-05-22 15:45:42 +0530 | [diff] [blame] | 91 | u16 macro_id) |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 92 | { |
| 93 | return NULL; |
| 94 | } |
Laxminath Kasam | 21c8b22 | 2018-06-21 18:47:22 +0530 | [diff] [blame] | 95 | |
Laxminath Kasam | 2df2d61 | 2018-05-22 15:45:42 +0530 | [diff] [blame] | 96 | static inline int bolero_request_clock(struct device *dev, u16 macro_id, |
| 97 | enum mclk_mux mclk_mux_id, |
| 98 | bool enable) |
| 99 | { |
| 100 | return 0; |
| 101 | } |
Laxminath Kasam | 21c8b22 | 2018-06-21 18:47:22 +0530 | [diff] [blame] | 102 | |
| 103 | static int bolero_info_create_codec_entry( |
| 104 | struct snd_info_entry *codec_root, |
| 105 | struct snd_soc_codec *codec) |
| 106 | { |
| 107 | return 0; |
| 108 | } |
Laxminath Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame] | 109 | |
| 110 | static inline void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n) |
| 111 | { |
| 112 | } |
Aditya Bavanari | c4e9612 | 2018-11-14 14:46:38 +0530 | [diff] [blame^] | 113 | |
| 114 | static inline int bolero_register_wake_irq(struct snd_soc_codec *codec, |
| 115 | u32 data) |
| 116 | { |
| 117 | return 0; |
| 118 | } |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 119 | #endif /* CONFIG_SND_SOC_BOLERO */ |
| 120 | #endif /* BOLERO_CDC_H */ |