Hi,

I found this problem caused by ARM Trusted Firmware (ATF).

>> Even if these fix are applied, dwxe cannot find ethernet PHY (RT8211).
>> Orange Pi One Plus' Schematics and DTB defines PHY address as 0x01,
>> but actually probed at 0x00 (MII broadcast) and 0x07.
>> We have to modify DTB or take measures such misconfiguration.

- No need to modify DTB, this is ATF and board issue

Armbian-21.08.6 uses ATF v2.2 and PHY works with address 1.
ATF v2.2 does not turn on aldo2, the upstream power source of ethernet PHY
(gmac-3v3). But I tried with v2.5, this is the difference.

ATF v2.3 and later always turns on regulators that have
"regulator-always-on" *or* "phandle" property in Device Tree node.
Orange Pi One Plus' aldo2 node has phandle (but no regulator-always-on),
so newer-ATF turns this on.

This is, powering on aldo2 before booting U-boot causes PHY malfunction.

An ATF developer noticed that "Enable regulators more judiciously"
(https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/4642),
but this looks rejected.

- Asserting PHY's reset signal is the remedy, but no definition in DTB

Orange Pi One Plus assigns GPIO-PD14 for resetting PHY chip,
but there is no definition in Device Tree. If it is defined,
if_dwxe does not handle the signal (if_dwge, if_fec can handle this).
Currently there is no way to reset PHY via Device Tree manner.

I hope simply replace powering on to off/delay(1sec?)/on sequence in
dwxe_attach() will fix this problem but not tested yet.
I will try it later but please tell me if there is better idea.

- We need to support "vin-supply" property for regulator-fixed.

Orange Pi One Plus' PHY uses gmac-3v3 regulator, but the source
described "vin-supply" property (aldo2) does not handled.
So we have to add the code like this:

Index: ofw_regulator.c
===================================================================
RCS file: /cvs/src/sys/dev/ofw/ofw_regulator.c,v
retrieving revision 1.15
diff -u -p -u -p -r1.15 ofw_regulator.c
--- ofw_regulator.c     23 Dec 2020 11:58:36 -0000      1.15
+++ ofw_regulator.c     3 Dec 2021 13:10:57 -0000
@@ -92,9 +92,25 @@ regulator_fixed_set(int node, int enable
 {
        uint32_t *gpio;
        uint32_t startup_delay;
+       uint32_t vin, vin_volt, vin_min, vin_max;
        int len;
 
        pinctrl_byname(node, "default");
+
+       /* turn on parent regulator (if exist) */
+       vin = OF_getpropint(node, "vin-supply", 0);
+       if (vin) {
+               /* check voltage setting, fix if invalid */
+               vin_volt = regulator_get_voltage(vin);
+               vin_min = OF_getpropint(vin, "regulator-min-microvolt", 0);
+               vin_max = OF_getpropint(vin, "regulator-max-microvolt", ~0);
+               if (vin_volt < vin_min)
+                       regulator_set_voltage(vin, vin_min);
+               else if (vin_volt > vin_max)
+                       regulator_set_voltage(vin, vin_max);
+
+               regulator_enable(vin);
+       }
 
        /* The "gpio" property is optional. */
        len = OF_getproplen(node, "gpio");

Regards,
-- 
SASANO Takayoshi (JG1UAA) <u...@mx5.nisiq.net>

Reply via email to