blob: cf132bdd2cfc648c5e5c9b8da24649539c3e7d52 [file] [log] [blame]
Meng Wang43bbb872018-12-10 12:32:05 +08001/* SPDX-License-Identifier: GPL-2.0-only */
Laxminath Kasam2fe71f52020-05-15 00:39:51 +05302/* Copyright (c) 2018-2020, 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 Kasam2fe71f52020-05-15 00:39:51 +053019 BOLERO_WCD_EVT_PA_ON_POST_FSCLK_ADIE_LB,
Laxminath Kasam497a6512018-09-17 16:11:52 +053020};
21
Laxminath Kasame562a362018-04-12 00:39:08 +053022enum {
23 REG_NO_ACCESS,
24 RD_REG,
25 WR_REG,
26 RD_WR_REG
27};
28
Laxminath Kasam497a6512018-09-17 16:11:52 +053029/* from WCD to bolero events */
30enum {
31 WCD_BOLERO_EVT_RX_MUTE = 1, /* for RX mute/unmute */
32 WCD_BOLERO_EVT_IMPED_TRUE, /* for imped true */
33 WCD_BOLERO_EVT_IMPED_FALSE, /* for imped false */
Karthikeyan Manic14c27a2019-06-21 14:11:34 -070034 WCD_BOLERO_EVT_RX_COMPANDER_SOFT_RST,
Vatsal Buchad06525f2019-10-14 23:14:12 +053035 WCD_BOLERO_EVT_BCS_CLK_OFF,
Vatsal Bucha8203a062020-07-17 19:13:19 +053036 WCD_BOLERO_EVT_RX_PA_GAIN_UPDATE,
Vatsal Bucha4b3e5232020-07-14 05:33:06 +053037 WCD_BOLERO_EVT_HPHL_HD2_ENABLE, /* to enable hd2 config for hphl */
38 WCD_BOLERO_EVT_HPHR_HD2_ENABLE, /* to enable hd2 config for hphr */
Laxminath Kasam497a6512018-09-17 16:11:52 +053039};
40
41struct wcd_ctrl_platform_data {
42 void *handle;
43 int (*update_wcd_event)(void *handle, u16 event, u32 data);
44 int (*register_notifier)(void *handle,
45 struct notifier_block *nblock,
46 bool enable);
47};
48
Laxminath Kasame562a362018-04-12 00:39:08 +053049struct bolero_priv {
50 struct device *dev;
Meng Wang15c825d2018-09-06 10:49:18 +080051 struct snd_soc_component *component;
Laxminath Kasame562a362018-04-12 00:39:08 +053052 struct regmap *regmap;
53 struct mutex io_lock;
Laxminath Kasam2df2d612018-05-22 15:45:42 +053054 struct mutex clk_lock;
Karthikeyan Maniac555db2019-07-09 12:11:23 -070055 struct mutex vote_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;
Mangesh Kunchamwarcdd68db2019-01-10 16:21:00 +053068 struct clk *lpass_core_hw_vote;
Sudheer Papothiba445bf2019-04-16 05:05:55 +053069 struct clk *lpass_audio_hw_vote;
Karthikeyan Maniac555db2019-07-09 12:11:23 -070070 int core_hw_vote_count;
71 int core_audio_vote_count;
Laxminath Kasam21c8b222018-06-21 18:47:22 +053072
73 /* Entry for version info */
74 struct snd_info_entry *entry;
75 struct snd_info_entry *version_entry;
Laxminath Kasame562a362018-04-12 00:39:08 +053076
77 int (*read_dev)(struct bolero_priv *priv,
78 u16 macro_id, u16 reg, u8 *val);
79 int (*write_dev)(struct bolero_priv *priv,
80 u16 macro_id, u16 reg, u8 val);
Laxminath Kasam497a6512018-09-17 16:11:52 +053081 struct platform_device *pdev_child_devices
82 [BOLERO_CDC_CHILD_DEVICES_MAX];
83 u16 child_count;
84 struct wcd_ctrl_platform_data plat_data;
85 struct device *wcd_dev;
86 struct blocking_notifier_head notifier;
Vidyakumar Athota5d45f4c2019-03-10 22:35:07 -070087 struct device *clk_dev;
88 rsc_clk_cb_t rsc_clk_cb;
Sudheer Papothid50a5812019-11-21 07:24:42 +053089 s32 dmic_0_1_clk_cnt;
90 s32 dmic_2_3_clk_cnt;
91 s32 dmic_4_5_clk_cnt;
92 s32 dmic_6_7_clk_cnt;
93 u8 dmic_0_1_clk_div;
94 u8 dmic_2_3_clk_div;
95 u8 dmic_4_5_clk_div;
96 u8 dmic_6_7_clk_div;
Laxminath Kasame562a362018-04-12 00:39:08 +053097};
98
99struct regmap *bolero_regmap_init(struct device *dev,
100 const struct regmap_config *config);
101int bolero_get_macro_id(bool va_no_dec_flag, u16 reg);
102
103extern const struct regmap_config bolero_regmap_config;
104extern u8 *bolero_reg_access[MAX_MACRO];
105extern u8 bolero_va_top_reg_access[BOLERO_CDC_VA_MACRO_TOP_MAX];
Laxminath Kasamfbd95ed2019-11-05 22:07:06 +0530106extern u8 bolero_va_reg_access_v2[BOLERO_CDC_VA_MACRO_MAX];
107extern u8 bolero_va_reg_access_v3[BOLERO_CDC_VA_MACRO_MAX];
108extern u8 bolero_tx_reg_access_v2[BOLERO_CDC_TX_MACRO_MAX];
Laxminath Kasame562a362018-04-12 00:39:08 +0530109extern const u16 macro_id_base_offset[MAX_MACRO];
110
111#endif