* Re: [PATCH v2 2/4] power: add axp20x-battery driver
[not found] ` <20161009062714.5085-2-icenowy@aosc.xyz>
@ 2016-10-10 12:57 ` Maxime Ripard
2016-10-10 13:12 ` Maxime Ripard
0 siblings, 1 reply; 2+ messages in thread
From: Maxime Ripard @ 2016-10-10 12:57 UTC (permalink / raw)
To: Icenowy Zheng
Cc: Rob Herring, Chen-Yu Tsai, Lee Jones, Bruno Prémont,
Michael Haas, Mark Rutland, Russell King, Sebastian Reichel,
devicetree, linux-arm-kernel, linux-kernel, linux-pm, quentin
[-- Attachment #1: Type: text/plain, Size: 1442 bytes --]
Hi Icenowy,
On Sun, Oct 09, 2016 at 02:27:12PM +0800, Icenowy Zheng wrote:
> + case POWER_SUPPLY_PROP_CURRENT_NOW:
> + ret = regmap_read(power->regmap, AXP20X_BATT_DISCHRG_I_H, &dh);
> + if (ret)
> + return ret;
> + ret = regmap_read(power->regmap, AXP20X_BATT_DISCHRG_I_L, &dl);
> + if (ret)
> + return ret;
> + /* it's a 12 bit integer, high 8-bit is stored in dh */
> + val->intval = dh << 4 | dl >> 4;
> + break;
> + case POWER_SUPPLY_PROP_VOLTAGE_NOW:
> + ret = regmap_read(power->regmap, AXP20X_BATT_V_H, &dh);
> + if (ret)
> + return ret;
> + ret = regmap_read(power->regmap, AXP20X_BATT_V_L, &dl);
> + if (ret)
> + return ret;
> + /* it's a 12 bit integer, high 8-bit is stored in dh */
> + val->intval = dh << 4 | dl >> 4;
> + /* The formula below is from axp22_vbat_to_mV function
> + * of Allwinner 3.4 kernel.
> + */
> + val->intval = val->intval * 1100 / 1000;
> + break;
I really feel that this should be implemented through a IIO driver
(like the AXP288). This is especially true for the AXP209 and its
multiple GPIOs that can be muxed to a general purpose ADC, but it's
also true for the AXP221 / 223 TS pin that can also be used as an ADC.
Quentin has been working on this lately for the AXP209, feel free to
sync with him to support the AXP22*
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2 2/4] power: add axp20x-battery driver
2016-10-10 12:57 ` [PATCH v2 2/4] power: add axp20x-battery driver Maxime Ripard
@ 2016-10-10 13:12 ` Maxime Ripard
0 siblings, 0 replies; 2+ messages in thread
From: Maxime Ripard @ 2016-10-10 13:12 UTC (permalink / raw)
To: Icenowy Zheng
Cc: Rob Herring, Chen-Yu Tsai, Lee Jones, Bruno Prémont,
Michael Haas, Mark Rutland, Russell King, Sebastian Reichel,
devicetree, linux-arm-kernel, linux-kernel, linux-pm, quentin
[-- Attachment #1: Type: text/plain, Size: 1733 bytes --]
Adding the real Quentin address
On Mon, Oct 10, 2016 at 02:57:26PM +0200, Maxime Ripard wrote:
> Hi Icenowy,
>
> On Sun, Oct 09, 2016 at 02:27:12PM +0800, Icenowy Zheng wrote:
> > + case POWER_SUPPLY_PROP_CURRENT_NOW:
> > + ret = regmap_read(power->regmap, AXP20X_BATT_DISCHRG_I_H, &dh);
> > + if (ret)
> > + return ret;
> > + ret = regmap_read(power->regmap, AXP20X_BATT_DISCHRG_I_L, &dl);
> > + if (ret)
> > + return ret;
> > + /* it's a 12 bit integer, high 8-bit is stored in dh */
> > + val->intval = dh << 4 | dl >> 4;
> > + break;
> > + case POWER_SUPPLY_PROP_VOLTAGE_NOW:
> > + ret = regmap_read(power->regmap, AXP20X_BATT_V_H, &dh);
> > + if (ret)
> > + return ret;
> > + ret = regmap_read(power->regmap, AXP20X_BATT_V_L, &dl);
> > + if (ret)
> > + return ret;
> > + /* it's a 12 bit integer, high 8-bit is stored in dh */
> > + val->intval = dh << 4 | dl >> 4;
> > + /* The formula below is from axp22_vbat_to_mV function
> > + * of Allwinner 3.4 kernel.
> > + */
> > + val->intval = val->intval * 1100 / 1000;
> > + break;
>
> I really feel that this should be implemented through a IIO driver
> (like the AXP288). This is especially true for the AXP209 and its
> multiple GPIOs that can be muxed to a general purpose ADC, but it's
> also true for the AXP221 / 223 TS pin that can also be used as an ADC.
>
> Quentin has been working on this lately for the AXP209, feel free to
> sync with him to support the AXP22*
>
> Maxime
>
> --
> Maxime Ripard, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com
--
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-10-10 13:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20161009062714.5085-1-icenowy@aosc.xyz>
[not found] ` <20161009062714.5085-2-icenowy@aosc.xyz>
2016-10-10 12:57 ` [PATCH v2 2/4] power: add axp20x-battery driver Maxime Ripard
2016-10-10 13:12 ` Maxime Ripard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox