diff mbox

[U-Boot,3/7] sunxi: power: Unify axp pmic function names

Message ID 1443882383-21181-3-git-send-email-hdegoede@redhat.com
State Accepted
Delegated to: Hans de Goede
Headers show

Commit Message

Hans de Goede Oct. 3, 2015, 2:26 p.m. UTC
Stop prefixing the axp functions for setting voltages, etc. with the
model number, there ever is only one pmic driver built into u-boot,
this allows simplifying the callers.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 arch/arm/cpu/armv7/sunxi/cpu_info.c |  4 +--
 arch/arm/cpu/armv7/sunxi/usb_phy.c  |  9 -----
 board/sunxi/board.c                 | 70 +++++++++++++++++--------------------
 drivers/gpio/axp_gpio.c             | 11 +-----
 drivers/power/axp152.c              | 12 +++----
 drivers/power/axp209.c              | 39 +++++----------------
 drivers/power/axp221.c              | 35 +++++++++----------
 drivers/video/sunxi_display.c       |  6 ++--
 include/axp152.h                    |  6 ----
 include/axp209.h                    |  9 -----
 include/axp221.h                    | 16 ---------
 include/axp_pmic.h                  | 37 ++++++++++++++++++++
 12 files changed, 106 insertions(+), 148 deletions(-)
 create mode 100644 include/axp_pmic.h

Comments

Chen-Yu Tsai Oct. 3, 2015, 2:32 p.m. UTC | #1
On Sat, Oct 3, 2015 at 10:26 PM, Hans de Goede <hdegoede@redhat.com> wrote:
> Stop prefixing the axp functions for setting voltages, etc. with the
> model number, there ever is only one pmic driver built into u-boot,
> this allows simplifying the callers.

Hmm... What's going to happen with the A80, which has 2 PMICs? IIRC
a subset of their LDOs share the same name, which would be a problem.

ChenYu

> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
Hans de Goede Oct. 3, 2015, 8:16 p.m. UTC | #2
Hi,

On 03-10-15 16:32, Chen-Yu Tsai wrote:
> On Sat, Oct 3, 2015 at 10:26 PM, Hans de Goede <hdegoede@redhat.com> wrote:
>> Stop prefixing the axp functions for setting voltages, etc. with the
>> model number, there ever is only one pmic driver built into u-boot,
>> this allows simplifying the callers.
>
> Hmm... What's going to happen with the A80, which has 2 PMICs? IIRC
> a subset of their LDOs share the same name, which would be a problem.

My plan for that is to use a different function name for the ldo-s
on the secondary pmic, e.g. something like axp2_set_xldo1(...), or
somesuch. Actually this patch should help adding support for the
other pmics since it will make it less of an #ifdef fest.

Regards,

Hans
Ian Campbell Oct. 9, 2015, 8:31 a.m. UTC | #3
On Sat, 2015-10-03 at 22:16 +0200, Hans de Goede wrote:
> Hi,
> 
> On 03-10-15 16:32, Chen-Yu Tsai wrote:
> > On Sat, Oct 3, 2015 at 10:26 PM, Hans de Goede <hdegoede@redhat.com>
> > wrote:
> > > Stop prefixing the axp functions for setting voltages, etc. with the
> > > model number, there ever is only one pmic driver built into u-boot,
> > > this allows simplifying the callers.
> > 
> > Hmm... What's going to happen with the A80, which has 2 PMICs? IIRC
> > a subset of their LDOs share the same name, which would be a problem.
> 
> My plan for that is to use a different function name for the ldo-s
> on the secondary pmic, e.g. something like axp2_set_xldo1(...), or
> somesuch. Actually this patch should help adding support for the
> other pmics since it will make it less of an #ifdef fest.

Is it going to be (or very likely to be) the case that a given AXPxxx
device will only ever be a primary or a secondary,  but never used as both
(perhaps on different boards)?

Is there some property of these devices which causes them to be only usable
as one or the other?

If there is some possibility of this not being the case then this
unification + my comments on patch #1 might be seen in a different light.

Having a board which uses two of the same AXPxxx device looks like it would
be even more problematic, if such a thing is possible.

Or is the plan to just cross that bridge if/when we get there? (I think I'm
 OK with that).

Ian.
Hans de Goede Oct. 9, 2015, 11:24 a.m. UTC | #4
Hi,

On 09-10-15 10:31, Ian Campbell wrote:
> On Sat, 2015-10-03 at 22:16 +0200, Hans de Goede wrote:
>> Hi,
>>
>> On 03-10-15 16:32, Chen-Yu Tsai wrote:
>>> On Sat, Oct 3, 2015 at 10:26 PM, Hans de Goede <hdegoede@redhat.com>
>>> wrote:
>>>> Stop prefixing the axp functions for setting voltages, etc. with the
>>>> model number, there ever is only one pmic driver built into u-boot,
>>>> this allows simplifying the callers.
>>>
>>> Hmm... What's going to happen with the A80, which has 2 PMICs? IIRC
>>> a subset of their LDOs share the same name, which would be a problem.
>>
>> My plan for that is to use a different function name for the ldo-s
>> on the secondary pmic, e.g. something like axp2_set_xldo1(...), or
>> somesuch. Actually this patch should help adding support for the
>> other pmics since it will make it less of an #ifdef fest.
>
> Is it going to be (or very likely to be) the case that a given AXPxxx
> device will only ever be a primary or a secondary,  but never used as both
> (perhaps on different boards)?

