Re: [PATCH net-next 2/2] net: mdio-mux: Add MDIO mux driver for Sophgo CV1800 SoCs
From: Inochi Amaoto
Date: Wed Jun 11 2025 - 20:34:42 EST
On Wed, Jun 11, 2025 at 06:13:00PM +0200, Andrew Lunn wrote:
> On Wed, Jun 11, 2025 at 04:02:00PM +0800, Inochi Amaoto wrote:
> > Add device driver for the mux driver for Sophgo CV18XX/SG200X
> > series SoCs.
> >
> > @@ -0,0 +1,119 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Sophgo CV1800 MDIO multiplexer driver
> > + *
> > + * Copyright (C) 2025 Inochi Amaoto <inochiama@xxxxxxxxx>
> > + */
> > +
> > +#include <linux/bitfield.h>
> > +#include <linux/bits.h>
> > +#include <linux/delay.h>
> > +#include <linux/clk.h>
> > +#include <linux/io.h>
> > +#include <linux/mdio-mux.h>
> > +#include <linux/module.h>
> > +#include <linux/platform_device.h>
> > +
> > +#define EPHY_PAGE_SELECT 0x07c
> > +#define EPHY_CTRL 0x800
> > +#define EPHY_REG_SELECT 0x804
> > +
> > +#define EPHY_PAGE_SELECT_SRC GENMASK(12, 8)
> > +
> > +#define EPHY_CTRL_ANALOG_SHUTDOWN BIT(0)
> > +#define EPHY_CTRL_USE_EXTPHY BIT(7)
> > +#define EPHY_CTRL_PHYMODE BIT(8)
> > +#define EPHY_CTRL_PHYMODE_SMI_RMII 1
> > +#define EPHY_CTRL_EXTPHY_ID GENMASK(15, 11)
>
> There are a lot of defines here which are not used, but as far as i
> see, there is one 8bit register, where bit 7 controls the mux.
>
You are true. Only bit 7 control the mux.
> It looks like you can throw this driver away and just use
> mdio-mux-mmioreg.c. This is from the binding documentation with a few
> tweaks:
>
> mdio-mux@3009000 {
> compatible = "mdio-mux-mmioreg", "mdio-mux";
> mdio-parent-bus = <&xmdio0>;
> #address-cells = <1>;
> #size-cells = <0>;
> reg = <0x3009000 1>;
> mux-mask = <128>;
>
> mdio@0 {
> reg = <0>;
> #address-cells = <1>;
> #size-cells = <0>;
>
> phy_xgmii_slot1: ethernet-phy@4 {
> compatible = "ethernet-phy-ieee802.3-c45";
> reg = <4>;
> };
> };
>
> mdio@128 {
> reg = <128>;
> #address-cells = <1>;
> #size-cells = <0>;
>
> ethernet-phy@4 {
> compatible = "ethernet-phy-ieee802.3-c45";
> reg = <4>;
> };
> };
> };
>
It is good for me to use this. I will have a try. Thanks.
Regards,
Inochi