From patchwork Mon Oct 28 07:18:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 177883 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3012643ill; Mon, 28 Oct 2019 00:19:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqxRahRJ7FudOlcByoPdWNz53qgojdFWh7rCnKSJxY5AxaA/WbbO9rsQ2dCqqEVdWUDC9Mkj X-Received: by 2002:a17:906:5c0e:: with SMTP id e14mr15518252ejq.200.1572247197770; Mon, 28 Oct 2019 00:19:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572247197; cv=none; d=google.com; s=arc-20160816; b=0OKFyKoCEwbcfJwcqWU5Rfwegkr52Ui3q91EC4hFSX8q/RA7y/nIaeKCjUGbH+fEIi U/50u7cH0ievpXmlMdrI79ujkuya7uUgXVt05loGu92vjKbZiXGJ2OrqiPmW34FZM54h lU4zQQ/1qCIXT0fhrvOdB5u37IsaCnr5qtcP44qeHumefOoHT4bMqRrSscBXNs0RzSrw 35zKn0sp+ZlqrVNQWToxM4t/KyKMBgRFARcuhdIdFIRYyNwbzt09OcR5+4NyQeDVzSSk X+7yPMKE5lILoNvboPd24ugsjEp8LzYXw4efbdohX3fk49Ui6Fb5TWFSLvL5he8Q4+jl aATQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=ssMFBj43632FcWk2CcxAhFxBDGN9BLK5UqZaapoI3EI=; b=J2Lum9nLZoc8+jdIumFVD26CAYIGk9ytbYaA3s+Jb7YLCXcFAeEklKl4WoYvb6Lm6+ yKge1gwt7Kh7KyNy2qqM16vLoL7g8f9fhNgvByaPPWoGHyYf1oeKtGOTrF5EtPYFH/pE JURbdSf7d5DLLSIKAKR0SLLaE3o+0wEdXaAmXA9CEgMyxH6LzKKMsFls43TKH0v89F9A Sq3Snrvs+jNcohtGL3kUxO1DID3vbd6Fn/vsO7Cmt+xZzd0laaxdEw9bUZPi8P0Z/2Uy cToidvHI6YCpDATAjI8+MX0xjtTO52lSLHX1sdcFDeNaH+eC970/kuD9kalJuct7Zd9K rynA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SrgmiIPW; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r9si5529473eju.251.2019.10.28.00.19.57; Mon, 28 Oct 2019 00:19:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SrgmiIPW; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732503AbfJ1HT4 (ORCPT + 10 others); Mon, 28 Oct 2019 03:19:56 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:39658 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732514AbfJ1HT4 (ORCPT ); Mon, 28 Oct 2019 03:19:56 -0400 Received: by mail-pf1-f194.google.com with SMTP id v4so6284371pff.6 for ; Mon, 28 Oct 2019 00:19:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=ssMFBj43632FcWk2CcxAhFxBDGN9BLK5UqZaapoI3EI=; b=SrgmiIPW0C51iZX8hYKQ2hSUsynSut8k+7kzklaDe3hpral131t906w1kTxvTbV5tI 3AJFcoHHfri+SAsbQwrHOkCumk9s5R6sxf0Lsy79Eu3J5KBusj0Cen9tu0V/2wqWGbOH RETMM4ndBRk1j1in/GGXg8h7nnVqMSf39k7vZ9ymw67v30mM/OouHrZs1i+tJqqJyyOF E3KORbX1/MWIMAzbqYg5QFuWzs2eufjGB9AgaqQiuXq3TcGvlFZyGGOLnDd9ObkzVP+4 sNMQvk6FIeWdhMOwKBK32SKHR1/sO5Itv7GXMlIUpon3uADMjv1Nqvuf//N/tlfER0f+ 1T/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=ssMFBj43632FcWk2CcxAhFxBDGN9BLK5UqZaapoI3EI=; b=WG/4x8SIh1Dl/qjIJpMukFcQKiSLAAEZyEtjOzUdc/5/4IxZAAMkMH523QJ1rha1cO Kb8BhNO6fjnixxi0oweiGcqDWHY/4uCEF2oqCQAclEk3hu/9RfwYd/snXwz23XHkTF6z GZcRYsTk6C+tFanxjnT5D3XdYe2xl/kW5LnTfYTcVY3/uykc4oPjCZVwqcq3ZwMrNV/L /g4GHFT8pTKdFD0yppnk/4fUrxZ8inWgMl6Z6OfUhNUY+ttr/iebxW5AX+x7neJEe5De dEPxBHQZiVaADljJlIaQbO9XvcnF3CWjCGM4o/6At2Jat5Quogu46UWYRnKxZKBYXMxv dsJA== X-Gm-Message-State: APjAAAV+LXmwgOcw0/eodyKG8g2T8OtxQ9OPDCpjchM8u70JRJdeOeAv YZzt7T2ESpbx5hb1Vo1Ogp129Q== X-Received: by 2002:a17:90b:f10:: with SMTP id br16mr20271382pjb.111.1572247194072; Mon, 28 Oct 2019 00:19:54 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id 13sm11504703pgq.72.2019.10.28.00.19.50 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Oct 2019 00:19:53 -0700 (PDT) From: Baolin Wang To: sre@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, yuanjiang.yu@unisoc.com, baolin.wang@linaro.org, baolin.wang7@gmail.com, zhang.lyra@gmail.com, orsonzhai@gmail.com Subject: [PATCH 1/5] dt-bindings: power: Introduce one property to describe the battery resistance with temperature changes Date: Mon, 28 Oct 2019 15:18:57 +0800 Message-Id: <44f0c19510c7317cb4ee6cac54b3adfa81c2d6d0.1572245011.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Since the battery internal resistance can be changed as the temperature changes, thus add one table to describe the battery resistance percent in different temperature to get a accurate battery internal resistance. Signed-off-by: Baolin Wang --- .../devicetree/bindings/power/supply/battery.txt | 5 +++++ 1 file changed, 5 insertions(+) -- 1.7.9.5 diff --git a/Documentation/devicetree/bindings/power/supply/battery.txt b/Documentation/devicetree/bindings/power/supply/battery.txt index 5c913d4c..1a6f951 100644 --- a/Documentation/devicetree/bindings/power/supply/battery.txt +++ b/Documentation/devicetree/bindings/power/supply/battery.txt @@ -35,6 +35,10 @@ Optional Properties: for each of the battery capacity lookup table. The first temperature value specifies the OCV table 0, and the second temperature value specifies the OCV table 1, and so on. + - resistance-temp-table: An array providing the resistance percent and + corresponding temperature in degree Celsius, which is used to look up the + resistance percent according to current temperature to get a accurate + batterty internal resistance. Battery properties are named, where possible, for the corresponding elements in enum power_supply_property, defined in @@ -61,6 +65,7 @@ Example: ocv-capacity-table-0 = <4185000 100>, <4113000 95>, <4066000 90>, ...; ocv-capacity-table-1 = <4200000 100>, <4185000 95>, <4113000 90>, ...; ocv-capacity-table-2 = <4250000 100>, <4200000 95>, <4185000 90>, ...; + resistance-temp-table = <20 100>, <10 90>, <0 80>, <(-10) 60>; }; charger: charger@11 { From patchwork Mon Oct 28 07:19:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 177886 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3012857ill; Mon, 28 Oct 2019 00:20:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqyRsrpdEZz0cQX61l5KCxn2Um9ghx+8AdbtnFaaegIy2C2HhQe1COqiY7ajd91R1hN08w+m X-Received: by 2002:a50:fc0a:: with SMTP id i10mr17790452edr.94.1572247210697; Mon, 28 Oct 2019 00:20:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572247210; cv=none; d=google.com; s=arc-20160816; b=kPpJzXbK/rHZU3ddyKhOE0D5iBGKXdzSyZoMOX7sM6Ul1ZWAbQpCUXIMDyxJu/QKbQ m8Ou8WrQnamVjMbzeb9WeOd6zq0qqtiL+Mr6rBW0ErrFRNYmCzNIQ6q6qi2ISX9MKMe9 m829SR/NvSUMU5nenUUe0W5QQ0oNEaMs4oxsahTxcr6+jGZEghJ2+lgRgqvb0EjFxGEA P9jKEdTh2GRGIGBxptBTztOfECLktBNHTTPowsGv2L4cPaOozutN0lfKj5zJZtxDKr5A c9bSO1fAP+9IYbYtXIQMGKay7KagG/Z84WdCnHUiC7oYkghEh2z1nPMjtSpbQGwtADbV hvjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=zz90kEkSWWg/YORe6tmdX1Bf7ogm6HlTvGcmmgO38JE=; b=cOraADMz6ANsWygGnhRt84R/YQl9zNs72DyBhhgExTci938mfjJC4VBnjrDY3kEFDJ Or/anvlc859q7XoxICFmA7txPDpdGWQn0GXYglcrN9/aLo/tvWoNnMJeevhjAtdz0lKr +qLqAsn2VzdSTckaI6BBk2PhtvEWiHUPKqPKK6XzhA2OnvLwPK10CfKUIXHly8sKTmQ+ Q6Ede/5UvC3MFSZcj6SsmtL7nKoIeIsbutsyAEAM1/RmiyDBRKTTmepydcgC0+eMwCLX 92IpQkx3OqDIr2201Zth3qCyNPLMWUqL4KPwlHpI433vnBulJ2jQAIndl6HZPLYZ/SSb WGPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HD06jgfK; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b29si727894ede.118.2019.10.28.00.20.10; Mon, 28 Oct 2019 00:20:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HD06jgfK; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732617AbfJ1HUJ (ORCPT + 10 others); Mon, 28 Oct 2019 03:20:09 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:37745 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732608AbfJ1HUI (ORCPT ); Mon, 28 Oct 2019 03:20:08 -0400 Received: by mail-pg1-f194.google.com with SMTP id p1so6295829pgi.4 for ; Mon, 28 Oct 2019 00:20:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=zz90kEkSWWg/YORe6tmdX1Bf7ogm6HlTvGcmmgO38JE=; b=HD06jgfKdHaybBrjNDZRaOXNwrZc0W1LGLFB2+ngCxaUP4+gDqrtFqGtDyC7MrXPwX jR87YsTHT2M2QI4PXnUjNQcWD3GGTN5fXlPkFY4Om+Z18tEZqNR4xE6Rw/t6FpVu1QGu C4CwaqrEkr96aBTVgePTF44Rfo0I6mTdcpTHjAmyHzC+uMtjxHKemtjTh1trpesbg5ts PMStpjRNp3jlevLAvILguA+lR4rfm3Fyw0/1hyFx0sMmmFtWlqMbBkcoeIEBdOhPdPgF Oy55yKn1eGz9KjE7kgmfCZbWQ4yljK0mARwq08Hmry7c4eQAktXMsEdZHmNi7z72sPZZ 7CHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=zz90kEkSWWg/YORe6tmdX1Bf7ogm6HlTvGcmmgO38JE=; b=TxJz7ST8oz+GRo/AXHJejAfIXFlR67zwP3l7KCmrHMSu6q7KOkax7q0+ZPFDbg0Ho8 IeYhYtMLG5AlFl0YYzY6ZOUdrMgusVMFcVgZWkr9Tt3hBV6MTkwAYKWqsTA2Vn7dfeX2 bwuHkZlxcFgFmDSDHflc0+5TFWSgU6mfQUUSH96MsS0z2jZBqSUWdLQLG0Kpo8qqxH/h ux3Epb/S0djhgy+u3b+tcCNkHHJabmINLr8HQh3sxkzXbkf3B2IRXDam+qZC8xSjaO51 jwr2Wz+rsxYdz2OfwyN9NCEKpjzUjrqKKHJuNsHIKLFD3ovVaYcFzSlLdWY4UlFuyqy3 jQ2A== X-Gm-Message-State: APjAAAW/q+uU3q5YxQKMw3RwuKKBBgElF24tcviDNPG1CRo0+N6mwNKJ nd1a5j4tq7cEH4huMHt7HfV+8Q== X-Received: by 2002:a17:90a:26c1:: with SMTP id m59mr20848364pje.101.1572247206109; Mon, 28 Oct 2019 00:20:06 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id 13sm11504703pgq.72.2019.10.28.00.20.02 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Oct 2019 00:20:05 -0700 (PDT) From: Baolin Wang To: sre@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, yuanjiang.yu@unisoc.com, baolin.wang@linaro.org, baolin.wang7@gmail.com, zhang.lyra@gmail.com, orsonzhai@gmail.com Subject: [PATCH 4/5] dt-bindings: power: sc27xx: Add a new property to describe the real resistance of coulomb counter chip Date: Mon, 28 Oct 2019 15:19:00 +0800 Message-Id: <00202f739348258555dcc40982c330542ac61863.1572245011.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add a new property to describe the real resistance of coulomb counter chip, which is used to calibrate the accuracy of the coulomb counter chip. Signed-off-by: Baolin Wang --- .../devicetree/bindings/power/supply/sc27xx-fg.txt | 2 ++ 1 file changed, 2 insertions(+) -- 1.7.9.5 diff --git a/Documentation/devicetree/bindings/power/supply/sc27xx-fg.txt b/Documentation/devicetree/bindings/power/supply/sc27xx-fg.txt index 0a5705b..fc042d0 100644 --- a/Documentation/devicetree/bindings/power/supply/sc27xx-fg.txt +++ b/Documentation/devicetree/bindings/power/supply/sc27xx-fg.txt @@ -13,6 +13,7 @@ Required properties: - io-channel-names: Should be "bat-temp" or "charge-vol". - nvmem-cells: A phandle to the calibration cells provided by eFuse device. - nvmem-cell-names: Should be "fgu_calib". +- sprd,calib-resistance: Specify the real resistance of coulomb counter chip in micro Ohms. - monitored-battery: Phandle of battery characteristics devicetree node. See Documentation/devicetree/bindings/power/supply/battery.txt @@ -52,5 +53,6 @@ Example: nvmem-cells = <&fgu_calib>; nvmem-cell-names = "fgu_calib"; monitored-battery = <&bat>; + sprd,calib-resistance = <21500>; }; }; From patchwork Mon Oct 28 07:19:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 177887 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3012974ill; Mon, 28 Oct 2019 00:20:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqyTUjBMvmgqjjmLQeZUdmpEKq+ll+5YyhUZAi2oCMbD13NgDGZNFCElTaAKFzovX7tUuhju X-Received: by 2002:a17:906:5859:: with SMTP id h25mr7422892ejs.2.1572247216254; Mon, 28 Oct 2019 00:20:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572247216; cv=none; d=google.com; s=arc-20160816; b=0p//DNHwHeABrqlwZm3pRsj63H3t4djUlnAaIX9DkMxRFdZ9OwjqRAz6Rr43KYhlGG iApBDycAEGQvnZ56T3/5EkpEVMzKPQ3Y50pn3I68/uKsc2KhyaMcHl/Xn7ajG5BHRchE liT07CU9MQQhKImZxgA74wLmcmphu192jEabQc4nlX+mu2DMbpXld9OWetg6Fv8YzhgZ R0ADVv49RejsHG8UvoGFp4Uu3etQ9NzdboaA/DOf5f6gYFOzhMMtelfntO54aSVk9ZDI 3tN7zdP2CKjuIesivG4Sk5iZ0pEGwBn33hkRrfMH09iVJ4lYPAOsZpLYu21HgKyDGrrC OEAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=HKtGe92TapQ2KIwqzwkswK8RAIuyaGxBvNdNmUU4dN4=; b=GcR8bwrY7SHJqKiQMHux46yXLyzzneMkkzCYvmQr0C2LB+Mt2bAE2aqetrRPPlggbn 9N5q9HS27P1zl22OXFn0+pZSXr2QqctSLP3h7apr0UDpPTTFIVgsk6XWRBR4WHT8may1 f6AmjGl5HLGXehCcY8j8j+2Tc9NUqrerf6Qi42nYQVryzOGBxINzv7WeaRkSZu4KZoNF Q3ZbPq031D0aULOc1cncPXszjO22Iv0J6cU0DabltEw8I8Q1/S8AuQ/LDdnxiqgaxbij F1RkZZrDl+drDiIuPIZXjpjrtyFuaOHSLMrDVuanAz+Yg3VK1a6a5wjKgtpjFNiwURV0 RN1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v6uDInPr; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n14si5136309ejx.354.2019.10.28.00.20.15; Mon, 28 Oct 2019 00:20:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v6uDInPr; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732641AbfJ1HUL (ORCPT + 10 others); Mon, 28 Oct 2019 03:20:11 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:41791 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732605AbfJ1HUK (ORCPT ); Mon, 28 Oct 2019 03:20:10 -0400 Received: by mail-pf1-f196.google.com with SMTP id p26so2148009pfq.8 for ; Mon, 28 Oct 2019 00:20:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=HKtGe92TapQ2KIwqzwkswK8RAIuyaGxBvNdNmUU4dN4=; b=v6uDInPrs2q1qq4SFLLdTjpdDc3eS25cnyOgpZtsm/H1e6dUBVUjCnRTrIW9Je4DLe XqJz6uv+N5YdTtXGCsY5Nwk+YABBQWVqJRGdRpgtWscX0dTeHgTPJbLMsxO2Nn6Hjz3S dbBAmtfdRa2obhR4Db360QfEdyh2kQKCBrXYwvs4DQUeecLSmuAgCNg+8vDcZ+byWbxq kvfNWHa1AXgqxiYlqzAl/rAe0f36GBnVfL8P29Oh6h2SM/31I+Xd91PIcC63SXDmcHIo jZzak31XqYgXmaToPXOP0+62BYK/AyoRWAgahLk4g/uE6jWTpMz8/SETq2QRPAsWDrvB +2AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=HKtGe92TapQ2KIwqzwkswK8RAIuyaGxBvNdNmUU4dN4=; b=OfgSjXDeppjY9teCFBmzVlg/D7ZeZ89kyXWgUYCw3xXnSBnQG5DiNJHmn4Nc5+OTzH CADKamoG9bhnFVbVyaCIzOSjwEPkUgSJ0S2C/INXKjBh7gGcPmpBu/36LaOpbF0GnH6B rnQPdV68MW0IOVfhEnM+JMmdI+egv/r9Oc0haBks/TatXRggoljctLkZ4WxPko46nOng 8y9E7VNRIcHvFSkW1+U00zX1nIWxy5gBLfoIXWcSM9j+hHgQ1WBJ90//YTpLGTAhA32O LyeiHYRbDTQwYr3alyLHrSQCN8gSxas5crI5Ptl17r+RF1NaJziIJv5R6I2SOVtp9scf EX4w== X-Gm-Message-State: APjAAAUvkEBMD6RRjfwDpz7z3S3GuwkIjn2bT7Heb7uYTBjrSj7jyaA2 R9cHIy5xyl8c4eTUmNi9ln3Ipg== X-Received: by 2002:a62:108:: with SMTP id 8mr9220601pfb.53.1572247209947; Mon, 28 Oct 2019 00:20:09 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id 13sm11504703pgq.72.2019.10.28.00.20.06 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Oct 2019 00:20:09 -0700 (PDT) From: Baolin Wang To: sre@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, yuanjiang.yu@unisoc.com, baolin.wang@linaro.org, baolin.wang7@gmail.com, zhang.lyra@gmail.com, orsonzhai@gmail.com Subject: [PATCH 5/5] power: supply: sc27xx: Calibrate the resistance of coulomb counter Date: Mon, 28 Oct 2019 15:19:01 +0800 Message-Id: <9c25e3ab9bdba2914b22cfe7495818740437ef27.1572245011.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org There are some deviations between the real resistance and the ideal resistance of coulomb counter, which will affect the accuracy of the coulomb counter, thus calibrate the real resistance of coulomb counter to improve the accuracy. Signed-off-by: Baolin Wang --- drivers/power/supply/sc27xx_fuel_gauge.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) -- 1.7.9.5 diff --git a/drivers/power/supply/sc27xx_fuel_gauge.c b/drivers/power/supply/sc27xx_fuel_gauge.c index 221b6fb..f363fa7 100644 --- a/drivers/power/supply/sc27xx_fuel_gauge.c +++ b/drivers/power/supply/sc27xx_fuel_gauge.c @@ -62,6 +62,8 @@ #define SC27XX_FGU_CUR_BASIC_ADC 8192 #define SC27XX_FGU_SAMPLE_HZ 2 +/* micro Ohms */ +#define SC27XX_FGU_IDEAL_RESISTANCE 20000 /* * struct sc27xx_fgu_data: describe the FGU device @@ -84,6 +86,7 @@ * @resist_table_len: the resistance table length * @cur_1000ma_adc: ADC value corresponding to 1000 mA * @vol_1000mv_adc: ADC value corresponding to 1000 mV + * @calib_resist: the real resistance of coulomb counter chip in mOhm * @cap_table: capacity table with corresponding ocv * @resist_table: resistance percent table with corresponding temperature */ @@ -108,6 +111,7 @@ struct sc27xx_fgu_data { int resist_table_len; int cur_1000ma_adc; int vol_1000mv_adc; + int calib_resist; struct power_supply_battery_ocv_table *cap_table; struct power_supply_resistance_temp_table *resist_table; }; @@ -900,7 +904,9 @@ static int sc27xx_fgu_calibration(struct sc27xx_fgu_data *data) */ cal_4200mv = (calib_data & 0x1ff) + 6963 - 4096 - 256; data->vol_1000mv_adc = DIV_ROUND_CLOSEST(cal_4200mv * 10, 42); - data->cur_1000ma_adc = data->vol_1000mv_adc * 4; + data->cur_1000ma_adc = + DIV_ROUND_CLOSEST(data->vol_1000mv_adc * 4 * data->calib_resist, + SC27XX_FGU_IDEAL_RESISTANCE); kfree(buf); return 0; @@ -1079,6 +1085,15 @@ static int sc27xx_fgu_probe(struct platform_device *pdev) return ret; } + ret = device_property_read_u32(&pdev->dev, + "sprd,calib-resistance", + &data->calib_resist); + if (ret) { + dev_err(&pdev->dev, + "failed to get fgu calibration resistance\n"); + return ret; + } + data->channel = devm_iio_channel_get(dev, "bat-temp"); if (IS_ERR(data->channel)) { dev_err(dev, "failed to get IIO channel\n");