blob: 89d3cadb7f3b2752c57e66bc214be89ec24c9d64 [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,
Vatsal Bucha53b4e142018-11-13 19:36:25 +053023 BOLERO_WCD_EVT_PA_OFF_PRE_SSR,
Laxminath Kasamfb0d6832018-09-22 01:49:52 +053024 BOLERO_WCD_EVT_SSR_DOWN,
25 BOLERO_WCD_EVT_SSR_UP,
Laxminath Kasam497a6512018-09-17 16:11:52 +053026};
27
Laxminath Kasame562a362018-04-12 00:39:08 +053028enum {
29 REG_NO_ACCESS,
30 RD_REG,
31 WR_REG,
32 RD_WR_REG
33};
34
Laxminath Kasam497a6512018-09-17 16:11:52 +053035/* from WCD to bolero events */
36enum {
37 WCD_BOLERO_EVT_RX_MUTE = 1, /* for RX mute/unmute */
38 WCD_BOLERO_EVT_IMPED_TRUE, /* for imped true */
39 WCD_BOLERO_EVT_IMPED_FALSE, /* for imped false */
40};
41
42struct wcd_ctrl_platform_data {
43 void *handle;
44 int (*update_wcd_event)(void *handle, u16 event, u32 data);
45 int (*register_notifier)(void *handle,
46 struct notifier_block *nblock,
47 bool enable);
48};
49
Laxminath Kasame562a362018-04-12 00:39:08 +053050struct bolero_priv {
51 struct device *dev;
52 struct snd_soc_codec *codec;
53 struct regmap *regmap;
54 struct mutex io_lock;
Laxminath Kasam2df2d612018-05-22 15:45:42 +053055 struct mutex clk_lock;
Laxminath Kasame562a362018-04-12 00:39:08 +053056 bool va_without_decimation;
57 bool macros_supported[MAX_MACRO];
Laxminath Kasamfb0d6832018-09-22 01:49:52 +053058 bool dev_up;
59 bool initial_boot;
Laxminath Kasame562a362018-04-12 00:39:08 +053060 struct macro_ops macro_params[MAX_MACRO];
61 struct snd_soc_dai_driver *bolero_dais;
62 u16 num_dais;
63 u16 num_macros_registered;
Laxminath Kasam497a6512018-09-17 16:11:52 +053064 u16 num_macros;
Laxminath Kasam2df2d612018-05-22 15:45:42 +053065 u16 current_mclk_mux_macro[MAX_MACRO];
Laxminath Kasame562a362018-04-12 00:39:08 +053066 struct work_struct bolero_add_child_devices_work;
Laxminath Kasam21c8b222018-06-21 18:47:22 +053067 u32 version;
68
69 /* Entry for version info */
70 struct snd_info_entry *entry;
71 struct snd_info_entry *version_entry;
Laxminath Kasame562a362018-04-12 00:39:08 +053072
73 int (*read_dev)(struct bolero_priv *priv,
74 u16 macro_id, u16 reg, u8 *val);
75 int (*write_dev)(struct bolero_priv *priv,
76 u16 macro_id, u16 reg, u8 val);
Laxminath Kasam497a6512018-09-17 16:11:52 +053077 struct platform_device *pdev_child_devices
78 [BOLERO_CDC_CHILD_DEVICES_MAX];
79 u16 child_count;
80 struct wcd_ctrl_platform_data plat_data;
81 struct device *wcd_dev;
82 struct blocking_notifier_head notifier;
Laxminath Kasame562a362018-04-12 00:39:08 +053083};
84
85struct regmap *bolero_regmap_init(struct device *dev,
86 const struct regmap_config *config);
87int bolero_get_macro_id(bool va_no_dec_flag, u16 reg);
88
89extern const struct regmap_config bolero_regmap_config;
90extern u8 *bolero_reg_access[MAX_MACRO];
91extern u8 bolero_va_top_reg_access[BOLERO_CDC_VA_MACRO_TOP_MAX];
92extern const u16 macro_id_base_offset[MAX_MACRO];
93
94#endif