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

Commit 6fc1617a authored by Sungjun Park's avatar Sungjun Park Committed by SungJun Park
Browse files

Bluetooth: Add external LDO check routine for Rome



For 1.1V on Rome, it can be used by either internal LDO or
external LDO based on platform.

Change-Id: Icbb64d92fbe529fa0fac53e50a06497f3cca98b8
Signed-off-by: default avatarSungJun Park <sjpark@codeaurora.org>
parent 0d38f7ef
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -30,6 +30,6 @@ Example:
    qca,bt-vdd-io-supply = <&pm8941_s3>;
    qca,bt-vdd-pa-supply = <&pm8941_l19>;
    qca,bt-chip-pwd-supply = <&ath_chip_pwd_l>;
    qca,bt-vdd-io-supply = <1800000 1800000>;
    qca,bt-vdd-pa-supply = <2900000 2900000>;
    qca,bt-vdd-io-voltage-level = <1800000 1800000>;
    qca,bt-vdd-pa-voltage-level = <2900000 2900000>;
  };
+43 −8
Original line number Diff line number Diff line
@@ -26,6 +26,9 @@
#include <linux/bluetooth-power.h>
#include <linux/slab.h>
#include <linux/regulator/consumer.h>
#ifdef CONFIG_CNSS
#include <net/cnss.h>
#endif

#define BT_PWR_DBG(fmt, arg...)  pr_debug("%s: " fmt "\n" , __func__ , ## arg)
#define BT_PWR_INFO(fmt, arg...) pr_info("%s: " fmt "\n" , __func__ , ## arg)
@@ -196,13 +199,6 @@ static int bluetooth_power(int on)
				goto out;
			}
		}
		if (bt_power_pdata->bt_vdd_ldo) {
			rc = bt_configure_vreg(bt_power_pdata->bt_vdd_ldo);
			if (rc < 0) {
				BT_PWR_ERR("bt_power vddldo config failed");
				goto vdd_ldo_fail;
			}
		}
		if (bt_power_pdata->bt_vdd_pa) {
			rc = bt_configure_vreg(bt_power_pdata->bt_vdd_pa);
			if (rc < 0) {
@@ -210,6 +206,13 @@ static int bluetooth_power(int on)
				goto vdd_pa_fail;
			}
		}
		if (bt_power_pdata->bt_vdd_ldo) {
			rc = bt_configure_vreg(bt_power_pdata->bt_vdd_ldo);
			if (rc < 0) {
				BT_PWR_ERR("bt_power vddldo config failed");
				goto vdd_ldo_fail;
			}
		}
		if (bt_power_pdata->bt_chip_pwd) {
			rc = bt_configure_vreg(bt_power_pdata->bt_chip_pwd);
			if (rc < 0) {
@@ -261,6 +264,33 @@ static const struct rfkill_ops bluetooth_power_rfkill_ops = {
	.set_block = bluetooth_toggle_radio,
};

#ifdef CONFIG_CNSS
static ssize_t enable_extldo(struct device *dev, struct device_attribute *attr,
			char *buf)
{
	int ret;
	bool enable = false;
	struct cnss_platform_cap cap;

	ret = cnss_get_platform_cap(&cap);
	if (ret) {
		BT_PWR_ERR("Platform capability info from CNSS not available!");
		enable = false;
	} else if (!ret && (cap.cap_flag & CNSS_HAS_EXTERNAL_SWREG)) {
		enable = true;
	}
	return snprintf(buf, 6, "%s", (enable ? "true" : "false"));
}
#else
static ssize_t enable_extldo(struct device *dev, struct device_attribute *attr,
			char *buf)
{
	return snprintf(buf, 6, "%s", "false");
}
#endif

static DEVICE_ATTR(extldo, S_IRUGO, enable_extldo, NULL);

static int bluetooth_power_rfkill_probe(struct platform_device *pdev)
{
	struct rfkill *rfkill;
@@ -275,6 +305,11 @@ static int bluetooth_power_rfkill_probe(struct platform_device *pdev)
		return -ENOMEM;
	}

	/* add file into rfkill0 to handle LDO27 */
	ret = device_create_file(&pdev->dev, &dev_attr_extldo);
	if (ret < 0)
		BT_PWR_ERR("device create file error!");

	/* force Bluetooth off during init to allow for user control */
	rfkill_init_sw_state(rfkill, 1);
	previous = 1;
@@ -328,7 +363,7 @@ static int bt_dt_parse_vreg_info(struct device *dev,
		vreg->name = vreg_name;

		snprintf(prop_name, MAX_PROP_SIZE,
				"qcom,%s-voltage-level", vreg_name);
				"%s-voltage-level", vreg_name);
		prop = of_get_property(np, prop_name, &len);
		if (!prop || (len != (2 * sizeof(__be32)))) {
			dev_warn(dev, "%s %s property\n",