AFAIK that is correct, there are different axp models for primary / secondary
pmics. Some a80 / a83 boards may only use the primary pmic, but using only
the secondary is not really expected.

> Is there some property of these devices which causes them to be only usable
> as one or the other?

No, not really (unless you count things like power-on / power-button handling
which only the primary has AFAIK).

> If there is some possibility of this not being the case then this
> unification + my comments on patch #1 might be seen in a different light.
>
> Having a board which uses two of the same AXPxxx device looks like it would
> be even more problematic, if such a thing is possible.

AFAIK there are no boards which use the same pmic twice.

> Or is the plan to just cross that bridge if/when we get there? (I think I'm
>   OK with that).

Yes that is pretty much the plan :)

Regards,

Hans
Ian Campbell Oct. 9, 2015, 12:41 p.m. UTC | #5
On Fri, 2015-10-09 at 13:24 +0200, Hans de Goede wrote:
> Hi,
> 
> On 09-10-15 10:31, Ian Campbell wrote:
> > On Sat, 2015-10-03 at 22:16 +0200, Hans de Goede wrote:
> > > Hi,
> > > 
> > > On 03-10-15 16:32, Chen-Yu Tsai wrote:
> > > > On Sat, Oct 3, 2015 at 10:26 PM, Hans de Goede <hdegoede@redhat.com
> > > > >
> > > > wrote:
> > > > > Stop prefixing the axp functions for setting voltages, etc. with
> > > > > the
> > > > > model number, there ever is only one pmic driver built into u
> > > > > -boot,
> > > > > this allows simplifying the callers.
> > > > 
> > > > Hmm... What's going to happen with the A80, which has 2 PMICs? IIRC
> > > > a subset of their LDOs share the same name, which would be a
> > > > problem.
> > > 
> > > My plan for that is to use a different function name for the ldo-s
> > > on the secondary pmic, e.g. something like axp2_set_xldo1(...), or
> > > somesuch. Actually this patch should help adding support for the
> > > other pmics since it will make it less of an #ifdef fest.
> > 
> > Is it going to be (or very likely to be) the case that a given AXPxxx
> > device will only ever be a primary or a secondary,  but never used as
> > both
> > (perhaps on different boards)?
> 
> AFAIK that is correct, there are different axp models for primary / secondary
> pmics.

OK, that makes sense, but then this:

>  Some a80 / a83 boards may only use the primary pmic, but using only
> the secondary is not really expected.

... makes me want to clarify, since I understand that having a secondary
but not a primary would be rather strange and wasn't what I was getting at.

What I meant was for a given AXPxxx is that model only ever either used as
a primary _or_ used as a secondary (with some other AXPabc as the primary).
I think your answer further above is telling me that yes, a given AXPxxx is
either designed (and used) as a primary or a secondary.

From the patch #1 discussion (since it is predicated on the above and
splitting the conversation in two will probably just get confusing):

> > ... these three ought to be inside a choice?
> 
> I was thinking the same, but on A80 boards there are 2
> different axp chips, so if we make this a choice now we
> just end up needing to revert this when we get full A80 support.

But one of those would be a primary and the other a secondary, and as
discussed above (as I currently understand it at least) each
CONFIG_AXPxxx_POWER can be a primary XOR a secondary.

In which case what we would want is a set of choice options for primary and
a separate set choice options for secondary (with a none option too in this
case) and there would be no duplication of any specific AXPxxx option
between both the primary and secondary sets.

Ian.
Hans de Goede Oct. 9, 2015, 1:44 p.m. UTC | #6
Hi,

On 09-10-15 14:41, Ian Campbell wrote:
> On Fri, 2015-10-09 at 13:24 +0200, Hans de Goede wrote:
>> Hi,
>>
>> On 09-10-15 10:31, Ian Campbell wrote:
>>> On Sat, 2015-10-03 at 22:16 +0200, Hans de Goede wrote:
>>>> Hi,
>>>>
>>>> On 03-10-15 16:32, Chen-Yu Tsai wrote:
>>>>> On Sat, Oct 3, 2015 at 10:26 PM, Hans de Goede <hdegoede@redhat.com
>>>>>>
>>>>> wrote:
>>>>>> Stop prefixing the axp functions for setting voltages, etc. with
>>>>>> the
>>>>>> model number, there ever is only one pmic driver built into u
>>>>>> -boot,
>>>>>> this allows simplifying the callers.
>>>>>
>>>>> Hmm... What's going to happen with the A80, which has 2 PMICs? IIRC
>>>>> a subset of their LDOs share the same name, which would be a
>>>>> problem.
>>>>
>>>> My plan for that is to use a different function name for the ldo-s
>>>> on the secondary pmic, e.g. something like axp2_set_xldo1(...), or
>>>> somesuch. Actually this patch should help adding support for the
>>>> other pmics since it will make it less of an #ifdef fest.
>>>
>>> Is it going to be (or very likely to be) the case that a given AXPxxx
>>> device will only ever be a primary or a secondary,  but never used as
>>> both
>>> (perhaps on different boards)?
>>
>> AFAIK that is correct, there are different axp models for primary / secondary
>> pmics.
>
> OK, that makes sense, but then this:
>
>>   Some a80 / a83 boards may only use the primary pmic, but using only
>> the secondary is not really expected.
>
> ... makes me want to clarify, since I understand that having a secondary
> but not a primary would be rather strange and wasn't what I was getting at.
>
> What I meant was for a given AXPxxx is that model only ever either used as
> a primary _or_ used as a secondary (with some other AXPabc as the primary).
> I think your answer further above is telling me that yes, a given AXPxxx is
> either designed (and used) as a primary or a secondary.
>
>  From the patch #1 discussion (since it is predicated on the above and
> splitting the conversation in two will probably just get confusing):
>
>>> ... these three ought to be inside a choice?
>>
>> I was thinking the same, but on A80 boards there are 2
>> different axp chips, so if we make this a choice now we
>> just end up needing to revert this when we get full A80 support.
>
> But one of those would be a primary and the other a secondary, and as
> discussed above (as I currently understand it at least) each
> CONFIG_AXPxxx_POWER can be a primary XOR a secondary.
>
> In which case what we would want is a set of choice options for primary and
> a separate set choice options for secondary (with a none option too in this
> case) and there would be no duplication of any specific AXPxxx option
> between both the primary and secondary sets.

