summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCheney Ni <cheneyni@google.com>2021-11-05 18:04:43 +0800
committerCheney Ni <cheneyni@google.com>2021-12-22 03:57:42 +0000
commitfa9bdcb11ba229f130d8ba045621a4b7956ef7d4 (patch)
tree0f40a720ee7d1ed333a957b9d54f885133fee99a
parenta55b58ec990c7665eeb5f7e75a881a165eeb9560 (diff)
downloadqcom-fa9bdcb11ba229f130d8ba045621a4b7956ef7d4.tar.gz
btpower: control GPIO to enable BUCK for BT AON
Enable the BUCK while Bluetooth is enabled, and keep it as ON. Bug: 202098667 Test: manually Signed-off-by: Cheney Ni <cheneyni@google.com> Change-Id: I3bd36762f34e21c213edfdecb17510e33f2d5051
-rw-r--r--btpower.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/btpower.c b/btpower.c
index d6cc98f..1faf64e 100644
--- a/btpower.c
+++ b/btpower.c
@@ -413,33 +413,33 @@ static void btpower_set_xo_clk_gpio_state(struct btpower_platform_data *drvdata,
if (!gpio_is_valid(xo_clk_gpio))
return;
-retry_gpio_req:
- rc = gpio_request(xo_clk_gpio, "bt_xo_clk_gpio");
- if (rc) {
- if (retry++ < XO_CLK_RETRY_COUNT_MAX) {
- /* wait for ~(10 - 20) ms */
- usleep_range(10000, 20000);
- goto retry_gpio_req;
+ do {
+ rc = gpio_request(xo_clk_gpio, "bt_xo_clk_gpio");
+ if (rc == 0)
+ break;
+ if (retry++ >= XO_CLK_RETRY_COUNT_MAX) {
+ pr_err("%s: unable to request XO clk gpio %d (%d)\n",
+ __func__, xo_clk_gpio, rc);
+ return;
}
- }
-
- if (rc) {
- pr_err("%s: unable to request XO clk gpio %d (%d)\n",
- __func__, xo_clk_gpio, rc);
- return;
- }
+ /* wait for ~(10 - 20) ms and try again */
+ usleep_range(10000, 20000);
+ } while (1);
+ rc = gpio_get_value(xo_clk_gpio);
if (enable) {
gpio_direction_output(xo_clk_gpio, 1);
- /*XO CLK must be asserted for some time before BT_EN */
- usleep_range(100, 200);
+ /* XO CLK must be asserted for some time before BT_EN */
+ usleep_range(5000, 7000);
} else {
/* Assert XO CLK ~(2-5)ms before off for valid latch in HW */
usleep_range(4000, 6000);
gpio_direction_output(xo_clk_gpio, 0);
}
- pr_debug("%s: gpio(%d) success\n", __func__, xo_clk_gpio);
+ if (rc != enable)
+ pr_info("%s: gpio(%d) %d to %d\n", __func__, xo_clk_gpio, rc,
+ enable);
gpio_free(xo_clk_gpio);
}
@@ -519,7 +519,6 @@ static int bt_configure_gpios(struct btpower_platform_data *drvdata, bool on)
btpower_set_xo_clk_gpio_state(drvdata, true);
pr_info("%s: BT-ON asserting BT_EN (with WLAN)\n", __func__);
SET_GPIO_SOURCE_STATE(drvdata, bt_reset_gpio, BT_RESET_GPIO, 1);
- btpower_set_xo_clk_gpio_state(drvdata, false);
}
if (gpio_is_valid(wl_reset_gpio) && !gpio_get_value(wl_reset_gpio)) {
if (gpio_get_value(bt_reset_gpio)) {
@@ -534,7 +533,6 @@ static int bt_configure_gpios(struct btpower_platform_data *drvdata, bool on)
btpower_set_xo_clk_gpio_state(drvdata, true);
pr_info("%s: BT-ON asserting BT_EN without WLAN\n", __func__);
SET_GPIO_SOURCE_STATE(drvdata, bt_reset_gpio, BT_RESET_GPIO, 1);
- btpower_set_xo_clk_gpio_state(drvdata, false);
}
msleep(50);