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

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

Merge "USB: dwc3-msm: Implement VOLTAGE_NOW property for usb power supply"

parents 613eaf41 6b6c4b3d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -49,6 +49,8 @@ Optional properties :
- qcom,no-suspend-resume: If present, the device will not perform any activity
		during suspend/resume
- qcom,usb-dbm : phandle for the DBM device
- 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,

Sub nodes:
- Sub node for "DWC3- USB3 controller".
@@ -69,6 +71,7 @@ Example MSM USB3.0 controller device node :
		qcom,dwc-usb3-msm-tx-fifo-size = <29696>;
		qcom,dwc-usb3-msm-qdss-tx-fifo-size = <16384>;
		qcom,usb-dbm = <&dbm_1p4>;
		qcom,usbin-vadc = <&pm8941_vadc>;

		qcom,msm_bus,name = "usb3";
		qcom,msm_bus,num_cases = <2>;
+26 −0
Original line number Diff line number Diff line
@@ -161,6 +161,7 @@ struct dwc3_msm {
	struct qpnp_adc_tm_chip *adc_tm_dev;
	struct delayed_work	init_adc_work;
	bool			id_adc_detect;
	struct qpnp_vadc_chip	*vadc_dev;
	u8			dcd_retries;
	u32			bus_perf_client;
	struct msm_bus_scale_pdata	*bus_scale_table;
@@ -1638,6 +1639,27 @@ static irqreturn_t msm_dwc3_irq(int irq, void *data)
	return IRQ_HANDLED;
}

static int
get_prop_usbin_voltage_now(struct dwc3_msm *mdwc)
{
	int rc = 0;
	struct qpnp_vadc_result results;

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

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

static int dwc3_msm_power_get_property_usb(struct power_supply *psy,
				  enum power_supply_property psp,
				  union power_supply_propval *val)
@@ -1663,6 +1685,9 @@ static int dwc3_msm_power_get_property_usb(struct power_supply *psy,
	case POWER_SUPPLY_PROP_TYPE:
		val->intval = psy->type;
		break;
	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
		val->intval = get_prop_usbin_voltage_now(mdwc);
		break;
	default:
		return -EINVAL;
	}
@@ -1799,6 +1824,7 @@ static enum power_supply_property dwc3_msm_pm_power_props_usb[] = {
	POWER_SUPPLY_PROP_CURRENT_MAX,
	POWER_SUPPLY_PROP_TYPE,
	POWER_SUPPLY_PROP_SCOPE,
	POWER_SUPPLY_PROP_VOLTAGE_NOW,
};

static void dwc3_init_adc_work(struct work_struct *w);