Ah Yes, from what we now know / expect about how things will work on
boards with 2 pmics that is correct. I'll respin the first patch to change
things into a choice including a none option.

Regards,

Hans
Ian Campbell Oct. 9, 2015, 2:24 p.m. UTC | #7
On Fri, 2015-10-09 at 15:44 +0200, Hans de Goede wrote:

> > In which case what we would want is a set of choice options for primary and
> > a separate set choice options for secondary (with a none option too in this
> > case) and there would be no duplication of any specific AXPxxx option
> > between both the primary and secondary sets.
> 
> Ah Yes, from what we now know / expect about how things will work on
> boards with 2 pmics that is correct. I'll respin the first patch to change
> things into a choice including a none option.

Do we need a "none" option for the primary case?
Chen-Yu Tsai Oct. 9, 2015, 2:49 p.m. UTC | #8
Hi,

On Fri, Oct 9, 2015 at 8:41 PM, Ian Campbell <ijc+uboot@hellion.org.uk> wrote:
> On Fri, 2015-10-09 at 13:24 +0200, Hans de Goede wrote:
>> Hi,
>>
>> On 09-10-15 10:31, Ian Campbell wrote:
>> > On Sat, 2015-10-03 at 22:16 +0200, Hans de Goede wrote:
>> > > Hi,
>> > >
>> > > On 03-10-15 16:32, Chen-Yu Tsai wrote:
>> > > > On Sat, Oct 3, 2015 at 10:26 PM, Hans de Goede <hdegoede@redhat.com
>> > > > >
>> > > > wrote:
>> > > > > Stop prefixing the axp functions for setting voltages, etc. with
>> > > > > the
>> > > > > model number, there ever is only one pmic driver built into u
>> > > > > -boot,
>> > > > > this allows simplifying the callers.
>> > > >
>> > > > Hmm... What's going to happen with the A80, which has 2 PMICs? IIRC
>> > > > a subset of their LDOs share the same name, which would be a
>> > > > problem.
>> > >
>> > > My plan for that is to use a different function name for the ldo-s
>> > > on the secondary pmic, e.g. something like axp2_set_xldo1(...), or
>> > > somesuch. Actually this patch should help adding support for the
>> > > other pmics since it will make it less of an #ifdef fest.
>> >
>> > Is it going to be (or very likely to be) the case that a given AXPxxx
>> > device will only ever be a primary or a secondary,  but never used as
>> > both
>> > (perhaps on different boards)?
>>
>> AFAIK that is correct, there are different axp models for primary / secondary
>> pmics.
>
> OK, that makes sense, but then this:
>
>>  Some a80 / a83 boards may only use the primary pmic, but using only
>> the secondary is not really expected.
>
> ... makes me want to clarify, since I understand that having a secondary
> but not a primary would be rather strange and wasn't what I was getting at.
>
> What I meant was for a given AXPxxx is that model only ever either used as
> a primary _or_ used as a secondary (with some other AXPabc as the primary).
> I think your answer further above is telling me that yes, a given AXPxxx is
> either designed (and used) as a primary or a secondary.

Only the AXP806 is multi-role, i.e. can be primary or secondary. All the
others that we know of, excluding the AXP818 for which we have no docs,
are standalone PMICs.

And a system can also have multiple AXP806s, even on the same bus. This
is supported by some address extension register.

Having said the above, I really don't expect to see these kinds of designs
in the wild.

> From the patch #1 discussion (since it is predicated on the above and
> splitting the conversation in two will probably just get confusing):
>
>> > ... these three ought to be inside a choice?
>>
>> I was thinking the same, but on A80 boards there are 2
>> different axp chips, so if we make this a choice now we
>> just end up needing to revert this when we get full A80 support.
>
> But one of those would be a primary and the other a secondary, and as
> discussed above (as I currently understand it at least) each
> CONFIG_AXPxxx_POWER can be a primary XOR a secondary.
>
> In which case what we would want is a set of choice options for primary and
> a separate set choice options for secondary (with a none option too in this
> case) and there would be no duplication of any specific AXPxxx option
> between both the primary and secondary sets.

AFAIK, all the AXPs except AXP806 belong in the primary list. The secondary
set should only have AXP806, at least until Allwinner delivers some Cortex-A57
or Cortex-A72 design that needs the extra power of a secondary PMIC.

Regards
ChenYu
Ian Campbell Oct. 11, 2015, 11:14 a.m. UTC | #9
On Sat, 2015-10-03 at 16:26 +0200, Hans de Goede wrote:
> Stop prefixing the axp functions for setting voltages, etc. with the
> model number, there ever is only one pmic driver built into u-boot,
> this allows simplifying the callers.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Acked-by: Ian Campbell <ijc@hellion.org.uk>

