summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGirish BN <quic_gbn@quicinc.com>2022-01-27 17:14:31 +0530
committerCheney Ni <cheneyni@google.com>2022-04-20 02:40:50 +0000
commit1c99138025bf526d37fbbccd1fc33fa2266597da (patch)
treefe5a6acad95a139eb424831cc872a4cd15a1e7ee
parent217ce5e0d7c2658509dd43b42a6def4882f5c917 (diff)
downloadqcom-1c99138025bf526d37fbbccd1fc33fa2266597da.tar.gz
OOBS enhancement changes for Bluetooth Driver
- Handling GPIO and UART clock throw State machine. CRs-fixed: 3123484 Change-Id: I9b10b15f2150c51823e5eb670954d5b6a97a606e Signed-off-by: Girish BN <quic_gbn@quicinc.com> Signed-off-by: Cheney Ni <cheneyni@google.com>
-rw-r--r--btpower.c35
-rw-r--r--linux/btpower.h14
2 files changed, 43 insertions, 6 deletions
diff --git a/btpower.c b/btpower.c
index 909a4e8..fe74623 100644
--- a/btpower.c
+++ b/btpower.c
@@ -1301,6 +1301,9 @@ static long btpower_ioctl(struct file *file, unsigned int cmd, unsigned long arg
{
struct btpower_platform_data *drvdata = file->private_data;
int ret = 0, pwr_cntrl = 0;
+#ifdef CONFIG_MSM_BT_OOBS
+ enum btpower_obs_param clk_cntrl;
+#endif
int chipset_version = 0;
int itr, num_vregs;
const struct bt_power_vreg_data *vreg_info = NULL;
@@ -1324,12 +1327,32 @@ static long btpower_ioctl(struct file *file, unsigned int cmd, unsigned long arg
__func__, drvdata->bt_gpio_dev_wake);
return -EIO;
}
- pwr_cntrl = (int)arg;
- btpower_uart_transport_locked(drvdata, (pwr_cntrl == 1 ? true : false));
- gpio_set_value(drvdata->bt_gpio_dev_wake, pwr_cntrl);
- pr_debug("%s: BT_CMD_OBS_VOTE_CLOCK cntrl(%d) %s\n", __func__,
- pwr_cntrl, gpio_get_value(drvdata->bt_gpio_dev_wake) ?
- "Assert" : "Deassert");
+ clk_cntrl = (enum btpower_obs_param)arg;
+ switch (clk_cntrl) {
+ case BTPOWER_OBS_CLK_OFF:
+ btpower_uart_transport_locked(drvdata, false);
+ ret = 0;
+ break;
+ case BTPOWER_OBS_CLK_ON:
+ btpower_uart_transport_locked(drvdata, true);
+ ret = 0;
+ break;
+ case BTPOWER_OBS_DEV_OFF:
+ gpio_set_value(drvdata->bt_gpio_dev_wake, 0);
+ ret = 0;
+ break;
+ case BTPOWER_OBS_DEV_ON:
+ gpio_set_value(drvdata->bt_gpio_dev_wake, 1);
+ ret = 0;
+ break;
+ default:
+ pr_debug("%s: BT_CMD_OBS_VOTE_CLOCK clk_cntrl(%d)\n",
+ __func__, clk_cntrl);
+ return -EINVAL;
+ }
+ pr_debug("%s: BT_CMD_OBS_VOTE_CLOCK clk_cntrl(%d) %s\n", __func__,
+ clk_cntrl, gpio_get_value(drvdata->bt_gpio_dev_wake) ?
+ "Assert" : "Deassert");
break;
#endif
case BT_CMD_SLIM_TEST:
diff --git a/linux/btpower.h b/linux/btpower.h
index fa4e837..5909395 100644
--- a/linux/btpower.h
+++ b/linux/btpower.h
@@ -118,6 +118,20 @@ extern int btpower_aop_mbox_init(struct btpower_platform_data *drvdata);
#ifdef CONFIG_MSM_BT_OOBS
#define BT_CMD_OBS_SIGNAL_TASK 0xbfd0
#define BT_CMD_OBS_VOTE_CLOCK 0xbfd1
+
+/**
+ * enum btpower_obs_param: OOBS low power param
+ * @BTPOWER_OBS_CLK_OFF: Transport bus is no longer acquired
+ * @BTPOWER_OBS_CLK_ON: Acquire transport bus for either transmitting or receiving
+ * @BTPOWER_OBS_DEV_OFF: Bluetooth is released because of no more transmission
+ * @BTPOWER_OBS_DEV_ON: Wake up the Bluetooth controller for transmission
+ */
+enum btpower_obs_param {
+ BTPOWER_OBS_CLK_OFF = 0,
+ BTPOWER_OBS_CLK_ON,
+ BTPOWER_OBS_DEV_OFF,
+ BTPOWER_OBS_DEV_ON,
+};
#endif
#endif /* __LINUX_BLUETOOTH_POWER_H */