All of lore.kernel.org
 help / color / mirror / Atom feed
From: k.kozlowski@samsung.com (Krzysztof Kozlowski)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 14/15] charger: max14577: Configure battery-dependent settings from DTS
Date: Thu, 20 Feb 2014 09:43:37 +0100	[thread overview]
Message-ID: <1392885817.3648.8.camel@AMDC1943> (raw)
In-Reply-To: <20140220063031.GC2498@jenny-desktop>

On Thu, 2014-02-20 at 12:00 +0530, Jenny Tc wrote:
> On Mon, Feb 17, 2014 at 10:05:49AM +0100, Krzysztof Kozlowski wrote:
> > +static inline int max14577_init_eoc(struct max14577_charger *chg,
> > +		unsigned int uamp)
> > +{
> > +	unsigned int current_bits = 0xf;
> > +	u8 reg_data;
> > +
> > +	switch (chg->maxim_core->dev_type) {
> > +	case MAXIM_DEVICE_TYPE_MAX77836:
> > +		if (uamp < 5000)
> > +			return -EINVAL; /* Requested current is too low */
> > +
> > +		if (uamp == 7500)
> > +			current_bits = 0x0;
> 
> if (uamp <= 7500) ?

(uamp < 7500) will be mapped to 5000 uA (0x1) so it will be OK. It is
safer to use lower current. The register description looks like:
0000 - 7.5 mA
0001 -  5 mA
0010 - 10 mA
0011 - 15 mA
...
1010 - 50 mA
1011 - 60 mA
1111 - 100 mA

However for value between <7501, 9999> this function will return 0x1
(5000 uA) which is not perfect. Better is to return 0x0 (7500 uA).
I'll fix this in next version of patch.


> 
> > +	/* Initialize Overvoltage-Protection Threshold */
> > +	switch (chg->pdata->ovp_uvolt) {
> > +	case 7500000:
> > +		reg_data = 0x0;
> > +		break;
> > +	case 6000000:
> > +	case 6500000:
> > +	case 7000000:
> > +		reg_data = 0x1 + (chg->pdata->ovp_uvolt - 6000000) / 500000;
> > +		break;
> 
> Is it battery OVP or charger source OVP? If it's battery OVP, then  minimum
> level as 6V seems to be unsafe even for 4.4V batteries.

It is on charger (input). Anyway only these 4 values are supported (6.0,
6.5, 7.0, 7.5 volts).


Best regards,
Krzysztof

WARNING: multiple messages have this Message-ID (diff)
From: Krzysztof Kozlowski <k.kozlowski@samsung.com>
To: Jenny Tc <jenny.tc@intel.com>
Cc: MyungJoo Ham <myungjoo.ham@samsung.com>,
	Chanwoo Choi <cw00.choi@samsung.com>,
	Samuel Ortiz <sameo@linux.intel.com>,
	Lee Jones <lee.jones@linaro.org>, Mark Brown <broonie@kernel.org>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Tomasz Figa <t.figa@samsung.com>,
	Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH v3 14/15] charger: max14577: Configure battery-dependent settings from DTS
Date: Thu, 20 Feb 2014 09:43:37 +0100	[thread overview]
Message-ID: <1392885817.3648.8.camel@AMDC1943> (raw)
In-Reply-To: <20140220063031.GC2498@jenny-desktop>

On Thu, 2014-02-20 at 12:00 +0530, Jenny Tc wrote:
> On Mon, Feb 17, 2014 at 10:05:49AM +0100, Krzysztof Kozlowski wrote:
> > +static inline int max14577_init_eoc(struct max14577_charger *chg,
> > +		unsigned int uamp)
> > +{
> > +	unsigned int current_bits = 0xf;
> > +	u8 reg_data;
> > +
> > +	switch (chg->maxim_core->dev_type) {
> > +	case MAXIM_DEVICE_TYPE_MAX77836:
> > +		if (uamp < 5000)
> > +			return -EINVAL; /* Requested current is too low */
> > +
> > +		if (uamp == 7500)
> > +			current_bits = 0x0;
> 
> if (uamp <= 7500) ?

(uamp < 7500) will be mapped to 5000 uA (0x1) so it will be OK. It is
safer to use lower current. The register description looks like:
0000 - 7.5 mA
0001 -  5 mA
0010 - 10 mA
0011 - 15 mA
...
1010 - 50 mA
1011 - 60 mA
1111 - 100 mA

However for value between <7501, 9999> this function will return 0x1
(5000 uA) which is not perfect. Better is to return 0x0 (7500 uA).
I'll fix this in next version of patch.


> 
> > +	/* Initialize Overvoltage-Protection Threshold */
> > +	switch (chg->pdata->ovp_uvolt) {
> > +	case 7500000:
> > +		reg_data = 0x0;
> > +		break;
> > +	case 6000000:
> > +	case 6500000:
> > +	case 7000000:
> > +		reg_data = 0x1 + (chg->pdata->ovp_uvolt - 6000000) / 500000;
> > +		break;
> 
> Is it battery OVP or charger source OVP? If it's battery OVP, then  minimum
> level as 6V seems to be unsafe even for 4.4V batteries.

It is on charger (input). Anyway only these 4 values are supported (6.0,
6.5, 7.0, 7.5 volts).


Best regards,
Krzysztof


  reply	other threads:[~2014-02-20  8:43 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-17  9:05 [PATCH v3 00/15] mfd: max14577: Add support for MAX77836 Krzysztof Kozlowski
2014-02-17  9:05 ` Krzysztof Kozlowski
2014-02-17  9:05 ` [PATCH v3 01/15] extcon: max14577: Change extcon name instead of static name according to device type Krzysztof Kozlowski
2014-02-17  9:05   ` Krzysztof Kozlowski
2014-02-17  9:05 ` [PATCH v3 02/15] mfd: max14577: Rename and add MAX14577 symbols to prepare for max77836 Krzysztof Kozlowski
2014-02-17  9:05   ` Krzysztof Kozlowski
2014-02-19 12:44   ` Krzysztof Kozlowski
2014-02-19 12:44     ` Krzysztof Kozlowski
2014-02-19 14:11     ` Mark Brown
2014-02-19 14:11       ` Mark Brown
2014-02-20  8:54       ` Krzysztof Kozlowski
2014-02-20  8:54         ` Krzysztof Kozlowski
2014-02-17  9:05 ` [PATCH v3 03/15] mfd: max14577: Rename state container to maxim_core Krzysztof Kozlowski
2014-02-17  9:05   ` Krzysztof Kozlowski
2014-02-17  9:05 ` [PATCH v3 04/15] mfd: max14577: Add "muic" suffix to regmap and irq_chip Krzysztof Kozlowski
2014-02-17  9:05   ` Krzysztof Kozlowski
2014-02-17  9:05 ` [PATCH v3 05/15] mfd: max14577: Add detection of device type Krzysztof Kozlowski
2014-02-17  9:05   ` Krzysztof Kozlowski
2014-02-17  9:05 ` [PATCH v3 06/15] extcon: max14577: Add max14577 prefix to muic_irqs Krzysztof Kozlowski
2014-02-17  9:05   ` Krzysztof Kozlowski
2014-02-17  9:05 ` [PATCH v3 07/15] extcon: max14577: Choose muic_irqs according to device type Krzysztof Kozlowski
2014-02-17  9:05   ` Krzysztof Kozlowski
2014-02-17  9:05 ` [PATCH v3 08/15] mfd: max77836: Add max77836 support to max14577 driver Krzysztof Kozlowski
2014-02-17  9:05   ` Krzysztof Kozlowski
2014-02-17  9:05 ` [PATCH v3 09/15] extcon: max14577: Add support for max77836 Krzysztof Kozlowski
2014-02-17  9:05   ` Krzysztof Kozlowski
2014-02-17  9:05 ` [PATCH v3 10/15] regulator: max14577: Add support for max77836 regulators Krzysztof Kozlowski
2014-02-17  9:05   ` Krzysztof Kozlowski
2014-02-17  9:05 ` [PATCH v3 11/15] charger: max14577: Add support for MAX77836 charger Krzysztof Kozlowski
2014-02-17  9:05   ` Krzysztof Kozlowski
2014-02-17  9:05 ` [PATCH v3 12/15] power: max17040: Add ID for max77836 Fuel Gauge block Krzysztof Kozlowski
2014-02-17  9:05   ` Krzysztof Kozlowski
2014-02-17  9:05 ` [PATCH v3 13/15] regulator/mfd: max14577: Export symbols for calculating charger current Krzysztof Kozlowski
2014-02-17  9:05   ` Krzysztof Kozlowski
2014-02-17  9:05 ` [PATCH v3 14/15] charger: max14577: Configure battery-dependent settings from DTS Krzysztof Kozlowski
2014-02-17  9:05   ` Krzysztof Kozlowski
2014-02-17 10:07   ` Lee Jones
2014-02-17 10:07     ` Lee Jones
2014-02-17 10:40     ` Krzysztof Kozlowski
2014-02-17 10:40       ` Krzysztof Kozlowski
2014-02-17 11:22       ` Lee Jones
2014-02-17 11:22         ` Lee Jones
2014-02-20  6:30   ` Jenny Tc
2014-02-20  6:30     ` Jenny Tc
2014-02-20  8:43     ` Krzysztof Kozlowski [this message]
2014-02-20  8:43       ` Krzysztof Kozlowski
2014-02-17  9:05 ` [PATCH v3 15/15] mfd: max14577: Add device tree bindings document Krzysztof Kozlowski
2014-02-17  9:05   ` Krzysztof Kozlowski
2014-02-19 15:12   ` Tomasz Figa
2014-02-19 15:12     ` Tomasz Figa
2014-02-19 15:12     ` Tomasz Figa
2014-02-19 15:17   ` Tomasz Figa
2014-02-19 15:17     ` Tomasz Figa

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=1392885817.3648.8.camel@AMDC1943 \
    --to=k.kozlowski@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.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.