]> git.sur5r.net Git - u-boot/blobdiff - drivers/power/axp209.c
sunxi: axp221: Allow specifying dcdc2 voltage via Kconfig
[u-boot] / drivers / power / axp209.c
index 9798e5bf7c621ebdba0c27b10f92e43796347609..5161bc14729e2a6b83dd4f1caaac5fb13eab4543 100644 (file)
@@ -7,26 +7,9 @@
 
 #include <common.h>
 #include <i2c.h>
+#include <asm/arch/gpio.h>
 #include <axp209.h>
 
-enum axp209_reg {
-       AXP209_POWER_STATUS = 0x00,
-       AXP209_CHIP_VERSION = 0x03,
-       AXP209_DCDC2_VOLTAGE = 0x23,
-       AXP209_DCDC3_VOLTAGE = 0x27,
-       AXP209_LDO24_VOLTAGE = 0x28,
-       AXP209_LDO3_VOLTAGE = 0x29,
-       AXP209_IRQ_STATUS5 = 0x4c,
-       AXP209_SHUTDOWN = 0x32,
-};
-
-#define AXP209_POWER_STATUS_ON_BY_DC   (1 << 0)
-
-#define AXP209_IRQ5_PEK_UP             (1 << 6)
-#define AXP209_IRQ5_PEK_DOWN           (1 << 5)
-
-#define AXP209_POWEROFF                        (1 << 7)
-
 static int axp209_write(enum axp209_reg reg, u8 val)
 {
        return i2c_write(0x34, reg, 1, &val, 1);
@@ -100,7 +83,7 @@ int axp209_set_ldo3(int mvolt)
        if (mvolt == -1)
                cfg = 0x80;     /* determined by LDO3IN pin */
        else
-               cfg = axp209_mvolt_to_cfg(mvolt, 700, 2275, 25);
+               cfg = axp209_mvolt_to_cfg(mvolt, 700, 3500, 25);
 
        return axp209_write(AXP209_LDO3_VOLTAGE, cfg);
 }
@@ -129,7 +112,7 @@ int axp209_set_ldo4(int mvolt)
 int axp209_init(void)
 {
        u8 ver;
-       int rc;
+       int i, rc;
 
        rc = axp209_read(AXP209_CHIP_VERSION, &ver);
        if (rc)
@@ -141,6 +124,13 @@ int axp209_init(void)
        if (ver != 0x1)
                return -1;
 
+       /* Mask all interrupts */
+       for (i = AXP209_IRQ_ENABLE1; i <= AXP209_IRQ_ENABLE5; i++) {
+               rc = axp209_write(i, 0);
+               if (rc)
+                       return rc;
+       }
+
        return 0;
 }