From patchwork Mon May 4 22:12:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Bakker X-Patchwork-Id: 11527665 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B618417EF for ; Mon, 4 May 2020 22:13:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A775C208DB for ; Mon, 4 May 2020 22:13:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728134AbgEDWNd (ORCPT ); Mon, 4 May 2020 18:13:33 -0400 Received: from mail-bn8nam11olkn2099.outbound.protection.outlook.com ([40.92.20.99]:30491 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726453AbgEDWNb (ORCPT ); Mon, 4 May 2020 18:13:31 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XLkkTj5NYw+b44s+2NrmGjlbnkoxH1lQ+6QZOdSHXmdLedGFHH809QlWcrG0kB7IIkiuAMAmKPVtdrsJrrt5kkmK+wT7yLJWGTw9rvfhoGhuvo0W92jD5RUh+VMWpbp0g3zQFa3fO09vWKMUhBZZ3zpe19Mi86EpuHLQjFlZXb6FM/RdPA700rQ2CiRohYz6fnHLenxAhOqaJiPlcRVd8HJQg5nSxrtgeVLRFk4ORJQrv/6/qZVM/tEVq63aaX1GZtC2PsJSoZFpjcMI5veqZ3fVmA5A9wNpMUhUZXjmhC/M5PiJNF3wgzfENcNCoQws0EVqeFqMjZ/+OSLFvdq19A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BjDFX7OxNYJ9dpDXgqdBWyfSjC9THLPC31mAGrV8EBQ=; b=MPEava+oJlmFDR3CuUuGyQwLDLDrVHAg5dixdxswBjQQMTqOUFqXTTe+mVreqikvfXvenIT5ey1ki2wr9LqmlbP552nJRGzJBjGWDvY3UwzDu6oMeG0gg+CYPedgjp+V1AkJ+X5D98ekdQoatUWZKP2e/TLD7NpwDlaZCLDr2IXfvkaerdEcw0xUQEqW9aPPgYC4hhHsoXTXU9IPkpsGO05Me7OZ6Q/USOCpPP0lAAv99dgUA9bOC3RzDbfBCWRR+MInnHysVMLZ3uN5S9tRuVwl0SHxs6TsYVB00S4JOt7jtP15VLHIh96uKp1JTExDFiSaL/WpyvxiLS3J9x+cvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=live.ca; dmarc=pass action=none header.from=live.ca; dkim=pass header.d=live.ca; arc=none Received: from BN8NAM11FT010.eop-nam11.prod.protection.outlook.com (2a01:111:e400:fc4b::4f) by BN8NAM11HT099.eop-nam11.prod.protection.outlook.com (2a01:111:e400:fc4b::262) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.19; Mon, 4 May 2020 22:13:28 +0000 Received: from BN6PR04MB0660.namprd04.prod.outlook.com (2a01:111:e400:fc4b::4d) by BN8NAM11FT010.mail.protection.outlook.com (2a01:111:e400:fc4b::309) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.19 via Frontend Transport; Mon, 4 May 2020 22:13:28 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:4D6007E31AEF8A9A2185AD085CBE1BF1311FF5835FD22518BC136F0631633D72;UpperCasedChecksum:545C498EF5A43E31BE380659542A3C8ABE875CC7C552718776E03615079AEE01;SizeAsReceived:7766;Count:50 Received: from BN6PR04MB0660.namprd04.prod.outlook.com ([fe80::ad10:4127:4bc8:76fc]) by BN6PR04MB0660.namprd04.prod.outlook.com ([fe80::ad10:4127:4bc8:76fc%6]) with mapi id 15.20.2958.029; Mon, 4 May 2020 22:13:28 +0000 From: Jonathan Bakker To: sre@kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, devicetree@vger.kernel.org Cc: Jonathan Bakker Subject: [PATCH 1/3] power: supply: max17040: Correct voltage reading Date: Mon, 4 May 2020 15:12:58 -0700 Message-ID: X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200504221300.3153-1-xc-racer2@live.ca> References: <20200504221300.3153-1-xc-racer2@live.ca> X-ClientProxiedBy: MWHPR2201CA0053.namprd22.prod.outlook.com (2603:10b6:301:16::27) To BN6PR04MB0660.namprd04.prod.outlook.com (2603:10b6:404:d9::21) X-Microsoft-Original-Message-ID: <20200504221300.3153-2-xc-racer2@live.ca> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from jon-hp-6570b.telus (2001:569:fb68:9c00:8067:f823:1e15:7520) by MWHPR2201CA0053.namprd22.prod.outlook.com (2603:10b6:301:16::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.19 via Frontend Transport; Mon, 4 May 2020 22:13:27 +0000 X-Mailer: git-send-email 2.20.1 X-Microsoft-Original-Message-ID: <20200504221300.3153-2-xc-racer2@live.ca> X-TMN: [WGkTflbsxw0dIwykn+04DaBhHAOY46l/NDMLDEEmKCkkfbLBdRzuVm1RbH/sVrrJ] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 4f4f15c5-7f67-4772-7a70-08d7f0785f58 X-MS-TrafficTypeDiagnostic: BN8NAM11HT099: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WmgzQyya2HdaYfIWzTL22N+4XlkssgRFFCLVrjnyXkHeNLpVM/wHwgxs4fG/POcbg58xEKK/LJWq7XUH9lATyK6VE9nixBJjgWRwxY6WF30vpQCbj6MXu2kl62RiOcIuQfXyUUKZjpnP4/dAMslH//EzjP1ONyRMF1I2C2EaMfACi1Hi6gVFRRlAqvfioPI8WtKYqpy7Uez7Gag0zOO0pYBgrMsZNt7DciWGmru8ss+e1nFikwD3vdWZzgRduLWM X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:0;SRV:;IPV:NLI;SFV:NSPM;H:BN6PR04MB0660.namprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:;DIR:OUT;SFP:1901; X-MS-Exchange-AntiSpam-MessageData: mJjyCY6y9xvwNd52CklzFcJ+/oJcFHZzo6/7HCNkh/ruPPUIBD7s9dPcVSGm+VZ5LrMjT5UdJOxWvChAV9r96fo93iNg1sst2TDepgu5eAsNxLHEB4pQj68YfC3yeci9bLt1tW7qwciXSZ3lq7JW0ivyMp/rXfqDev2jouj7ts4mgye1qFZ9O7Rvh3U9h6dt1knCu8LPkNeGU2r+hAlR0g== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4f4f15c5-7f67-4772-7a70-08d7f0785f58 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2020 22:13:28.7288 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8NAM11HT099 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org According to the datasheet available at (1), the bottom four bits are always zero and the actual voltage is 1.25x this value in mV. Since the kernel API specifies that voltages should be in uV, it should report 1250x the shifted value. 1) https://datasheets.maximintegrated.com/en/ds/MAX17040-MAX17041.pdf Signed-off-by: Jonathan Bakker --- drivers/power/supply/max17040_battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c index 8a1f0ee493aa..48aa44665e2f 100644 --- a/drivers/power/supply/max17040_battery.c +++ b/drivers/power/supply/max17040_battery.c @@ -126,7 +126,7 @@ static void max17040_get_vcell(struct i2c_client *client) vcell = max17040_read_reg(client, MAX17040_VCELL); - chip->vcell = vcell; + chip->vcell = (vcell >> 4) * 1250; } static void max17040_get_soc(struct i2c_client *client) From patchwork Mon May 4 22:12:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Bakker X-Patchwork-Id: 11527669 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 08AC681 for ; Mon, 4 May 2020 22:13:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF17C2078C for ; Mon, 4 May 2020 22:13:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728200AbgEDWNe (ORCPT ); Mon, 4 May 2020 18:13:34 -0400 Received: from mail-bn8nam11olkn2023.outbound.protection.outlook.com ([40.92.20.23]:11744 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726433AbgEDWNd (ORCPT ); Mon, 4 May 2020 18:13:33 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O7KJxVNphkxGpLTH/XU1bCG4MmBFuUo+YCk4WD51UrqPzVsxTAqCpbX0PVs4Sq4U6Kbc/bVDQIr16YkfyquhkhGnSQsYDgFDv8EP2Pi1TYUE0GoUDz23W3PWCE1waWFj6+jNbTaBMgT1cIJKgz8Da5/oJxsoQroiLJ9suD0MhaPOrKwQxkwegCUxutVcvNE5GIYLEdeEtkNfAM6+AhkTpKibOB7kjBnLEUWfYwM7KtozVRCz64TNwHxvaxGsH+DaR6Des+/ZcANJ6uWCr5vmmFGQe0YSkOBrpFkB5NHMmo2tlgRyavRds/WKIYR/dYpHJMVGgvzI0NfvVNVV3wyscg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IQlQFEkFCJP5s3LXh0PpwXlPhoi+wfKHEygXgJ+LySc=; b=Xs+Oikki7xASG13zGdQUJ7wcpDMsqcG9Qld02DL2AKrmQgZRVeEgK/jk1/vvLBAeM0mSLnI7W4QI27pUsuEbmmQUh1EMn2z+XrG1A7vReigb34ZW3Eyp8XUY9kqegWuMiRzlG6yDhC3MFdtjRDYXjeKY0naisOQchsIDSkgiKq1JfAIs74gXg/eOU248CwjLGKgOMY1rych+aPJlrSv+jygFW8w7OHqGfU89+yhf/gZQQ2k0PNfO4x8b/Y0kRgDsxD5L2zNdoQ02WFPGH8nNJ5eKpOoJTvKFu5KcyPWtYxkrYqReBWotcRxqESk/g9LtOJFWPrxS7N2bmsFSE4GpVw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=live.ca; dmarc=pass action=none header.from=live.ca; dkim=pass header.d=live.ca; arc=none Received: from BN8NAM11FT010.eop-nam11.prod.protection.outlook.com (2a01:111:e400:fc4b::4b) by BN8NAM11HT173.eop-nam11.prod.protection.outlook.com (2a01:111:e400:fc4b::385) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.19; Mon, 4 May 2020 22:13:30 +0000 Received: from BN6PR04MB0660.namprd04.prod.outlook.com (2a01:111:e400:fc4b::4d) by BN8NAM11FT010.mail.protection.outlook.com (2a01:111:e400:fc4b::309) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.19 via Frontend Transport; Mon, 4 May 2020 22:13:30 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:E3D82FCFBB480C77A928FC454D34593C1A7BDC516AEAEC1E884C2FC111877AA0;UpperCasedChecksum:E0146A7F0D2AECC0D278F856D9BC41B9739485A62C1581A349D7FCB67CE2BF0A;SizeAsReceived:7786;Count:50 Received: from BN6PR04MB0660.namprd04.prod.outlook.com ([fe80::ad10:4127:4bc8:76fc]) by BN6PR04MB0660.namprd04.prod.outlook.com ([fe80::ad10:4127:4bc8:76fc%6]) with mapi id 15.20.2958.029; Mon, 4 May 2020 22:13:30 +0000 From: Jonathan Bakker To: sre@kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, devicetree@vger.kernel.org Cc: Jonathan Bakker Subject: [PATCH 2/3] dt-bindings: power: supply: Document maxim,rcomp-value for max17040 Date: Mon, 4 May 2020 15:12:59 -0700 Message-ID: X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200504221300.3153-1-xc-racer2@live.ca> References: <20200504221300.3153-1-xc-racer2@live.ca> X-ClientProxiedBy: MWHPR2201CA0053.namprd22.prod.outlook.com (2603:10b6:301:16::27) To BN6PR04MB0660.namprd04.prod.outlook.com (2603:10b6:404:d9::21) X-Microsoft-Original-Message-ID: <20200504221300.3153-3-xc-racer2@live.ca> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from jon-hp-6570b.telus (2001:569:fb68:9c00:8067:f823:1e15:7520) by MWHPR2201CA0053.namprd22.prod.outlook.com (2603:10b6:301:16::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.19 via Frontend Transport; Mon, 4 May 2020 22:13:29 +0000 X-Mailer: git-send-email 2.20.1 X-Microsoft-Original-Message-ID: <20200504221300.3153-3-xc-racer2@live.ca> X-TMN: [WfGrgOUezFu0vC/W30ev1tWlInh3FoVZJ91iGfU0xFXxzpVcrC12z2QEsvNAYwPB] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: fc416014-dec5-43da-5c94-08d7f078603a X-MS-TrafficTypeDiagnostic: BN8NAM11HT173: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B/c+YeRTZ8DNcMHtecsCCrHyRiHs07igOUWEblDdQYqJ4Myrhe3lEOOk+NsNekfKlmyJTC0B44YxNAA/ivqzNnRsAhYg41rDp14HGaDvrCg3x2VqQlbL/mDg/TAhmbQePHDu7tpUz73d0q67E1g3KilQEN6IIZV21Y60xZgQChyuttp5PP66YrVPxhOg7iFI7SQbvkgJrn0guEx9LRsL7g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:0;SRV:;IPV:NLI;SFV:NSPM;H:BN6PR04MB0660.namprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:;DIR:OUT;SFP:1901; X-MS-Exchange-AntiSpam-MessageData: 9GFcBm5oAq1K5MFL55SVtPcCgEx7WYTg1j4ni2/0jH0j2bHWhlTQywWofqn+XPNx/2J9ffc74S0ZDKTZiTlO+JCxufvWZoXAnhMDuleO8ifYcLTUXipAinCe+hvzXFP5BixLurBxsgq2UPKqV4dQmMGVG6sDTAWEyCBzQtop6B3JfvyWtQx4A6QH5FcsLPVBV1DaZhHDmVgiP9c6pW5Fug== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: fc416014-dec5-43da-5c94-08d7f078603a X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2020 22:13:30.2631 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8NAM11HT173 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The rcomp value is a device-specific value for configuration based on specific chemistries. There is no public documentation on how to tune it. Signed-off-by: Jonathan Bakker Acked-by: Rob Herring --- .../devicetree/bindings/power/supply/max17040_battery.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/power/supply/max17040_battery.txt b/Documentation/devicetree/bindings/power/supply/max17040_battery.txt index 4e0186b8380f..14097b3ed278 100644 --- a/Documentation/devicetree/bindings/power/supply/max17040_battery.txt +++ b/Documentation/devicetree/bindings/power/supply/max17040_battery.txt @@ -11,6 +11,9 @@ Optional properties : generated. Can be configured from 1 up to 32 (%). If skipped the power up default value of 4 (%) will be used. +- maxim,rcomp-value : The value for specific lithium chemistry. If + not present, the default value of 0x97 will be + used. - interrupts : Interrupt line see Documentation/devicetree/ bindings/interrupt-controller/interrupts.txt - wakeup-source : This device has wakeup capabilities. Use this From patchwork Mon May 4 22:13:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Bakker X-Patchwork-Id: 11527667 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1086D17E8 for ; Mon, 4 May 2020 22:13:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F0B8B2078C for ; Mon, 4 May 2020 22:13:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728223AbgEDWNg (ORCPT ); Mon, 4 May 2020 18:13:36 -0400 Received: from mail-bn8nam11olkn2047.outbound.protection.outlook.com ([40.92.20.47]:17633 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728202AbgEDWNf (ORCPT ); Mon, 4 May 2020 18:13:35 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aZriF2GZk2BlwHCcwHeKv40eCG51RJChU6NoAnMob0wYXUdH0gGdiuHCv02PK2l2E2ZCPq8JkRAhJ1z3EK9JZK1f98W1sJURvzZKle/YjnZ+7ennvXvd8LR2rzCa+ak1foSBliiZmsfG4kPKz0pU5/6UxXspJer36IUgmlQXQ8hGxSqUDYqDd6pv/zusbvNkUBeCaaYgupepKsS/yEwV3mV9l6wQQX2C1yPSBLAryvugpHIxL/Ddr4r8laTsEnEFzcvEnkL06zTHtYc/9acAo32U06aL9s7VMZLcZ8qbR2/imRWoan5mnS61SLShvtQKW5IA1OAzPtBar/ba8XovJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0SrpbefCRfEjV8iCNrMUH8buPaWQxavRgC+FU0Fe/0U=; b=d1b/p/6Ta90hYUUHd421gI6BHzQ/u09/th1xOrKMZO8omNy6Uzox8+ivw9sn93uqajGnmQFhthMR1dKx5Ebcr740RLZ17AKKp9mo8kCVE8odGDp1tgdhmQMZU2LY8X2yOcJDhlZfEGwwp+mGBbte8UT/oxW5i+n+oRIFkgzVBWpE8ZV+fFKWlziXZI5HZ9HNWVXUEzHU2WoIxNOeWObNBab1k3HGek+cOOEPPvDMk7BFwbmr3yaKsTdai6j7tN6lu9eORGH52I7Z8zquN0O0+LkS10vTAe7qzoVK70PGtyBtmsUIG1VyUDmp1pCadOp7uIlclBFb3VAHn1czQndoXg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=live.ca; dmarc=pass action=none header.from=live.ca; dkim=pass header.d=live.ca; arc=none Received: from BN8NAM11FT010.eop-nam11.prod.protection.outlook.com (2a01:111:e400:fc4b::40) by BN8NAM11HT024.eop-nam11.prod.protection.outlook.com (2a01:111:e400:fc4b::194) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.19; Mon, 4 May 2020 22:13:31 +0000 Received: from BN6PR04MB0660.namprd04.prod.outlook.com (2a01:111:e400:fc4b::4d) by BN8NAM11FT010.mail.protection.outlook.com (2a01:111:e400:fc4b::309) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.19 via Frontend Transport; Mon, 4 May 2020 22:13:31 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:C4ED0778683EEC4312A8066D6998C8158858CDF1521D03DE303DEF954BE741C4;UpperCasedChecksum:B36B717E36E5C63444A31DF994CA95C786BD1BDC40255040C3BC9BAC164B2B47;SizeAsReceived:7758;Count:50 Received: from BN6PR04MB0660.namprd04.prod.outlook.com ([fe80::ad10:4127:4bc8:76fc]) by BN6PR04MB0660.namprd04.prod.outlook.com ([fe80::ad10:4127:4bc8:76fc%6]) with mapi id 15.20.2958.029; Mon, 4 May 2020 22:13:31 +0000 From: Jonathan Bakker To: sre@kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, devicetree@vger.kernel.org Cc: Jonathan Bakker Subject: [PATCH 3/3] power: supply: max17040: Set rcomp value Date: Mon, 4 May 2020 15:13:00 -0700 Message-ID: X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200504221300.3153-1-xc-racer2@live.ca> References: <20200504221300.3153-1-xc-racer2@live.ca> X-ClientProxiedBy: MWHPR2201CA0053.namprd22.prod.outlook.com (2603:10b6:301:16::27) To BN6PR04MB0660.namprd04.prod.outlook.com (2603:10b6:404:d9::21) X-Microsoft-Original-Message-ID: <20200504221300.3153-4-xc-racer2@live.ca> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from jon-hp-6570b.telus (2001:569:fb68:9c00:8067:f823:1e15:7520) by MWHPR2201CA0053.namprd22.prod.outlook.com (2603:10b6:301:16::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.19 via Frontend Transport; Mon, 4 May 2020 22:13:30 +0000 X-Mailer: git-send-email 2.20.1 X-Microsoft-Original-Message-ID: <20200504221300.3153-4-xc-racer2@live.ca> X-TMN: [KPXs7hi3OI0qzQkXUSboa9ggWN8isMFJInOlAPO9Hda/k0eObCDUSvcNS1hPkGEV] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: e86124e9-0d75-4e3b-c0c9-08d7f078611f X-MS-TrafficTypeDiagnostic: BN8NAM11HT024: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7l7qdfru6v/RME/CFdETyKAW4IqQ2vacxmFVLHGjhA4NT9U5fZKMqijA1lO/a0PpHtpaHVvYTYfGnRVAifvT1aAmxgbSGxbc95y//DGTAlXlptiGpHF69O8OdrVILbIxIvhYvIx9lhO4SKnasVsRd/CmwjiLLD0IhIjhquQ8ItOAwjFLJO7hXJ4hVsOKjcoT+6MLdipzc+m2lcnPTJ4JytYa4UtZ4JXyCSO3O1NEEZjUiV4WvCAhEY9HfVDJDqUg X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:0;SRV:;IPV:NLI;SFV:NSPM;H:BN6PR04MB0660.namprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:;DIR:OUT;SFP:1901; X-MS-Exchange-AntiSpam-MessageData: QZ0qL2uX4cnkVDH1EgjDNfnZ+YpdIXGSsuH1u6anzpQ2MdIqVccvzbiwVtZ5XszSsr5kkUHE/+ix9ckMxZD1Yhann1K81V6X8e0GmjXkwB31lOkGDzGxiOxSem03Zclgm4joa9kzgv2Jk8o8EvhkTNfj5k2QyenoH9Ny0YhrpVgLnTOXAMMOQA6kWuLNBmP7SxdHrpA2uq5tDJIsaQvfMg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e86124e9-0d75-4e3b-c0c9-08d7f078611f X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2020 22:13:31.5605 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8NAM11HT024 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org According to the datasheet (1), the rcomp parameter can vary based on the typical operating temperature and the battery chemistry. If provided, make sure we set it after we reset the chip on boot. 1) https://datasheets.maximintegrated.com/en/ds/MAX17040-MAX17041.pdf Signed-off-by: Jonathan Bakker --- drivers/power/supply/max17040_battery.c | 33 +++++++++++++++++++++---- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c index 48aa44665e2f..f66e2fdc0a8a 100644 --- a/drivers/power/supply/max17040_battery.c +++ b/drivers/power/supply/max17040_battery.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -31,6 +32,8 @@ #define MAX17040_ATHD_MASK 0xFFC0 #define MAX17040_ATHD_DEFAULT_POWER_UP 4 +#define MAX17040_RCOMP_MASK 0xFF +#define MAX17040_RCOMP_DEFAULT_POWER_UP 0x97 struct max17040_chip { struct i2c_client *client; @@ -48,6 +51,8 @@ struct max17040_chip { int status; /* Low alert threshold from 32% to 1% of the State of Charge */ u32 low_soc_alert; + /* Optimization for specific chemistries */ + u8 rcomp_value; }; static int max17040_get_property(struct power_supply *psy, @@ -119,6 +124,20 @@ static int max17040_set_low_soc_alert(struct i2c_client *client, u32 level) return ret; } +static int max17040_set_rcomp(struct i2c_client *client, u32 val) +{ + int ret; + u16 data; + + data = max17040_read_reg(client, MAX17040_RCOMP); + /* clear the rcomp val and set MSb 8 bits */ + data &= MAX17040_RCOMP_MASK; + data |= val << 8; + ret = max17040_write_reg(client, MAX17040_RCOMP, data); + + return ret; +} + static void max17040_get_vcell(struct i2c_client *client) { struct max17040_chip *chip = i2c_get_clientdata(client); @@ -190,8 +209,14 @@ static int max17040_get_of_data(struct max17040_chip *chip) "maxim,alert-low-soc-level", &chip->low_soc_alert); - if (chip->low_soc_alert <= 0 || chip->low_soc_alert >= 33) + if (chip->low_soc_alert <= 0 || chip->low_soc_alert >= 33) { + dev_err(&client->dev, + "failed: low SOC alert OF data out of bounds\n"); return -EINVAL; + } + + chip->rcomp_value = MAX17040_RCOMP_DEFAULT_POWER_UP; + device_property_read_u8(dev, "maxim,rcomp-value", &chip->rcomp_value); return 0; } @@ -289,11 +314,8 @@ static int max17040_probe(struct i2c_client *client, chip->client = client; chip->pdata = client->dev.platform_data; ret = max17040_get_of_data(chip); - if (ret) { - dev_err(&client->dev, - "failed: low SOC alert OF data out of bounds\n"); + if (ret) return ret; - } i2c_set_clientdata(client, chip); psy_cfg.drv_data = chip; @@ -307,6 +329,7 @@ static int max17040_probe(struct i2c_client *client, max17040_reset(client); max17040_get_version(client); + max17040_set_rcomp(client, chip->rcomp_value); /* check interrupt */ if (client->irq && of_device_is_compatible(client->dev.of_node,