All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Daniel Golle <daniel@makrotopia.org>
Cc: netdev@vger.kernel.org, linux-mediatek@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	"Heiner Kallweit" <hkallweit1@gmail.com>,
	"Lorenzo Bianconi" <lorenzo@kernel.org>,
	"Mark Lee" <Mark-MC.Lee@mediatek.com>,
	"John Crispin" <john@phrozen.org>, "Felix Fietkau" <nbd@nbd.name>,
	"AngeloGioacchino Del Regno"
	<angelogioacchino.delregno@collabora.com>,
	"Matthias Brugger" <matthias.bgg@gmail.com>,
	"DENG Qingfang" <dqfext@gmail.com>,
	"Landen Chao" <Landen.Chao@mediatek.com>,
	"Sean Wang" <sean.wang@mediatek.com>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Eric Dumazet" <edumazet@google.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Vladimir Oltean" <olteanv@gmail.com>,
	"Florian Fainelli" <f.fainelli@gmail.com>,
	"Andrew Lunn" <andrew@lunn.ch>,
	"Jianhui Zhao" <zhaojh329@gmail.com>,
	"Bjørn Mork" <bjorn@mork.no>
Subject: Re: [PATCH v2 09/11] net: pcs: add driver for MediaTek SGMII PCS
Date: Fri, 10 Feb 2023 10:50:31 +0000	[thread overview]
Message-ID: <Y+Yhd2Hou/kZkU1o@shell.armlinux.org.uk> (raw)
In-Reply-To: <20bcf972bc1b27ad14977a235292ef47443a7043.1675779094.git.daniel@makrotopia.org>

On Tue, Feb 07, 2023 at 02:23:08PM +0000, Daniel Golle wrote:
> +config PCS_MTK_LYNXI
> +	tristate
> +	select PHYLINK

Does this need to select PHYLINK? If the user of this doesn't already
select phylink, then phylink_create() won't be called and thus trying
to use PCS_MTK_LYNXI becomes impossible. I know PCS_XPCS does, none of
the others do though.

> +	select REGMAP
> +	help
> +	  This module provides helpers to phylink for managing the LynxI PCS
> +	  which is part of MediaTek's SoC and Ethernet switch ICs.
> +
>  config PCS_RZN1_MIIC
>  	tristate "Renesas RZ/N1 MII converter"
>  	depends on OF && (ARCH_RZN1 || COMPILE_TEST)
> diff --git a/drivers/net/pcs/Makefile b/drivers/net/pcs/Makefile
> index 4c780d8f2e98..9b9afd6b1c22 100644
> --- a/drivers/net/pcs/Makefile
> +++ b/drivers/net/pcs/Makefile
> @@ -5,5 +5,6 @@ pcs_xpcs-$(CONFIG_PCS_XPCS)	:= pcs-xpcs.o pcs-xpcs-nxp.o
>  
>  obj-$(CONFIG_PCS_XPCS)		+= pcs_xpcs.o
>  obj-$(CONFIG_PCS_LYNX)		+= pcs-lynx.o
> +obj-$(CONFIG_PCS_MTK_LYNXI)	+= pcs-mtk-lynxi.o
>  obj-$(CONFIG_PCS_RZN1_MIIC)	+= pcs-rzn1-miic.o
>  obj-$(CONFIG_PCS_ALTERA_TSE)	+= pcs-altera-tse.o
> diff --git a/drivers/net/pcs/pcs-mtk-lynxi.c b/drivers/net/pcs/pcs-mtk-lynxi.c
> new file mode 100644
> index 000000000000..0100def53d45
> --- /dev/null
> +++ b/drivers/net/pcs/pcs-mtk-lynxi.c
> @@ -0,0 +1,315 @@
> +// SPDX-License-Identifier: GPL-2.0
> +// Copyright (c) 2018-2019 MediaTek Inc.
> +/* A library for MediaTek SGMII circuit
> + *
> + * Author: Sean Wang <sean.wang@mediatek.com>
> + * Author: Daniel Golle <daniel@makrotopia.org>
> + *
> + */
> +#include <linux/mdio.h>
> +#include <linux/phylink.h>
> +#include <linux/pcs/pcs-mtk-lynxi.h>
> +#include <linux/of.h>
> +#include <linux/phylink.h>
> +#include <linux/regmap.h>
> +
> +/* SGMII subsystem config registers */
> +/* BMCR (low 16) BMSR (high 16) */
> +#define SGMSYS_PCS_CONTROL_1		0x0
> +#define SGMII_BMCR			GENMASK(15, 0)
> +#define SGMII_BMSR			GENMASK(31, 16)
> +#define SGMII_AN_RESTART		BIT(9)
> +#define SGMII_ISOLATE			BIT(10)
> +#define SGMII_AN_ENABLE			BIT(12)

