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

Commit 8d21e82f authored by Harry Yang's avatar Harry Yang Committed by Jeevan Shriram
Browse files

soc: eud: Fix event handling for input suspend/unsuspend



Extcon is being used currently in the EUD driver to enable/disable
charging. Replace it with setting power supply properties.

Change-Id: Ia6e302e9f225827760478e314ebf9012982771e5
Signed-off-by: default avatarHarry Yang <harryy@codeaurora.org>
parent 0d192184
Loading
Loading
Loading
Loading
+21 −4
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
 */

#include <linux/kernel.h>
@@ -65,6 +65,7 @@ struct eud_chip {
	struct extcon_dev		*extcon;
	struct uart_port		port;
	struct work_struct		eud_work;
	struct power_supply		*batt_psy;
};

static const unsigned int eud_extcon_cable[] = {
@@ -180,17 +181,33 @@ static const struct kernel_param_ops eud_param_ops = {

module_param_cb(enable, &eud_param_ops, &enable, 0644);

static bool is_batt_available(struct eud_chip *chip)
{
	if (!chip->batt_psy)
		chip->batt_psy = power_supply_get_by_name("battery");

	if (!chip->batt_psy)
		return false;

	return true;
}

static void eud_event_notifier(struct work_struct *eud_work)
{
	struct eud_chip *chip = container_of(eud_work, struct eud_chip,
					eud_work);
	union power_supply_propval pval;

	if (chip->int_status == EUD_INT_VBUS)
		extcon_set_state_sync(chip->extcon, chip->extcon_id,
					chip->usb_attach);
	else if (chip->int_status == EUD_INT_CHGR)
		extcon_set_state_sync(chip->extcon, chip->extcon_id,
					chip->chgr_enable);
	else if (chip->int_status == EUD_INT_CHGR) {
		if (is_batt_available(chip)) {
			pval.intval = !chip->chgr_enable;
			power_supply_set_property(chip->batt_psy,
				POWER_SUPPLY_PROP_INPUT_SUSPEND, &pval);
		}
	}
}

static void usb_attach_detach(struct eud_chip *chip)