Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932687AbdGKQHw (ORCPT ); Tue, 11 Jul 2017 12:07:52 -0400 Received: from mail-sn1nam01on0073.outbound.protection.outlook.com ([104.47.32.73]:15280 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932498AbdGKQHt (ORCPT ); Tue, 11 Jul 2017 12:07:49 -0400 Authentication-Results: spf=pass (sender IP is 137.71.25.57) smtp.mailfrom=analog.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=analog.com; From: Dragos Bogdan To: Sebastian Reichel , Rob Herring , "Mark Rutland" CC: , , , Dragos Bogdan Subject: [PATCH v2] power: supply: ltc2941-battery-gauge: Add LTC2944 support Date: Tue, 11 Jul 2017 19:07:32 +0300 Message-ID: <20170711160732.16170-1-dragos.bogdan@analog.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(39860400002)(39840400002)(39400400002)(39410400002)(39850400002)(39450400003)(2980300002)(438002)(189002)(199003)(33646002)(106466001)(38730400002)(47776003)(8936002)(8676002)(189998001)(53416004)(5003940100001)(626005)(5660300001)(356003)(77096006)(50986999)(4326008)(107886003)(7636002)(86362001)(36756003)(575784001)(54906002)(305945005)(2906002)(1076002)(478600001)(50466002)(48376002)(6666003)(72206003)(50226002);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR03MB2829;H:nwd2mta4.analog.com;FPR:;SPF:Pass;MLV:sfv;MX:1;A:1;LANG:en; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b9463862-342e-4e26-e7a6-08d4c876f83f X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(8251501002)(2017030254075)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:MWHPR03MB2829; X-MS-TrafficTypeDiagnostic: MWHPR03MB2829: X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB2829;20:JZpSdyyIztsuv+OgAFrCJ4JnOCANQxo+Zr/Fb3IhdULdLNsacRSH3zEf6850epLeRFsWMpINavNdvXMSjOGNxAgy7mXKY5u3DpOaJ3BxJx7UUO3getlx41DDkC6S2HsHaTWoOZtacGxiGr1I2PYZ13yQhlQ3+q9xMnRvdCmeAHc8T4JWqT9YhtBqN+EPinmIDPAxdDmdwzrn2wQnU5AzOG7P8LI7uMvmy0GFaIQjDAwA3TO70oD4QOYaDVBTUqXOqA113BaPBO5qJjeIs2opRI97YYgNg94T2wM1Em+OGoo+bPQGPW7beaYBogaVJNCk/OV9VnGA5Aui52U7Fa3vgpCtOnv8QW9CDs2FJEQZStTO+fj/7gmLDIFX6St3XHAeA83PkKgnK5YexB+2AAFnLTiWEeic4vAhOeTlJ2gc5r40QFMdvALY+IMhZWEjZVQPUjuI7zvYINcetEqLM4Ny5LIsc8vS1+HP0FhRPwrEPo0wgLvvm0QkktcOpqJMCP4G X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(133145235818549)(72170088055959)(236129657087228)(232431446821674); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(2017060910075)(13018025)(13016025)(5005006)(8121501046)(3002001)(100000703101)(100105400095)(93006095)(93004095)(10201501046)(6055026)(6041248)(20161123555025)(20161123564025)(20161123562025)(20161123560025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:MWHPR03MB2829;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:MWHPR03MB2829; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;MWHPR03MB2829;4:L3qVr60pP7DwVzaKSJm7+qPtfrhEktQuK5nxXj8UE+?= =?us-ascii?Q?mGSa3YsrjbNL/cgTb/7XHB+Q7uww9umYw8MxI3vBrYOmbUY9Rm/t+sHe6tJv?= =?us-ascii?Q?V1fLNvSR5uIoy1f8Cxg6uRFauJHHfgwWm6HBPqkANUkySieg/ULvPx4cF3/e?= =?us-ascii?Q?fACekhRYibkRapczknSfIh39dPVKGxcl3k2ogCDINk7VU/W1dKcw6Lf/wOE+?= =?us-ascii?Q?hNhohLNW6kp6AaJj6lESm6j8fURwQb0XhJA0N9mZkEXhf6If7VtP++OKLdGz?= =?us-ascii?Q?sEcukJiS1n/ZDphV1qFP17cjaONodj50YFiIC/6T5htnZgAG2nDsjGTwWoDQ?= =?us-ascii?Q?V56NW4yKRKgadovlzTQIEmsOkaknWdNlMPz7naGW1EzV3AQ4spdY7o+sxxr4?= =?us-ascii?Q?ju1jNzYilviiXWgXJ0RRrxHRJDyNIoUMzvNaTPnpmZ+dUGfbCCi0rBNKGfUf?= =?us-ascii?Q?0d035BxD/OXqKiq9s/FlLPxDFctpVcCQhIMKVtMgvPLf/QoH78laQvEeSeH8?= =?us-ascii?Q?kn9G7/cRiE20KV6VrttlDsZ8w7GL5/v1dJRerkjDOwS1hutRJSSw5ez1In2D?= =?us-ascii?Q?sZDyK7TYhYnsK/FSpvvcvxnbGhHZGRpfd7037aYsAn85aD0JsFXPpRC4tqwY?= =?us-ascii?Q?O2mE80JDhoPI3bpt1Mu14EQAgRw8R9O5HDVCGp6AuQEV0jgThJGpkR5FqIjg?= =?us-ascii?Q?GB/8kNInoqHL/Dr+SrhkmN4DowgFtD05FvDw2w14rOo6gEd+0mg33gMwd67c?= =?us-ascii?Q?V3DEEZdUjtITJJ7AaXmUTJIvW1/GSo3RElkec88kF4NAnzPCNJ6U2INgk5d4?= =?us-ascii?Q?tK/S3TLo5AQvOd8yjA7KvuBAdIEYQRjEFyjCsreJbN6cYoOaBV3WpWGAURPr?= =?us-ascii?Q?19gwWNmcLLQlts2ISFgCsL9a9wI/s5SPbAF/0nPCQhWk0cRt5if/bnyMdJCC?= =?us-ascii?Q?KYcUUN//dhC+Q4G0AR1c29x3IGkHabwAyawScwfG3HBtyNuXJ59sc4RibFoB?= =?us-ascii?Q?iiqvBDRh/9uXl16KK3n6BF/h6uaucAiekjiqu+bh4tkcz40Rqyg04SQOqRVy?= =?us-ascii?Q?x/vRhpE4BS7Do6sgtdH3nPxaJ47PZ9SAKsTGJBTUZc4cAEK1NyPVsITxkz0H?= =?us-ascii?Q?t1ILskcrKAA+OBOWZGjHnJW/rCrrNnXlrbaHiHfj+pKsdgw9sYSx4eVifP+f?= =?us-ascii?Q?s4ra8E0ANBa4jPqky4P1Ezpb9Jeth6jaAX7fQIZV37Ehq6VnOvDpPc9suuoK?= =?us-ascii?Q?VH2f5WSTx5BCMN4kzAALoRQk73FdDcBO2ChJONY/VSGT9vnl+qkSbFGfPKB5?= =?us-ascii?Q?eb85+VvFjwk5Z+xhsG+Kfbsxi9vkPy90ClXHVDzsPIMPSACXcQkK9BnyBKAH?= =?us-ascii?Q?xT7szTyuC01XNnGRu/NHe+/fY=3D?= X-Forefront-PRVS: 0365C0E14B X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;MWHPR03MB2829;23:/fbS089BRptyqrb5YiedpFiXT36UPM+r9k9stE+4V?= =?us-ascii?Q?rCL+kdjvMYqOMcQ5v1yYrGOGIbmvsUmJXyZD5evFtRxA+tlZpoTlPGVwX7Wh?= =?us-ascii?Q?7uKZpRyAUhidIhMZO5Ae3Ja9HIyEk3v50RjYlbvPSCHPH9+toWpzIHLFL1RD?= =?us-ascii?Q?95D9aATzzvrJMu8csH/8cWrfmqwl4eyj5yqbzWqT1flTb62o/2bPViWJjpfu?= =?us-ascii?Q?skVDdRoE2872yOqWXKzTxHAVO5WMWACYkLR6YDHQzOOoAXiT55mY1j+SIEDu?= =?us-ascii?Q?56/VNwBENIsYWU1hDu+1k/u8e9WbWYMUBM3JUehoIsvxjvN2H0BcPaZjt8YQ?= =?us-ascii?Q?JfEABpl3bnWMPxsnuXXgw/vNdh8oQ4nOi+5aqB2kgFtygqIEhVXDqbiYkXP7?= =?us-ascii?Q?HEY+BthNaz98sySkoX5uTXU9LmyfXUbCJrJ1jaWHYbWlzz3GMBrcPiPm7j3f?= =?us-ascii?Q?zNTPK/YEjj6g+h9flms3WPl3vBAL7c2TWGwnwP35jMOmhYnFd2IlqPZnEpf5?= =?us-ascii?Q?HBtNzcybB6b5U6j2EvtSJUNLxIdRWT00Q9wWCKHqtTsf1LCPrCy9Z0fOwXBE?= =?us-ascii?Q?9PCQY9107SX1gNW9LPSwMDyPT2LXRxo+hpTc2IbTQp7noZtnnIOYt2DYfkUr?= =?us-ascii?Q?xHK2FKDREofYKh1igLdaye7gB2o5wzZi3V5cACJ75QlXYGtHt8MMLIzyVNZT?= =?us-ascii?Q?48UvC85Rdxx+7iQu5NyjRWLBsm+pVdhSySYpNH6ekm0cPV46N/p7ShAzWHJv?= =?us-ascii?Q?8yeG8Eb9/bXO1jU+Nu1xYog8T4DVbVd7EP2MlHrwgwTHEtzKvji0/vYgwJcx?= =?us-ascii?Q?2H+aB+Km00f2Ke+MaNshnkS6yZQ9DfznKv4nzceyMenceDU03jt5/0sSAjlZ?= =?us-ascii?Q?X4995eUCDdfGjP8DeBTsQVvDKjfG7uR2xwfB2h2i05ZrT6UleXjYlMcCFAVw?= =?us-ascii?Q?lththN6mlF6O+2jBoZTdg2HzNG2mEupQmgN0zLG7Rr9pEJJ7dkfUswMuy/9Q?= =?us-ascii?Q?NxcvNh28EpKYf7uDEe6v577MSqlwdcnVrn/6iRdZ7He4A=3D=3D?= X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;MWHPR03MB2829;6:OU6f1Sg7wTS0/JXrIpfVEcOfDpVUqquGgDSI/AVYC+?= =?us-ascii?Q?GvX4jBq96y2ceQReGF9/qJ88SZx3gmDreJU4WS8Ic4QBkZaK2dMm8Mmaptrw?= =?us-ascii?Q?48+Hg1yjTPZBODqS6F9UJYqVeMI80S6pNgnT+XtIohN1GVK6CHAqbodQrrXh?= =?us-ascii?Q?rRtBpag0HnsiY/HB5vf4NO4HaR77XjxTMVBcV5wQNEmhfn+HoxOYQrE2dbdY?= =?us-ascii?Q?Bu4P73+p3dFIPzoTUO8TzZu2PItba7860Mdr+2gxcT8MGT2rj6w7uKS7wMjg?= =?us-ascii?Q?4nmwgcLwdoXsmUUrPlP1IopMDKyFrTZ/9Z3hdqoCULTB99DotEjHKj4ibbDQ?= =?us-ascii?Q?c8HclxYeDsrZXRP3xJKToGq24oXh5EkCIg89MRHazRMSoX0AET3ueBay5xBz?= =?us-ascii?Q?iujRDGjlZjOMPP6rb+6dHlCi57pVnM7vthu+np6s3XS2Q0P2HwabZ9Ydrul7?= =?us-ascii?Q?qa8QxwxzlIztjzOzw8pVSNxrOePOCqNmm0xejbZrnTVivViUsR4f1fbh3XQ5?= =?us-ascii?Q?wW53lHqkJgk3UGajFfnaTHxB4UNSEbRyksyGWkZMAk6OzhTeb02rxMy/Jq29?= =?us-ascii?Q?GcqzR3Rq0eCUDFUnxvAivLKoLaafxSx8LdaETidsDnQuMPHy/Tgpiai7e4fk?= =?us-ascii?Q?H+ojsdHRkMHb3W1oH8rcvl2+COnTtZYgGHFoXedF0R6AvX6evGrMFNPcrnX1?= =?us-ascii?Q?jGwpCCrw8qUvmeNYGo8DRxZ6MhGoT8SB31R2lQGyUtaattbp7uz9/oC6tZlp?= =?us-ascii?Q?A7bNywHri2iZLjkFMOAUGJIi4t5eb/dafDf85AAMLbmmefwBr1nfnScSy8xw?= =?us-ascii?Q?WJzVllADWE+xIsm1TGwYTGdsPI4CaDmfQI50Hr+78gOIFjjIjfN4mwPgrYqy?= =?us-ascii?Q?Po5NrVxcL4IZhBb6uh1PUZwOcLKPBvF2WNHNGX8wp0sbVwsbhw0x9YXJhyRi?= =?us-ascii?Q?4XkCiM0QfGTZCycD31c9Bvr8owAr65iUBbsM2uUHPAUnBt9iDAqSbenw+n+K?= =?us-ascii?Q?pQ6Fb+MZoXNWLEyK+k5TPQ?= X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB2829;5:X5SDB7RemzCzDs9eKO0yj8OsH/PpskppsGdReyhYslF0JoQdnaT7vbCC0r7yoSHOVsWG6yuVbPXMot8HMwDfTUoDf45nYv3ejkxktLn1CG3gycGGeZ32esnyK6MUBZk07mm4AAN0AZkwbWdzG7BLoggnqYnBT0pwx3dalIM79MdXnT7GjIpo/RdHDo79AXIaUk+G5SbKs3xOaIlroKt7wD+6QjA6meTmD8zVquyX716uBna5g+4iU93G7m/KVn7LEfCMKrUvbzCK/pCSZR8wSrXFWehE6Oa/tma6JJjUIi0xRiAhMQz3SNJw+te02Req+u2XKVIYzIUgpI3o9z81o9UQt7HYZHk3Du193DTxpyzkqSrQR/M2s65E1Bh3Rt3dh8/CDI5LOs/TmMFwWq/e1IACyjb6SgWr7ys7okYKbLZadlXCyLM10Sd/cabIdCxjKXVTSSalK5/9C5fhsh4L8zPuItnuhY6GeFsXoyt14XFUwWrp54AwvJlu4Z1snnC5;24:B/C2kRHmB9iYvhSXLhZXvY37DsR6j2TdSMdwYZ6Q4PnJ4D4kUq7cEhASkRAoGhcsZPKKV2/ANnO5XBMIxnA9xD2g0L3BAmCjigp1Phpr0Gs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB2829;7:cKpbHA7y2LJwInGNjEt+CyjPMV1JQRR6UF4L2Ql7g7m8sNd+9V09S5QN8DSHPLLj71+ghY9zMwenFtDpBHHrM+D00PeJCyt8KmxTIQuwfV04Ykwi8sGXM8gESuBc9ZxKH5z+XKl8y3aHaNs+Wf8/KDZI7u/mQj5a0evO+KvVsHx1asf7CWdASHLiQGAxB6zHsSfynKJ7OuIVy+BKea6XtbRFxZs0hymvrG6smC0S67hdS9WBLXrPAcxhMTdkgNhrm+lvRjlrol1u6CFOzJDcizB6VUXAKdYPT2V8qfSUrlQ97kjq50j0ng0Bw55jKF9atqv177KR0T3wyiAzq3rnIt9OESUZTpkaVCfbErfcWRn82uf0vHbGfuO4MYfM4cDsPNe5kWfh5ftIatSjHHMX+/lapvifvSalR690/DEGmVqa4igfEUPTVtcC8Q2JnOrUpYVB+TGMVvltwbiBAD4cWjRIgxHtkmhhlSjJTFZxM/Tr2nIIAh4El6PpKT6CBQd8rqob6j93sXMY4ttTwwKIvJUIo1VLy1Jr/V818GtSjESyAJ9jUcw+FnaFKZctZsPJtrxHvXdXgA/EUh2GTyQmYIbnzkG1aNuY0oXlZ+bM8zeC6PtktY79GiiPuIWALJ3kCiN43d5BLTuaBGjEO9i4w6FmnLF4MZr0kAI/q+WBvCfQU2YI7fw0HmdzyXM1z5v29lJOgtk+URsTdZN+jUU6f/p6ElBweFD8f3yaagDdnmZQhrD2G4d3Vy8h72Qzuk7V+4er0yMnlPKQycsSUKofdJfMt6g11UKmrKYliuBNWHQ= X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2017 16:07:46.1468 (UTC) X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta4.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR03MB2829 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5684 Lines: 163 The only difference between the already supported LTC2943 and LTC2944 is the operating range (3.6V - 20V compared to 3.6V - 60V). Signed-off-by: Dragos Bogdan --- Changes in v2: - Fix the voltage and current conversion. .../devicetree/bindings/power/supply/ltc2941.txt | 10 ++--- drivers/power/supply/ltc2941-battery-gauge.c | 46 +++++++++++++++++----- 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/Documentation/devicetree/bindings/power/supply/ltc2941.txt b/Documentation/devicetree/bindings/power/supply/ltc2941.txt index a9d7aa60558b..ed0f02846d10 100644 --- a/Documentation/devicetree/bindings/power/supply/ltc2941.txt +++ b/Documentation/devicetree/bindings/power/supply/ltc2941.txt @@ -1,9 +1,9 @@ -binding for LTC2941 and LTC2943 battery gauges +binding for LTC2941, LTC2943 and LTC2944 battery gauges -Both the LTC2941 and LTC2943 measure battery capacity. -The LTC2943 is compatible with the LTC2941, it adds voltage and -temperature monitoring, and uses a slightly different conversion -formula for the charge counter. +All the LTC2941, LTC2943 and LTC2944 measure battery capacity. +The LTC2943 and LTC2944 are compatible with the LTC2941, they add voltage and +temperature monitoring, and use a slightly different conversion formula for the +charge counter. Required properties: - compatible: Should contain "lltc,ltc2941" or "lltc,ltc2943" which also diff --git a/drivers/power/supply/ltc2941-battery-gauge.c b/drivers/power/supply/ltc2941-battery-gauge.c index 7efb908f4451..4c979b1a022b 100644 --- a/drivers/power/supply/ltc2941-battery-gauge.c +++ b/drivers/power/supply/ltc2941-battery-gauge.c @@ -1,5 +1,5 @@ /* - * I2C client/driver for the Linear Technology LTC2941 and LTC2943 + * I2C client/driver for the Linear Technology LTC2941, LTC2943 and LTC2944 * Battery Gas Gauge IC * * Copyright (C) 2014 Topic Embedded Systems @@ -57,6 +57,12 @@ enum ltc294x_reg { #define LTC2941_NUM_REGS 0x08 #define LTC2943_NUM_REGS 0x18 +enum ltc294x_id { + LTC2941_ID, + LTC2943_ID, + LTC2944_ID, +}; + struct ltc294x_info { struct i2c_client *client; /* I2C Client pointer */ struct power_supply *supply; /* Supply pointer */ @@ -66,6 +72,7 @@ struct ltc294x_info { int charge; /* Last charge register content */ int r_sense; /* mOhm */ int Qlsb; /* nAh */ + enum ltc294x_id id; }; static inline int convert_bin_to_uAh( @@ -145,7 +152,7 @@ static int ltc294x_reset(const struct ltc294x_info *info, int prescaler_exp) control = LTC294X_REG_CONTROL_PRESCALER_SET(prescaler_exp) | LTC294X_REG_CONTROL_ALCC_CONFIG_DISABLED; - /* Put the 2943 into "monitor" mode, so it measures every 10 sec */ + /* Put the 2943/4 into "monitor" mode, so it measures every 10 sec */ if (info->num_regs == LTC2943_NUM_REGS) control |= LTC2943_REG_CONTROL_MODE_SCAN; @@ -248,11 +255,16 @@ static int ltc294x_get_voltage(const struct ltc294x_info *info, int *val) int ret; u8 datar[2]; u32 value; + u32 full_scale; ret = ltc294x_read_regs(info->client, LTC294X_REG_VOLTAGE_MSB, &datar[0], 2); value = (datar[0] << 8) | datar[1]; - *val = ((value * 23600) / 0xFFFF) * 1000; /* in uV */ + if (info->id == LTC2944_ID) + full_scale = 70800; + else + full_scale = 23600; + *val = ((value * full_scale) / 0xFFFF) * 1000; /* in uV */ return ret; } @@ -261,15 +273,20 @@ static int ltc294x_get_current(const struct ltc294x_info *info, int *val) int ret; u8 datar[2]; s32 value; + u32 full_scale; ret = ltc294x_read_regs(info->client, LTC294X_REG_CURRENT_MSB, &datar[0], 2); value = (datar[0] << 8) | datar[1]; value -= 0x7FFF; + if (info->id == LTC2944_ID) + full_scale = 64000; + else + full_scale = 60000; /* Value is in range -32k..+32k, r_sense is usually 10..50 mOhm, * the formula below keeps everything in s32 range while preserving * enough digits */ - *val = 1000 * ((60000 * value) / (info->r_sense * 0x7FFF)); /* in uA */ + *val = 1000 * ((full_scale * value) / (info->r_sense * 0x7FFF)); /* in uA */ return ret; } @@ -388,7 +405,11 @@ static int ltc294x_i2c_probe(struct i2c_client *client, np = of_node_get(client->dev.of_node); - info->num_regs = (unsigned long)of_device_get_match_data(&client->dev); + info->id = (enum ltc294x_id)of_device_get_match_data(&client->dev); + if (info->id == LTC2941_ID) + info->num_regs = LTC2941_NUM_REGS; + else + info->num_regs = LTC2943_NUM_REGS; info->supply_desc.name = np->name; /* r_sense can be negative, when sense+ is connected to the battery @@ -492,8 +513,9 @@ static SIMPLE_DEV_PM_OPS(ltc294x_pm_ops, ltc294x_suspend, ltc294x_resume); static const struct i2c_device_id ltc294x_i2c_id[] = { - {"ltc2941", LTC2941_NUM_REGS}, - {"ltc2943", LTC2943_NUM_REGS}, + {"ltc2941", LTC2941_ID}, + {"ltc2943", LTC2943_ID}, + {"ltc2944", LTC2944_ID}, { }, }; MODULE_DEVICE_TABLE(i2c, ltc294x_i2c_id); @@ -501,11 +523,15 @@ MODULE_DEVICE_TABLE(i2c, ltc294x_i2c_id); static const struct of_device_id ltc294x_i2c_of_match[] = { { .compatible = "lltc,ltc2941", - .data = (void *)LTC2941_NUM_REGS + .data = (void *)LTC2941_ID }, { .compatible = "lltc,ltc2943", - .data = (void *)LTC2943_NUM_REGS + .data = (void *)LTC2943_ID + }, + { + .compatible = "lltc,ltc2944", + .data = (void *)LTC2944_ID }, { }, }; @@ -525,5 +551,5 @@ module_i2c_driver(ltc294x_driver); MODULE_AUTHOR("Auryn Verwegen, Topic Embedded Systems"); MODULE_AUTHOR("Mike Looijmans, Topic Embedded Products"); -MODULE_DESCRIPTION("LTC2941/LTC2943 Battery Gas Gauge IC driver"); +MODULE_DESCRIPTION("LTC2941/LTC2943/LTC2944 Battery Gas Gauge IC driver"); MODULE_LICENSE("GPL"); -- 2.11.0