@@ -1217,10 +1217,10 @@ static void sunxi_mode_set(const struct
> ctfb_res_modes *mode,
>  > 	> 	> if (IS_ENABLED(CONFIG_VIDEO_LCD_PANEL_EDP_4_LANE_1620M_VIA_ANX9804)) {
>  > 	> 	> 	> /*
>  > 	> 	> 	>  * The anx9804 needs 1.8V from eldo3, we do this here
> -> 	> 	> 	>  * and not via CONFIG_AXP221_ELDO3 from board_init()
> +> 	> 	> 	>  * and not via CONFIG_AXP_ELDO3_VOLT from board_init()

I think strictly speaking that hunk belonged in a previous patch, but
nevermind (or feel to retain acks on both if you want to move it).

Ian.
diff mbox

Patch

diff --git a/arch/arm/cpu/armv7/sunxi/cpu_info.c b/arch/arm/cpu/armv7/sunxi/cpu_info.c
index a276fad..05fef32 100644
--- a/arch/arm/cpu/armv7/sunxi/cpu_info.c
+++ b/arch/arm/cpu/armv7/sunxi/cpu_info.c
@@ -10,7 +10,7 @@ 
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/clock.h>
-#include <axp221.h>
+#include <axp_pmic.h>
 #include <errno.h>
 
 #ifdef CONFIG_MACH_SUN6I
@@ -82,7 +82,7 @@  int print_cpuinfo(void)
 int sunxi_get_sid(unsigned int *sid)
 {
 #ifdef CONFIG_AXP221_POWER
-	return axp221_get_sid(sid);
+	return axp_get_sid(sid);
 #elif defined SUNXI_SID_BASE
 	int i;
 
diff --git a/arch/arm/cpu/armv7/sunxi/usb_phy.c b/arch/arm/cpu/armv7/sunxi/usb_phy.c
index b7ca5d4..19bb5a1 100644
--- a/arch/arm/cpu/armv7/sunxi/usb_phy.c
+++ b/arch/arm/cpu/armv7/sunxi/usb_phy.c
@@ -17,15 +17,6 @@ 
 #include <asm/gpio.h>
 #include <asm/io.h>
 #include <errno.h>
-#ifdef CONFIG_AXP152_POWER
-#include <axp152.h>
-#endif
-#ifdef CONFIG_AXP209_POWER
-#include <axp209.h>
-#endif
-#ifdef CONFIG_AXP221_POWER
-#include <axp221.h>
-#endif
 
 #define SUNXI_USB_PMU_IRQ_ENABLE	0x800
 #ifdef CONFIG_MACH_SUN8I_A33
diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index bc0376b..e99b2ba 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -13,15 +13,7 @@ 
 
 #include <common.h>
 #include <mmc.h>
-#ifdef CONFIG_AXP152_POWER
-#include <axp152.h>
-#endif
-#ifdef CONFIG_AXP209_POWER
-#include <axp209.h>
-#endif
-#ifdef CONFIG_AXP221_POWER
-#include <axp221.h>
-#endif
+#include <axp_pmic.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/display.h>
@@ -442,40 +434,42 @@  void sunxi_board_init(void)
 	int power_failed = 0;
 	unsigned long ramsize;
 
-#ifdef CONFIG_AXP152_POWER
-	power_failed = axp152_init();
-	power_failed |= axp152_set_dcdc2(CONFIG_AXP_DCDC2_VOLT);
-	power_failed |= axp152_set_dcdc3(CONFIG_AXP_DCDC3_VOLT);
-	power_failed |= axp152_set_dcdc4(CONFIG_AXP_DCDC4_VOLT);
-	power_failed |= axp152_set_ldo2(CONFIG_AXP_ALDO2_VOLT);
+#if defined CONFIG_AXP152_POWER || defined CONFIG_AXP209_POWER || defined CONFIG_AXP221_POWER
+	power_failed = axp_init();
+
+#ifdef CONFIG_AXP221_POWER
+	power_failed |= axp_set_dcdc1(CONFIG_AXP_DCDC1_VOLT);
 #endif
-#ifdef CONFIG_AXP209_POWER
-	power_failed |= axp209_init();
-	power_failed |= axp209_set_dcdc2(CONFIG_AXP_DCDC2_VOLT);
-	power_failed |= axp209_set_dcdc3(CONFIG_AXP_DCDC3_VOLT);
-	power_failed |= axp209_set_ldo2(CONFIG_AXP_ALDO2_VOLT);
-	power_failed |= axp209_set_ldo3(CONFIG_AXP_ALDO3_VOLT);
-	power_failed |= axp209_set_ldo4(CONFIG_AXP_ALDO4_VOLT);
+	power_failed |= axp_set_dcdc2(CONFIG_AXP_DCDC2_VOLT);
+	power_failed |= axp_set_dcdc3(CONFIG_AXP_DCDC3_VOLT);
+#ifndef CONFIG_AXP209_POWER
+	power_failed |= axp_set_dcdc4(CONFIG_AXP_DCDC4_VOLT);
 #endif
 #ifdef CONFIG_AXP221_POWER
-	power_failed = axp221_init();
-	power_failed |= axp221_set_dcdc1(CONFIG_AXP_DCDC1_VOLT);
-	power_failed |= axp221_set_dcdc2(CONFIG_AXP_DCDC2_VOLT);
-	power_failed |= axp221_set_dcdc3(CONFIG_AXP_DCDC3_VOLT);
-	power_failed |= axp221_set_dcdc4(CONFIG_AXP_DCDC4_VOLT);
-	power_failed |= axp221_set_dcdc5(CONFIG_AXP_DCDC5_VOLT);
-	power_failed |= axp221_set_aldo1(CONFIG_AXP_ALDO1_VOLT);
-	power_failed |= axp221_set_aldo2(CONFIG_AXP_ALDO2_VOLT);
-	power_failed |= axp221_set_aldo3(CONFIG_AXP_ALDO3_VOLT);
-	power_failed |= axp221_set_dldo1(CONFIG_AXP_DLDO1_VOLT);
-	power_failed |= axp221_set_dldo2(CONFIG_AXP_DLDO2_VOLT);
-	power_failed |= axp221_set_dldo3(CONFIG_AXP_DLDO3_VOLT);
-	power_failed |= axp221_set_dldo4(CONFIG_AXP_DLDO4_VOLT);
-	power_failed |= axp221_set_eldo(1, CONFIG_AXP_ELDO1_VOLT);
-	power_failed |= axp221_set_eldo(2, CONFIG_AXP_ELDO2_VOLT);
-	power_failed |= axp221_set_eldo(3, CONFIG_AXP_ELDO3_VOLT);
+	power_failed |= axp_set_dcdc5(CONFIG_AXP_DCDC5_VOLT);
 #endif
 
+#ifdef CONFIG_AXP221_POWER
+	power_failed |= axp_set_aldo1(CONFIG_AXP_ALDO1_VOLT);
+#endif
+	power_failed |= axp_set_aldo2(CONFIG_AXP_ALDO2_VOLT);
+#ifndef CONFIG_AXP152_POWER
+	power_failed |= axp_set_aldo3(CONFIG_AXP_ALDO3_VOLT);
+#endif
+#ifdef CONFIG_AXP209_POWER
+	power_failed |= axp_set_aldo4(CONFIG_AXP_ALDO4_VOLT);
+#endif
+
+#ifdef CONFIG_AXP221_POWER
+	power_failed |= axp_set_dldo1(CONFIG_AXP_DLDO1_VOLT);
+	power_failed |= axp_set_dldo2(CONFIG_AXP_DLDO2_VOLT);
+	power_failed |= axp_set_dldo3(CONFIG_AXP_DLDO3_VOLT);
+	power_failed |= axp_set_dldo4(CONFIG_AXP_DLDO4_VOLT);
+	power_failed |= axp_set_eldo(1, CONFIG_AXP_ELDO1_VOLT);
+	power_failed |= axp_set_eldo(2, CONFIG_AXP_ELDO2_VOLT);
+	power_failed |= axp_set_eldo(3, CONFIG_AXP_ELDO3_VOLT);
+#endif
+#endif
 	printf("DRAM:");
 	ramsize = sunxi_dram_init();
 	printf(" %lu MiB\n", ramsize >> 20);
diff --git a/drivers/gpio/axp_gpio.c b/drivers/gpio/axp_gpio.c
index 2e97cc3..bd2ac89 100644
--- a/drivers/gpio/axp_gpio.c
+++ b/drivers/gpio/axp_gpio.c
@@ -10,22 +10,13 @@ 
 #include <asm/arch/gpio.h>
 #include <asm/arch/pmic_bus.h>
 #include <asm/gpio.h>
+#include <axp_pmic.h>
 #include <dm.h>
 #include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <dm/root.h>
 #include <errno.h>
 
-#ifdef CONFIG_AXP152_POWER
-#include <axp152.h>
-#elif defined CONFIG_AXP209_POWER
-#include <axp209.h>
-#elif defined CONFIG_AXP221_POWER
-#include <axp221.h>
-#else
-#error Unknown AXP model
-#endif
-
 static int axp_gpio_set_value(struct udevice *dev, unsigned pin, int val);
 
 static u8 axp_get_gpio_ctrl_reg(unsigned pin)
diff --git a/drivers/power/axp152.c b/drivers/power/axp152.c
index 740a3b4..c60e4d3 100644
--- a/drivers/power/axp152.c
+++ b/drivers/power/axp152.c
@@ -6,7 +6,7 @@ 
  */
 #include <common.h>
 #include <i2c.h>
-#include <axp152.h>
+#include <axp_pmic.h>
 
 static int axp152_write(enum axp152_reg reg, u8 val)
 {
@@ -28,7 +28,7 @@  static u8 axp152_mvolt_to_target(int mvolt, int min, int max, int div)
 	return (mvolt - min) / div;
 }
 
-int axp152_set_dcdc2(int mvolt)
+int axp_set_dcdc2(unsigned int mvolt)
 {
 	int rc;
 	u8 current, target;
@@ -49,28 +49,28 @@  int axp152_set_dcdc2(int mvolt)
 	return rc;
 }
 
-int axp152_set_dcdc3(int mvolt)
+int axp_set_dcdc3(unsigned int mvolt)
 {
 	u8 target = axp152_mvolt_to_target(mvolt, 700, 3500, 50);
 
 	return axp152_write(AXP152_DCDC3_VOLTAGE, target);
 }
 
-int axp152_set_dcdc4(int mvolt)
+int axp_set_dcdc4(unsigned int mvolt)
 {
 	u8 target = axp152_mvolt_to_target(mvolt, 700, 3500, 25);
 
 	return axp152_write(AXP152_DCDC4_VOLTAGE, target);
 }
 
-int axp152_set_ldo2(int mvolt)
+int axp_set_aldo2(unsigned int mvolt)
 {
 	u8 target = axp152_mvolt_to_target(mvolt, 700, 3500, 100);
 
 	return axp152_write(AXP152_LDO2_VOLTAGE, target);
 }
 
-int axp152_init(void)
+int axp_init(void)
 {
 	u8 ver;
 	int rc;
diff --git a/drivers/power/axp209.c b/drivers/power/axp209.c
index 5161bc1..91c35fa 100644
--- a/drivers/power/axp209.c
+++ b/drivers/power/axp209.c
@@ -7,8 +7,7 @@ 
 
 #include <common.h>
 #include <i2c.h>
-#include <asm/arch/gpio.h>
-#include <axp209.h>
+#include <axp_pmic.h>
 
 static int axp209_write(enum axp209_reg reg, u8 val)
 {
@@ -30,7 +29,7 @@  static u8 axp209_mvolt_to_cfg(int mvolt, int min, int max, int div)
 	return (mvolt - min) / div;
 }
 
-int axp209_set_dcdc2(int mvolt)
+int axp_set_dcdc2(unsigned int mvolt)
 {
 	int rc;
 	u8 cfg, current;
@@ -53,14 +52,14 @@  int axp209_set_dcdc2(int mvolt)
 	return rc;
 }
 
-int axp209_set_dcdc3(int mvolt)
+int axp_set_dcdc3(unsigned int mvolt)
 {
 	u8 cfg = axp209_mvolt_to_cfg(mvolt, 700, 3500, 25);
 
 	return axp209_write(AXP209_DCDC3_VOLTAGE, cfg);
 }
 
-int axp209_set_ldo2(int mvolt)
+int axp_set_aldo2(unsigned int mvolt)
 {
 	int rc;
 	u8 cfg, reg;
@@ -76,7 +75,7 @@  int axp209_set_ldo2(int mvolt)
 	return axp209_write(AXP209_LDO24_VOLTAGE, reg);
 }
 
-int axp209_set_ldo3(int mvolt)
+int axp_set_aldo3(unsigned int mvolt)
 {
 	u8 cfg;
 
@@ -88,10 +87,10 @@  int axp209_set_ldo3(int mvolt)
 	return axp209_write(AXP209_LDO3_VOLTAGE, cfg);
 }
 
-int axp209_set_ldo4(int mvolt)
+int axp_set_aldo4(unsigned int mvolt)
 {
 	int rc;
-	static const int vindex[] = {
+	static const unsigned int vindex[] = {
 		1250, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2500,
 		2700, 2800, 3000, 3100, 3200, 3300
 	};
@@ -109,7 +108,7 @@  int axp209_set_ldo4(int mvolt)
 	return axp209_write(AXP209_LDO24_VOLTAGE, reg);
 }
 
-int axp209_init(void)
+int axp_init(void)
 {
 	u8 ver;
 	int i, rc;
@@ -133,25 +132,3 @@  int axp209_init(void)
 
 	return 0;
 }
-
-int axp209_poweron_by_dc(void)
-{
-	u8 v;
-
-	if (axp209_read(AXP209_POWER_STATUS, &v))
-		return 0;
-
-	return (v & AXP209_POWER_STATUS_ON_BY_DC);
-}
-
-int axp209_power_button(void)
-{
-	u8 v;
-
-	if (axp209_read(AXP209_IRQ_STATUS5, &v))
-		return 0;
-
-	axp209_write(AXP209_IRQ_STATUS5, AXP209_IRQ5_PEK_DOWN);
-
-	return v & AXP209_IRQ5_PEK_DOWN;
-}
diff --git a/drivers/power/axp221.c b/drivers/power/axp221.c
index 7bbaec8..d621f2a 100644
--- a/drivers/power/axp221.c
+++ b/drivers/power/axp221.c
@@ -12,9 +12,8 @@ 
 
 #include <common.h>
 #include <errno.h>
-#include <asm/arch/gpio.h>
 #include <asm/arch/pmic_bus.h>
-#include <axp221.h>
+#include <axp_pmic.h>
 
 static u8 axp221_mvolt_to_cfg(int mvolt, int min, int max, int div)
 {
@@ -26,7 +25,7 @@  static u8 axp221_mvolt_to_cfg(int mvolt, int min, int max, int div)
 	return (mvolt - min) / div;
 }
 
-int axp221_set_dcdc1(unsigned int mvolt)
+int axp_set_dcdc1(unsigned int mvolt)
 {
 	int ret;
 	u8 cfg = axp221_mvolt_to_cfg(mvolt, 1600, 3400, 100);
@@ -48,7 +47,7 @@  int axp221_set_dcdc1(unsigned int mvolt)
 				AXP221_OUTPUT_CTRL1_DCDC1_EN);
 }
 
-int axp221_set_dcdc2(unsigned int mvolt)
+int axp_set_dcdc2(unsigned int mvolt)
 {
 	int ret;
 	u8 cfg = axp221_mvolt_to_cfg(mvolt, 600, 1540, 20);
@@ -65,7 +64,7 @@  int axp221_set_dcdc2(unsigned int mvolt)
 				AXP221_OUTPUT_CTRL1_DCDC2_EN);
 }
 
-int axp221_set_dcdc3(unsigned int mvolt)
+int axp_set_dcdc3(unsigned int mvolt)
 {
 	int ret;
 	u8 cfg = axp221_mvolt_to_cfg(mvolt, 600, 1860, 20);
@@ -82,7 +81,7 @@  int axp221_set_dcdc3(unsigned int mvolt)
 				AXP221_OUTPUT_CTRL1_DCDC3_EN);
 }
 
-int axp221_set_dcdc4(unsigned int mvolt)
+int axp_set_dcdc4(unsigned int mvolt)
 {
 	int ret;
 	u8 cfg = axp221_mvolt_to_cfg(mvolt, 600, 1540, 20);
@@ -99,7 +98,7 @@  int axp221_set_dcdc4(unsigned int mvolt)
 				AXP221_OUTPUT_CTRL1_DCDC4_EN);
 }
 
