From: Daniel Golle <daniel@makrotopia.org>
To: Markus Stockhausen <markus.stockhausen@gmx.de>
Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, netdev@vger.kernel.org,
chris.packham@alliedtelesis.co.nz
Subject: Re: [PATCH 4/9] net: mdio: realtek-rtl9300: Add pages to info structure
Date: Tue, 19 May 2026 18:29:42 +0100 [thread overview]
Message-ID: <agyeBuG9IJ0JOx6v@makrotopia.org> (raw)
In-Reply-To: <20260519165747.1288903-5-markus.stockhausen@gmx.de>
On Tue, May 19, 2026 at 06:57:42PM +0200, Markus Stockhausen wrote:
> The Realtek MDIO controller has a paging feature that allows to run C22
> reads/writes in one turn. At least this holds true for attached Realtek
> based PHYs. The controller is given the page, the register and the data
> and it runs all the page switching in the background in hardware.
>
> There is however one special page that allows to pass through all C22
> commands directly to the PHY - without any caching. This so called raw
> page is dependent of the hardware. It is the highest supported page
> number minus 1. This is either 4095 for low port count SOCs (up to 28
> ports) or 8191 for high port count SOCs (up to 56 ports).
>
> Provide the number of supported pages as a device specific property.
> The raw page directly derives from that as "num_pages - 1". Make use
> of it where needed.
>
> Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
> ---
> drivers/net/mdio/mdio-realtek-rtl9300.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/mdio/mdio-realtek-rtl9300.c b/drivers/net/mdio/mdio-realtek-rtl9300.c
> index 4533c2f68cab..0ea691d9fc1b 100644
> --- a/drivers/net/mdio/mdio-realtek-rtl9300.c
> +++ b/drivers/net/mdio/mdio-realtek-rtl9300.c
> @@ -47,13 +47,16 @@
> #define MAX_PORTS 28
> #define MAX_SMI_BUSSES 4
> #define MAX_SMI_ADDR 0x1f
> +#define RAW_PAGE(x) ((x) - 1)
Maybe use
#define RAW_PAGE(priv) ((priv)->info->num_pages - 1)
as anyway you are only calling it in that way.
>
> #define RTL9300_NUM_BUSES 4
> +#define RTL9300_NUM_PAGES 4096
> #define RTL9300_NUM_PORTS 28
>
> struct rtl_mdio_info {
> u8 num_buses;
> u8 num_ports;
> + u16 num_pages;
> };
>
> struct rtl_mdio_priv {
> @@ -126,7 +129,7 @@ static int rtl9300_mdio_read_c22(struct mii_bus *bus, int phy_id, int regnum)
>
> val = FIELD_PREP(PHY_CTRL_REG_ADDR, regnum) |
> FIELD_PREP(PHY_CTRL_PARK_PAGE, 0x1f) |
> - FIELD_PREP(PHY_CTRL_MAIN_PAGE, 0xfff) |
> + FIELD_PREP(PHY_CTRL_MAIN_PAGE, RAW_PAGE(priv->info->num_pages)) |
> PHY_CTRL_READ | PHY_CTRL_TYPE_C22 | PHY_CTRL_CMD;
> err = regmap_write(regmap, SMI_ACCESS_PHY_CTRL_1, val);
> if (err)
> @@ -179,7 +182,7 @@ static int rtl9300_mdio_write_c22(struct mii_bus *bus, int phy_id, int regnum, u
>
> val = FIELD_PREP(PHY_CTRL_REG_ADDR, regnum) |
> FIELD_PREP(PHY_CTRL_PARK_PAGE, 0x1f) |
> - FIELD_PREP(PHY_CTRL_MAIN_PAGE, 0xfff) |
> + FIELD_PREP(PHY_CTRL_MAIN_PAGE, RAW_PAGE(priv->info->num_pages)) |
> PHY_CTRL_WRITE | PHY_CTRL_TYPE_C22 | PHY_CTRL_CMD;
> err = regmap_write(regmap, SMI_ACCESS_PHY_CTRL_1, val);
> if (err)
> @@ -512,6 +515,7 @@ static int rtl_mdiobus_probe(struct platform_device *pdev)
> static const struct rtl_mdio_info rtl9300_mdio_info = {
> .num_buses = RTL9300_NUM_BUSES,
> .num_ports = RTL9300_NUM_PORTS,
> + .num_pages = RTL9300_NUM_PAGES,
> };
>
> static const struct of_device_id rtl_mdio_ids[] = {
> --
> 2.54.0
>
next prev parent reply other threads:[~2026-05-19 17:29 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-19 16:57 [PATCH 0/9] mdio: realtek-rtl9300: Groundwork for multi SOC support Markus Stockhausen
2026-05-19 16:57 ` [PATCH 1/9] net: mdio: realtek-rtl9300: Convert to generic prefix Markus Stockhausen
2026-05-19 17:51 ` Andrew Lunn
2026-05-19 16:57 ` [PATCH 2/9] net: mdio: realtek-rtl9300: Add device specific info structure Markus Stockhausen
2026-05-19 16:57 ` [PATCH 3/9] net: mdio: realtek-rtl9300: Add ports to " Markus Stockhausen
2026-05-19 17:27 ` Daniel Golle
2026-05-19 17:59 ` Andrew Lunn
2026-05-19 19:06 ` AW: " Markus Stockhausen
2026-05-19 20:14 ` Andrew Lunn
2026-05-19 20:36 ` AW: " Markus Stockhausen
2026-05-19 22:47 ` Daniel Golle
2026-05-20 1:09 ` Andrew Lunn
[not found] ` <10121615-6F47-2A48-825A-0AC1E0C0F0C1@hxcore.ol>
2026-05-20 1:42 ` Andrew Lunn
2026-05-20 2:59 ` Daniel Golle
2026-05-19 16:57 ` [PATCH 4/9] net: mdio: realtek-rtl9300: Add pages " Markus Stockhausen
2026-05-19 17:29 ` Daniel Golle [this message]
2026-05-19 18:07 ` Andrew Lunn
2026-05-19 16:57 ` [PATCH 5/9] net: mdio: realtek-rtl9300: Add register structure Markus Stockhausen
2026-05-19 16:57 ` [PATCH 6/9] net: mdio: realtek-rtl9300: Add command/C22 register Markus Stockhausen
2026-05-19 16:57 ` [PATCH 7/9] net: mdio: realtek-rtl9300: Add I/O register Markus Stockhausen
2026-05-19 16:57 ` [PATCH 8/9] net: mdio: realtek-rtl9300: Add mask register Markus Stockhausen
2026-05-19 18:43 ` Andrew Lunn
2026-05-19 16:57 ` [PATCH 9/9] net: mdio: realtek-rtl9300: Link I/O functions in info structure Markus Stockhausen
2026-05-19 18:46 ` Andrew Lunn
2026-05-19 19:25 ` AW: " Markus Stockhausen
2026-05-19 20:16 ` Andrew Lunn
2026-05-19 20:40 ` AW: " Markus Stockhausen
2026-05-20 2:04 ` [PATCH 0/9] mdio: realtek-rtl9300: Groundwork for multi SOC support Chris Packham
2026-05-20 6:06 ` AW: " Markus Stockhausen
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=agyeBuG9IJ0JOx6v@makrotopia.org \
--to=daniel@makrotopia.org \
--cc=andrew@lunn.ch \
--cc=chris.packham@alliedtelesis.co.nz \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux@armlinux.org.uk \
--cc=markus.stockhausen@gmx.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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