Commit 2abac6213d9d05c34fba7dcaa2934668774008a7
1 parent
3c781190d1
Exists in
v2017.01-smarct4x
and in
37 other branches
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>
Showing 2 changed files with 45 additions and 0 deletions Side-by-side Diff
drivers/power/axp221.c
... | ... | @@ -353,4 +353,40 @@ |
353 | 353 | |
354 | 354 | return 0; |
355 | 355 | } |
356 | + | |
357 | +static int axp_drivebus_setup(void) | |
358 | +{ | |
359 | + int ret; | |
360 | + | |
361 | + ret = axp221_init(); | |
362 | + if (ret) | |
363 | + return ret; | |
364 | + | |
365 | + /* Set N_VBUSEN pin to output / DRIVEBUS function */ | |
366 | + return axp221_clrbits(AXP221_MISC_CTRL, AXP221_MISC_CTRL_N_VBUSEN_FUNC); | |
367 | +} | |
368 | + | |
369 | +int axp_drivebus_enable(void) | |
370 | +{ | |
371 | + int ret; | |
372 | + | |
373 | + ret = axp_drivebus_setup(); | |
374 | + if (ret) | |
375 | + return ret; | |
376 | + | |
377 | + /* Set DRIVEBUS high */ | |
378 | + return axp221_setbits(AXP221_VBUS_IPSOUT, AXP221_VBUS_IPSOUT_DRIVEBUS); | |
379 | +} | |
380 | + | |
381 | +int axp_drivebus_disable(void) | |
382 | +{ | |
383 | + int ret; | |
384 | + | |
385 | + ret = axp_drivebus_setup(); | |
386 | + if (ret) | |
387 | + return ret; | |
388 | + | |
389 | + /* Set DRIVEBUS low */ | |
390 | + return axp221_clrbits(AXP221_VBUS_IPSOUT, AXP221_VBUS_IPSOUT_DRIVEBUS); | |
391 | +} |
include/axp221.h
... | ... | @@ -45,11 +45,18 @@ |
45 | 45 | #define AXP221_ALDO1_CTRL 0x28 |
46 | 46 | #define AXP221_ALDO2_CTRL 0x29 |
47 | 47 | #define AXP221_ALDO3_CTRL 0x2a |
48 | +#define AXP221_VBUS_IPSOUT 0x30 | |
49 | +#define AXP221_VBUS_IPSOUT_DRIVEBUS (1 << 2) | |
50 | +#define AXP221_MISC_CTRL 0x8f | |
51 | +#define AXP221_MISC_CTRL_N_VBUSEN_FUNC (1 << 4) | |
48 | 52 | #define AXP221_PAGE 0xff |
49 | 53 | |
50 | 54 | /* Page 1 addresses */ |
51 | 55 | #define AXP221_SID 0x20 |
52 | 56 | |
57 | +/* We support drivebus control */ | |
58 | +#define AXP_DRIVEBUS | |
59 | + | |
53 | 60 | int axp221_set_dcdc1(unsigned int mvolt); |
54 | 61 | int axp221_set_dcdc2(unsigned int mvolt); |
55 | 62 | int axp221_set_dcdc3(unsigned int mvolt); |
... | ... | @@ -64,4 +71,6 @@ |
64 | 71 | int axp221_set_aldo3(unsigned int mvolt); |
65 | 72 | int axp221_init(void); |
66 | 73 | int axp221_get_sid(unsigned int *sid); |
74 | +int axp_drivebus_enable(void); | |
75 | +int axp_drivebus_disable(void); |