Message ID | 1667647544-12945-3-git-send-email-ivo.g.dimitrov.75@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp940911wru; Sat, 5 Nov 2022 04:34:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6OAqA4yVkXaT9HvqefA2EI79m3xVF1kj/8Vyy/w+uSl4OB/ImIdM+99AdjwSIiEAnb8jS2 X-Received: by 2002:a17:903:2446:b0:187:11c6:6a1b with SMTP id l6-20020a170903244600b0018711c66a1bmr34256517pls.39.1667648083722; Sat, 05 Nov 2022 04:34:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667648083; cv=none; d=google.com; s=arc-20160816; b=A1yFj9Lo1c018KoMgM7wLV1ThN627LmwyTlobivpL38eS3pLRKvsV3GpU1B3OXhd3g G7803FBKgwAwnAD45CIgsgffhV9FgOzg82aBEqfGYq4cVhiQo5eUUb9t3HshWSVGwxg8 vnQbco6TEMKw0WPUg67WfIkqnlsXh3xL9rEBYrdfwjvVKZxyx58XJCGrXh2qbeG6Qpky NPjtM6olo0OmhU1XEyDWLQtkVeL96pfQ9KOTlzCFgNM9KjEQLffDv/LL0dbDXZYYqoWF m01L1A/cVaoREMZpFXubBTQ88yhKJMFzIaii8rfgAJvm4iqSogAOUWIHJpqsJaAvlOgX s2QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=mvbWRnJLjkEbJwbK1HqoKZYYWWWpHEGeJghtyoGl4P0=; b=fv6oqf2iK2SvB8mNMB4ou1gqY++0mG8jwm6qY/chh9rWIeEr5wJieWm13epYlRgvRx qh86QkJ8+5+BuNANjFJDS5Mz1AGyX+68lC6lXXwIeSGtakyWOROsmlAKcrUrwyb1U/XK ZaPszShQOa1j3IIQ7UyVFKHMoCXj8zwQe4/X8NBohlQ//Oys+OJHv3w/YIuN6eUX9V4u SkfC2+86cybxU7U+xvJizSJmp00W4ZtwcnUvXOFwfWdiwU0z3nJ71yx/6RLPq9YAlzDj tdkpCtSl+uRcFtZJeZI+Gqy6XVpBZLjrw4+YdBbpGhDLdKhYGP80WD3wLglvHeLOjQb8 DkeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=C8gR2s0A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f7-20020a170902ce8700b0016ce3d67e7csi3233265plg.387.2022.11.05.04.34.30; Sat, 05 Nov 2022 04:34:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=C8gR2s0A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229805AbiKEL02 (ORCPT <rfc822;hjfbswb@gmail.com> + 99 others); Sat, 5 Nov 2022 07:26:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229776AbiKEL0S (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 5 Nov 2022 07:26:18 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E9F21C93B; Sat, 5 Nov 2022 04:26:17 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id b2so19256128eja.6; Sat, 05 Nov 2022 04:26:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=mvbWRnJLjkEbJwbK1HqoKZYYWWWpHEGeJghtyoGl4P0=; b=C8gR2s0AAAG6uGJhhbsKl5NJ2n+1peuiSWA7QXTiZTMalCVYF+kWkYB4pzVxrQPawu RKLgbkvoQDXSjjiuyYupi3fNKABc1mppEqnPCuuNxIswwNEdB9js1on29IY/Y3KZYxp6 nnWbgja5HcwueVtL5j5vmXpzGc491l49mzUnQo+fIUJhPmEyQ4KPGnLsaX+y+8Zp08Ca ErkVwbpcVmFgQ3egvFuvyQOuEPy++nUCS2tf1zq0r+4wxAyTXX05mP3J4WFH28Mbe82V J868hOcDys45rd3Z7hxksZkNznnB+4q7796VJXRrIbDdnpB17jFdYItX5VVZhWRRpQDm W8yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mvbWRnJLjkEbJwbK1HqoKZYYWWWpHEGeJghtyoGl4P0=; b=P4GUQiILJkv+yQk9hvxhchX2xjR/8VviVHdN5pY3HY84szVXOQysHKIjfSfHVFuqHn 1m262+HrVjTVvVVaZNBQsffHapLdDexC+rfr+XOI7Cym77cEal9FssAQuwo/VAa+nesa 7ln8uumdi/SiW4iSoBldAX2jkJ6s86BjhOPvCq1ioo8m/BCCYIvRo+QmLwOBIBPCow4o hy1j57IcVbqpGLMbY7nUaKvP/YYngLEgxLUA3fV2WuzV256VzuaBftWo+kHsqotNMpwH 3rdHB7nv4I5sWuD53ZEzJYNTgEheLr8UCOalM4fi8ENqcBwfKLMJZnhmZiD0fIxyYbD5 EtRg== X-Gm-Message-State: ACrzQf3tRs7afrX78re9n43+jdmZKw5FE1yU+bxfJOoM0j0uS9+vEuba yeNDRRsqNCRvu/bh6nra/DQ= X-Received: by 2002:a17:907:608f:b0:78e:1b60:60e2 with SMTP id ht15-20020a170907608f00b0078e1b6060e2mr39212115ejc.382.1667647576266; Sat, 05 Nov 2022 04:26:16 -0700 (PDT) Received: from localhost.localdomain ([46.249.74.23]) by smtp.gmail.com with ESMTPSA id u18-20020a509512000000b004611c230bd0sm1050069eda.37.2022.11.05.04.26.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Nov 2022 04:26:15 -0700 (PDT) From: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> To: sre@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, tony@atomide.com, philipp@uvos.xyz, Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> Subject: [PATCH 2/3] power: supply: cpcap-battery: Fix battery identification Date: Sat, 5 Nov 2022 13:25:43 +0200 Message-Id: <1667647544-12945-3-git-send-email-ivo.g.dimitrov.75@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1667647544-12945-1-git-send-email-ivo.g.dimitrov.75@gmail.com> References: <1667647544-12945-1-git-send-email-ivo.g.dimitrov.75@gmail.com> X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748655757142301385?= X-GMAIL-MSGID: =?utf-8?q?1748655757142301385?= |
Series |
power: supply: cpcap-battery improvements
|
|
Commit Message
Ivaylo Dimitrov
Nov. 5, 2022, 11:25 a.m. UTC
Use the same logic to identify genuine batteries as Android does.
Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
---
drivers/power/supply/cpcap-battery.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
Comments
Hi, On Sat, Nov 05, 2022 at 01:25:43PM +0200, Ivaylo Dimitrov wrote: > Use the same logic to identify genuine batteries as Android does. > > Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> > --- Why do we care? -- Sebastian > drivers/power/supply/cpcap-battery.c | 19 ++++++++++++++----- > 1 file changed, 14 insertions(+), 5 deletions(-) > > diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c > index 8869067..ca6ee2b 100644 > --- a/drivers/power/supply/cpcap-battery.c > +++ b/drivers/power/supply/cpcap-battery.c > @@ -422,7 +422,7 @@ static int cpcap_battery_cc_to_ua(struct cpcap_battery_ddata *ddata, > > static int cpcap_battery_match_nvmem(struct device *dev, const void *data) > { > - if (strcmp(dev_name(dev), "89-500029ba0f73") == 0) > + if (strncmp(dev_name(dev), "89-500", 6) == 0) > return 1; > else > return 0; > @@ -439,10 +439,19 @@ static void cpcap_battery_detect_battery_type(struct cpcap_battery_ddata *ddata) > if (IS_ERR_OR_NULL(nvmem)) { > ddata->check_nvmem = true; > dev_info_once(ddata->dev, "Can not find battery nvmem device. Assuming generic lipo battery\n"); > - } else if (nvmem_device_read(nvmem, 2, 1, &battery_id) < 0) { > - battery_id = 0; > - ddata->check_nvmem = true; > - dev_warn(ddata->dev, "Can not read battery nvmem device. Assuming generic lipo battery\n"); > + } else { > + char buf[24]; > + > + if (nvmem_device_read(nvmem, 96, 4, buf) < 0 || > + strncmp(buf, "COPR", 4) != 0 || > + nvmem_device_read(nvmem, 104, 24, buf) < 0 || > + strncmp(buf, "MOTOROLA E.P CHARGE ONLY", 24) != 0 || > + nvmem_device_read(nvmem, 2, 1, &battery_id) < 0) { > + battery_id = 0; > + ddata->check_nvmem = true; > + dev_warn(ddata->dev, "Can not read battery nvmem device. Assuming generic lipo battery\n"); > + } > + > } > > switch (battery_id) { > -- > 1.9.1 >
Hi, On 10.11.22 г. 18:05 ч., Sebastian Reichel wrote: > Hi, > > On Sat, Nov 05, 2022 at 01:25:43PM +0200, Ivaylo Dimitrov wrote: >> Use the same logic to identify genuine batteries as Android does. >> >> Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> >> --- > > Why do we care? > Because if we know the battery is genuine (or at least pretends to be :) ), then we can read battery parameters from nvram, see patch 3/3. This will allow us to charge HV LiPo batteries to 4.35V, using the full capacity. Not to say the code currently identifies a specific battery with id of "89-500029ba0f73" as genuine one, ignoring all others. So this patch is more or less a bugfix too. Regards, Ivo > -- Sebastian > >> drivers/power/supply/cpcap-battery.c | 19 ++++++++++++++----- >> 1 file changed, 14 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c >> index 8869067..ca6ee2b 100644 >> --- a/drivers/power/supply/cpcap-battery.c >> +++ b/drivers/power/supply/cpcap-battery.c >> @@ -422,7 +422,7 @@ static int cpcap_battery_cc_to_ua(struct cpcap_battery_ddata *ddata, >> >> static int cpcap_battery_match_nvmem(struct device *dev, const void *data) >> { >> - if (strcmp(dev_name(dev), "89-500029ba0f73") == 0) >> + if (strncmp(dev_name(dev), "89-500", 6) == 0) >> return 1; >> else >> return 0; >> @@ -439,10 +439,19 @@ static void cpcap_battery_detect_battery_type(struct cpcap_battery_ddata *ddata) >> if (IS_ERR_OR_NULL(nvmem)) { >> ddata->check_nvmem = true; >> dev_info_once(ddata->dev, "Can not find battery nvmem device. Assuming generic lipo battery\n"); >> - } else if (nvmem_device_read(nvmem, 2, 1, &battery_id) < 0) { >> - battery_id = 0; >> - ddata->check_nvmem = true; >> - dev_warn(ddata->dev, "Can not read battery nvmem device. Assuming generic lipo battery\n"); >> + } else { >> + char buf[24]; >> + >> + if (nvmem_device_read(nvmem, 96, 4, buf) < 0 || >> + strncmp(buf, "COPR", 4) != 0 || >> + nvmem_device_read(nvmem, 104, 24, buf) < 0 || >> + strncmp(buf, "MOTOROLA E.P CHARGE ONLY", 24) != 0 || >> + nvmem_device_read(nvmem, 2, 1, &battery_id) < 0) { >> + battery_id = 0; >> + ddata->check_nvmem = true; >> + dev_warn(ddata->dev, "Can not read battery nvmem device. Assuming generic lipo battery\n"); >> + } >> + >> } >> >> switch (battery_id) { >> -- >> 1.9.1 >>
Hi, * Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> [221110 16:40]: > On 10.11.22 г. 18:05 ч., Sebastian Reichel wrote: > > Why do we care? > > > Because if we know the battery is genuine (or at least pretends to be :) ), > then we can read battery parameters from nvram, see patch 3/3. This will > allow us to charge HV LiPo batteries to 4.35V, using the full capacity. Let's not enable charge voltages above 4.2V automatically at all unless the user chooses to set a higher charge voltage via sysfs manually. We have had reports of bloated batteries if left connected to the charger at higher voltage than 4.2V. This seems to happen after connected for some weeks or months. AFAIK this happens both with Android and mainline kernel at higher voltages. For more information, please see commit d4ee021c410f ("power: supply: cpcap-charger: Limit voltage to 4.2V for battery"). No objections for using the NVRAM to detect the battery max voltages though. That is as long as the default charge voltage does not go above 4.2V. Regards, Tony
Hi, On 15.11.22 г. 15:49 ч., Tony Lindgren wrote: > Hi, > > * Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> [221110 16:40]: >> On 10.11.22 г. 18:05 ч., Sebastian Reichel wrote: >>> Why do we care? >>> >> Because if we know the battery is genuine (or at least pretends to be :) ), >> then we can read battery parameters from nvram, see patch 3/3. This will >> allow us to charge HV LiPo batteries to 4.35V, using the full capacity. > > Let's not enable charge voltages above 4.2V automatically at all unless > the user chooses to set a higher charge voltage via sysfs manually. > > We have had reports of bloated batteries if left connected to the charger > at higher voltage than 4.2V. This seems to happen after connected for some > weeks or months. AFAIK this happens both with Android and mainline kernel > at higher voltages. > Not that I sent such patch yet, but still, thinking about it, we should be able to easily prevent such damage by not restarting the charging after battery is full and voltage has dropped by 50mV or so. There can be a threshold (lets say 4.25 or 4.2) above which charging shall not be re-enabled unless the user reconnects the charger. Even if default stays 4.2 and it is the user that has enabled 4.35. Just an idea. > For more information, please see commit d4ee021c410f ("power: supply: > cpcap-charger: Limit voltage to 4.2V for battery"). > > No objections for using the NVRAM to detect the battery max voltages > though. That is as long as the default charge voltage does not go above > 4.2V. Patch 3/3 does just that - reads battery design parameters from NVRAM. Regards, Ivo > > Regards, > > Tony >
* Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> [221115 15:31]: > Hi, > > On 15.11.22 г. 15:49 ч., Tony Lindgren wrote: > > Hi, > > > > * Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> [221110 16:40]: > > > On 10.11.22 г. 18:05 ч., Sebastian Reichel wrote: > > > > Why do we care? > > > > > > > Because if we know the battery is genuine (or at least pretends to be :) ), > > > then we can read battery parameters from nvram, see patch 3/3. This will > > > allow us to charge HV LiPo batteries to 4.35V, using the full capacity. > > > > Let's not enable charge voltages above 4.2V automatically at all unless > > the user chooses to set a higher charge voltage via sysfs manually. > > > > We have had reports of bloated batteries if left connected to the charger > > at higher voltage than 4.2V. This seems to happen after connected for some > > weeks or months. AFAIK this happens both with Android and mainline kernel > > at higher voltages. > > > > Not that I sent such patch yet, but still, thinking about it, we should be > able to easily prevent such damage by not restarting the charging after > battery is full and voltage has dropped by 50mV or so. There can be a > threshold (lets say 4.25 or 4.2) above which charging shall not be > re-enabled unless the user reconnects the charger. Even if default stays 4.2 > and it is the user that has enabled 4.35. Just an idea. Sure the logic to handle max charge voltage and maintenance charge voltage could be there. With commit d4ee021c410f we now just wait for the charge to come down to 4.2V if charged at 4.35V with Android. We still should not enable higher charge voltages by default though. It still needs to be enabled by the user via sysfs. It's possible that also shorter peaks of higher charge voltage accelerate the battery degration. It just may happen slower than what we've seen earlier. To test this, multiple devices would need to be left connected to a charger for several months :) Regards, Tony
Hi Tony, We also have a pretty good case having the battery on 4.35V for regular amounts of time at a time is not damageing: 1. For one thing this corroborated by literature about hvlipos. 2. Personally i used the d4 for manny years with andorid without issue, giveing the battery manny cycles 3. I think so far we have found very few, if any, devices whos batteris where replaced by thair previous owners, judgeing by the condition of the stickers and the battery production dates. Even though maemo leste has access to manny manny devices. It is true the hvlipos have a lower cycle lifetime than regular 4.35V lipos when charged to 4.35 than regular lipos when charged to 4.2V, however it this effect is not as large as you might think. It is also true that leaving a Lithium cell of any chemistry on Vmax for long periods of time siginifcantly accelerates degradion, if this is sufficant cause to drop the "full" soc a couple of percent is a debateable and reasonable trade off and would be something we should then apply to all batteries if chosen, not just hvlipos as it affects regular lipos just the same. Regards, Philipp On Thu, 2022-11-17 at 06:53 +0200, Tony Lindgren wrote: > * Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> [221115 15:31]: > > Hi, > > > > On 15.11.22 г. 15:49 ч., Tony Lindgren wrote: > > > Hi, > > > > > > * Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com> [221110 16:40]: > > > > On 10.11.22 г. 18:05 ч., Sebastian Reichel wrote: > > > > > Why do we care? > > > > > > > > > Because if we know the battery is genuine (or at least pretends > > > > to be :) ), > > > > then we can read battery parameters from nvram, see patch 3/3. > > > > This will > > > > allow us to charge HV LiPo batteries to 4.35V, using the full > > > > capacity. > > > > > > Let's not enable charge voltages above 4.2V automatically at all > > > unless > > > the user chooses to set a higher charge voltage via sysfs > > > manually. > > > > > > We have had reports of bloated batteries if left connected to the > > > charger > > > at higher voltage than 4.2V. This seems to happen after connected > > > for some > > > weeks or months. AFAIK this happens both with Android and > > > mainline kernel > > > at higher voltages. > > > > > > > Not that I sent such patch yet, but still, thinking about it, we > > should be > > able to easily prevent such damage by not restarting the charging > > after > > battery is full and voltage has dropped by 50mV or so. There can be > > a > > threshold (lets say 4.25 or 4.2) above which charging shall not be > > re-enabled unless the user reconnects the charger. Even if default > > stays 4.2 > > and it is the user that has enabled 4.35. Just an idea. > > Sure the logic to handle max charge voltage and maintenance charge > voltage > could be there. With commit d4ee021c410f we now just wait for the > charge > to come down to 4.2V if charged at 4.35V with Android. > > We still should not enable higher charge voltages by default though. > It > still needs to be enabled by the user via sysfs. It's possible that > also > shorter peaks of higher charge voltage accelerate the battery > degration. > It just may happen slower than what we've seen earlier. To test this, > multiple devices would need to be left connected to a charger for > several > months :) > > Regards, > > Tony
* Carl Klemm <carl@uvos.xyz> [221117 08:06]: > 2. Personally i used the d4 for manny years with andorid without issue, > giveing the battery manny cycles Many cycles does not seem to be the issue, the issue seems to be leaving the device connected to the charger for longer periods of time at higher charge voltages. No objection to having the capability there. But enabling it by default is a different story. We need several folks test connected to a charger for months with proper Tested-by if we want to enable it by default. Regards, Tony
diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c index 8869067..ca6ee2b 100644 --- a/drivers/power/supply/cpcap-battery.c +++ b/drivers/power/supply/cpcap-battery.c @@ -422,7 +422,7 @@ static int cpcap_battery_cc_to_ua(struct cpcap_battery_ddata *ddata, static int cpcap_battery_match_nvmem(struct device *dev, const void *data) { - if (strcmp(dev_name(dev), "89-500029ba0f73") == 0) + if (strncmp(dev_name(dev), "89-500", 6) == 0) return 1; else return 0; @@ -439,10 +439,19 @@ static void cpcap_battery_detect_battery_type(struct cpcap_battery_ddata *ddata) if (IS_ERR_OR_NULL(nvmem)) { ddata->check_nvmem = true; dev_info_once(ddata->dev, "Can not find battery nvmem device. Assuming generic lipo battery\n"); - } else if (nvmem_device_read(nvmem, 2, 1, &battery_id) < 0) { - battery_id = 0; - ddata->check_nvmem = true; - dev_warn(ddata->dev, "Can not read battery nvmem device. Assuming generic lipo battery\n"); + } else { + char buf[24]; + + if (nvmem_device_read(nvmem, 96, 4, buf) < 0 || + strncmp(buf, "COPR", 4) != 0 || + nvmem_device_read(nvmem, 104, 24, buf) < 0 || + strncmp(buf, "MOTOROLA E.P CHARGE ONLY", 24) != 0 || + nvmem_device_read(nvmem, 2, 1, &battery_id) < 0) { + battery_id = 0; + ddata->check_nvmem = true; + dev_warn(ddata->dev, "Can not read battery nvmem device. Assuming generic lipo battery\n"); + } + } switch (battery_id) {