Re: [U-Boot] [PATCH v2 3/6] sunxi: axp: Add support for i2c based PMICs to the pmic-bus helpers

2015-05-02 Thread Ian Campbell
On Sun, 2015-04-26 at 11:51 +0200, Hans de Goede wrote:
> Add support for the axp152 and axp209 PMICs to the pmic register access
> helpers. This is a preparation patch for moving the axp gpio code to a
> separate gpio driver.
> 
> Signed-off-by: Hans de Goede 

Acked-by: Ian Campbell 


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 3/6] sunxi: axp: Add support for i2c based PMICs to the pmic-bus helpers

2015-04-27 Thread Simon Glass
On 26 April 2015 at 03:51, Hans de Goede  wrote:
> Add support for the axp152 and axp209 PMICs to the pmic register access
> helpers. This is a preparation patch for moving the axp gpio code to a
> separate gpio driver.
>
> Signed-off-by: Hans de Goede 
> ---
>  arch/arm/cpu/armv7/sunxi/Makefile   |  2 ++
>  arch/arm/cpu/armv7/sunxi/pmic_bus.c | 35 +++
>  2 files changed, 29 insertions(+), 8 deletions(-)

Reviewed-by: Simon Glass 
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v2 3/6] sunxi: axp: Add support for i2c based PMICs to the pmic-bus helpers

2015-04-26 Thread Hans de Goede
Add support for the axp152 and axp209 PMICs to the pmic register access
helpers. This is a preparation patch for moving the axp gpio code to a
separate gpio driver.

Signed-off-by: Hans de Goede 
---
 arch/arm/cpu/armv7/sunxi/Makefile   |  2 ++
 arch/arm/cpu/armv7/sunxi/pmic_bus.c | 35 +++
 2 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/arch/arm/cpu/armv7/sunxi/Makefile 
b/arch/arm/cpu/armv7/sunxi/Makefile
index 50791e0..5221902 100644
--- a/arch/arm/cpu/armv7/sunxi/Makefile
+++ b/arch/arm/cpu/armv7/sunxi/Makefile
@@ -32,6 +32,8 @@ obj-$(CONFIG_MACH_SUN8I_A23)  += clock_sun6i.o
 obj-$(CONFIG_MACH_SUN8I_A33)   += clock_sun6i.o
 obj-$(CONFIG_MACH_SUN9I)   += clock_sun9i.o
 
+obj-$(CONFIG_AXP152_POWER) += pmic_bus.o
+obj-$(CONFIG_AXP209_POWER) += pmic_bus.o
 obj-$(CONFIG_AXP221_POWER) += pmic_bus.o
 
 ifndef CONFIG_SPL_BUILD
diff --git a/arch/arm/cpu/armv7/sunxi/pmic_bus.c 
b/arch/arm/cpu/armv7/sunxi/pmic_bus.c
index 389144b..9e05127 100644
--- a/arch/arm/cpu/armv7/sunxi/pmic_bus.c
+++ b/arch/arm/cpu/armv7/sunxi/pmic_bus.c
@@ -12,8 +12,13 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
+#define AXP152_I2C_ADDR0x30
+
+#define AXP209_I2C_ADDR0x34
+
 #define AXP221_CHIP_ADDR   0x68
 #define AXP221_CTRL_ADDR   0x3e
 #define AXP221_INIT_DATA   0x3e
@@ -25,24 +30,26 @@ int pmic_bus_init(void)
 {
/* This cannot be 0 because it is used in SPL before BSS is ready */
static int needs_init = 1;
-   int ret;
+   __maybe_unused int ret;
 
if (!needs_init)
return 0;
 
-#ifdef CONFIG_MACH_SUN6I
+#ifdef CONFIG_AXP221_POWER
+# ifdef CONFIG_MACH_SUN6I
p2wi_init();
ret = p2wi_change_to_p2wi_mode(AXP221_CHIP_ADDR, AXP221_CTRL_ADDR,
   AXP221_INIT_DATA);
-#else
+# else
ret = rsb_init();
if (ret)
return ret;
 
ret = rsb_set_device_address(AXP223_DEVICE_ADDR, AXP223_RUNTIME_ADDR);
-#endif
+# endif
if (ret)
return ret;
+#endif
 
needs_init = 0;
return 0;
@@ -50,19 +57,31 @@ int pmic_bus_init(void)
 
 int pmic_bus_read(u8 reg, u8 *data)
 {
-#ifdef CONFIG_MACH_SUN6I
+#ifdef CONFIG_AXP152_POWER
+   return i2c_read(AXP152_I2C_ADDR, reg, 1, data, 1);
+#elif defined CONFIG_AXP209_POWER
+   return i2c_read(AXP209_I2C_ADDR, reg, 1, data, 1);
+#elif defined CONFIG_AXP221_POWER
+# ifdef CONFIG_MACH_SUN6I
return p2wi_read(reg, data);
-#else
+# else
return rsb_read(AXP223_RUNTIME_ADDR, reg, data);
+# endif
 #endif
 }
 
 int pmic_bus_write(u8 reg, u8 data)
 {
-#ifdef CONFIG_MACH_SUN6I
+#ifdef CONFIG_AXP152_POWER
+   return i2c_write(AXP152_I2C_ADDR, reg, 1, &data, 1);
+#elif defined CONFIG_AXP209_POWER
+   return i2c_write(AXP209_I2C_ADDR, reg, 1, &data, 1);
+#elif defined CONFIG_AXP221_POWER
+# ifdef CONFIG_MACH_SUN6I
return p2wi_write(reg, data);
-#else
+# else
return rsb_write(AXP223_RUNTIME_ADDR, reg, data);
+# endif
 #endif
 }
 
-- 
2.3.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot