From: Lukasz Majewski <lukma@denx.de>
To: Woojung Huh <woojung.huh@microchip.com>, UNGLinuxDriver@microchip.com
Cc: Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>,
davem@davemloft.net, Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Lukasz Majewski <lukma@denx.de>
Subject: [PATCH 1/2] net: dsa: microchip: KSZ9477: Provide functions to access MMD registers
Date: Thu, 24 Aug 2023 17:48:26 +0200 [thread overview]
Message-ID: <20230824154827.166274-1-lukma@denx.de> (raw)
Those function are necessary to access MMD (indirect) port registers of
the KSZ9477 device.
Signed-off-by: Lukasz Majewski <lukma@denx.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
next reply other threads:[~2023-08-24 15:48 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-24 15:48 Lukasz Majewski [this message]
2023-08-24 15:48 ` [PATCH 2/2] net: dsa: microchip: Provide Module 4 KSZ9477 errata (DS80000754C) Lukasz Majewski
2023-08-24 15:54 ` Florian Fainelli
2023-08-25 7:42 ` Lukasz Majewski
2023-08-25 1:12 ` Tristram.Ha
2023-08-25 8:39 ` Lukasz Majewski
2023-08-25 15:26 ` Florian Fainelli
2023-08-25 18:48 ` Tristram.Ha
2023-08-26 10:49 ` Vladimir Oltean
2023-08-29 8:35 ` Lukasz Majewski
2023-08-29 10:18 ` Vladimir Oltean
2023-08-29 11:24 ` Lukasz Majewski
2023-08-29 11:47 ` Oleksij Rempel
2023-08-29 12:38 ` Lukasz Majewski
2023-08-29 14:42 ` Oleksij Rempel
2023-08-29 15:29 ` Lukasz Majewski
2023-08-29 17:12 ` Oleksij Rempel
2023-08-29 22:23 ` Tristram.Ha
2023-08-30 6:16 ` Oleksij Rempel
2023-08-30 8:13 ` Lukasz Majewski
2023-08-29 21:57 ` Tristram.Ha
2023-08-29 22:00 ` Florian Fainelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230824154827.166274-1-lukma@denx.de \
--to=lukma@denx.de \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=woojung.huh@microchip.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).