]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
sunxi: axp221: Add support for controlling the drivebus pin
authorHans de Goede <hdegoede@redhat.com>
Sun, 11 Jan 2015 18:58:03 +0000 (19:58 +0100)
committerHans de Goede <hdegoede@redhat.com>
Wed, 14 Jan 2015 13:56:40 +0000 (14:56 +0100)
The axp221 / axp223's N_VBUSEN pin can be configured as an output rather
then an input, add axp_drivebus_enable() and _disable() functions to set
the pin in output mode and control it.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ian Campbell <ijc@hellion.org.uk>
drivers/power/axp221.c
include/axp221.h

index 728727b48eb6a72dc9635ba52fb0e1b08d9e93ac..4c86f099a2df52bb8223ed17115cbbc3da3232bf 100644 (file)
@@ -353,3 +353,39 @@ int axp221_get_sid(unsigned int *sid)
 
        return 0;
 }
+
+static int axp_drivebus_setup(void)
+{
+       int ret;
+
+       ret = axp221_init();
+       if (ret)
+               return ret;
+
+       /* Set N_VBUSEN pin to output / DRIVEBUS function */
+       return axp221_clrbits(AXP221_MISC_CTRL, AXP221_MISC_CTRL_N_VBUSEN_FUNC);
+}
+
+int axp_drivebus_enable(void)
+{
+       int ret;
+
+       ret = axp_drivebus_setup();
+       if (ret)
+               return ret;
+
+       /* Set DRIVEBUS high */
+       return axp221_setbits(AXP221_VBUS_IPSOUT, AXP221_VBUS_IPSOUT_DRIVEBUS);
+}
+
+int axp_drivebus_disable(void)
+{
+       int ret;
+
+       ret = axp_drivebus_setup();
+       if (ret)
+               return ret;
+
+       /* Set DRIVEBUS low */
+       return axp221_clrbits(AXP221_VBUS_IPSOUT, AXP221_VBUS_IPSOUT_DRIVEBUS);
+}
index e9552f65febefad7a511580c0966ddf25f674d2a..e6639f1ffe694b12b9dbf79f0a7f9b57102c2185 100644 (file)
 #define AXP221_ALDO1_CTRL      0x28
 #define AXP221_ALDO2_CTRL      0x29
 #define AXP221_ALDO3_CTRL      0x2a
+#define AXP221_VBUS_IPSOUT     0x30
+#define AXP221_VBUS_IPSOUT_DRIVEBUS    (1 << 2)
+#define AXP221_MISC_CTRL       0x8f
+#define AXP221_MISC_CTRL_N_VBUSEN_FUNC (1 << 4)
 #define AXP221_PAGE            0xff
 
 /* Page 1 addresses */
 #define AXP221_SID             0x20
 
+/* We support drivebus control */
+#define AXP_DRIVEBUS
+
 int axp221_set_dcdc1(unsigned int mvolt);
 int axp221_set_dcdc2(unsigned int mvolt);
 int axp221_set_dcdc3(unsigned int mvolt);
@@ -64,3 +71,5 @@ int axp221_set_aldo2(unsigned int mvolt);
 int axp221_set_aldo3(unsigned int mvolt);
 int axp221_init(void);
 int axp221_get_sid(unsigned int *sid);
+int axp_drivebus_enable(void);
+int axp_drivebus_disable(void);