mirror of
https://github.com/hanwckf/immortalwrt-mt798x.git
synced 2025-01-10 11:09:57 +08:00
73 lines
2.1 KiB
Diff
73 lines
2.1 KiB
Diff
diff --git a/include/linux/mdio.h b/include/linux/mdio.h
|
|
index 0f1f784de..006d1c1e9 100644
|
|
--- a/include/linux/mdio.h
|
|
+++ b/include/linux/mdio.h
|
|
@@ -7,8 +7,17 @@
|
|
#define __LINUX_MDIO_H__
|
|
|
|
#include <uapi/linux/mdio.h>
|
|
+#include <linux/bitfield.h>
|
|
#include <linux/mod_devicetable.h>
|
|
|
|
+/* Or MII_ADDR_C45 into regnum for read/write on mii_bus to enable the 21 bit
|
|
+ * IEEE 802.3ae clause 45 addressing mode used by 10GIGE phy chips.
|
|
+ */
|
|
+#define MII_ADDR_C45 (1<<30)
|
|
+#define MII_DEVADDR_C45_SHIFT 16
|
|
+#define MII_DEVADDR_C45_MASK GENMASK(20, 16)
|
|
+#define MII_REGADDR_C45_MASK GENMASK(15, 0)
|
|
+
|
|
struct gpio_desc;
|
|
struct mii_bus;
|
|
|
|
@@ -325,6 +334,46 @@ int mdiobus_read_nested(struct mii_bus *bus, int addr, u32 regnum);
|
|
int mdiobus_write(struct mii_bus *bus, int addr, u32 regnum, u16 val);
|
|
int mdiobus_write_nested(struct mii_bus *bus, int addr, u32 regnum, u16 val);
|
|
|
|
+static inline u32 mdiobus_c45_addr(int devad, u16 regnum)
|
|
+{
|
|
+ return MII_ADDR_C45 | devad << MII_DEVADDR_C45_SHIFT | regnum;
|
|
+}
|
|
+
|
|
+static inline u16 mdiobus_c45_regad(u32 regnum)
|
|
+{
|
|
+ return FIELD_GET(MII_REGADDR_C45_MASK, regnum);
|
|
+}
|
|
+
|
|
+static inline u16 mdiobus_c45_devad(u32 regnum)
|
|
+{
|
|
+ return FIELD_GET(MII_DEVADDR_C45_MASK, regnum);
|
|
+}
|
|
+
|
|
+static inline int __mdiobus_c45_read(struct mii_bus *bus, int prtad, int devad,
|
|
+ u16 regnum)
|
|
+{
|
|
+ return __mdiobus_read(bus, prtad, mdiobus_c45_addr(devad, regnum));
|
|
+}
|
|
+
|
|
+static inline int __mdiobus_c45_write(struct mii_bus *bus, int prtad, int devad,
|
|
+ u16 regnum, u16 val)
|
|
+{
|
|
+ return __mdiobus_write(bus, prtad, mdiobus_c45_addr(devad, regnum),
|
|
+ val);
|
|
+}
|
|
+
|
|
+static inline int mdiobus_c45_read(struct mii_bus *bus, int prtad, int devad,
|
|
+ u16 regnum)
|
|
+{
|
|
+ return mdiobus_read(bus, prtad, mdiobus_c45_addr(devad, regnum));
|
|
+}
|
|
+
|
|
+static inline int mdiobus_c45_write(struct mii_bus *bus, int prtad, int devad,
|
|
+ u16 regnum, u16 val)
|
|
+{
|
|
+ return mdiobus_write(bus, prtad, mdiobus_c45_addr(devad, regnum), val);
|
|
+}
|
|
+
|
|
int mdiobus_register_device(struct mdio_device *mdiodev);
|
|
int mdiobus_unregister_device(struct mdio_device *mdiodev);
|
|
bool mdiobus_is_registered_device(struct mii_bus *bus, int addr);
|
|
--
|
|
2.18.0
|
|
|