All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: Pavel Machek <pavel@ucw.cz>
Cc: Sebastian Reichel <sre@kernel.org>,
	linux-pm@vger.kernel.org, linux-omap@vger.kernel.org,
	Merlijn Wajer <merlijn@wizzup.org>
Subject: Re: [PATCH 2/3] power: supply: cpcap-charger: Allow changing constant charge voltage
Date: Fri, 20 Sep 2019 07:13:48 -0700	[thread overview]
Message-ID: <20190920141348.GL5610@atomide.com> (raw)
In-Reply-To: <20190919092658.GD9644@amd>

* Pavel Machek <pavel@ucw.cz> [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 <pavel@ucw.cz> 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


  reply	other threads:[~2019-09-20 14:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-17 21:52 [PATCH 0/3] cpcap charger and battery changes to deal with dropped voltage Tony Lindgren
2019-09-17 21:52 ` [PATCH 1/3] power: supply: cpcap-battery: Fix handling of lowered charger voltage Tony Lindgren
2019-09-17 21:52 ` [PATCH 2/3] power: supply: cpcap-charger: Allow changing constant charge voltage Tony Lindgren
2019-09-19  9:26   ` Pavel Machek
2019-09-20 14:13     ` Tony Lindgren [this message]
2019-09-17 21:52 ` [PATCH 3/3] power: supply: cpcap-charger: Adjust current based on charger interrupts Tony Lindgren
2019-09-19  9:34   ` Pavel Machek
2019-09-20 14:15     ` Tony Lindgren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190920141348.GL5610@atomide.com \
    --to=tony@atomide.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=merlijn@wizzup.org \
    --cc=pavel@ucw.cz \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.