mbox series

[net-next,0/4] MT7530 interrupt support

Message ID 20210429062130.29403-1-dqfext@gmail.com
Headers show
Series MT7530 interrupt support | expand

Message

Qingfang Deng April 29, 2021, 6:21 a.m. UTC
Add support for MT7530 interrupt controller.

DENG Qingfang (4):
  net: phy: add MediaTek PHY driver
  net: dsa: mt7530: add interrupt support
  dt-bindings: net: dsa: add MT7530 interrupt controller binding
  staging: mt7621-dts: enable MT7530 interrupt controller

 .../devicetree/bindings/net/dsa/mt7530.txt    |   6 +
 drivers/net/dsa/Kconfig                       |   1 +
 drivers/net/dsa/mt7530.c                      | 264 ++++++++++++++++--
 drivers/net/dsa/mt7530.h                      |  20 +-
 drivers/net/phy/Kconfig                       |   5 +
 drivers/net/phy/Makefile                      |   1 +
 drivers/net/phy/mediatek.c                    | 112 ++++++++
 drivers/staging/mt7621-dts/mt7621.dtsi        |   4 +
 8 files changed, 385 insertions(+), 28 deletions(-)
 create mode 100644 drivers/net/phy/mediatek.c

Comments

Andrew Lunn April 29, 2021, 9:26 p.m. UTC | #1
On Thu, Apr 29, 2021 at 02:21:27PM +0800, DENG Qingfang wrote:
> Add support for MediaTek PHYs found in MT7530 and MT7531 switches.
> The initialization procedure is from the vendor driver, but due to lack
> of documentation, the function of some register values remains unknown.
> 
> Signed-off-by: DENG Qingfang <dqfext@gmail.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

> +
> +	/* Enable HW auto downshift */
> +	phy_modify_paged(phydev, MTK_PHY_PAGE_EXTENDED, 0x14, 0, BIT(4));

As a follow up patch, you could add support for controlling this via a
PHY tunable.

    Andrew
David Miller April 30, 2021, 12:08 a.m. UTC | #2
Please fix this:

error: the following would cause module name conflict:
  drivers/net/phy/mediatek.ko
  drivers/usb/musb/mediatek.ko


Thanks.
Qingfang Deng April 30, 2021, 2:38 a.m. UTC | #3
On Thu, Apr 29, 2021 at 05:08:15PM -0700, David Miller wrote:
> 

> Please fix this:

> 

> error: the following would cause module name conflict:

>   drivers/net/phy/mediatek.ko

>   drivers/usb/musb/mediatek.ko


So I still have to rename the PHY driver..
Andrew, what is your suggestion? Is mediatek_phy.c okay?

> 

> 

> Thanks.
Andrew Lunn April 30, 2021, 12:24 p.m. UTC | #4
On Fri, Apr 30, 2021 at 10:38:39AM +0800, DENG Qingfang wrote:
> On Thu, Apr 29, 2021 at 05:08:15PM -0700, David Miller wrote:

> > 

> > Please fix this:

> > 

> > error: the following would cause module name conflict:

> >   drivers/net/phy/mediatek.ko

> >   drivers/usb/musb/mediatek.ko

> 

> So I still have to rename the PHY driver..

> Andrew, what is your suggestion? Is mediatek_phy.c okay?


mediatek_phy.c gets you into trouble with the generic PHY drivers.
Most Ethernet PHY drivers have the model number in the file name. Does
the PHY have its own name/numbering, or is it always considered part
of the switch?  If the PHY has an identity of its own, use
that. Otherwise maybe mediatek75xx.c?

      Andrew
Frank Wunderlich April 30, 2021, 12:37 p.m. UTC | #5
Hi,

i prepare rename of musb-driver to musb_mtk.ko as this is also not the best name.

if this module does only handle mt753x i would suggest

phy_mt753x.{c,ko}

regards Frank


> Gesendet: Freitag, 30. April 2021 um 14:24 Uhr
> Von: "Andrew Lunn" <andrew@lunn.ch>