-int axp221_set_dcdc5(unsigned int mvolt)
+int axp_set_dcdc5(unsigned int mvolt)
 {
 	int ret;
 	u8 cfg = axp221_mvolt_to_cfg(mvolt, 1000, 2550, 50);
@@ -116,7 +115,7 @@  int axp221_set_dcdc5(unsigned int mvolt)
 				AXP221_OUTPUT_CTRL1_DCDC5_EN);
 }
 
-int axp221_set_dldo1(unsigned int mvolt)
+int axp_set_dldo1(unsigned int mvolt)
 {
 	int ret;
 	u8 cfg = axp221_mvolt_to_cfg(mvolt, 700, 3300, 100);
@@ -133,7 +132,7 @@  int axp221_set_dldo1(unsigned int mvolt)
 				AXP221_OUTPUT_CTRL2_DLDO1_EN);
 }
 
-int axp221_set_dldo2(unsigned int mvolt)
+int axp_set_dldo2(unsigned int mvolt)
 {
 	int ret;
 	u8 cfg = axp221_mvolt_to_cfg(mvolt, 700, 3300, 100);
@@ -150,7 +149,7 @@  int axp221_set_dldo2(unsigned int mvolt)
 				AXP221_OUTPUT_CTRL2_DLDO2_EN);
 }
 
