Merge tag 'efi-2022-07-rc1-2' of https://source.denx.de/u-boot/custodians/u-boot-efi

Pull request for efi-2022-07-rc1-2

Documentation:

* Describe env command

UEFI

* simplify Unicode string functions
* clean up the usage of GUIDs for capsule updates
diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 314d277..ec77c7a 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -63,6 +63,7 @@
       - script: |
           KSYMLST=`mktemp`
           KUSEDLST=`mktemp`
+          RET=0
           cat `find . -name "Kconfig*"` | \
              sed -n -e 's/^\s*config *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \
              -e 's/^\s*menuconfig *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \
@@ -76,10 +77,12 @@
              NUM=`comm -123 --total --output-delimiter=, ${KSYMLST} ${KUSEDLST} | \
                 cut -d , -f 3`
              if [[ $NUM -ne 0 ]]; then
-                echo "Unmigrated symbols found in $CFG"
-                exit 1
+                echo "Unmigrated symbols found in $CFG:"
+                comm -12 ${KSYMLST} ${KUSEDLST}
+                RET=1
              fi
           done
+          exit $RET
 
   - job: cppcheck
     displayName: 'Static code analysis with cppcheck'
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 43fe8c6..f193ffd 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -124,6 +124,7 @@
   script:
     - KSYMLST=`mktemp`;
       KUSEDLST=`mktemp`;
+      RET=0;
       cat `find . -name "Kconfig*"` |
          sed -n -e 's/^\s*config *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p'
          -e 's/^\s*menuconfig *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p'
@@ -137,10 +138,12 @@
          NUM=`comm -123 --total --output-delimiter=, ${KSYMLST} ${KUSEDLST} |
             cut -d , -f 3`;
          if [[ $NUM -ne 0 ]]; then
-            echo "Unmigrated symbols found in $CFG";
-            exit 1;
+            echo "Unmigrated symbols found in $CFG:";
+            comm -12 ${KSYMLST} ${KUSEDLST};
+            RET=1;
          fi;
-      done
+      done;
+      exit $RET
 
 # QA jobs for code analytics
 # static code analysis with cppcheck (we can add --enable=all later)
diff --git a/Kconfig b/Kconfig
index 0ee3068..b45e60a 100644
--- a/Kconfig
+++ b/Kconfig
@@ -263,6 +263,7 @@
 
 config SYS_MALLOC_LEN
 	hex "Define memory for Dynamic allocation"
+	default 0x4000000 if SANDBOX
 	default 0x2000000 if ARCH_ROCKCHIP || ARCH_OMAP2PLUS || ARCH_MESON
 	default 0x200000 if ARCH_BMIPS || X86
 	default 0x120000 if MACH_SUNIV
diff --git a/arch/arm/mach-apple/board.c b/arch/arm/mach-apple/board.c
index 722dff1..ffc1301 100644
--- a/arch/arm/mach-apple/board.c
+++ b/arch/arm/mach-apple/board.c
@@ -177,6 +177,171 @@
 	}
 };
 
+/* Apple M1 Ultra */
+
+static struct mm_region t6002_mem_map[] = {
+	{
+		/* I/O */
+		.virt = 0x280000000,
+		.phys = 0x280000000,
+		.size = SZ_1G,
+		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+			 PTE_BLOCK_NON_SHARE |
+			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
+	}, {
+		/* I/O */
+		.virt = 0x380000000,
+		.phys = 0x380000000,
+		.size = SZ_1G,
+		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+			 PTE_BLOCK_NON_SHARE |
+			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
+	}, {
+		/* I/O */
+		.virt = 0x580000000,
+		.phys = 0x580000000,
+		.size = SZ_512M,
+		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+			 PTE_BLOCK_NON_SHARE |
+			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
+	}, {
+		/* PCIE */
+		.virt = 0x5a0000000,
+		.phys = 0x5a0000000,
+		.size = SZ_512M,
+		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRE) |
+			 PTE_BLOCK_INNER_SHARE |
+			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
+	}, {
+		/* PCIE */
+		.virt = 0x5c0000000,
+		.phys = 0x5c0000000,
+		.size = SZ_1G,
+		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRE) |
+			 PTE_BLOCK_INNER_SHARE |
+			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
+	}, {
+		/* I/O */
+		.virt = 0x700000000,
+		.phys = 0x700000000,
+		.size = SZ_1G,
+		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+			 PTE_BLOCK_NON_SHARE |
+			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
+	}, {
+		/* I/O */
+		.virt = 0xb00000000,
+		.phys = 0xb00000000,
+		.size = SZ_1G,
+		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+			 PTE_BLOCK_NON_SHARE |
+			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
+	}, {
+		/* I/O */
+		.virt = 0xf00000000,
+		.phys = 0xf00000000,
+		.size = SZ_1G,
+		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+			 PTE_BLOCK_NON_SHARE |
+			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
+	}, {
+		/* I/O */
+		.virt = 0x1300000000,
+		.phys = 0x1300000000,
+		.size = SZ_1G,
+		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+			 PTE_BLOCK_NON_SHARE |
+			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
+	}, {
+		/* I/O */
+		.virt = 0x2280000000,
+		.phys = 0x2280000000,
+		.size = SZ_1G,
+		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+			 PTE_BLOCK_NON_SHARE |
+			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
+	}, {
+		/* I/O */
+		.virt = 0x2380000000,
+		.phys = 0x2380000000,
+		.size = SZ_1G,
+		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+			 PTE_BLOCK_NON_SHARE |
+			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
+	}, {
+		/* I/O */
+		.virt = 0x2580000000,
+		.phys = 0x2580000000,
+		.size = SZ_512M,
+		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+			 PTE_BLOCK_NON_SHARE |
+			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
+	}, {
+		/* PCIE */
+		.virt = 0x25a0000000,
+		.phys = 0x25a0000000,
+		.size = SZ_512M,
+		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRE) |
+			 PTE_BLOCK_INNER_SHARE |
+			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
+	}, {
+		/* PCIE */
+		.virt = 0x25c0000000,
+		.phys = 0x25c0000000,
+		.size = SZ_1G,
+		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRE) |
+			 PTE_BLOCK_INNER_SHARE |
+			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
+	}, {
+		/* I/O */
+		.virt = 0x2700000000,
+		.phys = 0x2700000000,
+		.size = SZ_1G,
+		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+			 PTE_BLOCK_NON_SHARE |
+			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
+	}, {
+		/* I/O */
+		.virt = 0x2b00000000,
+		.phys = 0x2b00000000,
+		.size = SZ_1G,
+		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+			 PTE_BLOCK_NON_SHARE |
+			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
+	}, {
+		/* I/O */
+		.virt = 0x2f00000000,
+		.phys = 0x2f00000000,
+		.size = SZ_1G,
+		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+			 PTE_BLOCK_NON_SHARE |
+			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
+	}, {
+		/* I/O */
+		.virt = 0x3300000000,
+		.phys = 0x3300000000,
+		.size = SZ_1G,
+		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+			 PTE_BLOCK_NON_SHARE |
+			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
+	}, {
+		/* RAM */
+		.virt = 0x10000000000,
+		.phys = 0x10000000000,
+		.size = 16UL * SZ_1G,
+		.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+			 PTE_BLOCK_INNER_SHARE
+	}, {
+		/* Framebuffer */
+		.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL_NC) |
+			 PTE_BLOCK_INNER_SHARE |
+			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
+	}, {
+		/* List terminator */
+		0,
+	}
+};
+
 struct mm_region *mem_map;
 
 int board_init(void)
@@ -216,6 +381,8 @@
 		mem_map = t6000_mem_map;
 	else if (of_machine_is_compatible("apple,t6001"))
 		mem_map = t6000_mem_map;
+	else if (of_machine_is_compatible("apple,t6002"))
+		mem_map = t6002_mem_map;
 	else
 		panic("Unsupported SoC\n");
 
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 05c1cd5..5b38ee4 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -530,6 +530,14 @@
 		fake-host-hwaddr = [00 00 66 44 22 22];
 	};
 
+	phy_eth0: phy-test-eth {
+		compatible = "sandbox,eth";
+		reg = <0x10007000 0x1000>;
+		fake-host-hwaddr = [00 00 66 44 22 77];
+		phy-handle = <&ethphy1>;
+		phy-mode = "2500base-x";
+	};
+
 	dsa_eth0: dsa-test-eth {
 		compatible = "sandbox,eth";
 		reg = <0x10006000 0x1000>;
@@ -1555,6 +1563,12 @@
 
 	mdio: mdio-test {
 		compatible = "sandbox,mdio";
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		ethphy1: ethernet-phy@1 {
+			reg = <1>;
+		};
 	};
 
 	pm-bus-test {
diff --git a/arch/sandbox/include/asm/serial.h b/arch/sandbox/include/asm/serial.h
index bc82aeb..16589a1 100644
--- a/arch/sandbox/include/asm/serial.h
+++ b/arch/sandbox/include/asm/serial.h
@@ -17,6 +17,28 @@
 };
 
 /**
+ * sandbox_serial_written() - Get the total number of characters written
+ *
+ * This returns the number of characters written by the sandbox serial
+ * device. It is intended for performing tests of the serial subsystem
+ * where a console buffer cannot be used. The absolute number should not be
+ * relied upon; call this function twice and compare the difference.
+ *
+ * Return: The number of characters written
+ */
+size_t sandbox_serial_written(void);
+
+/**
+ * sandbox_serial_endisable() - Enable or disable serial output
+ * @enabled: Whether serial output should be enabled or not
+ *
+ * This allows tests to enable or disable the sandbox serial output. All
+ * processes relating to writing output (except the actual writing) will be
+ * performed.
+ */
+void sandbox_serial_endisable(bool enabled);
+
+/**
  * struct sandbox_serial_priv - Private data for this driver
  *
  * @buf: holds input characters available to be read by this driver
diff --git a/arch/sandbox/include/asm/tables.h b/arch/sandbox/include/asm/tables.h
deleted file mode 100644
index e69de29..0000000
--- a/arch/sandbox/include/asm/tables.h
+++ /dev/null
diff --git a/arch/x86/include/asm/tables.h b/arch/x86/include/asm/tables.h
index aa93883..37be012 100644
--- a/arch/x86/include/asm/tables.h
+++ b/arch/x86/include/asm/tables.h
@@ -17,19 +17,6 @@
 #define CB_TABLE_ADDR	0x800
 
 /**
- * table_compute_checksum() - Compute a table checksum
- *
- * This computes an 8-bit checksum for the configuration table.
- * All bytes in the configuration table, including checksum itself and
- * reserved bytes must add up to zero.
- *
- * @v:		configuration table base address
- * @len:	configuration table size
- * @return:	the 8-bit checksum
- */
-u8 table_compute_checksum(void *v, int len);
-
-/**
  * table_fill_string() - Fill a string with pad in the configuration table
  *
  * This fills a string in the configuration table. It copies number of bytes
diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c
index 8888a2d..9702d1f 100644
--- a/board/CZ.NIC/turris_mox/turris_mox.c
+++ b/board/CZ.NIC/turris_mox/turris_mox.c
@@ -396,7 +396,7 @@
 		return;
 	}
 
-	phydev = phy_find_by_mask(bus, BIT(1), PHY_INTERFACE_MODE_RGMII);
+	phydev = phy_find_by_mask(bus, BIT(1));
 	if (!phydev) {
 		printf("Cannot get ethernet PHY!\n");
 		return;
diff --git a/board/boundary/nitrogen6x/nitrogen6x.c b/board/boundary/nitrogen6x/nitrogen6x.c
index 8566c22..83bb445 100644
--- a/board/boundary/nitrogen6x/nitrogen6x.c
+++ b/board/boundary/nitrogen6x/nitrogen6x.c
@@ -345,7 +345,7 @@
 	if (!bus)
 		return -EINVAL;
 	/* scan phy 4,5,6,7 */
-	phydev = phy_find_by_mask(bus, (0xf << 4), PHY_INTERFACE_MODE_RGMII);
+	phydev = phy_find_by_mask(bus, (0xf << 4));
 	if (!phydev) {
 		ret = -EINVAL;
 		goto free_bus;
diff --git a/board/freescale/corenet_ds/eth_hydra.c b/board/freescale/corenet_ds/eth_hydra.c
index 6500c2f..a27e905 100644
--- a/board/freescale/corenet_ds/eth_hydra.c
+++ b/board/freescale/corenet_ds/eth_hydra.c
@@ -471,7 +471,7 @@
 			fm_info_set_mdio(i,
 				miiphy_get_dev_by_name("HYDRA_RGMII_MDIO"));
 			break;
-		case PHY_INTERFACE_MODE_NONE:
+		case PHY_INTERFACE_MODE_NA:
 			fm_info_set_phy_address(i, 0);
 			break;
 		default:
diff --git a/board/freescale/corenet_ds/eth_superhydra.c b/board/freescale/corenet_ds/eth_superhydra.c
index de7b692..55bac0f 100644
--- a/board/freescale/corenet_ds/eth_superhydra.c
+++ b/board/freescale/corenet_ds/eth_superhydra.c
@@ -583,7 +583,7 @@
 			fm_info_set_mdio(i,
 				miiphy_get_dev_by_name("SUPER_HYDRA_RGMII_MDIO"));
 			break;
-		case PHY_INTERFACE_MODE_NONE:
+		case PHY_INTERFACE_MODE_NA:
 			fm_info_set_phy_address(i, 0);
 			break;
 		default:
@@ -733,7 +733,7 @@
 			fm_info_set_mdio(i,
 			miiphy_get_dev_by_name("SUPER_HYDRA_RGMII_MDIO"));
 			break;
-		case PHY_INTERFACE_MODE_NONE:
+		case PHY_INTERFACE_MODE_NA:
 			fm_info_set_phy_address(i, 0);
 			break;
 		default:
diff --git a/board/freescale/t104xrdb/eth.c b/board/freescale/t104xrdb/eth.c
index b034f11..3ae5d72 100644
--- a/board/freescale/t104xrdb/eth.c
+++ b/board/freescale/t104xrdb/eth.c
@@ -89,7 +89,7 @@
 		case PHY_INTERFACE_MODE_QSGMII:
 			fm_info_set_phy_address(i, 0);
 			break;
-		case PHY_INTERFACE_MODE_NONE:
+		case PHY_INTERFACE_MODE_NA:
 			fm_info_set_phy_address(i, 0);
 			break;
 		default:
@@ -99,7 +99,7 @@
 			break;
 		}
 		if (fm_info_get_enet_if(i) == PHY_INTERFACE_MODE_QSGMII ||
-		    fm_info_get_enet_if(i) == PHY_INTERFACE_MODE_NONE)
+		    fm_info_get_enet_if(i) == PHY_INTERFACE_MODE_NA)
 			fm_info_set_mdio(i, NULL);
 		else
 			fm_info_set_mdio(i,
diff --git a/board/gdsys/a38x/controlcenterdc.c b/board/gdsys/a38x/controlcenterdc.c
index 7d65400..ccebba7 100644
--- a/board/gdsys/a38x/controlcenterdc.c
+++ b/board/gdsys/a38x/controlcenterdc.c
@@ -194,11 +194,12 @@
 	for (k = 0; k < 2; ++k) {
 		struct phy_device *phydev;
 
-		phydev = phy_find_by_mask(bus, 1 << k,
-					  PHY_INTERFACE_MODE_SGMII);
+		phydev = phy_find_by_mask(bus, 1 << k);
 
-		if (phydev)
+		if (phydev) {
+			phydev->interface = PHY_INTERFACE_MODE_SGMII;
 			phy_config(phydev);
+		}
 	}
 }
 
diff --git a/board/gdsys/a38x/ihs_phys.c b/board/gdsys/a38x/ihs_phys.c
index e09c000..60a5c37 100644
--- a/board/gdsys/a38x/ihs_phys.c
+++ b/board/gdsys/a38x/ihs_phys.c
@@ -28,6 +28,7 @@
 {
 	u16 reg;
 
+	phydev->interface = PHY_INTERFACE_MODE_MII;
 	phy_config(phydev);
 
 	/* enable QSGMII autonegotiation with flow control */
@@ -142,10 +143,9 @@
 int init_single_phy(struct porttype *porttype, struct mii_dev *bus,
 		    uint bus_idx, uint m, uint phy_idx)
 {
-	struct phy_device *phydev = phy_find_by_mask(
-		bus, 1 << (m * 8 + phy_idx),
-		PHY_INTERFACE_MODE_MII);
+	struct phy_device *phydev;
 
+	phydev = phy_find_by_mask(bus, BIT(m * 8 + phy_idx));
 	printf(" %u", bus_idx * 32 + m * 8 + phy_idx);
 
 	if (!phydev)
diff --git a/board/st/stm32f746-disco/stm32f746-disco.c b/board/st/stm32f746-disco/stm32f746-disco.c
index 95d83e7..69f657c 100644
--- a/board/st/stm32f746-disco/stm32f746-disco.c
+++ b/board/st/stm32f746-disco/stm32f746-disco.c
@@ -117,16 +117,13 @@
 int board_init(void)
 {
 #ifdef CONFIG_ETH_DESIGNWARE
-	const char *phy_mode;
-	int node;
+	ofnode node;
 
-	node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, "st,stm32-dwmac");
-	if (node < 0)
+	node = ofnode_by_compatible(ofnode_null(), "st,stm32-dwmac");
+	if (!ofnode_valid(node))
 		return -1;
 
-	phy_mode = fdt_getprop(gd->fdt_blob, node, "phy-mode", NULL);
-
-	switch (phy_get_interface_by_name(phy_mode)) {
+	switch (ofnode_read_phy_mode(node)) {
 	case PHY_INTERFACE_MODE_RMII:
 		STM32_SYSCFG->pmc |= SYSCFG_PMC_MII_RMII_SEL;
 		break;
@@ -134,7 +131,7 @@
 		STM32_SYSCFG->pmc &= ~SYSCFG_PMC_MII_RMII_SEL;
 		break;
 	default:
-		printf("PHY interface %s not supported !\n", phy_mode);
+		printf("Unsupported PHY interface!\n");
 	}
 #endif
 
diff --git a/cmd/ubi.c b/cmd/ubi.c
index fe8ac58..fccbfdf 100644
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -511,6 +511,11 @@
 	struct mtd_info *mtd;
 	int err = 0;
 
+	if (ubi && ubi->mtd && !strcmp(ubi->mtd->name, part_name)) {
+		printf("UBI partition '%s' already selected\n", part_name);
+		return 0;
+	}
+
 	ubi_detach();
 
 	mtd_probe_devices();
diff --git a/configs/M5253DEMO_defconfig b/configs/M5253DEMO_defconfig
index a072f96..6f69aca 100644
--- a/configs/M5253DEMO_defconfig
+++ b/configs/M5253DEMO_defconfig
@@ -37,4 +37,5 @@
 CONFIG_SYS_I2C_SPEED=80000
 CONFIG_MTD_NOR_FLASH=y
 CONFIG_USE_SYS_MAX_FLASH_BANKS=y
+CONFIG_DRIVER_DM9000=y
 CONFIG_MCFUART=y
diff --git a/configs/at91sam9261ek_dataflash_cs0_defconfig b/configs/at91sam9261ek_dataflash_cs0_defconfig
index c43a8a5..2f6651e 100644
--- a/configs/at91sam9261ek_dataflash_cs0_defconfig
+++ b/configs/at91sam9261ek_dataflash_cs0_defconfig
@@ -53,6 +53,7 @@
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH_ATMEL=y
 CONFIG_SPI_FLASH_DATAFLASH=y
+CONFIG_DRIVER_DM9000=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_AT91=y
 CONFIG_DM_SERIAL=y
diff --git a/configs/at91sam9261ek_dataflash_cs3_defconfig b/configs/at91sam9261ek_dataflash_cs3_defconfig
index baf527f..99fecc5 100644
--- a/configs/at91sam9261ek_dataflash_cs3_defconfig
+++ b/configs/at91sam9261ek_dataflash_cs3_defconfig
@@ -53,6 +53,7 @@
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH_ATMEL=y
 CONFIG_SPI_FLASH_DATAFLASH=y
+CONFIG_DRIVER_DM9000=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_AT91=y
 CONFIG_DM_SERIAL=y
diff --git a/configs/at91sam9261ek_nandflash_defconfig b/configs/at91sam9261ek_nandflash_defconfig
index 482a37d..7112746 100644
--- a/configs/at91sam9261ek_nandflash_defconfig
+++ b/configs/at91sam9261ek_nandflash_defconfig
@@ -51,6 +51,7 @@
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH_ATMEL=y
 CONFIG_SPI_FLASH_DATAFLASH=y
+CONFIG_DRIVER_DM9000=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_AT91=y
 CONFIG_DM_SERIAL=y
diff --git a/configs/ci20_mmc_defconfig b/configs/ci20_mmc_defconfig
index ed1ca2c..bcbfaad 100644
--- a/configs/ci20_mmc_defconfig
+++ b/configs/ci20_mmc_defconfig
@@ -49,6 +49,7 @@
 CONFIG_MMC_HS400_SUPPORT=y
 # CONFIG_MMC_VERBOSE is not set
 CONFIG_JZ47XX_MMC=y
+CONFIG_DRIVER_DM9000=y
 CONFIG_DM_SERIAL=y
 CONFIG_SYS_NS16550=y
 CONFIG_SPL_TINY_MEMSET=y
diff --git a/configs/colibri_pxa270_defconfig b/configs/colibri_pxa270_defconfig
index 9ce6586..0a7a2a3 100644
--- a/configs/colibri_pxa270_defconfig
+++ b/configs/colibri_pxa270_defconfig
@@ -50,6 +50,7 @@
 CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
 CONFIG_SYS_FLASH_PROTECTION=y
 CONFIG_SYS_FLASH_CFI=y
+CONFIG_DRIVER_DM9000=y
 CONFIG_DM_SERIAL=y
 CONFIG_PXA_SERIAL=y
 CONFIG_USB=y
diff --git a/configs/devkit8000_defconfig b/configs/devkit8000_defconfig
index e009f21..2bff7df 100644
--- a/configs/devkit8000_defconfig
+++ b/configs/devkit8000_defconfig
@@ -57,6 +57,7 @@
 CONFIG_SYS_NAND_BUSWIDTH_16BIT=y
 CONFIG_SYS_NAND_U_BOOT_LOCATIONS=y
 CONFIG_SYS_NAND_U_BOOT_OFFS=0x80000
+CONFIG_DRIVER_DM9000=y
 CONFIG_CONS_INDEX=3
 CONFIG_JFFS2_NAND=y
 CONFIG_OF_LIBFDT=y
diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
index db748bb..d7f22b3 100644
--- a/configs/sandbox64_defconfig
+++ b/configs/sandbox64_defconfig
@@ -1,5 +1,4 @@
 CONFIG_SYS_TEXT_BASE=0
-CONFIG_SYS_MALLOC_LEN=0x2000000
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_ENV_SIZE=0x2000
 CONFIG_DEFAULT_DEVICE_TREE="sandbox64"
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 0dfc2d8..06dbf38 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -1,5 +1,4 @@
 CONFIG_SYS_TEXT_BASE=0
-CONFIG_SYS_MALLOC_LEN=0x2000000
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_ENV_SIZE=0x2000
 CONFIG_DEFAULT_DEVICE_TREE="sandbox"
diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig
index 27dd38a..2e530ac 100644
--- a/configs/sandbox_flattree_defconfig
+++ b/configs/sandbox_flattree_defconfig
@@ -1,5 +1,4 @@
 CONFIG_SYS_TEXT_BASE=0
-CONFIG_SYS_MALLOC_LEN=0x2000000
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_ENV_SIZE=0x2000
 CONFIG_DEFAULT_DEVICE_TREE="sandbox"
diff --git a/configs/sandbox_noinst_defconfig b/configs/sandbox_noinst_defconfig
index 9eefe4f..c9430da 100644
--- a/configs/sandbox_noinst_defconfig
+++ b/configs/sandbox_noinst_defconfig
@@ -1,5 +1,4 @@
 CONFIG_SYS_TEXT_BASE=0x200000
-CONFIG_SYS_MALLOC_LEN=0x2000000
 CONFIG_SPL_GPIO=y
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
index 0092fea..13a76e8 100644
--- a/configs/sandbox_spl_defconfig
+++ b/configs/sandbox_spl_defconfig
@@ -1,5 +1,4 @@
 CONFIG_SYS_TEXT_BASE=0x200000
-CONFIG_SYS_MALLOC_LEN=0x2000000
 CONFIG_SPL_GPIO=y
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
diff --git a/doc/device-tree-bindings/net/phy/adin.txt b/doc/device-tree-bindings/net/phy/adin.txt
new file mode 100644
index 0000000..d4bab57
--- /dev/null
+++ b/doc/device-tree-bindings/net/phy/adin.txt
@@ -0,0 +1,26 @@
+* Analog Devices ADIN PHY Device Tree binding
+
+Required properties:
+- reg: PHY address
+
+Optional properties:
+- adi,rx-internal-delay-ps: RGMII RX Clock Delay used only when PHY operates
+	in RGMII mode with internal delay (phy-mode is 'rgmii-id' or
+	'rgmii-rxid') in pico-seconds.
+- adi,tx-internal-delay-ps: RGMII TX Clock Delay used only when PHY operates
+	in RGMII mode with internal delay (phy-mode is 'rgmii-id' or
+	'rgmii-txid') in pico-seconds.
+- adi,phy-mode-override: Override phy-mode property for adin. This is useful
+	when a single device tree supports an adin PHY (e.g. ADIN1300)
+	or another PHY (e.g. AR8033) at the same address, but they require
+	different phy-modes.
+
+Example:
+
+	ethernet-phy@0 {
+		reg = <0>;
+
+		adi,rx-internal-delay-ps = <1800>;
+		adi,tx-internal-delay-ps = <2200>;
+		adi,phy-mode-override = "rgmii-id";
+	};
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index 8042847..a59832e 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -1198,3 +1198,47 @@
 
 	return ofnode_read_string(node, prop_name);
 }
+
+ofnode ofnode_get_phy_node(ofnode node)
+{
+	/* DT node properties that reference a PHY node */
+	static const char * const phy_handle_str[] = {
+		"phy-handle", "phy", "phy-device",
+	};
+	struct ofnode_phandle_args args = {
+		.node = ofnode_null()
+	};
+	int i;
+
+	assert(ofnode_valid(node));
+
+	for (i = 0; i < ARRAY_SIZE(phy_handle_str); i++)
+		if (!ofnode_parse_phandle_with_args(node, phy_handle_str[i],
+						    NULL, 0, 0, &args))
+			break;
+
+	return args.node;
+}
+
+phy_interface_t ofnode_read_phy_mode(ofnode node)
+{
+	const char *mode;
+	int i;
+
+	assert(ofnode_valid(node));
+
+	mode = ofnode_read_string(node, "phy-mode");
+	if (!mode)
+		mode = ofnode_read_string(node, "phy-connection-type");
+
+	if (!mode)
+		return PHY_INTERFACE_MODE_NA;
+
+	for (i = 0; i < PHY_INTERFACE_MODE_MAX; i++)
+		if (!strcmp(mode, phy_interface_strings[i]))
+			return i;
+
+	debug("%s: Invalid PHY interface '%s'\n", __func__, mode);
+
+	return PHY_INTERFACE_MODE_NA;
+}
diff --git a/drivers/core/read.c b/drivers/core/read.c
index 31f9e78..c73508d 100644
--- a/drivers/core/read.c
+++ b/drivers/core/read.c
@@ -398,3 +398,13 @@
 {
 	return ofnode_decode_display_timing(dev_ofnode(dev), index, config);
 }
+
+ofnode dev_get_phy_node(const struct udevice *dev)
+{
+	return ofnode_get_phy_node(dev_ofnode(dev));
+}
+
+phy_interface_t dev_read_phy_mode(const struct udevice *dev)
+{
+	return ofnode_read_phy_mode(dev_ofnode(dev));
+}
diff --git a/drivers/led/led-uclass.c b/drivers/led/led-uclass.c
index 7e298db..5d7bf40 100644
--- a/drivers/led/led-uclass.c
+++ b/drivers/led/led-uclass.c
@@ -66,37 +66,56 @@
 }
 #endif
 
+/* This is superseded by led_post_bind()/led_post_probe() below. */
 int led_default_state(void)
 {
-	struct udevice *dev;
-	struct uclass *uc;
+	return 0;
+}
+
+static int led_post_bind(struct udevice *dev)
+{
+	struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev);
 	const char *default_state;
-	int ret;
 
-	ret = uclass_get(UCLASS_LED, &uc);
-	if (ret)
-		return ret;
-	for (uclass_find_first_device(UCLASS_LED, &dev);
-	     dev;
-	     uclass_find_next_device(&dev)) {
-		default_state = dev_read_string(dev, "default-state");
-		if (!default_state)
-			continue;
-		ret = device_probe(dev);
-		if (ret)
-			return ret;
-		if (!strncmp(default_state, "on", 2))
-			led_set_state(dev, LEDST_ON);
-		else if (!strncmp(default_state, "off", 3))
-			led_set_state(dev, LEDST_OFF);
-		/* default-state = "keep" : device is only probed */
-	}
+	uc_plat->label = dev_read_string(dev, "label");
+	if (!uc_plat->label)
+		uc_plat->label = ofnode_get_name(dev_ofnode(dev));
 
-	return ret;
+	uc_plat->default_state = LEDST_COUNT;
+
+	default_state = dev_read_string(dev, "default-state");
+	if (!default_state)
+		return 0;
+
+	if (!strncmp(default_state, "on", 2))
+		uc_plat->default_state = LEDST_ON;
+	else if (!strncmp(default_state, "off", 3))
+		uc_plat->default_state = LEDST_OFF;
+	else
+		return 0;
+
+	/*
+	 * In case the LED has default-state DT property, trigger
+	 * probe() to configure its default state during startup.
+	 */
+	return device_probe(dev);
+}
+
+static int led_post_probe(struct udevice *dev)
+{
+	struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev);
+
+	if (uc_plat->default_state == LEDST_ON ||
+	    uc_plat->default_state == LEDST_OFF)
+		led_set_state(dev, uc_plat->default_state);
+
+	return 0;
 }
 
 UCLASS_DRIVER(led) = {
 	.id		= UCLASS_LED,
 	.name		= "led",
 	.per_device_plat_auto	= sizeof(struct led_uc_plat),
+	.post_bind	= led_post_bind,
+	.post_probe	= led_post_probe,
 };