> mediatek_phy.c gets you into trouble with the generic PHY drivers.
> Most Ethernet PHY drivers have the model number in the file name. Does
> the PHY have its own name/numbering, or is it always considered part
> of the switch?  If the PHY has an identity of its own, use
> that. Otherwise maybe mediatek75xx.c?
Andrew Lunn April 30, 2021, 12:44 p.m. UTC | #6
On Fri, Apr 30, 2021 at 02:37:16PM +0200, Frank Wunderlich wrote:
> Hi,

> 

> i prepare rename of musb-driver to musb_mtk.ko as this is also not the best name.

> 

> if this module does only handle mt753x i would suggest

> 

> phy_mt753x.{c,ko}


Hi Frank

That name will cause confusion with generic PHY drivers. They all seem
to use phy- as a file name prefix. At the moment, no Ethernet PHY
driver has phy as filename prefix or suffix.

       Andrew
Frank Wunderlich April 30, 2021, 12:56 p.m. UTC | #7
Hi

which ethernet-phy drivers do you mean?
i found only combined phy-drivers with ethernet-handling (marvell,xilinx,mscc,ti) having the "phy-" prefix too

as i see something like this in drivers/phy/intel/

phy-intel-keembay-emmc.c
phy-intel-keembay-usb.c

maybe this in drivers/phy/mediatek/

phy-mediatek-mt753x.c

? maybe with additional -eth, but this seems redundant, as mt753x is an ethernet-switch

or like the other mtk-phys

phy-mtk-eth-mt7531.c (like phy-mtk-mipi-dsi.c,phy-mtk-hdmi.c,phy-mtk-hdmi-mt8173.c)

regards Frank


> Gesendet: Freitag, 30. April 2021 um 14:44 Uhr
> Von: "Andrew Lunn" <andrew@lunn.ch>
> That name will cause confusion with generic PHY drivers. They all seem
> to use phy- as a file name prefix. At the moment, no Ethernet PHY
> driver has phy as filename prefix or suffix.
Andrew Lunn April 30, 2021, 1:13 p.m. UTC | #8
On Fri, Apr 30, 2021 at 02:56:22PM +0200, Frank Wunderlich wrote:
> Hi

> 

> which ethernet-phy drivers do you mean?


drivers/net/phy.

> i found only combined phy-drivers with ethernet-handling (marvell,xilinx,mscc,ti) having the "phy-" prefix too

> 

> as i see something like this in drivers/phy/intel/

> 

> phy-intel-keembay-emmc.c

> phy-intel-keembay-usb.c

> 

> maybe this in drivers/phy/mediatek/

> 

> phy-mediatek-mt753x.c

> 

> ? maybe with additional -eth, but this seems redundant, as mt753x is an ethernet-switch

> 

> or like the other mtk-phys

> 

> phy-mtk-eth-mt7531.c (like phy-mtk-mipi-dsi.c,phy-mtk-hdmi.c,phy-mtk-hdmi-mt8173.c)


These are all examples of generic PHY drivers, not PHY drivers.

There is a lot of confusion between PHY drivers and generic PHY
drivers :-(

	Andrew
Frank Wunderlich April 30, 2021, 2:59 p.m. UTC | #9
> Gesendet: Freitag, 30. April 2021 um 15:13 Uhr
> Von: "Andrew Lunn" <andrew@lunn.ch>
> > which ethernet-phy drivers do you mean?
>
> drivers/net/phy.

ok, sorry :)

> These are all examples of generic PHY drivers, not PHY drivers.

