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

Commit b867699a authored by Abhijeet Dharmapurikar's avatar Abhijeet Dharmapurikar
Browse files

power_supply: introduce properties for HVDCP 3P0



HVDCP 3P0 needs few properties implemented by USB power supply and
battery power supply for correct operation.

Create them along with helper functions to modify them.

Change-Id: Ia69ec459eea72703f530c7124f7cc579f4d4c423
Signed-off-by: default avatarAbhijeet Dharmapurikar <adharmap@codeaurora.org>
parent 193ba99a
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -286,6 +286,22 @@ int power_supply_set_allow_detection(struct power_supply *psy, int value)
}
EXPORT_SYMBOL(power_supply_set_allow_detection);

/**
 * power_supply_set_dp_dm -
 * @psy:	the power supply to control
 * @value:	value to be passed to the power_supply
 */
int power_supply_set_dp_dm(struct power_supply *psy, int value)
{
	const union power_supply_propval ret = {value, };

	if (psy->set_property)
		return psy->set_property(psy, POWER_SUPPLY_PROP_DP_DM,
				&ret);
	return -ENXIO;
}
EXPORT_SYMBOL(power_supply_set_dp_dm);

static int __power_supply_changed_work(struct device *dev, void *data)
{
	struct power_supply *psy = data;
+5 −1
Original line number Diff line number Diff line
@@ -46,7 +46,8 @@ static ssize_t power_supply_show_property(struct device *dev,
	static char *type_text[] = {
		"Unknown", "Battery", "UPS", "Mains", "USB",
		"USB_DCP", "USB_CDP", "USB_ACA",
		"USB_HVDCP", "Wireless", "BMS", "USB_Parallel", "Wipower"
		"USB_HVDCP", "USB_HVDCP_3", "Wireless", "BMS", "USB_Parallel",
		"Wipower"
	};
	static char *status_text[] = {
		"Unknown", "Charging", "Discharging", "Not charging", "Full"
@@ -235,6 +236,9 @@ static struct device_attribute power_supply_attrs[] = {
	POWER_SUPPLY_ATTR(allow_detection),
	POWER_SUPPLY_ATTR(flash_active),
	POWER_SUPPLY_ATTR(force_tlim),
	POWER_SUPPLY_ATTR(dp_dm),
	POWER_SUPPLY_ATTR(input_current_limited),
	POWER_SUPPLY_ATTR(rerun_aicl),
	/* Local extensions of type int64_t */
	POWER_SUPPLY_ATTR(charge_counter_ext),
	/* Properties of type `const char *' */
+19 −0
Original line number Diff line number Diff line
@@ -87,6 +87,19 @@ enum {
	POWER_SUPPLY_SCOPE_DEVICE,
};

enum {
	POWER_SUPPLY_DP_DM_UNKNOWN = 0,
	POWER_SUPPLY_DP_DM_PREPARE = 1,
	POWER_SUPPLY_DP_DM_UNPREPARE = 2,
	POWER_SUPPLY_DP_DM_CONFIRMED_HVDCP3 = 3,
	POWER_SUPPLY_DP_DM_DP_PULSE = 4,
	POWER_SUPPLY_DP_DM_DM_PULSE = 5,
	POWER_SUPPLY_DP_DM_DP0P6_DMF = 6,
	POWER_SUPPLY_DP_DM_DP0P6_DM3P3 = 7,
	POWER_SUPPLY_DP_DM_DPF_DMF = 8,
	POWER_SUPPLY_DP_DM_DPR_DMR = 9,
};

enum power_supply_property {
	/* Properties of type `int' */
	POWER_SUPPLY_PROP_STATUS = 0,
@@ -183,6 +196,9 @@ enum power_supply_property {
	POWER_SUPPLY_PROP_ALLOW_DETECTION,
	POWER_SUPPLY_PROP_FLASH_ACTIVE,
	POWER_SUPPLY_PROP_FORCE_TLIM,
	POWER_SUPPLY_PROP_DP_DM,
	POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED,
	POWER_SUPPLY_PROP_RERUN_AICL,
	/* Local extensions of type int64_t */
	POWER_SUPPLY_PROP_CHARGE_COUNTER_EXT,
	/* Properties of type `const char *' */
@@ -202,6 +218,7 @@ enum power_supply_type {
	POWER_SUPPLY_TYPE_USB_CDP,	/* Charging Downstream Port */
	POWER_SUPPLY_TYPE_USB_ACA,	/* Accessory Charger Adapters */
	POWER_SUPPLY_TYPE_USB_HVDCP,	/* High Voltage DCP */
	POWER_SUPPLY_TYPE_USB_HVDCP_3,	/* Efficient High Voltage DCP */
	POWER_SUPPLY_TYPE_WIRELESS,	/* Accessory Charger Adapters */
	POWER_SUPPLY_TYPE_BMS,		/* Battery Monitor System */
	POWER_SUPPLY_TYPE_USB_PARALLEL,		/* USB Parallel Path */
@@ -341,6 +358,8 @@ extern int power_supply_set_low_power_state(struct power_supply *psy,
							int value);
extern int power_supply_set_allow_detection(struct power_supply *psy,
							int value);
extern int power_supply_set_dp_dm(struct power_supply *psy,
							int value);
extern int power_supply_is_system_supplied(void);
extern int power_supply_set_scope(struct power_supply *psy, int scope);
/* For APM emulation, think legacy userspace. */