netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
Cc: Ansuel Smith <ansuelsmth@gmail.com>, Andrew Lunn <andrew@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, Vivien Didelot <vivien.didelot@gmail.com>
Subject: Re: [PATCH net-next 5/6] net: dsa: qca8k: move pcs configuration
Date: Wed, 16 Feb 2022 17:45:18 +0200	[thread overview]
Message-ID: <20220216154518.piewevdckvxhzkbe@skbuf> (raw)
In-Reply-To: <E1nKLsr-009NN1-HQ@rmk-PC.armlinux.org.uk>

On Wed, Feb 16, 2022 at 03:06:21PM +0000, Russell King (Oracle) wrote:
> @@ -1981,6 +1917,89 @@ static int qca8k_pcs_config(struct phylink_pcs *pcs, unsigned int mode,
>  			    const unsigned long *advertising,
>  			    bool permit_pause_to_mac)
>  {
> +	struct qca8k_priv *priv = pcs_to_qca8k_pcs(pcs)->priv;
> +	int cpu_port_index, ret, port;
> +	u32 reg, val;
> +
> +	port = pcs_to_qca8k_pcs(pcs)->port;
> +	switch (port) {
> +	case 0:
> +		reg = QCA8K_REG_PORT0_PAD_CTRL;
> +		cpu_port_index = QCA8K_CPU_PORT0;
> +		break;
> +
> +	case 6:
> +		reg = QCA8K_REG_PORT6_PAD_CTRL;
> +		cpu_port_index = QCA8K_CPU_PORT6;
> +		break;
> +
> +	default:
> +		WARN_ON(1);
> +	}
> +
> +	/* Enable/disable SerDes auto-negotiation as necessary */
> +	ret = qca8k_read(priv, QCA8K_REG_PWS, &val);
> +	if (ret)
> +		return ret;
> +	if (phylink_autoneg_inband(mode))
> +		val &= ~QCA8K_PWS_SERDES_AEN_DIS;
> +	else
> +		val |= QCA8K_PWS_SERDES_AEN_DIS;
> +	qca8k_write(priv, QCA8K_REG_PWS, val);
> +
> +	/* Configure the SGMII parameters */
> +	ret = qca8k_read(priv, QCA8K_REG_SGMII_CTRL, &val);
> +	if (ret)
> +		return ret;
> +
> +	val |= QCA8K_SGMII_EN_SD;
> +
> +	if (priv->ports_config.sgmii_enable_pll)
> +		val |= QCA8K_SGMII_EN_PLL | QCA8K_SGMII_EN_RX |
> +		       QCA8K_SGMII_EN_TX;
> +
> +	if (dsa_is_cpu_port(priv->ds, port)) {
> +		/* CPU port, we're talking to the CPU MAC, be a PHY */
> +		val &= ~QCA8K_SGMII_MODE_CTRL_MASK;
> +		val |= QCA8K_SGMII_MODE_CTRL_PHY;
> +	} else if (interface == PHY_INTERFACE_MODE_SGMII) {
> +		val &= ~QCA8K_SGMII_MODE_CTRL_MASK;
> +		val |= QCA8K_SGMII_MODE_CTRL_MAC;
> +	} else if (interface == PHY_INTERFACE_MODE_1000BASEX) {
> +		val &= ~QCA8K_SGMII_MODE_CTRL_MASK;
> +		val |= QCA8K_SGMII_MODE_CTRL_BASEX;
> +	}
> +
> +	qca8k_write(priv, QCA8K_REG_SGMII_CTRL, val);
> +
> +	/* From original code is reported port instability as SGMII also
> +	 * require delay set. Apply advised values here or take them from DT.
> +	 */
> +	if (interface == PHY_INTERFACE_MODE_SGMII)
> +		qca8k_mac_config_setup_internal_delay(priv, cpu_port_index, reg);
> +	/* 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 (priv->ports_config.sgmii_rx_clk_falling_edge)
> +		val |= QCA8K_PORT0_PAD_SGMII_RXCLK_FALLING_EDGE;
> +
> +	if (priv->ports_config.sgmii_tx_clk_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);
> +
> +

Would be nice to avoid two consecutive empty lines at the end.

>  	return 0;
>  }
>  
> -- 
> 2.30.2
> 


  reply	other threads:[~2022-02-16 15:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-16 15:04 [PATCH net-next 0/6] net: dsa: qca8k: convert to phylink_pcs and mark as non-legacy Russell King (Oracle)
2022-02-16 15:06 ` [PATCH net-next 1/6] net: dsa: add support for phylink mac_select_pcs() Russell King (Oracle)
2022-02-16 15:43   ` Vladimir Oltean
2022-02-16 15:06 ` [PATCH net-next 2/6] net: dsa: qca8k: move qca8k_setup() Russell King (Oracle)
2022-02-16 15:06 ` [PATCH net-next 3/6] net: dsa: qca8k: move qca8k_phylink_mac_link_state() Russell King (Oracle)
2022-02-16 15:06 ` [PATCH net-next 4/6] net: dsa: qca8k: convert to use phylink_pcs Russell King (Oracle)
2022-02-16 15:06 ` [PATCH net-next 5/6] net: dsa: qca8k: move pcs configuration Russell King (Oracle)
2022-02-16 15:45   ` Vladimir Oltean [this message]
2022-02-16 15:06 ` [PATCH net-next 6/6] net: dsa: qca8k: mark as non-legacy Russell King (Oracle)

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=20220216154518.piewevdckvxhzkbe@skbuf \
    --to=olteanv@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=ansuelsmth@gmail.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=rmk+kernel@armlinux.org.uk \
    --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;
as well as URLs for NNTP newsgroup(s).