netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: "Rafał Miłecki" <zajec5@gmail.com>,
	"Andrew Lunn" <andrew@lunn.ch>,
	"Vivien Didelot" <vivien.didelot@gmail.com>,
	"Florian Fainelli" <f.fainelli@gmail.com>,
	"Vladimir Oltean" <olteanv@gmail.com>
Cc: "David S . Miller" <davem@davemloft.net>,
	"Jakub Kicinski" <kuba@kernel.org>,
	netdev@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com,
	"Rafał Miłecki" <rafal@milecki.pl>
Subject: Re: [PATCH] net: dsa: bcm_sf2: setup BCM4908 internal crossbar
Date: Wed, 10 Mar 2021 09:19:49 -0800	[thread overview]
Message-ID: <dafc2ec7-871b-3ddc-d094-400055e81e4c@gmail.com> (raw)
In-Reply-To: <20210310115951.14565-1-zajec5@gmail.com>

On 3/10/21 3:59 AM, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> On some SoCs (e.g. BCM4908, BCM631[345]8) SF2 has an integrated
> crossbar. It allows connecting its selected external ports to internal
> ports. It's used by vendors to handle custom Ethernet setups.
> 
> BCM4908 has following 3x2 crossbar. On Asus GT-AC5300 rgmii is used for
> connecting external BCM53134S switch. GPHY4 is usually used for WAN
> port. More fancy devices use SerDes for 2.5 Gbps Ethernet.
> 
>               ┌──────────┐
> SerDes ─── 0 ─┤          │
>               │   3x2    ├─ 0 ─── switch port 7
>  GPHY4 ─── 1 ─┤          │
>               │ crossbar ├─ 1 ─── runner (accelerator)
>  rgmii ─── 2 ─┤          │
>               └──────────┘
> 
> Use setup data based on DT info to configure BCM4908's switch port 7.
> Right now only GPHY and rgmii variants are supported. Handling SerDes
> can be implemented later.
> 
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> ---
>  drivers/net/dsa/bcm_sf2.c      | 41 ++++++++++++++++++++++++++++++++++
>  drivers/net/dsa/bcm_sf2.h      |  1 +
>  drivers/net/dsa/bcm_sf2_regs.h |  7 ++++++
>  3 files changed, 49 insertions(+)
> 
> diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
> index 8f50e91d4004..b4b36408f069 100644
> --- a/drivers/net/dsa/bcm_sf2.c
> +++ b/drivers/net/dsa/bcm_sf2.c
> @@ -432,6 +432,40 @@ static int bcm_sf2_sw_rst(struct bcm_sf2_priv *priv)
>  	return 0;
>  }
>  
> +static void bcm_sf2_crossbar_setup(struct bcm_sf2_priv *priv)
> +{
> +	struct device *dev = priv->dev->ds->dev;
> +	int shift;
> +	u32 mask;
> +	u32 reg;
> +	int i;
> +
> +	reg = 0;

I believe you need to do a read/modify/write here otherwise you are
clobbering the other settings for the p_wan_link_status and
p_wan_link_sel bits.

> +	switch (priv->type) {
> +	case BCM4908_DEVICE_ID:
> +		shift = CROSSBAR_BCM4908_INT_P7 * priv->num_crossbar_int_ports;
> +		if (priv->int_phy_mask & BIT(7))
> +			reg |= CROSSBAR_BCM4908_EXT_GPHY4 << shift;
> +		else if (0) /* FIXME */
> +			reg |= CROSSBAR_BCM4908_EXT_SERDES << shift;
> +		else

Maybe what you can do is change bcm_sf2_identify_ports() such that when
the 'phy-interface' property is retrieved from Device Tree, we also
store the 'mode' variable into the per-port structure
(bcm_sf2_port_status) and when you call bcm_sf2_crossbar_setup() for
each port that has been setup, and you update the logic to look like this:

if (priv->int_phy_mask & BIT(7))
	reg |= CROSSBAR_BCM4908_EXT_GPHY4 << shift;
else if (phy_interface_mode_is_rgmii(mode))
	reg |= CROSSBAR_BCM4908_EXT_RGMII

and we add support for SerDes when we get to that point. This would also
allow you to detect if an invalid configuration is specified via Device
Tree.
	
Other than that, this looks good to me, thanks!
-- 
Florian

  reply	other threads:[~2021-03-10 17:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-10 11:59 [PATCH] net: dsa: bcm_sf2: setup BCM4908 internal crossbar Rafał Miłecki
2021-03-10 17:19 ` Florian Fainelli [this message]
2021-03-11 22:04   ` Rafał Miłecki
2021-03-11 22:13     ` Florian Fainelli
2021-03-12 10:01       ` Rafał Miłecki
2021-03-12 17:16         ` Florian Fainelli

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=dafc2ec7-871b-3ddc-d094-400055e81e4c@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=rafal@milecki.pl \
    --cc=vivien.didelot@gmail.com \
    --cc=zajec5@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 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).