diff --git a/drivers/led/led_bcm6328.c b/drivers/led/led_bcm6328.c
index bf8207d..f59a92f 100644
--- a/drivers/led/led_bcm6328.c
+++ b/drivers/led/led_bcm6328.c
@@ -204,26 +204,14 @@
 	ofnode node;
 
 	dev_for_each_subnode(node, parent) {
-		struct led_uc_plat *uc_plat;
 		struct udevice *dev;
-		const char *label;
 		int ret;
 
-		label = ofnode_read_string(node, "label");
-		if (!label) {
-			debug("%s: node %s has no label\n", __func__,
-			      ofnode_get_name(node));
-			return -EINVAL;
-		}
-
 		ret = device_bind_driver_to_node(parent, "bcm6328-led",
 						 ofnode_get_name(node),
 						 node, &dev);
 		if (ret)
 			return ret;
-
-		uc_plat = dev_get_uclass_plat(dev);
-		uc_plat->label = label;
 	}
 
 	return 0;
diff --git a/drivers/led/led_bcm6358.c b/drivers/led/led_bcm6358.c
index 3e57cdf..25aa399 100644
--- a/drivers/led/led_bcm6358.c
+++ b/drivers/led/led_bcm6358.c
@@ -174,26 +174,14 @@
 	ofnode node;
 
 	dev_for_each_subnode(node, parent) {
-		struct led_uc_plat *uc_plat;
 		struct udevice *dev;
-		const char *label;
 		int ret;
 
-		label = ofnode_read_string(node, "label");
-		if (!label) {
-			debug("%s: node %s has no label\n", __func__,
-			      ofnode_get_name(node));
-			return -EINVAL;
-		}
-
 		ret = device_bind_driver_to_node(parent, "bcm6358-led",
 						 ofnode_get_name(node),
 						 node, &dev);
 		if (ret)
 			return ret;
-
-		uc_plat = dev_get_uclass_plat(dev);
-		uc_plat->label = label;
 	}
 
 	return 0;
diff --git a/drivers/led/led_bcm6753.c b/drivers/led/led_bcm6753.c
index a32bd82..88b650c 100644
--- a/drivers/led/led_bcm6753.c
+++ b/drivers/led/led_bcm6753.c
@@ -229,26 +229,14 @@
 	ofnode node;
 
 	dev_for_each_subnode(node, parent) {
-		struct led_uc_plat *uc_plat;
 		struct udevice *dev;
-		const char *label;
 		int ret;
 
-		label = ofnode_read_string(node, "label");
-		if (!label) {
-			debug("%s: node %s has no label\n", __func__,
-			      ofnode_get_name(node));
-			return -EINVAL;
-		}
-
 		ret = device_bind_driver_to_node(parent, "bcm6753-led",
 						 ofnode_get_name(node),
 						 node, &dev);
 		if (ret)
 			return ret;
-
-		uc_plat = dev_get_uclass_plat(dev);
-		uc_plat->label = label;
 	}
 
 	return 0;
diff --git a/drivers/led/led_bcm6858.c b/drivers/led/led_bcm6858.c
index 3ca6c5b..6b36986 100644
--- a/drivers/led/led_bcm6858.c
+++ b/drivers/led/led_bcm6858.c
@@ -241,26 +241,14 @@
 	ofnode node;
 
 	dev_for_each_subnode(node, parent) {
-		struct led_uc_plat *uc_plat;
 		struct udevice *dev;
-		const char *label;
 		int ret;
 
-		label = ofnode_read_string(node, "label");
-		if (!label) {
-			debug("%s: node %s has no label\n", __func__,
-			      ofnode_get_name(node));
-			return -EINVAL;
-		}
-
 		ret = device_bind_driver_to_node(parent, "bcm6858-led",
 						 ofnode_get_name(node),
 						 node, &dev);
 		if (ret)
 			return ret;
-
-		uc_plat = dev_get_uclass_plat(dev);
-		uc_plat->label = label;
 	}
 
 	return 0;
diff --git a/drivers/led/led_cortina.c b/drivers/led/led_cortina.c
index 598c0a0..bcbe78d 100644
--- a/drivers/led/led_cortina.c
+++ b/drivers/led/led_cortina.c
@@ -256,25 +256,14 @@
 	ofnode node;
 
 	dev_for_each_subnode(node, parent) {
-		struct led_uc_plat *uc_plat;
 		struct udevice *dev;
-		const char *label;
 		int ret;
 
-		label = ofnode_read_string(node, "label");
-		if (!label) {
-			debug("%s: node %s has no label\n", __func__,
-			      ofnode_get_name(node));
-			return -EINVAL;
-		}
-
 		ret = device_bind_driver_to_node(parent, "ca-leds",
 						 ofnode_get_name(node),
 						 node, &dev);
 		if (ret)
 			return ret;
-		uc_plat = dev_get_uclass_plat(dev);
-		uc_plat->label = label;
 	}
 
 	return 0;
diff --git a/drivers/led/led_gpio.c b/drivers/led/led_gpio.c
index 67ece3c..958dbd3 100644
--- a/drivers/led/led_gpio.c
+++ b/drivers/led/led_gpio.c
@@ -95,19 +95,11 @@
 	int ret;
 
 	dev_for_each_subnode(node, parent) {
-		struct led_uc_plat *uc_plat;
-		const char *label;
-
-		label = ofnode_read_string(node, "label");
-		if (!label)
-			label = ofnode_get_name(node);
 		ret = device_bind_driver_to_node(parent, "gpio_led",
 						 ofnode_get_name(node),
 						 node, &dev);
 		if (ret)
 			return ret;
-		uc_plat = dev_get_uclass_plat(dev);
-		uc_plat->label = label;
 	}
 
 	return 0;
diff --git a/drivers/led/led_pwm.c b/drivers/led/led_pwm.c
index 4e50272..10bd163 100644
--- a/drivers/led/led_pwm.c
+++ b/drivers/led/led_pwm.c
@@ -151,21 +151,11 @@
 	int ret;
 
 	dev_for_each_subnode(node, parent) {
-		struct led_uc_plat *uc_plat;
-		const char *label;
-
-		label = ofnode_read_string(node, "label");
-		if (!label)
-			label = ofnode_get_name(node);
-
 		ret = device_bind_driver_to_node(parent, LEDS_PWM_DRIVER_NAME,
 						 ofnode_get_name(node),
 						 node, &dev);
 		if (ret)
 			return ret;
-
-		uc_plat = dev_get_uclass_plat(dev);
-		uc_plat->label = label;
 	}
 	return 0;
 }
diff --git a/drivers/misc/atsha204a-i2c.c b/drivers/misc/atsha204a-i2c.c
index b89463b..63fe541 100644
--- a/drivers/misc/atsha204a-i2c.c
+++ b/drivers/misc/atsha204a-i2c.c
@@ -146,7 +146,7 @@
 	while (len--)
 		crc = crc16_byte(crc, *buffer++);
 
-	return cpu_to_le16(crc);
+	return crc;
 }
 
 static int atsha204a_send(struct udevice *dev, const u8 *buf, u8 len)
diff --git a/drivers/misc/qfw.c b/drivers/misc/qfw.c
index 677841a..1d54b75 100644
--- a/drivers/misc/qfw.c
+++ b/drivers/misc/qfw.c
@@ -15,9 +15,6 @@
 #include <dm.h>
 #include <misc.h>
 #include <tables_csum.h>
-#ifdef CONFIG_GENERATE_ACPI_TABLE
-#include <asm/tables.h>
-#endif
 
 #if defined(CONFIG_GENERATE_ACPI_TABLE) && !defined(CONFIG_SANDBOX)
 /*
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index a6171a7..347fe8a 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -191,6 +191,11 @@
 	  This driver supports the XGMAC in Calxeda Highbank and Midway
 	  machines.
 
+config DRIVER_DM9000
+	bool "Davicom DM9000 controller driver"
+	help
+	  The Davicom DM9000 parallel bus external ethernet interface chip.
+
 config DWC_ETH_QOS
 	bool "Synopsys DWC Ethernet QOS device support"
 	depends on DM_ETH
diff --git a/drivers/net/ag7xxx.c b/drivers/net/ag7xxx.c
index 632ab3c..a16c998 100644
--- a/drivers/net/ag7xxx.c
+++ b/drivers/net/ag7xxx.c
@@ -1254,7 +1254,6 @@
 static int ag7xxx_eth_of_to_plat(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_plat(dev);
-	const char *phy_mode;
 	int ret;
 
 	pdata->iobase = dev_read_addr(dev);
@@ -1265,13 +1264,9 @@
 	if (ret <= 0)
 		return ret;
 
-	phy_mode = fdt_getprop(gd->fdt_blob, ret, "phy-mode", NULL);
-	if (phy_mode)
-		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
-	if (pdata->phy_interface == -1) {
-		debug("%s: Invalid PHY interface '%s'\n", __func__, phy_mode);
+	pdata->phy_interface = dev_read_phy_mode(dev);
+	if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
 		return -EINVAL;
-	}
 
 	return 0;
 }
diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c
index eb4cd96..912d28f 100644
--- a/drivers/net/altera_tse.c
+++ b/drivers/net/altera_tse.c
@@ -435,11 +435,11 @@
 	if (priv->phyaddr)
 		mask = 1 << priv->phyaddr;
 
-	phydev = phy_find_by_mask(priv->bus, mask, priv->interface);
+	phydev = phy_find_by_mask(priv->bus, mask);
 	if (!phydev)
 		return -ENODEV;
 
-	phy_connect_dev(phydev, dev);
+	phy_connect_dev(phydev, dev, priv->interface);
 
 	phydev->supported &= PHY_GBIT_FEATURES;
 	phydev->advertising = phydev->supported;
@@ -676,17 +676,10 @@
 static int altera_tse_of_to_plat(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_plat(dev);
-	const char *phy_mode;
 
-	pdata->phy_interface = -1;
-	phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
-			       NULL);
-	if (phy_mode)
-		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
-	if (pdata->phy_interface == -1) {
-		debug("%s: Invalid PHY interface '%s'\n", __func__, phy_mode);
+	pdata->phy_interface = dev_read_phy_mode(dev);
+	if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
 		return -EINVAL;
-	}
 
 	return 0;
 }
diff --git a/drivers/net/bcm6348-eth.c b/drivers/net/bcm6348-eth.c
index 06e0dd7..5317173 100644
--- a/drivers/net/bcm6348-eth.c
+++ b/drivers/net/bcm6348-eth.c
@@ -415,7 +415,6 @@
 	struct eth_pdata *pdata = dev_get_plat(dev);
 	struct bcm6348_eth_priv *priv = dev_get_priv(dev);
 	struct ofnode_phandle_args phy;
-	const char *phy_mode;
 	int ret, i;
 
 	/* get base address */
@@ -425,11 +424,8 @@
 	pdata->iobase = (phys_addr_t) priv->base;
 
 	/* get phy mode */
-	pdata->phy_interface = PHY_INTERFACE_MODE_NONE;
-	phy_mode = dev_read_string(dev, "phy-mode");
-	if (phy_mode)
-		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
-	if (pdata->phy_interface == PHY_INTERFACE_MODE_NONE)
+	pdata->phy_interface = dev_read_phy_mode(dev);
+	if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
 		return -ENODEV;
 
 	/* get phy */
diff --git a/drivers/net/bcmgenet.c b/drivers/net/bcmgenet.c
index 6783956..4e1f8ed 100644
--- a/drivers/net/bcmgenet.c
+++ b/drivers/net/bcmgenet.c
@@ -526,8 +526,6 @@
 	}
 	phydev->advertising = phydev->supported;
 
-	phy_connect_dev(phydev, dev);
-
 	priv->phydev = phydev;
 	phy_config(priv->phydev);
 
@@ -690,20 +688,14 @@
 	struct eth_pdata *pdata = dev_get_plat(dev);
 	struct bcmgenet_eth_priv *priv = dev_get_priv(dev);
 	struct ofnode_phandle_args phy_node;
-	const char *phy_mode;
 	int ret;
 
 	pdata->iobase = dev_read_addr(dev);
 
 	/* Get phy mode from DT */
-	pdata->phy_interface = -1;
-	phy_mode = dev_read_string(dev, "phy-mode");
-	if (phy_mode)
-		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
-	if (pdata->phy_interface == -1) {
-		debug("%s: Invalid PHY interface '%s'\n", __func__, phy_mode);
+	pdata->phy_interface = dev_read_phy_mode(dev);
+	if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
 		return -EINVAL;
-	}
 
 	ret = dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
 					 &phy_node);
diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 5aaac60..1584b9e 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -914,21 +914,15 @@
 	struct dw_eth_dev *priv = dev_get_priv(dev);
 #endif
 	struct eth_pdata *pdata = &dw_pdata->eth_pdata;
-	const char *phy_mode;
 #if CONFIG_IS_ENABLED(DM_GPIO)
 	int reset_flags = GPIOD_IS_OUT;
 #endif
 	int ret = 0;
 
 	pdata->iobase = dev_read_addr(dev);
-	pdata->phy_interface = -1;
-	phy_mode = dev_read_string(dev, "phy-mode");
-	if (phy_mode)
-		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
-	if (pdata->phy_interface == -1) {
-		debug("%s: Invalid PHY interface '%s'\n", __func__, phy_mode);
+	pdata->phy_interface = dev_read_phy_mode(dev);
+	if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
 		return -EINVAL;
-	}
 
 	pdata->max_speed = dev_read_u32_default(dev, "max-speed", 0);
 
diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
index 4f062e9..78ce536 100644
--- a/drivers/net/dm9000x.c
+++ b/drivers/net/dm9000x.c
@@ -1,86 +1,66 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
-  dm9000.c: Version 1.2 12/15/2003
-
-	A Davicom DM9000 ISA NIC fast Ethernet driver for Linux.
-	Copyright (C) 1997  Sten Wang
-
-  (C)Copyright 1997-1998 DAVICOM Semiconductor,Inc. All Rights Reserved.
-
-V0.11	06/20/2001	REG_0A bit3=1, default enable BP with DA match
-	06/22/2001	Support DM9801 progrmming
-			E3: R25 = ((R24 + NF) & 0x00ff) | 0xf000
-			E4: R25 = ((R24 + NF) & 0x00ff) | 0xc200
-		R17 = (R17 & 0xfff0) | NF + 3
-			E5: R25 = ((R24 + NF - 3) & 0x00ff) | 0xc200
-		R17 = (R17 & 0xfff0) | NF
-
-v1.00			modify by simon 2001.9.5
-			change for kernel 2.4.x
-
-v1.1   11/09/2001	fix force mode bug
-
-v1.2   03/18/2003       Weilun Huang <weilun_huang@davicom.com.tw>:
-			Fixed phy reset.
-			Added tx/rx 32 bit mode.
-			Cleaned up for kernel merge.
-
---------------------------------------
-
-       12/15/2003       Initial port to u-boot by
-			Sascha Hauer <saschahauer@web.de>
-
-       06/03/2008	Remy Bohmer <linux@bohmer.net>
-			- Fixed the driver to work with DM9000A.
-			  (check on ISR receive status bit before reading the
-			  FIFO as described in DM9000 programming guide and
-			  application notes)
-			- Added autodetect of databus width.
-			- Made debug code compile again.
-			- Adapt eth_send such that it matches the DM9000*
-			  application notes. Needed to make it work properly
-			  for DM9000A.
-			- Adapted reset procedure to match DM9000 application
-			  notes (i.e. double reset)
-			- some minor code cleanups
-			These changes are tested with DM9000{A,EP,E} together
-			with a 200MHz Atmel AT91SAM9261 core
-
-TODO: external MII is not functional, only internal at the moment.
-*/
+ *   dm9000.c: Version 1.2 12/15/2003
+ *
+ *	A Davicom DM9000 ISA NIC fast Ethernet driver for Linux.
+ *	Copyright (C) 1997  Sten Wang
+ *
+ *   (C)Copyright 1997-1998 DAVICOM Semiconductor,Inc. All Rights Reserved.
+ *
+ * V0.11	06/20/2001	REG_0A bit3=1, default enable BP with DA match
+ *	06/22/2001	Support DM9801 progrmming
+ *			E3: R25 = ((R24 + NF) & 0x00ff) | 0xf000
+ *			E4: R25 = ((R24 + NF) & 0x00ff) | 0xc200
+ *		R17 = (R17 & 0xfff0) | NF + 3
+ *			E5: R25 = ((R24 + NF - 3) & 0x00ff) | 0xc200
+ *		R17 = (R17 & 0xfff0) | NF
+ *
+ * v1.00			modify by simon 2001.9.5
+ *			change for kernel 2.4.x
+ *
+ * v1.1   11/09/2001	fix force mode bug
+ *
+ * v1.2   03/18/2003       Weilun Huang <weilun_huang@davicom.com.tw>:
+ *			Fixed phy reset.
+ *			Added tx/rx 32 bit mode.
+ *			Cleaned up for kernel merge.
+ *
+ * --------------------------------------
+ *
+ *        12/15/2003       Initial port to u-boot by
+ *			Sascha Hauer <saschahauer@web.de>
+ *
+ *        06/03/2008	Remy Bohmer <linux@bohmer.net>
+ *			- Fixed the driver to work with DM9000A.
+ *			  (check on ISR receive status bit before reading the
+ *			  FIFO as described in DM9000 programming guide and
+ *			  application notes)
+ *			- Added autodetect of databus width.
+ *			- Made debug code compile again.
+ *			- Adapt eth_send such that it matches the DM9000*
+ *			  application notes. Needed to make it work properly
+ *			  for DM9000A.
+ *			- Adapted reset procedure to match DM9000 application
+ *			  notes (i.e. double reset)
+ *			- some minor code cleanups
+ *			These changes are tested with DM9000{A,EP,E} together
+ *			with a 200MHz Atmel AT91SAM9261 core
+ *
+ * TODO: external MII is not functional, only internal at the moment.
+ */
 
 #include <common.h>
 #include <command.h>
+#include <dm.h>
+#include <malloc.h>
 #include <net.h>
 #include <asm/io.h>
-#include <dm9000.h>
 #include <linux/delay.h>
 
 #include "dm9000x.h"
 
-/* Board/System/Debug information/definition ---------------- */
-
-/* #define CONFIG_DM9000_DEBUG */
-
-#ifdef CONFIG_DM9000_DEBUG
-#define DM9000_DBG(fmt,args...) printf(fmt, ##args)
-#define DM9000_DMP_PACKET(func,packet,length)  \
-	do { \
-		int i;							\
-		printf("%s: length: %d\n", func, length);		\
-		for (i = 0; i < length; i++) {				\
-			if (i % 8 == 0)					\
-				printf("\n%s: %02x: ", func, i);	\
-			printf("%02x ", ((unsigned char *) packet)[i]);	\
-		} printf("\n");						\
-	} while(0)
-#else
-#define DM9000_DBG(fmt,args...)
-#define DM9000_DMP_PACKET(func,packet,length)
-#endif
-
 /* Structure/enum declaration ------------------------------- */
-typedef struct board_info {
+struct dm9000_priv {
 	u32 runt_length_counter;	/* counter: RX length < 64byte */
 	u32 long_length_counter;	/* counter: RX length > 1514byte */
 	u32 reset_counter;	/* counter: RESET */
@@ -92,209 +72,261 @@
 	u8 phy_addr;
 	u8 device_wait_reset;	/* device state */
 	unsigned char srom[128];
-	void (*outblk)(volatile void *data_ptr, int count);
-	void (*inblk)(void *data_ptr, int count);
-	void (*rx_status)(u16 *RxStatus, u16 *RxLen);
-	struct eth_device netdev;
-} board_info_t;
-static board_info_t dm9000_info;
-
-
-/* function declaration ------------------------------------- */
-static int dm9000_probe(void);
-static u16 dm9000_phy_read(int);
-static void dm9000_phy_write(int, u16);
-static u8 DM9000_ior(int);
-static void DM9000_iow(int reg, u8 value);
+	void (*outblk)(struct dm9000_priv *db, void *data_ptr, int count);
+	void (*inblk)(struct dm9000_priv *db, void *data_ptr, int count);
+	void (*rx_status)(struct dm9000_priv *db, u16 *rxstatus, u16 *rxlen);
+#ifndef CONFIG_DM_ETH
+	struct eth_device dev;
+#endif
+	void __iomem *base_io;
+	void __iomem *base_data;
+};
 
 /* DM9000 network board routine ---------------------------- */
 #ifndef CONFIG_DM9000_BYTE_SWAPPED
-#define DM9000_outb(d,r) writeb(d, (volatile u8 *)(r))
-#define DM9000_outw(d,r) writew(d, (volatile u16 *)(r))
-#define DM9000_outl(d,r) writel(d, (volatile u32 *)(r))
-#define DM9000_inb(r) readb((volatile u8 *)(r))
-#define DM9000_inw(r) readw((volatile u16 *)(r))
-#define DM9000_inl(r) readl((volatile u32 *)(r))
+#define dm9000_outb(d, r) writeb((d), (r))
+#define dm9000_outw(d, r) writew((d), (r))
+#define dm9000_outl(d, r) writel((d), (r))
+#define dm9000_inb(r) readb(r)
+#define dm9000_inw(r) readw(r)
+#define dm9000_inl(r) readl(r)
 #else
-#define DM9000_outb(d, r) __raw_writeb(d, r)
-#define DM9000_outw(d, r) __raw_writew(d, r)
-#define DM9000_outl(d, r) __raw_writel(d, r)
-#define DM9000_inb(r) __raw_readb(r)
-#define DM9000_inw(r) __raw_readw(r)
-#define DM9000_inl(r) __raw_readl(r)
+#define dm9000_outb(d, r) __raw_writeb(d, r)
+#define dm9000_outw(d, r) __raw_writew(d, r)
+#define dm9000_outl(d, r) __raw_writel(d, r)
+#define dm9000_inb(r) __raw_readb(r)
+#define dm9000_inw(r) __raw_readw(r)
+#define dm9000_inl(r) __raw_readl(r)
 #endif
 
-#ifdef CONFIG_DM9000_DEBUG
-static void
-dump_regs(void)
-{
-	DM9000_DBG("\n");
-	DM9000_DBG("NCR   (0x00): %02x\n", DM9000_ior(0));
-	DM9000_DBG("NSR   (0x01): %02x\n", DM9000_ior(1));
-	DM9000_DBG("TCR   (0x02): %02x\n", DM9000_ior(2));
-	DM9000_DBG("TSRI  (0x03): %02x\n", DM9000_ior(3));
-	DM9000_DBG("TSRII (0x04): %02x\n", DM9000_ior(4));
-	DM9000_DBG("RCR   (0x05): %02x\n", DM9000_ior(5));
-	DM9000_DBG("RSR   (0x06): %02x\n", DM9000_ior(6));
-	DM9000_DBG("ISR   (0xFE): %02x\n", DM9000_ior(DM9000_ISR));
-	DM9000_DBG("\n");
-}
-#endif
-
-static void dm9000_outblk_8bit(volatile void *data_ptr, int count)
+#ifdef DEBUG
+static void dm9000_dump_packet(const char *func, u8 *packet, int length)
 {
 	int i;
+
+	printf("%s: length: %d\n", func, length);
+
+	for (i = 0; i < length; i++) {
+		if (i % 8 == 0)
+			printf("\n%s: %02x: ", func, i);
+		printf("%02x ", packet[i]);
+	}
+
+	printf("\n");
+}
+#else
+static void dm9000_dump_packet(const char *func, u8 *packet, int length) {}
+#endif
+
+static void dm9000_outblk_8bit(struct dm9000_priv *db, void *data_ptr, int count)
+{
+	int i;
+
 	for (i = 0; i < count; i++)
-		DM9000_outb((((u8 *) data_ptr)[i] & 0xff), DM9000_DATA);
+		dm9000_outb((((u8 *)data_ptr)[i] & 0xff), db->base_data);
 }
 
-static void dm9000_outblk_16bit(volatile void *data_ptr, int count)
+static void dm9000_outblk_16bit(struct dm9000_priv *db, void *data_ptr, int count)
 {
 	int i;
 	u32 tmplen = (count + 1) / 2;
 
 	for (i = 0; i < tmplen; i++)
-		DM9000_outw(((u16 *) data_ptr)[i], DM9000_DATA);
+		dm9000_outw(((u16 *)data_ptr)[i], db->base_data);
 }
-static void dm9000_outblk_32bit(volatile void *data_ptr, int count)
+
+static void dm9000_outblk_32bit(struct dm9000_priv *db, void *data_ptr, int count)
 {
 	int i;
 	u32 tmplen = (count + 3) / 4;
 
 	for (i = 0; i < tmplen; i++)
-		DM9000_outl(((u32 *) data_ptr)[i], DM9000_DATA);
+		dm9000_outl(((u32 *)data_ptr)[i], db->base_data);
 }
 
-static void dm9000_inblk_8bit(void *data_ptr, int count)
+static void dm9000_inblk_8bit(struct dm9000_priv *db, void *data_ptr, int count)
 {
 	int i;
+
 	for (i = 0; i < count; i++)
-		((u8 *) data_ptr)[i] = DM9000_inb(DM9000_DATA);
+		((u8 *)data_ptr)[i] = dm9000_inb(db->base_data);
 }
 
-static void dm9000_inblk_16bit(void *data_ptr, int count)
+static void dm9000_inblk_16bit(struct dm9000_priv *db, void *data_ptr, int count)
 {
 	int i;
 	u32 tmplen = (count + 1) / 2;
 
 	for (i = 0; i < tmplen; i++)
-		((u16 *) data_ptr)[i] = DM9000_inw(DM9000_DATA);
+		((u16 *)data_ptr)[i] = dm9000_inw(db->base_data);
 }
-static void dm9000_inblk_32bit(void *data_ptr, int count)
+
+static void dm9000_inblk_32bit(struct dm9000_priv *db, void *data_ptr, int count)
 {
 	int i;
 	u32 tmplen = (count + 3) / 4;
 
 	for (i = 0; i < tmplen; i++)
-		((u32 *) data_ptr)[i] = DM9000_inl(DM9000_DATA);
+		((u32 *)data_ptr)[i] = dm9000_inl(db->base_data);
 }
 
-static void dm9000_rx_status_32bit(u16 *RxStatus, u16 *RxLen)
+static void dm9000_rx_status_32bit(struct dm9000_priv *db, u16 *rxstatus, u16 *rxlen)
 {
 	u32 tmpdata;
 
-	DM9000_outb(DM9000_MRCMD, DM9000_IO);
+	dm9000_outb(DM9000_MRCMD, db->base_io);
 
-	tmpdata = DM9000_inl(DM9000_DATA);
-	*RxStatus = __le16_to_cpu(tmpdata);
-	*RxLen = __le16_to_cpu(tmpdata >> 16);
+	tmpdata = dm9000_inl(db->base_data);
+	*rxstatus = __le16_to_cpu(tmpdata);
+	*rxlen = __le16_to_cpu(tmpdata >> 16);
 }
 
-static void dm9000_rx_status_16bit(u16 *RxStatus, u16 *RxLen)
+static void dm9000_rx_status_16bit(struct dm9000_priv *db, u16 *rxstatus, u16 *rxlen)
 {
-	DM9000_outb(DM9000_MRCMD, DM9000_IO);
+	dm9000_outb(DM9000_MRCMD, db->base_io);
 
-	*RxStatus = __le16_to_cpu(DM9000_inw(DM9000_DATA));
-	*RxLen = __le16_to_cpu(DM9000_inw(DM9000_DATA));
+	*rxstatus = __le16_to_cpu(dm9000_inw(db->base_data));
+	*rxlen = __le16_to_cpu(dm9000_inw(db->base_data));
 }
 
