blob: 9e8a74c5e34ff7fc3a223062558640c8d6fd1b16 [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_INTERNAL_H
14#define _BOLERO_INTERNAL_H
15
Laxminath Kasam89438f32018-06-07 12:44:17 +053016#include "bolero-cdc-registers.h"
Laxminath Kasame562a362018-04-12 00:39:08 +053017
Laxminath Kasam497a6512018-09-17 16:11:52 +053018#define BOLERO_CDC_CHILD_DEVICES_MAX 5
19
20/* from bolero to WCD events */
21enum {
22 BOLERO_WCD_EVT_TX_CH_HOLD_CLEAR = 1,
23};
24
Laxminath Kasame562a362018-04-12 00:39:08 +053025enum {
26 REG_NO_ACCESS,
27 RD_REG,
28 WR_REG,
29 RD_WR_REG
30};
31
Laxminath Kasam497a6512018-09-17 16:11:52 +053032/* from WCD to bolero events */
33enum {
34 WCD_BOLERO_EVT_RX_MUTE = 1, /* for RX mute/unmute */
35 WCD_BOLERO_EVT_IMPED_TRUE, /* for imped true */
36 WCD_BOLERO_EVT_IMPED_FALSE, /* for imped false */
37};
38
39struct wcd_ctrl_platform_data {
40 void *handle;
41 int (*update_wcd_event)(void *handle, u16 event, u32 data);
42 int (*register_notifier)(void *handle,
43 struct notifier_block *nblock,
44 bool enable);
45};
46
Laxminath Kasame562a362018-04-12 00:39:08 +053047struct bolero_priv {
48 struct device *dev;
49 struct snd_soc_codec *codec;
50 struct regmap *regmap;
51 struct mutex io_lock;
Laxminath Kasam2df2d612018-05-22 15:45:42 +053052 struct mutex clk_lock;
Laxminath Kasame562a362018-04-12 00:39:08 +053053 bool va_without_decimation;
54 bool macros_supported[MAX_MACRO];
55 struct macro_ops macro_params[MAX_MACRO];
56 struct snd_soc_dai_driver *bolero_dais;
57 u16 num_dais;
58 u16 num_macros_registered;
Laxminath Kasam497a6512018-09-17 16:11:52 +053059 u16 num_macros;
Laxminath Kasam2df2d612018-05-22 15:45:42 +053060 u16 current_mclk_mux_macro[MAX_MACRO];
Laxminath Kasame562a362018-04-12 00:39:08 +053061 struct work_struct bolero_add_child_devices_work;
Laxminath Kasam21c8b222018-06-21 18:47:22 +053062 u32 version;
63
64 /* Entry for version info */
65 struct snd_info_entry *entry;
66 struct snd_info_entry *version_entry;
Laxminath Kasame562a362018-04-12 00:39:08 +053067
68 int (*read_dev)(struct bolero_priv *priv,
69 u16 macro_id, u16 reg, u8 *val);
70 int (*write_dev)(struct bolero_priv *priv,
71 u16 macro_id, u16 reg, u8 val);
Laxminath Kasam497a6512018-09-17 16:11:52 +053072 struct platform_device *pdev_child_devices
73 [BOLERO_CDC_CHILD_DEVICES_MAX];
74 u16 child_count;
75 struct wcd_ctrl_platform_data plat_data;
76 struct device *wcd_dev;
77 struct blocking_notifier_head notifier;
Laxminath Kasame562a362018-04-12 00:39:08 +053078};
79
80struct regmap *bolero_regmap_init(struct device *dev,
81 const struct regmap_config *config);
82int bolero_get_macro_id(bool va_no_dec_flag, u16 reg);
83
84extern const struct regmap_config bolero_regmap_config;
85extern u8 *bolero_reg_access[MAX_MACRO];
86extern u8 bolero_va_top_reg_access[BOLERO_CDC_VA_MACRO_TOP_MAX];
87extern const u16 macro_id_base_offset[MAX_MACRO];
88
89#endif