blob: ba89832e86b54c635592c1f478a2dfa11aab172f [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,
Vatsal Buchad06525f2019-10-14 23:14:12 +053034 WCD_BOLERO_EVT_BCS_CLK_OFF,
Laxminath Kasam497a6512018-09-17 16:11:52 +053035};
36
37struct wcd_ctrl_platform_data {
38 void *handle;
39 int (*update_wcd_event)(void *handle, u16 event, u32 data);
40 int (*register_notifier)(void *handle,
41 struct notifier_block *nblock,
42 bool enable);
43};
44
Laxminath Kasame562a362018-04-12 00:39:08 +053045struct bolero_priv {
46 struct device *dev;
Meng Wang15c825d2018-09-06 10:49:18 +080047 struct snd_soc_component *component;
Laxminath Kasame562a362018-04-12 00:39:08 +053048 struct regmap *regmap;
49 struct mutex io_lock;
Laxminath Kasam2df2d612018-05-22 15:45:42 +053050 struct mutex clk_lock;
Karthikeyan Maniac555db2019-07-09 12:11:23 -070051 struct mutex vote_lock;
Laxminath Kasame562a362018-04-12 00:39:08 +053052 bool va_without_decimation;
53 bool macros_supported[MAX_MACRO];
Laxminath Kasamfb0d6832018-09-22 01:49:52 +053054 bool dev_up;
55 bool initial_boot;
Laxminath Kasame562a362018-04-12 00:39:08 +053056 struct macro_ops macro_params[MAX_MACRO];
57 struct snd_soc_dai_driver *bolero_dais;
58 u16 num_dais;
59 u16 num_macros_registered;
Laxminath Kasam497a6512018-09-17 16:11:52 +053060 u16 num_macros;
Laxminath Kasam2df2d612018-05-22 15:45:42 +053061 u16 current_mclk_mux_macro[MAX_MACRO];
Laxminath Kasame562a362018-04-12 00:39:08 +053062 struct work_struct bolero_add_child_devices_work;
Laxminath Kasam21c8b222018-06-21 18:47:22 +053063 u32 version;
Mangesh Kunchamwarcdd68db2019-01-10 16:21:00 +053064 struct clk *lpass_core_hw_vote;
Sudheer Papothiba445bf2019-04-16 05:05:55 +053065 struct clk *lpass_audio_hw_vote;
Karthikeyan Maniac555db2019-07-09 12:11:23 -070066 int core_hw_vote_count;
67 int core_audio_vote_count;
Laxminath Kasam21c8b222018-06-21 18:47:22 +053068
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;
Vidyakumar Athota5d45f4c2019-03-10 22:35:07 -070083 struct device *clk_dev;
84 rsc_clk_cb_t rsc_clk_cb;
Laxminath Kasame562a362018-04-12 00:39:08 +053085};
86
87struct regmap *bolero_regmap_init(struct device *dev,
88 const struct regmap_config *config);
89int bolero_get_macro_id(bool va_no_dec_flag, u16 reg);
90
91extern const struct regmap_config bolero_regmap_config;
92extern u8 *bolero_reg_access[MAX_MACRO];
93extern u8 bolero_va_top_reg_access[BOLERO_CDC_VA_MACRO_TOP_MAX];
94extern const u16 macro_id_base_offset[MAX_MACRO];
95
96#endif