mmi_charger: Add state_of_health/first_usage_date/manufacturing_date

PROPAGATED_from (CR)

For LOT-X battery requirement
Add battery info
state_of_health, first_usage_data, manufacturing_date

Change-Id: I93376517bb96050798ac95aeb5d1f0c186b27270
Signed-off-by: liuyc20 <liuyc20@lenovo.com>
Reviewed-on: https://gerrit.mot.com/2854414
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Haijian Ma <mahj8@motorola.com>
Reviewed-by: Huosheng Liao <liaohs@motorola.com>
Submit-Approved: Jira Key
Signed-off-by: Robert Cabral <robertc@motorola.com>
Reviewed-on: https://gerrit.mot.com/3157739
Reviewed-by: Hugo Cuffa <hcuffa@motorola.com>
Reviewed-by: Yuecai Liu <liuyc20@motorola.com>
This commit is contained in:
liuyc20 2024-01-16 14:46:28 +08:00 • committed by Andrea dos Santos
commit 2ef1dc560d

View file

@ -526,6 +526,10 @@ struct smb_mmi_charger {
bool enable_dcp_ffc;
bool enable_fcc_large_qg_iterm;
/*Battery info*/
int manufacturing_date;
int first_usage_date;
};
#define CHGR_FAST_CHARGE_CURRENT_CFG_REG (CHGR_BASE + 0x61)
@ -4957,9 +4961,100 @@ static ssize_t age_show(struct device *dev,
}
static DEVICE_ATTR(age, S_IRUGO, age_show, NULL);
static ssize_t state_of_health_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
if (!this_chip) {
pr_err("mmi_charger: chip is invalid\n");
return -ENODEV;
}
return scnprintf(buf, CHG_SHOW_MAX_SIZE, "%d\n", this_chip->age);
}
static DEVICE_ATTR(state_of_health, S_IRUGO, state_of_health_show, NULL);
static ssize_t first_usage_date_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
if (!this_chip) {
pr_err("mmi_charger: chip is invalid\n");
return -ENODEV;
}
return scnprintf(buf, CHG_SHOW_MAX_SIZE, "%d\n", this_chip->first_usage_date);
}
static ssize_t first_usage_date_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
unsigned long r;
unsigned long first_usage_date;
if (!this_chip) {
pr_err("mmi_charger: chip is invalid\n");
return -ENODEV;
}
r = kstrtoul(buf, 0, &first_usage_date);
if (r) {
mmi_err(this_chip, "Invalid first_usage_date value = %lu\n", first_usage_date);
return -EINVAL;
}
this_chip->first_usage_date = first_usage_date;
return r ? r : count;
}
static DEVICE_ATTR(first_usage_date, 0644, first_usage_date_show, first_usage_date_store);
static ssize_t manufacturing_date_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
if (!this_chip) {
pr_err("mmi_charger: chip is invalid\n");
return -ENODEV;
}
return scnprintf(buf, CHG_SHOW_MAX_SIZE, "%d\n", this_chip->manufacturing_date);
}
static ssize_t manufacturing_date_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
unsigned long r;
unsigned long manufacturing_date;
if (!this_chip) {
pr_err("mmi_charger: chip is invalid\n");
return -ENODEV;
}
r = kstrtoul(buf, 0, &manufacturing_date);
if (r) {
mmi_err(this_chip, "Invalid manufacturing_date value = %lu\n", manufacturing_date);
return -EINVAL;
}
this_chip->manufacturing_date = manufacturing_date;
return r ? r : count;
}
static DEVICE_ATTR(manufacturing_date, 0644, manufacturing_date_show, manufacturing_date_store);
static struct attribute * mmi_g[] = {
&dev_attr_charge_rate.attr,
&dev_attr_age.attr,
&dev_attr_state_of_health.attr,
&dev_attr_manufacturing_date.attr,
&dev_attr_first_usage_date.attr,
NULL,
};