blob: 3e8197d58ee24cc0598db0d96f11f5221102df0c [file] [log] [blame]
Laxminath Kasame562a362018-04-12 00:39:08 +05301/* 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
19enum {
20 START_MACRO,
21 TX_MACRO = START_MACRO,
22 RX_MACRO,
23 WSA_MACRO,
24 VA_MACRO,
25 MAX_MACRO
26};
27
Laxminath Kasam2df2d612018-05-22 15:45:42 +053028enum mclk_mux {
29 MCLK_MUX0,
30 MCLK_MUX1,
31 MCLK_MUX_MAX
32};
33
Laxminath Kasam497a6512018-09-17 16:11:52 +053034enum {
35 BOLERO_ADC0 = 1,
36 BOLERO_ADC1,
37 BOLERO_ADC2,
38 BOLERO_ADC3,
39 BOLERO_ADC_MAX
40};
41
42enum {
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 */
46};
47
Laxminath Kasame562a362018-04-12 00:39:08 +053048struct macro_ops {
49 int (*init)(struct snd_soc_codec *codec);
50 int (*exit)(struct snd_soc_codec *codec);
51 u16 num_dais;
52 struct device *dev;
53 struct snd_soc_dai_driver *dai_ptr;
54 int (*mclk_fn)(struct device *dev, bool enable);
Laxminath Kasam497a6512018-09-17 16:11:52 +053055 int (*event_handler)(struct snd_soc_codec *codec, u16 event,
56 u32 data);
Laxminath Kasame562a362018-04-12 00:39:08 +053057 char __iomem *io_base;
58};
59
60#if IS_ENABLED(CONFIG_SND_SOC_BOLERO)
61int bolero_register_macro(struct device *dev, u16 macro_id,
62 struct macro_ops *ops);
63void bolero_unregister_macro(struct device *dev, u16 macro_id);
64struct device *bolero_get_device_ptr(struct device *dev, u16 macro_id);
Laxminath Kasam2df2d612018-05-22 15:45:42 +053065int bolero_request_clock(struct device *dev, u16 macro_id,
66 enum mclk_mux mclk_mux_id,
67 bool enable);
Laxminath Kasam21c8b222018-06-21 18:47:22 +053068int bolero_info_create_codec_entry(
69 struct snd_info_entry *codec_root,
70 struct snd_soc_codec *codec);
Laxminath Kasam497a6512018-09-17 16:11:52 +053071void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n);
Laxminath Kasame562a362018-04-12 00:39:08 +053072#else
73static inline int bolero_register_macro(struct device *dev,
74 u16 macro_id,
75 struct macro_ops *ops)
76{
77 return 0;
78}
79
80static inline void bolero_unregister_macro(struct device *dev, u16 macro_id)
81{
82}
83
84static inline struct device *bolero_get_device_ptr(struct device *dev,
Laxminath Kasam2df2d612018-05-22 15:45:42 +053085 u16 macro_id)
Laxminath Kasame562a362018-04-12 00:39:08 +053086{
87 return NULL;
88}
Laxminath Kasam21c8b222018-06-21 18:47:22 +053089
Laxminath Kasam2df2d612018-05-22 15:45:42 +053090static inline int bolero_request_clock(struct device *dev, u16 macro_id,
91 enum mclk_mux mclk_mux_id,
92 bool enable)
93{
94 return 0;
95}
Laxminath Kasam21c8b222018-06-21 18:47:22 +053096
97static int bolero_info_create_codec_entry(
98 struct snd_info_entry *codec_root,
99 struct snd_soc_codec *codec)
100{
101 return 0;
102}
Laxminath Kasam497a6512018-09-17 16:11:52 +0530103
104static inline void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n)
105{
106}
Laxminath Kasame562a362018-04-12 00:39:08 +0530107#endif /* CONFIG_SND_SOC_BOLERO */
108#endif /* BOLERO_CDC_H */