-static void dm9000_rx_status_8bit(u16 *RxStatus, u16 *RxLen)
+static void dm9000_rx_status_8bit(struct dm9000_priv *db, u16 *rxstatus, u16 *rxlen)
 {
-	DM9000_outb(DM9000_MRCMD, DM9000_IO);
+	dm9000_outb(DM9000_MRCMD, db->base_io);
 
-	*RxStatus =
-	    __le16_to_cpu(DM9000_inb(DM9000_DATA) +
-			  (DM9000_inb(DM9000_DATA) << 8));
-	*RxLen =
-	    __le16_to_cpu(DM9000_inb(DM9000_DATA) +
-			  (DM9000_inb(DM9000_DATA) << 8));
+	*rxstatus =
+	    __le16_to_cpu(dm9000_inb(db->base_data) +
+			  (dm9000_inb(db->base_data) << 8));
+	*rxlen =
+	    __le16_to_cpu(dm9000_inb(db->base_data) +
+			  (dm9000_inb(db->base_data) << 8));
 }
 
 /*
-  Search DM9000 board, allocate space and register it
-*/
-int
-dm9000_probe(void)
+ *  Read a byte from I/O port
+ */
+static u8 dm9000_ior(struct dm9000_priv *db, int reg)
+{
+	dm9000_outb(reg, db->base_io);
+	return dm9000_inb(db->base_data);
+}
+
+/*
+ *  Write a byte to I/O port
+ */
+static void dm9000_iow(struct dm9000_priv *db, int reg, u8 value)
+{
+	dm9000_outb(reg, db->base_io);
+	dm9000_outb(value, db->base_data);
+}
+
+/*
+ *  Read a word from phyxcer
+ */
+static u16 dm9000_phy_read(struct dm9000_priv *db, int reg)
+{
+	u16 val;
+
+	/* Fill the phyxcer register into REG_0C */
+	dm9000_iow(db, DM9000_EPAR, DM9000_PHY | reg);
+	dm9000_iow(db, DM9000_EPCR, 0xc);	/* Issue phyxcer read command */
+	udelay(100);			/* Wait read complete */
+	dm9000_iow(db, DM9000_EPCR, 0x0);	/* Clear phyxcer read command */
+	val = (dm9000_ior(db, DM9000_EPDRH) << 8) |
+	      dm9000_ior(db, DM9000_EPDRL);
+
+	/* The read data keeps on REG_0D & REG_0E */
+	debug("%s(0x%x): 0x%x\n", __func__, reg, val);
+	return val;
+}
+
+/*
+ *  Write a word to phyxcer
+ */
+static void dm9000_phy_write(struct dm9000_priv *db, int reg, u16 value)
+{
+	/* Fill the phyxcer register into REG_0C */
+	dm9000_iow(db, DM9000_EPAR, DM9000_PHY | reg);
+
+	/* Fill the written data into REG_0D & REG_0E */
+	dm9000_iow(db, DM9000_EPDRL, (value & 0xff));
+	dm9000_iow(db, DM9000_EPDRH, ((value >> 8) & 0xff));
+	dm9000_iow(db, DM9000_EPCR, 0xa);	/* Issue phyxcer write command */
+	udelay(500);			/* Wait write complete */
+	dm9000_iow(db, DM9000_EPCR, 0x0);	/* Clear phyxcer write command */
+	debug("%s(reg:0x%x, value:0x%x)\n", __func__, reg, value);
+}
+
+/*
+ * Search DM9000 board, allocate space and register it
+ */
+static int dm9000_probe(struct dm9000_priv *db)
 {
 	u32 id_val;
-	id_val = DM9000_ior(DM9000_VIDL);
-	id_val |= DM9000_ior(DM9000_VIDH) << 8;
-	id_val |= DM9000_ior(DM9000_PIDL) << 16;
-	id_val |= DM9000_ior(DM9000_PIDH) << 24;
-	if (id_val == DM9000_ID) {
-		printf("dm9000 i/o: 0x%x, id: 0x%x \n", CONFIG_DM9000_BASE,
-		       id_val);
-		return 0;
-	} else {
-		printf("dm9000 not found at 0x%08x id: 0x%08x\n",
-		       CONFIG_DM9000_BASE, id_val);
+
+	id_val = dm9000_ior(db, DM9000_VIDL);
+	id_val |= dm9000_ior(db, DM9000_VIDH) << 8;
+	id_val |= dm9000_ior(db, DM9000_PIDL) << 16;
+	id_val |= dm9000_ior(db, DM9000_PIDH) << 24;
+	if (id_val != DM9000_ID) {
+		printf("dm9000 not found at 0x%p id: 0x%08x\n",
+		       db->base_io, id_val);
 		return -1;
 	}
+
+	printf("dm9000 i/o: 0x%p, id: 0x%x\n", db->base_io, id_val);
+	return 0;
 }
 
 /* General Purpose dm9000 reset routine */
-static void
-dm9000_reset(void)
+static void dm9000_reset(struct dm9000_priv *db)
 {
-	DM9000_DBG("resetting DM9000\n");
+	debug("resetting DM9000\n");
 
-	/* Reset DM9000,
-	   see DM9000 Application Notes V1.22 Jun 11, 2004 page 29 */
+	/*
+	 * Reset DM9000,
+	 * see DM9000 Application Notes V1.22 Jun 11, 2004 page 29
+	 */
 
 	/* DEBUG: Make all GPIO0 outputs, all others inputs */
-	DM9000_iow(DM9000_GPCR, GPCR_GPIO0_OUT);
+	dm9000_iow(db, DM9000_GPCR, GPCR_GPIO0_OUT);
 	/* Step 1: Power internal PHY by writing 0 to GPIO0 pin */
-	DM9000_iow(DM9000_GPR, 0);
+	dm9000_iow(db, DM9000_GPR, 0);
 	/* Step 2: Software reset */
-	DM9000_iow(DM9000_NCR, (NCR_LBK_INT_MAC | NCR_RST));
+	dm9000_iow(db, DM9000_NCR, (NCR_LBK_INT_MAC | NCR_RST));
 
 	do {
-		DM9000_DBG("resetting the DM9000, 1st reset\n");
+		debug("resetting the DM9000, 1st reset\n");
 		udelay(25); /* Wait at least 20 us */
-	} while (DM9000_ior(DM9000_NCR) & 1);
+	} while (dm9000_ior(db, DM9000_NCR) & 1);
 
-	DM9000_iow(DM9000_NCR, 0);
-	DM9000_iow(DM9000_NCR, (NCR_LBK_INT_MAC | NCR_RST)); /* Issue a second reset */
+	dm9000_iow(db, DM9000_NCR, 0);
+	dm9000_iow(db, DM9000_NCR, (NCR_LBK_INT_MAC | NCR_RST)); /* Issue a second reset */
 
 	do {
-		DM9000_DBG("resetting the DM9000, 2nd reset\n");
+		debug("resetting the DM9000, 2nd reset\n");
 		udelay(25); /* Wait at least 20 us */
-	} while (DM9000_ior(DM9000_NCR) & 1);
+	} while (dm9000_ior(db, DM9000_NCR) & 1);
 
 	/* Check whether the ethernet controller is present */
-	if ((DM9000_ior(DM9000_PIDL) != 0x0) ||
-	    (DM9000_ior(DM9000_PIDH) != 0x90))
+	if ((dm9000_ior(db, DM9000_PIDL) != 0x0) ||
+	    (dm9000_ior(db, DM9000_PIDH) != 0x90))
 		printf("ERROR: resetting DM9000 -> not responding\n");
 }
 
-/* Initialize dm9000 board
-*/
-static int dm9000_init(struct eth_device *dev, struct bd_info *bd)
+/* Initialize dm9000 board */
+static int dm9000_init_common(struct dm9000_priv *db, u8 enetaddr[6])
 {
 	int i, oft, lnk;
 	u8 io_mode;
-	struct board_info *db = &dm9000_info;
-
-	DM9000_DBG("%s\n", __func__);
 
 	/* RESET device */
-	dm9000_reset();
+	dm9000_reset(db);
 
-	if (dm9000_probe() < 0)
+	if (dm9000_probe(db) < 0)
 		return -1;
 
 	/* Auto-detect 8/16/32 bit mode, ISR Bit 6+7 indicate bus width */
-	io_mode = DM9000_ior(DM9000_ISR) >> 6;
+	io_mode = dm9000_ior(db, DM9000_ISR) >> 6;
 
 	switch (io_mode) {
 	case 0x0:  /* 16-bit mode */
@@ -325,46 +357,45 @@
 	}
 
 	/* Program operating register, only internal phy supported */
-	DM9000_iow(DM9000_NCR, 0x0);
+	dm9000_iow(db, DM9000_NCR, 0x0);
 	/* TX Polling clear */
-	DM9000_iow(DM9000_TCR, 0);
+	dm9000_iow(db, DM9000_TCR, 0);
 	/* Less 3Kb, 200us */
-	DM9000_iow(DM9000_BPTR, BPTR_BPHW(3) | BPTR_JPT_600US);
+	dm9000_iow(db, DM9000_BPTR, BPTR_BPHW(3) | BPTR_JPT_600US);
 	/* Flow Control : High/Low Water */
-	DM9000_iow(DM9000_FCTR, FCTR_HWOT(3) | FCTR_LWOT(8));
+	dm9000_iow(db, DM9000_FCTR, FCTR_HWOT(3) | FCTR_LWOT(8));
 	/* SH FIXME: This looks strange! Flow Control */
-	DM9000_iow(DM9000_FCR, 0x0);
+	dm9000_iow(db, DM9000_FCR, 0x0);
 	/* Special Mode */
-	DM9000_iow(DM9000_SMCR, 0);
+	dm9000_iow(db, DM9000_SMCR, 0);
 	/* clear TX status */
-	DM9000_iow(DM9000_NSR, NSR_WAKEST | NSR_TX2END | NSR_TX1END);
+	dm9000_iow(db, DM9000_NSR, NSR_WAKEST | NSR_TX2END | NSR_TX1END);
 	/* Clear interrupt status */
-	DM9000_iow(DM9000_ISR, ISR_ROOS | ISR_ROS | ISR_PTS | ISR_PRS);
+	dm9000_iow(db, DM9000_ISR, ISR_ROOS | ISR_ROS | ISR_PTS | ISR_PRS);
 
-	printf("MAC: %pM\n", dev->enetaddr);
-	if (!is_valid_ethaddr(dev->enetaddr)) {
+	printf("MAC: %pM\n", enetaddr);
+	if (!is_valid_ethaddr(enetaddr))
 		printf("WARNING: Bad MAC address (uninitialized EEPROM?)\n");
-	}
 
 	/* fill device MAC address registers */
 	for (i = 0, oft = DM9000_PAR; i < 6; i++, oft++)
-		DM9000_iow(oft, dev->enetaddr[i]);
+		dm9000_iow(db, oft, enetaddr[i]);
 	for (i = 0, oft = 0x16; i < 8; i++, oft++)
-		DM9000_iow(oft, 0xff);
+		dm9000_iow(db, oft, 0xff);
 
 	/* read back mac, just to be sure */
 	for (i = 0, oft = 0x10; i < 6; i++, oft++)
-		DM9000_DBG("%02x:", DM9000_ior(oft));
-	DM9000_DBG("\n");
+		debug("%02x:", dm9000_ior(db, oft));
+	debug("\n");
 
 	/* Activate DM9000 */
 	/* RX enable */
-	DM9000_iow(DM9000_RCR, RCR_DIS_LONG | RCR_DIS_CRC | RCR_RXEN);
+	dm9000_iow(db, DM9000_RCR, RCR_DIS_LONG | RCR_DIS_CRC | RCR_RXEN);
 	/* Enable TX/RX interrupt mask */
-	DM9000_iow(DM9000_IMR, IMR_PAR);
+	dm9000_iow(db, DM9000_IMR, IMR_PAR);
 
 	i = 0;
-	while (!(dm9000_phy_read(1) & 0x20)) {	/* autonegation complete bit */
+	while (!(dm9000_phy_read(db, 1) & 0x20)) {	/* autonegation complete bit */
 		udelay(1000);
 		i++;
 		if (i == 10000) {
@@ -374,7 +405,7 @@
 	}
 
 	/* see what we've got */
-	lnk = dm9000_phy_read(17) >> 12;
+	lnk = dm9000_phy_read(db, 17) >> 12;
 	printf("operating at ");
 	switch (lnk) {
 	case 1:
@@ -398,241 +429,321 @@
 }
 
 /*
-  Hardware start transmission.
-  Send a packet to media from the upper layer.
-*/
-static int dm9000_send(struct eth_device *netdev, void *packet, int length)
+ * Hardware start transmission.
+ * Send a packet to media from the upper layer.
+ */
+static int dm9000_send_common(struct dm9000_priv *db, void *packet, int length)
 {
 	int tmo;
-	struct board_info *db = &dm9000_info;
 
-	DM9000_DMP_PACKET(__func__ , packet, length);
+	dm9000_dump_packet(__func__, packet, length);
 
-	DM9000_iow(DM9000_ISR, IMR_PTM); /* Clear Tx bit in ISR */
+	dm9000_iow(db, DM9000_ISR, IMR_PTM); /* Clear Tx bit in ISR */
 
 	/* Move data to DM9000 TX RAM */
-	DM9000_outb(DM9000_MWCMD, DM9000_IO); /* Prepare for TX-data */
+	dm9000_outb(DM9000_MWCMD, db->base_io); /* Prepare for TX-data */
 
 	/* push the data to the TX-fifo */
-	(db->outblk)(packet, length);
+	db->outblk(db, packet, length);
 
 	/* Set TX length to DM9000 */
-	DM9000_iow(DM9000_TXPLL, length & 0xff);
-	DM9000_iow(DM9000_TXPLH, (length >> 8) & 0xff);
+	dm9000_iow(db, DM9000_TXPLL, length & 0xff);
+	dm9000_iow(db, DM9000_TXPLH, (length >> 8) & 0xff);
 
 	/* Issue TX polling command */
-	DM9000_iow(DM9000_TCR, TCR_TXREQ); /* Cleared after TX complete */
+	dm9000_iow(db, DM9000_TCR, TCR_TXREQ); /* Cleared after TX complete */
 
 	/* wait for end of transmission */
 	tmo = get_timer(0) + 5 * CONFIG_SYS_HZ;
-	while ( !(DM9000_ior(DM9000_NSR) & (NSR_TX1END | NSR_TX2END)) ||
-		!(DM9000_ior(DM9000_ISR) & IMR_PTM) ) {
+	while (!(dm9000_ior(db, DM9000_NSR) & (NSR_TX1END | NSR_TX2END)) ||
+	       !(dm9000_ior(db, DM9000_ISR) & IMR_PTM)) {
 		if (get_timer(0) >= tmo) {
 			printf("transmission timeout\n");
 			break;
 		}
 	}
-	DM9000_iow(DM9000_ISR, IMR_PTM); /* Clear Tx bit in ISR */
+	dm9000_iow(db, DM9000_ISR, IMR_PTM); /* Clear Tx bit in ISR */
 
-	DM9000_DBG("transmit done\n\n");
+	debug("transmit done\n\n");
 	return 0;
 }
 
 /*
-  Stop the interface.
-  The interface is stopped when it is brought.
-*/
-static void dm9000_halt(struct eth_device *netdev)
+ * Stop the interface.
+ * The interface is stopped when it is brought.
+ */
+static void dm9000_halt_common(struct dm9000_priv *db)
 {
-	DM9000_DBG("%s\n", __func__);
-
-	/* RESET devie */
-	dm9000_phy_write(0, 0x8000);	/* PHY RESET */
-	DM9000_iow(DM9000_GPR, 0x01);	/* Power-Down PHY */
-	DM9000_iow(DM9000_IMR, 0x80);	/* Disable all interrupt */
-	DM9000_iow(DM9000_RCR, 0x00);	/* Disable RX */
+	/* RESET device */
+	dm9000_phy_write(db, 0, 0x8000);	/* PHY RESET */
+	dm9000_iow(db, DM9000_GPR, 0x01);	/* Power-Down PHY */
+	dm9000_iow(db, DM9000_IMR, 0x80);	/* Disable all interrupt */
+	dm9000_iow(db, DM9000_RCR, 0x00);	/* Disable RX */
 }
 
 /*
-  Received a packet and pass to upper layer
-*/
-static int dm9000_rx(struct eth_device *netdev)
+ * Received a packet and pass to upper layer
+ */
+static int dm9000_recv_common(struct dm9000_priv *db, uchar *rdptr)
 {
 	u8 rxbyte;
-	u8 *rdptr = (u8 *)net_rx_packets[0];
-	u16 RxStatus, RxLen = 0;
-	struct board_info *db = &dm9000_info;
+	u16 rxstatus, rxlen = 0;
 
-	/* Check packet ready or not, we must check
-	   the ISR status first for DM9000A */
-	if (!(DM9000_ior(DM9000_ISR) & 0x01)) /* Rx-ISR bit must be set. */
+	/*
+	 * Check packet ready or not, we must check
+	 * the ISR status first for DM9000A
+	 */
+	if (!(dm9000_ior(db, DM9000_ISR) & 0x01)) /* Rx-ISR bit must be set. */
 		return 0;
 
-	DM9000_iow(DM9000_ISR, 0x01); /* clear PR status latched in bit 0 */
+	dm9000_iow(db, DM9000_ISR, 0x01); /* clear PR status latched in bit 0 */
 
 	/* There is _at least_ 1 package in the fifo, read them all */
-	for (;;) {
-		DM9000_ior(DM9000_MRCMDX);	/* Dummy read */
+	dm9000_ior(db, DM9000_MRCMDX);	/* Dummy read */
 
-		/* Get most updated data,
-		   only look at bits 0:1, See application notes DM9000 */
-		rxbyte = DM9000_inb(DM9000_DATA) & 0x03;
+	/*
+	 * Get most updated data,
+	 * only look at bits 0:1, See application notes DM9000
+	 */
+	rxbyte = dm9000_inb(db->base_data) & 0x03;
 
-		/* Status check: this byte must be 0 or 1 */
-		if (rxbyte > DM9000_PKT_RDY) {
-			DM9000_iow(DM9000_RCR, 0x00);	/* Stop Device */
-			DM9000_iow(DM9000_ISR, 0x80);	/* Stop INT request */
-			printf("DM9000 error: status check fail: 0x%x\n",
-				rxbyte);
-			return 0;
-		}
-
-		if (rxbyte != DM9000_PKT_RDY)
-			return 0; /* No packet received, ignore */
-
-		DM9000_DBG("receiving packet\n");
-
-		/* A packet ready now  & Get status/length */
-		(db->rx_status)(&RxStatus, &RxLen);
-
-		DM9000_DBG("rx status: 0x%04x rx len: %d\n", RxStatus, RxLen);
-
-		/* Move data from DM9000 */
-		/* Read received packet from RX SRAM */
-		(db->inblk)(rdptr, RxLen);
-
-		if ((RxStatus & 0xbf00) || (RxLen < 0x40)
-			|| (RxLen > DM9000_PKT_MAX)) {
-			if (RxStatus & 0x100) {
-				printf("rx fifo error\n");
-			}
-			if (RxStatus & 0x200) {
-				printf("rx crc error\n");
-			}
-			if (RxStatus & 0x8000) {
-				printf("rx length error\n");
-			}
-			if (RxLen > DM9000_PKT_MAX) {
-				printf("rx length too big\n");
-				dm9000_reset();
-			}
-		} else {
-			DM9000_DMP_PACKET(__func__ , rdptr, RxLen);
-
-			DM9000_DBG("passing packet to upper layer\n");
-			net_process_received_packet(net_rx_packets[0], RxLen);
-		}
+	/* Status check: this byte must be 0 or 1 */
+	if (rxbyte > DM9000_PKT_RDY) {
+		dm9000_iow(db, DM9000_RCR, 0x00);	/* Stop Device */
+		dm9000_iow(db, DM9000_ISR, 0x80);	/* Stop INT request */
+		printf("DM9000 error: status check fail: 0x%x\n",
+		       rxbyte);
+		return -EINVAL;
 	}
-	return 0;
+
+	if (rxbyte != DM9000_PKT_RDY)
+		return 0; /* No packet received, ignore */
+
+	debug("receiving packet\n");
+
+	/* A packet ready now  & Get status/length */
+	db->rx_status(db, &rxstatus, &rxlen);
+
+	debug("rx status: 0x%04x rx len: %d\n", rxstatus, rxlen);
+
+	/* Move data from DM9000 */
+	/* Read received packet from RX SRAM */
+	db->inblk(db, rdptr, rxlen);
+
+	if (rxstatus & 0xbf00 || rxlen < 0x40 || rxlen > DM9000_PKT_MAX) {
+		if (rxstatus & 0x100)
+			printf("rx fifo error\n");
+		if (rxstatus & 0x200)
+			printf("rx crc error\n");
+		if (rxstatus & 0x8000)
+			printf("rx length error\n");
+		if (rxlen > DM9000_PKT_MAX) {
+			printf("rx length too big\n");
+			dm9000_reset(db);
+		}
+		return -EINVAL;
+	}
+
+	return rxlen;
 }
 
 /*
-  Read a word data from SROM
-*/
+ * Read a word data from SROM
+ */
 #if !defined(CONFIG_DM9000_NO_SROM)
-void dm9000_read_srom_word(int offset, u8 *to)
+static void dm9000_read_srom_word(struct dm9000_priv *db, int offset, u8 *to)
 {
-	DM9000_iow(DM9000_EPAR, offset);
-	DM9000_iow(DM9000_EPCR, 0x4);
-	udelay(8000);
-	DM9000_iow(DM9000_EPCR, 0x0);
-	to[0] = DM9000_ior(DM9000_EPDRL);
-	to[1] = DM9000_ior(DM9000_EPDRH);
+	dm9000_iow(db, DM9000_EPAR, offset);
+	dm9000_iow(db, DM9000_EPCR, 0x4);
+	mdelay(8);
+	dm9000_iow(db, DM9000_EPCR, 0x0);
+	to[0] = dm9000_ior(db, DM9000_EPDRL);
+	to[1] = dm9000_ior(db, DM9000_EPDRH);
 }
 
-void dm9000_write_srom_word(int offset, u16 val)
+static void dm9000_get_enetaddr(struct dm9000_priv *db, u8 *enetaddr)
 {
-	DM9000_iow(DM9000_EPAR, offset);
-	DM9000_iow(DM9000_EPDRH, ((val >> 8) & 0xff));
-	DM9000_iow(DM9000_EPDRL, (val & 0xff));
-	DM9000_iow(DM9000_EPCR, 0x12);
-	udelay(8000);
-	DM9000_iow(DM9000_EPCR, 0);
-}
-#endif
-
-static void dm9000_get_enetaddr(struct eth_device *dev)
-{
-#if !defined(CONFIG_DM9000_NO_SROM)
 	int i;
+
 	for (i = 0; i < 3; i++)
-		dm9000_read_srom_word(i, dev->enetaddr + (2 * i));
+		dm9000_read_srom_word(db, i, enetaddr + (2 * i));
+}
+#else
+static void dm9000_get_enetaddr(struct dm9000_priv *db, u8 *enetaddr) {}
 #endif
+
+#ifndef CONFIG_DM_ETH
+static int dm9000_init(struct eth_device *dev, struct bd_info *bd)
+{
+	struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
+
+	return dm9000_init_common(db, dev->enetaddr);
 }
 
-/*
-   Read a byte from I/O port
-*/
-static u8
-DM9000_ior(int reg)
+static void dm9000_halt(struct eth_device *dev)
 {
-	DM9000_outb(reg, DM9000_IO);
-	return DM9000_inb(DM9000_DATA);
+	struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
+
+	dm9000_halt_common(db);
 }
 
-/*
-   Write a byte to I/O port
-*/
-static void
-DM9000_iow(int reg, u8 value)
+static int dm9000_send(struct eth_device *dev, void *packet, int length)
 {
-	DM9000_outb(reg, DM9000_IO);
-	DM9000_outb(value, DM9000_DATA);
+	struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
+
+	return dm9000_send_common(db, packet, length);
 }
 
-/*
-   Read a word from phyxcer
-*/
-static u16
-dm9000_phy_read(int reg)
+static int dm9000_recv(struct eth_device *dev)
 {
-	u16 val;
+	struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
+	int ret;
 
-	/* Fill the phyxcer register into REG_0C */
-	DM9000_iow(DM9000_EPAR, DM9000_PHY | reg);
-	DM9000_iow(DM9000_EPCR, 0xc);	/* Issue phyxcer read command */
-	udelay(100);			/* Wait read complete */
-	DM9000_iow(DM9000_EPCR, 0x0);	/* Clear phyxcer read command */
-	val = (DM9000_ior(DM9000_EPDRH) << 8) | DM9000_ior(DM9000_EPDRL);
+	ret = dm9000_recv_common(db, net_rx_packets[0]);
+	if (ret > 0)
+		net_process_received_packet(net_rx_packets[0], ret);
 
-	/* The read data keeps on REG_0D & REG_0E */
-	DM9000_DBG("dm9000_phy_read(0x%x): 0x%x\n", reg, val);
-	return val;
-}
-
-/*
-   Write a word to phyxcer
-*/
-static void
-dm9000_phy_write(int reg, u16 value)
-{
-
-	/* Fill the phyxcer register into REG_0C */
-	DM9000_iow(DM9000_EPAR, DM9000_PHY | reg);
-
-	/* Fill the written data into REG_0D & REG_0E */
-	DM9000_iow(DM9000_EPDRL, (value & 0xff));
-	DM9000_iow(DM9000_EPDRH, ((value >> 8) & 0xff));
-	DM9000_iow(DM9000_EPCR, 0xa);	/* Issue phyxcer write command */
-	udelay(500);			/* Wait write complete */
-	DM9000_iow(DM9000_EPCR, 0x0);	/* Clear phyxcer write command */
-	DM9000_DBG("dm9000_phy_write(reg:0x%x, value:0x%x)\n", reg, value);
+	return ret;
 }
 
 int dm9000_initialize(struct bd_info *bis)
 {
-	struct eth_device *dev = &(dm9000_info.netdev);
+	struct dm9000_priv *priv;
+	struct eth_device *dev;
+
+	priv = calloc(1, sizeof(*priv));
+	if (!priv)
+		return -ENOMEM;
+
+	dev = &priv->dev;
+
+	priv->base_io = (void __iomem *)DM9000_IO;
+	priv->base_data = (void __iomem *)DM9000_DATA;
 
 	/* Load MAC address from EEPROM */
-	dm9000_get_enetaddr(dev);
+	dm9000_get_enetaddr(priv, dev->enetaddr);
 
 	dev->init = dm9000_init;
 	dev->halt = dm9000_halt;
 	dev->send = dm9000_send;
-	dev->recv = dm9000_rx;
+	dev->recv = dm9000_recv;
 	strcpy(dev->name, "dm9000");
 
-	eth_register(dev);
+	eth_register(&priv->dev);
 
 	return 0;
 }
+#else	/* ifdef CONFIG_DM_ETH */
+static int dm9000_start(struct udevice *dev)
+{
+	struct dm9000_priv *db = dev_get_priv(dev);
+	struct eth_pdata *pdata = dev_get_plat(dev);
+
+	return dm9000_init_common(db, pdata->enetaddr);
+}
+
+static void dm9000_stop(struct udevice *dev)
+{
+	struct dm9000_priv *db = dev_get_priv(dev);
+
+	dm9000_halt_common(db);
+}
+
+static int dm9000_send(struct udevice *dev, void *packet, int length)
+{
+	struct dm9000_priv *db = dev_get_priv(dev);
+	int ret;
+
+	ret = dm9000_send_common(db, packet, length);
+
+	return ret ? 0 : -ETIMEDOUT;
+}
+
+static int dm9000_recv(struct udevice *dev, int flags, uchar **packetp)
+{
+	struct dm9000_priv *db = dev_get_priv(dev);
+	uchar *data = net_rx_packets[0];
+	int ret;
+
+	ret = dm9000_recv_common(db, data);
+	if (ret)
+		*packetp = (void *)data;
+
+	return ret ? ret : -EAGAIN;
+}
+
+static int dm9000_write_hwaddr(struct udevice *dev)
+{
+	struct dm9000_priv *db = dev_get_priv(dev);
+	struct eth_pdata *pdata = dev_get_plat(dev);
+	int i, oft;
+
+	/* fill device MAC address registers */
+	for (i = 0, oft = DM9000_PAR; i < 6; i++, oft++)
+		dm9000_iow(db, oft, pdata->enetaddr[i]);
+
+	for (i = 0, oft = 0x16; i < 8; i++, oft++)
+		dm9000_iow(db, oft, 0xff);
+
+	/* read back mac, just to be sure */
+	for (i = 0, oft = 0x10; i < 6; i++, oft++)
+		debug("%02x:", dm9000_ior(db, oft));
+
+	debug("\n");
+
+	return 0;
+}
+
+static int dm9000_read_rom_hwaddr(struct udevice *dev)
+{
+	struct dm9000_priv *db = dev_get_priv(dev);
+	struct eth_pdata *pdata = dev_get_plat(dev);
+
+	dm9000_get_enetaddr(db, pdata->enetaddr);
+
+	return !is_valid_ethaddr(pdata->enetaddr);
+}
+
+static int dm9000_bind(struct udevice *dev)
+{
+	return device_set_name(dev, dev->name);
+}
+
+static int dm9000_of_to_plat(struct udevice *dev)
+{
+	struct dm9000_priv *db = dev_get_priv(dev);
+	struct eth_pdata *pdata = dev_get_plat(dev);
+
+	pdata->iobase = dev_read_addr_index(dev, 0);
+	db->base_io = (void __iomem *)pdata->iobase;
+	db->base_data = (void __iomem *)dev_read_addr_index(dev, 1);
+
+	return 0;
+}
+
+static const struct eth_ops dm9000_ops = {
+	.start		= dm9000_start,
+	.stop		= dm9000_stop,
+	.send		= dm9000_send,
+	.recv		= dm9000_recv,
+	.write_hwaddr	= dm9000_write_hwaddr,
+	.read_rom_hwaddr = dm9000_read_rom_hwaddr,
+};
+
+static const struct udevice_id dm9000_ids[] = {
+	{ .compatible = "davicom,dm9000" },
+	{ }
+};
+
+U_BOOT_DRIVER(dm9000) = {
+	.name		= "eth_dm9000",
+	.id		= UCLASS_ETH,
+	.of_match	= dm9000_ids,
+	.bind		= dm9000_bind,
+	.of_to_plat = dm9000_of_to_plat,
+	.ops		= &dm9000_ops,
+	.priv_auto	= sizeof(struct dm9000_priv),
+	.plat_auto	= sizeof(struct eth_pdata),
+	.flags		= DM_FLAG_ALLOC_PRIV_DMA,
+};
+#endif
diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c
index ea0c2cf..9d255cf 100644
--- a/drivers/net/dwc_eth_qos.c
+++ b/drivers/net/dwc_eth_qos.c
@@ -270,7 +270,7 @@
 	int config_mac;
 	int config_mac_mdio;
 	unsigned int axi_bus_width;
-	phy_interface_t (*interface)(struct udevice *dev);
+	phy_interface_t (*interface)(const struct udevice *dev);
 	struct eqos_ops *ops;
 };
 
@@ -1682,7 +1682,7 @@
 
 	interface = eqos->config->interface(dev);
 
-	if (interface == PHY_INTERFACE_MODE_NONE) {
+	if (interface == PHY_INTERFACE_MODE_NA) {
 		pr_err("Invalid PHY interface\n");
 		return -EINVAL;
 	}
@@ -1729,21 +1729,7 @@
 	return ret;
 }
 
-static phy_interface_t eqos_get_interface_stm32(struct udevice *dev)
-{
-	const char *phy_mode;
-	phy_interface_t interface = PHY_INTERFACE_MODE_NONE;
-
-	debug("%s(dev=%p):\n", __func__, dev);
-
-	phy_mode = dev_read_prop(dev, "phy-mode", NULL);
-	if (phy_mode)
-		interface = phy_get_interface_by_name(phy_mode);
-
-	return interface;
-}
-
-static phy_interface_t eqos_get_interface_tegra186(struct udevice *dev)
+static phy_interface_t eqos_get_interface_tegra186(const struct udevice *dev)
 {
 	return PHY_INTERFACE_MODE_MII;
 }
@@ -1757,7 +1743,7 @@
 
 	interface = eqos->config->interface(dev);
 
-	if (interface == PHY_INTERFACE_MODE_NONE) {
+	if (interface == PHY_INTERFACE_MODE_NA) {
 		pr_err("Invalid PHY interface\n");
 		return -EINVAL;
 	}
@@ -1766,20 +1752,6 @@
 	return 0;
 }
 
-static phy_interface_t eqos_get_interface_imx(struct udevice *dev)
-{
-	const char *phy_mode;
-	phy_interface_t interface = PHY_INTERFACE_MODE_NONE;
-
-	debug("%s(dev=%p):\n", __func__, dev);
-
-	phy_mode = dev_read_prop(dev, "phy-mode", NULL);
-	if (phy_mode)
-		interface = phy_get_interface_by_name(phy_mode);
-
-	return interface;
-}
-
 static int eqos_remove_resources_tegra186(struct udevice *dev)
 {
 	struct eqos_priv *eqos = dev_get_priv(dev);
@@ -1985,7 +1957,7 @@
 	.config_mac = EQOS_MAC_RXQ_CTRL0_RXQ0EN_ENABLED_AV,
 	.config_mac_mdio = EQOS_MAC_MDIO_ADDRESS_CR_250_300,
 	.axi_bus_width = EQOS_AXI_WIDTH_64,
-	.interface = eqos_get_interface_stm32,
+	.interface = dev_read_phy_mode,
 	.ops = &eqos_stm32_ops
 };
 
@@ -2013,7 +1985,7 @@
 	.config_mac = EQOS_MAC_RXQ_CTRL0_RXQ0EN_ENABLED_DCB,
 	.config_mac_mdio = EQOS_MAC_MDIO_ADDRESS_CR_250_300,
 	.axi_bus_width = EQOS_AXI_WIDTH_64,
-	.interface = eqos_get_interface_imx,
+	.interface = dev_read_phy_mode,
 	.ops = &eqos_imx_ops
 };
 
diff --git a/drivers/net/eth-phy-uclass.c b/drivers/net/eth-phy-uclass.c
index 1f285f7..27b7744 100644
--- a/drivers/net/eth-phy-uclass.c
+++ b/drivers/net/eth-phy-uclass.c
@@ -137,7 +137,7 @@
 	/* search "reset-gpios" in phy node */
 	ret = gpio_request_by_name(dev, "reset-gpios", 0,
 				   &uc_priv->reset_gpio,
-				   GPIOD_IS_OUT);
+				   GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
 	if (ret && ret != -ENOENT)
 		return ret;
 
diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c
index 7f146d4..a219aff 100644
--- a/drivers/net/ethoc.c
+++ b/drivers/net/ethoc.c
@@ -614,11 +614,11 @@
 	mask = 1 << CONFIG_PHY_ADDR;
 #endif
 
-	phydev = phy_find_by_mask(priv->bus, mask, PHY_INTERFACE_MODE_MII);
+	phydev = phy_find_by_mask(priv->bus, mask);
 	if (!phydev)
 		return -ENODEV;
 
-	phy_connect_dev(phydev, dev);
+	phy_connect_dev(phydev, dev, PHY_INTERFACE_MODE_MII);
 
 	phydev->supported &= PHY_BASIC_FEATURES;
 	phydev->advertising = phydev->supported;
diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index e8ebef0..a623a5c 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -1310,20 +1310,13 @@
 	int ret = 0;
 	struct eth_pdata *pdata = dev_get_plat(dev);
 	struct fec_priv *priv = dev_get_priv(dev);
-	const char *phy_mode;
 
 	pdata->iobase = dev_read_addr(dev);
 	priv->eth = (struct ethernet_regs *)pdata->iobase;
 
-	pdata->phy_interface = -1;
-	phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
-			       NULL);
-	if (phy_mode)
-		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
-	if (pdata->phy_interface == -1) {
-		debug("%s: Invalid PHY interface '%s'\n", __func__, phy_mode);
+	pdata->phy_interface = dev_read_phy_mode(dev);
+	if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
 		return -EINVAL;
-	}
 
 #ifdef CONFIG_DM_REGULATOR
 	device_get_supply_regulator(dev, "phy-supply", &priv->phy_supply);
@@ -1331,7 +1324,7 @@
 
 #if CONFIG_IS_ENABLED(DM_GPIO)
 	ret = gpio_request_by_name(dev, "phy-reset-gpios", 0,
-				   &priv->phy_reset_gpio, GPIOD_IS_OUT);
+				   &priv->phy_reset_gpio, GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
 	if (ret < 0)
 		return 0; /* property is optional, don't return error! */
 
diff --git a/drivers/net/fm/b4860.c b/drivers/net/fm/b4860.c
index 6e3d008..e622d86 100644
--- a/drivers/net/fm/b4860.c
+++ b/drivers/net/fm/b4860.c
@@ -55,7 +55,7 @@
 #endif
 
 	if (is_device_disabled(port))
-		return PHY_INTERFACE_MODE_NONE;
+		return PHY_INTERFACE_MODE_NA;
 
 	/*B4860 has two 10Gig Mac*/
 	if ((port == FM1_10GEC1 || port == FM1_10GEC2)	&&
@@ -112,7 +112,7 @@
 					 (port == FM1_DTSEC2) ||
 					 (port == FM1_DTSEC3) ||
 					 (port == FM1_DTSEC4))
-					return PHY_INTERFACE_MODE_NONE;
+					return PHY_INTERFACE_MODE_NA;
 			}
 		}
 	}
