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

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

Merge "power: qpnp-smbcharger: Report charger types in REAL_TYPE property"

parents d6f2095d 73e857e0
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
/* Copyright (c) 2014-2017 The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2018 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
@@ -4653,6 +4653,7 @@ static int smbchg_change_usb_supply_type(struct smbchg_chip *chip,
						enum power_supply_type type)
{
	int rc, current_limit_ma;
	union power_supply_propval propval;

	/*
	 * if the type is not unknown, set the type before changing ICL vote
@@ -4691,8 +4692,12 @@ static int smbchg_change_usb_supply_type(struct smbchg_chip *chip,
		goto out;
	}

	if (!chip->skip_usb_notification)
		power_supply_set_supply_type(chip->usb_psy, type);
	if (!chip->skip_usb_notification) {
		propval.intval = type;
		chip->usb_psy->set_property(chip->usb_psy,
				POWER_SUPPLY_PROP_REAL_TYPE,
				&propval);
	}

	/*
	 * otherwise if it is unknown, remove vote
@@ -6064,7 +6069,7 @@ static void smbchg_external_power_changed(struct power_supply *psy)
		current_limit = prop.intval / 1000;

	rc = chip->usb_psy->get_property(chip->usb_psy,
				POWER_SUPPLY_PROP_TYPE, &prop);
				POWER_SUPPLY_PROP_REAL_TYPE, &prop);

	read_usb_type(chip, &usb_type_name, &usb_supply_type);

+27 −7
Original line number Diff line number Diff line
/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2018, 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
@@ -238,6 +238,7 @@ struct dwc3_msm {
	u32			bus_perf_client;
	struct msm_bus_scale_pdata	*bus_scale_table;
	struct power_supply	usb_psy;
	enum power_supply_type	usb_supply_type;
	unsigned int		online;
	bool			in_host_mode;
	unsigned int		voltage_max;
@@ -2511,6 +2512,9 @@ static int dwc3_msm_power_get_property_usb(struct power_supply *psy,
	case POWER_SUPPLY_PROP_ONLINE:
		val->intval = mdwc->online;
		break;
	case POWER_SUPPLY_PROP_REAL_TYPE:
		val->intval = mdwc->usb_supply_type;
		break;
	case POWER_SUPPLY_PROP_TYPE:
		val->intval = psy->type;
		break;
@@ -2619,10 +2623,22 @@ static int dwc3_msm_power_set_property_usb(struct power_supply *psy,
						mdwc->bc1p2_current_max);
		}
		break;
	case POWER_SUPPLY_PROP_TYPE:
		psy->type = val->intval;

		switch (psy->type) {
	case POWER_SUPPLY_PROP_REAL_TYPE:
		mdwc->usb_supply_type = val->intval;
		/*
		 * Update TYPE property to DCP for HVDCP/HVDCP3 charger types
		 * so that they can be recongized as AC chargers by healthd.
		 * Don't report UNKNOWN charger type to prevent healthd missing
		 * detecting this power_supply status change.
		 */
		if (mdwc->usb_supply_type == POWER_SUPPLY_TYPE_USB_HVDCP_3
			|| mdwc->usb_supply_type == POWER_SUPPLY_TYPE_USB_HVDCP)
			psy->type = POWER_SUPPLY_TYPE_USB_DCP;
		else if (mdwc->usb_supply_type == POWER_SUPPLY_TYPE_UNKNOWN)
			psy->type = POWER_SUPPLY_TYPE_USB;
		else
			psy->type = mdwc->usb_supply_type;
		switch (mdwc->usb_supply_type) {
		case POWER_SUPPLY_TYPE_USB:
			mdwc->chg_type = DWC3_SDP_CHARGER;
			mdwc->voltage_max = MICRO_5V;
@@ -2674,7 +2690,7 @@ dwc3_msm_property_is_writeable(struct power_supply *psy,
	case POWER_SUPPLY_PROP_PRESENT:
	case POWER_SUPPLY_PROP_VOLTAGE_MAX:
	case POWER_SUPPLY_PROP_INPUT_CURRENT_MAX:
	case POWER_SUPPLY_PROP_TYPE:
	case POWER_SUPPLY_PROP_REAL_TYPE:
		return 1;
	default:
		break;
@@ -2698,6 +2714,7 @@ static enum power_supply_property dwc3_msm_pm_power_props_usb[] = {
	POWER_SUPPLY_PROP_TYPE,
	POWER_SUPPLY_PROP_HEALTH,
	POWER_SUPPLY_PROP_USB_OTG,
	POWER_SUPPLY_PROP_REAL_TYPE,
};

static irqreturn_t dwc3_pmic_id_irq(int irq, void *data)
@@ -3754,6 +3771,7 @@ static int dwc3_otg_start_peripheral(struct dwc3_msm *mdwc, int on)
static int dwc3_msm_gadget_vbus_draw(struct dwc3_msm *mdwc, unsigned mA)
{
	enum power_supply_type power_supply_type;
	union power_supply_propval propval;

	if (mdwc->charging_disabled)
		return 0;
@@ -3778,7 +3796,9 @@ static int dwc3_msm_gadget_vbus_draw(struct dwc3_msm *mdwc, unsigned mA)
	else
		power_supply_type = POWER_SUPPLY_TYPE_UNKNOWN;

	power_supply_set_supply_type(&mdwc->usb_psy, power_supply_type);
	propval.intval = power_supply_type;
	mdwc->usb_psy.set_property(&mdwc->usb_psy,
			POWER_SUPPLY_PROP_REAL_TYPE, &propval);

skip_psy_type:

+30 −9
Original line number Diff line number Diff line
/* Copyright (c) 2009-2017, Linux Foundation. All rights reserved.
/* Copyright (c) 2009-2018, 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
@@ -1715,7 +1715,7 @@ static void msm_otg_notify_host_mode(struct msm_otg *motg, bool host_mode)
static int msm_otg_notify_chg_type(struct msm_otg *motg)
{
	static int charger_type;

	union power_supply_propval propval;
	/*
	 * TODO
	 * Unify OTG driver charger types and power supply charger types
@@ -1742,7 +1742,10 @@ static int msm_otg_notify_chg_type(struct msm_otg *motg)
	pr_debug("setting usb power supply type %d\n", charger_type);
	msm_otg_dbg_log_event(&motg->phy, "SET USB PWR SUPPLY TYPE",
			motg->chg_type, charger_type);
	power_supply_set_supply_type(psy, charger_type);

	propval.intval = charger_type;
	psy->set_property(psy, POWER_SUPPLY_PROP_REAL_TYPE, &propval);

	return 0;
}

@@ -3525,6 +3528,9 @@ static int otg_power_get_property_usb(struct power_supply *psy,
	case POWER_SUPPLY_PROP_ONLINE:
		val->intval = motg->online;
		break;
	case POWER_SUPPLY_PROP_REAL_TYPE:
		val->intval = motg->usb_supply_type;
		break;
	case POWER_SUPPLY_PROP_TYPE:
		val->intval = psy->type;
		break;
@@ -3550,7 +3556,8 @@ static int otg_power_set_property_usb(struct power_supply *psy,
	struct msm_otg *motg = container_of(psy, struct msm_otg, usb_psy);
	struct msm_otg_platform_data *pdata = motg->pdata;

	msm_otg_dbg_log_event(&motg->phy, "SET PWR PROPERTY", psp, psy->type);
	msm_otg_dbg_log_event(&motg->phy, "SET PWR PROPERTY",
				psp, motg->usb_supply_type);
	switch (psp) {
	case POWER_SUPPLY_PROP_USB_OTG:
		motg->id_state = val->intval ? USB_ID_GROUND : USB_ID_FLOAT;
@@ -3594,9 +3601,21 @@ static int otg_power_set_property_usb(struct power_supply *psy,
			msm_otg_notify_charger(motg, motg->bc1p2_current_max);
		}
		break;
	case POWER_SUPPLY_PROP_TYPE:
		psy->type = val->intval;

	case POWER_SUPPLY_PROP_REAL_TYPE:
		motg->usb_supply_type = val->intval;
		/*
		 * Update TYPE property to DCP for HVDCP/HVDCP3 charger types
		 * so that they can be recongized as AC chargers by healthd.
		 * Don't report UNKNOWN charger type to prevent healthd missing
		 * detecting this power_supply status change.
		 */
		if (motg->usb_supply_type == POWER_SUPPLY_TYPE_USB_HVDCP_3
			|| motg->usb_supply_type == POWER_SUPPLY_TYPE_USB_HVDCP)
			psy->type = POWER_SUPPLY_TYPE_USB_DCP;
		else if (motg->usb_supply_type == POWER_SUPPLY_TYPE_UNKNOWN)
			psy->type = POWER_SUPPLY_TYPE_USB;
		else
			psy->type = motg->usb_supply_type;
		/*
		 * If charger detection is done by the USB driver,
		 * motg->chg_type is already assigned in the
@@ -3611,7 +3630,7 @@ static int otg_power_set_property_usb(struct power_supply *psy,
		if (motg->chg_state == USB_CHG_STATE_DETECTED)
			break;

		switch (psy->type) {
		switch (motg->usb_supply_type) {
		case POWER_SUPPLY_TYPE_USB:
			motg->chg_type = USB_SDP_CHARGER;
			motg->voltage_max = MICRO_5V;
@@ -3650,7 +3669,7 @@ static int otg_power_set_property_usb(struct power_supply *psy,
		dev_dbg(motg->phy.dev, "%s: charger type = %s\n", __func__,
			chg_to_string(motg->chg_type));
		msm_otg_dbg_log_event(&motg->phy, "SET CHARGER TYPE ",
				motg->chg_type, psy->type);
				motg->chg_type, motg->usb_supply_type);
		break;
	case POWER_SUPPLY_PROP_HEALTH:
		if (val->intval > POWER_SUPPLY_HEALTH_HOT)
@@ -3678,6 +3697,7 @@ static int otg_power_property_is_writeable_usb(struct power_supply *psy,
	case POWER_SUPPLY_PROP_DP_DM:
	case POWER_SUPPLY_PROP_INPUT_CURRENT_MAX:
	case POWER_SUPPLY_PROP_USB_OTG:
	case POWER_SUPPLY_PROP_REAL_TYPE:
		return 1;
	default:
		break;
@@ -3702,6 +3722,7 @@ static enum power_supply_property otg_pm_power_props_usb[] = {
	POWER_SUPPLY_PROP_VOLTAGE_NOW,
	POWER_SUPPLY_PROP_DP_DM,
	POWER_SUPPLY_PROP_USB_OTG,
	POWER_SUPPLY_PROP_REAL_TYPE,
};

const struct file_operations msm_otg_bus_fops = {
+2 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
 *
 * Copyright (C) 2008 Google, Inc.
 * Author: Brian Swetland <swetland@google.com>
 * Copyright (c) 2009-2017, The Linux Foundation. All rights reserved.
 * Copyright (c) 2009-2018, The Linux Foundation. All rights reserved.
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
@@ -523,6 +523,7 @@ struct msm_otg {
#define PHY_REGULATORS_LPM	BIT(4)
	int reset_counter;
	struct power_supply usb_psy;
	enum power_supply_type usb_supply_type;
	unsigned int online;
	unsigned int host_mode;
	unsigned int voltage_max;