Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2018, The Linux Foundation. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #ifndef _BOLERO_INTERNAL_H |
| 14 | #define _BOLERO_INTERNAL_H |
| 15 | |
Laxminath Kasam | 89438f3 | 2018-06-07 12:44:17 +0530 | [diff] [blame] | 16 | #include "bolero-cdc-registers.h" |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 17 | |
Laxminath Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame] | 18 | #define BOLERO_CDC_CHILD_DEVICES_MAX 5 |
| 19 | |
| 20 | /* from bolero to WCD events */ |
| 21 | enum { |
| 22 | BOLERO_WCD_EVT_TX_CH_HOLD_CLEAR = 1, |
Vatsal Bucha | 53b4e14 | 2018-11-13 19:36:25 +0530 | [diff] [blame^] | 23 | BOLERO_WCD_EVT_PA_OFF_PRE_SSR, |
Laxminath Kasam | fb0d683 | 2018-09-22 01:49:52 +0530 | [diff] [blame] | 24 | BOLERO_WCD_EVT_SSR_DOWN, |
| 25 | BOLERO_WCD_EVT_SSR_UP, |
Laxminath Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame] | 26 | }; |
| 27 | |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 28 | enum { |
| 29 | REG_NO_ACCESS, |
| 30 | RD_REG, |
| 31 | WR_REG, |
| 32 | RD_WR_REG |
| 33 | }; |
| 34 | |
Laxminath Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame] | 35 | /* from WCD to bolero events */ |
| 36 | enum { |
| 37 | WCD_BOLERO_EVT_RX_MUTE = 1, /* for RX mute/unmute */ |
| 38 | WCD_BOLERO_EVT_IMPED_TRUE, /* for imped true */ |
| 39 | WCD_BOLERO_EVT_IMPED_FALSE, /* for imped false */ |
| 40 | }; |
| 41 | |
| 42 | struct wcd_ctrl_platform_data { |
| 43 | void *handle; |
| 44 | int (*update_wcd_event)(void *handle, u16 event, u32 data); |
| 45 | int (*register_notifier)(void *handle, |
| 46 | struct notifier_block *nblock, |
| 47 | bool enable); |
| 48 | }; |
| 49 | |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 50 | struct bolero_priv { |
| 51 | struct device *dev; |
| 52 | struct snd_soc_codec *codec; |
| 53 | struct regmap *regmap; |
| 54 | struct mutex io_lock; |
Laxminath Kasam | 2df2d61 | 2018-05-22 15:45:42 +0530 | [diff] [blame] | 55 | struct mutex clk_lock; |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 56 | bool va_without_decimation; |
| 57 | bool macros_supported[MAX_MACRO]; |
Laxminath Kasam | fb0d683 | 2018-09-22 01:49:52 +0530 | [diff] [blame] | 58 | bool dev_up; |
| 59 | bool initial_boot; |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 60 | 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 Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame] | 64 | u16 num_macros; |
Laxminath Kasam | 2df2d61 | 2018-05-22 15:45:42 +0530 | [diff] [blame] | 65 | u16 current_mclk_mux_macro[MAX_MACRO]; |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 66 | struct work_struct bolero_add_child_devices_work; |
Laxminath Kasam | 21c8b22 | 2018-06-21 18:47:22 +0530 | [diff] [blame] | 67 | u32 version; |
| 68 | |
| 69 | /* Entry for version info */ |
| 70 | struct snd_info_entry *entry; |
| 71 | struct snd_info_entry *version_entry; |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 72 | |
| 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 Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame] | 77 | 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; |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | struct regmap *bolero_regmap_init(struct device *dev, |
| 86 | const struct regmap_config *config); |
| 87 | int bolero_get_macro_id(bool va_no_dec_flag, u16 reg); |
| 88 | |
| 89 | extern const struct regmap_config bolero_regmap_config; |
| 90 | extern u8 *bolero_reg_access[MAX_MACRO]; |
| 91 | extern u8 bolero_va_top_reg_access[BOLERO_CDC_VA_MACRO_TOP_MAX]; |
| 92 | extern const u16 macro_id_base_offset[MAX_MACRO]; |
| 93 | |
| 94 | #endif |