blob: 9093334208971826a54e79db1530554a50001442 [file] [log] [blame]
Meng Wang43bbb872018-12-10 12:32:05 +08001/* SPDX-License-Identifier: GPL-2.0-only */
Laxminath Kasame562a362018-04-12 00:39:08 +05302/* Copyright (c) 2018, 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
Laxminath Kasam497a6512018-09-17 16:11:52 +053010#define BOLERO_CDC_CHILD_DEVICES_MAX 5
11
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 Kasam497a6512018-09-17 16:11:52 +053018};
19
Laxminath Kasame562a362018-04-12 00:39:08 +053020enum {
21 REG_NO_ACCESS,
22 RD_REG,
23 WR_REG,
24 RD_WR_REG
25};
26
Laxminath Kasam497a6512018-09-17 16:11:52 +053027/* from WCD to bolero events */
28enum {
29 WCD_BOLERO_EVT_RX_MUTE = 1, /* for RX mute/unmute */
30 WCD_BOLERO_EVT_IMPED_TRUE, /* for imped true */
31 WCD_BOLERO_EVT_IMPED_FALSE, /* for imped false */
32};
33
34struct wcd_ctrl_platform_data {
35 void *handle;
36 int (*update_wcd_event)(void *handle, u16 event, u32 data);
37 int (*register_notifier)(void *handle,
38 struct notifier_block *nblock,
39 bool enable);
40};
41
Laxminath Kasame562a362018-04-12 00:39:08 +053042struct bolero_priv {
43 struct device *dev;
Meng Wang15c825d2018-09-06 10:49:18 +080044 struct snd_soc_component *component;
Laxminath Kasame562a362018-04-12 00:39:08 +053045 struct regmap *regmap;
46 struct mutex io_lock;
Laxminath Kasam2df2d612018-05-22 15:45:42 +053047 struct mutex clk_lock;
Laxminath Kasame562a362018-04-12 00:39:08 +053048 bool va_without_decimation;
49 bool macros_supported[MAX_MACRO];
Laxminath Kasamfb0d6832018-09-22 01:49:52 +053050 bool dev_up;
51 bool initial_boot;
Laxminath Kasame562a362018-04-12 00:39:08 +053052 struct macro_ops macro_params[MAX_MACRO];
53 struct snd_soc_dai_driver *bolero_dais;
54 u16 num_dais;
55 u16 num_macros_registered;
Laxminath Kasam497a6512018-09-17 16:11:52 +053056 u16 num_macros;
Laxminath Kasam2df2d612018-05-22 15:45:42 +053057 u16 current_mclk_mux_macro[MAX_MACRO];
Laxminath Kasame562a362018-04-12 00:39:08 +053058 struct work_struct bolero_add_child_devices_work;
Laxminath Kasam21c8b222018-06-21 18:47:22 +053059 u32 version;
Mangesh Kunchamwar920015c2018-11-13 16:16:35 +053060 struct clk *lpass_npa_rsc_island;
Laxminath Kasam21c8b222018-06-21 18:47:22 +053061
62 /* Entry for version info */
63 struct snd_info_entry *entry;
64 struct snd_info_entry *version_entry;
Laxminath Kasame562a362018-04-12 00:39:08 +053065
66 int (*read_dev)(struct bolero_priv *priv,
67 u16 macro_id, u16 reg, u8 *val);
68 int (*write_dev)(struct bolero_priv *priv,
69 u16 macro_id, u16 reg, u8 val);
Laxminath Kasam497a6512018-09-17 16:11:52 +053070 struct platform_device *pdev_child_devices
71 [BOLERO_CDC_CHILD_DEVICES_MAX];
72 u16 child_count;
73 struct wcd_ctrl_platform_data plat_data;
74 struct device *wcd_dev;
75 struct blocking_notifier_head notifier;
Laxminath Kasame562a362018-04-12 00:39:08 +053076};
77
78struct regmap *bolero_regmap_init(struct device *dev,
79 const struct regmap_config *config);
80int bolero_get_macro_id(bool va_no_dec_flag, u16 reg);
81
82extern const struct regmap_config bolero_regmap_config;
83extern u8 *bolero_reg_access[MAX_MACRO];
84extern u8 bolero_va_top_reg_access[BOLERO_CDC_VA_MACRO_TOP_MAX];
85extern const u16 macro_id_base_offset[MAX_MACRO];
86
87#endif