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

Commit a53ef3d8 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "USB: msm_otg: Implement VOLTAGE_NOW property for usb power supply"

parents 8ae4df9e 994f08bd
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -102,6 +102,8 @@ Optional properties :
	enable this feature without proper bus voting.
- qcom,disable-retention-with-vdd-min: If present don't allow phy retention but allow
	vdd min.
- qcom,usbin-vadc: Corresponding vadc device's phandle to read usbin voltage using VADC.
	This will be used to get value of usb power supply's VOLTAGE_NOW property.

Example HSUSB OTG controller device node :
	usb@f9690000 {
@@ -137,6 +139,7 @@ Example HSUSB OTG controller device node :
		qcom,hsusb-otg-vddmin-gpio = <&pm8019_mpps 6 0>;
		qcom,hsusb-otg-rw-during-lpm-workaround = <1>;
		qcom,disable-retention-with-vdd-min;
		qcom,usbin-vadc = <&pm8226_vadc>;
	};

MSM HSUSB EHCI controller
+26 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@
#include <linux/mfd/pm8xxx/pm8921-charger.h>
#include <linux/mfd/pm8xxx/misc.h>
#include <linux/mhl_8334.h>
#include <linux/qpnp/qpnp-adc.h>

#include <mach/msm_xo.h>
#include <mach/msm_bus.h>
@@ -3758,6 +3759,27 @@ static ssize_t msm_otg_bus_write(struct file *file, const char __user *ubuf,
	return count;
}

static int
otg_get_prop_usbin_voltage_now(struct msm_otg *motg)
{
	int rc = 0;
	struct qpnp_vadc_result results;

	if (IS_ERR_OR_NULL(motg->vadc_dev)) {
		motg->vadc_dev = qpnp_get_vadc(motg->phy.dev, "usbin");
		if (IS_ERR(motg->vadc_dev))
			return PTR_ERR(motg->vadc_dev);
	}

	rc = qpnp_vadc_read(motg->vadc_dev, USBIN, &results);
	if (rc) {
		pr_err("Unable to read usbin rc=%d\n", rc);
		return 0;
	} else {
		return results.physical;
	}
}

static int otg_power_get_property_usb(struct power_supply *psy,
				  enum power_supply_property psp,
				  union power_supply_propval *val)
@@ -3789,6 +3811,9 @@ static int otg_power_get_property_usb(struct power_supply *psy,
	case POWER_SUPPLY_PROP_HEALTH:
		val->intval = motg->usbin_health;
		break;
	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
		val->intval = otg_get_prop_usbin_voltage_now(motg);
		break;
	default:
		return -EINVAL;
	}
@@ -3859,6 +3884,7 @@ static enum power_supply_property otg_pm_power_props_usb[] = {
	POWER_SUPPLY_PROP_CURRENT_MAX,
	POWER_SUPPLY_PROP_SCOPE,
	POWER_SUPPLY_PROP_TYPE,
	POWER_SUPPLY_PROP_VOLTAGE_NOW,
};

const struct file_operations msm_otg_bus_fops = {
+1 −0
Original line number Diff line number Diff line
@@ -480,6 +480,7 @@ struct msm_otg {
	struct completion ext_chg_wait;
	int ui_enabled;
	bool pm_done;
	struct qpnp_vadc_chip	*vadc_dev;
};

struct ci13xxx_platform_data {