From: hdegoede@redhat•com (Hans de Goede)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH 4/8] power: Add an axp20x-usb-power driver
Date: Wed, 10 Jun 2015 11:22:00 +0200 [thread overview]
Message-ID: <557801B8.5040804@redhat.com> (raw)
In-Reply-To: <20150610072957.GV2982@x1>
Hi,
Thanks for the quick review I'll do a v2 addressing your concerns soonish.
On 10-06-15 09:29, Lee Jones wrote:
> On Tue, 09 Jun 2015, Hans de Goede wrote:
>
>> This adds a driver for the usb power_supply bits of the axp20x PMICs.
>>
>> I initially started writing my own driver, before coming aware of
>> Bruno Pr?mont's excellent earlier RFC with a driver for this.
>>
>> My driver was lacking CURRENT_MAX and VOLTAGE_MIN support Bruno's
>> drvier has, so I've copied the code for those from his driver.
>>
>> Note that the AC-power-supply and battery charger bits will need separate
>> drivers. Each one needs its own devictree child-node so that other
>> devicetree nodes can reference the right power-supply, and thus each one
>> will get its own mfd-cell / platform_device and platform-driver.
>>
>> Cc: Bruno Pr?mont <bonbons@linux-vserver•org>
>> Signed-off-by: Hans de Goede <hdegoede@redhat•com>
>> ---
>> .../bindings/power_supply/axp20x_usb_power.txt | 34 +++
>
> This needs to be submitted in a seperate patch.
Ok.
>
>> drivers/power/Kconfig | 7 +
>> drivers/power/Makefile | 1 +
>> drivers/power/axp20x_usb_power.c | 241 +++++++++++++++++++++
>> include/linux/mfd/axp20x.h | 24 ++
>> 5 files changed, 307 insertions(+)
>> create mode 100644 Documentation/devicetree/bindings/power_supply/axp20x_usb_power.txt
>> create mode 100644 drivers/power/axp20x_usb_power.c
>
> [...]
>
>> diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
>> index f4290ae..d7adb2e 100644
>> --- a/include/linux/mfd/axp20x.h
>> +++ b/include/linux/mfd/axp20x.h
>> @@ -11,6 +11,8 @@
>> #ifndef __LINUX_MFD_AXP20X_H
>> #define __LINUX_MFD_AXP20X_H
>>
>> +#include <linux/regmap.h>
>> +
>> enum {
>> AXP202_ID = 0,
>> AXP209_ID,
>> @@ -366,4 +368,26 @@ struct axp20x_fg_pdata {
>> int thermistor_curve[MAX_THERM_CURVE_SIZE][2];
>> };
>>
>> +/* generic helper function for reading 9-16 bit wide regs */
>> +static inline int axp20x_read_16bit(struct regmap *regmap,
>
> This is only used twice and only in one file.
>
> Do you know of any other uses of this call that will be upstreamed
> shortly?
Yes I plan to write drivers for the other 3 power_supply class
cells (ac-power, battery-charger, rtc-bat-charger) in the axp209,
and most of those need the same helper which I why I put it here.
>
>> + unsigned int reg, unsigned int width)
>
> The function name is a bit misleading.
How about: axp20x_read_multibyte_reg ?
>
>> +{
>> + unsigned int v, raw;
>> + int r;
>
> 'v' and 'r' are not good variable names.
>
>> + r = regmap_read(regmap, reg, &v);
>> + if (r)
>> + return r;
>> +
>> + raw = v << (width - 8);
>
> So 'reg' is expected to be top end loaded?
>
> E.g A value of say 0x0101 (257) in 9 bits will look like this:
>
> reg reg + 1
> 1000 0000b 0000 0001b
Yes, I guess this was done so that you can get all the 8 msb-s
in a single read if you do not care about the lsb-s.
>
>> + r = regmap_read(regmap, reg + 1, &v);
>> + if (r)
>> + return r;
>> +
>> + raw |= v;
>> +
>> + return raw;
>> +}
>> +
>> #endif /* __LINUX_MFD_AXP20X_H */
>
Regards,
Hans
next prev parent reply other threads:[~2015-06-10 9:22 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-09 21:37 [PATCH 0/8] mfd/power/phy: Add support for otg vbus detection via axp pmic Hans de Goede
2015-06-09 21:37 ` [PATCH 1/8] mfd: axp20x: Add missing registers, and mark more registers volatile Hans de Goede
2015-06-10 7:36 ` Lee Jones
2015-06-09 21:37 ` [PATCH 2/8] mfd: axp20x: Add a cell for the usb power_supply part of the axp20x PMICs Hans de Goede
2015-06-10 1:19 ` [linux-sunxi] " Chen-Yu Tsai
2015-06-10 7:57 ` Hans de Goede
2015-06-13 13:50 ` Maxime Ripard
2015-06-24 12:18 ` Michal Suchanek
2015-06-10 7:35 ` Lee Jones
2015-06-10 7:36 ` Lee Jones
2015-06-09 21:37 ` [PATCH 3/8] power: Add devm_power_supply_get_by_phandle() helper function Hans de Goede
2015-06-10 14:49 ` Sebastian Reichel
2015-06-09 21:37 ` [PATCH 4/8] power: Add an axp20x-usb-power driver Hans de Goede
2015-06-10 7:29 ` Lee Jones
2015-06-10 9:22 ` Hans de Goede [this message]
2015-06-10 9:34 ` Lee Jones
2015-06-09 21:37 ` [PATCH 5/8] phy-sun4i-usb: Add support for monitoring vbus via a power-supply Hans de Goede
2015-06-09 21:37 ` [PATCH 6/8] ARM: dts: axp209: Add usb_power_supply child node to the ax209 node Hans de Goede
2015-07-31 5:31 ` [linux-sunxi] " Chen-Yu Tsai
2015-07-31 5:51 ` Bruno Prémont
2015-07-31 6:14 ` Chen-Yu Tsai
2015-07-31 6:35 ` Bruno Prémont
2015-07-31 7:57 ` Maxime Ripard
2015-07-31 8:31 ` Hans de Goede
2015-07-31 9:00 ` Chen-Yu Tsai
2015-07-31 9:11 ` Hans de Goede
2015-07-31 10:06 ` Chen-Yu Tsai
2015-07-31 9:14 ` Hans de Goede
2015-06-09 21:38 ` [PATCH 7/8] ARM: dts: sun7i: Add regulator configuration to the bananapi dts file Hans de Goede
2015-06-09 21:38 ` [PATCH 8/8] ARM: dts: sun7i: Enable USB DRC on Bananapi Hans de Goede
2015-06-10 6:15 ` [linux-sunxi] [PATCH 0/8] mfd/power/phy: Add support for otg vbus detection via axp pmic Priit Laes
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=557801B8.5040804@redhat.com \
--to=hdegoede@redhat$(echo .)com \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox