From 361cb9feac012a0ac1b88cf1681a7fdb1435aaf8 Mon Sep 17 00:00:00 2001 From: priyankar Date: Mon, 1 Mar 2021 14:34:18 +0530 Subject: [PATCH] Disable ASD regulator if HST is attached This patch contains changes for disabling ASD regulator if HST is attached. Change-Id: Ic1f6515861600f8bebc1d065ce51d7df5a3f28db Signed-off-by: priyankar --- drivers/bluetooth/btpower.c | 29 +++++++++++++++++++++++++++++ include/linux/btpower.h | 10 +++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/btpower.c b/drivers/bluetooth/btpower.c index 0ce0cc63cc70..a50493a9c5fa 100644 --- a/drivers/bluetooth/btpower.c +++ b/drivers/bluetooth/btpower.c @@ -830,6 +830,27 @@ static void bt_power_vreg_put(void) } } +static int bt_disable_asd(void) +{ + int rc = 0; + int i; + int num_vregs = bt_power_pdata->num_vregs; + struct bt_power_vreg_data *vreg_info = NULL; + + for (i = 0; i < num_vregs; i++) { + vreg_info = &bt_power_pdata->vreg_info[i]; + if (strnstr(vreg_info->name, "bt-vdd-asd", sizeof(vreg_info->name))) { + if (vreg_info->reg) { + pr_warn("%s: Disabling ASD regulator\n", __func__); + rc = bt_vreg_disable(vreg_info); + } else { + pr_warn("%s: ASD regulator is not configured\n", __func__); + } + break; + } + } + return rc; +} static int bt_power_populate_dt_pinfo(struct platform_device *pdev) { @@ -1056,6 +1077,14 @@ static long bt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) chipset_version); if (chipset_version) { soc_id = chipset_version; + if (soc_id == HASTINGS_SOC_ID_0100 || + soc_id == HASTINGS_SOC_ID_0101 || + soc_id == HASTINGS_SOC_ID_0110 || + soc_id == HASTINGS_SOC_ID_0200) { + ret = bt_disable_asd(); + if (ret >= 0) + PWR_SRC_STATUS_SET(BT_VDD_ASD_LDO, PWR_SRC_NOT_AVAILABLE); + } } else { pr_err("%s: got invalid soc version\n", __func__); soc_id = 0; diff --git a/include/linux/btpower.h b/include/linux/btpower.h index d670e446ca1c..57b235733d62 100644 --- a/include/linux/btpower.h +++ b/include/linux/btpower.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. */ #ifndef __LINUX_BLUETOOTH_POWER_H @@ -18,6 +18,14 @@ enum bt_power_modes { BT_POWER_RETENTION }; +/* Hasting chipset version information */ +enum { + HASTINGS_SOC_ID_0100 = 0x400A0100, + HASTINGS_SOC_ID_0101 = 0x400A0101, + HASTINGS_SOC_ID_0110 = 0x400A0110, + HASTINGS_SOC_ID_0200 = 0x400A0200, +}; + struct log_index { int init; int crash;