Skip to content
Snippets Groups Projects
Commit 3c781190 authored by Hans de Goede's avatar Hans de Goede
Browse files

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: default avatarHans de Goede <hdegoede@redhat.com>
Acked-by: default avatarIan Campbell <ijc@hellion.org.uk>
parent 52755b12
No related branches found
No related tags found
No related merge requests found
...@@ -304,9 +304,14 @@ int axp221_set_aldo3(unsigned int mvolt) ...@@ -304,9 +304,14 @@ int axp221_set_aldo3(unsigned int mvolt)
int axp221_init(void) 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; u8 axp_chip_id;
int ret; int ret;
if (!needs_init)
return 0;
ret = pmic_bus_init(); ret = pmic_bus_init();
if (ret) if (ret)
return ret; return ret;
...@@ -318,6 +323,7 @@ int axp221_init(void) ...@@ -318,6 +323,7 @@ int axp221_init(void)
if (!(axp_chip_id == 0x6 || axp_chip_id == 0x7 || axp_chip_id == 0x17)) if (!(axp_chip_id == 0x6 || axp_chip_id == 0x7 || axp_chip_id == 0x17))
return -ENODEV; return -ENODEV;
needs_init = 0;
return 0; return 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment