From: Sander Vanheule <sander@svanheule.net>
To: Chris Packham <chris.packham@alliedtelesis.co.nz>,
lee@kernel.org, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
tsbogend@alpha.franken.de, hkallweit1@gmail.com,
linux@armlinux.org.uk, daniel@makrotopia.org,
markus.stockhausen@gmx.de
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, linux-mips@vger.kernel.org
Subject: Re: [PATCH net-next v6 4/6] net: mdio: Add RTL9300 MDIO driver
Date: Sun, 09 Feb 2025 15:19:29 +0100 [thread overview]
Message-ID: <091a2e9cc6fedd99f35da124f67a54b69478648f.camel@svanheule.net> (raw)
In-Reply-To: <20250204030249.1965444-5-chris.packham@alliedtelesis.co.nz>
Hi Chris,
On Tue, 2025-02-04 at 16:02 +1300, Chris Packham wrote:
> Add a driver for the MDIO controller on the RTL9300 family of Ethernet
> switches with integrated SoC. There are 4 physical SMI interfaces on the
> RTL9300 however access is done using the switch ports. The driver takes
> the MDIO bus hierarchy from the DTS and uses this to configure the
> switch ports so they are associated with the correct PHY. This mapping
> is also used when dealing with software requests from phylib.
>
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> ---
>
> Notes:
> Changes in v6:
> - Parse port->phy mapping from devicetree removing the need for the
> realtek,port property
Good to see you found a way to do this!
> +/*
> + * MDIO controller for RTL9300 switches with integrated SoC.
> + *
> + * The MDIO communication is abstracted by the switch. At the software level
> + * communication uses the switch port to address the PHY. We work out the
> + * mapping based on the MDIO bus described in device tree and the realtek,port
> + * property.
> + */
Needs an update again ;-)
> +static int rtl9300_mdio_phy_to_port(struct mii_bus *bus, int phy_id)
> +{
> + struct rtl9300_mdio_chan *chan = bus->priv;
> + struct rtl9300_mdio_priv *priv = chan->priv;
> + int i;
> +
> + for (i = find_first_bit(priv->valid_ports, MAX_PORTS);
> + i < MAX_PORTS;
> + i = find_next_bit(priv->valid_ports, MAX_PORTS, i + 1))
You could use the for_each_set_bit(i, priv->valid_ports, MAX_PORTS) loop macro.
> +static int rtl9300_mdio_read_c22(struct mii_bus *bus, int phy_id, int regnum)
> +{
[...]
> +
> + err = regmap_write(regmap, SMI_ACCESS_PHY_CTRL_2, port << 16);
Another candidate for FIELD_PREP()
> + if (err)
> + return err;
> +
> + val = FIELD_PREP(GENMASK(24, 20), regnum) |
> + FIELD_PREP(GENMASK(19, 15), 0x1f) |
> + FIELD_PREP(GENMASK(14, 3), 0xfff) |
You could use #define-s for the GENMASK() field masks too, similar to PHY_CTRL_*. That
would make what you're setting a bit clearer, compared to these literal values.
Nit: You're also setting all-one values, so GENMASK(19, 15) and GENMASK(14, 3) by
themselves are sufficient. E.g. PHY_CTRL_NO_PAGE_PARK and PHY_CTRL_NO_PAGE_SELECT.
> +static int rtl9300_mdiobus_probe(struct platform_device *pdev)
> +{
[...]
> +
> + device_for_each_child_node(dev, child) {
> + err = rtl9300_mdiobus_probe_one(dev, priv, child);
In your next patch you use 'status = "disabled"' for the base dtsi. You may want to use
fwnode_for_each_available_child_node() in that case, so unused busses are not probed.
Best,
Sander
next prev parent reply other threads:[~2025-02-09 14:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-04 3:02 [PATCH net-next v6 0/6] RTL9300 MDIO driver Chris Packham
2025-02-04 3:02 ` [PATCH net-next v6 1/6] dt-bindings: mfd: Add switch to RTL9300 Chris Packham
2025-02-04 8:09 ` Krzysztof Kozlowski
2025-02-04 20:14 ` Chris Packham
2025-02-04 16:02 ` Rob Herring
2025-02-04 3:02 ` [PATCH net-next v6 2/6] dt-bindings: net: Add Realtek MDIO controller Chris Packham
2025-02-04 16:03 ` Rob Herring (Arm)
2025-02-04 3:02 ` [PATCH net-next v6 3/6] dt-bindings: mfd: Add MDIO interface to rtl9301-switch Chris Packham
2025-02-04 3:02 ` [PATCH net-next v6 4/6] net: mdio: Add RTL9300 MDIO driver Chris Packham
2025-02-09 14:19 ` Sander Vanheule [this message]
2025-02-11 21:06 ` Chris Packham
2025-02-04 3:02 ` [PATCH net-next v6 5/6] mips: dts: realtek: Add MDIO controller Chris Packham
2025-02-04 3:02 ` [PATCH net-next v6 6/6] mips: dts: cameo-rtl9302c: Add switch block Chris Packham
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=091a2e9cc6fedd99f35da124f67a54b69478648f.camel@svanheule.net \
--to=sander@svanheule.net \
--cc=andrew+netdev@lunn.ch \
--cc=chris.packham@alliedtelesis.co.nz \
--cc=conor+dt@kernel.org \
--cc=daniel@makrotopia.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=markus.stockhausen@gmx.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
--cc=tsbogend@alpha.franken.de \
/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).