@@ -131,8 +131,8 @@
 			return PHY_INTERFACE_MODE_SGMII;
 		break;
 	default:
-		return PHY_INTERFACE_MODE_NONE;
+		return PHY_INTERFACE_MODE_NA;
 	}
 
-	return PHY_INTERFACE_MODE_NONE;
+	return PHY_INTERFACE_MODE_NA;
 }
diff --git a/drivers/net/fm/eth.c b/drivers/net/fm/eth.c
index 5e0d0bc..1ffe9e2 100644
--- a/drivers/net/fm/eth.c
+++ b/drivers/net/fm/eth.c
@@ -954,17 +954,6 @@
 	return 0;
 }
 #else /* CONFIG_DM_ETH */
-#ifdef CONFIG_PHYLIB
-phy_interface_t fman_read_sys_if(struct udevice *dev)
-{
-	const char *if_str;
-
-	if_str = ofnode_read_string(dev_ofnode(dev), "phy-connection-type");
-	debug("MAC system interface mode %s\n", if_str);
-
-	return phy_get_interface_by_name(if_str);
-}
-#endif
 
 static int fm_eth_bind(struct udevice *dev)
 {
@@ -1038,7 +1027,7 @@
 	reg = (void *)(uintptr_t)dev_read_addr(dev);
 	fm_eth->mac_type = dev_get_driver_data(dev);
 #ifdef CONFIG_PHYLIB
-	fm_eth->enet_if = fman_read_sys_if(dev);
+	fm_eth->enet_if = dev_read_phy_mode(dev);
 #else
 	fm_eth->enet_if = PHY_INTERFACE_MODE_SGMII;
 	printf("%s: warning - unable to determine interface type\n", __func__);
diff --git a/drivers/net/fm/init.c b/drivers/net/fm/init.c
index 2fed642..af94dab 100644
--- a/drivers/net/fm/init.c
+++ b/drivers/net/fm/init.c
@@ -130,7 +130,7 @@
 
 /*
  * Determine if an interface is actually active based on HW config
- * we expect fman_port_enet_if() to report PHY_INTERFACE_MODE_NONE if
+ * we expect fman_port_enet_if() to report PHY_INTERFACE_MODE_NA if
  * the interface is not active based on HW cfg of the SoC
  */
 void fman_enet_init(void)
@@ -141,7 +141,7 @@
 		phy_interface_t enet_if;
 
 		enet_if = fman_port_enet_if(fm_info[i].port);
-		if (enet_if != PHY_INTERFACE_MODE_NONE) {
+		if (enet_if != PHY_INTERFACE_MODE_NA) {
 			fm_info[i].enabled = 1;
 			fm_info[i].enet_if = enet_if;
 		} else {
@@ -221,12 +221,12 @@
 	int i = fm_port_to_index(port);
 
 	if (i == -1)
-		return PHY_INTERFACE_MODE_NONE;
+		return PHY_INTERFACE_MODE_NA;
 
 	if (fm_info[i].enabled)
 		return fm_info[i].enet_if;
 
-	return PHY_INTERFACE_MODE_NONE;
+	return PHY_INTERFACE_MODE_NA;
 }
 
 static void
diff --git a/drivers/net/fm/ls1043.c b/drivers/net/fm/ls1043.c
index e1abf8f..cd8376a 100644
--- a/drivers/net/fm/ls1043.c
+++ b/drivers/net/fm/ls1043.c
@@ -54,13 +54,13 @@
 	u32 rcwsr13 = in_be32(&gur->rcwsr[13]);
 
 	if (is_device_disabled(port))
-		return PHY_INTERFACE_MODE_NONE;
+		return PHY_INTERFACE_MODE_NA;
 
 	if ((port == FM1_10GEC1) && (is_serdes_configured(XFI_FM1_MAC9)))
 		return PHY_INTERFACE_MODE_XGMII;
 
 	if ((port == FM1_DTSEC9) && (is_serdes_configured(XFI_FM1_MAC9)))
-		return PHY_INTERFACE_MODE_NONE;
+		return PHY_INTERFACE_MODE_NA;
 
 	if (port == FM1_DTSEC3)
 		if ((rcwsr13 & FSL_CHASSIS2_RCWSR13_EC1) ==
@@ -107,5 +107,5 @@
 		break;
 	}
 
-	return PHY_INTERFACE_MODE_NONE;
+	return PHY_INTERFACE_MODE_NA;
 }
diff --git a/drivers/net/fm/ls1046.c b/drivers/net/fm/ls1046.c
index 09df0aa..876f48b 100644
--- a/drivers/net/fm/ls1046.c
+++ b/drivers/net/fm/ls1046.c
@@ -54,19 +54,19 @@
 	u32 rcwsr13 = in_be32(&gur->rcwsr[13]);
 
 	if (is_device_disabled(port))
-		return PHY_INTERFACE_MODE_NONE;
+		return PHY_INTERFACE_MODE_NA;
 
 	if ((port == FM1_10GEC1) && (is_serdes_configured(XFI_FM1_MAC9)))
 		return PHY_INTERFACE_MODE_XGMII;
 
 	if ((port == FM1_DTSEC9) && (is_serdes_configured(XFI_FM1_MAC9)))
-		return PHY_INTERFACE_MODE_NONE;
+		return PHY_INTERFACE_MODE_NA;
 
 	if ((port == FM1_10GEC2) && (is_serdes_configured(XFI_FM1_MAC10)))
 		return PHY_INTERFACE_MODE_XGMII;
 
 	if ((port == FM1_DTSEC10) && (is_serdes_configured(XFI_FM1_MAC10)))
-		return PHY_INTERFACE_MODE_NONE;
+		return PHY_INTERFACE_MODE_NA;
 
 	if (port == FM1_DTSEC3)
 		if ((rcwsr13 & FSL_CHASSIS2_RCWSR13_EC1) ==
@@ -118,5 +118,5 @@
 		break;
 	}
 
-	return PHY_INTERFACE_MODE_NONE;
+	return PHY_INTERFACE_MODE_NA;
 }
diff --git a/drivers/net/fm/p1023.c b/drivers/net/fm/p1023.c
index d4167e4..c9b85fc 100644
--- a/drivers/net/fm/p1023.c
+++ b/drivers/net/fm/p1023.c
@@ -46,7 +46,7 @@
 	u32 pordevsr = in_be32(&gur->pordevsr);
 
 	if (is_device_disabled(port))
-		return PHY_INTERFACE_MODE_NONE;
+		return PHY_INTERFACE_MODE_NA;
 
 	/* DTSEC1 can be SGMII, RGMII or RMII */
 	if (port == FM1_DTSEC1) {
@@ -68,5 +68,5 @@
 			return PHY_INTERFACE_MODE_RGMII;
 	}
 
-	return PHY_INTERFACE_MODE_NONE;
+	return PHY_INTERFACE_MODE_NA;
 }
diff --git a/drivers/net/fm/p4080.c b/drivers/net/fm/p4080.c
index b78b02d..577ee22 100644
--- a/drivers/net/fm/p4080.c
+++ b/drivers/net/fm/p4080.c
@@ -54,7 +54,7 @@
 	u32 rcwsr11 = in_be32(&gur->rcwsr[11]);
 
 	if (is_device_disabled(port))
-		return PHY_INTERFACE_MODE_NONE;
+		return PHY_INTERFACE_MODE_NA;
 
 	if ((port == FM1_10GEC1) && (is_serdes_configured(XAUI_FM1)))
 		return PHY_INTERFACE_MODE_XGMII;
@@ -91,8 +91,8 @@
 			return PHY_INTERFACE_MODE_SGMII;
 		break;
 	default:
-		return PHY_INTERFACE_MODE_NONE;
+		return PHY_INTERFACE_MODE_NA;
 	}
 
-	return PHY_INTERFACE_MODE_NONE;
+	return PHY_INTERFACE_MODE_NA;
 }
diff --git a/drivers/net/fm/p5020.c b/drivers/net/fm/p5020.c
index 8189531..8ecc482 100644
--- a/drivers/net/fm/p5020.c
+++ b/drivers/net/fm/p5020.c
@@ -50,7 +50,7 @@
 	u32 rcwsr11 = in_be32(&gur->rcwsr[11]);
 
 	if (is_device_disabled(port))
-		return PHY_INTERFACE_MODE_NONE;
+		return PHY_INTERFACE_MODE_NA;
 
 	if ((port == FM1_10GEC1) && (is_serdes_configured(XAUI_FM1)))
 		return PHY_INTERFACE_MODE_XGMII;
@@ -82,8 +82,8 @@
 			return PHY_INTERFACE_MODE_SGMII;
 		break;
 	default:
-		return PHY_INTERFACE_MODE_NONE;
+		return PHY_INTERFACE_MODE_NA;
 	}
 
-	return PHY_INTERFACE_MODE_NONE;
+	return PHY_INTERFACE_MODE_NA;
 }
diff --git a/drivers/net/fm/p5040.c b/drivers/net/fm/p5040.c
index 38744e7..3a1494d 100644
--- a/drivers/net/fm/p5040.c
+++ b/drivers/net/fm/p5040.c
@@ -56,7 +56,7 @@
 	u32 rcwsr11 = in_be32(&gur->rcwsr[11]);
 
 	if (is_device_disabled(port))
-		return PHY_INTERFACE_MODE_NONE;
+		return PHY_INTERFACE_MODE_NA;
 
 	if ((port == FM1_10GEC1) && (is_serdes_configured(XAUI_FM1)))
 		return PHY_INTERFACE_MODE_XGMII;
@@ -99,8 +99,8 @@
 			return PHY_INTERFACE_MODE_SGMII;
 		break;
 	default:
-		return PHY_INTERFACE_MODE_NONE;
+		return PHY_INTERFACE_MODE_NA;
 	}
 
-	return PHY_INTERFACE_MODE_NONE;
+	return PHY_INTERFACE_MODE_NA;
 }
diff --git a/drivers/net/fm/t1024.c b/drivers/net/fm/t1024.c
index 696e74c..7110fb4 100644
--- a/drivers/net/fm/t1024.c
+++ b/drivers/net/fm/t1024.c
@@ -39,7 +39,7 @@
 	u32 rcwsr13 = in_be32(&gur->rcwsr[13]);
 
 	if (is_device_disabled(port))
-		return PHY_INTERFACE_MODE_NONE;
+		return PHY_INTERFACE_MODE_NA;
 
 	if ((port == FM1_10GEC1) && (is_serdes_configured(XFI_FM1_MAC1)))
 		return PHY_INTERFACE_MODE_XGMII;
@@ -83,5 +83,5 @@
 		break;
 	}
 
-	return PHY_INTERFACE_MODE_NONE;
+	return PHY_INTERFACE_MODE_NA;
 }
diff --git a/drivers/net/fm/t1040.c b/drivers/net/fm/t1040.c
index af4f5c5..192f1c6 100644
--- a/drivers/net/fm/t1040.c
+++ b/drivers/net/fm/t1040.c
@@ -56,8 +56,8 @@
 			return PHY_INTERFACE_MODE_SGMII;
 		break;
 	default:
-		return PHY_INTERFACE_MODE_NONE;
+		return PHY_INTERFACE_MODE_NA;
 	}
 
-	return PHY_INTERFACE_MODE_NONE;
+	return PHY_INTERFACE_MODE_NA;
 }
diff --git a/drivers/net/fm/t2080.c b/drivers/net/fm/t2080.c
index f4d8d2d..bfbd8de 100644
--- a/drivers/net/fm/t2080.c
+++ b/drivers/net/fm/t2080.c
@@ -47,7 +47,7 @@
 	u32 rcwsr13 = in_be32(&gur->rcwsr[13]);
 
 	if (is_device_disabled(port))
-		return PHY_INTERFACE_MODE_NONE;
+		return PHY_INTERFACE_MODE_NA;
 
 	if ((port == FM1_10GEC1 || port == FM1_10GEC2) &&
 	    ((is_serdes_configured(XAUI_FM1_MAC9))	||
@@ -85,8 +85,8 @@
 			return PHY_INTERFACE_MODE_SGMII;
 		break;
 	default:
-		return PHY_INTERFACE_MODE_NONE;
+		return PHY_INTERFACE_MODE_NA;
 	}
 
-	return PHY_INTERFACE_MODE_NONE;
+	return PHY_INTERFACE_MODE_NA;
 }
diff --git a/drivers/net/fm/t4240.c b/drivers/net/fm/t4240.c
index f8e63c3..ba7b862 100644
--- a/drivers/net/fm/t4240.c
+++ b/drivers/net/fm/t4240.c
@@ -61,7 +61,7 @@
 	u32 rcwsr13 = in_be32(&gur->rcwsr[13]);
 
 	if (is_device_disabled(port))