-int axp221_set_dldo3(unsigned int mvolt)
+int axp_set_dldo3(unsigned int mvolt)
 {
 	int ret;
 	u8 cfg = axp221_mvolt_to_cfg(mvolt, 700, 3300, 100);
@@ -167,7 +166,7 @@  int axp221_set_dldo3(unsigned int mvolt)
 				AXP221_OUTPUT_CTRL2_DLDO3_EN);
 }
 
-int axp221_set_dldo4(unsigned int mvolt)
+int axp_set_dldo4(unsigned int mvolt)
 {
 	int ret;
 	u8 cfg = axp221_mvolt_to_cfg(mvolt, 700, 3300, 100);
@@ -184,7 +183,7 @@  int axp221_set_dldo4(unsigned int mvolt)
 				AXP221_OUTPUT_CTRL2_DLDO4_EN);
 }
 
-int axp221_set_aldo1(unsigned int mvolt)
+int axp_set_aldo1(unsigned int mvolt)
 {
 	int ret;
 	u8 cfg = axp221_mvolt_to_cfg(mvolt, 700, 3300, 100);
@@ -201,7 +200,7 @@  int axp221_set_aldo1(unsigned int mvolt)
 				AXP221_OUTPUT_CTRL1_ALDO1_EN);
 }
 
