Index: rtemsbsd/powerpc/include/linux/phy.h
===================================================================
--- rtemsbsd/powerpc/include/linux/phy.h	(revision 66e83e0e64d13376ff8b99c6b7a9f72de5f441ac)
+++ rtemsbsd/powerpc/include/linux/phy.h	(revision 9da83e7886d9374aca023717d9f87643ce87c2d5)
@@ -81,7 +81,9 @@
 #define	SUPPORTED_Pause			(1U << 9)
 
+#define MII_ADDR_C45 (1 << 30)
+
 struct mdio_bus {
-	int (*read)(struct mdio_bus *bus, int phy, int reg);
-	int (*write)(struct mdio_bus *bus, int phy, int reg, int val);
+	int (*read)(struct mdio_bus *bus, int addr, int reg);
+	int (*write)(struct mdio_bus *bus, int addr, int reg, int val);
 	SLIST_ENTRY(mdio_bus) next;
 	int node;
@@ -92,25 +94,12 @@
 		struct device dev;
 		int addr;
+		int is_c45;
 		struct mdio_bus *bus;
 	} mdio;
 };
 
-static inline int
-phy_read(struct phy_device *phy_dev, int reg)
-{
-	struct mdio_bus *mdio_dev;
+int phy_read(struct phy_device *phy_dev, int reg);
 
-	mdio_dev = phy_dev->mdio.bus;
-	return ((*mdio_dev->read)(mdio_dev, phy_dev->mdio.addr, (int)reg));
-}
-
-static inline int
-phy_write(struct phy_device *phy_dev, int reg, int val)
-{
-	struct mdio_bus *mdio_dev;
-
-	mdio_dev = phy_dev->mdio.bus;
-	return ((*mdio_dev->write)(mdio_dev, phy_dev->mdio.addr, reg, val));
-}
+int phy_write(struct phy_device *phy_dev, int reg, int val);
 
 #ifdef __cplusplus
Index: rtemsbsd/sys/powerpc/fdt_phy.c
===================================================================
--- rtemsbsd/sys/powerpc/fdt_phy.c	(revision 66e83e0e64d13376ff8b99c6b7a9f72de5f441ac)
+++ rtemsbsd/sys/powerpc/fdt_phy.c	(revision 9da83e7886d9374aca023717d9f87643ce87c2d5)
@@ -56,5 +56,33 @@
 };
 
-MTX_SYSINIT(mdio_mutex, &mdio.mutex, "FDT MDIO", MTX_DEF);
+MTX_SYSINIT(mdio_mutex, &mdio.mutex, "MDIO", MTX_DEF);
+
+int
+phy_read(struct phy_device *phy_dev, int reg)
+{
+	struct mdio_bus *mdio_dev;
+	int val;
+
+	mdio_dev = phy_dev->mdio.bus;
+	MDIO_LOCK();
+	val = (*mdio_dev->read)(mdio_dev, phy_dev->mdio.addr,
+	    reg | phy_dev->mdio.is_c45);
+	MDIO_UNLOCK();
+	return (val);
+}
+
+int
+phy_write(struct phy_device *phy_dev, int reg, int val)
+{
+	struct mdio_bus *mdio_dev;
+	int err;
+
+	mdio_dev = phy_dev->mdio.bus;
+	MDIO_LOCK();
+	err = (*mdio_dev->write)(mdio_dev, phy_dev->mdio.addr,
+	    reg | phy_dev->mdio.is_c45, val);
+	MDIO_UNLOCK();
+	return (err);
+}
 
 static uint64_t
@@ -158,8 +186,48 @@
 
 static int