-		return PHY_INTERFACE_MODE_NONE;
+		return PHY_INTERFACE_MODE_NA;
 
 	if ((port == FM1_10GEC1 || port == FM1_10GEC2) &&
 	    ((is_serdes_configured(XAUI_FM1_MAC9))	||
@@ -73,7 +73,7 @@
 	if ((port == FM1_DTSEC9 || port == FM1_DTSEC10) &&
 	    ((is_serdes_configured(XFI_FM1_MAC9)) ||
 	     (is_serdes_configured(XFI_FM1_MAC10))))
-		return PHY_INTERFACE_MODE_NONE;
+		return PHY_INTERFACE_MODE_NA;
 
 	if ((port == FM2_10GEC1 || port == FM2_10GEC2) &&
 	    ((is_serdes_configured(XAUI_FM2_MAC9))	||
@@ -166,5 +166,5 @@
 		break;
 	}
 
-	return PHY_INTERFACE_MODE_NONE;
+	return PHY_INTERFACE_MODE_NA;
 }
diff --git a/drivers/net/fsl_enetc.c b/drivers/net/fsl_enetc.c
index 915c7c8..1724f94 100644
--- a/drivers/net/fsl_enetc.c
+++ b/drivers/net/fsl_enetc.c
@@ -260,9 +260,6 @@
 static void enetc_start_pcs(struct udevice *dev)
 {
 	struct enetc_priv *priv = dev_get_priv(dev);
-	const char *if_str;
-
-	priv->if_type = PHY_INTERFACE_MODE_NONE;
 
 	/* register internal MDIO for debug purposes */
 	if (enetc_read_port(priv, ENETC_PCAPR0) & ENETC_PCAPRO_MDIO) {
@@ -279,14 +276,12 @@
 		return;
 	}
 
-	if_str = ofnode_read_string(dev_ofnode(dev), "phy-mode");
-	if (if_str)
-		priv->if_type = phy_get_interface_by_name(if_str);
-	else
+	priv->if_type = dev_read_phy_mode(dev);
+	if (priv->if_type == PHY_INTERFACE_MODE_NA) {
 		enetc_dbg(dev,
 			  "phy-mode property not found, defaulting to SGMII\n");
-	if (priv->if_type < 0)
-		priv->if_type = PHY_INTERFACE_MODE_NONE;
+		priv->if_type = PHY_INTERFACE_MODE_SGMII;
+	}
 
 	switch (priv->if_type) {
 	case PHY_INTERFACE_MODE_SGMII:
diff --git a/drivers/net/ftgmac100.c b/drivers/net/ftgmac100.c
index aa719d2..78779d7 100644
--- a/drivers/net/ftgmac100.c
+++ b/drivers/net/ftgmac100.c
@@ -549,17 +549,12 @@
 {
 	struct eth_pdata *pdata = dev_get_plat(dev);
 	struct ftgmac100_data *priv = dev_get_priv(dev);
-	const char *phy_mode;
 
 	pdata->iobase = dev_read_addr(dev);
-	pdata->phy_interface = -1;
-	phy_mode = dev_read_string(dev, "phy-mode");
-	if (phy_mode)
-		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
-	if (pdata->phy_interface == -1) {
-		dev_err(dev, "Invalid PHY interface '%s'\n", phy_mode);
+
+	pdata->phy_interface = dev_read_phy_mode(dev);
+	if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
 		return -EINVAL;
-	}
 
 	pdata->max_speed = dev_read_u32_default(dev, "max-speed", 0);
 
diff --git a/drivers/net/higmacv300.c b/drivers/net/higmacv300.c
index aa79d6e..1862235 100644
--- a/drivers/net/higmacv300.c
+++ b/drivers/net/higmacv300.c
@@ -561,19 +561,14 @@
 static int higmac_of_to_plat(struct udevice *dev)
 {
 	struct higmac_priv *priv = dev_get_priv(dev);
-	int phyintf = PHY_INTERFACE_MODE_NONE;
-	const char *phy_mode;
 	ofnode phy_node;
 
 	priv->base = dev_remap_addr_index(dev, 0);
 	priv->macif_ctrl = dev_remap_addr_index(dev, 1);
 
-	phy_mode = dev_read_string(dev, "phy-mode");
-	if (phy_mode)
-		phyintf = phy_get_interface_by_name(phy_mode);
-	if (phyintf == PHY_INTERFACE_MODE_NONE)
+	priv->phyintf = dev_read_phy_mode(dev);
+	if (priv->phyintf == PHY_INTERFACE_MODE_NA)
 		return -ENODEV;
-	priv->phyintf = phyintf;
 
 	phy_node = dev_read_subnode(dev, "phy");
 	if (!ofnode_valid(phy_node)) {
diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c b/drivers/net/ldpaa_eth/ldpaa_eth.c
index 725173f..b6f589e 100644
--- a/drivers/net/ldpaa_eth/ldpaa_eth.c
+++ b/drivers/net/ldpaa_eth/ldpaa_eth.c
@@ -1120,31 +1120,14 @@
 	return fdtdec_get_uint(gd->fdt_blob, port_node, "reg", -1);
 }
 
-static const char *ldpaa_eth_get_phy_mode_str(struct udevice *dev)
-{
-	int port_node = dev_of_offset(dev);
-	const char *phy_mode_str;
-
-	phy_mode_str = fdt_getprop(gd->fdt_blob, port_node,
-				   "phy-connection-type", NULL);
-	if (phy_mode_str)
-		return phy_mode_str;
-
-	phy_mode_str = fdt_getprop(gd->fdt_blob, port_node, "phy-mode", NULL);
-	return phy_mode_str;
-}
-
 static int ldpaa_eth_bind(struct udevice *dev)
 {
-	const char *phy_mode_str = NULL;
 	uint32_t dpmac_id;
 	char eth_name[16];
 	int phy_mode = -1;
 
-	phy_mode_str = ldpaa_eth_get_phy_mode_str(dev);
-	if (phy_mode_str)
-		phy_mode = phy_get_interface_by_name(phy_mode_str);
-	if (phy_mode == -1) {
+	phy_mode = dev_read_phy_mode(dev);
+	if (phy_mode == PHY_INTERFACE_MODE_NA) {
 		dev_err(dev, "incorrect phy mode\n");
 		return -EINVAL;
 	}
@@ -1155,7 +1138,8 @@
 		return -EINVAL;
 	}
 
-	sprintf(eth_name, "DPMAC%d@%s", dpmac_id, phy_mode_str);
+	sprintf(eth_name, "DPMAC%d@%s", dpmac_id,
+		phy_string_for_interface(phy_mode));
 	device_set_name(dev, eth_name);
 
 	return 0;
@@ -1164,11 +1148,9 @@
 static int ldpaa_eth_of_to_plat(struct udevice *dev)
 {
 	struct ldpaa_eth_priv *priv = dev_get_priv(dev);
-	const char *phy_mode_str;
 
 	priv->dpmac_id = ldpaa_eth_get_dpmac_id(dev);
-	phy_mode_str = ldpaa_eth_get_phy_mode_str(dev);
-	priv->phy_mode = phy_get_interface_by_name(phy_mode_str);
+	priv->phy_mode = dev_read_phy_mode(dev);
 
 	return 0;
 }
diff --git a/drivers/net/ldpaa_eth/ldpaa_wriop.c b/drivers/net/ldpaa_eth/ldpaa_wriop.c
index 06a284a..adecb81 100644
--- a/drivers/net/ldpaa_eth/ldpaa_wriop.c
+++ b/drivers/net/ldpaa_eth/ldpaa_wriop.c
@@ -16,7 +16,7 @@
 
 __weak phy_interface_t wriop_dpmac_enet_if(int dpmac_id, int lane_prtc)
 {
-	return PHY_INTERFACE_MODE_NONE;
+	return PHY_INTERFACE_MODE_NA;
 }
 
 void wriop_init_dpmac(int sd, int dpmac_id, int lane_prtcl)
@@ -26,10 +26,10 @@
 
 	dpmac_info[dpmac_id].enabled = 0;
 	dpmac_info[dpmac_id].id = 0;
-	dpmac_info[dpmac_id].enet_if = PHY_INTERFACE_MODE_NONE;
+	dpmac_info[dpmac_id].enet_if = PHY_INTERFACE_MODE_NA;
 
 	enet_if = wriop_dpmac_enet_if(dpmac_id, lane_prtcl);
-	if (enet_if != PHY_INTERFACE_MODE_NONE) {
+	if (enet_if != PHY_INTERFACE_MODE_NA) {
 		dpmac_info[dpmac_id].enabled = 1;
 		dpmac_info[dpmac_id].id = dpmac_id;
 		dpmac_info[dpmac_id].enet_if = enet_if;
@@ -183,10 +183,10 @@
 	int i = wriop_dpmac_to_index(dpmac_id);
 
 	if (i == -1)
-		return PHY_INTERFACE_MODE_NONE;
+		return PHY_INTERFACE_MODE_NA;
 
 	if (dpmac_info[i].enabled)
 		return dpmac_info[i].enet_if;
 
-	return PHY_INTERFACE_MODE_NONE;
+	return PHY_INTERFACE_MODE_NA;
 }
diff --git a/drivers/net/ldpaa_eth/ls1088a.c b/drivers/net/ldpaa_eth/ls1088a.c
index 54cb16e..943113b 100644
--- a/drivers/net/ldpaa_eth/ls1088a.c
+++ b/drivers/net/ldpaa_eth/ls1088a.c
@@ -50,7 +50,7 @@
 	enum srds_prtcl;
 
 	if (is_device_disabled(dpmac_id + 1))
-		return PHY_INTERFACE_MODE_NONE;
+		return PHY_INTERFACE_MODE_NA;
 
 	switch (lane_prtcl) {
 	case SGMII1:
@@ -66,7 +66,7 @@
 	if (lane_prtcl >= QSGMII_A && lane_prtcl <= QSGMII_B)
 		return PHY_INTERFACE_MODE_QSGMII;
 
-	return PHY_INTERFACE_MODE_NONE;
+	return PHY_INTERFACE_MODE_NA;
 }
 
 void wriop_init_dpmac_qsgmii(int sd, int lane_prtcl)
diff --git a/drivers/net/ldpaa_eth/ls2080a.c b/drivers/net/ldpaa_eth/ls2080a.c
index 49eee04..62e1d6b 100644
--- a/drivers/net/ldpaa_eth/ls2080a.c
+++ b/drivers/net/ldpaa_eth/ls2080a.c
@@ -62,7 +62,7 @@
 	enum srds_prtcl;
 
 	if (is_device_disabled(dpmac_id + 1))
-		return PHY_INTERFACE_MODE_NONE;
+		return PHY_INTERFACE_MODE_NA;
 
 	if (lane_prtcl >= SGMII1 && lane_prtcl <= SGMII16)
 		return PHY_INTERFACE_MODE_SGMII;
@@ -76,7 +76,7 @@
 	if (lane_prtcl >= QSGMII_A && lane_prtcl <= QSGMII_D)
 		return PHY_INTERFACE_MODE_QSGMII;
 
-	return PHY_INTERFACE_MODE_NONE;
+	return PHY_INTERFACE_MODE_NA;
 }
 
 void wriop_init_dpmac_qsgmii(int sd, int lane_prtcl)
diff --git a/drivers/net/ldpaa_eth/lx2160a.c b/drivers/net/ldpaa_eth/lx2160a.c
index e57f1a1..f0f8ee1 100644
--- a/drivers/net/ldpaa_eth/lx2160a.c
+++ b/drivers/net/ldpaa_eth/lx2160a.c
@@ -58,7 +58,7 @@
 	enum srds_prtcl;
 
 	if (is_device_disabled(dpmac_id))
-		return PHY_INTERFACE_MODE_NONE;
+		return PHY_INTERFACE_MODE_NA;
 
 	if (lane_prtcl >= SGMII1 && lane_prtcl <= SGMII18)
 		return PHY_INTERFACE_MODE_SGMII;
@@ -78,7 +78,7 @@
 	if (lane_prtcl >= _100GE1 && lane_prtcl <= _100GE2)
 		return PHY_INTERFACE_MODE_CAUI4;
 
-	return PHY_INTERFACE_MODE_NONE;
+	return PHY_INTERFACE_MODE_NA;
 }
 
 #ifdef CONFIG_SYS_FSL_HAS_RGMII
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 37eed59..e02a57b 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -1360,17 +1360,11 @@
 	struct eth_pdata *pdata = dev_get_plat(dev);
 	struct macb_device *macb = dev_get_priv(dev);
 	struct ofnode_phandle_args phandle_args;
-	const char *phy_mode;
 	int ret;
 
-	phy_mode = dev_read_prop(dev, "phy-mode", NULL);
-
-	if (phy_mode)
-		macb->phy_interface = phy_get_interface_by_name(phy_mode);
-	if (macb->phy_interface == -1) {
-		debug("%s: Invalid PHY interface '%s'\n", __func__, phy_mode);
+	macb->phy_interface = dev_read_phy_mode(dev);
+	if (macb->phy_interface == PHY_INTERFACE_MODE_NA)
 		return -EINVAL;
-	}
 
 	/* Read phyaddr from DT */
 	if (!dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
diff --git a/drivers/net/mdio_mux_sandbox.c b/drivers/net/mdio_mux_sandbox.c
index fff6ddb..e1801c1 100644
--- a/drivers/net/mdio_mux_sandbox.c
+++ b/drivers/net/mdio_mux_sandbox.c
@@ -20,7 +20,6 @@
 static int mdio_mux_sandbox_mark_selection(struct udevice *dev, int sel)
 {
 	struct udevice *mdio;
-	struct mdio_ops *ops;
 	int err;
 
 	/*
@@ -30,9 +29,8 @@
 	err = uclass_get_device_by_name(UCLASS_MDIO, "mdio-test", &mdio);
 	if (err)
 		return err;
-	ops = mdio_get_ops(mdio);
-	return ops->write(mdio, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
-			  SANDBOX_PHY_REG_CNT - 1, (u16)sel);
+	return dm_mdio_write(mdio, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
+			     SANDBOX_PHY_REG_CNT - 1, (u16)sel);
 }
 
 static int mdio_mux_sandbox_select(struct udevice *dev, int cur, int sel)
diff --git a/drivers/net/mscc_eswitch/jr2_switch.c b/drivers/net/mscc_eswitch/jr2_switch.c
index d1e5b61..1462b8f 100644
--- a/drivers/net/mscc_eswitch/jr2_switch.c
+++ b/drivers/net/mscc_eswitch/jr2_switch.c
@@ -954,7 +954,7 @@
 
 		phy = phy_connect(priv->ports[i].bus,
 				  priv->ports[i].phy_addr, dev,
-				  PHY_INTERFACE_MODE_NONE);
+				  PHY_INTERFACE_MODE_NA);
 		if (phy)
 			board_phy_config(phy);
 	}
diff --git a/drivers/net/mscc_eswitch/luton_switch.c b/drivers/net/mscc_eswitch/luton_switch.c
index 73c950d..5e4f00c 100644
--- a/drivers/net/mscc_eswitch/luton_switch.c
+++ b/drivers/net/mscc_eswitch/luton_switch.c
@@ -685,7 +685,7 @@
 
 		phy = phy_connect(priv->ports[i].bus,
 				  priv->ports[i].phy_addr, dev,
-				  PHY_INTERFACE_MODE_NONE);
+				  PHY_INTERFACE_MODE_NA);
 		if (phy && i >= MAX_INT_PORT)
 			board_phy_config(phy);
 	}
diff --git a/drivers/net/mscc_eswitch/ocelot_switch.c b/drivers/net/mscc_eswitch/ocelot_switch.c
index d1d0a48..1bf6c42 100644
--- a/drivers/net/mscc_eswitch/ocelot_switch.c
+++ b/drivers/net/mscc_eswitch/ocelot_switch.c
@@ -608,7 +608,7 @@
 
 		phy = phy_connect(priv->ports[i].bus,
 				  priv->ports[i].phy_addr, dev,
-				  PHY_INTERFACE_MODE_NONE);
+				  PHY_INTERFACE_MODE_NA);
 		if (phy && external_bus(priv, i))
 			board_phy_config(phy);
 	}
diff --git a/drivers/net/mscc_eswitch/serval_switch.c b/drivers/net/mscc_eswitch/serval_switch.c
index c4b81f7..38ddba1 100644
--- a/drivers/net/mscc_eswitch/serval_switch.c
+++ b/drivers/net/mscc_eswitch/serval_switch.c
@@ -561,7 +561,7 @@
 
 		phy = phy_connect(priv->ports[i].bus,
 				  priv->ports[i].phy_addr, dev,
-				  PHY_INTERFACE_MODE_NONE);
+				  PHY_INTERFACE_MODE_NA);
 		if (phy)
 			board_phy_config(phy);
 	}
diff --git a/drivers/net/mscc_eswitch/servalt_switch.c b/drivers/net/mscc_eswitch/servalt_switch.c
index f114086..db863c2 100644
--- a/drivers/net/mscc_eswitch/servalt_switch.c
+++ b/drivers/net/mscc_eswitch/servalt_switch.c
@@ -482,7 +482,7 @@
 			continue;
 
 		phy_connect(priv->ports[i].bus, priv->ports[i].phy_addr, dev,
-			    PHY_INTERFACE_MODE_NONE);
+			    PHY_INTERFACE_MODE_NA);
 	}
 
 	return 0;
diff --git a/drivers/net/mt7620-eth.c b/drivers/net/mt7620-eth.c
index 222250d..038cba1 100644
--- a/drivers/net/mt7620-eth.c
+++ b/drivers/net/mt7620-eth.c
@@ -596,7 +596,7 @@
 	case PHY_INTERFACE_MODE_RGMII:
 		ge_mode = MT7620_SYSC_GE_RGMII;
 		break;
-	case PHY_INTERFACE_MODE_NONE:
+	case PHY_INTERFACE_MODE_NA:
 		if (gmac == 2)
 			ge_mode = MT7620_SYSC_GE_ESW_PHY;
 		else
@@ -620,7 +620,7 @@
 {
 	u32 pmcr;
 
-	if (port_cfg->mode == PHY_INTERFACE_MODE_NONE) {
+	if (port_cfg->mode == PHY_INTERFACE_MODE_NA) {
 		if (port == 5) {
 			gsw_write(priv, GSW_PMCR(port), FORCE_MODE);
 			return;
@@ -666,7 +666,7 @@
 {
 	int phy_addr_st, phy_addr_end;
 
-	if (priv->port_cfg[0].mode == PHY_INTERFACE_MODE_NONE)
+	if (priv->port_cfg[0].mode == PHY_INTERFACE_MODE_NA)
 		priv->ephy_num = NUM_FE_PHYS;
 	else
 		priv->ephy_num = NUM_FE_PHYS - 1;
@@ -1048,33 +1048,20 @@
 				     ofnode node)
 {
 	ofnode subnode;
-	const char *str;
-	int mode, speed, ret;
+	int speed, ret;
 	u32 phy_addr;
 
-	str = ofnode_read_string(node, "phy-mode");
-	if (str) {
-		mode = phy_get_interface_by_name(str);
-		if (mode < 0) {
-			dev_err(priv->dev, "mt7620_eth: invalid phy-mode\n");
-			return -EINVAL;
-		}
+	priv->port_cfg[idx].mode = ofnode_read_phy_mode(node);
 
-		switch (mode) {
-		case PHY_INTERFACE_MODE_MII:
-		case PHY_INTERFACE_MODE_RMII:
-		case PHY_INTERFACE_MODE_RGMII:
-		case PHY_INTERFACE_MODE_NONE:
-			break;
-		default:
-			dev_err(priv->dev,
-				"mt7620_eth: unsupported phy-mode\n");
-			return -ENOTSUPP;
-		}
-
-		priv->port_cfg[idx].mode = mode;
-	} else {
-		priv->port_cfg[idx].mode = PHY_INTERFACE_MODE_NONE;
+	switch (priv->port_cfg[idx].mode) {
+	case PHY_INTERFACE_MODE_MII:
+	case PHY_INTERFACE_MODE_RMII:
+	case PHY_INTERFACE_MODE_RGMII:
+	case PHY_INTERFACE_MODE_NA:
+		break;
+	default:
+		dev_err(priv->dev, "mt7620_eth: unsupported phy-mode\n");
+		return -ENOTSUPP;
 	}
 
 	subnode = ofnode_find_subnode(node, "fixed-link");
@@ -1141,14 +1128,14 @@
 		if (ret)
 			return ret;
 	} else {
-		priv->port_cfg[0].mode = PHY_INTERFACE_MODE_NONE;
+		priv->port_cfg[0].mode = PHY_INTERFACE_MODE_NA;
 	}
 
 	subnode = ofnode_find_subnode(dev_ofnode(dev), "port5");
 	if (ofnode_valid(subnode))
 		return mt7620_eth_parse_gsw_port(priv, 1, subnode);
 
-	priv->port_cfg[1].mode = PHY_INTERFACE_MODE_NONE;
+	priv->port_cfg[1].mode = PHY_INTERFACE_MODE_NA;
 	return 0;
 }
 
diff --git a/drivers/net/mtk_eth.c b/drivers/net/mtk_eth.c
index 26f0284..666ddeb 100644
--- a/drivers/net/mtk_eth.c
+++ b/drivers/net/mtk_eth.c
@@ -1447,11 +1447,9 @@
 	priv->gmac_id = dev_read_u32_default(dev, "mediatek,gmac-id", 0);
 
 	/* Interface mode is required */
-	str = dev_read_string(dev, "phy-mode");
-	if (str) {
-		pdata->phy_interface = phy_get_interface_by_name(str);
-		priv->phy_interface = pdata->phy_interface;
-	} else {
+	pdata->phy_interface = dev_read_phy_mode(dev);
+	priv->phy_interface = pdata->phy_interface;
+	if (pdata->phy_interface == PHY_INTERFACE_MODE_NA) {
 		printf("error: phy-mode is not set\n");
 		return -EINVAL;
 	}
diff --git a/drivers/net/mvgbe.c b/drivers/net/mvgbe.c
index 954bf86..bf5ed55 100644
--- a/drivers/net/mvgbe.c
+++ b/drivers/net/mvgbe.c
@@ -993,7 +993,6 @@
 	struct mvgbe_device *dmvgbe = dev_get_priv(dev);
 	void *blob = (void *)gd->fdt_blob;
 	int node = dev_of_offset(dev);
-	const char *phy_mode;
 	int fl_node;
 	int pnode;
 	unsigned long addr;
@@ -1005,10 +1004,8 @@
 					      "marvell,kirkwood-eth-port");
 
 	/* Get phy-mode / phy_interface from DT */
-	phy_mode = fdt_getprop(gd->fdt_blob, pnode, "phy-mode", NULL);
-	if (phy_mode)
-		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
-	else
+	pdata->phy_interface = dev_read_phy_mode(dev);
+	if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
 		pdata->phy_interface = PHY_INTERFACE_MODE_GMII;
 
 	dmvgbe->phy_interface = pdata->phy_interface;
diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 4a4268c..e2ac4d8 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -1799,20 +1799,13 @@
 static int mvneta_of_to_plat(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_plat(dev);
-	const char *phy_mode;
 
 	pdata->iobase = dev_read_addr(dev);
 
 	/* Get phy-mode / phy_interface from DT */
-	pdata->phy_interface = -1;
-	phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
-			       NULL);
-	if (phy_mode)
-		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
-	if (pdata->phy_interface == -1) {
-		debug("%s: Invalid PHY interface '%s'\n", __func__, phy_mode);
+	pdata->phy_interface = dev_read_phy_mode(dev);
+	if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
 		return -EINVAL;
-	}
 
 	return 0;
 }
diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index 4c0a7b0..8c9afdf 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -4786,11 +4786,9 @@
 static int phy_info_parse(struct udevice *dev, struct mvpp2_port *port)
 {
 	int port_node = dev_of_offset(dev);
-	const char *phy_mode_str;
 	int phy_node;
 	u32 id;
 	u32 phyaddr = 0;
-	int phy_mode = -1;
 	int fixed_link = 0;
 	int ret;
 
@@ -4821,10 +4819,8 @@
 		phyaddr = PHY_MAX_ADDR;
 	}
 
-	phy_mode_str = fdt_getprop(gd->fdt_blob, port_node, "phy-mode", NULL);
-	if (phy_mode_str)
-		phy_mode = phy_get_interface_by_name(phy_mode_str);
-	if (phy_mode == -1) {
+	port->phy_interface = dev_read_phy_mode(dev);
+	if (port->phy_interface == PHY_INTERFACE_MODE_NA) {
 		dev_err(dev, "incorrect phy mode\n");
 		return -EINVAL;
 	}
@@ -4847,7 +4843,6 @@
 		port->first_rxq = port->id * rxq_number;
 	else
 		port->first_rxq = port->id * port->priv->max_port_rxqs;
-	port->phy_interface = phy_mode;
 	port->phyaddr = phyaddr;
 
 	return 0;
diff --git a/drivers/net/pch_gbe.c b/drivers/net/pch_gbe.c
index fabcf85..f189524 100644
--- a/drivers/net/pch_gbe.c
+++ b/drivers/net/pch_gbe.c
@@ -416,13 +416,13 @@
 	struct phy_device *phydev;
 	int mask = 0xffffffff;
 
-	phydev = phy_find_by_mask(priv->bus, mask, plat->phy_interface);
+	phydev = phy_find_by_mask(priv->bus, mask);
 	if (!phydev) {
 		printf("pch_gbe: cannot find the phy\n");
 		return -1;
 	}
 
-	phy_connect_dev(phydev, dev);
+	phy_connect_dev(phydev, dev, plat->phy_interface);
 
 	phydev->supported &= PHY_GBIT_FEATURES;
 	phydev->advertising = phydev->supported;
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index d40ce92..33a4b6f 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -68,6 +68,11 @@
 config PHYLIB_10G
 	bool "Generic 10G PHY support"
 
+config PHY_ADIN
+	bool "Analog Devices Industrial Ethernet PHYs"
+	help
+		Add support for configuring RGMII on Analog Devices ADIN PHYs.
+
 menuconfig PHY_AQUANTIA
 	bool "Aquantia Ethernet PHYs support"
 	select PHY_GIGE
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 67ca4d3..9d87eb2 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -10,6 +10,7 @@
 
 obj-$(CONFIG_PHYLIB) += phy.o
 obj-$(CONFIG_PHYLIB_10G) += generic_10g.o
+obj-$(CONFIG_PHY_ADIN) += adin.o
 obj-$(CONFIG_PHY_AQUANTIA) += aquantia.o
 obj-$(CONFIG_PHY_ATHEROS) += atheros.o
 obj-$(CONFIG_PHY_BROADCOM) += broadcom.o
diff --git a/drivers/net/phy/adin.c b/drivers/net/phy/adin.c
new file mode 100644
index 0000000..cff841a
--- /dev/null
+++ b/drivers/net/phy/adin.c
@@ -0,0 +1,228 @@
+// SPDX-License-Identifier: GPL-2.0+
+/**
+ *  Driver for Analog Devices Industrial Ethernet PHYs
+ *
+ * Copyright 2019 Analog Devices Inc.
+ * Copyright 2022 Variscite Ltd.
+ */
+#include <common.h>
+#include <phy.h>
+#include <linux/bitops.h>
+#include <linux/bitfield.h>
+
+#define PHY_ID_ADIN1300				0x0283bc30
+#define ADIN1300_EXT_REG_PTR			0x10
+#define ADIN1300_EXT_REG_DATA			0x11
+#define ADIN1300_GE_RGMII_CFG			0xff23
+#define ADIN1300_GE_RGMII_RX_MSK		GENMASK(8, 6)
+#define ADIN1300_GE_RGMII_RX_SEL(x)		\
+		FIELD_PREP(ADIN1300_GE_RGMII_RX_MSK, x)
+#define ADIN1300_GE_RGMII_GTX_MSK		GENMASK(5, 3)
+#define ADIN1300_GE_RGMII_GTX_SEL(x)		\
+		FIELD_PREP(ADIN1300_GE_RGMII_GTX_MSK, x)
+#define ADIN1300_GE_RGMII_RXID_EN		BIT(2)
+#define ADIN1300_GE_RGMII_TXID_EN		BIT(1)
+#define ADIN1300_GE_RGMII_EN			BIT(0)
+
+/* RGMII internal delay settings for rx and tx for ADIN1300 */
+#define ADIN1300_RGMII_1_60_NS			0x0001
+#define ADIN1300_RGMII_1_80_NS			0x0002
+#define	ADIN1300_RGMII_2_00_NS			0x0000
+#define	ADIN1300_RGMII_2_20_NS			0x0006
+#define	ADIN1300_RGMII_2_40_NS			0x0007
+
+/**
+ * struct adin_cfg_reg_map - map a config value to aregister value
+ * @cfg		value in device configuration
+ * @reg		value in the register
+ */
+struct adin_cfg_reg_map {
+	int cfg;
+	int reg;
+};
+
+static const struct adin_cfg_reg_map adin_rgmii_delays[] = {
+	{ 1600, ADIN1300_RGMII_1_60_NS },
+	{ 1800, ADIN1300_RGMII_1_80_NS },
+	{ 2000, ADIN1300_RGMII_2_00_NS },
+	{ 2200, ADIN1300_RGMII_2_20_NS },
+	{ 2400, ADIN1300_RGMII_2_40_NS },
+	{ },
+};
+
+static int adin_lookup_reg_value(const struct adin_cfg_reg_map *tbl, int cfg)
+{
+	size_t i;
+
+	for (i = 0; tbl[i].cfg; i++) {
+		if (tbl[i].cfg == cfg)
+			return tbl[i].reg;
+	}
+
+	return -EINVAL;
+}
+
+static u32 adin_get_reg_value(struct phy_device *phydev,
+			      const char *prop_name,
+			      const struct adin_cfg_reg_map *tbl,
+			      u32 dflt)
+{
+	u32 val;
+	int rc;
+
+	ofnode node = phy_get_ofnode(phydev);
+	if (!ofnode_valid(node)) {
+		printf("%s: failed to get node\n", __func__);
+		return -EINVAL;
+	}
+
+	if (ofnode_read_u32(node, prop_name, &val)) {
+		printf("%s: failed to find %s, using default %d\n",
+		       __func__, prop_name, dflt);
+		return dflt;
+	}
+
+	debug("%s: %s = '%d'\n", __func__, prop_name, val);
+
+	rc = adin_lookup_reg_value(tbl, val);
+	if (rc < 0) {
+		printf("%s: Unsupported value %u for %s using default (%u)\n",
+		      __func__, val, prop_name, dflt);
+		return dflt;
+	}
+
+	return rc;
+}
+
+/**
+ * adin_get_phy_mode_override - Get phy-mode override for adin PHY
+ *
+ * The function gets phy-mode string from property 'adi,phy-mode-override'
+ * and return its index in phy_interface_strings table, or -1 in error case.
+ */
+int adin_get_phy_mode_override(struct phy_device *phydev)
+{
+	ofnode node = phy_get_ofnode(phydev);
+	const char *phy_mode_override;
+	const char *prop_phy_mode_override = "adi,phy-mode-override";
+	int override_interface;
+
+	phy_mode_override = ofnode_read_string(node, prop_phy_mode_override);
+	if (!phy_mode_override)
+		return -ENODEV;
+
+	debug("%s: %s = '%s'\n",
+	      __func__, prop_phy_mode_override, phy_mode_override);
+
+	override_interface = phy_get_interface_by_name(phy_mode_override);
+
+	if (override_interface < 0)
+		printf("%s: %s = '%s' is not valid\n",
+		       __func__, prop_phy_mode_override, phy_mode_override);
+
+	return override_interface;
+}
+
+static u16 adin_ext_read(struct phy_device *phydev, const u32 regnum)
+{
+	u16 val;
+
+	phy_write(phydev, MDIO_DEVAD_NONE, ADIN1300_EXT_REG_PTR, regnum);
+	val = phy_read(phydev, MDIO_DEVAD_NONE, ADIN1300_EXT_REG_DATA);
+
+	debug("%s: adin@0x%x 0x%x=0x%x\n", __func__, phydev->addr, regnum, val);
+
+	return val;
+}
+
+static int adin_ext_write(struct phy_device *phydev, const u32 regnum, const u16 val)
+{
+	debug("%s: adin@0x%x 0x%x=0x%x\n", __func__, phydev->addr, regnum, val);
+
+	phy_write(phydev, MDIO_DEVAD_NONE, ADIN1300_EXT_REG_PTR, regnum);
+
+	return phy_write(phydev, MDIO_DEVAD_NONE, ADIN1300_EXT_REG_DATA, val);
+}
+
+static int adin_config_rgmii_mode(struct phy_device *phydev)
+{
+	u16 reg_val;
+	u32 val;
+	int phy_mode_override = adin_get_phy_mode_override(phydev);
+
+	if (phy_mode_override >= 0) {
+		phydev->interface = (phy_interface_t) phy_mode_override;
+	}
+
+	reg_val = adin_ext_read(phydev, ADIN1300_GE_RGMII_CFG);
+
+	if (!phy_interface_is_rgmii(phydev)) {
+		/* Disable RGMII */
+		reg_val &= ~ADIN1300_GE_RGMII_EN;
+		return adin_ext_write(phydev, ADIN1300_GE_RGMII_CFG, reg_val);
+	}
+
+	/* Enable RGMII */
+	reg_val |= ADIN1300_GE_RGMII_EN;
+
+	/* Enable / Disable RGMII RX Delay */
+	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
+	    phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) {
+		reg_val |= ADIN1300_GE_RGMII_RXID_EN;
+
+		val = adin_get_reg_value(phydev, "adi,rx-internal-delay-ps",
+					 adin_rgmii_delays,
+					 ADIN1300_RGMII_2_00_NS);
+		reg_val &= ~ADIN1300_GE_RGMII_RX_MSK;
+		reg_val |= ADIN1300_GE_RGMII_RX_SEL(val);
+	} else {
+		reg_val &= ~ADIN1300_GE_RGMII_RXID_EN;
+	}
+
+	/* Enable / Disable RGMII RX Delay */
+	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
+	    phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) {
+		reg_val |= ADIN1300_GE_RGMII_TXID_EN;
+
+		val = adin_get_reg_value(phydev, "adi,tx-internal-delay-ps",
+					 adin_rgmii_delays,
+					 ADIN1300_RGMII_2_00_NS);
+		reg_val &= ~ADIN1300_GE_RGMII_GTX_MSK;
+		reg_val |= ADIN1300_GE_RGMII_GTX_SEL(val);
+	} else {
+		reg_val &= ~ADIN1300_GE_RGMII_TXID_EN;
+	}
+
+	return adin_ext_write(phydev, ADIN1300_GE_RGMII_CFG, reg_val);
+}
+
+static int adin1300_config(struct phy_device *phydev)
+{
+	int ret;
+
+	printf("ADIN1300 PHY detected at addr %d\n", phydev->addr);
+
+	ret = adin_config_rgmii_mode(phydev);
+
+	if (ret < 0)
+		return ret;
+
+	return genphy_config(phydev);
+}
+
+static struct phy_driver ADIN1300_driver =  {
+	.name = "ADIN1300",
+	.uid = PHY_ID_ADIN1300,
+	.mask = 0xffffffff,
+	.features = PHY_GBIT_FEATURES,
+	.config = adin1300_config,
+	.startup = genphy_startup,
+	.shutdown = genphy_shutdown,
+};
+
+int phy_adin_init(void)
+{
+	phy_register(&ADIN1300_driver);
+
+	return 0;
+}
diff --git a/drivers/net/phy/aquantia.c b/drivers/net/phy/aquantia.c
index 83075f7..7e950fe 100644
--- a/drivers/net/phy/aquantia.c
+++ b/drivers/net/phy/aquantia.c
@@ -305,7 +305,7 @@
 	u16 syscfg;
 	int cnt;
 	u16 start_rate;
-} aquantia_syscfg[PHY_INTERFACE_MODE_COUNT] = {
+} aquantia_syscfg[PHY_INTERFACE_MODE_MAX] = {
 	[PHY_INTERFACE_MODE_SGMII] =      {0x04b, AQUANTIA_VND1_GSYSCFG_1G,
 					   AQUANTIA_VND1_GSTART_RATE_1G},
 	[PHY_INTERFACE_MODE_2500BASEX]  = {0x144, AQUANTIA_VND1_GSYSCFG_2_5G,
diff --git a/drivers/net/phy/atheros.c b/drivers/net/phy/atheros.c
index f922fec..fa1fe08 100644
--- a/drivers/net/phy/atheros.c
+++ b/drivers/net/phy/atheros.c
@@ -199,7 +199,7 @@
 
 	node = phy_get_ofnode(phydev);
 	if (!ofnode_valid(node))
-		return -EINVAL;
+		return 0;
 
 	priv = malloc(sizeof(*priv));
 	if (!priv)
diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index eada454..3d86263 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -158,7 +158,7 @@
 
 	node = phy_get_ofnode(phydev);
 	if (!ofnode_valid(node))
-		return -EINVAL;
+		return 0;
 
 	/* Optional configuration */
 	ret = ofnode_read_u32(node, "ti,clk-output-sel",
@@ -266,7 +266,7 @@
 static int dp83867_config(struct phy_device *phydev)
 {
 	struct dp83867_private *dp83867;
-	unsigned int val, delay, cfg2;
+	int val, delay, cfg2;
 	int ret, bs;
 
 	dp83867 = (struct dp83867_private *)phydev->priv;
@@ -291,8 +291,11 @@
 
 	if (phy_interface_is_rgmii(phydev)) {
 		val = phy_read(phydev, MDIO_DEVAD_NONE, MII_DP83867_PHYCTRL);
-		if (val < 0)
+		if (val < 0) {
+			ret = val;
 			goto err_out;
+		}
+
 		val &= ~DP83867_PHYCR_FIFO_DEPTH_MASK;
 		val |= (dp83867->fifo_depth << DP83867_PHYCR_FIFO_DEPTH_SHIFT);
 
diff --git a/drivers/net/phy/ethernet_id.c b/drivers/net/phy/ethernet_id.c
index 1a78a75..8864f99 100644
--- a/drivers/net/phy/ethernet_id.c
+++ b/drivers/net/phy/ethernet_id.c
@@ -12,7 +12,7 @@
 #include <asm/gpio.h>
 
 struct phy_device *phy_connect_phy_id(struct mii_dev *bus, struct udevice *dev,
-				      int phyaddr, phy_interface_t interface)
+				      int phyaddr)
 {
 	struct phy_device *phydev;
 	struct ofnode_phandle_args phandle_args;
@@ -68,7 +68,7 @@
 	}
 
 	id =  vendor << 16 | device;
-	phydev = phy_device_create(bus, phyaddr, id, false, interface);
+	phydev = phy_device_create(bus, phyaddr, id, false);
 	if (phydev)
 		phydev->node = node;
 
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 3672262..1121b99 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -490,6 +490,9 @@
 #ifdef CONFIG_MV88E61XX_SWITCH
 	phy_mv88e61xx_init();
 #endif
+#ifdef CONFIG_PHY_ADIN
+	phy_adin_init();
+#endif
 #ifdef CONFIG_PHY_AQUANTIA
 	phy_aquantia_init();
 #endif
@@ -635,18 +638,17 @@
 	return err;
 }
 
-static struct phy_driver *generic_for_interface(phy_interface_t interface)
+static struct phy_driver *generic_for_phy(struct phy_device *phydev)
 {
 #ifdef CONFIG_PHYLIB_10G
-	if (is_10g_interface(interface))
+	if (phydev->is_c45)
 		return &gen10g_driver;
 #endif
 
 	return &genphy_driver;
 }
 
-static struct phy_driver *get_phy_driver(struct phy_device *phydev,
-					 phy_interface_t interface)
+static struct phy_driver *get_phy_driver(struct phy_device *phydev)
 {
 	struct list_head *entry;
 	int phy_id = phydev->phy_id;
@@ -659,12 +661,11 @@
 	}
 
 	/* If we made it here, there's no driver for this PHY */
-	return generic_for_interface(interface);
+	return generic_for_phy(phydev);
 }
 
 struct phy_device *phy_device_create(struct mii_dev *bus, int addr,
-				     u32 phy_id, bool is_c45,
-				     phy_interface_t interface)
+				     u32 phy_id, bool is_c45)
 {
 	struct phy_device *dev;
 
@@ -683,7 +684,7 @@
 
 	dev->duplex = -1;
 	dev->link = 0;
-	dev->interface = interface;
+	dev->interface = PHY_INTERFACE_MODE_NA;
 
 #ifdef CONFIG_DM_ETH
 	dev->node = ofnode_null();
@@ -696,7 +697,7 @@
 	dev->is_c45 = is_c45;
 	dev->bus = bus;
 
-	dev->drv = get_phy_driver(dev, interface);
+	dev->drv = get_phy_driver(dev);
 
 	if (phy_probe(dev)) {
 		printf("%s, PHY probe failed\n", __func__);
@@ -745,8 +746,7 @@
 }
 
 static struct phy_device *create_phy_by_mask(struct mii_dev *bus,
-					     uint phy_mask, int devad,
-					     phy_interface_t interface)
+					     uint phy_mask, int devad)
 {
 	u32 phy_id = 0xffffffff;
 	bool is_c45;
@@ -767,8 +767,7 @@
 		/* If the PHY ID is mostly f's, we didn't find anything */
 		if (r == 0 && (phy_id & 0x1fffffff) != 0x1fffffff) {
 			is_c45 = (devad == MDIO_DEVAD_NONE) ? false : true;
-			return phy_device_create(bus, addr, phy_id, is_c45,
-						 interface);
+			return phy_device_create(bus, addr, phy_id, is_c45);
 		}
 next:
 		phy_mask &= ~(1 << addr);
@@ -777,25 +776,22 @@
 }
 
 static struct phy_device *search_for_existing_phy(struct mii_dev *bus,
-						  uint phy_mask,
-						  phy_interface_t interface)
+						  uint phy_mask)
 {
 	/* If we have one, return the existing device, with new interface */
 	while (phy_mask) {
 		int addr = ffs(phy_mask) - 1;
 
-		if (bus->phymap[addr]) {
-			bus->phymap[addr]->interface = interface;
+		if (bus->phymap[addr])
 			return bus->phymap[addr];
-		}
+
 		phy_mask &= ~(1 << addr);
 	}
 	return NULL;
 }
 
 static struct phy_device *get_phy_device_by_mask(struct mii_dev *bus,
-						 uint phy_mask,
-						 phy_interface_t interface)
+						 uint phy_mask)
 {
 	struct phy_device *phydev;
 	int devad[] = {
@@ -811,13 +807,12 @@
 	int i, devad_cnt;
 
 	devad_cnt = sizeof(devad)/sizeof(int);
-	phydev = search_for_existing_phy(bus, phy_mask, interface);
+	phydev = search_for_existing_phy(bus, phy_mask);
 	if (phydev)
 		return phydev;
 	/* try different access clauses  */
 	for (i = 0; i < devad_cnt; i++) {
-		phydev = create_phy_by_mask(bus, phy_mask,
-					    devad[i], interface);
+		phydev = create_phy_by_mask(bus, phy_mask, devad[i]);
 		if (IS_ERR(phydev))
 			return NULL;
 		if (phydev)
@@ -845,10 +840,9 @@
  * Description: Reads the ID registers of the PHY at @addr on the
  *   @bus, then allocates and returns the phy_device to represent it.
  */
-static struct phy_device *get_phy_device(struct mii_dev *bus, int addr,
-					 phy_interface_t interface)
+static struct phy_device *get_phy_device(struct mii_dev *bus, int addr)
 {
-	return get_phy_device_by_mask(bus, 1 << addr, interface);
+	return get_phy_device_by_mask(bus, 1 << addr);
 }
 
 int phy_reset(struct phy_device *phydev)
@@ -862,7 +856,7 @@
 
 #ifdef CONFIG_PHYLIB_10G
 	/* If it's 10G, we need to issue reset through one of the MMDs */
-	if (is_10g_interface(phydev->interface)) {
+	if (phydev->is_c45) {
 		if (!phydev->mmds)
 			gen10g_discover_mmds(phydev);
 
@@ -907,18 +901,12 @@
 	struct mii_dev *bus = miiphy_get_dev_by_name(devname);
 	struct phy_device *phydev;
 
-	/*
-	 * miiphy_reset was only used on standard PHYs, so we'll fake it here.
-	 * If later code tries to connect with the right interface, this will
-	 * be corrected by get_phy_device in phy_connect()
-	 */
-	phydev = get_phy_device(bus, addr, PHY_INTERFACE_MODE_MII);
+	phydev = get_phy_device(bus, addr);
 
 	return phy_reset(phydev);
 }
 
-struct phy_device *phy_find_by_mask(struct mii_dev *bus, uint phy_mask,
-				    phy_interface_t interface)
+struct phy_device *phy_find_by_mask(struct mii_dev *bus, uint phy_mask)
 {
 	/* Reset the bus */
 	if (bus->reset) {
@@ -928,13 +916,15 @@
 		mdelay(15);
 	}
 
-	return get_phy_device_by_mask(bus, phy_mask, interface);
+	return get_phy_device_by_mask(bus, phy_mask);
 }
 
 #ifdef CONFIG_DM_ETH
-void phy_connect_dev(struct phy_device *phydev, struct udevice *dev)
+void phy_connect_dev(struct phy_device *phydev, struct udevice *dev,
+		     phy_interface_t interface)
 #else
-void phy_connect_dev(struct phy_device *phydev, struct eth_device *dev)
+void phy_connect_dev(struct phy_device *phydev, struct eth_device *dev,
+		     phy_interface_t interface)
 #endif
 {
 	/* Soft Reset the PHY */
@@ -945,13 +935,14 @@
 		       phydev->dev->name, dev->name);
 	}
 	phydev->dev = dev;
-	debug("%s connected to %s\n", dev->name, phydev->drv->name);
+	phydev->interface = interface;
+	debug("%s connected to %s mode %s\n", dev->name, phydev->drv->name,
+	      phy_string_for_interface(interface));
 }
 
 #ifdef CONFIG_PHY_XILINX_GMII2RGMII
 static struct phy_device *phy_connect_gmii2rgmii(struct mii_dev *bus,
-						 struct udevice *dev,
-						 phy_interface_t interface)
+						 struct udevice *dev)
 {
 	struct phy_device *phydev = NULL;
 	ofnode node;
@@ -960,8 +951,7 @@
 		node = ofnode_by_compatible(node, "xlnx,gmii-to-rgmii-1.0");
 		if (ofnode_valid(node)) {
 			phydev = phy_device_create(bus, 0,
-						   PHY_GMII2RGMII_ID, false,
-						   interface);
+						   PHY_GMII2RGMII_ID, false);
 			if (phydev)
 				phydev->node = node;
 			break;
@@ -985,41 +975,31 @@
  */
 struct phy_device *fixed_phy_create(ofnode node)
 {
-	phy_interface_t interface = PHY_INTERFACE_MODE_NONE;
 	struct phy_device *phydev;
-	const char *if_str;
 	ofnode subnode;
 
-	if_str = ofnode_read_string(node, "phy-mode");
-	if (!if_str) {
-		if_str = ofnode_read_string(node, "phy-interface-type");
-	}
-	if (if_str) {
-		interface = phy_get_interface_by_name(if_str);
-	}
-
 	subnode = ofnode_find_subnode(node, "fixed-link");
 	if (!ofnode_valid(subnode)) {
 		return NULL;
 	}
 
-	phydev = phy_device_create(NULL, 0, PHY_FIXED_ID, false, interface);
+	phydev = phy_device_create(NULL, 0, PHY_FIXED_ID, false);
 	if (phydev)
 		phydev->node = subnode;
 
+	phydev->interface = ofnode_read_phy_mode(node);
+
 	return phydev;
 }
 
 static struct phy_device *phy_connect_fixed(struct mii_dev *bus,
-					    struct udevice *dev,
-					    phy_interface_t interface)
+					    struct udevice *dev)
 {
 	ofnode node = dev_ofnode(dev), subnode;
 	struct phy_device *phydev = NULL;
 
 	if (ofnode_phy_is_fixed_link(node, &subnode)) {
-		phydev = phy_device_create(bus, 0, PHY_FIXED_ID,
-					   false, interface);
+		phydev = phy_device_create(bus, 0, PHY_FIXED_ID, false);
 		if (phydev)
 			phydev->node = subnode;
 	}
@@ -1042,29 +1022,29 @@
 	uint mask = (addr >= 0) ? (1 << addr) : 0xffffffff;
 
 #ifdef CONFIG_PHY_FIXED
-	phydev = phy_connect_fixed(bus, dev, interface);
+	phydev = phy_connect_fixed(bus, dev);
 #endif
 
 #ifdef CONFIG_PHY_NCSI
 	if (!phydev)
-		phydev = phy_device_create(bus, 0, PHY_NCSI_ID, false, interface);
+		phydev = phy_device_create(bus, 0, PHY_NCSI_ID, false);
 #endif
 
 #ifdef CONFIG_PHY_ETHERNET_ID
 	if (!phydev)
-		phydev = phy_connect_phy_id(bus, dev, addr, interface);
+		phydev = phy_connect_phy_id(bus, dev, addr);
 #endif
 
 #ifdef CONFIG_PHY_XILINX_GMII2RGMII
 	if (!phydev)
-		phydev = phy_connect_gmii2rgmii(bus, dev, interface);
+		phydev = phy_connect_gmii2rgmii(bus, dev);
 #endif
 
 	if (!phydev)
-		phydev = phy_find_by_mask(bus, mask, interface);
+		phydev = phy_find_by_mask(bus, mask);
 
 	if (phydev)
-		phy_connect_dev(phydev, dev);
+		phy_connect_dev(phydev, dev, interface);
 	else
 		printf("Could not get PHY for %s: addr %d\n", bus->name, addr);
 	return phydev;
@@ -1102,18 +1082,6 @@
 	return 0;
 }
 
-int phy_get_interface_by_name(const char *str)
-{
-	int i;
-
-	for (i = 0; i < PHY_INTERFACE_MODE_COUNT; i++) {
-		if (!strcmp(str, phy_interface_strings[i]))
-			return i;
-	}
-
-	return -1;
-}
-
 /**
  * phy_modify - Convenience function for modifying a given PHY register
  * @phydev: the phy_device struct
diff --git a/drivers/net/phy/xilinx_gmii2rgmii.c b/drivers/net/phy/xilinx_gmii2rgmii.c
index 635c057..7376283 100644
--- a/drivers/net/phy/xilinx_gmii2rgmii.c
+++ b/drivers/net/phy/xilinx_gmii2rgmii.c
@@ -26,6 +26,11 @@
 
 	debug("%s\n", __func__);
 
+	if (phydev->interface != PHY_INTERFACE_MODE_GMII) {
+		printf("Incorrect interface type\n");
+		return -EINVAL;
+	}
+
 	if (!ofnode_valid(node))
 		return -EINVAL;
 
@@ -37,13 +42,13 @@
 
 	ext_phyaddr = ofnode_read_u32_default(phandle.node, "reg", -1);
 	ext_phydev = phy_find_by_mask(phydev->bus,
-				      1 << ext_phyaddr,
-				      PHY_INTERFACE_MODE_RGMII);
+				      1 << ext_phyaddr);
 	if (!ext_phydev) {
 		printf("%s, No external phy device found\n", __func__);
 		return -EINVAL;
 	}
 
+	ext_phydev->interface = PHY_INTERFACE_MODE_RGMII;
 	ext_phydev->node = phandle.node;
 	phydev->priv = ext_phydev;
 
@@ -114,11 +119,6 @@
 {
 	debug("%s\n", __func__);
 
-	if (phydev->interface != PHY_INTERFACE_MODE_GMII) {
-		printf("Incorrect interface type\n");
-		return -EINVAL;
-	}
-
 	phydev->flags |= PHY_FLAG_BROKEN_RESET;
 
 	return 0;
diff --git a/drivers/net/pic32_eth.c b/drivers/net/pic32_eth.c
index 5a678d1..1333a3a 100644
--- a/drivers/net/pic32_eth.c
+++ b/drivers/net/pic32_eth.c
@@ -534,7 +534,6 @@
 {
 	struct eth_pdata *pdata = dev_get_plat(dev);
 	struct pic32eth_dev *priv = dev_get_priv(dev);
-	const char *phy_mode;
 	void __iomem *iobase;
 	fdt_addr_t addr;
 	fdt_size_t size;
@@ -550,15 +549,9 @@
 	pdata->iobase = (phys_addr_t)addr;
 
 	/* get phy mode */
-	pdata->phy_interface = -1;
-	phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
-			       NULL);
-	if (phy_mode)
-		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
-	if (pdata->phy_interface == -1) {
-		debug("%s: Invalid PHY interface '%s'\n", __func__, phy_mode);
+	pdata->phy_interface = dev_read_phy_mode(dev);
+	if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
 		return -EINVAL;
-	}
 
 	/* get phy addr */
 	offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev),
diff --git a/drivers/net/qe/dm_qe_uec.c b/drivers/net/qe/dm_qe_uec.c
index a12c8cd..8fec1c2 100644
--- a/drivers/net/qe/dm_qe_uec.c
+++ b/drivers/net/qe/dm_qe_uec.c
@@ -1133,19 +1133,12 @@
 static int qe_uec_of_to_plat(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_plat(dev);
-	const char *phy_mode;
 
 	pdata->iobase = (phys_addr_t)devfdt_get_addr(dev);
 
-	pdata->phy_interface = -1;
-	phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
-			       "phy-connection-type", NULL);
-	if (phy_mode)
-		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
-	if (pdata->phy_interface == -1) {
-		debug("%s: Invalid PHY interface '%s'\n", __func__, phy_mode);
+	pdata->phy_interface = dev_read_phy_mode(dev);
+	if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
 		return -EINVAL;
-	}
 
 	return 0;
 }
diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c
index 4078d33..c286805 100644
--- a/drivers/net/ravb.c
+++ b/drivers/net/ravb.c
@@ -319,11 +319,11 @@
 		mdelay(1);
 	}
 
-	phydev = phy_find_by_mask(eth->bus, mask, pdata->phy_interface);
+	phydev = phy_find_by_mask(eth->bus, mask);
 	if (!phydev)
 		return -ENODEV;
 
-	phy_connect_dev(phydev, dev);
+	phy_connect_dev(phydev, dev, pdata->phy_interface);
 
 	eth->phydev = phydev;
 
@@ -674,20 +674,13 @@
 int ravb_of_to_plat(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_plat(dev);
-	const char *phy_mode;
 	const fdt32_t *cell;
-	int ret = 0;
 
 	pdata->iobase = dev_read_addr(dev);
-	pdata->phy_interface = -1;
-	phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
-			       NULL);
-	if (phy_mode)
-		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
-	if (pdata->phy_interface == -1) {
-		debug("%s: Invalid PHY interface '%s'\n", __func__, phy_mode);
+
+	pdata->phy_interface = dev_read_phy_mode(dev);
+	if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
 		return -EINVAL;
-	}
 
 	pdata->max_speed = 1000;
 	cell = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "max-speed", NULL);
