[PATCH v2 56/87] power: Drop unused fg_max17042 driver and fuel gauge code
Simon Glass
sjg at chromium.org
Sun Jan 29 01:58:32 CET 2023
This driver is not used. Drop it and the entire fuel_gauge directory,
since there is nothing left.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
(no changes since v1)
drivers/power/Makefile | 1 -
drivers/power/fuel_gauge/Makefile | 6 -
drivers/power/fuel_gauge/fg_max17042.c | 287 -------------------------
include/power/fg_battery_cell_params.h | 73 -------
4 files changed, 367 deletions(-)
delete mode 100644 drivers/power/fuel_gauge/Makefile
delete mode 100644 drivers/power/fuel_gauge/fg_max17042.c
delete mode 100644 include/power/fg_battery_cell_params.h
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index efdae3655ac..93003e97e01 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -5,7 +5,6 @@
obj-$(CONFIG_$(SPL_TPL_)ACPI_PMC) += acpi_pmc/
obj-$(CONFIG_$(SPL_TPL_)POWER_DOMAIN) += domain/
-obj-y += fuel_gauge/
obj-y += mfd/
obj-y += pmic/
obj-y += regulator/
diff --git a/drivers/power/fuel_gauge/Makefile b/drivers/power/fuel_gauge/Makefile
deleted file mode 100644
index ca2df947585..00000000000
--- a/drivers/power/fuel_gauge/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0+
-#
-# Copyright (C) 2012 Samsung Electronics
-# Lukasz Majewski <l.majewski at samsung.com>
-
-obj-$(CONFIG_POWER_FG_MAX17042) += fg_max17042.o
diff --git a/drivers/power/fuel_gauge/fg_max17042.c b/drivers/power/fuel_gauge/fg_max17042.c
deleted file mode 100644
index a395d587a86..00000000000
--- a/drivers/power/fuel_gauge/fg_max17042.c
+++ /dev/null
@@ -1,287 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2012 Samsung Electronics
- * Lukasz Majewski <l.majewski at samsung.com>
- */
-
-#include <common.h>
-#include <log.h>
-#include <linux/delay.h>
-#include <power/pmic.h>
-#include <power/max17042_fg.h>
-#include <i2c.h>
-#include <power/max8997_pmic.h>
-#include <power/power_chrg.h>
-#include <power/battery.h>
-#include <power/fg_battery_cell_params.h>
-#include <errno.h>
-
-static int fg_write_regs(struct pmic *p, u8 addr, u16 *data, int num)
-{
- int ret = 0;
- int i;
-
- for (i = 0; i < num; i++, addr++) {
- ret = pmic_reg_write(p, addr, *(data + i));
- if (ret)
- return ret;
- }
-
- return 0;
-}
-
-static int fg_read_regs(struct pmic *p, u8 addr, u16 *data, int num)
-{
- unsigned int dat;
- int ret = 0;
- int i;
-
- for (i = 0; i < num; i++, addr++) {
- ret = pmic_reg_read(p, addr, &dat);
- if (ret)
- return ret;
-
- *(data + i) = (u16)dat;
- }
-
- return 0;
-}
-
-static int fg_write_and_verify(struct pmic *p, u8 addr, u16 data)
-{
- unsigned int val = data;
- int ret = 0;
-
- ret |= pmic_reg_write(p, addr, val);
- ret |= pmic_reg_read(p, addr, &val);
-
- if (ret)
- return ret;
-
- if (((u16) val) == data)
- return 0;
-
- return -1;
-}
-
-static void por_fuelgauge_init(struct pmic *p)
-{
- u16 r_data0[16], r_data1[16], r_data2[16];
- u32 rewrite_count = 5;
- u32 check_count;
- u32 lock_count;
- u32 i = 0;
- u32 val;
- s32 ret = 0;
- char *status_msg;
-
- /* Delay 500 ms */
- mdelay(500);
- /* Initilize Configuration */
- pmic_reg_write(p, MAX17042_CONFIG, 0x2310);
-
-rewrite_model:
- check_count = 5;
- lock_count = 5;
-
- if (!rewrite_count--) {
- status_msg = "init failed!";
- goto error;
- }
-
- /* Unlock Model Access */
- pmic_reg_write(p, MAX17042_MLOCKReg1, MODEL_UNLOCK1);
- pmic_reg_write(p, MAX17042_MLOCKReg2, MODEL_UNLOCK2);
-
- /* Write/Read/Verify the Custom Model */
- ret = fg_write_regs(p, MAX17042_MODEL1, cell_character0,
- ARRAY_SIZE(cell_character0));
- if (ret)
- goto rewrite_model;
-
- ret = fg_write_regs(p, MAX17042_MODEL2, cell_character1,
- ARRAY_SIZE(cell_character1));
- if (ret)
- goto rewrite_model;
-
- ret = fg_write_regs(p, MAX17042_MODEL3, cell_character2,
- ARRAY_SIZE(cell_character2));
- if (ret)
- goto rewrite_model;
-
-check_model:
- if (!check_count--) {
- if (rewrite_count)
- goto rewrite_model;
- else
- status_msg = "check failed!";
-
- goto error;
- }
-
- ret = fg_read_regs(p, MAX17042_MODEL1, r_data0, ARRAY_SIZE(r_data0));
- if (ret)
- goto check_model;
-
- ret = fg_read_regs(p, MAX17042_MODEL2, r_data1, ARRAY_SIZE(r_data1));
- if (ret)
- goto check_model;
-
- ret = fg_read_regs(p, MAX17042_MODEL3, r_data2, ARRAY_SIZE(r_data2));
- if (ret)
- goto check_model;
-
- for (i = 0; i < 16; i++) {
- if ((cell_character0[i] != r_data0[i])
- || (cell_character1[i] != r_data1[i])
- || (cell_character2[i] != r_data2[i]))
- goto rewrite_model;
- }
-
-lock_model:
- if (!lock_count--) {
- if (rewrite_count)
- goto rewrite_model;
- else
- status_msg = "lock failed!";
-
- goto error;
- }
-
- /* Lock model access */
- pmic_reg_write(p, MAX17042_MLOCKReg1, MODEL_LOCK1);
- pmic_reg_write(p, MAX17042_MLOCKReg2, MODEL_LOCK2);
-
- /* Verify the model access is locked */
- ret = fg_read_regs(p, MAX17042_MODEL1, r_data0, ARRAY_SIZE(r_data0));
- if (ret)
- goto lock_model;
-
- ret = fg_read_regs(p, MAX17042_MODEL2, r_data1, ARRAY_SIZE(r_data1));
- if (ret)
- goto lock_model;
-
- ret = fg_read_regs(p, MAX17042_MODEL3, r_data2, ARRAY_SIZE(r_data2));
- if (ret)
- goto lock_model;
-
- for (i = 0; i < ARRAY_SIZE(r_data0); i++) {
- /* Check if model locked */
- if (r_data0[i] || r_data1[i] || r_data2[i])
- goto lock_model;
- }
-
- /* Write Custom Parameters */
- fg_write_and_verify(p, MAX17042_RCOMP0, RCOMP0);
- fg_write_and_verify(p, MAX17042_TEMPCO, TempCo);
-
- /* Delay at least 350mS */
- mdelay(350);
-
- /* Initialization Complete */
- pmic_reg_read(p, MAX17042_STATUS, &val);
- /* Write and Verify Status with POR bit Cleared */
- fg_write_and_verify(p, MAX17042_STATUS, val & ~MAX17042_POR);
-
- /* Delay at least 350 ms */
- mdelay(350);
-
- status_msg = "OK!";
-error:
- debug("%s: model init status: %s\n", p->name, status_msg);
- return;
-}
-
-static int power_update_battery(struct pmic *p, struct pmic *bat)
-{
- struct power_battery *pb = bat->pbat;
- unsigned int val;
- int ret = 0;
-
- if (pmic_probe(p)) {
- puts("Can't find max17042 fuel gauge\n");
- return -ENODEV;
- }
-
- ret |= pmic_reg_read(p, MAX17042_VFSOC, &val);
- pb->bat->state_of_chrg = (val >> 8);
-
- pmic_reg_read(p, MAX17042_VCELL, &val);
- debug("vfsoc: 0x%x\n", val);
- pb->bat->voltage_uV = ((val & 0xFFUL) >> 3) + ((val & 0xFF00) >> 3);
- pb->bat->voltage_uV = (pb->bat->voltage_uV * 625);
-
- pmic_reg_read(p, 0x05, &val);
- pb->bat->capacity = val >> 2;
-
- return ret;
-}
-
-static int power_check_battery(struct pmic *p, struct pmic *bat)
-{
- struct power_battery *pb = bat->pbat;
- unsigned int val;
- int ret = 0;
-
- if (pmic_probe(p)) {
- puts("Can't find max17042 fuel gauge\n");
- return -ENODEV;
- }
-
- ret |= pmic_reg_read(p, MAX17042_STATUS, &val);
- debug("fg status: 0x%x\n", val);
-
- if (val & MAX17042_POR)
- por_fuelgauge_init(p);
-
- ret |= pmic_reg_read(p, MAX17042_VERSION, &val);
- pb->bat->version = val;
-
- power_update_battery(p, bat);
- debug("fg ver: 0x%x\n", pb->bat->version);
- printf("BAT: state_of_charge(SOC):%d%%\n",
- pb->bat->state_of_chrg);
-
- printf(" voltage: %d.%6.6d [V] (expected to be %d [mAh])\n",
- pb->bat->voltage_uV / 1000000,
- pb->bat->voltage_uV % 1000000,
- pb->bat->capacity);
-
- if (pb->bat->voltage_uV > 3850000)
- pb->bat->state = EXT_SOURCE;
- else if (pb->bat->voltage_uV < 3600000 || pb->bat->state_of_chrg < 5)
- pb->bat->state = CHARGE;
- else
- pb->bat->state = NORMAL;
-
- return ret;
-}
-
-static struct power_fg power_fg_ops = {
- .fg_battery_check = power_check_battery,
- .fg_battery_update = power_update_battery,
-};
-
-int power_fg_init(unsigned char bus)
-{
- static const char name[] = "MAX17042_FG";
- struct pmic *p = pmic_alloc();
-
- if (!p) {
- printf("%s: POWER allocation error!\n", __func__);
- return -ENOMEM;
- }
-
- debug("Board Fuel Gauge init\n");
-
- p->name = name;
- p->interface = PMIC_I2C;
- p->number_of_regs = FG_NUM_OF_REGS;
- p->hw.i2c.addr = MAX17042_I2C_ADDR;
- p->hw.i2c.tx_num = 2;
- p->sensor_byte_order = PMIC_SENSOR_BYTE_ORDER_BIG;
- p->bus = bus;
-
- p->fg = &power_fg_ops;
- return 0;
-}
diff --git a/include/power/fg_battery_cell_params.h b/include/power/fg_battery_cell_params.h
deleted file mode 100644
index 500c8ea7174..00000000000
--- a/include/power/fg_battery_cell_params.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2012 Samsung Electronics
- * Lukasz Majewski <l.majewski at samsung.com>
- */
-
-#ifndef __FG_BATTERY_CELL_PARAMS_H_
-#define __FG_BATTERY_CELL_PARAMS_H_
-
-#if defined(CONFIG_POWER_FG_MAX17042) && defined(CONFIG_TARGET_TRATS)
-
-/* Cell characteristics - Exynos4 TRATS development board */
-/* Shall be written to addr 0x80h */
-u16 cell_character0[16] = {
- 0xA2A0,
- 0xB6E0,
- 0xB850,
- 0xBAD0,
- 0xBB20,
- 0xBB70,
- 0xBBC0,
- 0xBC20,
- 0xBC80,
- 0xBCE0,
- 0xBD80,
- 0xBE20,
- 0xC090,
- 0xC420,
- 0xC910,
- 0xD070
-};
-
-/* Shall be written to addr 0x90h */
-u16 cell_character1[16] = {
- 0x0090,
- 0x1A50,
- 0x02F0,
- 0x2060,
- 0x2060,
- 0x2E60,
- 0x26A0,
- 0x2DB0,
- 0x2DB0,
- 0x1870,
- 0x2A20,
- 0x16F0,
- 0x08F0,
- 0x0D40,
- 0x08C0,
- 0x08C0
-};
-
-/* Shall be written to addr 0xA0h */
-u16 cell_character2[16] = {
- 0x0100,
- 0x0100,
- 0x0100,
- 0x0100,
- 0x0100,
- 0x0100,
- 0x0100,
- 0x0100,
- 0x0100,
- 0x0100,
- 0x0100,
- 0x0100,
- 0x0100,
- 0x0100,
- 0x0100,
- 0x0100
-};
-#endif
-#endif /* __FG_BATTERY_CELL_PARAMS_H_ */
--
2.39.1.456.gfc5497dd1b-goog
More information about the U-Boot
mailing list