Meng Wang | 43bbb87 | 2018-12-10 12:32:05 +0800 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 2 | /* Copyright (c) 2018, The Linux Foundation. All rights reserved. |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 3 | */ |
| 4 | |
| 5 | #ifndef _BOLERO_INTERNAL_H |
| 6 | #define _BOLERO_INTERNAL_H |
| 7 | |
Laxminath Kasam | 89438f3 | 2018-06-07 12:44:17 +0530 | [diff] [blame] | 8 | #include "bolero-cdc-registers.h" |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 9 | |
Laxminath Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame] | 10 | #define BOLERO_CDC_CHILD_DEVICES_MAX 5 |
| 11 | |
| 12 | /* from bolero to WCD events */ |
| 13 | enum { |
| 14 | BOLERO_WCD_EVT_TX_CH_HOLD_CLEAR = 1, |
Vatsal Bucha | 53b4e14 | 2018-11-13 19:36:25 +0530 | [diff] [blame] | 15 | BOLERO_WCD_EVT_PA_OFF_PRE_SSR, |
Laxminath Kasam | fb0d683 | 2018-09-22 01:49:52 +0530 | [diff] [blame] | 16 | BOLERO_WCD_EVT_SSR_DOWN, |
| 17 | BOLERO_WCD_EVT_SSR_UP, |
Laxminath Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame] | 18 | }; |
| 19 | |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 20 | enum { |
| 21 | REG_NO_ACCESS, |
| 22 | RD_REG, |
| 23 | WR_REG, |
| 24 | RD_WR_REG |
| 25 | }; |
| 26 | |
Laxminath Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame] | 27 | /* from WCD to bolero events */ |
| 28 | enum { |
| 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 | |
| 34 | struct 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 Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 42 | struct bolero_priv { |
| 43 | struct device *dev; |
Meng Wang | 15c825d | 2018-09-06 10:49:18 +0800 | [diff] [blame] | 44 | struct snd_soc_component *component; |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 45 | struct regmap *regmap; |
| 46 | struct mutex io_lock; |
Laxminath Kasam | 2df2d61 | 2018-05-22 15:45:42 +0530 | [diff] [blame] | 47 | struct mutex clk_lock; |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 48 | bool va_without_decimation; |
| 49 | bool macros_supported[MAX_MACRO]; |
Laxminath Kasam | fb0d683 | 2018-09-22 01:49:52 +0530 | [diff] [blame] | 50 | bool dev_up; |
| 51 | bool initial_boot; |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 52 | 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 Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame] | 56 | u16 num_macros; |
Laxminath Kasam | 2df2d61 | 2018-05-22 15:45:42 +0530 | [diff] [blame] | 57 | u16 current_mclk_mux_macro[MAX_MACRO]; |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 58 | struct work_struct bolero_add_child_devices_work; |
Laxminath Kasam | 21c8b22 | 2018-06-21 18:47:22 +0530 | [diff] [blame] | 59 | u32 version; |
Mangesh Kunchamwar | 920015c | 2018-11-13 16:16:35 +0530 | [diff] [blame] | 60 | struct clk *lpass_npa_rsc_island; |
Laxminath Kasam | 21c8b22 | 2018-06-21 18:47:22 +0530 | [diff] [blame] | 61 | |
| 62 | /* Entry for version info */ |
| 63 | struct snd_info_entry *entry; |
| 64 | struct snd_info_entry *version_entry; |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 65 | |
| 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 Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame] | 70 | 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 Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | struct regmap *bolero_regmap_init(struct device *dev, |
| 79 | const struct regmap_config *config); |
| 80 | int bolero_get_macro_id(bool va_no_dec_flag, u16 reg); |
| 81 | |
| 82 | extern const struct regmap_config bolero_regmap_config; |
| 83 | extern u8 *bolero_reg_access[MAX_MACRO]; |
| 84 | extern u8 bolero_va_top_reg_access[BOLERO_CDC_VA_MACRO_TOP_MAX]; |
| 85 | extern const u16 macro_id_base_offset[MAX_MACRO]; |
| 86 | |
| 87 | #endif |