@@ -696,7 +689,7 @@
 
 	sprintf(bb_miiphy_buses[0].name, dev->name);
 
-	return ret;
+	return 0;
 }
 
 static const struct udevice_id ravb_ids[] = {
diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c
index 4055f07..1de3ff8 100644
--- a/drivers/net/sh_eth.c
+++ b/drivers/net/sh_eth.c
@@ -762,11 +762,11 @@
 	struct phy_device *phydev;
 	int mask = 0xffffffff;
 
-	phydev = phy_find_by_mask(priv->bus, mask, pdata->phy_interface);
+	phydev = phy_find_by_mask(priv->bus, mask);
 	if (!phydev)
 		return -ENODEV;
 
-	phy_connect_dev(phydev, dev);
+	phy_connect_dev(phydev, dev, pdata->phy_interface);
 
 	port_info->phydev = phydev;
 	phy_config(phydev);
@@ -915,20 +915,13 @@
 int sh_ether_of_to_plat(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_plat(dev);
-	const char *phy_mode;
 	const fdt32_t *cell;
-	int ret = 0;
 
 	pdata->iobase = dev_read_addr(dev);
-	pdata->phy_interface = -1;
-	phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
-			       NULL);
-	if (phy_mode)
-		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
-	if (pdata->phy_interface == -1) {
-		debug("%s: Invalid PHY interface '%s'\n", __func__, phy_mode);
+
+	pdata->phy_interface = dev_read_phy_mode(dev);
+	if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
 		return -EINVAL;
-	}
 
 	pdata->max_speed = 1000;
 	cell = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "max-speed", NULL);
@@ -937,7 +930,7 @@
 
 	sprintf(bb_miiphy_buses[0].name, dev->name);
 
-	return ret;
+	return 0;
 }
 
 static const struct udevice_id sh_ether_ids[] = {
diff --git a/drivers/net/sni_ave.c b/drivers/net/sni_ave.c
index ab51552..58276a4 100644
--- a/drivers/net/sni_ave.c
+++ b/drivers/net/sni_ave.c
@@ -393,11 +393,11 @@
 	struct phy_device *phydev;
 	int mask = GENMASK(31, 0), ret;
 
-	phydev = phy_find_by_mask(priv->bus, mask, priv->phy_mode);
+	phydev = phy_find_by_mask(priv->bus, mask);
 	if (!phydev)
 		return -ENODEV;
 
-	phy_connect_dev(phydev, dev);
+	phy_connect_dev(phydev, dev, priv->phy_mode);
 
 	phydev->supported &= PHY_GBIT_FEATURES;
 	if (priv->max_speed) {
@@ -738,7 +738,6 @@
 	struct eth_pdata *pdata = dev_get_plat(dev);
 	struct ave_private *priv = dev_get_priv(dev);
 	struct ofnode_phandle_args args;
-	const char *phy_mode;
 	const u32 *valp;
 	int ret, nc, nr;
 	const char *name;
@@ -748,15 +747,10 @@
 		return -EINVAL;
 
 	pdata->iobase = dev_read_addr(dev);
-	pdata->phy_interface = -1;
-	phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
-			       NULL);
-	if (phy_mode)
-		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
-	if (pdata->phy_interface == -1) {
-		dev_err(dev, "Invalid PHY interface '%s'\n", phy_mode);
+
+	pdata->phy_interface = dev_read_phy_mode(dev);
+	if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
 		return -EINVAL;
-	}
 
 	pdata->max_speed = 0;
 	valp = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "max-speed",
diff --git a/drivers/net/sni_netsec.c b/drivers/net/sni_netsec.c
index 4901321..24caacf 100644
--- a/drivers/net/sni_netsec.c
+++ b/drivers/net/sni_netsec.c
@@ -1029,19 +1029,13 @@
 	struct eth_pdata *pdata = dev_get_plat(dev);
 	struct netsec_priv *priv = dev_get_priv(dev);
 	struct ofnode_phandle_args phandle_args;
-	const char *phy_mode;
 
 	pdata->iobase = dev_read_addr_index(dev, 0);
 	priv->eeprom_base = dev_read_addr_index(dev, 1) - EERPROM_MAP_OFFSET;
 
-	pdata->phy_interface = -1;
-	phy_mode = dev_read_prop(dev, "phy-mode", NULL);
-	if (phy_mode)
-		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
-	if (pdata->phy_interface == -1) {
-		pr_err("%s: Invalid PHY interface '%s'\n", __func__, phy_mode);
+	pdata->phy_interface = dev_read_phy_mode(dev);
+	if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
 		return -EINVAL;
-	}
 
 	if (!dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
 					&phandle_args))
diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c
index b23faa2..2220f84 100644
--- a/drivers/net/sun8i_emac.c
+++ b/drivers/net/sun8i_emac.c
@@ -383,8 +383,6 @@
 	if (!phydev)
 		return -ENODEV;
 
-	phy_connect_dev(phydev, dev);
-
 	priv->phydev = phydev;
 	phy_config(priv->phydev);
 
@@ -795,7 +793,6 @@
 	struct sun8i_eth_pdata *sun8i_pdata = dev_get_plat(dev);
 	struct eth_pdata *pdata = &sun8i_pdata->eth_pdata;
 	struct emac_eth_dev *priv = dev_get_priv(dev);
-	const char *phy_mode;
 	const fdt32_t *reg;
 	int node = dev_of_offset(dev);
 	int offset = 0;
@@ -859,16 +856,10 @@
 	}
 	priv->phyaddr = fdtdec_get_int(gd->fdt_blob, offset, "reg", -1);
 
-	phy_mode = fdt_getprop(gd->fdt_blob, node, "phy-mode", NULL);
-
-	if (phy_mode)
-		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
+	pdata->phy_interface = dev_read_phy_mode(dev);
 	printf("phy interface%d\n", pdata->phy_interface);
-
-	if (pdata->phy_interface == -1) {
-		debug("%s: Invalid PHY interface '%s'\n", __func__, phy_mode);
+	if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
 		return -EINVAL;
-	}
 
 	if (priv->variant == H3_EMAC) {
 		ret = sun8i_handle_internal_phy(dev, priv);
diff --git a/drivers/net/sunxi_emac.c b/drivers/net/sunxi_emac.c
index d15b0ad..8625e49 100644
--- a/drivers/net/sunxi_emac.c
+++ b/drivers/net/sunxi_emac.c
@@ -271,12 +271,11 @@
 	if (ret)
 		return ret;
 
-	priv->phydev = phy_find_by_mask(priv->bus, mask,
-					PHY_INTERFACE_MODE_MII);
+	priv->phydev = phy_find_by_mask(priv->bus, mask);
 	if (!priv->phydev)
 		return -ENODEV;
 
-	phy_connect_dev(priv->phydev, dev);
+	phy_connect_dev(priv->phydev, dev, PHY_INTERFACE_MODE_MII);
 	phy_config(priv->phydev);
 
 	return 0;
diff --git a/drivers/net/ti/am65-cpsw-nuss.c b/drivers/net/ti/am65-cpsw-nuss.c
index 87f51b3..9580fa3 100644
--- a/drivers/net/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ti/am65-cpsw-nuss.c
@@ -602,21 +602,14 @@
 	struct eth_pdata *pdata = dev_get_plat(dev);
 	struct am65_cpsw_priv *priv = dev_get_priv(dev);
 	struct ofnode_phandle_args out_args;
-	const char *phy_mode;
 	int ret = 0;
 
 	dev_read_u32(dev, "reg", &priv->port_id);
 
-	phy_mode = dev_read_string(dev, "phy-mode");
-	if (phy_mode) {
-		pdata->phy_interface =
-				phy_get_interface_by_name(phy_mode);
-		if (pdata->phy_interface == -1) {
-			dev_err(dev, "Invalid PHY mode '%s', port %u\n",
-				phy_mode, priv->port_id);
-			ret = -EINVAL;
-			goto out;
-		}
+	pdata->phy_interface = dev_read_phy_mode(dev);
+	if (pdata->phy_interface == PHY_INTERFACE_MODE_NA) {
+		dev_err(dev, "Invalid PHY mode, port %u\n", priv->port_id);
+		return -EINVAL;
 	}
 
 	dev_read_u32(dev, "max-speed", (u32 *)&pdata->max_speed);
diff --git a/drivers/net/ti/cpsw.c b/drivers/net/ti/cpsw.c
index 68f4191..8988c21 100644
--- a/drivers/net/ti/cpsw.c
+++ b/drivers/net/ti/cpsw.c
@@ -1194,15 +1194,12 @@
 {
 	struct ofnode_phandle_args out_args;
 	struct cpsw_slave_data *slave_data;
-	const char *phy_mode;
 	u32 phy_id[2];
 	int ret;
 
 	slave_data = &data->slave_data[slave_index];
 
-	phy_mode = ofnode_read_string(subnode, "phy-mode");
-	if (phy_mode)
-		slave_data->phy_if = phy_get_interface_by_name(phy_mode);
+	slave_data->phy_if = ofnode_read_phy_mode(subnode);
 
 	ret = ofnode_parse_phandle_with_args(subnode, "phy-handle",
 					     NULL, 0, 0, &out_args);
@@ -1348,11 +1345,8 @@
 	}
 
 	pdata->phy_interface = data->slave_data[data->active_slave].phy_if;
-	if (pdata->phy_interface == -1) {
-		debug("%s: Invalid PHY interface '%s'\n", __func__,
-		      phy_string_for_interface(pdata->phy_interface));
+	if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
 		return -EINVAL;
-	}
 
 	return 0;
 }
diff --git a/drivers/net/ti/keystone_net.c b/drivers/net/ti/keystone_net.c
index 5e8f683..fbec69f 100644
--- a/drivers/net/ti/keystone_net.c
+++ b/drivers/net/ti/keystone_net.c
@@ -23,7 +23,6 @@
 #include <asm/ti-common/keystone_net.h>
 #include <asm/ti-common/keystone_serdes.h>
 #include <asm/arch/psc_defs.h>
-#include <linux/libfdt.h>
 
 #include "cpsw_mdio.h"
 
@@ -91,9 +90,9 @@
 	struct mii_dev			*mdio_bus;
 	int				phy_addr;
 	phy_interface_t			phy_if;
-	int				phy_of_handle;
+	ofnode				phy_ofnode;
 	int				sgmii_link_type;
-	void				*mdio_base;
+	phys_addr_t			mdio_base;
 	struct rx_buff_desc		net_rx_buffs;
 	struct pktdma_cfg		*netcp_pktdma;
 	void				*hd;
@@ -570,7 +569,7 @@
 		 * to re-use the same
 		 */
 		mdio_bus = cpsw_mdio_init("ethernet-mdio",
-					  (u32)priv->mdio_base,
+					  priv->mdio_base,
 					  EMAC_MDIO_CLOCK_FREQ,
 					  EMAC_MDIO_BUS_FREQ);
 		if (!mdio_bus) {
@@ -593,8 +592,8 @@
 		priv->phydev = phy_connect(priv->mdio_bus, priv->phy_addr,
 					   dev, priv->phy_if);
 #ifdef CONFIG_DM_ETH
-	if (priv->phy_of_handle)
-		priv->phydev->node = offset_to_ofnode(priv->phy_of_handle);
+	if (ofnode_valid(priv->phy_ofnode))
+		priv->phydev->node = priv->phy_ofnode;
 #endif
 		phy_config(priv->phydev);
 	}
@@ -621,105 +620,88 @@
 	.write_hwaddr		= ks2_eth_write_hwaddr,
 };
 
