summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPotin Lai <potin.lai@quantatw.com>2022-04-07 09:17:37 +0800
committerDavid S. Miller <davem@davemloft.net>2022-04-08 12:20:52 +0100
commiteb0571932314e6f4f0cb4e05c590fe78c01acbd7 (patch)
tree881c8c1a1d7f29299499e78ffd5cf0a8f105caa3
parent737ca352569e744bf753b4522a6f91b120a734f1 (diff)
downloadlinux-eb0571932314e6f4f0cb4e05c590fe78c01acbd7.tar.gz
linux-eb0571932314e6f4f0cb4e05c590fe78c01acbd7.tar.bz2
linux-eb0571932314e6f4f0cb4e05c590fe78c01acbd7.zip
net: mdio: aspeed: Introduce read write function for c22 and c45
Add following additional functions to move out the implementation from aspeed_mdio_read() and aspeed_mdio_write(). c22: - aspeed_mdio_read_c22() - aspeed_mdio_write_c22() c45: - aspeed_mdio_read_c45() - aspeed_mdio_write_c45() Signed-off-by: Potin Lai <potin.lai@quantatw.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/mdio/mdio-aspeed.c46
1 files changed, 34 insertions, 12 deletions
diff --git a/drivers/net/mdio/mdio-aspeed.c b/drivers/net/mdio/mdio-aspeed.c
index f22be2f069e9..5becddb56117 100644
--- a/drivers/net/mdio/mdio-aspeed.c
+++ b/drivers/net/mdio/mdio-aspeed.c
@@ -79,17 +79,10 @@ static int aspeed_mdio_get_data(struct mii_bus *bus)
return FIELD_GET(ASPEED_MDIO_DATA_MIIRDATA, data);
}
-static int aspeed_mdio_read(struct mii_bus *bus, int addr, int regnum)
+static int aspeed_mdio_read_c22(struct mii_bus *bus, int addr, int regnum)
{
int rc;
- dev_dbg(&bus->dev, "%s: addr: %d, regnum: %d\n", __func__, addr,
- regnum);
-
- /* Just clause 22 for the moment */
- if (regnum & MII_ADDR_C45)
- return -EOPNOTSUPP;
-
rc = aspeed_mdio_op(bus, ASPEED_MDIO_CTRL_ST_C22, MDIO_C22_OP_READ,
addr, regnum, 0);
if (rc < 0)
@@ -98,17 +91,46 @@ static int aspeed_mdio_read(struct mii_bus *bus, int addr, int regnum)
return aspeed_mdio_get_data(bus);
}
+static int aspeed_mdio_write_c22(struct mii_bus *bus, int addr, int regnum,
+ u16 val)
+{
+ return aspeed_mdio_op(bus, ASPEED_MDIO_CTRL_ST_C22, MDIO_C22_OP_WRITE,
+ addr, regnum, val);
+}
+
+static int aspeed_mdio_read_c45(struct mii_bus *bus, int addr, int regnum)
+{
+ /* TODO: add c45 support */
+ return -EOPNOTSUPP;
+}
+
+static int aspeed_mdio_write_c45(struct mii_bus *bus, int addr, int regnum,
+ u16 val)
+{
+ /* TODO: add c45 support */
+ return -EOPNOTSUPP;
+}
+
+static int aspeed_mdio_read(struct mii_bus *bus, int addr, int regnum)
+{
+ dev_dbg(&bus->dev, "%s: addr: %d, regnum: %d\n", __func__, addr,
+ regnum);
+
+ if (regnum & MII_ADDR_C45)
+ return aspeed_mdio_read_c45(bus, addr, regnum);
+
+ return aspeed_mdio_read_c22(bus, addr, regnum);
+}
+
static int aspeed_mdio_write(struct mii_bus *bus, int addr, int regnum, u16 val)
{
dev_dbg(&bus->dev, "%s: addr: %d, regnum: %d, val: 0x%x\n",
__func__, addr, regnum, val);
- /* Just clause 22 for the moment */
if (regnum & MII_ADDR_C45)
- return -EOPNOTSUPP;
+ return aspeed_mdio_write_c45(bus, addr, regnum, val);
- return aspeed_mdio_op(bus, ASPEED_MDIO_CTRL_ST_C22, MDIO_C22_OP_WRITE,
- addr, regnum, val);
+ return aspeed_mdio_write_c22(bus, addr, regnum, val);
}
static int aspeed_mdio_probe(struct platform_device *pdev)