-int axp221_set_aldo2(unsigned int mvolt)
+int axp_set_aldo2(unsigned int mvolt)
 {
 	int ret;
 	u8 cfg = axp221_mvolt_to_cfg(mvolt, 700, 3300, 100);
@@ -218,7 +217,7 @@  int axp221_set_aldo2(unsigned int mvolt)
 				AXP221_OUTPUT_CTRL1_ALDO2_EN);
 }
 
-int axp221_set_aldo3(unsigned int mvolt)
+int axp_set_aldo3(unsigned int mvolt)
 {
 	int ret;
 	u8 cfg = axp221_mvolt_to_cfg(mvolt, 700, 3300, 100);
@@ -235,7 +234,7 @@  int axp221_set_aldo3(unsigned int mvolt)
 				AXP221_OUTPUT_CTRL3_ALDO3_EN);
 }
 
-int axp221_set_eldo(int eldo_num, unsigned int mvolt)
+int axp_set_eldo(int eldo_num, unsigned int mvolt)
 {
 	int ret;
 	u8 cfg = axp221_mvolt_to_cfg(mvolt, 700, 3300, 100);
@@ -268,7 +267,7 @@  int axp221_set_eldo(int eldo_num, unsigned int mvolt)
 	return pmic_bus_setbits(AXP221_OUTPUT_CTRL2, bits);
 }
 
-int axp221_init(void)
+int axp_init(void)
 {
 	/* This cannot be 0 because it is used in SPL before BSS is ready */
 	static int needs_init = 1;
@@ -293,12 +292,12 @@  int axp221_init(void)
 	return 0;
 }
 
