Bluetooth: Update power sources for auto BT SoCs

This change will add all the power sources which are needed
for automotive BT SoCs QCA6574/QCA6595/QCA6696.

Change-Id: Icaa9d6fe9d8fc8f51a23caeaa6dd950757b6c7ef
Signed-off-by: Xiaoning Ma <mxiaonin@codeaurora.org>
This commit is contained in:
Xiaoning Ma 2021-02-01 14:40:22 +08:00 • committed by Gerrit - the friendly Code Review server
commit 8b5a8ca0aa

View file

@ -32,10 +32,18 @@
#endif
#include <linux/fs.h>
#define PWR_SRC_STATUS_SET(index, status) do { \
if (index >= PWR_SRC_INIT_STATE_IDX && index < BT_POWER_SRC_SIZE) { \
bt_power_src_status[index] = (int) status; \
} \
} while (0)
#define PWR_SRC_NOT_AVAILABLE -2
#define DEFAULT_INVALID_VALUE -1
#define PWR_SRC_INIT_STATE_IDX 0
#define PWR_SRC_LOG_UNSUPPORTED {DEFAULT_INVALID_VALUE, DEFAULT_INVALID_VALUE}
enum power_src_pos {
BT_RESET_GPIO = PWR_SRC_INIT_STATE_IDX,
BT_SW_CTRL_GPIO,
@ -119,6 +127,25 @@ static struct bt_power bt_vreg_info_wcn399x = {
.num_vregs = 4,
};
static struct bt_power bt_vreg_info_qca_auto = {
.compatible = "qcom,qca-auto-converged",
.vregs = (struct bt_power_vreg_data []) {
{NULL, "qcom,bt-vdd-ctrl1", 0, 0, 0, false, false,
PWR_SRC_LOG_UNSUPPORTED},
{NULL, "qcom,bt-vdd-ctrl2", 0, 0, 0, false, false,
PWR_SRC_LOG_UNSUPPORTED},
{NULL, "qcom,bt-vdd-aon", 1055000, 1055000, 0, false, false,
PWR_SRC_LOG_UNSUPPORTED},
{NULL, "qcom,bt-vdd-rfa1", 1370000, 1370000, 0, false, false,
PWR_SRC_LOG_UNSUPPORTED},
{NULL, "qcom,bt-vdd-rfa2", 2040000, 2040000, 0, false, false,
PWR_SRC_LOG_UNSUPPORTED},
{NULL, "qcom,bt-vdd-rfa3", 1900000, 1900000, 0, false, false,
PWR_SRC_LOG_UNSUPPORTED},
},
.num_vregs = 6,
};
static struct bt_power bt_vreg_info_qca6174 = {
.compatible = "qcom,qca6174",
.vregs = bt_vregs_info_qca61x4_937x,
@ -149,6 +176,7 @@ static const struct of_device_id bt_power_match_table[] = {
{ .compatible = "qcom,qca6390", .data = &bt_vreg_info_qca6390},
{ .compatible = "qcom,qca6490", .data = &bt_vreg_info_qca6490},
{ .compatible = "qcom,wcn6750-bt", .data = &bt_vreg_info_wcn6750},
{ .compatible = "qcom,qca-auto-converged", .data = &bt_vreg_info_qca_auto},
{},
};
@ -347,15 +375,15 @@ static int bt_configure_gpios(int on)
pr_err("%s: Unable to set direction\n", __func__);
return rc;
}
bt_power_src_status[BT_RESET_GPIO] =
gpio_get_value(bt_reset_gpio);
PWR_SRC_STATUS_SET(BT_RESET_GPIO,
gpio_get_value(bt_reset_gpio));
msleep(50);
pr_info("BTON:Turn Bt Off bt-reset-gpio(%d) value(%d)\n",
bt_reset_gpio, gpio_get_value(bt_reset_gpio));
if (bt_sw_ctrl_gpio >= 0) {
pr_info("BTON:Turn Bt Off\n");
bt_power_src_status[BT_SW_CTRL_GPIO] =
gpio_get_value(bt_sw_ctrl_gpio);
PWR_SRC_STATUS_SET(BT_SW_CTRL_GPIO,
gpio_get_value(bt_sw_ctrl_gpio));
pr_info("bt-sw-ctrl-gpio(%d) value(%d)\n",
bt_sw_ctrl_gpio,
bt_power_src_status[BT_SW_CTRL_GPIO]);
@ -372,8 +400,8 @@ static int bt_configure_gpios(int on)
pr_err("%s: Unable to set direction\n", __func__);
return rc;
}
bt_power_src_status[BT_RESET_GPIO] =
gpio_get_value(bt_reset_gpio);
PWR_SRC_STATUS_SET(BT_RESET_GPIO,
gpio_get_value(bt_reset_gpio));
}
if ((wl_reset_gpio >= 0) && (gpio_get_value(wl_reset_gpio) == 0)) {
if (gpio_get_value(bt_reset_gpio)) {
@ -384,8 +412,8 @@ static int bt_configure_gpios(int on)
pr_err("%s: Unable to set direction\n", __func__);
return rc;
}
bt_power_src_status[BT_RESET_GPIO] =
gpio_get_value(bt_reset_gpio);
PWR_SRC_STATUS_SET(BT_RESET_GPIO,
gpio_get_value(bt_reset_gpio));
}
pr_info("%s:add 100ms delay for AON output to fully discharge\n",
__func__);
@ -452,8 +480,8 @@ static int bt_configure_gpios(int on)
bt_reset_gpio, gpio_get_value(bt_reset_gpio));
if (bt_sw_ctrl_gpio >= 0) {
pr_info("BTON:Turn Bt On\n");
bt_power_src_status[BT_SW_CTRL_GPIO] =
gpio_get_value(bt_sw_ctrl_gpio);
PWR_SRC_STATUS_SET(BT_SW_CTRL_GPIO,
gpio_get_value(bt_sw_ctrl_gpio));
pr_info("bt-sw-ctrl-gpio(%d) value(%d)\n",
bt_sw_ctrl_gpio,
bt_power_src_status[BT_SW_CTRL_GPIO]);
@ -500,10 +528,10 @@ static int bluetooth_power(int on)
}
}
if (bt_power_pdata->bt_gpio_sys_rst > 0) {
bt_power_src_status[BT_RESET_GPIO] =
DEFAULT_INVALID_VALUE;
bt_power_src_status[BT_SW_CTRL_GPIO] =
DEFAULT_INVALID_VALUE;
PWR_SRC_STATUS_SET(BT_RESET_GPIO,
DEFAULT_INVALID_VALUE);
PWR_SRC_STATUS_SET(BT_SW_CTRL_GPIO,
DEFAULT_INVALID_VALUE);
rc = bt_configure_gpios(on);
if (rc < 0) {
pr_err("%s: bt_power gpio config failed\n",
@ -748,15 +776,15 @@ static int bt_power_vreg_set(enum bt_power_modes mode)
vreg_info = &bt_power_pdata->vreg_info[i];
log_indx = vreg_info->indx.init;
if (vreg_info->reg) {
bt_power_src_status[log_indx] =
DEFAULT_INVALID_VALUE;
PWR_SRC_STATUS_SET(log_indx,
DEFAULT_INVALID_VALUE);
ret = bt_vreg_enable(vreg_info);
if (ret < 0)
goto out;
if (vreg_info->is_enabled) {
bt_power_src_status[log_indx] =
PWR_SRC_STATUS_SET(log_indx,
regulator_get_voltage(
vreg_info->reg);
vreg_info->reg));
}
}
}
@ -863,7 +891,7 @@ static int bt_power_probe(struct platform_device *pdev)
*/
for (itr = PWR_SRC_INIT_STATE_IDX;
itr < BT_POWER_SRC_SIZE; ++itr)
bt_power_src_status[itr] = PWR_SRC_NOT_AVAILABLE;
PWR_SRC_STATUS_SET(itr, PWR_SRC_NOT_AVAILABLE);
bt_power_pdata = kzalloc(sizeof(*bt_power_pdata), GFP_KERNEL);
@ -942,17 +970,17 @@ EXPORT_SYMBOL(btpower_get_chipset_version);
static void set_pwr_srcs_status(struct bt_power_vreg_data *handle)
{
int ldo_index;
int ldo_vol;
if (handle) {
ldo_index = handle->indx.crash;
bt_power_src_status[ldo_index] =
DEFAULT_INVALID_VALUE;
PWR_SRC_STATUS_SET(ldo_index, DEFAULT_INVALID_VALUE);
if (handle->is_enabled &&
(regulator_is_enabled(handle->reg))) {
bt_power_src_status[ldo_index] =
(int)regulator_get_voltage(handle->reg);
ldo_vol = regulator_get_voltage(handle->reg);
PWR_SRC_STATUS_SET(ldo_index, ldo_vol);
pr_err("%s(%d) value(%d)\n", handle->name,
handle, bt_power_src_status[ldo_index]);
handle, ldo_vol);
} else {
pr_err("%s:%s is_enabled: %d\n",
__func__, handle->name,
@ -964,13 +992,13 @@ static void set_pwr_srcs_status(struct bt_power_vreg_data *handle)
static void set_gpios_srcs_status(char *gpio_name,
int gpio_index, int handle)
{
int gpio_val;
if (handle >= 0) {
bt_power_src_status[gpio_index] =
DEFAULT_INVALID_VALUE;
bt_power_src_status[gpio_index] =
gpio_get_value(handle);
gpio_val = gpio_get_value(handle);
PWR_SRC_STATUS_SET(gpio_index, gpio_val);
pr_err("%s(%d) value(%d)\n", gpio_name,
handle, bt_power_src_status[gpio_index]);
handle, gpio_val);
} else {
pr_err("%s: %s not configured\n",
__func__, gpio_name);
@ -1034,8 +1062,8 @@ static long bt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
/* Check if SW_CTRL is asserted */
pr_info("BT_CMD_CHECK_SW_CTRL\n");
if (bt_power_pdata->bt_gpio_sw_ctrl > 0) {
bt_power_src_status[BT_SW_CTRL_GPIO] =
DEFAULT_INVALID_VALUE;
PWR_SRC_STATUS_SET(BT_SW_CTRL_GPIO,
DEFAULT_INVALID_VALUE);
ret = gpio_direction_input(
bt_power_pdata->bt_gpio_sw_ctrl);
if (ret) {
@ -1044,9 +1072,9 @@ static long bt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
pr_err("%s:failed for SW_CTRL:%d\n",
__func__, ret);
} else {
bt_power_src_status[BT_SW_CTRL_GPIO] =
PWR_SRC_STATUS_SET(BT_SW_CTRL_GPIO,
gpio_get_value(
bt_power_pdata->bt_gpio_sw_ctrl);
bt_power_pdata->bt_gpio_sw_ctrl));
pr_info("bt-sw-ctrl-gpio(%d) value(%d)\n",
bt_power_pdata->bt_gpio_sw_ctrl,
bt_power_src_status[BT_SW_CTRL_GPIO]);