Not really a review comment but a question: would it be sensible to
define these as:

#define SGMII_AN_RESTART		BMCR_ANRESTART

etc, since they follow the IEEE802.3 clause 22 register layout?

> +#define SGMII_LINK_STATYS		BIT(18)
> +#define SGMII_AN_ABILITY		BIT(19)
> +#define SGMII_AN_COMPLETE		BIT(21)

These also correspond to BMSR bits (<<16).

> +#define SGMII_PCS_FAULT			BIT(23)
> +#define SGMII_AN_EXPANSION_CLR		BIT(30)

This define doesn't seem to be used.

> +
> +#define SGMSYS_PCS_DEVICE_ID		0x4
> +#define SGMII_LYNXI_DEV_ID		0x4d544950
> +
> +#define SGMSYS_PCS_ADVERTISE		0x8
> +#define SGMII_ADVERTISE			GENMASK(15, 0)
> +#define SGMII_LPA			GENMASK(31, 16)
> +
> +#define SGMSYS_PCS_SCRATCH		0x14
> +#define SGMII_DEV_VERSION		GENMASK(31, 16)
> +
> +/* Register to programmable link timer, the unit in 2 * 8ns */
> +#define SGMSYS_PCS_LINK_TIMER		0x18
> +#define SGMII_LINK_TIMER_MASK		GENMASK(19, 0)
> +#define SGMII_LINK_TIMER_DEFAULT	(0x186a0 & SGMII_LINK_TIMER_MASK)

We no longer make use of SGMII_LINK_TIMER_DEFAULT, so this can be
removed.

> +
> +/* Register to control remote fault */
> +#define SGMSYS_SGMII_MODE		0x20
> +#define SGMII_IF_MODE_SGMII		BIT(0)
> +#define SGMII_SPEED_DUPLEX_AN		BIT(1)
> +#define SGMII_SPEED_MASK		GENMASK(3, 2)
> +#define SGMII_SPEED_10			FIELD_PREP(SGMII_SPEED_MASK, 0)
> +#define SGMII_SPEED_100			FIELD_PREP(SGMII_SPEED_MASK, 1)
> +#define SGMII_SPEED_1000		FIELD_PREP(SGMII_SPEED_MASK, 2)
> +#define SGMII_DUPLEX_HALF		BIT(4)
> +#define SGMII_REMOTE_FAULT_DIS		BIT(8)

> +#define SGMII_CODE_SYNC_SET_VAL		BIT(9)
> +#define SGMII_CODE_SYNC_SET_EN		BIT(10)
> +#define SGMII_SEND_AN_ERROR_EN		BIT(11)

These three don't appear to be used.

> +
> +/* Register to reset SGMII design */
> +#define SGMII_RESERVED_0		0x34
> +#define SGMII_SW_RESET			BIT(0)
> +
> +/* Register to set SGMII speed, ANA RG_ Control Signals III */
> +#define SGMSYS_ANA_RG_CS3		0x2028

SGMSYS_ANA_RG_CS3 isn't used here, although its register bits below
are.

> +#define RG_PHY_SPEED_MASK		(BIT(2) | BIT(3))
> +#define RG_PHY_SPEED_1_25G		0x0
> +#define RG_PHY_SPEED_3_125G		BIT(2)
> +

...