-fman_mdio_read(struct mdio_bus *base, int phy, int reg)
+fman_mdio_setup(volatile struct fman_mdio_regs *regs, int addr, int reg,
+    uint32_t *mdio_ctrl_p)
+{
+	uint32_t mdio_cfg;
+	uint32_t mdio_ctrl;
+	uint32_t reg_addr;
+	int err;
+
+	err = fman_mdio_wait(regs);
+	if (err != 0) {
+		return (err);
+	}
+
+	mdio_cfg = regs->mdio_cfg;
+	if ((reg & MII_ADDR_C45) != 0) {
+		reg_addr = (uint32_t)(reg >> 16);
+		mdio_cfg |= MDIO_CFG_ENC45;
+	} else {
+		reg_addr = (uint32_t)reg;
+		mdio_cfg &= ~MDIO_CFG_ENC45;
+	}
+	regs->mdio_cfg = mdio_cfg;
+
+	mdio_ctrl = MDIO_CTRL_PHY_ADDR(addr) | MDIO_CTRL_REG_ADDR(reg_addr);
+	regs->mdio_ctrl = mdio_ctrl;
+
+	if ((reg & MII_ADDR_C45) != 0) {
+		regs->mdio_addr = (uint32_t)(reg & 0xffff);
+		err = fman_mdio_wait(regs);
+		if (err != 0) {
+			return (err);
+		}
+	}
+
+	*mdio_ctrl_p = mdio_ctrl;
+	return (0);
+}
+
+static int
+fman_mdio_read(struct mdio_bus *base, int addr, int reg)
 {
 	struct fman_mdio_bus *fm;
 	volatile struct fman_mdio_regs *regs;
+	uint32_t mdio_ctrl;
 	int val;
 	int err;
@@ -168,31 +236,18 @@
 	regs = fm->regs;
 
-	MDIO_LOCK();
+	err = fman_mdio_setup(regs, addr, reg, &mdio_ctrl);
+	if (err != 0) {
+		return (-1);
+	}
+
+	mdio_ctrl |= MDIO_CTRL_READ;
+	regs->mdio_ctrl = mdio_ctrl;
 
 	err = fman_mdio_wait(regs);
-	if (err == 0) {
-		uint32_t mdio_cfg;
-		uint32_t mdio_ctrl;
-
-		mdio_cfg = regs->mdio_cfg;
-		mdio_cfg &= ~MDIO_CFG_ENC45;
-		regs->mdio_cfg = mdio_cfg;
-
-		mdio_ctrl = MDIO_CTRL_PHY_ADDR(phy) | MDIO_CTRL_REG_ADDR(reg);
-		regs->mdio_ctrl = mdio_ctrl;
-		mdio_ctrl |= MDIO_CTRL_READ;
-		regs->mdio_ctrl = mdio_ctrl;
-
-		err = fman_mdio_wait(regs);
-		if (err == 0 && (regs->mdio_cfg & MDIO_CFG_RD_ERR) == 0) {
-			val = (int)(regs->mdio_data & 0xffff);
-		} else {
-			val = 0xffff;
-		}
+	if (err == 0 && (regs->mdio_cfg & MDIO_CFG_RD_ERR) == 0) {
+		val = (int)(regs->mdio_data & 0xffff);
 	} else {
-		val = 0xffff;
-	}
-
-	MDIO_UNLOCK();
+		val = -1;
+	}
 
 	return (val);
@@ -200,8 +255,9 @@
 
 static int
-fman_mdio_write(struct mdio_bus *base, int phy, int reg, int val)
+fman_mdio_write(struct mdio_bus *base, int addr, int reg, int val)
 {
 	struct fman_mdio_bus *fm;
 	volatile struct fman_mdio_regs *regs;
+	uint32_t mdio_ctrl;
 	int err;
 
@@ -209,25 +265,11 @@
 	regs = fm->regs;
 
-	MDIO_LOCK();
-
-	err = fman_mdio_wait(regs);
-	if (err == 0) {
-		uint32_t mdio_cfg;
-		uint32_t mdio_ctrl;
-
-		mdio_cfg = regs->mdio_cfg;
-		mdio_cfg &= ~MDIO_CFG_ENC45;
-		regs->mdio_cfg = mdio_cfg;
-
-		mdio_ctrl = MDIO_CTRL_PHY_ADDR(phy) | MDIO_CTRL_REG_ADDR(reg);
-		regs->mdio_ctrl = mdio_ctrl;
-
-		regs->mdio_data = (uint32_t)(val & 0xffff);
-
-		fman_mdio_wait(regs);
-	}
-
-	MDIO_UNLOCK();
-
+	err = fman_mdio_setup(regs, addr, reg, &mdio_ctrl);
+	if (err != 0) {
+		return (0);
+	}
+
+	regs->mdio_data = (uint32_t)(val & 0xffff);
+	fman_mdio_wait(regs);
 	return (0);
 }
@@ -291,5 +333,5 @@
 
 static struct phy_device *
-phy_obtain(const void *fdt, int mdio_node, int phy)
+phy_obtain(const void *fdt, int is_c45, int mdio_node, int addr)
 {
 	struct phy_device *phy_dev;
@@ -301,5 +343,6 @@
 	}
 
-	phy_dev->mdio.addr = phy;
+	phy_dev->mdio.addr = addr;
+	phy_dev->mdio.is_c45 = is_c45;
 	MDIO_LOCK();
 	err = find_mdio_bus(fdt, mdio_node, phy_dev);
@@ -318,13 +361,20 @@
 {
 	const void *fdt;
-	const fdt32_t *phy;
+	const fdt32_t *addr;
 	int len;
+	int is_c45;
 	int mdio_node;
 
 	fdt = bsp_fdt_get();
 
-	phy = fdt_getprop(fdt, dn->offset, "reg", &len);
-	if (phy == NULL || len != sizeof(*phy)) {
-		return (NULL);
+	addr = fdt_getprop(fdt, dn->offset, "reg", &len);
+	if (addr == NULL || len != sizeof(*addr)) {
+		return (NULL);
+	}
+
+	if (of_device_is_compatible(dn, "ethernet-phy-ieee802.3-c45")) {
+		is_c45 = MII_ADDR_C45;
+	} else {
+		is_c45 = 0;
 	}
 
@@ -334,4 +384,4 @@
 	}
 
-	return (phy_obtain(fdt, mdio_node, (int)fdt32_to_cpu(*phy)));
-}
+	return (phy_obtain(fdt, is_c45, mdio_node, (int)fdt32_to_cpu(*addr)));
+}