> There is a lot of confusion between PHY drivers and generic PHY
> drivers :-(

right, there is (at least by me) a confusion about generic phy and phy (here net-only phy) drivers.

mhm, maybe the naming should differ if generic phy and net-phy are that different. i guess there is no way to merge the net phys to the generic phys (due to linking to the net device drivers) to have only 1 phy section, right?

but if phy- prefix is used by generic phys, maybe eth- or net- can be used here (maybe with "phy" added)

something like

eth-phy-mt753x.ko

else i have no idea now...my patch renaming the musb-module seems not to be accepted due to possible breakage

regards Frank
Andrew Lunn April 30, 2021, 4:34 p.m. UTC | #10
> mhm, maybe the naming should differ if generic phy and net-phy are

> that different. i guess there is no way to merge the net phys to the

> generic phys (due to linking to the net device drivers) to have only

> 1 phy section, right?


phys and generic PHYs are very different things, completely different
API etc. They cannot be merged.

> but if phy- prefix is used by generic phys, maybe eth- or net- can be used here (maybe with "phy" added)

> 

> something like

> 

> eth-phy-mt753x.ko

> 

> else i have no idea now...my patch renaming the musb-module seems not

> to be accepted due to possible breakage


The usb module has been around for a long time, so it cannot be
changed. The phy driver is new, not in a released kernel. So we can
still rename it without causing problems.

I still want to understand the naming here. If you look at most
Ethernet switches with integrated PHYs, the PHYs have their own naming
scheme, separate from the switch, because they are independent IP. So
i would prefer this driver by named after the PHY name, not the switch
name. That might solve the naming conflict, mt123x for the PHY, mt7530
for the switch driver.

	Andrew
Landen Chao May 5, 2021, 9:31 a.m. UTC | #11
On Fri, 2021-04-30 at 18:34 +0200, Andrew Lunn wrote:
> > mhm, maybe the naming should differ if generic phy and net-phy are

> > that different. i guess there is no way to merge the net phys to

> > the

> > generic phys (due to linking to the net device drivers) to have

> > only

> > 1 phy section, right?

> 

> phys and generic PHYs are very different things, completely different

> API etc. They cannot be merged.

> 

> > but if phy- prefix is used by generic phys, maybe eth- or net- can

> > be used here (maybe with "phy" added)

> > 

> > something like

> > 

> > eth-phy-mt753x.ko

How about using mediatek-ge.ko. 'ge' is the abbreviation of gigabit
Ethernet. Most mediatek products use the same gigabit Ethernet phy.

Landen
> > 

> > else i have no idea now...my patch renaming the musb-module seems

> > not

> > to be accepted due to possible breakage

> 

> The usb module has been around for a long time, so it cannot be

> changed. The phy driver is new, not in a released kernel. So we can

> still rename it without causing problems.

> 

> I still want to understand the naming here. If you look at most

> Ethernet switches with integrated PHYs, the PHYs have their own

> naming

> scheme, separate from the switch, because they are independent IP. So

> i would prefer this driver by named after the PHY name, not the

> switch

> name. That might solve the naming conflict, mt123x for the PHY,

> mt7530

> for the switch driver.

> 

> 	Andrew
Qingfang Deng May 5, 2021, 9:43 a.m. UTC | #12
On Wed, May 5, 2021 at 5:31 PM Landen Chao <landen.chao@mediatek.com> wrote:
> How about using mediatek-ge.ko. 'ge' is the abbreviation of gigabit

> Ethernet. Most mediatek products use the same gigabit Ethernet phy.


Well, MT7620's PHY is FE..

>

> Landen
Landen Chao May 6, 2021, 12:54 p.m. UTC | #13
On Wed, 2021-05-05 at 17:43 +0800, DENG Qingfang wrote:
> On Wed, May 5, 2021 at 5:31 PM Landen Chao <landen.chao@mediatek.com>

> wrote:

> > How about using mediatek-ge.ko. 'ge' is the abbreviation of gigabit

> > Ethernet. Most mediatek products use the same gigabit Ethernet phy.

> 

> Well, MT7620's PHY is FE..

MT7620's FE PHY HW is different from MT753x's GE PHY. Vendor registers
of these two PHY are totally different.
However, MT7620 internal switch MAC is quite the same as MT753x's MAC
except for VLAN table and other minor changes. The MAC part can be
reused. 

> 

> > 

> > Landen
Qingfang Deng May 7, 2021, 7:55 a.m. UTC | #14
On Thu, May 6, 2021 at 8:54 PM Landen Chao <landen.chao@mediatek.com> wrote:
> MT7620's FE PHY HW is different from MT753x's GE PHY. Vendor registers

> of these two PHY are totally different.


Okay. So if the FE PHY is added later, it can be named mediatek-fe.c.