[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230824154827.166274-1-lukma@denx.de>
Date: Thu, 24 Aug 2023 17:48:26 +0200
From: Lukasz Majewski <lukma@...x.de>
To: Woojung Huh <woojung.huh@...rochip.com>,
UNGLinuxDriver@...rochip.com
Cc: Andrew Lunn <andrew@...n.ch>,
Florian Fainelli <f.fainelli@...il.com>,
Vladimir Oltean <olteanv@...il.com>,
davem@...emloft.net,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
netdev@...r.kernel.org,
linux-kernel@...r.kernel.org,
Lukasz Majewski <lukma@...x.de>
Subject: [PATCH 1/2] net: dsa: microchip: KSZ9477: Provide functions to access MMD registers
Those function are necessary to access MMD (indirect) port registers of
the KSZ9477 device.
Signed-off-by: Lukasz Majewski <lukma@...x.de>
---
drivers/net/dsa/microchip/ksz9477.c | 31 +++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index 83b7f2d5c1ea..cb6aa7c668a8 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -43,6 +43,37 @@ static void ksz9477_port_cfg32(struct ksz_device *dev, int port, int offset,
bits, set ? bits : 0);
}
+static void ksz9477_port_mmd_setup(struct ksz_device *dev, uint port, u16 devid,
+ u16 reg, u16 len)
+{
+ u16 ctrl = PORT_MMD_OP_DATA_NO_INCR;
+
+ if (len > 1)
+ ctrl = PORT_MMD_OP_DATA_INCR_RW;
+
+ ksz_pwrite16(dev, port, REG_PORT_PHY_MMD_SETUP,
+ MMD_SETUP(PORT_MMD_OP_INDEX, devid));
+ ksz_pwrite16(dev, port, REG_PORT_PHY_MMD_INDEX_DATA, reg);
+ ksz_pwrite16(dev, port, REG_PORT_PHY_MMD_SETUP,
+ MMD_SETUP(ctrl, devid));
+}
+
+static void ksz9477_port_mmd_read(struct ksz_device *dev, uint port, u16 devid,
+ u16 reg, u16 *buf, u16 len)
+{
+ ksz9477_port_mmd_setup(dev, port, devid, reg, len);
+ for (; len; buf++, len--)
+ ksz_pread16(dev, port, REG_PORT_PHY_MMD_INDEX_DATA, buf);
+}
+
+static void ksz9477_port_mmd_write(struct ksz_device *dev, uint port, u16 devid,
+ u16 reg, u16 *buf, u16 len)
+{
+ ksz9477_port_mmd_setup(dev, port, devid, reg, len);
+ for (; len; buf++, len--)
+ ksz_pwrite16(dev, port, REG_PORT_PHY_MMD_INDEX_DATA, *buf);
+}
+
int ksz9477_change_mtu(struct ksz_device *dev, int port, int mtu)
{
u16 frame_size;
--
2.20.1
Powered by blists - more mailing lists