Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d603e191 authored by Harish Bandi's avatar Harish Bandi
Browse files

Bluetooth: Add the support for wcn3980 in SDM429w



Enable the new msm GPIO's to enable eLDO for
3.3v and 1.3v to turn on wcn3980.

Change-Id: Id476b187336906cddd66621471afa20dd8924b40
Signed-off-by: default avatarHarish Bandi <hbandi@codeaurora.org>
parent feb2bf44
Loading
Loading
Loading
Loading
+85 −0
Original line number Diff line number Diff line
@@ -242,6 +242,64 @@ static int bt_clk_disable(struct bt_power_clk_data *clk)
	return rc;
}

static int bt_configure_gpios_2wcn(int on)
{
	int rc = 0;
	int bt_3p3_en_gpio = bt_power_pdata->bt_gpio_3p3_en;
	int bt_1p3_en_gpio = bt_power_pdata->bt_gpio_1p3_en;

	BT_PWR_DBG("2wcn - bt_gpio= %d on: %d", bt_3p3_en_gpio, on);

	if (on) {
		rc = gpio_request(bt_3p3_en_gpio, "bt_3p3_en_n");
		if (rc) {
			BT_PWR_ERR("unable to request gpio %d (%d)\n",
					bt_3p3_en_gpio, rc);
			return rc;
		}

		rc = gpio_direction_output(bt_3p3_en_gpio, 0);
		if (rc) {
			BT_PWR_ERR("Unable to set direction\n");
			return rc;
		}
		msleep(50);
		rc = gpio_direction_output(bt_3p3_en_gpio, 1);
		if (rc) {
			BT_PWR_ERR("Unable to set direction\n");
			return rc;
		}
		msleep(50);

		rc = gpio_request(bt_1p3_en_gpio, "bt_1p3_en_n");
		if (rc) {
			BT_PWR_ERR("unable to request gpio %d (%d)\n",
					bt_1p3_en_gpio, rc);
			return rc;
		}

		rc = gpio_direction_output(bt_1p3_en_gpio, 0);
		if (rc) {
			BT_PWR_ERR("Unable to set direction\n");
			return rc;
		}
		msleep(50);
		rc = gpio_direction_output(bt_1p3_en_gpio, 1);
		if (rc) {
			BT_PWR_ERR("Unable to set direction\n");
			return rc;
		}
		msleep(50);
	} else {
		gpio_set_value(bt_3p3_en_gpio, 0);
		msleep(100);
		gpio_set_value(bt_1p3_en_gpio, 0);
		msleep(100);
	}
	return rc;
}


static int bt_configure_gpios(int on)
{
	int rc = 0;
@@ -305,12 +363,27 @@ static int bluetooth_power(int on)
				goto gpio_fail;
			}
		}
		if (bt_power_pdata->bt_gpio_3p3_en > 0) {
			BT_PWR_ERR(
			"bt_power gpio config start for  2wcn gpios");
			rc = bt_configure_gpios_2wcn(on);
			if (rc < 0) {
				BT_PWR_ERR("bt_power gpio config failed");
				goto gpio_fail;
			}
		}
	} else {
		if (bt_power_pdata->bt_gpio_sys_rst > 0)
			bt_configure_gpios(on);
		if (bt_power_pdata->bt_gpio_3p3_en > 0)
			bt_configure_gpios_2wcn(on);
gpio_fail:
		if (bt_power_pdata->bt_gpio_sys_rst > 0)
			gpio_free(bt_power_pdata->bt_gpio_sys_rst);
		if (bt_power_pdata->bt_gpio_3p3_en > 0)
			gpio_free(bt_power_pdata->bt_gpio_3p3_en);
		if (bt_power_pdata->bt_gpio_1p3_en > 0)
			gpio_free(bt_power_pdata->bt_gpio_1p3_en);
		if (bt_power_pdata->bt_chip_clk)
			bt_clk_disable(bt_power_pdata->bt_chip_clk);
clk_fail:
@@ -584,6 +657,18 @@ static int bt_power_populate_dt_pinfo(struct platform_device *pdev)
		if (bt_power_pdata->bt_gpio_sys_rst < 0)
			BT_PWR_ERR("bt-reset-gpio not provided in device tree");

		bt_power_pdata->bt_gpio_3p3_en =
			of_get_named_gpio(pdev->dev.of_node,
						"qca,bt-3P3-en-gpio", 0);
		if (bt_power_pdata->bt_gpio_3p3_en < 0)
			BT_PWR_INFO("bt-3P3-gpio not provided in devicetree");

		bt_power_pdata->bt_gpio_1p3_en =
			of_get_named_gpio(pdev->dev.of_node,
						"qca,bt-1P3-en-gpio", 0);
		if (bt_power_pdata->bt_gpio_1p3_en < 0)
			BT_PWR_INFO("bt-1P3-gpio not provided in devicetree");

		rc = bt_dt_parse_clk_info(&pdev->dev,
					&bt_power_pdata->bt_chip_clk);
		if (rc < 0)
+5 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2013-2018,2020, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -59,6 +59,10 @@ struct bt_power_clk_data {
struct bluetooth_power_platform_data {
	/* Bluetooth reset gpio */
	int bt_gpio_sys_rst;
	/* Bluetooth 3p3 gpio */
	int bt_gpio_3p3_en;
	/* Bluetooth 1p3 gpio */
	int bt_gpio_1p3_en;
	struct device *slim_dev;
	/* VDDIO voltage regulator */
	struct bt_power_vreg_data *vreg_info;