^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * I2C client/driver for the Linear Technology LTC2941, LTC2942, LTC2943
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * and LTC2944 Battery Gas Gauge IC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2014 Topic Embedded Systems
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Author: Auryn Verwegen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Author: Mike Looijmans
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/of_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/swab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/power_supply.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define I16_MSB(x) ((x >> 8) & 0xFF)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define I16_LSB(x) (x & 0xFF)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define LTC294X_WORK_DELAY 10 /* Update delay in seconds */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define LTC294X_MAX_VALUE 0xFFFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define LTC294X_MID_SUPPLY 0x7FFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define LTC2941_MAX_PRESCALER_EXP 7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define LTC2943_MAX_PRESCALER_EXP 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) enum ltc294x_reg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) LTC294X_REG_STATUS = 0x00,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) LTC294X_REG_CONTROL = 0x01,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) LTC294X_REG_ACC_CHARGE_MSB = 0x02,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) LTC294X_REG_ACC_CHARGE_LSB = 0x03,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) LTC294X_REG_CHARGE_THR_HIGH_MSB = 0x04,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) LTC294X_REG_CHARGE_THR_HIGH_LSB = 0x05,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) LTC294X_REG_CHARGE_THR_LOW_MSB = 0x06,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) LTC294X_REG_CHARGE_THR_LOW_LSB = 0x07,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) LTC294X_REG_VOLTAGE_MSB = 0x08,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) LTC294X_REG_VOLTAGE_LSB = 0x09,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) LTC2942_REG_TEMPERATURE_MSB = 0x0C,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) LTC2942_REG_TEMPERATURE_LSB = 0x0D,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) LTC2943_REG_CURRENT_MSB = 0x0E,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) LTC2943_REG_CURRENT_LSB = 0x0F,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) LTC2943_REG_TEMPERATURE_MSB = 0x14,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) LTC2943_REG_TEMPERATURE_LSB = 0x15,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) enum ltc294x_id {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) LTC2941_ID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) LTC2942_ID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) LTC2943_ID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) LTC2944_ID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #define LTC2941_REG_STATUS_CHIP_ID BIT(7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #define LTC2942_REG_CONTROL_MODE_SCAN (BIT(7) | BIT(6))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #define LTC2943_REG_CONTROL_MODE_SCAN BIT(7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #define LTC294X_REG_CONTROL_PRESCALER_MASK (BIT(5) | BIT(4) | BIT(3))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #define LTC294X_REG_CONTROL_SHUTDOWN_MASK (BIT(0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #define LTC294X_REG_CONTROL_PRESCALER_SET(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) ((x << 3) & LTC294X_REG_CONTROL_PRESCALER_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #define LTC294X_REG_CONTROL_ALCC_CONFIG_DISABLED 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) #define LTC294X_REG_CONTROL_ADC_DISABLE(x) ((x) & ~(BIT(7) | BIT(6)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) struct ltc294x_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) struct i2c_client *client; /* I2C Client pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) struct power_supply *supply; /* Supply pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) struct power_supply_desc supply_desc; /* Supply description */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) struct delayed_work work; /* Work scheduler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) enum ltc294x_id id; /* Chip type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) int charge; /* Last charge register content */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) int r_sense; /* mOhm */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) int Qlsb; /* nAh */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) static inline int convert_bin_to_uAh(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) const struct ltc294x_info *info, int Q)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) return ((Q * (info->Qlsb / 10))) / 100;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) static inline int convert_uAh_to_bin(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) const struct ltc294x_info *info, int uAh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) int Q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) Q = (uAh * 100) / (info->Qlsb/10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) return (Q < LTC294X_MAX_VALUE) ? Q : LTC294X_MAX_VALUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) static int ltc294x_read_regs(struct i2c_client *client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) enum ltc294x_reg reg, u8 *buf, int num_regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) struct i2c_msg msgs[2] = { };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) u8 reg_start = reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) msgs[0].addr = client->addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) msgs[0].len = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) msgs[0].buf = ®_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) msgs[1].addr = client->addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) msgs[1].len = num_regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) msgs[1].buf = buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) msgs[1].flags = I2C_M_RD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) ret = i2c_transfer(client->adapter, &msgs[0], 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) dev_err(&client->dev, "ltc2941 read_reg failed!\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) dev_dbg(&client->dev, "%s (%#x, %d) -> %#x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) __func__, reg, num_regs, *buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) static int ltc294x_write_regs(struct i2c_client *client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) enum ltc294x_reg reg, const u8 *buf, int num_regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) u8 reg_start = reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) ret = i2c_smbus_write_i2c_block_data(client, reg_start, num_regs, buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) dev_err(&client->dev, "ltc2941 write_reg failed!\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) dev_dbg(&client->dev, "%s (%#x, %d) -> %#x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) __func__, reg, num_regs, *buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) static int ltc294x_reset(const struct ltc294x_info *info, int prescaler_exp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) u8 value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) u8 control;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) /* Read status and control registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) ret = ltc294x_read_regs(info->client, LTC294X_REG_CONTROL, &value, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) dev_err(&info->client->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) "Could not read registers from device\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) goto error_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) control = LTC294X_REG_CONTROL_PRESCALER_SET(prescaler_exp) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) LTC294X_REG_CONTROL_ALCC_CONFIG_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) /* Put device into "monitor" mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) switch (info->id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) case LTC2942_ID: /* 2942 measures every 2 sec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) control |= LTC2942_REG_CONTROL_MODE_SCAN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) case LTC2943_ID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) case LTC2944_ID: /* 2943 and 2944 measure every 10 sec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) control |= LTC2943_REG_CONTROL_MODE_SCAN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) if (value != control) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) ret = ltc294x_write_regs(info->client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) LTC294X_REG_CONTROL, &control, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) dev_err(&info->client->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) "Could not write register\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) goto error_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) error_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) static int ltc294x_read_charge_register(const struct ltc294x_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) enum ltc294x_reg reg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) u8 datar[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) ret = ltc294x_read_regs(info->client, reg, &datar[0], 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) return (datar[0] << 8) + datar[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) static int ltc294x_get_charge(const struct ltc294x_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) enum ltc294x_reg reg, int *val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) int value = ltc294x_read_charge_register(info, reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) if (value < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) return value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) /* When r_sense < 0, this counts up when the battery discharges */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) if (info->Qlsb < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) value -= 0xFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) *val = convert_bin_to_uAh(info, value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) static int ltc294x_set_charge_now(const struct ltc294x_info *info, int val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) u8 dataw[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) u8 ctrl_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) s32 value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) value = convert_uAh_to_bin(info, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) /* Direction depends on how sense+/- were connected */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) if (info->Qlsb < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) value += 0xFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) if ((value < 0) || (value > 0xFFFF)) /* input validation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) /* Read control register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) ret = ltc294x_read_regs(info->client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) LTC294X_REG_CONTROL, &ctrl_reg, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) /* Disable analog section */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) ctrl_reg |= LTC294X_REG_CONTROL_SHUTDOWN_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) ret = ltc294x_write_regs(info->client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) LTC294X_REG_CONTROL, &ctrl_reg, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) /* Set new charge value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) dataw[0] = I16_MSB(value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) dataw[1] = I16_LSB(value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) ret = ltc294x_write_regs(info->client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) LTC294X_REG_ACC_CHARGE_MSB, &dataw[0], 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) goto error_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) /* Enable analog section */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) error_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) ctrl_reg &= ~LTC294X_REG_CONTROL_SHUTDOWN_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) ret = ltc294x_write_regs(info->client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) LTC294X_REG_CONTROL, &ctrl_reg, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) return ret < 0 ? ret : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) static int ltc294x_set_charge_thr(const struct ltc294x_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) enum ltc294x_reg reg, int val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) u8 dataw[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) s32 value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) value = convert_uAh_to_bin(info, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) /* Direction depends on how sense+/- were connected */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) if (info->Qlsb < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) value += 0xFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) if ((value < 0) || (value > 0xFFFF)) /* input validation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) /* Set new charge value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) dataw[0] = I16_MSB(value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) dataw[1] = I16_LSB(value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) return ltc294x_write_regs(info->client, reg, &dataw[0], 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) static int ltc294x_get_charge_counter(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) const struct ltc294x_info *info, int *val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) int value = ltc294x_read_charge_register(info, LTC294X_REG_ACC_CHARGE_MSB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) if (value < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) return value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) value -= LTC294X_MID_SUPPLY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) *val = convert_bin_to_uAh(info, value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) static int ltc294x_get_voltage(const struct ltc294x_info *info, int *val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) u8 datar[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) u32 value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) ret = ltc294x_read_regs(info->client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) LTC294X_REG_VOLTAGE_MSB, &datar[0], 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) value = (datar[0] << 8) | datar[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) switch (info->id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) case LTC2943_ID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) value *= 23600 * 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) value /= 0xFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) value *= 1000 / 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) case LTC2944_ID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) value *= 70800 / 5*4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) value /= 0xFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) value *= 1000 * 5/4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) value *= 6000 * 10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) value /= 0xFFFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) value *= 1000 / 10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) *val = value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) static int ltc294x_get_current(const struct ltc294x_info *info, int *val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) u8 datar[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) s32 value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) ret = ltc294x_read_regs(info->client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) LTC2943_REG_CURRENT_MSB, &datar[0], 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) value = (datar[0] << 8) | datar[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) value -= 0x7FFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) if (info->id == LTC2944_ID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) value *= 64000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) value *= 60000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) /* Value is in range -32k..+32k, r_sense is usually 10..50 mOhm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) * the formula below keeps everything in s32 range while preserving
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) * enough digits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) *val = 1000 * (value / (info->r_sense * 0x7FFF)); /* in uA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) static int ltc294x_get_temperature(const struct ltc294x_info *info, int *val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) enum ltc294x_reg reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) u8 datar[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) u32 value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) if (info->id == LTC2942_ID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) reg = LTC2942_REG_TEMPERATURE_MSB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) value = 6000; /* Full-scale is 600 Kelvin */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) reg = LTC2943_REG_TEMPERATURE_MSB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) value = 5100; /* Full-scale is 510 Kelvin */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) ret = ltc294x_read_regs(info->client, reg, &datar[0], 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) value *= (datar[0] << 8) | datar[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) /* Convert to tenths of degree Celsius */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) *val = value / 0xFFFF - 2722;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) static int ltc294x_get_property(struct power_supply *psy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) enum power_supply_property prop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) union power_supply_propval *val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) struct ltc294x_info *info = power_supply_get_drvdata(psy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) switch (prop) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) case POWER_SUPPLY_PROP_CHARGE_FULL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) return ltc294x_get_charge(info, LTC294X_REG_CHARGE_THR_HIGH_MSB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) &val->intval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) case POWER_SUPPLY_PROP_CHARGE_EMPTY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) return ltc294x_get_charge(info, LTC294X_REG_CHARGE_THR_LOW_MSB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) &val->intval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) case POWER_SUPPLY_PROP_CHARGE_NOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) return ltc294x_get_charge(info, LTC294X_REG_ACC_CHARGE_MSB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) &val->intval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) case POWER_SUPPLY_PROP_CHARGE_COUNTER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) return ltc294x_get_charge_counter(info, &val->intval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) case POWER_SUPPLY_PROP_VOLTAGE_NOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) return ltc294x_get_voltage(info, &val->intval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) case POWER_SUPPLY_PROP_CURRENT_NOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) return ltc294x_get_current(info, &val->intval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) case POWER_SUPPLY_PROP_TEMP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) return ltc294x_get_temperature(info, &val->intval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) static int ltc294x_set_property(struct power_supply *psy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) enum power_supply_property psp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) const union power_supply_propval *val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) struct ltc294x_info *info = power_supply_get_drvdata(psy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) switch (psp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) case POWER_SUPPLY_PROP_CHARGE_FULL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) return ltc294x_set_charge_thr(info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) LTC294X_REG_CHARGE_THR_HIGH_MSB, val->intval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) case POWER_SUPPLY_PROP_CHARGE_EMPTY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) return ltc294x_set_charge_thr(info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) LTC294X_REG_CHARGE_THR_LOW_MSB, val->intval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) case POWER_SUPPLY_PROP_CHARGE_NOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) return ltc294x_set_charge_now(info, val->intval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) return -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) static int ltc294x_property_is_writeable(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) struct power_supply *psy, enum power_supply_property psp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) switch (psp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) case POWER_SUPPLY_PROP_CHARGE_FULL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) case POWER_SUPPLY_PROP_CHARGE_EMPTY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) case POWER_SUPPLY_PROP_CHARGE_NOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) static void ltc294x_update(struct ltc294x_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) int charge = ltc294x_read_charge_register(info, LTC294X_REG_ACC_CHARGE_MSB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) if (charge != info->charge) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) info->charge = charge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) power_supply_changed(info->supply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) static void ltc294x_work(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) struct ltc294x_info *info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) info = container_of(work, struct ltc294x_info, work.work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) ltc294x_update(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) schedule_delayed_work(&info->work, LTC294X_WORK_DELAY * HZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) static enum power_supply_property ltc294x_properties[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) POWER_SUPPLY_PROP_CHARGE_COUNTER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) POWER_SUPPLY_PROP_CHARGE_FULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) POWER_SUPPLY_PROP_CHARGE_EMPTY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) POWER_SUPPLY_PROP_CHARGE_NOW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) POWER_SUPPLY_PROP_VOLTAGE_NOW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) POWER_SUPPLY_PROP_TEMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) POWER_SUPPLY_PROP_CURRENT_NOW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) static int ltc294x_i2c_remove(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) struct ltc294x_info *info = i2c_get_clientdata(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) cancel_delayed_work_sync(&info->work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) power_supply_unregister(info->supply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) static int ltc294x_i2c_probe(struct i2c_client *client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) const struct i2c_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) struct power_supply_config psy_cfg = {};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) struct ltc294x_info *info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) struct device_node *np;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) u32 prescaler_exp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) s32 r_sense;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) u8 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) info = devm_kzalloc(&client->dev, sizeof(*info), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) if (info == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) i2c_set_clientdata(client, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) np = of_node_get(client->dev.of_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) info->id = (enum ltc294x_id) (uintptr_t) of_device_get_match_data(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) &client->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) info->supply_desc.name = np->name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) /* r_sense can be negative, when sense+ is connected to the battery
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) * instead of the sense-. This results in reversed measurements. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) ret = of_property_read_u32(np, "lltc,resistor-sense", &r_sense);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) dev_err(&client->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) "Could not find lltc,resistor-sense in devicetree\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) info->r_sense = r_sense;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) ret = of_property_read_u32(np, "lltc,prescaler-exponent",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) &prescaler_exp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) dev_warn(&client->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) "lltc,prescaler-exponent not in devicetree\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) prescaler_exp = LTC2941_MAX_PRESCALER_EXP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) if (info->id == LTC2943_ID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) if (prescaler_exp > LTC2943_MAX_PRESCALER_EXP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) prescaler_exp = LTC2943_MAX_PRESCALER_EXP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) info->Qlsb = ((340 * 50000) / r_sense) /
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) (4096 / (1 << (2*prescaler_exp)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) if (prescaler_exp > LTC2941_MAX_PRESCALER_EXP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) prescaler_exp = LTC2941_MAX_PRESCALER_EXP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) info->Qlsb = ((85 * 50000) / r_sense) /
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) (128 / (1 << prescaler_exp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) /* Read status register to check for LTC2942 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) if (info->id == LTC2941_ID || info->id == LTC2942_ID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) ret = ltc294x_read_regs(client, LTC294X_REG_STATUS, &status, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) dev_err(&client->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) "Could not read status register\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) if (status & LTC2941_REG_STATUS_CHIP_ID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) info->id = LTC2941_ID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) info->id = LTC2942_ID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) info->client = client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) info->supply_desc.type = POWER_SUPPLY_TYPE_BATTERY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) info->supply_desc.properties = ltc294x_properties;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) switch (info->id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) case LTC2944_ID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) case LTC2943_ID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) info->supply_desc.num_properties =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) ARRAY_SIZE(ltc294x_properties);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) case LTC2942_ID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) info->supply_desc.num_properties =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) ARRAY_SIZE(ltc294x_properties) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) case LTC2941_ID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) info->supply_desc.num_properties =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) ARRAY_SIZE(ltc294x_properties) - 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) info->supply_desc.get_property = ltc294x_get_property;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) info->supply_desc.set_property = ltc294x_set_property;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) info->supply_desc.property_is_writeable = ltc294x_property_is_writeable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) info->supply_desc.external_power_changed = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) psy_cfg.drv_data = info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) INIT_DELAYED_WORK(&info->work, ltc294x_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) ret = ltc294x_reset(info, prescaler_exp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) dev_err(&client->dev, "Communication with chip failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) info->supply = power_supply_register(&client->dev, &info->supply_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) &psy_cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) if (IS_ERR(info->supply)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) dev_err(&client->dev, "failed to register ltc2941\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) return PTR_ERR(info->supply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) schedule_delayed_work(&info->work, LTC294X_WORK_DELAY * HZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) static void ltc294x_i2c_shutdown(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) struct ltc294x_info *info = i2c_get_clientdata(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) u8 value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) u8 control;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) /* The LTC2941 does not need any special handling */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) if (info->id == LTC2941_ID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) /* Read control register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) ret = ltc294x_read_regs(info->client, LTC294X_REG_CONTROL, &value, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) /* Disable continuous ADC conversion as this drains the battery */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) control = LTC294X_REG_CONTROL_ADC_DISABLE(value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) if (control != value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) ltc294x_write_regs(info->client, LTC294X_REG_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) &control, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) #ifdef CONFIG_PM_SLEEP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) static int ltc294x_suspend(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) struct i2c_client *client = to_i2c_client(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) struct ltc294x_info *info = i2c_get_clientdata(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) cancel_delayed_work(&info->work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) static int ltc294x_resume(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) struct i2c_client *client = to_i2c_client(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) struct ltc294x_info *info = i2c_get_clientdata(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) schedule_delayed_work(&info->work, LTC294X_WORK_DELAY * HZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) static SIMPLE_DEV_PM_OPS(ltc294x_pm_ops, ltc294x_suspend, ltc294x_resume);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) #define LTC294X_PM_OPS (<c294x_pm_ops)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) #define LTC294X_PM_OPS NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) #endif /* CONFIG_PM_SLEEP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) static const struct i2c_device_id ltc294x_i2c_id[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) { "ltc2941", LTC2941_ID, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) { "ltc2942", LTC2942_ID, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) { "ltc2943", LTC2943_ID, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) { "ltc2944", LTC2944_ID, },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) { },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) MODULE_DEVICE_TABLE(i2c, ltc294x_i2c_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) static const struct of_device_id ltc294x_i2c_of_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) .compatible = "lltc,ltc2941",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) .data = (void *)LTC2941_ID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) .compatible = "lltc,ltc2942",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) .data = (void *)LTC2942_ID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) .compatible = "lltc,ltc2943",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) .data = (void *)LTC2943_ID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) .compatible = "lltc,ltc2944",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) .data = (void *)LTC2944_ID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) { },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) MODULE_DEVICE_TABLE(of, ltc294x_i2c_of_match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) static struct i2c_driver ltc294x_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) .name = "LTC2941",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) .of_match_table = ltc294x_i2c_of_match,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) .pm = LTC294X_PM_OPS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) .probe = ltc294x_i2c_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) .remove = ltc294x_i2c_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) .shutdown = ltc294x_i2c_shutdown,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) .id_table = ltc294x_i2c_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) module_i2c_driver(ltc294x_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) MODULE_AUTHOR("Auryn Verwegen, Topic Embedded Systems");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) MODULE_AUTHOR("Mike Looijmans, Topic Embedded Products");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) MODULE_DESCRIPTION("LTC2941/LTC2942/LTC2943/LTC2944 Battery Gas Gauge IC driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) MODULE_LICENSE("GPL");