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

Commit 1709072b authored by Kavya Nunna's avatar Kavya Nunna Committed by Gerrit - the friendly Code Review server
Browse files

power: vm_bms: Skip adc-tm notifications for a debug board



On detecting a debug board disable adc-tm notifications for low
and high vbat thresholds, as vbat monitoring is not required
in case of debug board.

while at it disable adc-tm notifications for batt_therm channel for
linear charger.

Change-Id: I93cd747902d4c3e05c335dbc73c3ea0e308c9af4
Signed-off-by: default avatarKavya Nunna <knunna@codeaurora.org>
parent d1a99118
Loading
Loading
Loading
Loading
+25 −3
Original line number Original line Diff line number Diff line
/* Copyright (c) 2013-2015, 2017-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2015, 2017-2019, The Linux Foundation. All rights reserved.
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * 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
 * it under the terms of the GNU General Public License version 2 and
@@ -414,6 +414,7 @@ struct qpnp_lbc_chip {
	struct qpnp_adc_tm_chip		*adc_tm_dev;
	struct qpnp_adc_tm_chip		*adc_tm_dev;
	struct led_classdev		led_cdev;
	struct led_classdev		led_cdev;
	struct dentry			*debug_root;
	struct dentry			*debug_root;
	struct work_struct		debug_board_work;


	/* parallel-chg params */
	/* parallel-chg params */
	struct power_supply		*parallel_psy;
	struct power_supply		*parallel_psy;
@@ -1496,7 +1497,7 @@ static int qpnp_lbc_configure_jeita(struct qpnp_lbc_chip *chip,
		return -EINVAL;
		return -EINVAL;
	}
	}


	if (chip->cfg_use_fake_battery)
	if (chip->cfg_use_fake_battery || chip->debug_board)
		return 0;
		return 0;


	mutex_lock(&chip->jeita_configure_lock);
	mutex_lock(&chip->jeita_configure_lock);
@@ -1550,6 +1551,22 @@ static int qpnp_lbc_configure_jeita(struct qpnp_lbc_chip *chip,
	return rc;
	return rc;
}
}


static void qpnp_lbc_debug_board_work_fn(struct work_struct *work)
{
	struct qpnp_lbc_chip *chip = container_of(work, struct qpnp_lbc_chip,
						debug_board_work);
	int rc = 0;

	if (chip->adc_param.channel == LR_MUX1_BATT_THERM
					&& chip->debug_board) {
		pr_debug("Disable adc-tm notifications for debug board\n");
		rc = qpnp_adc_tm_disable_chan_meas(chip->adc_tm_dev,
							 &chip->adc_param);
		if (rc < 0)
			pr_err("failed to disable tm %d\n", rc);
	}
}

static int qpnp_batt_property_is_writeable(struct power_supply *psy,
static int qpnp_batt_property_is_writeable(struct power_supply *psy,
					enum power_supply_property psp)
					enum power_supply_property psp)
{
{
@@ -1663,6 +1680,7 @@ static int qpnp_batt_power_set_property(struct power_supply *psy,
		break;
		break;
	case POWER_SUPPLY_PROP_DEBUG_BATTERY:
	case POWER_SUPPLY_PROP_DEBUG_BATTERY:
		chip->debug_board = val->intval;
		chip->debug_board = val->intval;
		schedule_work(&chip->debug_board_work);
		rc = qpnp_lbc_charger_enable(chip, DEBUG_BOARD,
		rc = qpnp_lbc_charger_enable(chip, DEBUG_BOARD,
						!(val->intval));
						!(val->intval));
		break;
		break;
@@ -2679,6 +2697,9 @@ static irqreturn_t qpnp_lbc_batt_pres_irq_handler(int irq, void *_chip)
	struct qpnp_lbc_chip *chip = _chip;
	struct qpnp_lbc_chip *chip = _chip;
	int batt_present;
	int batt_present;


	if (chip->debug_board)
		return IRQ_HANDLED;

	batt_present = qpnp_lbc_is_batt_present(chip);
	batt_present = qpnp_lbc_is_batt_present(chip);
	pr_debug("batt-pres triggered: %d\n", batt_present);
	pr_debug("batt-pres triggered: %d\n", batt_present);


@@ -3343,7 +3364,7 @@ static int qpnp_lbc_main_probe(struct platform_device *pdev)
	alarm_init(&chip->vddtrim_alarm, ALARM_REALTIME, vddtrim_callback);
	alarm_init(&chip->vddtrim_alarm, ALARM_REALTIME, vddtrim_callback);
	INIT_DELAYED_WORK(&chip->collapsible_detection_work,
	INIT_DELAYED_WORK(&chip->collapsible_detection_work,
			qpnp_lbc_collapsible_detection_work);
			qpnp_lbc_collapsible_detection_work);

	INIT_WORK(&chip->debug_board_work, qpnp_lbc_debug_board_work_fn);
	/* Get all device-tree properties */
	/* Get all device-tree properties */
	rc = qpnp_charger_read_dt_props(chip);
	rc = qpnp_charger_read_dt_props(chip);
	if (rc) {
	if (rc) {
@@ -3553,6 +3574,7 @@ static int qpnp_lbc_remove(struct platform_device *pdev)
		alarm_cancel(&chip->vddtrim_alarm);
		alarm_cancel(&chip->vddtrim_alarm);
		cancel_work_sync(&chip->vddtrim_work);
		cancel_work_sync(&chip->vddtrim_work);
	}
	}
	cancel_work_sync(&chip->debug_board_work);
	cancel_delayed_work_sync(&chip->collapsible_detection_work);
	cancel_delayed_work_sync(&chip->collapsible_detection_work);
	debugfs_remove_recursive(chip->debug_root);
	debugfs_remove_recursive(chip->debug_root);
	if (chip->bat_if_base)
	if (chip->bat_if_base)
+5 −1
Original line number Original line Diff line number Diff line
/* Copyright (c) 2014-2016, 2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2016, 2018-2019, The Linux Foundation. All rights reserved.
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * 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
 * it under the terms of the GNU General Public License version 2 and
@@ -1863,6 +1863,10 @@ static int setup_vbat_monitoring(struct qpnp_bms_chip *chip)
{
{
	int rc;
	int rc;


	if (is_debug_batt_id(chip)) {
		pr_debug("skip configuring vbat monitoring for debug_board\n");
		return 0;
	}
	chip->vbat_monitor_params.low_thr =
	chip->vbat_monitor_params.low_thr =
					chip->dt.cfg_low_voltage_threshold;
					chip->dt.cfg_low_voltage_threshold;
	chip->vbat_monitor_params.high_thr =
	chip->vbat_monitor_params.high_thr =