feat(allwinner): allow to skip PMIC regulator setup

For somewhat historical reasons we are doing some initial PMIC regulator
setup in BL31, as U-Boot does not (yet) have a PMIC driver. This worked
fine so far, but there is at least one board (OrangePi 3) that gets upset,
because the Ethernet PHY needs some *coordinated* bringup of *two*
regulators.

To avoid custom hacks, let's introduce a build option to keep doing the
regulator setup in TF-A. Defining SUNXI_SETUP_REGULATORS to 0 will break
support for some devices on some boards in U-Boot (Ethernet and HDMI),
but will allow to bring up the OrangePi 3 in Linux correctly. We keep
the default at 1 to not change the behaviour for all other boards.

After U-Boot gained proper PMIC support at some point in the future, we
will probably change the default to 0, to get rid of the less optimal
PMIC code in TF-A.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Change-Id: Ie8e2583d0396f6eeaae8ffe6b6190f27db63e2a7
diff --git a/drivers/allwinner/axp/axp803.c b/drivers/allwinner/axp/axp803.c
index 53b11c1..7050818 100644
--- a/drivers/allwinner/axp/axp803.c
+++ b/drivers/allwinner/axp/axp803.c
@@ -9,6 +9,7 @@
 const uint8_t axp_chip_id = AXP803_CHIP_ID;
 const char *const axp_compatible = "x-powers,axp803";
 
+#if SUNXI_SETUP_REGULATORS == 1
 const struct axp_regulator axp_regulators[] = {
 	{"dcdc1", 1600, 3400, 100, NA, 0x20, 0x10, 0},
 	{"dcdc5",  800, 1840,  10, 32, 0x24, 0x10, 4},
@@ -20,3 +21,4 @@
 	{"fldo1",  700, 1450,  50, NA, 0x1c, 0x13, 2},
 	{}
 };
+#endif
diff --git a/drivers/allwinner/axp/axp805.c b/drivers/allwinner/axp/axp805.c
index 8d029c0..3a03fec 100644
--- a/drivers/allwinner/axp/axp805.c
+++ b/drivers/allwinner/axp/axp805.c
@@ -9,6 +9,7 @@
 const uint8_t axp_chip_id = AXP805_CHIP_ID;
 const char *const axp_compatible = "x-powers,axp805";
 
+#if SUNXI_SETUP_REGULATORS == 1
 /*
  * The "dcdcd" split changes the step size by a factor of 5, not 2;
  * disallow values above the split to maintain accuracy.
@@ -31,3 +32,4 @@
 	{"cldo3",  700, 3300, 100, NA, 0x26, 0x11, 6},
 	{}
 };
+#endif
diff --git a/drivers/allwinner/axp/common.c b/drivers/allwinner/axp/common.c
index 143fb0f..f1250b0 100644
--- a/drivers/allwinner/axp/common.c
+++ b/drivers/allwinner/axp/common.c
@@ -48,6 +48,7 @@
 	axp_setbits(0x32, BIT(7));
 }
 
+#if SUNXI_SETUP_REGULATORS == 1
 /*
  * Retrieve the voltage from a given regulator DTB node.
  * Both the regulator-{min,max}-microvolt properties must be present and
@@ -208,3 +209,4 @@
 			axp_setbits(0x11, BIT(7));
 	}
 }
+#endif	/* SUNXI_SETUP_REGULATORS */
diff --git a/include/drivers/allwinner/axp.h b/include/drivers/allwinner/axp.h
index 222820b..8b90c7f 100644
--- a/include/drivers/allwinner/axp.h
+++ b/include/drivers/allwinner/axp.h
@@ -47,6 +47,13 @@
 
 int axp_check_id(void);
 void axp_power_off(void);
+
+#if SUNXI_SETUP_REGULATORS == 1
 void axp_setup_regulators(const void *fdt);
+#else
+static inline void axp_setup_regulators(const void *fdt)
+{
+}
+#endif
 
 #endif /* AXP_H */
diff --git a/plat/allwinner/common/allwinner-common.mk b/plat/allwinner/common/allwinner-common.mk
index 61ae9b6..34fdaf6 100644
--- a/plat/allwinner/common/allwinner-common.mk
+++ b/plat/allwinner/common/allwinner-common.mk
@@ -61,6 +61,10 @@
 				${AW_PLAT}/common/sunxi_scpi_pm.c
 endif
 
+SUNXI_SETUP_REGULATORS	?=	1
+$(eval $(call assert_boolean,SUNXI_SETUP_REGULATORS))
+$(eval $(call add_define,SUNXI_SETUP_REGULATORS))
+
 # The bootloader is guaranteed to only run on CPU 0 by the boot ROM.
 COLD_BOOT_SINGLE_CPU		:=	1