Alright I think I got a solution for you here. You’ll still need to make a device tree change but it will allow you to change the power state of the ethernet PHY during runtime from userspace, without switching images.
In short you need to remove the ethernet voltage regulator reference in the device tree I referenced earlier. Then configure the PMIC_EN_ETH
pin as a free GPIO. What this does is allow you, the user, to modify the value of this pin from userspace. Physically the pin is still connected to the power circuit for the ethernet PHY, so changing it’s value will still affect the power state.
However keep in mind that by removing the reference to the regulator in the device tree this means the pin isn’t being managed by the kernel or any software drivers. In other words this may lead to unforeseen behavior.
Here’s a reference of the device tree changes:
diff --git a/dts-arm64/imx8mm-verdin.dtsi b/dts-arm64/imx8mm-verdin.dtsi
index c7c0722..9dfe401 100755
--- a/dts-arm64/imx8mm-verdin.dtsi
+++ b/dts-arm64/imx8mm-verdin.dtsi
@@ -75,20 +75,6 @@
regulator-name = "REG_MIPI_PHY";
};
- reg_ethphy: regulator-ethphy {
- compatible = "regulator-fixed";
- enable-active-high;
- gpio = <&gpio2 20 GPIO_ACTIVE_HIGH>; /* PMIC_EN_ETH */
- off-on-delay = <500000>;
- pinctrl-names = "default";
- pinctrl-0 = <&pinctrl_reg_eth>;
- regulator-boot-on;
- regulator-max-microvolt = <3300000>;
- regulator-min-microvolt = <3300000>;
- regulator-name = "V3.3_ETH";
- startup-delay-us = <200000>;
- };
-
reg_usb_otg1_vbus: regulator-usb-otg1 {
compatible = "regulator-fixed";
enable-active-high;
@@ -201,7 +187,6 @@
fsl,magic-packet;
phy-handle = <ðphy0>;
phy-mode = "rgmii-id";
- phy-supply = <®_ethphy>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&pinctrl_fec1>;
pinctrl-1 = <&pinctrl_fec1_sleep>;
@@ -806,7 +791,7 @@
<&pinctrl_gpio3>, <&pinctrl_gpio4>,
<&pinctrl_gpio7>, <&pinctrl_gpio8>,
<&pinctrl_gpio_hog1>, <&pinctrl_gpio_hog2>, <&pinctrl_gpio_hog3>,
- <&pinctrl_pmic_tpm_ena>;
+ <&pinctrl_pmic_tpm_ena>, <&pinctrl_reg_eth>;
pinctrl_can1_int: can1intgrp {
fsl,pins = <
You can then use whatever method to manipulate the GPIO from user-space. In my short tests when I set the GPIO to low, I lose all ethernet functionality and I can see the LEDs on the Ethernet port turn off. Which seems to be a pretty good indication that power was cut off.
Best Regards,
Jeremias