> +struct mtk_pcs_lynxi {
> +	struct regmap		*regmap;
> +	struct device		*dev;

I can only find one place that this is written to in this patch, it
seems its otherwise never used. Do we need it?

Other than that, I don't see anything else to comment on that hasn't
been mentioned in previous patches. Thanks!

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!


WARNING: multiple messages have this Message-ID (diff)
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Daniel Golle <daniel@makrotopia.org>
Cc: netdev@vger.kernel.org, linux-mediatek@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	"Heiner Kallweit" <hkallweit1@gmail.com>,
	"Lorenzo Bianconi" <lorenzo@kernel.org>,
	"Mark Lee" <Mark-MC.Lee@mediatek.com>,
	"John Crispin" <john@phrozen.org>, "Felix Fietkau" <nbd@nbd.name>,
	"AngeloGioacchino Del Regno"
	<angelogioacchino.delregno@collabora.com>,
	"Matthias Brugger" <matthias.bgg@gmail.com>,
	"DENG Qingfang" <dqfext@gmail.com>,
	"Landen Chao" <Landen.Chao@mediatek.com>,
	"Sean Wang" <sean.wang@mediatek.com>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Eric Dumazet" <edumazet@google.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Vladimir Oltean" <olteanv@gmail.com>,
	"Florian Fainelli" <f.fainelli@gmail.com>,
	"Andrew Lunn" <andrew@lunn.ch>,
	"Jianhui Zhao" <zhaojh329@gmail.com>,
	"Bjørn Mork" <bjorn@mork.no>
Subject: Re: [PATCH v2 09/11] net: pcs: add driver for MediaTek SGMII PCS
Date: Fri, 10 Feb 2023 10:50:31 +0000	[thread overview]
Message-ID: <Y+Yhd2Hou/kZkU1o@shell.armlinux.org.uk> (raw)
In-Reply-To: <20bcf972bc1b27ad14977a235292ef47443a7043.1675779094.git.daniel@makrotopia.org>

On Tue, Feb 07, 2023 at 02:23:08PM +0000, Daniel Golle wrote:
> +config PCS_MTK_LYNXI
> +	tristate
> +	select PHYLINK

Does this need to select PHYLINK? If the user of this doesn't already
select phylink, then phylink_create() won't be called and thus trying
to use PCS_MTK_LYNXI becomes impossible. I know PCS_XPCS does, none of
the others do though.

> +	select REGMAP
> +	help
> +	  This module provides helpers to phylink for managing the LynxI PCS
> +	  which is part of MediaTek's SoC and Ethernet switch ICs.
> +
>  config PCS_RZN1_MIIC
>  	tristate "Renesas RZ/N1 MII converter"
>  	depends on OF && (ARCH_RZN1 || COMPILE_TEST)
> diff --git a/drivers/net/pcs/Makefile b/drivers/net/pcs/Makefile
> index 4c780d8f2e98..9b9afd6b1c22 100644
> --- a/drivers/net/pcs/Makefile
> +++ b/drivers/net/pcs/Makefile
> @@ -5,5 +5,6 @@ pcs_xpcs-$(CONFIG_PCS_XPCS)	:= pcs-xpcs.o pcs-xpcs-nxp.o
>  
>  obj-$(CONFIG_PCS_XPCS)		+= pcs_xpcs.o
>  obj-$(CONFIG_PCS_LYNX)		+= pcs-lynx.o
> +obj-$(CONFIG_PCS_MTK_LYNXI)	+= pcs-mtk-lynxi.o
>  obj-$(CONFIG_PCS_RZN1_MIIC)	+= pcs-rzn1-miic.o
>  obj-$(CONFIG_PCS_ALTERA_TSE)	+= pcs-altera-tse.o
> diff --git a/drivers/net/pcs/pcs-mtk-lynxi.c b/drivers/net/pcs/pcs-mtk-lynxi.c
> new file mode 100644
> index 000000000000..0100def53d45
> --- /dev/null
> +++ b/drivers/net/pcs/pcs-mtk-lynxi.c
> @@ -0,0 +1,315 @@
> +// SPDX-License-Identifier: GPL-2.0
> +// Copyright (c) 2018-2019 MediaTek Inc.
> +/* A library for MediaTek SGMII circuit
> + *
> + * Author: Sean Wang <sean.wang@mediatek.com>
> + * Author: Daniel Golle <daniel@makrotopia.org>
> + *
> + */
> +#include <linux/mdio.h>
> +#include <linux/phylink.h>
> +#include <linux/pcs/pcs-mtk-lynxi.h>
> +#include <linux/of.h>
> +#include <linux/phylink.h>
> +#include <linux/regmap.h>
> +
> +/* SGMII subsystem config registers */
> +/* BMCR (low 16) BMSR (high 16) */
> +#define SGMSYS_PCS_CONTROL_1		0x0
> +#define SGMII_BMCR			GENMASK(15, 0)
> +#define SGMII_BMSR			GENMASK(31, 16)
> +#define SGMII_AN_RESTART		BIT(9)
> +#define SGMII_ISOLATE			BIT(10)
> +#define SGMII_AN_ENABLE			BIT(12)

Not really a review comment but a question: would it be sensible to
define these as:

#define SGMII_AN_RESTART		BMCR_ANRESTART

etc, since they follow the IEEE802.3 clause 22 register layout?

> +#define SGMII_LINK_STATYS		BIT(18)
> +#define SGMII_AN_ABILITY		BIT(19)
> +#define SGMII_AN_COMPLETE		BIT(21)

These also correspond to BMSR bits (<<16).

> +#define SGMII_PCS_FAULT			BIT(23)
> +#define SGMII_AN_EXPANSION_CLR		BIT(30)

This define doesn't seem to be used.

> +
> +#define SGMSYS_PCS_DEVICE_ID		0x4
> +#define SGMII_LYNXI_DEV_ID		0x4d544950
> +
> +#define SGMSYS_PCS_ADVERTISE		0x8
> +#define SGMII_ADVERTISE			GENMASK(15, 0)
> +#define SGMII_LPA			GENMASK(31, 16)
> +
> +#define SGMSYS_PCS_SCRATCH		0x14
> +#define SGMII_DEV_VERSION		GENMASK(31, 16)
> +
> +/* Register to programmable link timer, the unit in 2 * 8ns */
> +#define SGMSYS_PCS_LINK_TIMER		0x18
> +#define SGMII_LINK_TIMER_MASK		GENMASK(19, 0)
> +#define SGMII_LINK_TIMER_DEFAULT	(0x186a0 & SGMII_LINK_TIMER_MASK)

We no longer make use of SGMII_LINK_TIMER_DEFAULT, so this can be
removed.

> +
> +/* Register to control remote fault */
> +#define SGMSYS_SGMII_MODE		0x20
> +#define SGMII_IF_MODE_SGMII		BIT(0)
> +#define SGMII_SPEED_DUPLEX_AN		BIT(1)
> +#define SGMII_SPEED_MASK		GENMASK(3, 2)
> +#define SGMII_SPEED_10			FIELD_PREP(SGMII_SPEED_MASK, 0)
> +#define SGMII_SPEED_100			FIELD_PREP(SGMII_SPEED_MASK, 1)
> +#define SGMII_SPEED_1000		FIELD_PREP(SGMII_SPEED_MASK, 2)
> +#define SGMII_DUPLEX_HALF		BIT(4)
> +#define SGMII_REMOTE_FAULT_DIS		BIT(8)

> +#define SGMII_CODE_SYNC_SET_VAL		BIT(9)
> +#define SGMII_CODE_SYNC_SET_EN		BIT(10)
> +#define SGMII_SEND_AN_ERROR_EN		BIT(11)

These three don't appear to be used.

> +
> +/* Register to reset SGMII design */
> +#define SGMII_RESERVED_0		0x34
> +#define SGMII_SW_RESET			BIT(0)
> +
> +/* Register to set SGMII speed, ANA RG_ Control Signals III */
> +#define SGMSYS_ANA_RG_CS3		0x2028

SGMSYS_ANA_RG_CS3 isn't used here, although its register bits below
are.

> +#define RG_PHY_SPEED_MASK		(BIT(2) | BIT(3))
> +#define RG_PHY_SPEED_1_25G		0x0
> +#define RG_PHY_SPEED_3_125G		BIT(2)
> +

...

> +struct mtk_pcs_lynxi {
> +	struct regmap		*regmap;
> +	struct device		*dev;

I can only find one place that this is written to in this patch, it
seems its otherwise never used. Do we need it?

Other than that, I don't see anything else to comment on that hasn't
been mentioned in previous patches. Thanks!

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-02-10 10:50 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-07 14:18 [PATCH v2 00/11] net: ethernet: mtk_eth_soc: various enhancements Daniel Golle
2023-02-07 14:18 ` Daniel Golle
2023-02-07 14:18 ` [PATCH v2 01/11] net: ethernet: mtk_eth_soc: add support for MT7981 SoC Daniel Golle
2023-02-07 14:18   ` Daniel Golle
2023-02-07 14:19 ` [PATCH v2 02/11] dt-bindings: net: mediatek,net: add mt7981-eth binding Daniel Golle
2023-02-07 14:19   ` Daniel Golle
2023-02-07 17:36   ` Krzysztof Kozlowski
2023-02-07 17:36     ` Krzysztof Kozlowski
2023-02-07 14:19 ` [PATCH v2 03/11] dt-bindings: arm: mediatek: add 'mediatek,pn_swap' property Daniel Golle
2023-02-07 14:19   ` Daniel Golle
2023-02-07 17:38   ` Krzysztof Kozlowski
2023-02-07 17:38     ` Krzysztof Kozlowski
2023-02-07 18:00     ` Daniel Golle
2023-02-07 18:00       ` Daniel Golle
2023-02-08  9:32       ` Krzysztof Kozlowski
2023-02-08  9:32         ` Krzysztof Kozlowski
2023-02-08 13:51         ` Daniel Golle
2023-02-08 13:51           ` Daniel Golle
2023-02-08 20:08           ` Krzysztof Kozlowski
2023-02-08 20:08             ` Krzysztof Kozlowski
2023-02-08 22:30             ` Daniel Golle
2023-02-08 22:30               ` Daniel Golle
2023-02-09 11:30               ` Krzysztof Kozlowski
2023-02-09 11:30                 ` Krzysztof Kozlowski
2023-02-10 10:34                 ` Russell King (Oracle)
2023-02-10 10:34                   ` Russell King (Oracle)
2023-02-10 12:23                   ` Russell King (Oracle)
2023-02-10 12:23                     ` Russell King (Oracle)
2023-02-10 12:35                     ` Krzysztof Kozlowski
2023-02-10 12:35                       ` Krzysztof Kozlowski
2023-02-10 10:30     ` Russell King (Oracle)
2023-02-10 10:30       ` Russell King (Oracle)
2023-02-07 14:20 ` [PATCH v2 04/11] net: ethernet: mtk_eth_soc: set MDIO bus clock frequency Daniel Golle
2023-02-07 14:20   ` Daniel Golle
2023-02-07 17:07   ` Andrew Lunn
2023-02-07 17:07     ` Andrew Lunn
2023-02-07 14:21 ` [PATCH v2 05/11] net: ethernet: mtk_eth_soc: reset PCS state Daniel Golle
2023-02-07 14:21   ` Daniel Golle
2023-02-10 10:36   ` Russell King (Oracle)
2023-02-10 10:36     ` Russell King (Oracle)
2023-02-07 14:21 ` [PATCH v2 06/11] net: ethernet: mtk_eth_soc: only write values if needed Daniel Golle
2023-02-07 14:21   ` Daniel Golle
2023-02-10 10:38   ` Russell King (Oracle)
2023-02-10 10:38     ` Russell King (Oracle)
2023-02-07 14:22 ` [PATCH v2 07/11] net: ethernet: mtk_eth_soc: fix RX data corruption issue Daniel Golle
2023-02-07 14:22   ` Daniel Golle
2023-02-07 14:22 ` [PATCH v2 08/11] net: ethernet: mtk_eth_soc: ppe: add support for flow accounting Daniel Golle
2023-02-07 14:22   ` Daniel Golle
2023-02-07 14:23 ` [PATCH v2 09/11] net: pcs: add driver for MediaTek SGMII PCS Daniel Golle
2023-02-07 14:23   ` Daniel Golle
2023-02-10 10:50   ` Russell King (Oracle) [this message]
2023-02-10 10:50     ` Russell King (Oracle)
2023-02-07 14:23 ` [PATCH v2 10/11] net: ethernet: mtk_eth_soc: switch to external PCS driver Daniel Golle
2023-02-07 14:23   ` Daniel Golle
2023-02-07 14:30   ` Daniel Golle
2023-02-07 14:30     ` Daniel Golle
2023-02-07 14:24 ` [PATCH v2 11/11] net: dsa: mt7530: use " Daniel Golle
2023-02-07 14:24   ` Daniel Golle
2023-02-10 10:56   ` Russell King (Oracle)
2023-02-10 10:56     ` Russell King (Oracle)
2023-02-10 12:52     ` Daniel Golle
2023-02-10 12:52       ` Daniel Golle
2023-02-10 22:17     ` Daniel Golle
2023-02-10 22:17       ` Daniel Golle

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=Y+Yhd2Hou/kZkU1o@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=Landen.Chao@mediatek.com \
    --cc=Mark-MC.Lee@mediatek.com \
    --cc=andrew@lunn.ch \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=bjorn@mork.no \
    --cc=daniel@makrotopia.org \
    --cc=davem@davemloft.net \
    --cc=dqfext@gmail.com \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=john@phrozen.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=lorenzo@kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=nbd@nbd.name \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=sean.wang@mediatek.com \
    --cc=zhaojh329@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.