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, |
| 23 | }; |
| 24 | |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 25 | enum { |
| 26 | REG_NO_ACCESS, |
| 27 | RD_REG, |
| 28 | WR_REG, |
| 29 | RD_WR_REG |
| 30 | }; |
| 31 | |
Laxminath Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame^] | 32 | /* from WCD to bolero events */ |
| 33 | enum { |
| 34 | WCD_BOLERO_EVT_RX_MUTE = 1, /* for RX mute/unmute */ |
| 35 | WCD_BOLERO_EVT_IMPED_TRUE, /* for imped true */ |
| 36 | WCD_BOLERO_EVT_IMPED_FALSE, /* for imped false */ |
| 37 | }; |
| 38 | |
| 39 | struct wcd_ctrl_platform_data { |
| 40 | void *handle; |
| 41 | int (*update_wcd_event)(void *handle, u16 event, u32 data); |
| 42 | int (*register_notifier)(void *handle, |
| 43 | struct notifier_block *nblock, |
| 44 | bool enable); |
| 45 | }; |
| 46 | |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 47 | struct bolero_priv { |
| 48 | struct device *dev; |
| 49 | struct snd_soc_codec *codec; |
| 50 | struct regmap *regmap; |
| 51 | struct mutex io_lock; |
Laxminath Kasam | 2df2d61 | 2018-05-22 15:45:42 +0530 | [diff] [blame] | 52 | struct mutex clk_lock; |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 53 | bool va_without_decimation; |
| 54 | bool macros_supported[MAX_MACRO]; |
| 55 | struct macro_ops macro_params[MAX_MACRO]; |
| 56 | struct snd_soc_dai_driver *bolero_dais; |
| 57 | u16 num_dais; |
| 58 | u16 num_macros_registered; |
Laxminath Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame^] | 59 | u16 num_macros; |
Laxminath Kasam | 2df2d61 | 2018-05-22 15:45:42 +0530 | [diff] [blame] | 60 | u16 current_mclk_mux_macro[MAX_MACRO]; |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 61 | struct work_struct bolero_add_child_devices_work; |
Laxminath Kasam | 21c8b22 | 2018-06-21 18:47:22 +0530 | [diff] [blame] | 62 | u32 version; |
| 63 | |
| 64 | /* Entry for version info */ |
| 65 | struct snd_info_entry *entry; |
| 66 | struct snd_info_entry *version_entry; |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 67 | |
| 68 | int (*read_dev)(struct bolero_priv *priv, |
| 69 | u16 macro_id, u16 reg, u8 *val); |
| 70 | int (*write_dev)(struct bolero_priv *priv, |
| 71 | u16 macro_id, u16 reg, u8 val); |
Laxminath Kasam | 497a651 | 2018-09-17 16:11:52 +0530 | [diff] [blame^] | 72 | struct platform_device *pdev_child_devices |
| 73 | [BOLERO_CDC_CHILD_DEVICES_MAX]; |
| 74 | u16 child_count; |
| 75 | struct wcd_ctrl_platform_data plat_data; |
| 76 | struct device *wcd_dev; |
| 77 | struct blocking_notifier_head notifier; |
Laxminath Kasam | e562a36 | 2018-04-12 00:39:08 +0530 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | struct regmap *bolero_regmap_init(struct device *dev, |
| 81 | const struct regmap_config *config); |
| 82 | int bolero_get_macro_id(bool va_no_dec_flag, u16 reg); |
| 83 | |
| 84 | extern const struct regmap_config bolero_regmap_config; |
| 85 | extern u8 *bolero_reg_access[MAX_MACRO]; |
| 86 | extern u8 bolero_va_top_reg_access[BOLERO_CDC_VA_MACRO_TOP_MAX]; |
| 87 | extern const u16 macro_id_base_offset[MAX_MACRO]; |
| 88 | |
| 89 | #endif |