diff options
author | Hans de Goede <hdegoede@redhat.com> | 2015-01-11 19:58:03 +0100 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2015-01-14 14:56:40 +0100 |
commit | 2abac6213d9d05c34fba7dcaa2934668774008a7 (patch) | |
tree | 4232558f135a6f0fd620c11f6d4650de087ceb09 /drivers/power/axp221.c | |
parent | 3c781190d11ca44752562867d76ccfb8d0a45ac3 (diff) | |
download | u-boot-imx-2abac6213d9d05c34fba7dcaa2934668774008a7.zip u-boot-imx-2abac6213d9d05c34fba7dcaa2934668774008a7.tar.gz u-boot-imx-2abac6213d9d05c34fba7dcaa2934668774008a7.tar.bz2 |
sunxi: axp221: Add support for controlling the drivebus pin
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>
Diffstat (limited to 'drivers/power/axp221.c')
-rw-r--r-- | drivers/power/axp221.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/power/axp221.c b/drivers/power/axp221.c index 728727b..4c86f09 100644 --- a/drivers/power/axp221.c +++ b/drivers/power/axp221.c @@ -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); +} |