-static int ks2_eth_bind_slaves(struct udevice *dev, int gbe, int *gbe_0)
+static int ks2_bind_one_slave(struct udevice *dev, ofnode slave, ofnode *gbe_0)
 {
-	const void *fdt = gd->fdt_blob;
-	struct udevice *sl_dev;
-	int interfaces;
-	int sec_slave;
-	int slave;
-	int ret;
 	char *slave_name;
+	u32 slave_no;
+	int ret;
 
-	interfaces = fdt_subnode_offset(fdt, gbe, "interfaces");
-	fdt_for_each_subnode(slave, fdt, interfaces) {
-		int slave_no;
+	if (ofnode_read_u32(slave, "slave-port", &slave_no))
+		return 0;
 
-		slave_no = fdtdec_get_int(fdt, slave, "slave-port", -ENOENT);
-		if (slave_no == -ENOENT)
-			continue;
-
-		if (slave_no == 0) {
-			/* This is the current eth device */
-			*gbe_0 = slave;
-		} else {
-			/* Slave devices to be registered */
-			slave_name = malloc(20);
-			snprintf(slave_name, 20, "netcp@slave-%d", slave_no);
-			ret = device_bind_driver_to_node(dev, "eth_ks2_sl",
-					slave_name, offset_to_ofnode(slave),
-					&sl_dev);
-			if (ret) {
-				pr_err("ks2_net - not able to bind slave interfaces\n");
-				return ret;
-			}
-		}
+	if (gbe_0 && slave_no == 0) {
+		/* This is the current eth device */
+		*gbe_0 = slave;
+		return 0;
 	}
 
-	sec_slave = fdt_subnode_offset(fdt, gbe, "secondary-slave-ports");
-	fdt_for_each_subnode(slave, fdt, sec_slave) {
-		int slave_no;
+	/* Slave devices to be registered */
+	slave_name = malloc(20);
+	snprintf(slave_name, 20, "netcp@slave-%d", slave_no);
+	ret = device_bind_driver_to_node(dev, "eth_ks2_sl", slave_name, slave,
+					 NULL);
+	if (ret)
+		pr_err("ks2_net - not able to bind slave interfaces\n");
 
-		slave_no = fdtdec_get_int(fdt, slave, "slave-port", -ENOENT);
-		if (slave_no == -ENOENT)
-			continue;
+	return ret;
+}
 
-		/* Slave devices to be registered */
-		slave_name = malloc(20);
-		snprintf(slave_name, 20, "netcp@slave-%d", slave_no);
-		ret = device_bind_driver_to_node(dev, "eth_ks2_sl", slave_name,
-					offset_to_ofnode(slave), &sl_dev);
-		if (ret) {
-			pr_err("ks2_net - not able to bind slave interfaces\n");
+static int ks2_eth_bind_slaves(struct udevice *dev, ofnode gbe, ofnode *gbe_0)
+{
+	ofnode interfaces, sec_slave, slave;
+	int ret;
+
+	interfaces = ofnode_find_subnode(gbe, "interfaces");
+	ofnode_for_each_subnode(slave, interfaces) {
+		ret = ks2_bind_one_slave(dev, slave, gbe_0);
+		if (ret)
 			return ret;
-		}
+	}
+
+	sec_slave = ofnode_find_subnode(gbe, "secondary-slave-ports");
+	ofnode_for_each_subnode(slave, sec_slave) {
+		ret = ks2_bind_one_slave(dev, slave, NULL);
+		if (ret)
+			return ret;
 	}
 
 	return 0;
 }
 
-static int ks2_eth_parse_slave_interface(int netcp, int slave,
+static int ks2_eth_parse_slave_interface(ofnode netcp, ofnode slave,
 					 struct ks2_eth_priv *priv,
 					 struct eth_pdata *pdata)
 {
-	const void *fdt = gd->fdt_blob;
-	int mdio;
-	int phy;
+	struct ofnode_phandle_args dma_args;
+	ofnode phy, mdio;
 	int dma_count;
-	u32 dma_channel[8];
-	const char *phy_mode;
 
-	priv->slave_port = fdtdec_get_int(fdt, slave, "slave-port", -1);
+	priv->slave_port = ofnode_read_s32_default(slave, "slave-port", -1);
 	priv->net_rx_buffs.rx_flow = priv->slave_port * 8;
 
 	/* U-Boot slave port number starts with 1 instead of 0 */
 	priv->slave_port += 1;
 
-	dma_count = fdtdec_get_int_array_count(fdt, netcp,
-					       "ti,navigator-dmas",
-					       dma_channel, 8);
+	dma_count = ofnode_count_phandle_with_args(netcp, "ti,navigator-dmas",
+						   NULL, 1);
+	if (priv->slave_port < dma_count &&
+	    !ofnode_parse_phandle_with_args(netcp, "ti,navigator-dmas", NULL, 1,
+					    priv->slave_port - 1, &dma_args))
+		priv->net_rx_buffs.rx_flow = dma_args.args[0];
 
-	if (dma_count > (2 * priv->slave_port)) {
-		int dma_idx;
+	priv->link_type = ofnode_read_s32_default(slave, "link-interface", -1);
 
-		dma_idx = priv->slave_port * 2 - 1;
-		priv->net_rx_buffs.rx_flow = dma_channel[dma_idx];
-	}
+	phy = ofnode_get_phy_node(slave);
+	priv->phy_ofnode = phy;
+	if (ofnode_valid(phy)) {
+		priv->phy_addr = ofnode_read_s32_default(phy, "reg", -1);
 
-	priv->link_type = fdtdec_get_int(fdt, slave, "link-interface", -1);
-
-	phy = fdtdec_lookup_phandle(fdt, slave, "phy-handle");
-
-	if (phy >= 0) {
-		priv->phy_of_handle = phy;
-		priv->phy_addr = fdtdec_get_int(fdt, phy, "reg", -1);
-
-		mdio = fdt_parent_offset(fdt, phy);
-		if (mdio < 0) {
+		mdio = ofnode_get_parent(phy);
+		if (!ofnode_valid(mdio)) {
 			pr_err("mdio dt not found\n");
 			return -ENODEV;
 		}
-		priv->mdio_base = (void *)fdtdec_get_addr(fdt, mdio, "reg");
+		priv->mdio_base = ofnode_get_addr(mdio);
 	}
 
 	if (priv->link_type == LINK_TYPE_SGMII_MAC_TO_PHY_MODE) {
@@ -728,20 +710,19 @@
 		priv->sgmii_link_type = SGMII_LINK_MAC_PHY;
 		priv->has_mdio = true;
 	} else if (priv->link_type == LINK_TYPE_RGMII_LINK_MAC_PHY) {
-		phy_mode = fdt_getprop(fdt, slave, "phy-mode", NULL);
-		if (phy_mode) {
-			priv->phy_if = phy_get_interface_by_name(phy_mode);
-			if (priv->phy_if != PHY_INTERFACE_MODE_RGMII &&
-			    priv->phy_if != PHY_INTERFACE_MODE_RGMII_ID &&
-			    priv->phy_if != PHY_INTERFACE_MODE_RGMII_RXID &&
-			    priv->phy_if != PHY_INTERFACE_MODE_RGMII_TXID) {
-				pr_err("invalid phy-mode\n");
-				return -EINVAL;
-			}
-		} else {
+		priv->phy_if = ofnode_read_phy_mode(slave);
+		if (priv->phy_if == PHY_INTERFACE_MODE_NA)
 			priv->phy_if = PHY_INTERFACE_MODE_RGMII;
-		}
 		pdata->phy_interface = priv->phy_if;
+
+		if (priv->phy_if != PHY_INTERFACE_MODE_RGMII &&
+		    priv->phy_if != PHY_INTERFACE_MODE_RGMII_ID &&
+		    priv->phy_if != PHY_INTERFACE_MODE_RGMII_RXID &&
+		    priv->phy_if != PHY_INTERFACE_MODE_RGMII_TXID) {
+			pr_err("invalid phy-mode\n");
+			return -EINVAL;
+		}
+
 		priv->has_mdio = true;
 	}
 
@@ -750,23 +731,19 @@
 
 static int ks2_sl_eth_of_to_plat(struct udevice *dev)
 {
+	ofnode slave, interfaces, gbe, netcp_devices, netcp;
 	struct ks2_eth_priv *priv = dev_get_priv(dev);
 	struct eth_pdata *pdata = dev_get_plat(dev);
-	const void *fdt = gd->fdt_blob;
-	int slave = dev_of_offset(dev);
-	int interfaces;
-	int gbe;
-	int netcp_devices;
-	int netcp;
 
-	interfaces = fdt_parent_offset(fdt, slave);
-	gbe = fdt_parent_offset(fdt, interfaces);
-	netcp_devices = fdt_parent_offset(fdt, gbe);
-	netcp = fdt_parent_offset(fdt, netcp_devices);
+	slave = dev_ofnode(dev);
+	interfaces = ofnode_get_parent(slave);
+	gbe = ofnode_get_parent(interfaces);
+	netcp_devices = ofnode_get_parent(gbe);
+	netcp = ofnode_get_parent(netcp_devices);
 
 	ks2_eth_parse_slave_interface(netcp, slave, priv, pdata);
 
-	pdata->iobase = fdtdec_get_addr(fdt, netcp, "reg");
+	pdata->iobase = ofnode_get_addr(netcp);
 
 	return 0;
 }
@@ -775,18 +752,15 @@
 {
 	struct ks2_eth_priv *priv = dev_get_priv(dev);
 	struct eth_pdata *pdata = dev_get_plat(dev);
-	const void *fdt = gd->fdt_blob;
-	int gbe_0 = -ENODEV;
-	int netcp_devices;
-	int gbe;
+	ofnode netcp_devices, gbe, gbe_0;
 
-	netcp_devices = fdt_subnode_offset(fdt, dev_of_offset(dev),
-					   "netcp-devices");
-	gbe = fdt_subnode_offset(fdt, netcp_devices, "gbe");
+	netcp_devices = dev_read_subnode(dev, "netcp-devices");
+	gbe = ofnode_find_subnode(netcp_devices, "gbe");
 
+	gbe_0 = ofnode_null();
 	ks2_eth_bind_slaves(dev, gbe, &gbe_0);
 
-	ks2_eth_parse_slave_interface(dev_of_offset(dev), gbe_0, priv, pdata);
+	ks2_eth_parse_slave_interface(dev_ofnode(dev), gbe_0, priv, pdata);
 
 	pdata->iobase = dev_read_addr(dev);
 
diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
index beca886..d69a9ff 100644
--- a/drivers/net/tsec.c
+++ b/drivers/net/tsec.c
@@ -834,7 +834,6 @@
 	struct ofnode_phandle_args phandle_args;
 	u32 tbiaddr = CONFIG_SYS_TBIPA_VALUE;
 	struct tsec_data *data;
-	const char *phy_mode;
 	ofnode parent, child;
 	fdt_addr_t reg;
 	u32 max_speed;
@@ -894,12 +893,8 @@
 
 	priv->tbiaddr = tbiaddr;
 
-	phy_mode = dev_read_prop(dev, "phy-connection-type", NULL);
-	if (!phy_mode)
-		phy_mode = dev_read_prop(dev, "phy-mode", NULL);
-	if (phy_mode)
-		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
-	if (pdata->phy_interface == -1)
+	pdata->phy_interface = dev_read_phy_mode(dev);
+	if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
 		pdata->phy_interface = tsec_get_interface(priv);
 
 	priv->interface = pdata->phy_interface;
diff --git a/drivers/net/xilinx_axi_emac.c b/drivers/net/xilinx_axi_emac.c
index f21addb..a471573 100644
--- a/drivers/net/xilinx_axi_emac.c
+++ b/drivers/net/xilinx_axi_emac.c
@@ -821,7 +821,6 @@
 	struct eth_pdata *pdata = &plat->eth_pdata;
 	int node = dev_of_offset(dev);
 	int offset = 0;
-	const char *phy_mode;
 
 	pdata->iobase = dev_read_addr(dev);
 	plat->mactype = dev_get_driver_data(dev);
@@ -850,14 +849,9 @@
 			plat->phy_of_handle = offset;
 		}
 
-		phy_mode = fdt_getprop(gd->fdt_blob, node, "phy-mode", NULL);
-		if (phy_mode)
-			pdata->phy_interface = phy_get_interface_by_name(phy_mode);
-		if (pdata->phy_interface == -1) {
-			printf("%s: Invalid PHY interface '%s'\n", __func__,
-			       phy_mode);
+		pdata->phy_interface = dev_read_phy_mode(dev);
+		if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
 			return -EINVAL;
-		}
 
 		plat->eth_hasnobuf = fdtdec_get_bool(gd->fdt_blob, node,
 						     "xlnx,eth-hasnobuf");
diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c
index 4c83ccc..4e8dd4b 100644
--- a/drivers/net/zynq_gem.c
+++ b/drivers/net/zynq_gem.c
@@ -889,7 +889,6 @@
 	struct eth_pdata *pdata = dev_get_plat(dev);
 	struct zynq_gem_priv *priv = dev_get_priv(dev);
 	struct ofnode_phandle_args phandle_args;
-	const char *phy_mode;
 
 	pdata->iobase = (phys_addr_t)dev_read_addr(dev);
 	priv->iobase = (struct zynq_gem_regs *)pdata->iobase;
@@ -923,13 +922,9 @@
 		}
 	}
 
-	phy_mode = dev_read_prop(dev, "phy-mode", NULL);
-	if (phy_mode)
-		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
-	if (pdata->phy_interface == -1) {
-		debug("%s: Invalid PHY interface '%s'\n", __func__, phy_mode);
+	pdata->phy_interface = dev_read_phy_mode(dev);
+	if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
 		return -EINVAL;
-	}
 	priv->interface = pdata->phy_interface;
 
 	priv->int_pcs = dev_read_bool(dev, "is-internal-pcspma");
diff --git a/drivers/power/domain/ti-power-domain.c b/drivers/power/domain/ti-power-domain.c
index a7dadf2..752e76b 100644
--- a/drivers/power/domain/ti-power-domain.c
+++ b/drivers/power/domain/ti-power-domain.c
@@ -16,7 +16,9 @@
 #include <linux/iopoll.h>
 
 #define PSC_PTCMD		0x120
+#define PSC_PTCMD_H		0x124
 #define PSC_PTSTAT		0x128
+#define PSC_PTSTAT_H		0x12C
 #define PSC_PDSTAT		0x200
 #define PSC_PDCTL		0x300
 #define PSC_MDSTAT		0x800
@@ -120,10 +122,17 @@
 static int ti_pd_wait(struct ti_pd *pd)
 {
 	u32 ptstat;
+	u32 pdoffset = 0;
+	u32 ptstatreg = PSC_PTSTAT;
 	int ret;
 
-	ret = readl_poll_timeout(pd->psc->base + PSC_PTSTAT, ptstat,
-				 !(ptstat & BIT(pd->id)), PD_TIMEOUT);
+	if (pd->id > 31) {
+		pdoffset = 32;
+		ptstatreg = PSC_PTSTAT_H;
+	}
+
+	ret = readl_poll_timeout(pd->psc->base + ptstatreg, ptstat,
+				 !(ptstat & BIT(pd->id - pdoffset)), PD_TIMEOUT);
 
 	if (ret)
 		printf("%s: psc%d, pd%d failed to transition.\n", __func__,
@@ -134,7 +143,15 @@
 
 static void ti_pd_transition(struct ti_pd *pd)
 {
-	psc_write(BIT(pd->id), pd->psc, PSC_PTCMD);
+	u32 pdoffset = 0;
+	u32 ptcmdreg = PSC_PTCMD;
+
+	if (pd->id > 31) {
+		pdoffset = 32;
+		ptcmdreg = PSC_PTCMD_H;
+	}
+
+	psc_write(BIT(pd->id - pdoffset), pd->psc, ptcmdreg);
 }
 
 u8 ti_pd_state(struct ti_pd *pd)
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 286c998..dc514c9 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -779,6 +779,7 @@
 config SANDBOX_SERIAL
 	bool "Sandbox UART support"
 	depends on SANDBOX
+	imply SERIAL_PUTS
 	help
 	  Select this to enable a seral UART for sandbox. This is required to
 	  operate correctly, otherwise you will see no serial output from
@@ -833,6 +834,7 @@
 config SEMIHOSTING_SERIAL
 	bool "Semihosting UART support"
 	depends on SEMIHOSTING && !SERIAL_RX_BUFFER
+	imply SERIAL_PUTS
 	help
 	  Select this to enable a serial UART using semihosting. Special halt
 	  instructions will be issued which an external debugger (such as a
diff --git a/drivers/serial/sandbox.c b/drivers/serial/sandbox.c
index 0b1756f..e726e19 100644
--- a/drivers/serial/sandbox.c
+++ b/drivers/serial/sandbox.c
@@ -23,6 +23,19 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+static size_t _sandbox_serial_written = 1;
+static bool sandbox_serial_enabled = true;
+
+size_t sandbox_serial_written(void)
+{
+	return _sandbox_serial_written;
+}
+
+void sandbox_serial_endisable(bool enabled)
+{
+	sandbox_serial_enabled = enabled;
+}
+
 /**
  * output_ansi_colour() - Output an ANSI colour code
  *
@@ -67,7 +80,7 @@
 	return 0;
 }
 
-static int sandbox_serial_putc(struct udevice *dev, const char ch)
+static void sandbox_print_color(struct udevice *dev)
 {
 	struct sandbox_serial_priv *priv = dev_get_priv(dev);
 	struct sandbox_serial_plat *plat = dev_get_plat(dev);
@@ -78,14 +91,44 @@
 		priv->start_of_line = false;
 		output_ansi_colour(plat->colour);
 	}
+}
 
-	os_write(1, &ch, 1);
+static int sandbox_serial_putc(struct udevice *dev, const char ch)
+{
+	struct sandbox_serial_priv *priv = dev_get_priv(dev);
+
 	if (ch == '\n')
 		priv->start_of_line = true;
 
+	if (sandbox_serial_enabled) {
+		sandbox_print_color(dev);
+		os_write(1, &ch, 1);
+	}
+	_sandbox_serial_written += 1;
 	return 0;
 }
 
+static ssize_t sandbox_serial_puts(struct udevice *dev, const char *s,
+				   size_t len)
+{
+	struct sandbox_serial_priv *priv = dev_get_priv(dev);
+	ssize_t ret;
+
+	if (s[len - 1] == '\n')
+		priv->start_of_line = true;
+
+	if (sandbox_serial_enabled) {
+		sandbox_print_color(dev);
+		ret = os_write(1, s, len);
+		if (ret < 0)
+			return ret;
+	} else {
+		ret = len;
+	}
+	_sandbox_serial_written += ret;
+	return ret;
+}
+
 static int sandbox_serial_pending(struct udevice *dev, bool input)
 {
 	struct sandbox_serial_priv *priv = dev_get_priv(dev);
@@ -212,6 +255,7 @@
 
 static const struct dm_serial_ops sandbox_serial_ops = {
 	.putc = sandbox_serial_putc,
+	.puts = sandbox_serial_puts,
 	.pending = sandbox_serial_pending,
 	.getc = sandbox_serial_getc,
 	.getconfig = sandbox_serial_getconfig,
diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index 10d6b80..30650e3 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -198,6 +198,22 @@
 	} while (err == -EAGAIN);
 }
 
+static int __serial_puts(struct udevice *dev, const char *str, size_t len)
+{
+	struct dm_serial_ops *ops = serial_get_ops(dev);
+
+	do {
+		ssize_t written = ops->puts(dev, str, len);
+
+		if (written < 0)
+			return written;
+		str += written;
+		len -= written;
+	} while (len);
+
+	return 0;
+}
+
 static void _serial_puts(struct udevice *dev, const char *str)
 {
 	struct dm_serial_ops *ops = serial_get_ops(dev);
@@ -210,19 +226,15 @@
 
 	do {
 		const char *newline = strchrnul(str, '\n');
-		size_t len = newline - str + !!*newline;
+		size_t len = newline - str;
 
-		do {
-			ssize_t written = ops->puts(dev, str, len);
+		if (__serial_puts(dev, str, len))
+			return;
 
-			if (written < 0)
-				return;
-			str += written;
-			len -= written;
-		} while (len);
+		if (*newline && __serial_puts(dev, "\r\n", 2))
+			return;
 
-		if (*newline)
-			_serial_putc(dev, '\r');
+		str += len + !!*newline;
 	} while (*str);
 }
 
diff --git a/drivers/serial/serial_semihosting.c b/drivers/serial/serial_semihosting.c
index 62b1b22..4328b3d 100644
--- a/drivers/serial/serial_semihosting.c
+++ b/drivers/serial/serial_semihosting.c
@@ -5,12 +5,14 @@
 
 #include <common.h>
 #include <dm.h>
+#include <malloc.h>
 #include <serial.h>
 #include <semihosting.h>
 
 /**
  * struct smh_serial_priv - Semihosting serial private data
  * @infd: stdin file descriptor (or error)
+ * @outfd: stdout file descriptor (or error)
  */
 struct smh_serial_priv {
 	int infd;
@@ -36,8 +38,36 @@
 	return 0;
 }
 
+static ssize_t smh_serial_puts(struct udevice *dev, const char *s, size_t len)
+{
+	int ret;
+	struct smh_serial_priv *priv = dev_get_priv(dev);
+	unsigned long written;
+
+	if (priv->outfd < 0) {
+		char *buf;
+
+		/* Try and avoid a copy if we can */
+		if (!s[len + 1]) {
+			smh_puts(s);
+			return len;
+		}
+
+		buf = strndup(s, len);
+		smh_puts(buf);
+		free(buf);
+		return len;
+	}
+
+	ret = smh_write(priv->outfd, s, len, &written);
+	if (written)
+		return written;
+	return ret;
+}
+
 static const struct dm_serial_ops smh_serial_ops = {
 	.putc = smh_serial_putc,
+	.puts = smh_serial_puts,
 	.getc = smh_serial_getc,
 };
 
@@ -53,6 +83,7 @@
 	struct smh_serial_priv *priv = dev_get_priv(dev);
 
 	priv->infd = smh_open(":tt", MODE_READ);
+	priv->outfd = smh_open(":tt", MODE_WRITE);
 	return 0;
 }
 
diff --git a/fs/fs.c b/fs/fs.c
index c3a2ed9..c67a1c7 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -177,7 +177,7 @@
 };
 
 static struct fstype_info fstypes[] = {
-#ifdef CONFIG_FS_FAT
+#if CONFIG_IS_ENABLED(FS_FAT)
 	{
 		.fstype = FS_TYPE_FAT,
 		.name = "fat",
@@ -267,6 +267,7 @@
 		.ln = fs_ln_unsupported,
 	},
 #endif
+#ifndef CONFIG_SPL_BUILD
 #ifdef CONFIG_CMD_UBIFS
 	{
 		.fstype = FS_TYPE_UBIFS,
@@ -286,6 +287,7 @@
 		.ln = fs_ln_unsupported,
 	},
 #endif
+#endif
 #ifdef CONFIG_FS_BTRFS
 	{
 		.fstype = FS_TYPE_BTRFS,
diff --git a/include/_exports.h b/include/_exports.h
index 8030d70..f6df8b6 100644
--- a/include/_exports.h
+++ b/include/_exports.h
@@ -77,8 +77,7 @@
 	EXPORT_FUNC(mdio_get_current_dev, struct mii_dev *,
 		    mdio_get_current_dev, void)
 	EXPORT_FUNC(phy_find_by_mask, struct phy_device *, phy_find_by_mask,
-		    struct mii_dev *bus, unsigned phy_mask,
-		    phy_interface_t interface)
+		    struct mii_dev *bus, unsigned phy_mask)
 	EXPORT_FUNC(mdio_phydev_for_ethname, struct phy_device *,
 		    mdio_phydev_for_ethname, const char *ethname)
 	EXPORT_FUNC(miiphy_set_current_dev, int, miiphy_set_current_dev,
diff --git a/include/configs/M5253DEMO.h b/include/configs/M5253DEMO.h
index b7fdd71..079675b 100644
--- a/include/configs/M5253DEMO.h
+++ b/include/configs/M5253DEMO.h
@@ -25,7 +25,6 @@
 #	undef CONFIG_LBA48
 #endif
 
-#define CONFIG_DRIVER_DM9000
 #ifdef CONFIG_DRIVER_DM9000
 #	define CONFIG_DM9000_BASE	(CONFIG_SYS_CS1_BASE | 0x300)
 #	define DM9000_IO		CONFIG_DM9000_BASE
diff --git a/include/configs/at91sam9261ek.h b/include/configs/at91sam9261ek.h
index 55ddb38..2089fe5 100644
--- a/include/configs/at91sam9261ek.h
+++ b/include/configs/at91sam9261ek.h
@@ -44,7 +44,6 @@
 #endif
 
 /* Ethernet */
-#define CONFIG_DRIVER_DM9000
 #define CONFIG_DM9000_BASE		0x30000000
 #define DM9000_IO			CONFIG_DM9000_BASE
 #define DM9000_DATA			(CONFIG_DM9000_BASE + 4)
diff --git a/include/configs/ci20.h b/include/configs/ci20.h
index ea9440d..cc70a59 100644
--- a/include/configs/ci20.h
+++ b/include/configs/ci20.h
@@ -24,7 +24,6 @@
 #define CONFIG_SYS_NS16550_CLK		48000000
 
 /* Ethernet: davicom DM9000 */
-#define CONFIG_DRIVER_DM9000		1
 #define CONFIG_DM9000_BASE		0xb6000000
 #define DM9000_IO			CONFIG_DM9000_BASE
 #define DM9000_DATA			(CONFIG_DM9000_BASE + 2)
diff --git a/include/configs/colibri_pxa270.h b/include/configs/colibri_pxa270.h
index a5ba916..809afb7 100644
--- a/include/configs/colibri_pxa270.h
+++ b/include/configs/colibri_pxa270.h
@@ -43,7 +43,6 @@
  */
 #ifdef	CONFIG_CMD_NET
 
-#define	CONFIG_DRIVER_DM9000		1
 #define CONFIG_DM9000_BASE		0x08000000
 #define DM9000_IO			(CONFIG_DM9000_BASE)
 #define DM9000_DATA			(CONFIG_DM9000_BASE + 4)
diff --git a/include/configs/devkit8000.h b/include/configs/devkit8000.h
index 16b3650..5dbd126 100644
--- a/include/configs/devkit8000.h
+++ b/include/configs/devkit8000.h
@@ -35,7 +35,6 @@
 
 /* Hardware drivers */
 /* DM9000 */
-#define	CONFIG_DRIVER_DM9000		1
 #define	CONFIG_DM9000_BASE		0x2c000000
 #define	DM9000_IO			CONFIG_DM9000_BASE
 #define	DM9000_DATA			(CONFIG_DM9000_BASE + 0x400)
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index 6a996d9..2c4d72d 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -12,6 +12,7 @@
 #include <dm/of.h>
 #include <dm/of_access.h>
 #include <log.h>
+#include <phy_interface.h>
 
 /* Enable checks to protect against invalid calls */
 #undef OF_CHECKS
@@ -1217,4 +1218,30 @@
  */
 const char *ofnode_conf_read_str(const char *prop_name);
 
+/**
+ * ofnode_get_phy_node() - Get PHY node for a MAC (if not fixed-link)
+ *
+ * This function parses PHY handle from the Ethernet controller's ofnode
+ * (trying all possible PHY handle property names), and returns the PHY ofnode.
+ *
+ * Before this is used, ofnode_phy_is_fixed_link() should be checked first, and
+ * if the result to that is true, this function should not be called.
+ *
+ * @eth_node:	ofnode belonging to the Ethernet controller
+ * Return: ofnode of the PHY, if it exists, otherwise an invalid ofnode
+ */
+ofnode ofnode_get_phy_node(ofnode eth_node);
+
+/**
+ * ofnode_read_phy_mode() - Read PHY connection type from a MAC node
+ *
+ * This function parses the "phy-mode" / "phy-connection-type" property and
+ * returns the corresponding PHY interface type.
+ *
+ * @mac_node:	ofnode containing the property
+ * Return: one of PHY_INTERFACE_MODE_* constants, PHY_INTERFACE_MODE_NA on
+ *	   error
+ */
+phy_interface_t ofnode_read_phy_mode(ofnode mac_node);
+
 #endif
diff --git a/include/dm/read.h b/include/dm/read.h
index 233af3c..1b54b69 100644
--- a/include/dm/read.h
+++ b/include/dm/read.h
@@ -743,6 +743,32 @@
 int dev_decode_display_timing(const struct udevice *dev, int index,
 			      struct display_timing *config);
 
+/**
+ * dev_get_phy_node() - Get PHY node for a MAC (if not fixed-link)
+ *
+ * This function parses PHY handle from the Ethernet controller's ofnode
+ * (trying all possible PHY handle property names), and returns the PHY ofnode.
+ *
+ * Before this is used, ofnode_phy_is_fixed_link() should be checked first, and
+ * if the result to that is true, this function should not be called.
+ *
+ * @dev: device representing the MAC
+ * Return: ofnode of the PHY, if it exists, otherwise an invalid ofnode
+ */
+ofnode dev_get_phy_node(const struct udevice *dev);
+
+/**
+ * dev_read_phy_mode() - Read PHY connection type from a MAC
+ *
+ * This function parses the "phy-mode" / "phy-connection-type" property and
+ * returns the corresponding PHY interface type.
+ *
+ * @dev: device representing the MAC
+ * Return: one of PHY_INTERFACE_MODE_* constants, PHY_INTERFACE_MODE_NA on
+ *	   error
+ */
+phy_interface_t dev_read_phy_mode(const struct udevice *dev);
+
 #else /* CONFIG_DM_DEV_READ_INLINE is enabled */
 #include <asm/global_data.h>
 
@@ -1092,6 +1118,16 @@
 	return ofnode_decode_display_timing(dev_ofnode(dev), index, config);
 }
 
+static inline ofnode dev_get_phy_node(const struct udevice *dev)
+{
+	return ofnode_get_phy_node(dev_ofnode(dev));
+}
+
+static inline phy_interface_t dev_read_phy_mode(const struct udevice *dev)
+{
+	return ofnode_read_phy_mode(dev_ofnode(dev));
+}
+
 #endif /* CONFIG_DM_DEV_READ_INLINE */
 
 /**
diff --git a/include/dm9000.h b/include/dm9000.h
deleted file mode 100644
index f780e51..0000000
--- a/include/dm9000.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * NOTE:        DAVICOM DM9000 ethernet driver interface
- *
- * Authors:     Remy Bohmer <linux@bohmer.net>
- */
-#ifndef __DM9000_H__
-#define __DM9000_H__
-
-/******************  function prototypes **********************/
-#if !defined(CONFIG_DM9000_NO_SROM)
-void dm9000_write_srom_word(int offset, u16 val);
-void dm9000_read_srom_word(int offset, u8 *to);
-#endif
-
-#endif /* __DM9000_H__ */
diff --git a/include/exports.h b/include/exports.h
index 550cafd..6f8c9cf 100644
--- a/include/exports.h
+++ b/include/exports.h
@@ -55,8 +55,7 @@
 #endif
 #ifdef CONFIG_PHY_AQUANTIA
 struct mii_dev *mdio_get_current_dev(void);
-struct phy_device *phy_find_by_mask(struct mii_dev *bus, unsigned phy_mask,
-		phy_interface_t interface);
+struct phy_device *phy_find_by_mask(struct mii_dev *bus, unsigned phy_mask);
 struct phy_device *mdio_phydev_for_ethname(const char *ethname);
 int miiphy_set_current_dev(const char *devname);
 #endif
diff --git a/include/fm_eth.h b/include/fm_eth.h
index 44da014..bf95706 100644
--- a/include/fm_eth.h
+++ b/include/fm_eth.h
@@ -72,7 +72,7 @@
 #define FM_ETH_INFO_INITIALIZER(idx, pregs) \
 	.fm		= idx,						\
 	.phy_regs	= (void *)pregs,				\
-	.enet_if	= PHY_INTERFACE_MODE_NONE,			\
+	.enet_if	= PHY_INTERFACE_MODE_NA,			\
 
 #ifdef CONFIG_SYS_FMAN_V3
 #define FM_DTSEC_INFO_INITIALIZER(idx, n) \
diff --git a/include/led.h b/include/led.h
index 8eeb5a7..43acca8 100644
--- a/include/led.h
+++ b/include/led.h
@@ -9,24 +9,6 @@
 
 struct udevice;
 
-/**
- * struct led_uc_plat - Platform data the uclass stores about each device
- *
- * @label:	LED label
- */
-struct led_uc_plat {
-	const char *label;
-};
-
-/**
- * struct led_uc_priv - Private data the uclass stores about each device
- *
- * @period_ms:	Flash period in milliseconds
- */
-struct led_uc_priv {
-	int period_ms;
-};
-
 enum led_state_t {
 	LEDST_OFF = 0,
 	LEDST_ON = 1,
@@ -38,6 +20,26 @@
 	LEDST_COUNT,
 };
 
+/**
+ * struct led_uc_plat - Platform data the uclass stores about each device
+ *
+ * @label:	LED label
+ * @default_state:	LED default state
+ */
+struct led_uc_plat {
+	const char *label;
+	enum led_state_t default_state;
+};
+
+/**
+ * struct led_uc_priv - Private data the uclass stores about each device
+ *
+ * @period_ms:	Flash period in milliseconds
+ */
+struct led_uc_priv {
+	int period_ms;
+};
+
 struct led_ops {
 	/**
 	 * set_state() - set the state of an LED
diff --git a/include/miiphy.h b/include/miiphy.h
index 235ae06..110921f 100644
--- a/include/miiphy.h
+++ b/include/miiphy.h
@@ -158,6 +158,37 @@
 void dm_mdio_probe_devices(void);
 
 /**
+ * dm_mdio_read - Wrapper over .read() operation for DM MDIO
+ *
+ * @mdiodev: mdio device
+ * @addr: PHY address on MDIO bus
+ * @devad: device address on PHY if C45; should be MDIO_DEVAD_NONE if C22
+ * @reg: register address
+ * Return: register value if non-negative, -error code otherwise
+ */
+int dm_mdio_read(struct udevice *mdio_dev, int addr, int devad, int reg);
+
+/**
+ * dm_mdio_write - Wrapper over .write() operation for DM MDIO
+ *
+ * @mdiodev: mdio device
+ * @addr: PHY address on MDIO bus
+ * @devad: device address on PHY if C45; should be MDIO_DEVAD_NONE if C22
+ * @reg: register address
+ * @val: value to write
+ * Return: 0 on success, -error code otherwise
+ */
+int dm_mdio_write(struct udevice *mdio_dev, int addr, int devad, int reg, u16 val);
+
+/**
+ * dm_mdio_reset - Wrapper over .reset() operation for DM MDIO
+ *
+ * @mdiodev: mdio device
+ * Return: 0 on success, -error code otherwise
+ */
+int dm_mdio_reset(struct udevice *mdio_dev);
+
+/**
  * dm_mdio_phy_connect - Wrapper over phy_connect for DM MDIO
  *
  * @mdiodev: mdio device the PHY is accesible on
diff --git a/include/phy.h b/include/phy.h
index 528839a..b329595 100644
--- a/include/phy.h
+++ b/include/phy.h
@@ -359,18 +359,6 @@
 
 #ifdef CONFIG_PHYLIB_10G
 extern struct phy_driver gen10g_driver;
-
-/*
- * List all 10G interfaces here, the assumption being that PHYs on these
- * interfaces are C45
- */
-static inline int is_10g_interface(phy_interface_t interface)
-{
-	return interface == PHY_INTERFACE_MODE_XGMII ||
-	       interface == PHY_INTERFACE_MODE_USXGMII ||
-	       interface == PHY_INTERFACE_MODE_10GBASER;
-}
-
 #endif
 
 /**
@@ -400,11 +388,9 @@
  *
  * @bus:	MII/MDIO bus to scan
  * @phy_mask:	bitmap of PYH addresses to scan
- * @interface:	type of MAC-PHY interface
  * @return: pointer to phy_device if a PHY is found, or NULL otherwise
  */
-struct phy_device *phy_find_by_mask(struct mii_dev *bus, unsigned phy_mask,
-		phy_interface_t interface);
+struct phy_device *phy_find_by_mask(struct mii_dev *bus, unsigned phy_mask);
 
 #ifdef CONFIG_PHY_FIXED
 
@@ -433,8 +419,10 @@
  * phy_connect_dev() - Associates the given pair of PHY and Ethernet devices
  * @phydev:	PHY device
  * @dev:	Ethernet device
+ * @interface:	type of MAC-PHY interface
  */
-void phy_connect_dev(struct phy_device *phydev, struct udevice *dev);
+void phy_connect_dev(struct phy_device *phydev, struct udevice *dev,
+		     phy_interface_t interface);
 
 /**
  * phy_connect() - Creates a PHY device for the Ethernet interface
@@ -461,12 +449,10 @@
  * @addr:		PHY address on MDIO bus
  * @phy_id:		where to store the ID retrieved
  * @is_c45:		Device Identifiers if is_c45
- * @interface:		interface between the MAC and PHY
  * @return: pointer to phy_device if a PHY is found, or NULL otherwise
  */
 struct phy_device *phy_device_create(struct mii_dev *bus, int addr,
-				     u32 phy_id, bool is_c45,
-				     phy_interface_t interface);
+				     u32 phy_id, bool is_c45);
 
 /**
  * phy_connect_phy_id() - Connect to phy device by reading PHY id
@@ -474,12 +460,11 @@
  *
  * @bus:		MII/MDIO bus that hosts the PHY
  * @dev:		Ethernet device to associate to the PHY
- * @interface:		Interface between the MAC and PHY
  * @return:		pointer to phy_device if a PHY is found,
  *			or NULL otherwise
  */
 struct phy_device *phy_connect_phy_id(struct mii_dev *bus, struct udevice *dev,
-				      int phyaddr, phy_interface_t interface);
+				      int phyaddr);
 
 static inline ofnode phy_get_ofnode(struct phy_device *phydev)
 {
@@ -494,8 +479,10 @@
  * phy_connect_dev() - Associates the given pair of PHY and Ethernet devices
  * @phydev:	PHY device
  * @dev:	Ethernet device
+ * @interface:	type of MAC-PHY interface
  */
-void phy_connect_dev(struct phy_device *phydev, struct eth_device *dev);
+void phy_connect_dev(struct phy_device *phydev, struct eth_device *dev,
+		     phy_interface_t interface);
 
 /**
  * phy_connect() - Creates a PHY device for the Ethernet interface
@@ -542,6 +529,7 @@
 
 int phy_b53_init(void);
 int phy_mv88e61xx_init(void);
+int phy_adin_init(void);
 int phy_aquantia_init(void);
 int phy_atheros_init(void);
 int phy_broadcom_init(void);
@@ -572,14 +560,6 @@
 int get_phy_id(struct mii_dev *bus, int addr, int devad, u32 *phy_id);
 
 /**
- * phy_get_interface_by_name() - Look up a PHY interface name
- *
- * @str:	PHY interface name, e.g. "mii"
- * @return: PHY_INTERFACE_MODE_... value, or -1 if not found
- */
-int phy_get_interface_by_name(const char *str);
-
-/**
  * phy_interface_is_rgmii - Convenience function for testing if a PHY interface
  * is RGMII (all variants)
  * @phydev: the phy_device struct
diff --git a/include/phy_interface.h b/include/phy_interface.h
index f075abe..ce3b500 100644
--- a/include/phy_interface.h
+++ b/include/phy_interface.h
@@ -13,6 +13,7 @@
 #include <string.h>
 
 typedef enum {
+	PHY_INTERFACE_MODE_NA, /* don't touch */
 	PHY_INTERFACE_MODE_MII,
 	PHY_INTERFACE_MODE_GMII,
 	PHY_INTERFACE_MODE_SGMII,
@@ -39,12 +40,11 @@
 	PHY_INTERFACE_MODE_NCSI,
 	PHY_INTERFACE_MODE_10GBASER,
 	PHY_INTERFACE_MODE_USXGMII,
-	PHY_INTERFACE_MODE_NONE,	/* Must be last */
-
-	PHY_INTERFACE_MODE_COUNT,
+	PHY_INTERFACE_MODE_MAX,
 } phy_interface_t;
 
 static const char * const phy_interface_strings[] = {
+	[PHY_INTERFACE_MODE_NA]		= "",
 	[PHY_INTERFACE_MODE_MII]		= "mii",
 	[PHY_INTERFACE_MODE_GMII]		= "gmii",
 	[PHY_INTERFACE_MODE_SGMII]		= "sgmii",
@@ -71,7 +71,6 @@
 	[PHY_INTERFACE_MODE_NCSI]		= "NC-SI",
 	[PHY_INTERFACE_MODE_10GBASER]		= "10gbase-r",
 	[PHY_INTERFACE_MODE_USXGMII]		= "usxgmii",
-	[PHY_INTERFACE_MODE_NONE]		= "",
 };
 
 /* Backplane modes:
@@ -86,8 +85,8 @@
 static inline const char *phy_string_for_interface(phy_interface_t i)
 {
 	/* Default to unknown */
-	if (i > PHY_INTERFACE_MODE_NONE)
-		i = PHY_INTERFACE_MODE_NONE;
+	if (i > PHY_INTERFACE_MODE_NA)
+		i = PHY_INTERFACE_MODE_NA;
 
 	return phy_interface_strings[i];
 }
diff --git a/include/tables_csum.h b/include/tables_csum.h
index 5f7edc4..4812333 100644
--- a/include/tables_csum.h
+++ b/include/tables_csum.h
@@ -6,16 +6,17 @@
 #ifndef _TABLES_CSUM_H_
 #define _TABLES_CSUM_H_
 
-static inline u8 table_compute_checksum(void *v, int len)
-{
-	u8 *bytes = v;
-	u8 checksum = 0;
-	int i;
-
-	for (i = 0; i < len; i++)
-		checksum -= bytes[i];
-
-	return checksum;
-}
+/**
+ * table_compute_checksum() - Compute a table checksum
+ *
+ * This computes an 8-bit checksum for the configuration table.
+ * All bytes in the configuration table, including checksum itself and
+ * reserved bytes must add up to zero.
+ *
+ * @v:		configuration table base address
+ * @len:	configuration table size
+ * @return:	the 8-bit checksum
+ */
+u8 table_compute_checksum(void *v, int len);
 
 #endif
diff --git a/include/vsc9953.h b/include/vsc9953.h
index a9c84b4..fd52c93 100644
--- a/include/vsc9953.h
+++ b/include/vsc9953.h
@@ -691,7 +691,7 @@
 	.phyaddr	= 0,						\
 	.index		= idx,						\
 	.phy_regs	= NULL,						\
-	.enet_if	= PHY_INTERFACE_MODE_NONE,			\
+	.enet_if	= PHY_INTERFACE_MODE_NA,			\
 	.bus		= NULL,						\
 	.phydev		= NULL,						\
 }
diff --git a/net/mdio-mux-uclass.c b/net/mdio-mux-uclass.c
index 780526c..94b90e0 100644
--- a/net/mdio-mux-uclass.c
+++ b/net/mdio-mux-uclass.c
@@ -54,11 +54,6 @@
 	return pdata->mdio_parent;
 }
 
-static struct mdio_ops *mmux_get_mdio_parent_ops(struct udevice *mux)
-{
-	return mdio_get_ops(mmux_get_parent_mdio(mux));
-}
-
 /* call driver select function before performing MDIO r/w */
 static int mmux_change_sel(struct udevice *ch, bool sel)
 {
@@ -90,14 +85,13 @@
 {
 	struct udevice *mux = ch->parent;
 	struct udevice *parent_mdio = mmux_get_parent_mdio(mux);
-	struct mdio_ops *parent_ops = mmux_get_mdio_parent_ops(mux);
 	int err;
 
 	err = mmux_change_sel(ch, true);
 	if (err)
 		return err;
 
-	err = parent_ops->read(parent_mdio, addr, devad, reg);
+	err = dm_mdio_read(parent_mdio, addr, devad, reg);
 	mmux_change_sel(ch, false);
 
 	return err;
@@ -109,14 +103,13 @@
 {
 	struct udevice *mux = ch->parent;
 	struct udevice *parent_mdio = mmux_get_parent_mdio(mux);
-	struct mdio_ops *parent_ops = mmux_get_mdio_parent_ops(mux);
 	int err;
 
 	err = mmux_change_sel(ch, true);
 	if (err)
 		return err;
 
-	err = parent_ops->write(parent_mdio, addr, devad, reg, val);
+	err = dm_mdio_write(parent_mdio, addr, devad, reg, val);
 	mmux_change_sel(ch, false);
 
 	return err;
@@ -127,18 +120,17 @@
 {
 	struct udevice *mux = ch->parent;
 	struct udevice *parent_mdio = mmux_get_parent_mdio(mux);
-	struct mdio_ops *parent_ops = mmux_get_mdio_parent_ops(mux);
 	int err;
 
 	/* reset is optional, if it's not implemented just exit */
-	if (!parent_ops->reset)
+	if (!mdio_get_ops(parent_mdio)->reset)
 		return 0;
 
 	err = mmux_change_sel(ch, true);
 	if (err)
 		return err;
 
-	err = parent_ops->reset(parent_mdio);
+	err = dm_mdio_reset(parent_mdio);
 	mmux_change_sel(ch, false);
 
 	return err;
diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c
index e74e34f..7593618 100644
--- a/net/mdio-uclass.c
+++ b/net/mdio-uclass.c
@@ -15,16 +15,6 @@
 #include <dm/uclass-internal.h>
 #include <linux/compat.h>
 
-/* DT node properties for MAC-PHY interface */
-#define PHY_MODE_STR_CNT	2
-static const char *phy_mode_str[PHY_MODE_STR_CNT] = { "phy-mode",
-						      "phy-connection-type" };
-/* DT node properties that reference a PHY node */
-#define PHY_HANDLE_STR_CNT	3
-const char *phy_handle_str[PHY_HANDLE_STR_CNT] = { "phy-handle",
-						   "phy",
-						   "phy-device" };
-
 void dm_mdio_probe_devices(void)
 {
 	struct udevice *it;
@@ -62,6 +52,37 @@
 	return 0;
 }
 
+int dm_mdio_read(struct udevice *mdio_dev, int addr, int devad, int reg)
+{
+	struct mdio_ops *ops = mdio_get_ops(mdio_dev);
+
+	if (!ops->read)
+		return -ENOSYS;
+
+	return ops->read(mdio_dev, addr, devad, reg);
+}
+
+int dm_mdio_write(struct udevice *mdio_dev, int addr, int devad, int reg,
+		  u16 val)
+{
+	struct mdio_ops *ops = mdio_get_ops(mdio_dev);
+
+	if (!ops->write)
+		return -ENOSYS;
+
+	return ops->write(mdio_dev, addr, devad, reg, val);
+}
+
+int dm_mdio_reset(struct udevice *mdio_dev)
+{
+	struct mdio_ops *ops = mdio_get_ops(mdio_dev);
+
+	if (!ops->reset)
+		return 0;
+
+	return ops->reset(mdio_dev);
+}
+
 /*
  * Following read/write/reset functions are registered with legacy MII code.
  * These are called for PHY operations by upper layers and we further call the
@@ -69,27 +90,18 @@
  */
 static int mdio_read(struct mii_dev *mii_bus, int addr, int devad, int reg)
 {
-	struct udevice *dev = mii_bus->priv;
-
-	return mdio_get_ops(dev)->read(dev, addr, devad, reg);
+	return dm_mdio_read(mii_bus->priv, addr, devad, reg);
 }
 
 static int mdio_write(struct mii_dev *mii_bus, int addr, int devad, int reg,
 		      u16 val)
 {
-	struct udevice *dev = mii_bus->priv;
-
-	return mdio_get_ops(dev)->write(dev, addr, devad, reg, val);
+	return dm_mdio_write(mii_bus->priv, addr, devad, reg, val);
 }
 
 static int mdio_reset(struct mii_dev *mii_bus)
 {
-	struct udevice *dev = mii_bus->priv;
-
-	if (mdio_get_ops(dev)->reset)
-		return mdio_get_ops(dev)->reset(dev);
-	else
-		return 0;
+	return dm_mdio_reset(mii_bus->priv);
 }
 
 static int dm_mdio_post_probe(struct udevice *dev)
@@ -109,10 +121,8 @@
 static int dm_mdio_pre_remove(struct udevice *dev)
 {
 	struct mdio_perdev_priv *pdata = dev_get_uclass_priv(dev);
-	struct mdio_ops *ops = mdio_get_ops(dev);
 
-	if (ops->reset)
-		ops->reset(dev);
+	dm_mdio_reset(dev);
 	mdio_unregister(pdata->mii_bus);
 	mdio_free(pdata->mii_bus);
 
@@ -137,23 +147,16 @@
 	u32 phy_addr;
 	struct udevice *mdiodev;
 	struct phy_device *phy;
-	struct ofnode_phandle_args phandle = {.node = ofnode_null()};
 	ofnode phynode;
-	int i;
 
 	if (CONFIG_IS_ENABLED(PHY_FIXED) &&
 	    ofnode_phy_is_fixed_link(dev_ofnode(ethdev), &phynode)) {
 		phy = phy_connect(NULL, 0, ethdev, interface);
-		phandle.node = phynode;
 		goto out;
 	}
 
-	for (i = 0; i < PHY_HANDLE_STR_CNT; i++)
-		if (!dev_read_phandle_with_args(ethdev, phy_handle_str[i], NULL,
-						0, 0, &phandle))
-			break;
-
-	if (!ofnode_valid(phandle.node)) {
+	phynode = dev_get_phy_node(ethdev);
+	if (!ofnode_valid(phynode)) {
 		dev_dbg(ethdev, "can't find PHY node\n");
 		return NULL;
 	}
@@ -162,16 +165,16 @@
 	 * reading 'reg' directly should be fine.  This is a PHY node, the
 	 * address is always size 1 and requires no translation
 	 */
-	if (ofnode_read_u32(phandle.node, "reg", &phy_addr)) {
+	if (ofnode_read_u32(phynode, "reg", &phy_addr)) {
 		dev_dbg(ethdev, "missing reg property in phy node\n");
 		return NULL;
 	}
 
 	if (uclass_get_device_by_ofnode(UCLASS_MDIO,
-					ofnode_get_parent(phandle.node),
+					ofnode_get_parent(phynode),
 					&mdiodev)) {
 		dev_dbg(ethdev, "can't find MDIO bus for node %s\n",
-			ofnode_get_name(ofnode_get_parent(phandle.node)));
+			ofnode_get_name(ofnode_get_parent(phynode)));
 		return NULL;
 	}
 
@@ -179,7 +182,7 @@
 
 out:
 	if (phy)
-		phy->node = phandle.node;
+		phy->node = phynode;
 
 	return phy;
 }
@@ -187,28 +190,17 @@
 /* Connect to a PHY linked in eth DT node */
 struct phy_device *dm_eth_phy_connect(struct udevice *ethdev)
 {
-	const char *if_str;
 	phy_interface_t interface;
 	struct phy_device *phy;
-	int i;
 
 	if (!dev_has_ofnode(ethdev)) {
 		debug("%s: supplied eth dev has no DT node!\n", ethdev->name);
 		return NULL;
 	}
 
-	interface = PHY_INTERFACE_MODE_NONE;
-	for (i = 0; i < PHY_MODE_STR_CNT; i++) {
-		if_str = dev_read_string(ethdev, phy_mode_str[i]);
-		if (if_str) {
-			interface = phy_get_interface_by_name(if_str);
-			break;
-		}
-	}
-	if (interface < 0)
-		interface = PHY_INTERFACE_MODE_NONE;
-	if (interface == PHY_INTERFACE_MODE_NONE)
-		dev_dbg(ethdev, "can't find interface mode, default to NONE\n");
+	interface = dev_read_phy_mode(ethdev);
+	if (interface == PHY_INTERFACE_MODE_NA)
+		dev_dbg(ethdev, "can't find interface mode, default to NA\n");
 
 	phy = dm_eth_connect_phy_handle(ethdev, interface);
 
diff --git a/net/tftp.c b/net/tftp.c
index e1e3597..bfc4c9b 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -906,6 +906,8 @@
 	tftp_block_size = TFTP_BLOCK_SIZE;
 	tftp_cur_block = 0;
 	tftp_our_port = WELL_KNOWN_PORT;
+	tftp_windowsize = 1;
+	tftp_next_ack = tftp_windowsize;
 
 #ifdef CONFIG_TFTP_TSIZE
 	tftp_tsize = 0;
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index ef7dbbf..df70ae2 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -25,7 +25,6 @@
 CONFIG_DM9000_NO_SROM
 CONFIG_DM9000_USE_16BIT
 CONFIG_DP_DDR_DIMM_SLOTS_PER_CTLR
-CONFIG_DRIVER_DM9000
 CONFIG_DSP_CLUSTER_START
 CONFIG_DWC_AHSATA_BASE_ADDR
 CONFIG_DWC_AHSATA_PORT_ID
diff --git a/test/cmd/pinmux.c b/test/cmd/pinmux.c
index ba338b8..de3bb0d 100644
--- a/test/cmd/pinmux.c
+++ b/test/cmd/pinmux.c
@@ -16,7 +16,7 @@
 	/* Test that 'pinmux status <pinname>' displays the selected pin. */
 	console_record_reset();
 	run_command("pinmux status a5", 0);
-	ut_assert_nextlinen("a5        : gpio input .");
+	ut_assert_nextlinen("a5        : gpio output .");
 	ut_assert_console_end();
 
 	console_record_reset();
diff --git a/test/dm/mdio.c b/test/dm/mdio.c
index 64347e1..f863c52 100644
--- a/test/dm/mdio.c
+++ b/test/dm/mdio.c
@@ -38,18 +38,18 @@
 	ut_assertnonnull(ops->read);
 	ut_assertnonnull(ops->write);
 
-	ut_assertok(ops->write(dev, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
-			       SANDBOX_PHY_REG, TEST_REG_VALUE));
-	reg = ops->read(dev, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
-			SANDBOX_PHY_REG);
+	ut_assertok(dm_mdio_write(dev, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
+				  SANDBOX_PHY_REG, TEST_REG_VALUE));
+	reg = dm_mdio_read(dev, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
+			   SANDBOX_PHY_REG);
 	ut_asserteq(reg, TEST_REG_VALUE);
 
-	ut_assert(ops->read(dev, SANDBOX_PHY_ADDR + 1, MDIO_DEVAD_NONE,
-			    SANDBOX_PHY_REG) != 0);
+	ut_assert(dm_mdio_read(dev, SANDBOX_PHY_ADDR + 1, MDIO_DEVAD_NONE,
+			       SANDBOX_PHY_REG) != 0);
 
-	ut_assertok(ops->reset(dev));
-	reg = ops->read(dev, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
-			SANDBOX_PHY_REG);
+	ut_assertok(dm_mdio_reset(dev));
+	reg = dm_mdio_read(dev, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
+			   SANDBOX_PHY_REG);
 	ut_asserteq(reg, 0);
 
 	return 0;
diff --git a/test/dm/mdio_mux.c b/test/dm/mdio_mux.c
index 950f385..bfe3518 100644
--- a/test/dm/mdio_mux.c
+++ b/test/dm/mdio_mux.c
@@ -57,22 +57,22 @@
 	 * is selected to the selection #.  Just reading that register from
 	 * either of the child buses should return the id of the child bus
 	 */
-	reg = ops->read(mdio_ch0, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
-			SANDBOX_PHY_REG_CNT - 1);
+	reg = dm_mdio_read(mdio_ch0, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
+			   SANDBOX_PHY_REG_CNT - 1);
 	ut_asserteq(reg, 0);
 
-	reg = ops->read(mdio_ch1, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
-			SANDBOX_PHY_REG_CNT - 1);
+	reg = dm_mdio_read(mdio_ch1, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
+			   SANDBOX_PHY_REG_CNT - 1);
 	ut_asserteq(reg, 1);
 
 	mmops->select(mux, MDIO_MUX_SELECT_NONE, 5);
-	reg = ops_parent->read(mdio, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
-			SANDBOX_PHY_REG_CNT - 1);
+	reg = dm_mdio_read(mdio, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
+			   SANDBOX_PHY_REG_CNT - 1);
 	ut_asserteq(reg, 5);
 
 	mmops->deselect(mux, 5);
-	reg = ops_parent->read(mdio, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
-			SANDBOX_PHY_REG_CNT - 1);
+	reg = dm_mdio_read(mdio, SANDBOX_PHY_ADDR, MDIO_DEVAD_NONE,
+			   SANDBOX_PHY_REG_CNT - 1);
 	ut_asserteq(reg, (u16)MDIO_MUX_SELECT_NONE);
 
 	return 0;
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index dab0480..61ae1db 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -447,3 +447,25 @@
 	return 0;
 }
 DM_TEST(dm_test_ofnode_string_err, UT_TESTF_LIVE_TREE);
+
+static int dm_test_ofnode_get_phy(struct unit_test_state *uts)
+{
+	ofnode eth_node, phy_node;
+	phy_interface_t mode;
+	u32 reg;
+
+	eth_node = ofnode_path("/phy-test-eth");
+	ut_assert(ofnode_valid(eth_node));
+
+	mode = ofnode_read_phy_mode(eth_node);
+	ut_assert(mode == PHY_INTERFACE_MODE_2500BASEX);
+
+	phy_node = ofnode_get_phy_node(eth_node);
+	ut_assert(ofnode_valid(phy_node));
+
+	reg = ofnode_read_u32_default(phy_node, "reg", -1U);
+	ut_asserteq_64(0x1, reg);
+
+	return 0;
+}
+DM_TEST(dm_test_ofnode_get_phy, 0);
diff --git a/test/dm/serial.c b/test/dm/serial.c
index 0662b5f..37d17a6 100644
--- a/test/dm/serial.c
+++ b/test/dm/serial.c
@@ -7,14 +7,22 @@
 #include <log.h>
 #include <serial.h>
 #include <dm.h>
+#include <asm/serial.h>
 #include <dm/test.h>
 #include <test/test.h>
 #include <test/ut.h>
 
+static const char test_message[] =
+	"This is a test message\n"
+	"consisting of multiple lines\n";
+
 static int dm_test_serial(struct unit_test_state *uts)
 {
+	int i;
 	struct serial_device_info info_serial = {0};
 	struct udevice *dev_serial;
+	size_t start, putc_written;
+
 	uint value_serial;
 
 	ut_assertok(uclass_get_device_by_name(UCLASS_SERIAL, "serial",
@@ -66,6 +74,17 @@
 						   SERIAL_8_BITS,
 						   SERIAL_TWO_STOP)));
 
+	/* Verify that putc and puts print the same number of characters */
+	sandbox_serial_endisable(false);
+	start = sandbox_serial_written();
+	for (i = 0; i < sizeof(test_message) - 1; i++)
+		serial_putc(test_message[i]);
+	putc_written = sandbox_serial_written();
+	serial_puts(test_message);
+	sandbox_serial_endisable(true);
+	ut_asserteq(putc_written - start,
+		    sandbox_serial_written() - putc_written);
+
 	return 0;
 }