public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Ansuel Smith <ansuelsmth@gmail.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Russell King <linux@armlinux.org.uk>,
	netdev@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, Matthew Hagan <mnhagan88@gmail.com>
Subject: Re: [net-next PATCH v4 02/13] net: dsa: qca8k: add support for sgmii falling edge
Date: Sun, 10 Oct 2021 15:05:26 +0300	[thread overview]
Message-ID: <20211010120526.xzd7m3ug4plvwcjw@skbuf> (raw)
In-Reply-To: <20211010111556.30447-3-ansuelsmth@gmail.com>

On Sun, Oct 10, 2021 at 01:15:45PM +0200, Ansuel Smith wrote:
> Add support for this in the qca8k driver. Also add support for SGMII
> rx/tx clock falling edge. This is only present for pad0, pad5 and
> pad6 have these bit reserved from Documentation. Add a comment that this
> is hardcoded to PAD0 as qca8327/28/34/37 have an unique sgmii line and
> setting falling in port0 applies to both configuration with sgmii used
> for port0 or port6.
> 
> Signed-off-by: Matthew Hagan <mnhagan88@gmail.com>
> Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
> ---
>  drivers/net/dsa/qca8k.c | 25 +++++++++++++++++++++++++
>  drivers/net/dsa/qca8k.h |  3 +++
>  2 files changed, 28 insertions(+)
> 
> diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c
> index a892b897cd0d..3e4a12d6d61c 100644
> --- a/drivers/net/dsa/qca8k.c
> +++ b/drivers/net/dsa/qca8k.c
> @@ -1172,6 +1172,7 @@ qca8k_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
>  			 const struct phylink_link_state *state)
>  {
>  	struct qca8k_priv *priv = ds->priv;
> +	struct dsa_port *dp;
>  	u32 reg, val;
>  	int ret;
>  
> @@ -1240,6 +1241,8 @@ qca8k_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
>  		break;
>  	case PHY_INTERFACE_MODE_SGMII:
>  	case PHY_INTERFACE_MODE_1000BASEX:
> +		dp = dsa_to_port(ds, port);
> +
>  		/* Enable SGMII on the port */
>  		qca8k_write(priv, reg, QCA8K_PORT_PAD_SGMII_EN);
>  
> @@ -1274,6 +1277,28 @@ qca8k_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
>  		}
>  
>  		qca8k_write(priv, QCA8K_REG_SGMII_CTRL, val);
> +
> +		/* For qca8327/qca8328/qca8334/qca8338 sgmii is unique and
> +		 * falling edge is set writing in the PORT0 PAD reg
> +		 */
> +		if (priv->switch_id == QCA8K_ID_QCA8327 ||
> +		    priv->switch_id == QCA8K_ID_QCA8337)
> +			reg = QCA8K_REG_PORT0_PAD_CTRL;
> +
> +		val = 0;
> +
> +		/* SGMII Clock phase configuration */
> +		if (of_property_read_bool(dp->dn, "qca,sgmii-rxclk-falling-edge"))

I would strongly recommend that you stop accessing dp->dn and add your
own device tree parsing function during probe time. It is also a runtime
invariant, there is no reason to read the device tree during each mac_config.

