summaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2015-01-11 19:43:56 +0100
committerHans de Goede <hdegoede@redhat.com>2015-01-14 14:56:40 +0100
commit3c781190d11ca44752562867d76ccfb8d0a45ac3 (patch)
tree3e3050046c066b150489eb43413bddeeea6c704b /drivers/power
parent52755b12e30e45501ccea9260d47a2b6aba12a91 (diff)
downloadtalos-obmc-uboot-3c781190d11ca44752562867d76ccfb8d0a45ac3.tar.gz
talos-obmc-uboot-3c781190d11ca44752562867d76ccfb8d0a45ac3.zip
sunxi: axp221: Protect axp221_init against multiple calls
The voltage setting code knows it needs to call axp221_init before calling the various voltage setting functions. But users of axp utility functions like axp221_get_sid() do not know this, so the utility functions always call axp221_init() to ensure that the p2wi / rsb setup magic has been done. Since doing this repeatedly is quite expensive, add a check to axp221_init so that it only does the initialization once. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Ian Campbell <ijc@hellion.org.uk>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/axp221.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/power/axp221.c b/drivers/power/axp221.c
index 1fda19ac01..728727b48e 100644
--- a/drivers/power/axp221.c
+++ b/drivers/power/axp221.c
@@ -304,9 +304,14 @@ int axp221_set_aldo3(unsigned int mvolt)
int axp221_init(void)
{
+ /* This cannot be 0 because it is used in SPL before BSS is ready */
+ static int needs_init = 1;
u8 axp_chip_id;
int ret;
+ if (!needs_init)
+ return 0;
+
ret = pmic_bus_init();
if (ret)
return ret;
@@ -318,6 +323,7 @@ int axp221_init(void)
if (!(axp_chip_id == 0x6 || axp_chip_id == 0x7 || axp_chip_id == 0x17))
return -ENODEV;
+ needs_init = 0;
return 0;
}
OpenPOWER on IntegriCloud