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

Commit 0b908b0f authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

power: qcom: step-chg-jeita: Make read_range_data_from_node global



Currently, read_range_data_from_node() is used to read step
charging and SW JEITA thresholds from the battery profile. Since
this function can be shared with other drivers which only wants
to read the parameters but not use the entire step charging
algorithm, make read_range_data_from_node() a global function so
that it can be reused.

Also, maximum entries supported for step charging thresholds
should be made common.

Change-Id: If318cffba864aa1fd9a48f80d38134fb2fb69326
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent c92a68f9
Loading
Loading
Loading
Loading
+8 −9
Original line number Diff line number Diff line
/* Copyright (c) 2017 The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-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
@@ -20,7 +20,6 @@
#include <linux/pmic-voter.h>
#include "step-chg-jeita.h"

#define MAX_STEP_CHG_ENTRIES	8
#define STEP_CHG_VOTER		"STEP_CHG_VOTER"
#define JEITA_VOTER		"JEITA_VOTER"

@@ -30,12 +29,6 @@
		|| ((left) <= (right) && (left) <= (value) \
			&& (value) <= (right)))

struct range_data {
	u32 low_threshold;
	u32 high_threshold;
	u32 value;
};

struct step_chg_cfg {
	u32			psy_prop;
	char			*prop_name;
@@ -118,12 +111,17 @@ static bool is_bms_available(struct step_chg_info *chip)
	return true;
}

static int read_range_data_from_node(struct device_node *node,
int read_range_data_from_node(struct device_node *node,
		const char *prop_str, struct range_data *ranges,
		u32 max_threshold, u32 max_value)
{
	int rc = 0, i, length, per_tuple_length, tuples;

	if (!node || !prop_str || !ranges) {
		pr_err("Invalid parameters passed\n");
		return -EINVAL;
	}

	rc = of_property_count_elems_of_size(node, prop_str, sizeof(u32));
	if (rc < 0) {
		pr_err("Count %s failed, rc=%d\n", prop_str, rc);
@@ -184,6 +182,7 @@ static int read_range_data_from_node(struct device_node *node,
	memset(ranges, 0, tuples * sizeof(struct range_data));
	return rc;
}
EXPORT_SYMBOL(read_range_data_from_node);

static int get_step_chg_jeita_setting_from_profile(struct step_chg_info *chip)
{
+13 −1
Original line number Diff line number Diff line
/* Copyright (c) 2017 The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-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
@@ -12,7 +12,19 @@

#ifndef __STEP_CHG_H__
#define __STEP_CHG_H__

#define MAX_STEP_CHG_ENTRIES	8

struct range_data {
	u32 low_threshold;
	u32 high_threshold;
	u32 value;
};

int qcom_step_chg_init(struct device *dev,
		bool step_chg_enable, bool sw_jeita_enable);
void qcom_step_chg_deinit(void);
int read_range_data_from_node(struct device_node *node,
		const char *prop_str, struct range_data *ranges,
		u32 max_threshold, u32 max_value);
#endif /* __STEP_CHG_H__ */