> +			val |= QCA8K_PORT0_PAD_SGMII_RXCLK_FALLING_EDGE;
> +
> +		if (of_property_read_bool(dp->dn, "qca,sgmii-txclk-falling-edge"))
> +			val |= QCA8K_PORT0_PAD_SGMII_TXCLK_FALLING_EDGE;
> +
> +		if (val)
> +			ret = qca8k_rmw(priv, reg,
> +					QCA8K_PORT0_PAD_SGMII_RXCLK_FALLING_EDGE |
> +					QCA8K_PORT0_PAD_SGMII_TXCLK_FALLING_EDGE,
> +					val);
>  		break;
>  	default:
>  		dev_err(ds->dev, "xMII mode %s not supported for port %d\n",
> diff --git a/drivers/net/dsa/qca8k.h b/drivers/net/dsa/qca8k.h
> index fc7db94cc0c9..3fded69a6839 100644
> --- a/drivers/net/dsa/qca8k.h
> +++ b/drivers/net/dsa/qca8k.h
> @@ -35,6 +35,9 @@
>  #define   QCA8K_MASK_CTRL_DEVICE_ID_MASK		GENMASK(15, 8)
>  #define   QCA8K_MASK_CTRL_DEVICE_ID(x)			((x) >> 8)
>  #define QCA8K_REG_PORT0_PAD_CTRL			0x004
> +#define   QCA8K_PORT0_PAD_CTRL_MAC06_EXCHG		BIT(31)

QCA8K_PORT0_PAD_CTRL_MAC06_EXCHG is not used in this patch.

> +#define   QCA8K_PORT0_PAD_SGMII_RXCLK_FALLING_EDGE	BIT(19)
> +#define   QCA8K_PORT0_PAD_SGMII_TXCLK_FALLING_EDGE	BIT(18)
>  #define QCA8K_REG_PORT5_PAD_CTRL			0x008
>  #define QCA8K_REG_PORT6_PAD_CTRL			0x00c
>  #define   QCA8K_PORT_PAD_RGMII_EN			BIT(26)
> -- 
> 2.32.0
> 


  reply	other threads:[~2021-10-10 12:05 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-10 11:15 [net-next PATCH v4 00/13] Multiple improvement for qca8337 switch Ansuel Smith
2021-10-10 11:15 ` [net-next PATCH v4 01/13] net: dsa: qca8k: add mac_power_sel support Ansuel Smith
2021-10-10 19:42   ` Vladimir Oltean
2021-10-10 11:15 ` [net-next PATCH v4 02/13] net: dsa: qca8k: add support for sgmii falling edge Ansuel Smith
2021-10-10 12:05   ` Vladimir Oltean [this message]
2021-10-10 12:10     ` Ansuel Smith
2021-10-10 12:50       ` Vladimir Oltean
2021-10-10 11:15 ` [net-next PATCH v4 03/13] dt-bindings: net: dsa: qca8k: Add MAC swap and clock phase properties Ansuel Smith
2021-10-10 12:07   ` Vladimir Oltean
2021-10-10 12:11     ` Ansuel Smith
2021-10-10 11:15 ` [net-next PATCH v4 04/13] drivers: net: dsa: qca8k: add support for cpu port 6 Ansuel Smith
2021-10-10 12:42   ` Vladimir Oltean
2021-10-10 13:22     ` Ansuel Smith
2021-10-11  8:17       ` Jonathan McDowell
2021-10-10 11:15 ` [net-next PATCH v4 05/13] dt-bindings: net: dsa: qca8k: Document support for CPU " Ansuel Smith
2021-10-10 11:15 ` [net-next PATCH v4 06/13] net: dsa: qca8k: move rgmii delay detection to phylink mac_config Ansuel Smith
2021-10-10 12:47   ` Vladimir Oltean
2021-10-10 13:28     ` Ansuel Smith
2021-10-10 18:11       ` Vladimir Oltean
2021-10-10 18:18         ` Ansuel Smith
2021-10-10 15:18     ` Andrew Lunn
2021-10-10 15:53       ` Vladimir Oltean
2021-10-10 11:15 ` [net-next PATCH v4 07/13] net: dsa: qca8k: add explicit SGMII PLL enable Ansuel Smith
2021-10-10 11:15 ` [net-next PATCH v4 08/13] dt-bindings: net: dsa: qca8k: Document qca,sgmii-enable-pll Ansuel Smith
2021-10-10 11:15 ` [net-next PATCH v4 09/13] drivers: net: dsa: qca8k: add support for pws config reg Ansuel Smith
2021-10-10 11:15 ` [net-next PATCH v4 10/13] dt-bindings: net: dsa: qca8k: document open drain binding Ansuel Smith
2021-10-10 12:54   ` Vladimir Oltean
2021-10-10 11:15 ` [net-next PATCH v4 11/13] drivers: net: dsa: qca8k: add support for QCA8328 Ansuel Smith
2021-10-10 11:15 ` [net-next PATCH v4 12/13] dt-bindings: net: dsa: qca8k: document support for qca8328 Ansuel Smith
2021-10-10 11:15 ` [net-next PATCH v4 13/13] drivers: net: dsa: qca8k: set internal delay also for sgmii Ansuel Smith

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=20211010120526.xzd7m3ug4plvwcjw@skbuf \
    --to=olteanv@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=ansuelsmth@gmail.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mnhagan88@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=vivien.didelot@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