MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Fuel gauge driver for Maxim 17042 / 8966 / 8997 |
| 3 | * Note that Maxim 8966 and 8997 are mfd and this is its subdevice. |
| 4 | * |
| 5 | * Copyright (C) 2011 Samsung Electronics |
| 6 | * MyungJoo Ham <myungjoo.ham@samsung.com> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | * |
| 22 | * This driver is based on max17040_battery.c |
| 23 | */ |
| 24 | |
| 25 | #include <linux/init.h> |
Paul Gortmaker | 7e6d62d | 2011-07-03 15:28:29 -0400 | [diff] [blame] | 26 | #include <linux/module.h> |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 27 | #include <linux/slab.h> |
| 28 | #include <linux/i2c.h> |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 29 | #include <linux/delay.h> |
Ramakrishna Pallala | e5f3872 | 2012-01-24 09:26:06 -0800 | [diff] [blame] | 30 | #include <linux/interrupt.h> |
Ramakrishna Pallala | 48bc177 | 2012-03-27 02:23:40 +0530 | [diff] [blame] | 31 | #include <linux/pm.h> |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 32 | #include <linux/mod_devicetable.h> |
| 33 | #include <linux/power_supply.h> |
| 34 | #include <linux/power/max17042_battery.h> |
Karol Lewandowski | 3832246 | 2012-02-22 19:06:22 +0100 | [diff] [blame] | 35 | #include <linux/of.h> |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 36 | #include <linux/regmap.h> |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 37 | |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 38 | /* Status register bits */ |
| 39 | #define STATUS_POR_BIT (1 << 1) |
| 40 | #define STATUS_BST_BIT (1 << 3) |
| 41 | #define STATUS_VMN_BIT (1 << 8) |
| 42 | #define STATUS_TMN_BIT (1 << 9) |
| 43 | #define STATUS_SMN_BIT (1 << 10) |
| 44 | #define STATUS_BI_BIT (1 << 11) |
| 45 | #define STATUS_VMX_BIT (1 << 12) |
| 46 | #define STATUS_TMX_BIT (1 << 13) |
| 47 | #define STATUS_SMX_BIT (1 << 14) |
| 48 | #define STATUS_BR_BIT (1 << 15) |
| 49 | |
Ramakrishna Pallala | e5f3872 | 2012-01-24 09:26:06 -0800 | [diff] [blame] | 50 | /* Interrupt mask bits */ |
| 51 | #define CONFIG_ALRT_BIT_ENBL (1 << 2) |
Ramakrishna Pallala | 5cdd4d7 | 2012-03-21 03:03:16 +0530 | [diff] [blame] | 52 | #define STATUS_INTR_SOCMIN_BIT (1 << 10) |
| 53 | #define STATUS_INTR_SOCMAX_BIT (1 << 14) |
Ramakrishna Pallala | e5f3872 | 2012-01-24 09:26:06 -0800 | [diff] [blame] | 54 | |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 55 | #define VFSOC0_LOCK 0x0000 |
| 56 | #define VFSOC0_UNLOCK 0x0080 |
| 57 | #define MODEL_UNLOCK1 0X0059 |
| 58 | #define MODEL_UNLOCK2 0X00C4 |
| 59 | #define MODEL_LOCK1 0X0000 |
| 60 | #define MODEL_LOCK2 0X0000 |
| 61 | |
| 62 | #define dQ_ACC_DIV 0x4 |
| 63 | #define dP_ACC_100 0x1900 |
| 64 | #define dP_ACC_200 0x3200 |
| 65 | |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 66 | struct max17042_chip { |
| 67 | struct i2c_client *client; |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 68 | struct regmap *regmap; |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 69 | struct power_supply *battery; |
Ramakrishna Pallala | 9a8422d | 2012-05-05 14:34:26 +0530 | [diff] [blame] | 70 | enum max170xx_chip_type chip_type; |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 71 | struct max17042_platform_data *pdata; |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 72 | struct work_struct work; |
| 73 | int init_complete; |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 74 | }; |
| 75 | |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 76 | static enum power_supply_property max17042_battery_props[] = { |
Donggeun Kim | 086ef50 | 2011-06-30 18:07:41 +0900 | [diff] [blame] | 77 | POWER_SUPPLY_PROP_PRESENT, |
| 78 | POWER_SUPPLY_PROP_CYCLE_COUNT, |
| 79 | POWER_SUPPLY_PROP_VOLTAGE_MAX, |
| 80 | POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 81 | POWER_SUPPLY_PROP_VOLTAGE_NOW, |
| 82 | POWER_SUPPLY_PROP_VOLTAGE_AVG, |
Ramakrishna Pallala | a2ebfe2 | 2012-04-10 16:21:20 +0530 | [diff] [blame] | 83 | POWER_SUPPLY_PROP_VOLTAGE_OCV, |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 84 | POWER_SUPPLY_PROP_CAPACITY, |
Donggeun Kim | 086ef50 | 2011-06-30 18:07:41 +0900 | [diff] [blame] | 85 | POWER_SUPPLY_PROP_CHARGE_FULL, |
Ramakrishna Pallala | 5fc55bc | 2012-05-07 10:25:58 +0530 | [diff] [blame] | 86 | POWER_SUPPLY_PROP_CHARGE_COUNTER, |
Donggeun Kim | 086ef50 | 2011-06-30 18:07:41 +0900 | [diff] [blame] | 87 | POWER_SUPPLY_PROP_TEMP, |
| 88 | POWER_SUPPLY_PROP_CURRENT_NOW, |
| 89 | POWER_SUPPLY_PROP_CURRENT_AVG, |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | static int max17042_get_property(struct power_supply *psy, |
| 93 | enum power_supply_property psp, |
| 94 | union power_supply_propval *val) |
| 95 | { |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 96 | struct max17042_chip *chip = power_supply_get_drvdata(psy); |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 97 | struct regmap *map = chip->regmap; |
Ramakrishna Pallala | 60a1f6e | 2011-11-26 04:11:15 +0400 | [diff] [blame] | 98 | int ret; |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 99 | u32 data; |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 100 | |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 101 | if (!chip->init_complete) |
| 102 | return -EAGAIN; |
| 103 | |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 104 | switch (psp) { |
Donggeun Kim | 086ef50 | 2011-06-30 18:07:41 +0900 | [diff] [blame] | 105 | case POWER_SUPPLY_PROP_PRESENT: |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 106 | ret = regmap_read(map, MAX17042_STATUS, &data); |
Ramakrishna Pallala | 60a1f6e | 2011-11-26 04:11:15 +0400 | [diff] [blame] | 107 | if (ret < 0) |
| 108 | return ret; |
| 109 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 110 | if (data & MAX17042_STATUS_BattAbsent) |
Donggeun Kim | 086ef50 | 2011-06-30 18:07:41 +0900 | [diff] [blame] | 111 | val->intval = 0; |
| 112 | else |
| 113 | val->intval = 1; |
| 114 | break; |
| 115 | case POWER_SUPPLY_PROP_CYCLE_COUNT: |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 116 | ret = regmap_read(map, MAX17042_Cycles, &data); |
Ramakrishna Pallala | 60a1f6e | 2011-11-26 04:11:15 +0400 | [diff] [blame] | 117 | if (ret < 0) |
| 118 | return ret; |
| 119 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 120 | val->intval = data; |
Donggeun Kim | 086ef50 | 2011-06-30 18:07:41 +0900 | [diff] [blame] | 121 | break; |
| 122 | case POWER_SUPPLY_PROP_VOLTAGE_MAX: |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 123 | ret = regmap_read(map, MAX17042_MinMaxVolt, &data); |
Ramakrishna Pallala | 60a1f6e | 2011-11-26 04:11:15 +0400 | [diff] [blame] | 124 | if (ret < 0) |
| 125 | return ret; |
| 126 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 127 | val->intval = data >> 8; |
Donggeun Kim | 086ef50 | 2011-06-30 18:07:41 +0900 | [diff] [blame] | 128 | val->intval *= 20000; /* Units of LSB = 20mV */ |
| 129 | break; |
| 130 | case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: |
Beomho Seo | 709c2c7 | 2015-04-03 17:26:08 +0900 | [diff] [blame^] | 131 | if (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17042) |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 132 | ret = regmap_read(map, MAX17042_V_empty, &data); |
Ramakrishna Pallala | 9a8422d | 2012-05-05 14:34:26 +0530 | [diff] [blame] | 133 | else |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 134 | ret = regmap_read(map, MAX17047_V_empty, &data); |
Ramakrishna Pallala | 60a1f6e | 2011-11-26 04:11:15 +0400 | [diff] [blame] | 135 | if (ret < 0) |
| 136 | return ret; |
| 137 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 138 | val->intval = data >> 7; |
Donggeun Kim | 086ef50 | 2011-06-30 18:07:41 +0900 | [diff] [blame] | 139 | val->intval *= 10000; /* Units of LSB = 10mV */ |
| 140 | break; |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 141 | case POWER_SUPPLY_PROP_VOLTAGE_NOW: |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 142 | ret = regmap_read(map, MAX17042_VCELL, &data); |
Ramakrishna Pallala | 60a1f6e | 2011-11-26 04:11:15 +0400 | [diff] [blame] | 143 | if (ret < 0) |
| 144 | return ret; |
| 145 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 146 | val->intval = data * 625 / 8; |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 147 | break; |
| 148 | case POWER_SUPPLY_PROP_VOLTAGE_AVG: |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 149 | ret = regmap_read(map, MAX17042_AvgVCELL, &data); |
Ramakrishna Pallala | 60a1f6e | 2011-11-26 04:11:15 +0400 | [diff] [blame] | 150 | if (ret < 0) |
| 151 | return ret; |
| 152 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 153 | val->intval = data * 625 / 8; |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 154 | break; |
Ramakrishna Pallala | a2ebfe2 | 2012-04-10 16:21:20 +0530 | [diff] [blame] | 155 | case POWER_SUPPLY_PROP_VOLTAGE_OCV: |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 156 | ret = regmap_read(map, MAX17042_OCVInternal, &data); |
Ramakrishna Pallala | a2ebfe2 | 2012-04-10 16:21:20 +0530 | [diff] [blame] | 157 | if (ret < 0) |
| 158 | return ret; |
| 159 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 160 | val->intval = data * 625 / 8; |
Ramakrishna Pallala | a2ebfe2 | 2012-04-10 16:21:20 +0530 | [diff] [blame] | 161 | break; |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 162 | case POWER_SUPPLY_PROP_CAPACITY: |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 163 | ret = regmap_read(map, MAX17042_RepSOC, &data); |
Ramakrishna Pallala | 60a1f6e | 2011-11-26 04:11:15 +0400 | [diff] [blame] | 164 | if (ret < 0) |
| 165 | return ret; |
| 166 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 167 | val->intval = data >> 8; |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 168 | break; |
Donggeun Kim | 086ef50 | 2011-06-30 18:07:41 +0900 | [diff] [blame] | 169 | case POWER_SUPPLY_PROP_CHARGE_FULL: |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 170 | ret = regmap_read(map, MAX17042_FullCAP, &data); |
Ramakrishna Pallala | 60a1f6e | 2011-11-26 04:11:15 +0400 | [diff] [blame] | 171 | if (ret < 0) |
| 172 | return ret; |
| 173 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 174 | val->intval = data * 1000 / 2; |
Donggeun Kim | 086ef50 | 2011-06-30 18:07:41 +0900 | [diff] [blame] | 175 | break; |
Ramakrishna Pallala | 5fc55bc | 2012-05-07 10:25:58 +0530 | [diff] [blame] | 176 | case POWER_SUPPLY_PROP_CHARGE_COUNTER: |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 177 | ret = regmap_read(map, MAX17042_QH, &data); |
Ramakrishna Pallala | 5fc55bc | 2012-05-07 10:25:58 +0530 | [diff] [blame] | 178 | if (ret < 0) |
| 179 | return ret; |
| 180 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 181 | val->intval = data * 1000 / 2; |
Ramakrishna Pallala | 5fc55bc | 2012-05-07 10:25:58 +0530 | [diff] [blame] | 182 | break; |
Donggeun Kim | 086ef50 | 2011-06-30 18:07:41 +0900 | [diff] [blame] | 183 | case POWER_SUPPLY_PROP_TEMP: |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 184 | ret = regmap_read(map, MAX17042_TEMP, &data); |
Ramakrishna Pallala | 60a1f6e | 2011-11-26 04:11:15 +0400 | [diff] [blame] | 185 | if (ret < 0) |
| 186 | return ret; |
| 187 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 188 | val->intval = data; |
Donggeun Kim | 086ef50 | 2011-06-30 18:07:41 +0900 | [diff] [blame] | 189 | /* The value is signed. */ |
| 190 | if (val->intval & 0x8000) { |
| 191 | val->intval = (0x7fff & ~val->intval) + 1; |
| 192 | val->intval *= -1; |
| 193 | } |
| 194 | /* The value is converted into deci-centigrade scale */ |
| 195 | /* Units of LSB = 1 / 256 degree Celsius */ |
| 196 | val->intval = val->intval * 10 / 256; |
| 197 | break; |
| 198 | case POWER_SUPPLY_PROP_CURRENT_NOW: |
| 199 | if (chip->pdata->enable_current_sense) { |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 200 | ret = regmap_read(map, MAX17042_Current, &data); |
Ramakrishna Pallala | 60a1f6e | 2011-11-26 04:11:15 +0400 | [diff] [blame] | 201 | if (ret < 0) |
| 202 | return ret; |
| 203 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 204 | val->intval = data; |
Donggeun Kim | 086ef50 | 2011-06-30 18:07:41 +0900 | [diff] [blame] | 205 | if (val->intval & 0x8000) { |
| 206 | /* Negative */ |
| 207 | val->intval = ~val->intval & 0x7fff; |
| 208 | val->intval++; |
| 209 | val->intval *= -1; |
| 210 | } |
Philip Rakity | 91d8b0d | 2011-08-12 21:19:57 -0700 | [diff] [blame] | 211 | val->intval *= 1562500 / chip->pdata->r_sns; |
Donggeun Kim | 086ef50 | 2011-06-30 18:07:41 +0900 | [diff] [blame] | 212 | } else { |
| 213 | return -EINVAL; |
| 214 | } |
| 215 | break; |
| 216 | case POWER_SUPPLY_PROP_CURRENT_AVG: |
| 217 | if (chip->pdata->enable_current_sense) { |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 218 | ret = regmap_read(map, MAX17042_AvgCurrent, &data); |
Ramakrishna Pallala | 60a1f6e | 2011-11-26 04:11:15 +0400 | [diff] [blame] | 219 | if (ret < 0) |
| 220 | return ret; |
| 221 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 222 | val->intval = data; |
Donggeun Kim | 086ef50 | 2011-06-30 18:07:41 +0900 | [diff] [blame] | 223 | if (val->intval & 0x8000) { |
| 224 | /* Negative */ |
| 225 | val->intval = ~val->intval & 0x7fff; |
| 226 | val->intval++; |
| 227 | val->intval *= -1; |
| 228 | } |
| 229 | val->intval *= 1562500 / chip->pdata->r_sns; |
| 230 | } else { |
| 231 | return -EINVAL; |
| 232 | } |
| 233 | break; |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 234 | default: |
| 235 | return -EINVAL; |
| 236 | } |
| 237 | return 0; |
| 238 | } |
| 239 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 240 | static int max17042_write_verify_reg(struct regmap *map, u8 reg, u32 value) |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 241 | { |
| 242 | int retries = 8; |
| 243 | int ret; |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 244 | u32 read_value; |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 245 | |
| 246 | do { |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 247 | ret = regmap_write(map, reg, value); |
| 248 | regmap_read(map, reg, &read_value); |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 249 | if (read_value != value) { |
| 250 | ret = -EIO; |
| 251 | retries--; |
| 252 | } |
| 253 | } while (retries && read_value != value); |
| 254 | |
| 255 | if (ret < 0) |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 256 | pr_err("%s: err %d\n", __func__, ret); |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 257 | |
| 258 | return ret; |
| 259 | } |
| 260 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 261 | static inline void max17042_override_por(struct regmap *map, |
| 262 | u8 reg, u16 value) |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 263 | { |
| 264 | if (value) |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 265 | regmap_write(map, reg, value); |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | static inline void max10742_unlock_model(struct max17042_chip *chip) |
| 269 | { |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 270 | struct regmap *map = chip->regmap; |
| 271 | regmap_write(map, MAX17042_MLOCKReg1, MODEL_UNLOCK1); |
| 272 | regmap_write(map, MAX17042_MLOCKReg2, MODEL_UNLOCK2); |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | static inline void max10742_lock_model(struct max17042_chip *chip) |
| 276 | { |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 277 | struct regmap *map = chip->regmap; |
| 278 | |
| 279 | regmap_write(map, MAX17042_MLOCKReg1, MODEL_LOCK1); |
| 280 | regmap_write(map, MAX17042_MLOCKReg2, MODEL_LOCK2); |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 281 | } |
| 282 | |
| 283 | static inline void max17042_write_model_data(struct max17042_chip *chip, |
| 284 | u8 addr, int size) |
| 285 | { |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 286 | struct regmap *map = chip->regmap; |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 287 | int i; |
| 288 | for (i = 0; i < size; i++) |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 289 | regmap_write(map, addr + i, |
| 290 | chip->pdata->config_data->cell_char_tbl[i]); |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | static inline void max17042_read_model_data(struct max17042_chip *chip, |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 294 | u8 addr, u32 *data, int size) |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 295 | { |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 296 | struct regmap *map = chip->regmap; |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 297 | int i; |
| 298 | |
| 299 | for (i = 0; i < size; i++) |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 300 | regmap_read(map, addr + i, &data[i]); |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | static inline int max17042_model_data_compare(struct max17042_chip *chip, |
| 304 | u16 *data1, u16 *data2, int size) |
| 305 | { |
| 306 | int i; |
| 307 | |
| 308 | if (memcmp(data1, data2, size)) { |
| 309 | dev_err(&chip->client->dev, "%s compare failed\n", __func__); |
| 310 | for (i = 0; i < size; i++) |
| 311 | dev_info(&chip->client->dev, "0x%x, 0x%x", |
| 312 | data1[i], data2[i]); |
| 313 | dev_info(&chip->client->dev, "\n"); |
| 314 | return -EINVAL; |
| 315 | } |
| 316 | return 0; |
| 317 | } |
| 318 | |
| 319 | static int max17042_init_model(struct max17042_chip *chip) |
| 320 | { |
| 321 | int ret; |
Dan Carpenter | 1ef3d8f | 2012-03-15 14:37:32 +0300 | [diff] [blame] | 322 | int table_size = ARRAY_SIZE(chip->pdata->config_data->cell_char_tbl); |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 323 | u32 *temp_data; |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 324 | |
Dan Carpenter | 1ef3d8f | 2012-03-15 14:37:32 +0300 | [diff] [blame] | 325 | temp_data = kcalloc(table_size, sizeof(*temp_data), GFP_KERNEL); |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 326 | if (!temp_data) |
| 327 | return -ENOMEM; |
| 328 | |
| 329 | max10742_unlock_model(chip); |
| 330 | max17042_write_model_data(chip, MAX17042_MODELChrTbl, |
| 331 | table_size); |
| 332 | max17042_read_model_data(chip, MAX17042_MODELChrTbl, temp_data, |
| 333 | table_size); |
| 334 | |
| 335 | ret = max17042_model_data_compare( |
| 336 | chip, |
| 337 | chip->pdata->config_data->cell_char_tbl, |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 338 | (u16 *)temp_data, |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 339 | table_size); |
| 340 | |
| 341 | max10742_lock_model(chip); |
| 342 | kfree(temp_data); |
| 343 | |
| 344 | return ret; |
| 345 | } |
| 346 | |
| 347 | static int max17042_verify_model_lock(struct max17042_chip *chip) |
| 348 | { |
| 349 | int i; |
Dan Carpenter | 1ef3d8f | 2012-03-15 14:37:32 +0300 | [diff] [blame] | 350 | int table_size = ARRAY_SIZE(chip->pdata->config_data->cell_char_tbl); |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 351 | u32 *temp_data; |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 352 | int ret = 0; |
| 353 | |
Dan Carpenter | 1ef3d8f | 2012-03-15 14:37:32 +0300 | [diff] [blame] | 354 | temp_data = kcalloc(table_size, sizeof(*temp_data), GFP_KERNEL); |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 355 | if (!temp_data) |
| 356 | return -ENOMEM; |
| 357 | |
| 358 | max17042_read_model_data(chip, MAX17042_MODELChrTbl, temp_data, |
| 359 | table_size); |
| 360 | for (i = 0; i < table_size; i++) |
| 361 | if (temp_data[i]) |
| 362 | ret = -EINVAL; |
| 363 | |
| 364 | kfree(temp_data); |
| 365 | return ret; |
| 366 | } |
| 367 | |
| 368 | static void max17042_write_config_regs(struct max17042_chip *chip) |
| 369 | { |
| 370 | struct max17042_config_data *config = chip->pdata->config_data; |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 371 | struct regmap *map = chip->regmap; |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 372 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 373 | regmap_write(map, MAX17042_CONFIG, config->config); |
| 374 | regmap_write(map, MAX17042_LearnCFG, config->learn_cfg); |
| 375 | regmap_write(map, MAX17042_FilterCFG, |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 376 | config->filter_cfg); |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 377 | regmap_write(map, MAX17042_RelaxCFG, config->relax_cfg); |
Beomho Seo | 709c2c7 | 2015-04-03 17:26:08 +0900 | [diff] [blame^] | 378 | if (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17047 || |
| 379 | chip->chip_type == MAXIM_DEVICE_TYPE_MAX17050) |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 380 | regmap_write(map, MAX17047_FullSOCThr, |
Ramakrishna Pallala | 9a8422d | 2012-05-05 14:34:26 +0530 | [diff] [blame] | 381 | config->full_soc_thresh); |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 382 | } |
| 383 | |
| 384 | static void max17042_write_custom_regs(struct max17042_chip *chip) |
| 385 | { |
| 386 | struct max17042_config_data *config = chip->pdata->config_data; |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 387 | struct regmap *map = chip->regmap; |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 388 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 389 | max17042_write_verify_reg(map, MAX17042_RCOMP0, config->rcomp0); |
| 390 | max17042_write_verify_reg(map, MAX17042_TempCo, config->tcompc0); |
| 391 | max17042_write_verify_reg(map, MAX17042_ICHGTerm, config->ichgt_term); |
Beomho Seo | 709c2c7 | 2015-04-03 17:26:08 +0900 | [diff] [blame^] | 392 | if (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17042) { |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 393 | regmap_write(map, MAX17042_EmptyTempCo, config->empty_tempco); |
| 394 | max17042_write_verify_reg(map, MAX17042_K_empty0, |
Ramakrishna Pallala | 9a8422d | 2012-05-05 14:34:26 +0530 | [diff] [blame] | 395 | config->kempty0); |
| 396 | } else { |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 397 | max17042_write_verify_reg(map, MAX17047_QRTbl00, |
Ramakrishna Pallala | 9a8422d | 2012-05-05 14:34:26 +0530 | [diff] [blame] | 398 | config->qrtbl00); |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 399 | max17042_write_verify_reg(map, MAX17047_QRTbl10, |
Ramakrishna Pallala | 9a8422d | 2012-05-05 14:34:26 +0530 | [diff] [blame] | 400 | config->qrtbl10); |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 401 | max17042_write_verify_reg(map, MAX17047_QRTbl20, |
Ramakrishna Pallala | 9a8422d | 2012-05-05 14:34:26 +0530 | [diff] [blame] | 402 | config->qrtbl20); |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 403 | max17042_write_verify_reg(map, MAX17047_QRTbl30, |
Ramakrishna Pallala | 9a8422d | 2012-05-05 14:34:26 +0530 | [diff] [blame] | 404 | config->qrtbl30); |
| 405 | } |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | static void max17042_update_capacity_regs(struct max17042_chip *chip) |
| 409 | { |
| 410 | struct max17042_config_data *config = chip->pdata->config_data; |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 411 | struct regmap *map = chip->regmap; |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 412 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 413 | max17042_write_verify_reg(map, MAX17042_FullCAP, |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 414 | config->fullcap); |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 415 | regmap_write(map, MAX17042_DesignCap, config->design_cap); |
| 416 | max17042_write_verify_reg(map, MAX17042_FullCAPNom, |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 417 | config->fullcapnom); |
| 418 | } |
| 419 | |
| 420 | static void max17042_reset_vfsoc0_reg(struct max17042_chip *chip) |
| 421 | { |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 422 | unsigned int vfSoc; |
| 423 | struct regmap *map = chip->regmap; |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 424 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 425 | regmap_read(map, MAX17042_VFSOC, &vfSoc); |
| 426 | regmap_write(map, MAX17042_VFSOC0Enable, VFSOC0_UNLOCK); |
| 427 | max17042_write_verify_reg(map, MAX17042_VFSOC0, vfSoc); |
| 428 | regmap_write(map, MAX17042_VFSOC0Enable, VFSOC0_LOCK); |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | static void max17042_load_new_capacity_params(struct max17042_chip *chip) |
| 432 | { |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 433 | u32 full_cap0, rep_cap, dq_acc, vfSoc; |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 434 | u32 rem_cap; |
| 435 | |
| 436 | struct max17042_config_data *config = chip->pdata->config_data; |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 437 | struct regmap *map = chip->regmap; |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 438 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 439 | regmap_read(map, MAX17042_FullCAP0, &full_cap0); |
| 440 | regmap_read(map, MAX17042_VFSOC, &vfSoc); |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 441 | |
| 442 | /* fg_vfSoc needs to shifted by 8 bits to get the |
| 443 | * perc in 1% accuracy, to get the right rem_cap multiply |
| 444 | * full_cap0, fg_vfSoc and devide by 100 |
| 445 | */ |
| 446 | rem_cap = ((vfSoc >> 8) * full_cap0) / 100; |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 447 | max17042_write_verify_reg(map, MAX17042_RemCap, rem_cap); |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 448 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 449 | rep_cap = rem_cap; |
| 450 | max17042_write_verify_reg(map, MAX17042_RepCap, rep_cap); |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 451 | |
| 452 | /* Write dQ_acc to 200% of Capacity and dP_acc to 200% */ |
| 453 | dq_acc = config->fullcap / dQ_ACC_DIV; |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 454 | max17042_write_verify_reg(map, MAX17042_dQacc, dq_acc); |
| 455 | max17042_write_verify_reg(map, MAX17042_dPacc, dP_ACC_200); |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 456 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 457 | max17042_write_verify_reg(map, MAX17042_FullCAP, |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 458 | config->fullcap); |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 459 | regmap_write(map, MAX17042_DesignCap, |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 460 | config->design_cap); |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 461 | max17042_write_verify_reg(map, MAX17042_FullCAPNom, |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 462 | config->fullcapnom); |
Ramakrishna Pallala | 9a8422d | 2012-05-05 14:34:26 +0530 | [diff] [blame] | 463 | /* Update SOC register with new SOC */ |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 464 | regmap_write(map, MAX17042_RepSOC, vfSoc); |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 465 | } |
| 466 | |
| 467 | /* |
| 468 | * Block write all the override values coming from platform data. |
| 469 | * This function MUST be called before the POR initialization proceedure |
| 470 | * specified by maxim. |
| 471 | */ |
| 472 | static inline void max17042_override_por_values(struct max17042_chip *chip) |
| 473 | { |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 474 | struct regmap *map = chip->regmap; |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 475 | struct max17042_config_data *config = chip->pdata->config_data; |
| 476 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 477 | max17042_override_por(map, MAX17042_TGAIN, config->tgain); |
| 478 | max17042_override_por(map, MAx17042_TOFF, config->toff); |
| 479 | max17042_override_por(map, MAX17042_CGAIN, config->cgain); |
| 480 | max17042_override_por(map, MAX17042_COFF, config->coff); |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 481 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 482 | max17042_override_por(map, MAX17042_VALRT_Th, config->valrt_thresh); |
| 483 | max17042_override_por(map, MAX17042_TALRT_Th, config->talrt_thresh); |
| 484 | max17042_override_por(map, MAX17042_SALRT_Th, |
| 485 | config->soc_alrt_thresh); |
| 486 | max17042_override_por(map, MAX17042_CONFIG, config->config); |
| 487 | max17042_override_por(map, MAX17042_SHDNTIMER, config->shdntimer); |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 488 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 489 | max17042_override_por(map, MAX17042_DesignCap, config->design_cap); |
| 490 | max17042_override_por(map, MAX17042_ICHGTerm, config->ichgt_term); |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 491 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 492 | max17042_override_por(map, MAX17042_AtRate, config->at_rate); |
| 493 | max17042_override_por(map, MAX17042_LearnCFG, config->learn_cfg); |
| 494 | max17042_override_por(map, MAX17042_FilterCFG, config->filter_cfg); |
| 495 | max17042_override_por(map, MAX17042_RelaxCFG, config->relax_cfg); |
| 496 | max17042_override_por(map, MAX17042_MiscCFG, config->misc_cfg); |
| 497 | max17042_override_por(map, MAX17042_MaskSOC, config->masksoc); |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 498 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 499 | max17042_override_por(map, MAX17042_FullCAP, config->fullcap); |
| 500 | max17042_override_por(map, MAX17042_FullCAPNom, config->fullcapnom); |
Beomho Seo | 709c2c7 | 2015-04-03 17:26:08 +0900 | [diff] [blame^] | 501 | if (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17042) |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 502 | max17042_override_por(map, MAX17042_SOC_empty, |
Ramakrishna Pallala | 9a8422d | 2012-05-05 14:34:26 +0530 | [diff] [blame] | 503 | config->socempty); |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 504 | max17042_override_por(map, MAX17042_LAvg_empty, config->lavg_empty); |
| 505 | max17042_override_por(map, MAX17042_dQacc, config->dqacc); |
| 506 | max17042_override_por(map, MAX17042_dPacc, config->dpacc); |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 507 | |
Beomho Seo | 709c2c7 | 2015-04-03 17:26:08 +0900 | [diff] [blame^] | 508 | if (chip->chip_type == MAXIM_DEVICE_TYPE_MAX17042) |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 509 | max17042_override_por(map, MAX17042_V_empty, config->vempty); |
Ramakrishna Pallala | 9a8422d | 2012-05-05 14:34:26 +0530 | [diff] [blame] | 510 | else |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 511 | max17042_override_por(map, MAX17047_V_empty, config->vempty); |
| 512 | max17042_override_por(map, MAX17042_TempNom, config->temp_nom); |
| 513 | max17042_override_por(map, MAX17042_TempLim, config->temp_lim); |
| 514 | max17042_override_por(map, MAX17042_FCTC, config->fctc); |
| 515 | max17042_override_por(map, MAX17042_RCOMP0, config->rcomp0); |
| 516 | max17042_override_por(map, MAX17042_TempCo, config->tcompc0); |
Ramakrishna Pallala | 9a8422d | 2012-05-05 14:34:26 +0530 | [diff] [blame] | 517 | if (chip->chip_type) { |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 518 | max17042_override_por(map, MAX17042_EmptyTempCo, |
| 519 | config->empty_tempco); |
| 520 | max17042_override_por(map, MAX17042_K_empty0, |
| 521 | config->kempty0); |
Ramakrishna Pallala | 9a8422d | 2012-05-05 14:34:26 +0530 | [diff] [blame] | 522 | } |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 523 | } |
| 524 | |
| 525 | static int max17042_init_chip(struct max17042_chip *chip) |
| 526 | { |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 527 | struct regmap *map = chip->regmap; |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 528 | int ret; |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 529 | |
| 530 | max17042_override_por_values(chip); |
| 531 | /* After Power up, the MAX17042 requires 500mS in order |
| 532 | * to perform signal debouncing and initial SOC reporting |
| 533 | */ |
| 534 | msleep(500); |
| 535 | |
| 536 | /* Initialize configaration */ |
| 537 | max17042_write_config_regs(chip); |
| 538 | |
| 539 | /* write cell characterization data */ |
| 540 | ret = max17042_init_model(chip); |
| 541 | if (ret) { |
| 542 | dev_err(&chip->client->dev, "%s init failed\n", |
| 543 | __func__); |
| 544 | return -EIO; |
| 545 | } |
Alan Cox | a879f19 | 2012-11-18 14:59:47 -0800 | [diff] [blame] | 546 | |
| 547 | ret = max17042_verify_model_lock(chip); |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 548 | if (ret) { |
| 549 | dev_err(&chip->client->dev, "%s lock verify failed\n", |
| 550 | __func__); |
| 551 | return -EIO; |
| 552 | } |
| 553 | /* write custom parameters */ |
| 554 | max17042_write_custom_regs(chip); |
| 555 | |
| 556 | /* update capacity params */ |
| 557 | max17042_update_capacity_regs(chip); |
| 558 | |
| 559 | /* delay must be atleast 350mS to allow VFSOC |
| 560 | * to be calculated from the new configuration |
| 561 | */ |
| 562 | msleep(350); |
| 563 | |
| 564 | /* reset vfsoc0 reg */ |
| 565 | max17042_reset_vfsoc0_reg(chip); |
| 566 | |
| 567 | /* load new capacity params */ |
| 568 | max17042_load_new_capacity_params(chip); |
| 569 | |
| 570 | /* Init complete, Clear the POR bit */ |
Krzysztof Kozlowski | bc35268 | 2015-02-24 10:54:47 +0100 | [diff] [blame] | 571 | regmap_update_bits(map, MAX17042_STATUS, STATUS_POR_BIT, 0x0); |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 572 | return 0; |
| 573 | } |
| 574 | |
Ramakrishna Pallala | e5f3872 | 2012-01-24 09:26:06 -0800 | [diff] [blame] | 575 | static void max17042_set_soc_threshold(struct max17042_chip *chip, u16 off) |
| 576 | { |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 577 | struct regmap *map = chip->regmap; |
| 578 | u32 soc, soc_tr; |
Ramakrishna Pallala | e5f3872 | 2012-01-24 09:26:06 -0800 | [diff] [blame] | 579 | |
| 580 | /* program interrupt thesholds such that we should |
| 581 | * get interrupt for every 'off' perc change in the soc |
| 582 | */ |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 583 | regmap_read(map, MAX17042_RepSOC, &soc); |
| 584 | soc >>= 8; |
Ramakrishna Pallala | e5f3872 | 2012-01-24 09:26:06 -0800 | [diff] [blame] | 585 | soc_tr = (soc + off) << 8; |
| 586 | soc_tr |= (soc - off); |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 587 | regmap_write(map, MAX17042_SALRT_Th, soc_tr); |
Ramakrishna Pallala | e5f3872 | 2012-01-24 09:26:06 -0800 | [diff] [blame] | 588 | } |
| 589 | |
Ramakrishna Pallala | e5f3872 | 2012-01-24 09:26:06 -0800 | [diff] [blame] | 590 | static irqreturn_t max17042_thread_handler(int id, void *dev) |
| 591 | { |
| 592 | struct max17042_chip *chip = dev; |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 593 | u32 val; |
Ramakrishna Pallala | e5f3872 | 2012-01-24 09:26:06 -0800 | [diff] [blame] | 594 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 595 | regmap_read(chip->regmap, MAX17042_STATUS, &val); |
Ramakrishna Pallala | 5cdd4d7 | 2012-03-21 03:03:16 +0530 | [diff] [blame] | 596 | if ((val & STATUS_INTR_SOCMIN_BIT) || |
| 597 | (val & STATUS_INTR_SOCMAX_BIT)) { |
Ramakrishna Pallala | e5f3872 | 2012-01-24 09:26:06 -0800 | [diff] [blame] | 598 | dev_info(&chip->client->dev, "SOC threshold INTR\n"); |
| 599 | max17042_set_soc_threshold(chip, 1); |
| 600 | } |
| 601 | |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 602 | power_supply_changed(chip->battery); |
Ramakrishna Pallala | e5f3872 | 2012-01-24 09:26:06 -0800 | [diff] [blame] | 603 | return IRQ_HANDLED; |
| 604 | } |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 605 | |
| 606 | static void max17042_init_worker(struct work_struct *work) |
| 607 | { |
| 608 | struct max17042_chip *chip = container_of(work, |
| 609 | struct max17042_chip, work); |
| 610 | int ret; |
| 611 | |
| 612 | /* Initialize registers according to values from the platform data */ |
| 613 | if (chip->pdata->enable_por_init && chip->pdata->config_data) { |
| 614 | ret = max17042_init_chip(chip); |
| 615 | if (ret) |
| 616 | return; |
| 617 | } |
| 618 | |
| 619 | chip->init_complete = 1; |
| 620 | } |
| 621 | |
Karol Lewandowski | 3832246 | 2012-02-22 19:06:22 +0100 | [diff] [blame] | 622 | #ifdef CONFIG_OF |
| 623 | static struct max17042_platform_data * |
| 624 | max17042_get_pdata(struct device *dev) |
| 625 | { |
| 626 | struct device_node *np = dev->of_node; |
| 627 | u32 prop; |
| 628 | struct max17042_platform_data *pdata; |
| 629 | |
| 630 | if (!np) |
| 631 | return dev->platform_data; |
| 632 | |
| 633 | pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); |
| 634 | if (!pdata) |
| 635 | return NULL; |
| 636 | |
| 637 | /* |
| 638 | * Require current sense resistor value to be specified for |
| 639 | * current-sense functionality to be enabled at all. |
| 640 | */ |
| 641 | if (of_property_read_u32(np, "maxim,rsns-microohm", &prop) == 0) { |
| 642 | pdata->r_sns = prop; |
| 643 | pdata->enable_current_sense = true; |
| 644 | } |
| 645 | |
| 646 | return pdata; |
| 647 | } |
| 648 | #else |
| 649 | static struct max17042_platform_data * |
| 650 | max17042_get_pdata(struct device *dev) |
| 651 | { |
| 652 | return dev->platform_data; |
| 653 | } |
| 654 | #endif |
| 655 | |
Krzysztof Kozlowski | e029128 | 2015-01-05 09:50:17 +0100 | [diff] [blame] | 656 | static const struct regmap_config max17042_regmap_config = { |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 657 | .reg_bits = 8, |
| 658 | .val_bits = 16, |
| 659 | .val_format_endian = REGMAP_ENDIAN_NATIVE, |
| 660 | }; |
| 661 | |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 662 | static const struct power_supply_desc max17042_psy_desc = { |
| 663 | .name = "max170xx_battery", |
| 664 | .type = POWER_SUPPLY_TYPE_BATTERY, |
| 665 | .get_property = max17042_get_property, |
| 666 | .properties = max17042_battery_props, |
| 667 | .num_properties = ARRAY_SIZE(max17042_battery_props), |
| 668 | }; |
| 669 | |
| 670 | static const struct power_supply_desc max17042_no_current_sense_psy_desc = { |
| 671 | .name = "max170xx_battery", |
| 672 | .type = POWER_SUPPLY_TYPE_BATTERY, |
| 673 | .get_property = max17042_get_property, |
| 674 | .properties = max17042_battery_props, |
| 675 | .num_properties = ARRAY_SIZE(max17042_battery_props) - 2, |
| 676 | }; |
| 677 | |
Bill Pemberton | c8afa64 | 2012-11-19 13:22:23 -0500 | [diff] [blame] | 678 | static int max17042_probe(struct i2c_client *client, |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 679 | const struct i2c_device_id *id) |
| 680 | { |
| 681 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 682 | const struct power_supply_desc *max17042_desc = &max17042_psy_desc; |
| 683 | struct power_supply_config psy_cfg = {}; |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 684 | struct max17042_chip *chip; |
| 685 | int ret; |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 686 | int i; |
| 687 | u32 val; |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 688 | |
| 689 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA)) |
| 690 | return -EIO; |
| 691 | |
Karol Lewandowski | 2f3b434 | 2012-02-22 19:06:20 +0100 | [diff] [blame] | 692 | chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 693 | if (!chip) |
| 694 | return -ENOMEM; |
| 695 | |
| 696 | chip->client = client; |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 697 | chip->regmap = devm_regmap_init_i2c(client, &max17042_regmap_config); |
| 698 | if (IS_ERR(chip->regmap)) { |
| 699 | dev_err(&client->dev, "Failed to initialize regmap\n"); |
| 700 | return -EINVAL; |
| 701 | } |
| 702 | |
Karol Lewandowski | 3832246 | 2012-02-22 19:06:22 +0100 | [diff] [blame] | 703 | chip->pdata = max17042_get_pdata(&client->dev); |
| 704 | if (!chip->pdata) { |
| 705 | dev_err(&client->dev, "no platform data provided\n"); |
| 706 | return -EINVAL; |
| 707 | } |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 708 | |
| 709 | i2c_set_clientdata(client, chip); |
Beomho Seo | 709c2c7 | 2015-04-03 17:26:08 +0900 | [diff] [blame^] | 710 | chip->chip_type = id->driver_data; |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 711 | psy_cfg.drv_data = chip; |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 712 | |
Donggeun Kim | 086ef50 | 2011-06-30 18:07:41 +0900 | [diff] [blame] | 713 | /* When current is not measured, |
| 714 | * CURRENT_NOW and CURRENT_AVG properties should be invisible. */ |
| 715 | if (!chip->pdata->enable_current_sense) |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 716 | max17042_desc = &max17042_no_current_sense_psy_desc; |
Donggeun Kim | 086ef50 | 2011-06-30 18:07:41 +0900 | [diff] [blame] | 717 | |
Philip Rakity | 4cfa892 | 2011-08-12 21:18:18 -0700 | [diff] [blame] | 718 | if (chip->pdata->r_sns == 0) |
| 719 | chip->pdata->r_sns = MAX17042_DEFAULT_SNS_RESISTOR; |
| 720 | |
Donggeun Kim | 086ef50 | 2011-06-30 18:07:41 +0900 | [diff] [blame] | 721 | if (chip->pdata->init_data) |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 722 | for (i = 0; i < chip->pdata->num_init_data; i++) |
| 723 | regmap_write(chip->regmap, |
| 724 | chip->pdata->init_data[i].addr, |
| 725 | chip->pdata->init_data[i].data); |
Donggeun Kim | 086ef50 | 2011-06-30 18:07:41 +0900 | [diff] [blame] | 726 | |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 727 | if (!chip->pdata->enable_current_sense) { |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 728 | regmap_write(chip->regmap, MAX17042_CGAIN, 0x0000); |
| 729 | regmap_write(chip->regmap, MAX17042_MiscCFG, 0x0003); |
| 730 | regmap_write(chip->regmap, MAX17042_LearnCFG, 0x0007); |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 731 | } |
| 732 | |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 733 | chip->battery = power_supply_register(&client->dev, max17042_desc, |
| 734 | &psy_cfg); |
| 735 | if (IS_ERR(chip->battery)) { |
Ramakrishna Pallala | 243e352 | 2012-05-05 03:08:37 +0530 | [diff] [blame] | 736 | dev_err(&client->dev, "failed: power supply register\n"); |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 737 | return PTR_ERR(chip->battery); |
Ramakrishna Pallala | 243e352 | 2012-05-05 03:08:37 +0530 | [diff] [blame] | 738 | } |
| 739 | |
Ramakrishna Pallala | e5f3872 | 2012-01-24 09:26:06 -0800 | [diff] [blame] | 740 | if (client->irq) { |
Ramakrishna Pallala | 5cdd4d7 | 2012-03-21 03:03:16 +0530 | [diff] [blame] | 741 | ret = request_threaded_irq(client->irq, NULL, |
Jonghwa Lee | 26740db | 2013-12-18 12:53:53 +0900 | [diff] [blame] | 742 | max17042_thread_handler, |
| 743 | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 744 | chip->battery->desc->name, chip); |
Ramakrishna Pallala | e5f3872 | 2012-01-24 09:26:06 -0800 | [diff] [blame] | 745 | if (!ret) { |
Krzysztof Kozlowski | bc35268 | 2015-02-24 10:54:47 +0100 | [diff] [blame] | 746 | regmap_update_bits(chip->regmap, MAX17042_CONFIG, |
| 747 | CONFIG_ALRT_BIT_ENBL, |
| 748 | CONFIG_ALRT_BIT_ENBL); |
Ramakrishna Pallala | e5f3872 | 2012-01-24 09:26:06 -0800 | [diff] [blame] | 749 | max17042_set_soc_threshold(chip, 1); |
Ramakrishna Pallala | e5ba50b | 2012-05-05 04:43:10 +0530 | [diff] [blame] | 750 | } else { |
| 751 | client->irq = 0; |
Ramakrishna Pallala | e5f3872 | 2012-01-24 09:26:06 -0800 | [diff] [blame] | 752 | dev_err(&client->dev, "%s(): cannot get IRQ\n", |
| 753 | __func__); |
Ramakrishna Pallala | e5ba50b | 2012-05-05 04:43:10 +0530 | [diff] [blame] | 754 | } |
Ramakrishna Pallala | e5f3872 | 2012-01-24 09:26:06 -0800 | [diff] [blame] | 755 | } |
| 756 | |
Jonghwa Lee | 39e7213 | 2013-10-25 13:55:02 +0900 | [diff] [blame] | 757 | regmap_read(chip->regmap, MAX17042_STATUS, &val); |
| 758 | if (val & STATUS_POR_BIT) { |
Ramakrishna Pallala | f3a71a6 | 2012-03-13 22:03:52 +0400 | [diff] [blame] | 759 | INIT_WORK(&chip->work, max17042_init_worker); |
| 760 | schedule_work(&chip->work); |
| 761 | } else { |
| 762 | chip->init_complete = 1; |
| 763 | } |
| 764 | |
Ramakrishna Pallala | 243e352 | 2012-05-05 03:08:37 +0530 | [diff] [blame] | 765 | return 0; |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 766 | } |
| 767 | |
Bill Pemberton | 415ec69 | 2012-11-19 13:26:07 -0500 | [diff] [blame] | 768 | static int max17042_remove(struct i2c_client *client) |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 769 | { |
| 770 | struct max17042_chip *chip = i2c_get_clientdata(client); |
| 771 | |
Ramakrishna Pallala | bb28da9 | 2012-03-26 15:38:26 +0530 | [diff] [blame] | 772 | if (client->irq) |
| 773 | free_irq(client->irq, chip); |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 774 | power_supply_unregister(chip->battery); |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 775 | return 0; |
| 776 | } |
| 777 | |
Manish Badarkhe | 3d23c7f | 2013-10-14 10:56:51 +0530 | [diff] [blame] | 778 | #ifdef CONFIG_PM_SLEEP |
Ramakrishna Pallala | 48bc177 | 2012-03-27 02:23:40 +0530 | [diff] [blame] | 779 | static int max17042_suspend(struct device *dev) |
| 780 | { |
| 781 | struct max17042_chip *chip = dev_get_drvdata(dev); |
| 782 | |
Anton Vorontsov | 48e41c7 | 2012-05-04 20:38:13 -0700 | [diff] [blame] | 783 | /* |
| 784 | * disable the irq and enable irq_wake |
Ramakrishna Pallala | 48bc177 | 2012-03-27 02:23:40 +0530 | [diff] [blame] | 785 | * capability to the interrupt line. |
| 786 | */ |
| 787 | if (chip->client->irq) { |
| 788 | disable_irq(chip->client->irq); |
| 789 | enable_irq_wake(chip->client->irq); |
| 790 | } |
| 791 | |
| 792 | return 0; |
| 793 | } |
| 794 | |
| 795 | static int max17042_resume(struct device *dev) |
| 796 | { |
| 797 | struct max17042_chip *chip = dev_get_drvdata(dev); |
| 798 | |
| 799 | if (chip->client->irq) { |
| 800 | disable_irq_wake(chip->client->irq); |
| 801 | enable_irq(chip->client->irq); |
| 802 | /* re-program the SOC thresholds to 1% change */ |
| 803 | max17042_set_soc_threshold(chip, 1); |
| 804 | } |
| 805 | |
| 806 | return 0; |
| 807 | } |
Ramakrishna Pallala | 48bc177 | 2012-03-27 02:23:40 +0530 | [diff] [blame] | 808 | #endif |
| 809 | |
Manish Badarkhe | 3d23c7f | 2013-10-14 10:56:51 +0530 | [diff] [blame] | 810 | static SIMPLE_DEV_PM_OPS(max17042_pm_ops, max17042_suspend, |
| 811 | max17042_resume); |
| 812 | |
Karol Lewandowski | 3832246 | 2012-02-22 19:06:22 +0100 | [diff] [blame] | 813 | #ifdef CONFIG_OF |
| 814 | static const struct of_device_id max17042_dt_match[] = { |
| 815 | { .compatible = "maxim,max17042" }, |
Ramakrishna Pallala | 9a8422d | 2012-05-05 14:34:26 +0530 | [diff] [blame] | 816 | { .compatible = "maxim,max17047" }, |
| 817 | { .compatible = "maxim,max17050" }, |
Karol Lewandowski | 3832246 | 2012-02-22 19:06:22 +0100 | [diff] [blame] | 818 | { }, |
| 819 | }; |
| 820 | MODULE_DEVICE_TABLE(of, max17042_dt_match); |
| 821 | #endif |
| 822 | |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 823 | static const struct i2c_device_id max17042_id[] = { |
Beomho Seo | 709c2c7 | 2015-04-03 17:26:08 +0900 | [diff] [blame^] | 824 | { "max17042", MAXIM_DEVICE_TYPE_MAX17042 }, |
| 825 | { "max17047", MAXIM_DEVICE_TYPE_MAX17047 }, |
| 826 | { "max17050", MAXIM_DEVICE_TYPE_MAX17050 }, |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 827 | { } |
| 828 | }; |
| 829 | MODULE_DEVICE_TABLE(i2c, max17042_id); |
| 830 | |
| 831 | static struct i2c_driver max17042_i2c_driver = { |
| 832 | .driver = { |
| 833 | .name = "max17042", |
Karol Lewandowski | 3832246 | 2012-02-22 19:06:22 +0100 | [diff] [blame] | 834 | .of_match_table = of_match_ptr(max17042_dt_match), |
Manish Badarkhe | 3d23c7f | 2013-10-14 10:56:51 +0530 | [diff] [blame] | 835 | .pm = &max17042_pm_ops, |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 836 | }, |
| 837 | .probe = max17042_probe, |
Bill Pemberton | 28ea73f | 2012-11-19 13:20:40 -0500 | [diff] [blame] | 838 | .remove = max17042_remove, |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 839 | .id_table = max17042_id, |
| 840 | }; |
Axel Lin | 5ff92e7 | 2012-01-21 14:42:54 +0800 | [diff] [blame] | 841 | module_i2c_driver(max17042_i2c_driver); |
MyungJoo Ham | 359ab9f | 2011-01-14 14:46:11 +0900 | [diff] [blame] | 842 | |
| 843 | MODULE_AUTHOR("MyungJoo Ham <myungjoo.ham@samsung.com>"); |
| 844 | MODULE_DESCRIPTION("MAX17042 Fuel Gauge"); |
| 845 | MODULE_LICENSE("GPL"); |