blob: d3f6894674463ecfcae62b960f1bf20bb5a81c14 [file] [log] [blame]
Meng Wang43bbb872018-12-10 12:32:05 +08001/* SPDX-License-Identifier: GPL-2.0-only */
Mangesh Kunchamwarcdd68db2019-01-10 16:21:00 +05302/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
Laxminath Kasame562a362018-04-12 00:39:08 +05303 */
4
5#ifndef _BOLERO_INTERNAL_H
6#define _BOLERO_INTERNAL_H
7
Laxminath Kasam89438f32018-06-07 12:44:17 +05308#include "bolero-cdc-registers.h"
Laxminath Kasame562a362018-04-12 00:39:08 +05309
Vidyakumar Athota5d45f4c2019-03-10 22:35:07 -070010#define BOLERO_CDC_CHILD_DEVICES_MAX 6
Laxminath Kasam497a6512018-09-17 16:11:52 +053011
12/* from bolero to WCD events */
13enum {
14 BOLERO_WCD_EVT_TX_CH_HOLD_CLEAR = 1,
Vatsal Bucha53b4e142018-11-13 19:36:25 +053015 BOLERO_WCD_EVT_PA_OFF_PRE_SSR,
Laxminath Kasamfb0d6832018-09-22 01:49:52 +053016 BOLERO_WCD_EVT_SSR_DOWN,
17 BOLERO_WCD_EVT_SSR_UP,
Laxminath Kasam069df142019-09-17 23:43:34 +053018 BOLERO_WCD_EVT_PA_ON_POST_FSCLK,
Laxminath Kasam497a6512018-09-17 16:11:52 +053019};
20
Laxminath Kasame562a362018-04-12 00:39:08 +053021enum {
22 REG_NO_ACCESS,
23 RD_REG,
24 WR_REG,
25 RD_WR_REG
26};
27
Laxminath Kasam497a6512018-09-17 16:11:52 +053028/* from WCD to bolero events */
29enum {
30 WCD_BOLERO_EVT_RX_MUTE = 1, /* for RX mute/unmute */
31 WCD_BOLERO_EVT_IMPED_TRUE, /* for imped true */
32 WCD_BOLERO_EVT_IMPED_FALSE, /* for imped false */
Karthikeyan Manic14c27a2019-06-21 14:11:34 -070033 WCD_BOLERO_EVT_RX_COMPANDER_SOFT_RST,
Laxminath Kasam497a6512018-09-17 16:11:52 +053034};
35
36struct wcd_ctrl_platform_data {
37 void *handle;
38 int (*update_wcd_event)(void *handle, u16 event, u32 data);
39 int (*register_notifier)(void *handle,
40 struct notifier_block *nblock,
41 bool enable);
42};
43
Laxminath Kasame562a362018-04-12 00:39:08 +053044struct bolero_priv {
45 struct device *dev;
Meng Wang15c825d2018-09-06 10:49:18 +080046 struct snd_soc_component *component;
Laxminath Kasame562a362018-04-12 00:39:08 +053047 struct regmap *regmap;
48 struct mutex io_lock;
Laxminath Kasam2df2d612018-05-22 15:45:42 +053049 struct mutex clk_lock;
Karthikeyan Maniac555db2019-07-09 12:11:23 -070050 struct mutex vote_lock;
Laxminath Kasame562a362018-04-12 00:39:08 +053051 bool va_without_decimation;
52 bool macros_supported[MAX_MACRO];
Laxminath Kasamfb0d6832018-09-22 01:49:52 +053053 bool dev_up;
54 bool initial_boot;
Laxminath Kasame562a362018-04-12 00:39:08 +053055 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;
Mangesh Kunchamwarcdd68db2019-01-10 16:21:00 +053063 struct clk *lpass_core_hw_vote;
Sudheer Papothiba445bf2019-04-16 05:05:55 +053064 struct clk *lpass_audio_hw_vote;
Karthikeyan Maniac555db2019-07-09 12:11:23 -070065 int core_hw_vote_count;
66 int core_audio_vote_count;
Laxminath Kasam21c8b222018-06-21 18:47:22 +053067
68 /* Entry for version info */
69 struct snd_info_entry *entry;
70 struct snd_info_entry *version_entry;
Laxminath Kasame562a362018-04-12 00:39:08 +053071
72 int (*read_dev)(struct bolero_priv *priv,
73 u16 macro_id, u16 reg, u8 *val);
74 int (*write_dev)(struct bolero_priv *priv,
75 u16 macro_id, u16 reg, u8 val);
Laxminath Kasam497a6512018-09-17 16:11:52 +053076 struct platform_device *pdev_child_devices
77 [BOLERO_CDC_CHILD_DEVICES_MAX];
78 u16 child_count;
79 struct wcd_ctrl_platform_data plat_data;
80 struct device *wcd_dev;
81 struct blocking_notifier_head notifier;
Vidyakumar Athota5d45f4c2019-03-10 22:35:07 -070082 struct device *clk_dev;
83 rsc_clk_cb_t rsc_clk_cb;
Laxminath Kasame562a362018-04-12 00:39:08 +053084};
85
86struct regmap *bolero_regmap_init(struct device *dev,
87 const struct regmap_config *config);
88int bolero_get_macro_id(bool va_no_dec_flag, u16 reg);
89
90extern const struct regmap_config bolero_regmap_config;
91extern u8 *bolero_reg_access[MAX_MACRO];
92extern u8 bolero_va_top_reg_access[BOLERO_CDC_VA_MACRO_TOP_MAX];
93extern const u16 macro_id_base_offset[MAX_MACRO];
94
95#endif