]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
mach-snapdragon: fixup power-domains
authorCaleb Connolly <caleb.connolly@linaro.org>
Wed, 3 Apr 2024 12:07:46 +0000 (14:07 +0200)
committerCaleb Connolly <caleb.connolly@linaro.org>
Thu, 4 Apr 2024 15:46:47 +0000 (17:46 +0200)
We don't support the RPM(h)PD power domains in U-Boot, and we don't need
to - the necessary resources are on, and we aren't going to enter any
low power modes.

We could try using a no-op device, but this requires adding a compatible
for every platform, and just pollutes the driver model. So instead let's
just remove every "power-domains" property that references the RPM(h)pd
power controller. This takes <1ms as we're using OF_LIVE.

Of note, this only applies to drivers which are loading post-relocation.
Drivers loaded pre-reloc that reference the rpm(h)pd still need
DM_FLAG_DEFAULT_PD_CTRL_OFF in their flags.

Acked-by: Sumit Garg <sumit.garg@linaro.org>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
arch/arm/mach-snapdragon/of_fixup.c

index 4fdfed2dff1608143b18ebe45b7775ead6fc5409..3f7ac227bd090e208ffdd2d763e1cd7c008b6d11 100644 (file)
@@ -22,6 +22,7 @@
 #include <dm/of.h>
 #include <fdt_support.h>
 #include <linux/errno.h>
+#include <stdlib.h>
 #include <time.h>
 
 /* U-Boot only supports USB high-speed mode on Qualcomm platforms with DWC3
@@ -110,6 +111,36 @@ static void fixup_usb_nodes(void)
        }
 }
 
+/* Remove all references to the rpmhpd device */
+static void fixup_power_domains(void)
+{
+       struct device_node *pd = NULL, *np = NULL;
+       struct property *prop;
+       const __be32 *val;
+
+       /* All Qualcomm platforms name the rpm(h)pd "power-controller" */
+       for_each_of_allnodes(pd) {
+               if (pd->name && !strcmp("power-controller", pd->name))
+                       break;
+       }
+
+       /* Sanity check that this is indeed a power domain controller */
+       if (!of_find_property(pd, "#power-domain-cells", NULL)) {
+               log_err("Found power-controller but it doesn't have #power-domain-cells\n");
+               return;
+       }
+
+       /* Remove all references to the power domain controller */
+       for_each_of_allnodes(np) {
+               if (!(prop = of_find_property(np, "power-domains", NULL)))
+                       continue;
+
+               val = prop->value;
+               if (val[0] == cpu_to_fdt32(pd->phandle))
+                       of_remove_property(np, prop);
+       }
+}
+
 #define time_call(func, ...) \
        do { \
                u64 start = timer_get_us(); \
@@ -120,4 +151,5 @@ static void fixup_usb_nodes(void)
 void qcom_of_fixup_nodes(void)
 {
        time_call(fixup_usb_nodes);
+       time_call(fixup_power_domains);
 }