-int axp221_get_sid(unsigned int *sid)
+int axp_get_sid(unsigned int *sid)
 {
 	u8 *dest = (u8 *)sid;
 	int i, ret;
 
-	ret = axp221_init();
+	ret = pmic_bus_init();
 	if (ret)
 		return ret;
 
diff --git a/drivers/video/sunxi_display.c b/drivers/video/sunxi_display.c
index fc1aea3..9fee66a 100644
--- a/drivers/video/sunxi_display.c
+++ b/drivers/video/sunxi_display.c
@@ -15,7 +15,7 @@ 
 #include <asm/global_data.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
-#include <axp221.h>
+#include <axp_pmic.h>
 #include <errno.h>
 #include <fdtdec.h>
 #include <fdt_support.h>
@@ -1217,10 +1217,10 @@  static void sunxi_mode_set(const struct ctfb_res_modes *mode,
 		if (IS_ENABLED(CONFIG_VIDEO_LCD_PANEL_EDP_4_LANE_1620M_VIA_ANX9804)) {
 			/*
 			 * The anx9804 needs 1.8V from eldo3, we do this here
-			 * and not via CONFIG_AXP221_ELDO3 from board_init()
+			 * and not via CONFIG_AXP_ELDO3_VOLT from board_init()
 			 * to avoid turning this on when using hdmi output.
 			 */
-			axp221_set_eldo(3, 1800);
+			axp_set_eldo(3, 1800);
 			anx9804_init(CONFIG_VIDEO_LCD_I2C_BUS, 4,
 				     ANX9804_DATA_RATE_1620M,
 				     sunxi_display.depth);
diff --git a/include/axp152.h b/include/axp152.h
index c3aef77..1643266 100644
--- a/include/axp152.h
+++ b/include/axp152.h
@@ -25,9 +25,3 @@  enum axp152_reg {
 #define AXP_GPIO_CTRL_INPUT			0x02 /* Input */
 #define AXP_GPIO_STATE			0x97
 #define AXP_GPIO_STATE_OFFSET			0
-
-int axp152_set_dcdc2(int mvolt);
-int axp152_set_dcdc3(int mvolt);
-int axp152_set_dcdc4(int mvolt);
-int axp152_set_ldo2(int mvolt);
-int axp152_init(void);
diff --git a/include/axp209.h b/include/axp209.h
index 6170202..13aa66c 100644
--- a/include/axp209.h
+++ b/include/axp209.h
@@ -39,12 +39,3 @@  enum axp209_reg {
 #define AXP_GPIO_CTRL_INPUT			0x02 /* Input */
 #define AXP_GPIO_STATE			0x94
 #define AXP_GPIO_STATE_OFFSET			4
-
-extern int axp209_set_dcdc2(int mvolt);
-extern int axp209_set_dcdc3(int mvolt);
-extern int axp209_set_ldo2(int mvolt);
-extern int axp209_set_ldo3(int mvolt);
-extern int axp209_set_ldo4(int mvolt);
-extern int axp209_init(void);
-extern int axp209_poweron_by_dc(void);
-extern int axp209_power_button(void);
diff --git a/include/axp221.h b/include/axp221.h
index 9c87162..0ee21b6 100644
--- a/include/axp221.h
+++ b/include/axp221.h
@@ -62,19 +62,3 @@ 
 #define AXP_GPIO_CTRL_INPUT			0x02 /* Input */
 #define AXP_GPIO_STATE			0x94
 #define AXP_GPIO_STATE_OFFSET			0
-
-int axp221_set_dcdc1(unsigned int mvolt);
-int axp221_set_dcdc2(unsigned int mvolt);
-int axp221_set_dcdc3(unsigned int mvolt);
-int axp221_set_dcdc4(unsigned int mvolt);
-int axp221_set_dcdc5(unsigned int mvolt);
-int axp221_set_dldo1(unsigned int mvolt);
-int axp221_set_dldo2(unsigned int mvolt);
-int axp221_set_dldo3(unsigned int mvolt);
-int axp221_set_dldo4(unsigned int mvolt);
-int axp221_set_aldo1(unsigned int mvolt);
-int axp221_set_aldo2(unsigned int mvolt);
-int axp221_set_aldo3(unsigned int mvolt);
-int axp221_set_eldo(int eldo_num, unsigned int mvolt);
-int axp221_init(void);
-int axp221_get_sid(unsigned int *sid);
diff --git a/include/axp_pmic.h b/include/axp_pmic.h
new file mode 100644
index 0000000..ef339c4
--- /dev/null
+++ b/include/axp_pmic.h
@@ -0,0 +1,37 @@ 
+/*
+ * (C) Copyright 2015 Hans de Goede <hdegoede@redhat.com>
+ *
+ * X-Powers AX Power Management IC support header
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#ifndef _AXP_PMIC_H_
+
+#ifdef CONFIG_AXP152_POWER
+#include <axp152.h>
+#endif
+#ifdef CONFIG_AXP209_POWER
+#include <axp209.h>
+#endif
+#ifdef CONFIG_AXP221_POWER
+#include <axp221.h>
+#endif
+
+int axp_set_dcdc1(unsigned int mvolt);
+int axp_set_dcdc2(unsigned int mvolt);
+int axp_set_dcdc3(unsigned int mvolt);
+int axp_set_dcdc4(unsigned int mvolt);
+int axp_set_dcdc5(unsigned int mvolt);
+int axp_set_aldo1(unsigned int mvolt);
+int axp_set_aldo2(unsigned int mvolt);
+int axp_set_aldo3(unsigned int mvolt);
+int axp_set_aldo4(unsigned int mvolt);
+int axp_set_dldo1(unsigned int mvolt);
+int axp_set_dldo2(unsigned int mvolt);
+int axp_set_dldo3(unsigned int mvolt);
+int axp_set_dldo4(unsigned int mvolt);
+int axp_set_eldo(int eldo_num, unsigned int mvolt);
+int axp_init(void);
+int axp_get_sid(unsigned int *sid);
+
+#endif