aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorAndre Przywara <andre.przywara@arm.com>2020-08-03 00:25:21 +0100
committerAndre Przywara <andre.przywara@arm.com>2020-08-17 11:13:59 +0100
commit93fa305c0ae39813a6f4971997aacd2a428305f9 (patch)
tree16d0bd3fbd6872480b3ec6e9ca81625b6651ca31 /drivers
parent9bc28a5eb2f650648babaea62b6da871819370de (diff)
downloadtrusted-firmware-a-93fa305c0ae39813a6f4971997aacd2a428305f9.tar.gz
plat/allwinner: Only enable DRIVEVBUS if really needed
The DRIVEVBUS power rail of the AXP803 PMIC is mostly used to supply the USB bus power on micro USB sockets, when used in host mode. As this is a dynamic operation, and mostly we want micro USB sockets to act in client mode initially, BL31 should not actually enable this power line. However, on some boards DRIVEVBUS is used to supply power to normal USB-A sockets. Failing to activate this line there results in non-functional USB in U-Boot on those boards. For that reason we were enabling DRIVEVBUS so far, as it did not seem to cause any harm to the other boards. However it turns out that on the Pinephone (and other systems with a battery), actually enabling DRIVEVBUS unconditionally causes serious problems (reboot loop). To accommodate both use cases, without reverting to a build time option, check the default OTG configuration in the devicetree. For boards with USB-A sockets this is set to "host", on boards with micro-B sockets to "otg". Depending on this setting, we either enable DRIVEVBUS or leave it alone. This fixes TF-A on the Pinephone and potentially other battery powered devices. Change-Id: Iec0e07f218b2b4393bf4e05c3386261f8ed19e9f Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/allwinner/axp/common.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/drivers/allwinner/axp/common.c b/drivers/allwinner/axp/common.c
index 13437fec81..e98b16fdb2 100644
--- a/drivers/allwinner/axp/common.c
+++ b/drivers/allwinner/axp/common.c
@@ -105,6 +105,25 @@ static bool should_enable_regulator(const void *fdt, int node)
return false;
}
+static bool board_uses_usb0_host_mode(const void *fdt)
+{
+ int node, length;
+ const char *prop;
+
+ node = fdt_node_offset_by_compatible(fdt, -1,
+ "allwinner,sun8i-a33-musb");
+ if (node < 0) {
+ return false;
+ }
+
+ prop = fdt_getprop(fdt, node, "dr_mode", &length);
+ if (!prop) {
+ return false;
+ }
+
+ return !strncmp(prop, "host", length);
+}
+
void axp_setup_regulators(const void *fdt)
{
int node;
@@ -121,7 +140,8 @@ void axp_setup_regulators(const void *fdt)
}
/* This applies to AXP803 only. */
- if (fdt_getprop(fdt, node, "x-powers,drive-vbus-en", NULL)) {
+ if (fdt_getprop(fdt, node, "x-powers,drive-vbus-en", NULL) &&
+ board_uses_usb0_host_mode(fdt)) {
axp_clrbits(0x8f, BIT(4));
axp_setbits(0x30, BIT(2));
INFO("PMIC: Enabling DRIVEVBUS\n");