From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60A9AC49ED7 for ; Fri, 20 Sep 2019 14:13:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2FA802086A for ; Fri, 20 Sep 2019 14:13:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387721AbfITONw (ORCPT ); Fri, 20 Sep 2019 10:13:52 -0400 Received: from muru.com ([72.249.23.125]:33952 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387716AbfITONw (ORCPT ); Fri, 20 Sep 2019 10:13:52 -0400 Received: from atomide.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTPS id 3931780AA; Fri, 20 Sep 2019 14:14:23 +0000 (UTC) Date: Fri, 20 Sep 2019 07:13:48 -0700 From: Tony Lindgren To: Pavel Machek Cc: Sebastian Reichel , linux-pm@vger.kernel.org, linux-omap@vger.kernel.org, Merlijn Wajer Subject: Re: [PATCH 2/3] power: supply: cpcap-charger: Allow changing constant charge voltage Message-ID: <20190920141348.GL5610@atomide.com> References: <20190917215253.17880-1-tony@atomide.com> <20190917215253.17880-3-tony@atomide.com> <20190919092658.GD9644@amd> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190919092658.GD9644@amd> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org * Pavel Machek [190919 09:27]: > Hi! > > > Let's allow reconfiguring the cpcap-charger max charge voltage and > > default to 4.2V that should be safe for the known users. > > > > This allows the users to use 4.35V for the extra capacity if really > > needed at a cost of probably shorter battery life. We check the > > constant charge voltage limit set by the battery. > > > > Some pieces of the property setting code is based on an earlier patch > > from Pavel Machek but limited to configuring the charge > > voltage for now. > > I'm sorry I'm a tiny bit busy at the moment. > > > +const int cpcap_charge_voltage[] = { > > + [CPCAP_REG_CRM_VCHRG_3V80] = 3800000, > > + [CPCAP_REG_CRM_VCHRG_4V10] = 4100000, > > + [CPCAP_REG_CRM_VCHRG_4V12] = 4120000, > > + [CPCAP_REG_CRM_VCHRG_4V15] = 4150000, > > + [CPCAP_REG_CRM_VCHRG_4V17] = 4170000, > > + [CPCAP_REG_CRM_VCHRG_4V20] = 4200000, > > + [CPCAP_REG_CRM_VCHRG_4V23] = 4230000, > > + [CPCAP_REG_CRM_VCHRG_4V25] = 4250000, > > + [CPCAP_REG_CRM_VCHRG_4V27] = 4270000, > > + [CPCAP_REG_CRM_VCHRG_4V30] = 4300000, > > + [CPCAP_REG_CRM_VCHRG_4V33] = 4330000, > > + [CPCAP_REG_CRM_VCHRG_4V35] = 4350000, > > + [CPCAP_REG_CRM_VCHRG_4V38] = 4380000, > > + [CPCAP_REG_CRM_VCHRG_4V40] = 4400000, > > + [CPCAP_REG_CRM_VCHRG_4V42] = 4420000, > > + [CPCAP_REG_CRM_VCHRG_4V44] = 4440000, > > +}; > > We really don't need this kind of explicit table, as the values can be > simply computed. Can I offer this? > > Best regards, > Pavel > > static int voltage_to_register(int microvolt) > { > int milivolt = microvolt/1000; > int res; > > if (milivolt < 4100) > return CPCAP_REG_CRM_VCHRG_3V80; > if (milivolt > 4350) > return -EINVAL; > > milivolt = milivolt - (4100 - 250); > res = milivolt / 250; > BUG_ON(res < 1); > BUG_ON(res > 0xb); > return CPCAP_REG_CRM_VCHRG(res); > } Well that does not help as we have four different ranges there. I got something figured out for the new suggested fix I posted. Regards, TOny