From nobody Sat Nov 23 02:03:20 2024 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6387C193061; Thu, 14 Nov 2024 15:36:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731598576; cv=none; b=pYV4JiwNWRz8pxWcJhc6BkGLYlTPf0zypNI8aQOL3XgPzUdfM4bTNsG2xkAnDgXnfArKPxEr4MKovcruMgPMxpQVF7uwapn/seXjtvgWYBSPmTqh3aRlWj1nHHr/256vopE5Jk9B/AlnrLyEEW/jy8ZuNGWxT0BfBwHbUgcVrEQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731598576; c=relaxed/simple; bh=aXDa6WXqAsGTp271cwDJq8clhE7AZLg1W7agSE8IHpY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FAV+sTbwuUXGKYKZ9RA5Vc9zeZl/YOxt94h7aS2kmk7tRR7F83tTS0XrAnhhAa1bnmUznDqyeMUH8OiNfzSCIR6TiIc4II3snQ2QNNCCORPvdQgSZ4C500Avcyo2uhbBMVJs04p+tmj6u4/9zLGlQ9W9Uu82VijdncVu2vjy8rQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=Yf5SpRpd; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Yf5SpRpd" Received: by mail.gandi.net (Postfix) with ESMTPSA id 5858D1BF208; Thu, 14 Nov 2024 15:36:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1731598567; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RxGGhBtDTqWK4tM+QLuLJgRdIcL+yhd5ZKBES7qfk0g=; b=Yf5SpRpdOyGccdaHG+TnVqEQWpp7+EpWmrtK8GJLmtxo2XRVCTcpLofML0eq2SxrBg52dc M7ZleiUG0N3oT66unHuzKYWKBgThv0ZxCA36QyCpbmC+7xGTMHDNET4MeaD4h0eTy2RUa0 034pahCjrw+pbF33x4izemJUKBV7yP28rklVo3A+D9VVu3KPnLWIN1ZSrKJrVxXzROe0u1 c63jL6w8+z+sg1EAmcWGzpmkCE++1qVJwqYfEisiZcnqVRKcyHIi6YYPMezpeEouctPNpU M3XpwLKltOpNQMsXjUNozPSv0cCgsJEsuFc0kr0+84/Lubv1n1Zds1zfCadK7A== From: Maxime Chevallier To: davem@davemloft.net, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , Christophe Leroy , Heiner Kallweit Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Herve Codina , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linuxppc-dev@lists.ozlabs.org Subject: [PATCH net-next v2 01/10] net: freescale: ucc_geth: Drop support for the "interface" DT property Date: Thu, 14 Nov 2024 16:35:52 +0100 Message-ID: <20241114153603.307872-2-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241114153603.307872-1-maxime.chevallier@bootlin.com> References: <20241114153603.307872-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" In april 2007, ucc_geth was converted to phylib with : commit 728de4c927a3 ("ucc_geth: migrate ucc_geth to phylib"). In that commit, the device-tree property "interface", that could be used to retrieve the PHY interface mode was deprecated. DTS files that still used that property were converted along the way, in the following commit, also dating from april 2007 : commit 0fd8c47cccb1 ("[POWERPC] Replace undocumented interface properties i= n dts files") 17 years later, there's no users of that property left and I hope it's safe to say we can remove support from that in the ucc_geth driver, making the probe() function a bit simpler. Should there be any users that have a DT that was generated when 2.6.21 was cutting-edge, print an error message with hints on how to convert the devicetree if the 'interface' property is found. With that property gone, we can greatly simplify the parsing of the phy-interface-mode from the devicetree by using of_get_phy_mode(), allowing the removal of the open-coded parsing in the driver. Reviewed-by: Andrew Lunn Signed-off-by: Maxime Chevallier --- V2: No changes drivers/net/ethernet/freescale/ucc_geth.c | 63 +++++------------------ 1 file changed, 12 insertions(+), 51 deletions(-) diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethern= et/freescale/ucc_geth.c index 6663c1768089..80540c817c4e 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.c +++ b/drivers/net/ethernet/freescale/ucc_geth.c @@ -3469,32 +3469,6 @@ static int ucc_geth_resume(struct platform_device *o= fdev) #define ucc_geth_resume NULL #endif =20 -static phy_interface_t to_phy_interface(const char *phy_connection_type) -{ - if (strcasecmp(phy_connection_type, "mii") =3D=3D 0) - return PHY_INTERFACE_MODE_MII; - if (strcasecmp(phy_connection_type, "gmii") =3D=3D 0) - return PHY_INTERFACE_MODE_GMII; - if (strcasecmp(phy_connection_type, "tbi") =3D=3D 0) - return PHY_INTERFACE_MODE_TBI; - if (strcasecmp(phy_connection_type, "rmii") =3D=3D 0) - return PHY_INTERFACE_MODE_RMII; - if (strcasecmp(phy_connection_type, "rgmii") =3D=3D 0) - return PHY_INTERFACE_MODE_RGMII; - if (strcasecmp(phy_connection_type, "rgmii-id") =3D=3D 0) - return PHY_INTERFACE_MODE_RGMII_ID; - if (strcasecmp(phy_connection_type, "rgmii-txid") =3D=3D 0) - return PHY_INTERFACE_MODE_RGMII_TXID; - if (strcasecmp(phy_connection_type, "rgmii-rxid") =3D=3D 0) - return PHY_INTERFACE_MODE_RGMII_RXID; - if (strcasecmp(phy_connection_type, "rtbi") =3D=3D 0) - return PHY_INTERFACE_MODE_RTBI; - if (strcasecmp(phy_connection_type, "sgmii") =3D=3D 0) - return PHY_INTERFACE_MODE_SGMII; - - return PHY_INTERFACE_MODE_MII; -} - static int ucc_geth_ioctl(struct net_device *dev, struct ifreq *rq, int cm= d) { struct ucc_geth_private *ugeth =3D netdev_priv(dev); @@ -3564,19 +3538,6 @@ static int ucc_geth_probe(struct platform_device* of= dev) int err, ucc_num, max_speed =3D 0; const unsigned int *prop; phy_interface_t phy_interface; - static const int enet_to_speed[] =3D { - SPEED_10, SPEED_10, SPEED_10, - SPEED_100, SPEED_100, SPEED_100, - SPEED_1000, SPEED_1000, SPEED_1000, SPEED_1000, - }; - static const phy_interface_t enet_to_phy_interface[] =3D { - PHY_INTERFACE_MODE_MII, PHY_INTERFACE_MODE_RMII, - PHY_INTERFACE_MODE_RGMII, PHY_INTERFACE_MODE_MII, - PHY_INTERFACE_MODE_RMII, PHY_INTERFACE_MODE_RGMII, - PHY_INTERFACE_MODE_GMII, PHY_INTERFACE_MODE_RGMII, - PHY_INTERFACE_MODE_TBI, PHY_INTERFACE_MODE_RTBI, - PHY_INTERFACE_MODE_SGMII, - }; =20 ugeth_vdbg("%s: IN", __func__); =20 @@ -3627,18 +3588,17 @@ static int ucc_geth_probe(struct platform_device* o= fdev) /* Find the TBI PHY node. If it's not there, we don't support SGMII */ ug_info->tbi_node =3D of_parse_phandle(np, "tbi-handle", 0); =20 - /* get the phy interface type, or default to MII */ - prop =3D of_get_property(np, "phy-connection-type", NULL); - if (!prop) { - /* handle interface property present in old trees */ - prop =3D of_get_property(ug_info->phy_node, "interface", NULL); - if (prop !=3D NULL) { - phy_interface =3D enet_to_phy_interface[*prop]; - max_speed =3D enet_to_speed[*prop]; - } else - phy_interface =3D PHY_INTERFACE_MODE_MII; - } else { - phy_interface =3D to_phy_interface((const char *)prop); + prop =3D of_get_property(ug_info->phy_node, "interface", NULL); + if (prop) { + dev_err(&ofdev->dev, + "Device-tree property 'interface' is no longer supported. Please use 'p= hy-connection-type' instead."); + goto err_put_tbi; + } + + err =3D of_get_phy_mode(np, &phy_interface); + if (err) { + dev_err(&ofdev->dev, "Invalid phy-connection-type"); + goto err_put_tbi; } =20 /* get speed, or derive from PHY interface */ @@ -3746,6 +3706,7 @@ static int ucc_geth_probe(struct platform_device* ofd= ev) err_deregister_fixed_link: if (of_phy_is_fixed_link(np)) of_phy_deregister_fixed_link(np); +err_put_tbi: of_node_put(ug_info->tbi_node); of_node_put(ug_info->phy_node); return err; --=20 2.47.0 From nobody Sat Nov 23 02:03:20 2024 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17D8D1A0B07; Thu, 14 Nov 2024 15:36:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731598578; cv=none; b=HUj4eT9mAhRSy/Ej5amk7yj3LXhWb//Q6uk5G8MxGXqKPRYBjBH5th+Vc7BUDXrhjpUdZZw/dasl5SN9zuQMHV3IG+TjoNiFMJMg87BnHKRqMjYYZUzolSgFRnZV50iP1qJTTi5HYc/CHMD76SnYujEw9X/X2oJDKWqi01faXvo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731598578; c=relaxed/simple; bh=neKwiyC1PY4eT+QTZ5DnIjsnkk1H1GkhHLBu60Fe5fc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aWMZ6HdAfcoNct7F+AFImozrbi1mi9DGFYlFXPy9G7fVw4l2n94pLy5ZtvOCgxutC7PqnZkVg6SCgtVl6rMovlqvuvtA/4tnd1whqv101OiIpjX4iplUz2fpIXxSroAnRh6rJMTOqzEWIZYMcDBm/CsHimb/Sc78kin0Ot/LBF0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=FM20FU5O; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="FM20FU5O" Received: by mail.gandi.net (Postfix) with ESMTPSA id 22B781BF206; Thu, 14 Nov 2024 15:36:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1731598567; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2J76VxJOFhE7W3G57sG/Tt9BM1TPg186/HkI44UmxWw=; b=FM20FU5O6wYlTQaNiSx3v+cWLn+KxSgejmicoCY8EaaA1B8McXZ3qoyZSoJolg7UbHj/oQ +plmJWfGN2DpT5QuM2uWkuJUy0Bl1JSkDrZFdUih2IBboNbZxK4kNYQ5rFUl82aiPxD3S4 0qOpjBQazmJXXqpbvf2po2CniM0QpcZiTnrwnkGMJlZHRmiXIK5Qut7/aTvrNxyBhnOb89 SKQ/OynqEwv+uCZO10RXQp6de+5OupKK3wsNNmK/ii64r8gu3tJyKdIF3lZziTvT9c26lr ONP689zqjr8MOxGXyW8c136/+sNMvNDl+MrXQulod085Ok8/3pRdHyPTfpfybg== From: Maxime Chevallier To: davem@davemloft.net, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , Christophe Leroy , Heiner Kallweit Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Herve Codina , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linuxppc-dev@lists.ozlabs.org Subject: [PATCH net-next v2 02/10] net: freescale: ucc_geth: split adjust_link for phylink conversion Date: Thu, 14 Nov 2024 16:35:53 +0100 Message-ID: <20241114153603.307872-3-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241114153603.307872-1-maxime.chevallier@bootlin.com> References: <20241114153603.307872-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" Preparing the phylink conversion, split the adjust_link callbaclk, by clearly separating the mac configuration, link_up and link_down phases. Reviewed-by: Andrew Lunn Signed-off-by: Maxime Chevallier --- V2: No changes. Russell, I did see your comment with regards to the overall usefulness of this patch, hopefully now patch 10 is a easier to digest now, but if now I'll just merge that one with the actual phylink switch in patch 10. drivers/net/ethernet/freescale/ucc_geth.c | 180 +++++++++++----------- 1 file changed, 93 insertions(+), 87 deletions(-) diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethern= et/freescale/ucc_geth.c index 80540c817c4e..6286cd185a35 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.c +++ b/drivers/net/ethernet/freescale/ucc_geth.c @@ -1548,105 +1548,111 @@ static void ugeth_activate(struct ucc_geth_privat= e *ugeth) __netdev_watchdog_up(ugeth->ndev); } =20 -/* Called every time the controller might need to be made - * aware of new link state. The PHY code conveys this - * information through variables in the ugeth structure, and this - * function converts those variables into the appropriate - * register values, and can bring down the device if needed. - */ - -static void adjust_link(struct net_device *dev) +static void ugeth_link_up(struct ucc_geth_private *ugeth, + struct phy_device *phy, + phy_interface_t interface, int speed, int duplex) { - struct ucc_geth_private *ugeth =3D netdev_priv(dev); - struct ucc_geth __iomem *ug_regs; - struct ucc_fast __iomem *uf_regs; - struct phy_device *phydev =3D ugeth->phydev; + struct ucc_geth __iomem *ug_regs =3D ugeth->ug_regs; + struct ucc_fast __iomem *uf_regs =3D ugeth->uccf->uf_regs; + u32 tempval =3D in_be32(&ug_regs->maccfg2); + u32 upsmr =3D in_be32(&uf_regs->upsmr); int new_state =3D 0; =20 - ug_regs =3D ugeth->ug_regs; - uf_regs =3D ugeth->uccf->uf_regs; - - if (phydev->link) { - u32 tempval =3D in_be32(&ug_regs->maccfg2); - u32 upsmr =3D in_be32(&uf_regs->upsmr); - /* Now we make sure that we can be in full duplex mode. - * If not, we operate in half-duplex mode. */ - if (phydev->duplex !=3D ugeth->oldduplex) { - new_state =3D 1; - if (!(phydev->duplex)) - tempval &=3D ~(MACCFG2_FDX); - else - tempval |=3D MACCFG2_FDX; - ugeth->oldduplex =3D phydev->duplex; - } + /* Now we make sure that we can be in full duplex mode. + * If not, we operate in half-duplex mode. + */ + if (duplex !=3D ugeth->oldduplex) { + new_state =3D 1; + if (duplex =3D=3D DUPLEX_HALF) + tempval &=3D ~(MACCFG2_FDX); + else + tempval |=3D MACCFG2_FDX; + ugeth->oldduplex =3D duplex; + } =20 - if (phydev->speed !=3D ugeth->oldspeed) { - new_state =3D 1; - switch (phydev->speed) { - case SPEED_1000: - tempval =3D ((tempval & - ~(MACCFG2_INTERFACE_MODE_MASK)) | - MACCFG2_INTERFACE_MODE_BYTE); - break; - case SPEED_100: - case SPEED_10: - tempval =3D ((tempval & - ~(MACCFG2_INTERFACE_MODE_MASK)) | - MACCFG2_INTERFACE_MODE_NIBBLE); - /* if reduced mode, re-set UPSMR.R10M */ - if ((ugeth->phy_interface =3D=3D PHY_INTERFACE_MODE_RMII) || - (ugeth->phy_interface =3D=3D PHY_INTERFACE_MODE_RGMII) || - (ugeth->phy_interface =3D=3D PHY_INTERFACE_MODE_RGMII_ID) || - (ugeth->phy_interface =3D=3D PHY_INTERFACE_MODE_RGMII_RXID) || - (ugeth->phy_interface =3D=3D PHY_INTERFACE_MODE_RGMII_TXID) || - (ugeth->phy_interface =3D=3D PHY_INTERFACE_MODE_RTBI)) { - if (phydev->speed =3D=3D SPEED_10) - upsmr |=3D UCC_GETH_UPSMR_R10M; - else - upsmr &=3D ~UCC_GETH_UPSMR_R10M; - } - break; - default: - if (netif_msg_link(ugeth)) - pr_warn( - "%s: Ack! Speed (%d) is not 10/100/1000!", - dev->name, phydev->speed); - break; + if (speed !=3D ugeth->oldspeed) { + new_state =3D 1; + switch (speed) { + case SPEED_1000: + tempval =3D ((tempval & + ~(MACCFG2_INTERFACE_MODE_MASK)) | + MACCFG2_INTERFACE_MODE_BYTE); + break; + case SPEED_100: + case SPEED_10: + tempval =3D ((tempval & + ~(MACCFG2_INTERFACE_MODE_MASK)) | + MACCFG2_INTERFACE_MODE_NIBBLE); + /* if reduced mode, re-set UPSMR.R10M */ + if (interface =3D=3D PHY_INTERFACE_MODE_RMII || + phy_interface_mode_is_rgmii(interface) || + interface =3D=3D PHY_INTERFACE_MODE_RTBI) { + if (speed =3D=3D SPEED_10) + upsmr |=3D UCC_GETH_UPSMR_R10M; + else + upsmr &=3D ~UCC_GETH_UPSMR_R10M; } - ugeth->oldspeed =3D phydev->speed; + break; + default: + if (netif_msg_link(ugeth)) + pr_warn("%s: Speed (%d) is not 10/100/1000!", + netdev_name(ugeth->ndev), speed); + break; } + ugeth->oldspeed =3D speed; + } =20 - if (!ugeth->oldlink) { - new_state =3D 1; - ugeth->oldlink =3D 1; - } + if (!ugeth->oldlink) { + new_state =3D 1; + ugeth->oldlink =3D 1; + } =20 - if (new_state) { - /* - * To change the MAC configuration we need to disable - * the controller. To do so, we have to either grab - * ugeth->lock, which is a bad idea since 'graceful - * stop' commands might take quite a while, or we can - * quiesce driver's activity. - */ - ugeth_quiesce(ugeth); - ugeth_disable(ugeth, COMM_DIR_RX_AND_TX); + if (new_state) { + /* + * To change the MAC configuration we need to disable + * the controller. To do so, we have to either grab + * ugeth->lock, which is a bad idea since 'graceful + * stop' commands might take quite a while, or we can + * quiesce driver's activity. + */ + ugeth_quiesce(ugeth); + ugeth_disable(ugeth, COMM_DIR_RX_AND_TX); =20 - out_be32(&ug_regs->maccfg2, tempval); - out_be32(&uf_regs->upsmr, upsmr); + out_be32(&ug_regs->maccfg2, tempval); + out_be32(&uf_regs->upsmr, upsmr); =20 - ugeth_enable(ugeth, COMM_DIR_RX_AND_TX); - ugeth_activate(ugeth); - } - } else if (ugeth->oldlink) { - new_state =3D 1; - ugeth->oldlink =3D 0; - ugeth->oldspeed =3D 0; - ugeth->oldduplex =3D -1; + ugeth_enable(ugeth, COMM_DIR_RX_AND_TX); + ugeth_activate(ugeth); } =20 - if (new_state && netif_msg_link(ugeth)) - phy_print_status(phydev); + if (netif_msg_link(ugeth)) + phy_print_status(phy); +} + +static void ugeth_link_down(struct ucc_geth_private *ugeth) +{ + ugeth->oldlink =3D 0; + ugeth->oldspeed =3D 0; + ugeth->oldduplex =3D -1; +} + +/* Called every time the controller might need to be made + * aware of new link state. The PHY code conveys this + * information through variables in the ugeth structure, and this + * function converts those variables into the appropriate + * register values, and can bring down the device if needed. + */ + +static void adjust_link(struct net_device *dev) +{ + struct ucc_geth_private *ugeth =3D netdev_priv(dev); + struct phy_device *phydev =3D ugeth->phydev; + + if (phydev->link) + ugeth_link_up(ugeth, phydev, phydev->interface, + phydev->speed, phydev->duplex); + else + ugeth_link_down(ugeth); } =20 /* Initialize TBI PHY interface for communicating with the --=20 2.47.0 From nobody Sat Nov 23 02:03:20 2024 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17D3C19CC0F; Thu, 14 Nov 2024 15:36:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731598578; cv=none; b=A/8sL28cAbn8BJ0Vhv+1Aed3hJAfjDkS9gJ/nb9z1oLJSR4wV3MpFYP/jnbN9IUjDW89pGa7UWBGi02SsaEDTMd6g2QD5zRi4KjhVa3Cgwxil9TMudK0TydsxLcMk6WJ+vu1ey99asSHFiXSS/zNtN+yZjTdPCc4MeTPMvftqho= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731598578; c=relaxed/simple; bh=891f4ChfUy9ld15ZISZhA05VjzAsC22sOsxxWTgB5Wc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ostaMsULgSmHxCoFBMpUy0bjSrp/cpivmmVbkCQoS7NISs1QLVUmX12X21PaME89WwN2GRWalv8UW4aw9YiNUYe3+PDGXqvLCf7WI66ahCABiMJDc9g9L3Mrm2ldCXxIExbR0EGVEobe+UMdfjIlSxa+PD26pulfdFMqd4wqO2U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=jyhMgyjQ; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="jyhMgyjQ" Received: by mail.gandi.net (Postfix) with ESMTPSA id DCCF41BF20F; Thu, 14 Nov 2024 15:36:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1731598568; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kW6y+es3PhkNN7oGJsip9taWxcOyK0imTW0mpB6Vpt4=; b=jyhMgyjQNphFcbuLgQ6JC1+lbRGUxfdG4uDocbUbLs17d7Ri+vicdK2NWyAeH5ocBKOeoA JnzTJmcXNkr+r04mVeBO1rpKs48cpUyBnctnmpp05hqZl+VDLz5MnFzrcP7PaRHtSV0EvG dcQN0mBSUB7offJ2AcNuCryTChJ/6/ASYFwZ5ObKIaTYcMfMg1QrjnMo6rizwcNxljTWWB yDLDHTxai7n2A1BUO0PZUoV60C5+slZPC43E5ZdgDGYmOiHcRGLBw9Y5Z6b5Jc0sdoZrTJ Ka2d6qSd8BUT7LFZym0IwS4VAT9vxbJu1B1UPgf4tkTgAfoZrzmcJ3DQAXgibA== From: Maxime Chevallier To: davem@davemloft.net, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , Christophe Leroy , Heiner Kallweit Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Herve Codina , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linuxppc-dev@lists.ozlabs.org Subject: [PATCH net-next v2 03/10] net: freescale: ucc_geth: Use netdev->phydev to access the PHY Date: Thu, 14 Nov 2024 16:35:54 +0100 Message-ID: <20241114153603.307872-4-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241114153603.307872-1-maxime.chevallier@bootlin.com> References: <20241114153603.307872-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" As this driver pre-dates phylib, it uses a private pointer to get a reference to the attached phy_device. Drop that pointer and use the netdev's pointer instead. Reviewed-by: Andrew Lunn Signed-off-by: Maxime Chevallier --- V2: No changes drivers/net/ethernet/freescale/ucc_geth.c | 27 ++++++++----------- drivers/net/ethernet/freescale/ucc_geth.h | 1 - .../net/ethernet/freescale/ucc_geth_ethtool.c | 17 ++++++------ 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethern= et/freescale/ucc_geth.c index 6286cd185a35..13b8f8401c81 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.c +++ b/drivers/net/ethernet/freescale/ucc_geth.c @@ -1646,7 +1646,7 @@ static void ugeth_link_down(struct ucc_geth_private *= ugeth) static void adjust_link(struct net_device *dev) { struct ucc_geth_private *ugeth =3D netdev_priv(dev); - struct phy_device *phydev =3D ugeth->phydev; + struct phy_device *phydev =3D dev->phydev; =20 if (phydev->link) ugeth_link_up(ugeth, phydev, phydev->interface, @@ -1727,8 +1727,6 @@ static int init_phy(struct net_device *dev) =20 phy_set_max_speed(phydev, priv->max_speed); =20 - priv->phydev =3D phydev; - return 0; } =20 @@ -2001,7 +1999,7 @@ static void ucc_geth_set_multi(struct net_device *dev) static void ucc_geth_stop(struct ucc_geth_private *ugeth) { struct ucc_geth __iomem *ug_regs =3D ugeth->ug_regs; - struct phy_device *phydev =3D ugeth->phydev; + struct phy_device *phydev =3D ugeth->ndev->phydev; =20 ugeth_vdbg("%s: IN", __func__); =20 @@ -3316,13 +3314,13 @@ static int ucc_geth_open(struct net_device *dev) goto err; } =20 - phy_start(ugeth->phydev); + phy_start(dev->phydev); napi_enable(&ugeth->napi); netdev_reset_queue(dev); netif_start_queue(dev); =20 device_set_wakeup_capable(&dev->dev, - qe_alive_during_sleep() || ugeth->phydev->irq); + qe_alive_during_sleep() || dev->phydev->irq); device_set_wakeup_enable(&dev->dev, ugeth->wol_en); =20 return err; @@ -3343,8 +3341,7 @@ static int ucc_geth_close(struct net_device *dev) =20 cancel_work_sync(&ugeth->timeout_work); ucc_geth_stop(ugeth); - phy_disconnect(ugeth->phydev); - ugeth->phydev =3D NULL; + phy_disconnect(dev->phydev); =20 free_irq(ugeth->ug_info->uf_info.irq, ugeth->ndev); =20 @@ -3378,7 +3375,7 @@ static void ucc_geth_timeout_work(struct work_struct = *work) ucc_geth_stop(ugeth); ucc_geth_init_mac(ugeth); /* Must start PHY here */ - phy_start(ugeth->phydev); + phy_start(dev->phydev); netif_tx_start_all_queues(dev); } =20 @@ -3421,7 +3418,7 @@ static int ucc_geth_suspend(struct platform_device *o= fdev, pm_message_t state) setbits32(&ugeth->ug_regs->maccfg2, MACCFG2_MPE); ucc_fast_enable(ugeth->uccf, COMM_DIR_RX_AND_TX); } else if (!(ugeth->wol_en & WAKE_PHY)) { - phy_stop(ugeth->phydev); + phy_stop(ndev->phydev); } =20 return 0; @@ -3461,8 +3458,8 @@ static int ucc_geth_resume(struct platform_device *of= dev) ugeth->oldspeed =3D 0; ugeth->oldduplex =3D -1; =20 - phy_stop(ugeth->phydev); - phy_start(ugeth->phydev); + phy_stop(ndev->phydev); + phy_start(ndev->phydev); =20 napi_enable(&ugeth->napi); netif_device_attach(ndev); @@ -3477,15 +3474,13 @@ static int ucc_geth_resume(struct platform_device *= ofdev) =20 static int ucc_geth_ioctl(struct net_device *dev, struct ifreq *rq, int cm= d) { - struct ucc_geth_private *ugeth =3D netdev_priv(dev); - if (!netif_running(dev)) return -EINVAL; =20 - if (!ugeth->phydev) + if (!dev->phydev) return -ENODEV; =20 - return phy_mii_ioctl(ugeth->phydev, rq, cmd); + return phy_mii_ioctl(dev->phydev, rq, cmd); } =20 static const struct net_device_ops ucc_geth_netdev_ops =3D { diff --git a/drivers/net/ethernet/freescale/ucc_geth.h b/drivers/net/ethern= et/freescale/ucc_geth.h index 4294ed096ebb..c08a56b7c9fe 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.h +++ b/drivers/net/ethernet/freescale/ucc_geth.h @@ -1210,7 +1210,6 @@ struct ucc_geth_private { u16 skb_dirtytx[NUM_TX_QUEUES]; =20 struct ugeth_mii_info *mii_info; - struct phy_device *phydev; phy_interface_t phy_interface; int max_speed; uint32_t msg_enable; diff --git a/drivers/net/ethernet/freescale/ucc_geth_ethtool.c b/drivers/ne= t/ethernet/freescale/ucc_geth_ethtool.c index 699f346faf5c..fb5254d7d1ba 100644 --- a/drivers/net/ethernet/freescale/ucc_geth_ethtool.c +++ b/drivers/net/ethernet/freescale/ucc_geth_ethtool.c @@ -103,8 +103,7 @@ static const char rx_fw_stat_gstrings[][ETH_GSTRING_LEN= ] =3D { static int uec_get_ksettings(struct net_device *netdev, struct ethtool_link_ksettings= *cmd) { - struct ucc_geth_private *ugeth =3D netdev_priv(netdev); - struct phy_device *phydev =3D ugeth->phydev; + struct phy_device *phydev =3D netdev->phydev; =20 if (!phydev) return -ENODEV; @@ -118,8 +117,7 @@ static int uec_set_ksettings(struct net_device *netdev, const struct ethtool_link_ksettings *cmd) { - struct ucc_geth_private *ugeth =3D netdev_priv(netdev); - struct phy_device *phydev =3D ugeth->phydev; + struct phy_device *phydev =3D netdev->phydev; =20 if (!phydev) return -ENODEV; @@ -132,8 +130,10 @@ uec_get_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause) { struct ucc_geth_private *ugeth =3D netdev_priv(netdev); + struct phy_device *phydev =3D netdev->phydev; =20 - pause->autoneg =3D ugeth->phydev->autoneg; + if (phydev) + pause->autoneg =3D phydev->autoneg; =20 if (ugeth->ug_info->receiveFlowControl) pause->rx_pause =3D 1; @@ -146,12 +146,13 @@ uec_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause) { struct ucc_geth_private *ugeth =3D netdev_priv(netdev); + struct phy_device *phydev =3D netdev->phydev; int ret =3D 0; =20 ugeth->ug_info->receiveFlowControl =3D pause->rx_pause; ugeth->ug_info->transmitFlowControl =3D pause->tx_pause; =20 - if (ugeth->phydev->autoneg) { + if (phydev && phydev->autoneg) { if (netif_running(netdev)) { /* FIXME: automatically restart */ netdev_info(netdev, "Please re-open the interface\n"); @@ -343,7 +344,7 @@ uec_get_drvinfo(struct net_device *netdev, static void uec_get_wol(struct net_device *netdev, struct ethtool_wolinfo = *wol) { struct ucc_geth_private *ugeth =3D netdev_priv(netdev); - struct phy_device *phydev =3D ugeth->phydev; + struct phy_device *phydev =3D netdev->phydev; =20 if (phydev && phydev->irq) wol->supported |=3D WAKE_PHY; @@ -356,7 +357,7 @@ static void uec_get_wol(struct net_device *netdev, stru= ct ethtool_wolinfo *wol) static int uec_set_wol(struct net_device *netdev, struct ethtool_wolinfo *= wol) { struct ucc_geth_private *ugeth =3D netdev_priv(netdev); - struct phy_device *phydev =3D ugeth->phydev; + struct phy_device *phydev =3D netdev->phydev; =20 if (wol->wolopts & ~(WAKE_PHY | WAKE_MAGIC)) return -EINVAL; --=20 2.47.0 From nobody Sat Nov 23 02:03:20 2024 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56E651A3A95; Thu, 14 Nov 2024 15:36:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731598578; cv=none; b=hInaDjQ1pTq83XLSAQN60EC0MyXmjuJ5/twkxrsdTrSjFQgV2G20mKz59fj58fMJVnclbTnAn998oz/NbBSdpd5TQ3jQmSyegXzlGN/aUuTMJXfAtK1NijXlEseMeJYi8pG6aUcbfhYLrxYNdLC0Fcl+7JsK5h+7GaS9AJQnjD0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731598578; c=relaxed/simple; bh=B+PCAI540XD3fd4y0ya7YSHILUH9X/B2UA1J0r2jkKU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tUyiF//yzP3/Ef0JKGWnzJ4VODODxDRgIbaIbMh8Lnz7AnkFzp1qMmCboahI2daAMjS1UICh7AvSNcaImDuolqU3m6UKU5TeNzUdB7eb7pH9ACY8QjpgiNJhLe0oQqBnFqH+E0nHhErwIutWtljgCBLa6DJzE4eOSLkEHWw3a9k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=FhIZd88T; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="FhIZd88T" Received: by mail.gandi.net (Postfix) with ESMTPSA id A8F971BF210; Thu, 14 Nov 2024 15:36:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1731598569; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vOe5I5RV009/ewvKsTnVJ8v2QKmxpVyy8K9Vn3nWYhQ=; b=FhIZd88TTOZcqjc0guKQCBJMu2N4P6TeOLSV0DXGYcjgtbVGT7jfK3B49OveA0CQdnbVlF Btjvo5r+wgNRn45asVSf8II6FMlqDNNcsGiEqCen5vYvXLUhbGUMimV+ZOSe5Rdw5r+wdB lG3x66GXT373VkmtNgU7O//RjSYHxaHoJjckcLtnyQzwovz5UVEQFj4aGRNIjjrHoP0PWb +BMe6H44oXDl4r8nfQ6ky4YzSRTfq0wXH96DmfqqxyGokLEQmldFhirtMUrW9GX61XCtmj Q7qKbJDiWwDfxz4NXId9R7+aR5Yxcy3Fo5ozQaDIxzodB7yOlZjUZ2CWyL2x+A== From: Maxime Chevallier To: davem@davemloft.net, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , Christophe Leroy , Heiner Kallweit Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Herve Codina , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linuxppc-dev@lists.ozlabs.org Subject: [PATCH net-next v2 04/10] net: freescale: ucc_geth: Fix WOL configuration Date: Thu, 14 Nov 2024 16:35:55 +0100 Message-ID: <20241114153603.307872-5-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241114153603.307872-1-maxime.chevallier@bootlin.com> References: <20241114153603.307872-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" The get/set_wol ethtool ops rely on querying the PHY for its WoL capabilities, checking for the presence of a PHY and a PHY interrupts isn't enough. Address that by cleaning up the WoL configuration sequence. Signed-off-by: Maxime Chevallier --- V2: Reworked the whole configuration sequence, and introduced an internal attribute to store the PHY wol capabilities drivers/net/ethernet/freescale/ucc_geth.c | 4 +-- drivers/net/ethernet/freescale/ucc_geth.h | 1 + .../net/ethernet/freescale/ucc_geth_ethtool.c | 36 +++++++++++++++---- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethern= et/freescale/ucc_geth.c index 13b8f8401c81..42254ee64a35 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.c +++ b/drivers/net/ethernet/freescale/ucc_geth.c @@ -3413,11 +3413,11 @@ static int ucc_geth_suspend(struct platform_device = *ofdev, pm_message_t state) */ ugeth_disable(ugeth, COMM_DIR_RX_AND_TX); =20 - if (ugeth->wol_en & WAKE_MAGIC) { + if (ugeth->wol_en & WAKE_MAGIC && !ugeth->phy_wol_en) { setbits32(ugeth->uccf->p_uccm, UCC_GETH_UCCE_MPD); setbits32(&ugeth->ug_regs->maccfg2, MACCFG2_MPE); ucc_fast_enable(ugeth->uccf, COMM_DIR_RX_AND_TX); - } else if (!(ugeth->wol_en & WAKE_PHY)) { + } else if (!ugeth->phy_wol_en) { phy_stop(ndev->phydev); } =20 diff --git a/drivers/net/ethernet/freescale/ucc_geth.h b/drivers/net/ethern= et/freescale/ucc_geth.h index c08a56b7c9fe..e08cfc8d8904 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.h +++ b/drivers/net/ethernet/freescale/ucc_geth.h @@ -1217,6 +1217,7 @@ struct ucc_geth_private { int oldduplex; int oldlink; int wol_en; + u32 phy_wol_en; =20 struct device_node *node; }; diff --git a/drivers/net/ethernet/freescale/ucc_geth_ethtool.c b/drivers/ne= t/ethernet/freescale/ucc_geth_ethtool.c index fb5254d7d1ba..89b323ef8145 100644 --- a/drivers/net/ethernet/freescale/ucc_geth_ethtool.c +++ b/drivers/net/ethernet/freescale/ucc_geth_ethtool.c @@ -346,26 +346,48 @@ static void uec_get_wol(struct net_device *netdev, st= ruct ethtool_wolinfo *wol) struct ucc_geth_private *ugeth =3D netdev_priv(netdev); struct phy_device *phydev =3D netdev->phydev; =20 - if (phydev && phydev->irq) - wol->supported |=3D WAKE_PHY; + wol->supported =3D 0; + wol->wolopts =3D 0; + + if (phydev) + phy_ethtool_get_wol(phydev, wol); + if (qe_alive_during_sleep()) wol->supported |=3D WAKE_MAGIC; =20 - wol->wolopts =3D ugeth->wol_en; + wol->wolopts |=3D ugeth->wol_en; } =20 static int uec_set_wol(struct net_device *netdev, struct ethtool_wolinfo *= wol) { struct ucc_geth_private *ugeth =3D netdev_priv(netdev); struct phy_device *phydev =3D netdev->phydev; + int ret =3D 0; =20 - if (wol->wolopts & ~(WAKE_PHY | WAKE_MAGIC)) - return -EINVAL; - else if (wol->wolopts & WAKE_PHY && (!phydev || !phydev->irq)) + if (phydev) { + ret =3D phy_ethtool_set_wol(phydev, wol); + if (ret =3D=3D -EOPNOTSUPP) { + ugeth->phy_wol_en =3D 0; + } else if (ret) { + return ret; + } else { + ugeth->phy_wol_en =3D wol->wolopts; + goto out; + } + } + + /* If the PHY isn't handling the WoL and the MAC is asked to more than + * WAKE_MAGIC, error-out + */ + if (!ugeth->phy_wol_en && + wol->wolopts & ~WAKE_MAGIC) return -EINVAL; - else if (wol->wolopts & WAKE_MAGIC && !qe_alive_during_sleep()) + + if (wol->wolopts & WAKE_MAGIC && + !qe_alive_during_sleep()) return -EINVAL; =20 +out: ugeth->wol_en =3D wol->wolopts; device_set_wakeup_enable(&netdev->dev, ugeth->wol_en); =20 --=20 2.47.0 From nobody Sat Nov 23 02:03:20 2024 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A1C81AAE0B; Thu, 14 Nov 2024 15:36:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731598579; cv=none; b=QCaawJtkLUd977gfpa5xJJvkIQ4JRAnUGK+KkNbSh3K4GwGkqNORYJ4hTGZOqoNWjeeQ/n9cKeaiF6dyhxYfHL/VCTqW4bTd/Sp14fCThPiJvfYipP1WIcKrwZO9eonTh1RYZGzlRCB6IjToXsk6EbUE3N4xRWPRmkjHUGrXbn4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731598579; c=relaxed/simple; bh=iAIwa8BE5d3uS5cAE2NLdrDK1X6VTuX1FoFv8Iq+npA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ABuIbjgv+IiNphXVsuguh1QRAJvMvVl+SCy7c3lbKDUkvEhR+VP12yn5/MF0Q0HLl5HZwSFx0WmDdKD8z69iTDaBBPhgvQOqRwk8Yc4JylXAjGCSBYGVGWc++LdrwQi4tdbasljVm+rhv8XC/HVwpIeBQZWXoVZ0cOs2mhp8/Zc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=QYahOLiF; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="QYahOLiF" Received: by mail.gandi.net (Postfix) with ESMTPSA id 8831D1BF20B; Thu, 14 Nov 2024 15:36:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1731598570; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GX711hqSGvX8B43wBtgMdev5PFTCzhCgQ+es8CQApoM=; b=QYahOLiFcVLSUhzjgCAI1G1Nyic5CJH+jyEQOacbF/zwOwRNJwTmk6BiywGOyNptPyp0XB HL9bskRPwMaPJFqHvvyR8d4ZWfJAxRN+bEx/Ihsf5h2QjKlcPlFxEYcXdfb3yQtXXxvttw /sQy7i0zLdf2AIRLGKidrsiApliygkWFL8uDsy34cZ2a5APN7sq+9S/RemVjH6uPXHUodk hcCtMMNJ7PTerj4mCUzhkEgNIqMhBsHBlCoUuh84yvRqsbxo2f9Zn7ISf7Nk3KToGHo3a4 OLeG2K4xIkZOalQTXG6kYHLxgvU+xUUhtLdTGVHLCpF8IhvP6Lst69AQ5TBSHg== From: Maxime Chevallier To: davem@davemloft.net, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , Christophe Leroy , Heiner Kallweit Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Herve Codina , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linuxppc-dev@lists.ozlabs.org Subject: [PATCH net-next v2 05/10] net: freescale: ucc_geth: Use the correct type to store WoL opts Date: Thu, 14 Nov 2024 16:35:56 +0100 Message-ID: <20241114153603.307872-6-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241114153603.307872-1-maxime.chevallier@bootlin.com> References: <20241114153603.307872-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" The WoL opts are represented through a bitmask stored in a u32. As this mask is copied as-is in the driver, make sure we use the exact same type to store them internally. Signed-off-by: Maxime Chevallier --- V2: New patch drivers/net/ethernet/freescale/ucc_geth.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/ucc_geth.h b/drivers/net/ethern= et/freescale/ucc_geth.h index e08cfc8d8904..60fd804a616a 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.h +++ b/drivers/net/ethernet/freescale/ucc_geth.h @@ -1216,7 +1216,7 @@ struct ucc_geth_private { int oldspeed; int oldduplex; int oldlink; - int wol_en; + u32 wol_en; u32 phy_wol_en; =20 struct device_node *node; --=20 2.47.0 From nobody Sat Nov 23 02:03:20 2024 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C5B71ABEC6; Thu, 14 Nov 2024 15:36:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731598581; cv=none; b=UEPhstMzbLWIDhqNtfpskojrsfQ+3TgLjUtTbZ5vJ51w8BeQYps1leRIjdCVBdAEICF9NXVqH42Hv1v1R3Un/NfXyJPJsnBa/oEYZeikM2I1akam9hBUlOMVvScMuPn55VuJUijRRw1loQzODoGDmp9RM6ivqSDszRgUKpAt6fA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731598581; c=relaxed/simple; bh=D0Ihx6W6vMhkvdWBBTjBM042pgzSMrP8w8JKh+aC7Lc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Cx+s+o0GEyaLTpctassEGqhWe4zT66Thyhjm+y2oA5dC1sIyzIbn8FR6cCoYUMWUhjZkfcIz6uEH/TUrt+aO+X8mtxFa08zMPoxfZYWOh9PAUjUuRFPM3qm+6iCQhWupxtibfEFwj2/rPPRKuwH1GD2ybNdlQYSPtBgEkT5k/PM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=dYQZoJ8G; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="dYQZoJ8G" Received: by mail.gandi.net (Postfix) with ESMTPSA id 522F21BF20C; Thu, 14 Nov 2024 15:36:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1731598571; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=unLNMvXwm+4Ey2QBvMpwyWlJW/nP417xwtjjmRzD8A0=; b=dYQZoJ8GizsCRQNeeh7mP0iuOKIpX2vWhjKhzP9R6JubF51/zwWoT/X8B5NRZJexKLoB63 oR1xrOQgwS+A8Y3E1kzfk0LfZV1CWj/r6OVHE6e/LCMo6QxstbMcjUR93kJx9FJ053kQh8 9ti8pcUIhV8NKnr2+3gHNjSPEBFt5oe/DX3iqnfjUuFn+57hrfrsx4R+bl1p6wBkJbACFi STgplV/jJP5uQkweqQIqtt0tU3tuc8QlnHn5dQbMIPLebL8kx9qkii0cBqjqURksVIpggF 28RjUYmWhPoivm+a42rka9XyXE44yRJxVgp7bok3hAcS77xFQrEJHpcB0ku0Kw== From: Maxime Chevallier To: davem@davemloft.net, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , Christophe Leroy , Heiner Kallweit Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Herve Codina , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linuxppc-dev@lists.ozlabs.org Subject: [PATCH net-next v2 06/10] net: freescale: ucc_geth: Simplify frame length check Date: Thu, 14 Nov 2024 16:35:57 +0100 Message-ID: <20241114153603.307872-7-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241114153603.307872-1-maxime.chevallier@bootlin.com> References: <20241114153603.307872-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" The frame length check is configured when the phy interface is setup. However, it's configured according to an internal flag that is always false. So, just make so that we disable the relevant bit in the MACCFG2 register upon accessing it for other MAC configuration operations. Reviewed-by: Andrew Lunn Signed-off-by: Maxime Chevallier --- V2: No changes drivers/net/ethernet/freescale/ucc_geth.c | 21 +++------------------ drivers/net/ethernet/freescale/ucc_geth.h | 1 - 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethern= et/freescale/ucc_geth.c index 42254ee64a35..7db575a1e710 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.c +++ b/drivers/net/ethernet/freescale/ucc_geth.c @@ -1205,22 +1205,6 @@ static int init_mac_station_addr_regs(u8 address_byt= e_0, return 0; } =20 -static int init_check_frame_length_mode(int length_check, - u32 __iomem *maccfg2_register) -{ - u32 value =3D 0; - - value =3D in_be32(maccfg2_register); - - if (length_check) - value |=3D MACCFG2_LC; - else - value &=3D ~MACCFG2_LC; - - out_be32(maccfg2_register, value); - return 0; -} - static int init_preamble_length(u8 preamble_length, u32 __iomem *maccfg2_register) { @@ -1304,6 +1288,9 @@ static int adjust_enet_interface(struct ucc_geth_priv= ate *ugeth) =20 /* Set MACCFG2 */ maccfg2 =3D in_be32(&ug_regs->maccfg2); + + /* Disable frame length check */ + maccfg2 &=3D ~MACCFG2_LC; maccfg2 &=3D ~MACCFG2_INTERFACE_MODE_MASK; if ((ugeth->max_speed =3D=3D SPEED_10) || (ugeth->max_speed =3D=3D SPEED_100)) @@ -1365,8 +1352,6 @@ static int adjust_enet_interface(struct ucc_geth_priv= ate *ugeth) put_device(&tbiphy->mdio.dev); } =20 - init_check_frame_length_mode(ug_info->lengthCheckRx, &ug_regs->maccfg2); - ret_val =3D init_preamble_length(ug_info->prel, &ug_regs->maccfg2); if (ret_val !=3D 0) { if (netif_msg_probe(ugeth)) diff --git a/drivers/net/ethernet/freescale/ucc_geth.h b/drivers/net/ethern= et/freescale/ucc_geth.h index 60fd804a616a..2365b61c743a 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.h +++ b/drivers/net/ethernet/freescale/ucc_geth.h @@ -1088,7 +1088,6 @@ struct ucc_geth_info { u8 miminumInterFrameGapEnforcement; u8 backToBackInterFrameGap; int ipAddressAlignment; - int lengthCheckRx; u32 mblinterval; u16 nortsrbytetime; u8 fracsiz; --=20 2.47.0 From nobody Sat Nov 23 02:03:20 2024 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4F901A08DB; Thu, 14 Nov 2024 15:36:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731598576; cv=none; b=RGu/akGXPFVJpRII7giS1STHOjPf7dQVp6teOnXm+wjfUGj5BLqZp1zcoqUeUNewyJuMQaimOe5/20jcGScz1EXC9NYFftLopttKNSNhf6KrYH+Q57d3kwaBg0SqxwbZV4MSrhmerb0UFx1SMGSSNXSb/cOm3UyrcAMDOM0xFHU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731598576; c=relaxed/simple; bh=6/ohv3YBaa3NqtukGevwSlGS7o/CG05tJoymm4zSfrM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EIHQpkNF/zGx3OTLW+LPUArjpNLm3Whv1syaoAa4NEb6Fy24HscmozXI4Wn46ryt+bChLTOL3AntAy7baInALgm/xlDyBVXrGR9CpC8Dq9Rk/DhaVPxMNHUduLC7P86LI5hoOXhmRc2HNkVHaTAfESi1sOhFj3GdeKMU20W5d7c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=XF77Mkcy; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="XF77Mkcy" Received: by mail.gandi.net (Postfix) with ESMTPSA id 415461BF204; Thu, 14 Nov 2024 15:36:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1731598571; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hnkEJJ7E36CR1k2VcdbDWHeTGRVqK5i6Dg1xeARjpMk=; b=XF77MkcyE+O5SW14/VffO1uGKkBCM2cVfa2ZSbZNWVs6X0tMeVCW/4uVrf3hl5m6RXoF5u +5N8xqvuThwyr4upKMrjnSUqL73ToBGuARWiBqhG4/gOHqYZC+AF2zwVxR/9IO28TkIKrM oTfXlnyAoQDBQ7G8sbrXX/rii5ASYirBUL2BRM1w+/K9Vpf3sGHzdB9QEpzFfwZ1LkyZIH NWA8bgoVC4kzXNfZ3m0q83d7L/wiw0aMBAKp23how4uQiUF73nSOyDSRsBOhtYYO8HiNFi Rl3SGQ34BkFGmw0p7ofczjzKSzSLXtfWxJ0eW9KQaD/VU4zcYrZHcaoBEH8G9Q== From: Maxime Chevallier To: davem@davemloft.net, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , Christophe Leroy , Heiner Kallweit Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Herve Codina , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linuxppc-dev@lists.ozlabs.org Subject: [PATCH net-next v2 07/10] net: freescale: ucc_geth: Hardcode the preamble length to 7 bytes Date: Thu, 14 Nov 2024 16:35:58 +0100 Message-ID: <20241114153603.307872-8-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241114153603.307872-1-maxime.chevallier@bootlin.com> References: <20241114153603.307872-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" The preamble length can be configured in ucc_geth, however it just ends-up always being configured to 7 bytes, as nothing ever changes the default value of 7. Make that value the default value when the MACCFG2 register gets initialized, and remove the code to configure that value altogether. Reviewed-by: Andrew Lunn Signed-off-by: Maxime Chevallier --- V2: No changes drivers/net/ethernet/freescale/ucc_geth.c | 21 --------------------- drivers/net/ethernet/freescale/ucc_geth.h | 4 ++-- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethern= et/freescale/ucc_geth.c index 7db575a1e710..57e8f0718dc7 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.c +++ b/drivers/net/ethernet/freescale/ucc_geth.c @@ -132,7 +132,6 @@ static const struct ucc_geth_info ugeth_primary_info = =3D { .transmitFlowControl =3D 1, .maxGroupAddrInHash =3D 4, .maxIndAddrInHash =3D 4, - .prel =3D 7, .maxFrameLength =3D 1518+16, /* Add extra bytes for VLANs etc. */ .minFrameLength =3D 64, .maxD1Length =3D 1520+16, /* Add extra bytes for VLANs etc. */ @@ -1205,18 +1204,6 @@ static int init_mac_station_addr_regs(u8 address_byt= e_0, return 0; } =20 -static int init_preamble_length(u8 preamble_length, - u32 __iomem *maccfg2_register) -{ - if ((preamble_length < 3) || (preamble_length > 7)) - return -EINVAL; - - clrsetbits_be32(maccfg2_register, MACCFG2_PREL_MASK, - preamble_length << MACCFG2_PREL_SHIFT); - - return 0; -} - static int init_rx_parameters(int reject_broadcast, int receive_short_frames, int promiscuous, u32 __iomem *upsmr_register) @@ -1276,7 +1263,6 @@ static int adjust_enet_interface(struct ucc_geth_priv= ate *ugeth) struct ucc_geth_info *ug_info; struct ucc_geth __iomem *ug_regs; struct ucc_fast __iomem *uf_regs; - int ret_val; u32 upsmr, maccfg2; u16 value; =20 @@ -1352,13 +1338,6 @@ static int adjust_enet_interface(struct ucc_geth_pri= vate *ugeth) put_device(&tbiphy->mdio.dev); } =20 - ret_val =3D init_preamble_length(ug_info->prel, &ug_regs->maccfg2); - if (ret_val !=3D 0) { - if (netif_msg_probe(ugeth)) - pr_err("Preamble length must be between 3 and 7 inclusive\n"); - return ret_val; - } - return 0; } =20 diff --git a/drivers/net/ethernet/freescale/ucc_geth.h b/drivers/net/ethern= et/freescale/ucc_geth.h index 2365b61c743a..dfb727327093 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.h +++ b/drivers/net/ethernet/freescale/ucc_geth.h @@ -921,7 +921,8 @@ struct ucc_geth_hardware_statistics { #define UCC_GETH_UPSMR_INIT UCC_GETH_UPSMR_RES1 =20 #define UCC_GETH_MACCFG1_INIT 0 -#define UCC_GETH_MACCFG2_INIT (MACCFG2_RESERVED_1) +#define UCC_GETH_MACCFG2_INIT (MACCFG2_RESERVED_1 | \ + (7 << MACCFG2_PREL_SHIFT)) =20 /* Ethernet Address Type. */ enum enet_addr_type { @@ -1113,7 +1114,6 @@ struct ucc_geth_info { int transmitFlowControl; u8 maxGroupAddrInHash; u8 maxIndAddrInHash; - u8 prel; u16 maxFrameLength; u16 minFrameLength; u16 maxD1Length; --=20 2.47.0 From nobody Sat Nov 23 02:03:20 2024 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7542E1A01B9; Thu, 14 Nov 2024 15:36:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731598576; cv=none; b=IpN5YGG6hdN4kG92PdXtC1oI/0q7k69vMHaz3AEZFX6DrLvOQNgTuwMiK1UgJtFvH0YEfHMwBWxKIUzhoKRYRKuMt5TY55lUmLoTUOb8yfrKHub6hWvCkDBIsiCpn8KQY4ZMhrKXJaOO1+0vRXXO7sunAGWWIRJM1OEmnVgoa9s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731598576; c=relaxed/simple; bh=0UsaPE2Uh4SyaFc9Rflbhw3/kdxyOR6CEBmi99Vhh+w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jWsR1z2kCzei3djAYtYxhLafzjpnW/9K8H58TB9zGfzqJ7OD/5rwMucQkudggDL4m0M+5GD1sgvOUZzaYH004LSTdQbDqD3BuR8CjmVKaTFDJ7aTAO9p5Nbb9Au9xaFR7UYspWw5yeZ6Y4fAgmtJN4v7klvhateMz7n1e6l+zW4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=DFiaN64+; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="DFiaN64+" Received: by mail.gandi.net (Postfix) with ESMTPSA id 0D20A1BF207; Thu, 14 Nov 2024 15:36:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1731598572; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1dMKBG+AoRYWHAnDg3HglYfHqu6OSVERdBxJpGegsQM=; b=DFiaN64+rcortkHZ2MvYoDftQM3Z+rhQ8tXu9CzURnWE/b3pfpD2t5c3leJLl1dOAldhZa Wqz+Qf5jy7+3xL5uovFLZaQIO2TM8Lfzyp1gSIOFuVm5f0cldTiemjn6EZLmU9T4+4dedB 3zbTxI+1KC3XRmGDPVlsSmgshTV/wZbIDmhIoeCIqOm0oGImmekvyfUR0+XF7t7gzQOKYe KHqOerpDE7jk/GvgWcYGkHb5AeYWGWslOGgBx6KxmPEDdX8AvZ57GrdJoa1nGU9EW8DQBF abzIHFolSmHqMbh06T3Z1dQPpQJHWjBzGNGqXEtd8Tzc6mNYxFlDlhm09DLvOQ== From: Maxime Chevallier To: davem@davemloft.net, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , Christophe Leroy , Heiner Kallweit Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Herve Codina , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linuxppc-dev@lists.ozlabs.org Subject: [PATCH net-next v2 08/10] net: freescale: ucc_geth: Move the serdes configuration around Date: Thu, 14 Nov 2024 16:35:59 +0100 Message-ID: <20241114153603.307872-9-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241114153603.307872-1-maxime.chevallier@bootlin.com> References: <20241114153603.307872-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" The uec_configure_serdes() function deals with serialized linkmodes settings. It's used during the link bringup sequence. It is planned to be used during the phylink conversion for mac configuration, but it needs to me moved around in the process. To make the phylink port clearer, this commit moves the function without any feature change. Signed-off-by: Maxime Chevallier --- V2: New patch drivers/net/ethernet/freescale/ucc_geth.c | 93 +++++++++++------------ 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethern= et/freescale/ucc_geth.c index 57e8f0718dc7..15d05b270b6e 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.c +++ b/drivers/net/ethernet/freescale/ucc_geth.c @@ -1512,6 +1512,52 @@ static void ugeth_activate(struct ucc_geth_private *= ugeth) __netdev_watchdog_up(ugeth->ndev); } =20 +/* Initialize TBI PHY interface for communicating with the + * SERDES lynx PHY on the chip. We communicate with this PHY + * through the MDIO bus on each controller, treating it as a + * "normal" PHY at the address found in the UTBIPA register. We assume + * that the UTBIPA register is valid. Either the MDIO bus code will set + * it to a value that doesn't conflict with other PHYs on the bus, or the + * value doesn't matter, as there are no other PHYs on the bus. + */ +static void uec_configure_serdes(struct net_device *dev) +{ + struct ucc_geth_private *ugeth =3D netdev_priv(dev); + struct ucc_geth_info *ug_info =3D ugeth->ug_info; + struct phy_device *tbiphy; + + if (!ug_info->tbi_node) { + dev_warn(&dev->dev, "SGMII mode requires that the device tree specify a = tbi-handle\n"); + return; + } + + tbiphy =3D of_phy_find_device(ug_info->tbi_node); + if (!tbiphy) { + dev_err(&dev->dev, "error: Could not get TBI device\n"); + return; + } + + /* + * If the link is already up, we must already be ok, and don't need to + * configure and reset the TBI<->SerDes link. Maybe U-Boot configured + * everything for us? Resetting it takes the link down and requires + * several seconds for it to come back. + */ + if (phy_read(tbiphy, ENET_TBI_MII_SR) & TBISR_LSTATUS) { + put_device(&tbiphy->mdio.dev); + return; + } + + /* Single clk mode, mii mode off(for serdes communication) */ + phy_write(tbiphy, ENET_TBI_MII_ANA, TBIANA_SETTINGS); + + phy_write(tbiphy, ENET_TBI_MII_TBICON, TBICON_CLK_SELECT); + + phy_write(tbiphy, ENET_TBI_MII_CR, TBICR_SETTINGS); + + put_device(&tbiphy->mdio.dev); +} + static void ugeth_link_up(struct ucc_geth_private *ugeth, struct phy_device *phy, phy_interface_t interface, int speed, int duplex) @@ -1619,53 +1665,6 @@ static void adjust_link(struct net_device *dev) ugeth_link_down(ugeth); } =20 -/* Initialize TBI PHY interface for communicating with the - * SERDES lynx PHY on the chip. We communicate with this PHY - * through the MDIO bus on each controller, treating it as a - * "normal" PHY at the address found in the UTBIPA register. We assume - * that the UTBIPA register is valid. Either the MDIO bus code will set - * it to a value that doesn't conflict with other PHYs on the bus, or the - * value doesn't matter, as there are no other PHYs on the bus. - */ -static void uec_configure_serdes(struct net_device *dev) -{ - struct ucc_geth_private *ugeth =3D netdev_priv(dev); - struct ucc_geth_info *ug_info =3D ugeth->ug_info; - struct phy_device *tbiphy; - - if (!ug_info->tbi_node) { - dev_warn(&dev->dev, "SGMII mode requires that the device " - "tree specify a tbi-handle\n"); - return; - } - - tbiphy =3D of_phy_find_device(ug_info->tbi_node); - if (!tbiphy) { - dev_err(&dev->dev, "error: Could not get TBI device\n"); - return; - } - - /* - * If the link is already up, we must already be ok, and don't need to - * configure and reset the TBI<->SerDes link. Maybe U-Boot configured - * everything for us? Resetting it takes the link down and requires - * several seconds for it to come back. - */ - if (phy_read(tbiphy, ENET_TBI_MII_SR) & TBISR_LSTATUS) { - put_device(&tbiphy->mdio.dev); - return; - } - - /* Single clk mode, mii mode off(for serdes communication) */ - phy_write(tbiphy, ENET_TBI_MII_ANA, TBIANA_SETTINGS); - - phy_write(tbiphy, ENET_TBI_MII_TBICON, TBICON_CLK_SELECT); - - phy_write(tbiphy, ENET_TBI_MII_CR, TBICR_SETTINGS); - - put_device(&tbiphy->mdio.dev); -} - /* Configure the PHY for dev. * returns 0 if success. -1 if failure */ --=20 2.47.0 From nobody Sat Nov 23 02:03:20 2024 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 533A119F113; Thu, 14 Nov 2024 15:36:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731598577; cv=none; b=G6JGNIVQ3HQ4n0VTol3HcrjGcYYG/SGy5HoItLuoEA59SCwK9ngNoeALWfnbGpYYWkqSwX1L02E4raMWhcWFpeyshuMa/HOtZnXhRoO+jdE9jOZA8TnrE5Bq+eAdIgX3VACB33f5/F8yV+nqRdDyDBezDxOCONHzvVkPb4wbhkY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731598577; c=relaxed/simple; bh=pagQ4E98llj5WhhVwg5sUuIuZIu2/SnjGoREWIzjN8k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uynCysnXHSvM6vcc6wO5TPJ/YEzwMby9MIzWLlTr0wi/m1AE+Qk2g9OBXh+wkPIoIbmOtVv9PkA0FdqOGBILtCj/6z3PnPUWLH7JEBRGEAN+Ocd6S51wkxKMiLfA5pAE5aHzrjaHIbUl5nfDk31glRCh8ysYQS/3nhK+XMsMfvo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=W+67YXOF; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="W+67YXOF" Received: by mail.gandi.net (Postfix) with ESMTPSA id D47D81BF214; Thu, 14 Nov 2024 15:36:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1731598573; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VD8/1+T7I2KYJ8+l7lEvgJb4z9DYRhu4yhGy99MnF/0=; b=W+67YXOFfNvngolUaEvMFYOYRinl6enMqD5OqOmjXIWHHFOzdBmjrwrUBNQmp7wUJLYcMe F5M+Wf3jWW8MMfYQjcXkIS8EkCg0MvR3z/SbGct+UkK/ctnFz3duQeXPvAWcOhhydmiuSq DTc0gYfpubMHuJqpvt2ZkdbgLABoUDOzeLkM3Hc3PFJXyeaHTljLX2CpWk7jKeyviKYxzr sJouP0/UqDuz9GeM2ReV6PsBpk5o75QQT+gRJSbCW46OHuyj+8YboIecRaVUb0kFfhHJMo ORH0CkWRXITnbTEzk9KwX4sht1y4nAFOS9ufbG29hGiLdVDyySx1gWgm3/OTzg== From: Maxime Chevallier To: davem@davemloft.net, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , Christophe Leroy , Heiner Kallweit Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Herve Codina , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linuxppc-dev@lists.ozlabs.org Subject: [PATCH net-next v2 09/10] net: freescale: ucc_geth: Introduce a helper to check Reduced modes Date: Thu, 14 Nov 2024 16:36:00 +0100 Message-ID: <20241114153603.307872-10-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241114153603.307872-1-maxime.chevallier@bootlin.com> References: <20241114153603.307872-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" A number of parallel MII interfaces also exist in a "Reduced" mode, usually with higher clock rates and fewer data lines, to ease the hardware design. This is what the 'R' stands for in RGMII, RMII, RTBI, RXAUI, etc. The UCC Geth controller has a special configuration bit that needs to be set when the MII mode is one of the supported reduced modes. Add a local helper for that. Signed-off-by: Maxime Chevallier --- V2: New patch drivers/net/ethernet/freescale/ucc_geth.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethern= et/freescale/ucc_geth.c index 15d05b270b6e..ace332d51aa8 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.c +++ b/drivers/net/ethernet/freescale/ucc_geth.c @@ -1258,6 +1258,13 @@ static int init_min_frame_len(u16 min_frame_length, return 0; } =20 +static bool phy_interface_mode_is_reduced(phy_interface_t interface) +{ + return phy_interface_mode_is_rgmii(interface) || + interface =3D=3D PHY_INTERFACE_MODE_RMII || + interface =3D=3D PHY_INTERFACE_MODE_RTBI; +} + static int adjust_enet_interface(struct ucc_geth_private *ugeth) { struct ucc_geth_info *ug_info; @@ -1290,12 +1297,7 @@ static int adjust_enet_interface(struct ucc_geth_pri= vate *ugeth) upsmr =3D in_be32(&uf_regs->upsmr); upsmr &=3D ~(UCC_GETH_UPSMR_RPM | UCC_GETH_UPSMR_R10M | UCC_GETH_UPSMR_TBIM | UCC_GETH_UPSMR_RMM); - if ((ugeth->phy_interface =3D=3D PHY_INTERFACE_MODE_RMII) || - (ugeth->phy_interface =3D=3D PHY_INTERFACE_MODE_RGMII) || - (ugeth->phy_interface =3D=3D PHY_INTERFACE_MODE_RGMII_ID) || - (ugeth->phy_interface =3D=3D PHY_INTERFACE_MODE_RGMII_RXID) || - (ugeth->phy_interface =3D=3D PHY_INTERFACE_MODE_RGMII_TXID) || - (ugeth->phy_interface =3D=3D PHY_INTERFACE_MODE_RTBI)) { + if (phy_interface_mode_is_reduced(ugeth->phy_interface)) { if (ugeth->phy_interface !=3D PHY_INTERFACE_MODE_RMII) upsmr |=3D UCC_GETH_UPSMR_RPM; switch (ugeth->max_speed) { @@ -1594,9 +1596,7 @@ static void ugeth_link_up(struct ucc_geth_private *ug= eth, ~(MACCFG2_INTERFACE_MODE_MASK)) | MACCFG2_INTERFACE_MODE_NIBBLE); /* if reduced mode, re-set UPSMR.R10M */ - if (interface =3D=3D PHY_INTERFACE_MODE_RMII || - phy_interface_mode_is_rgmii(interface) || - interface =3D=3D PHY_INTERFACE_MODE_RTBI) { + if (phy_interface_mode_is_reduced(interface)) { if (speed =3D=3D SPEED_10) upsmr |=3D UCC_GETH_UPSMR_R10M; else --=20 2.47.0 From nobody Sat Nov 23 02:03:20 2024 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8420F1AB503; Thu, 14 Nov 2024 15:36:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731598581; cv=none; b=MGUhTxdjk6g/NLsOlzRrMb/KcwU2Wg7gkx3fU9LwCaWailyGJN1+1nAWYdHaDxd58CuxMstOfpo8OzzMJzAHMBSgir6HzDm8jB4bSwcNmDQM6k8VV9XP44xds/l8mZL/fqMxDTRNfUBcLd24GJIlo+O/7q7xbsQohmzSf+1ssvw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731598581; c=relaxed/simple; bh=rNQnsDFe9Ht8C3CoTzkdeiXUeIZCm1ssR9Qp5IBk1o8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sY63rQgUeQg5ZEX91untIORCa88pI2aF/bbbzz5RAVFiRWGmdgj8tJt1QpFpCPKTi8r1+RaeCczIf6LnTGiqeEsNvCx8YQyPA97MFQjoNE1ch2Xz7mFOIKB9oqcYAQCbqLsEF1kXu8H9PAf3XkQKKGeePQplLJBWrURrvPzKwq8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=Ft4k5AqV; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Ft4k5AqV" Received: by mail.gandi.net (Postfix) with ESMTPSA id A234A1BF215; Thu, 14 Nov 2024 15:36:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1731598574; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KSnEjP1QW60E5BtVvu3jqWOXDYRMgg1lqwlyMHiI+9E=; b=Ft4k5AqV0a959NWv/uJTBs2i2nJDHEdK8INpp0XTHWxALSFRjbblHNN4DneRSs362KI6v6 Edo5She0zQ5Y8FD+KT3ChRmq8wrAa9Lc/uLqTKKDPPrVhl19iDnNbv9BwNb60FNF7rw+/o ITPqI61dNETb7I+p7XChiR/91sKZahYFFkHjUx4+M2v4AxtsFCfZrr1Af0ldsiJ/msYcgb cj6zPUgwdqi6jNOc0o3nUEbf8xm87Dcb7A1hBv5WXm4vEReEnVCt1ESdG5PdR333H0tI0R MDWnGG+3ZkZYZq5I4AQcyVYHRC3GvEQ68PWmLgKfqEYVRkh7WRxr4Rilx+w3sg== From: Maxime Chevallier To: davem@davemloft.net, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , Christophe Leroy , Heiner Kallweit Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Herve Codina , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linuxppc-dev@lists.ozlabs.org Subject: [PATCH net-next v2 10/10] net: freescale: ucc_geth: phylink conversion Date: Thu, 14 Nov 2024 16:36:01 +0100 Message-ID: <20241114153603.307872-11-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241114153603.307872-1-maxime.chevallier@bootlin.com> References: <20241114153603.307872-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: maxime.chevallier@bootlin.com Content-Type: text/plain; charset="utf-8" ucc_geth is quite capable in terms of supported interfaces, and even includes an externally controlled PCS (well, TBI). Port that driver to phylink. Signed-off-by: Maxime Chevallier --- V2: Adjust the WoL sequence, split-out a few things from patches 8/9 drivers/net/ethernet/freescale/Kconfig | 3 +- drivers/net/ethernet/freescale/ucc_geth.c | 438 ++++++++---------- drivers/net/ethernet/freescale/ucc_geth.h | 13 +- .../net/ethernet/freescale/ucc_geth_ethtool.c | 73 +-- 4 files changed, 205 insertions(+), 322 deletions(-) diff --git a/drivers/net/ethernet/freescale/Kconfig b/drivers/net/ethernet/= freescale/Kconfig index 75401d2a5fb4..a2d7300925a8 100644 --- a/drivers/net/ethernet/freescale/Kconfig +++ b/drivers/net/ethernet/freescale/Kconfig @@ -81,8 +81,7 @@ config UCC_GETH tristate "Freescale QE Gigabit Ethernet" depends on QUICC_ENGINE && PPC32 select FSL_PQ_MDIO - select PHYLIB - select FIXED_PHY + select PHYLINK help This driver supports the Gigabit Ethernet mode of the QUICC Engine, which is available on some Freescale SOCs. diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethern= et/freescale/ucc_geth.c index ace332d51aa8..85307e9ea318 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.c +++ b/drivers/net/ethernet/freescale/ucc_geth.c @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include @@ -34,6 +34,7 @@ #include #include #include +#include =20 #include #include @@ -1265,84 +1266,6 @@ static bool phy_interface_mode_is_reduced(phy_interf= ace_t interface) interface =3D=3D PHY_INTERFACE_MODE_RTBI; } =20 -static int adjust_enet_interface(struct ucc_geth_private *ugeth) -{ - struct ucc_geth_info *ug_info; - struct ucc_geth __iomem *ug_regs; - struct ucc_fast __iomem *uf_regs; - u32 upsmr, maccfg2; - u16 value; - - ugeth_vdbg("%s: IN", __func__); - - ug_info =3D ugeth->ug_info; - ug_regs =3D ugeth->ug_regs; - uf_regs =3D ugeth->uccf->uf_regs; - - /* Set MACCFG2 */ - maccfg2 =3D in_be32(&ug_regs->maccfg2); - - /* Disable frame length check */ - maccfg2 &=3D ~MACCFG2_LC; - maccfg2 &=3D ~MACCFG2_INTERFACE_MODE_MASK; - if ((ugeth->max_speed =3D=3D SPEED_10) || - (ugeth->max_speed =3D=3D SPEED_100)) - maccfg2 |=3D MACCFG2_INTERFACE_MODE_NIBBLE; - else if (ugeth->max_speed =3D=3D SPEED_1000) - maccfg2 |=3D MACCFG2_INTERFACE_MODE_BYTE; - maccfg2 |=3D ug_info->padAndCrc; - out_be32(&ug_regs->maccfg2, maccfg2); - - /* Set UPSMR */ - upsmr =3D in_be32(&uf_regs->upsmr); - upsmr &=3D ~(UCC_GETH_UPSMR_RPM | UCC_GETH_UPSMR_R10M | - UCC_GETH_UPSMR_TBIM | UCC_GETH_UPSMR_RMM); - if (phy_interface_mode_is_reduced(ugeth->phy_interface)) { - if (ugeth->phy_interface !=3D PHY_INTERFACE_MODE_RMII) - upsmr |=3D UCC_GETH_UPSMR_RPM; - switch (ugeth->max_speed) { - case SPEED_10: - upsmr |=3D UCC_GETH_UPSMR_R10M; - fallthrough; - case SPEED_100: - if (ugeth->phy_interface !=3D PHY_INTERFACE_MODE_RTBI) - upsmr |=3D UCC_GETH_UPSMR_RMM; - } - } - if ((ugeth->phy_interface =3D=3D PHY_INTERFACE_MODE_TBI) || - (ugeth->phy_interface =3D=3D PHY_INTERFACE_MODE_RTBI)) { - upsmr |=3D UCC_GETH_UPSMR_TBIM; - } - if (ugeth->phy_interface =3D=3D PHY_INTERFACE_MODE_SGMII) - upsmr |=3D UCC_GETH_UPSMR_SGMM; - - out_be32(&uf_regs->upsmr, upsmr); - - /* Disable autonegotiation in tbi mode, because by default it - comes up in autonegotiation mode. */ - /* Note that this depends on proper setting in utbipar register. */ - if ((ugeth->phy_interface =3D=3D PHY_INTERFACE_MODE_TBI) || - (ugeth->phy_interface =3D=3D PHY_INTERFACE_MODE_RTBI)) { - struct ucc_geth_info *ug_info =3D ugeth->ug_info; - struct phy_device *tbiphy; - - if (!ug_info->tbi_node) - pr_warn("TBI mode requires that the device tree specify a tbi-handle\n"= ); - - tbiphy =3D of_phy_find_device(ug_info->tbi_node); - if (!tbiphy) - pr_warn("Could not get TBI device\n"); - - value =3D phy_read(tbiphy, ENET_TBI_MII_CR); - value &=3D ~0x1000; /* Turn off autonegotiation */ - phy_write(tbiphy, ENET_TBI_MII_CR, value); - - put_device(&tbiphy->mdio.dev); - } - - return 0; -} - static int ugeth_graceful_stop_tx(struct ucc_geth_private *ugeth) { struct ucc_fast_private *uccf; @@ -1560,64 +1483,62 @@ static void uec_configure_serdes(struct net_device = *dev) put_device(&tbiphy->mdio.dev); } =20 -static void ugeth_link_up(struct ucc_geth_private *ugeth, - struct phy_device *phy, - phy_interface_t interface, int speed, int duplex) +static void ugeth_mac_link_up(struct phylink_config *config, struct phy_de= vice *phy, + unsigned int mode, phy_interface_t interface, + int speed, int duplex, bool tx_pause, bool rx_pause) { + struct net_device *ndev =3D to_net_dev(config->dev); + struct ucc_geth_private *ugeth =3D netdev_priv(ndev); + struct ucc_geth_info *ug_info =3D ugeth->ug_info; struct ucc_geth __iomem *ug_regs =3D ugeth->ug_regs; struct ucc_fast __iomem *uf_regs =3D ugeth->uccf->uf_regs; - u32 tempval =3D in_be32(&ug_regs->maccfg2); - u32 upsmr =3D in_be32(&uf_regs->upsmr); - int new_state =3D 0; + u32 old_maccfg2, maccfg2 =3D in_be32(&ug_regs->maccfg2); + u32 old_upsmr, upsmr =3D in_be32(&uf_regs->upsmr); =20 - /* Now we make sure that we can be in full duplex mode. - * If not, we operate in half-duplex mode. - */ - if (duplex !=3D ugeth->oldduplex) { - new_state =3D 1; - if (duplex =3D=3D DUPLEX_HALF) - tempval &=3D ~(MACCFG2_FDX); - else - tempval |=3D MACCFG2_FDX; - ugeth->oldduplex =3D duplex; - } + old_maccfg2 =3D maccfg2; + old_upsmr =3D upsmr; + + /* No length check */ + maccfg2 &=3D ~MACCFG2_LC; + maccfg2 &=3D ~MACCFG2_INTERFACE_MODE_MASK; + upsmr &=3D ~(UCC_GETH_UPSMR_RPM | UCC_GETH_UPSMR_R10M | + UCC_GETH_UPSMR_TBIM | UCC_GETH_UPSMR_RMM); + + if (speed =3D=3D SPEED_10 || speed =3D=3D SPEED_100) + maccfg2 |=3D MACCFG2_INTERFACE_MODE_NIBBLE; + else if (speed =3D=3D SPEED_1000) + maccfg2 |=3D MACCFG2_INTERFACE_MODE_BYTE; + + maccfg2 |=3D ug_info->padAndCrc; + + if (phy_interface_mode_is_reduced(interface)) { + + if (interface !=3D PHY_INTERFACE_MODE_RMII) + upsmr |=3D UCC_GETH_UPSMR_RPM; =20 - if (speed !=3D ugeth->oldspeed) { - new_state =3D 1; switch (speed) { - case SPEED_1000: - tempval =3D ((tempval & - ~(MACCFG2_INTERFACE_MODE_MASK)) | - MACCFG2_INTERFACE_MODE_BYTE); - break; - case SPEED_100: case SPEED_10: - tempval =3D ((tempval & - ~(MACCFG2_INTERFACE_MODE_MASK)) | - MACCFG2_INTERFACE_MODE_NIBBLE); - /* if reduced mode, re-set UPSMR.R10M */ - if (phy_interface_mode_is_reduced(interface)) { - if (speed =3D=3D SPEED_10) - upsmr |=3D UCC_GETH_UPSMR_R10M; - else - upsmr &=3D ~UCC_GETH_UPSMR_R10M; - } - break; - default: - if (netif_msg_link(ugeth)) - pr_warn("%s: Speed (%d) is not 10/100/1000!", - netdev_name(ugeth->ndev), speed); - break; + upsmr |=3D UCC_GETH_UPSMR_R10M; + fallthrough; + case SPEED_100: + if (interface !=3D PHY_INTERFACE_MODE_RTBI) + upsmr |=3D UCC_GETH_UPSMR_RMM; } - ugeth->oldspeed =3D speed; } =20 - if (!ugeth->oldlink) { - new_state =3D 1; - ugeth->oldlink =3D 1; - } + if (interface =3D=3D PHY_INTERFACE_MODE_TBI || + interface =3D=3D PHY_INTERFACE_MODE_RTBI) + upsmr |=3D UCC_GETH_UPSMR_TBIM; + + if (interface =3D=3D PHY_INTERFACE_MODE_SGMII) + upsmr |=3D UCC_GETH_UPSMR_SGMM; + + if (duplex =3D=3D DUPLEX_HALF) + maccfg2 &=3D ~(MACCFG2_FDX); + else + maccfg2 |=3D MACCFG2_FDX; =20 - if (new_state) { + if (maccfg2 !=3D old_maccfg2 || upsmr !=3D old_upsmr) { /* * To change the MAC configuration we need to disable * the controller. To do so, we have to either grab @@ -1628,69 +1549,79 @@ static void ugeth_link_up(struct ucc_geth_private *= ugeth, ugeth_quiesce(ugeth); ugeth_disable(ugeth, COMM_DIR_RX_AND_TX); =20 - out_be32(&ug_regs->maccfg2, tempval); + out_be32(&ug_regs->maccfg2, maccfg2); out_be32(&uf_regs->upsmr, upsmr); =20 ugeth_enable(ugeth, COMM_DIR_RX_AND_TX); ugeth_activate(ugeth); } =20 - if (netif_msg_link(ugeth)) - phy_print_status(phy); -} + if (interface =3D=3D PHY_INTERFACE_MODE_SGMII) + uec_configure_serdes(ndev); =20 -static void ugeth_link_down(struct ucc_geth_private *ugeth) -{ - ugeth->oldlink =3D 0; - ugeth->oldspeed =3D 0; - ugeth->oldduplex =3D -1; -} + if (!phylink_autoneg_inband(mode)) { + ug_info->aufc =3D 0; + ug_info->receiveFlowControl =3D rx_pause; + ug_info->transmitFlowControl =3D tx_pause; =20 -/* Called every time the controller might need to be made - * aware of new link state. The PHY code conveys this - * information through variables in the ugeth structure, and this - * function converts those variables into the appropriate - * register values, and can bring down the device if needed. - */ + init_flow_control_params(ug_info->aufc, + ug_info->receiveFlowControl, + ug_info->transmitFlowControl, + ug_info->pausePeriod, + ug_info->extensionField, + &ugeth->uccf->uf_regs->upsmr, + &ugeth->ug_regs->uempr, + &ugeth->ug_regs->maccfg1); + } + + ugeth_enable(ugeth, COMM_DIR_RX_AND_TX); +} =20 -static void adjust_link(struct net_device *dev) +static void ugeth_mac_link_down(struct phylink_config *config, + unsigned int mode, phy_interface_t interface) { - struct ucc_geth_private *ugeth =3D netdev_priv(dev); - struct phy_device *phydev =3D dev->phydev; + struct net_device *ndev =3D to_net_dev(config->dev); + struct ucc_geth_private *ugeth =3D netdev_priv(ndev); =20 - if (phydev->link) - ugeth_link_up(ugeth, phydev, phydev->interface, - phydev->speed, phydev->duplex); - else - ugeth_link_down(ugeth); + ugeth_disable(ugeth, COMM_DIR_RX_AND_TX); } =20 -/* Configure the PHY for dev. - * returns 0 if success. -1 if failure - */ -static int init_phy(struct net_device *dev) +static void ugeth_mac_config(struct phylink_config *config, unsigned int m= ode, + const struct phylink_link_state *state) { - struct ucc_geth_private *priv =3D netdev_priv(dev); - struct ucc_geth_info *ug_info =3D priv->ug_info; - struct phy_device *phydev; + struct net_device *ndev =3D to_net_dev(config->dev); + struct ucc_geth_private *ugeth =3D netdev_priv(ndev); + struct ucc_geth_info *ug_info =3D ugeth->ug_info; + u16 value; =20 - priv->oldlink =3D 0; - priv->oldspeed =3D 0; - priv->oldduplex =3D -1; + if (state->interface =3D=3D PHY_INTERFACE_MODE_TBI || + state->interface =3D=3D PHY_INTERFACE_MODE_RTBI) { + struct phy_device *tbiphy; =20 - phydev =3D of_phy_connect(dev, ug_info->phy_node, &adjust_link, 0, - priv->phy_interface); - if (!phydev) { - dev_err(&dev->dev, "Could not attach to PHY\n"); - return -ENODEV; - } + if (!ug_info->tbi_node) + pr_warn("TBI mode requires that the device tree specify a tbi-handle\n"= ); =20 - if (priv->phy_interface =3D=3D PHY_INTERFACE_MODE_SGMII) - uec_configure_serdes(dev); + tbiphy =3D of_phy_find_device(ug_info->tbi_node); + if (!tbiphy) + pr_warn("Could not get TBI device\n"); =20 - phy_set_max_speed(phydev, priv->max_speed); + value =3D phy_read(tbiphy, ENET_TBI_MII_CR); + value &=3D ~0x1000; /* Turn off autonegotiation */ + phy_write(tbiphy, ENET_TBI_MII_CR, value); =20 - return 0; + put_device(&tbiphy->mdio.dev); + } + + if (phylink_autoneg_inband(mode)) { + ug_info->aufc =3D 1; + + init_flow_control_params(ug_info->aufc, 1, 1, + ug_info->pausePeriod, + ug_info->extensionField, + &ugeth->uccf->uf_regs->upsmr, + &ugeth->ug_regs->uempr, + &ugeth->ug_regs->maccfg1); + } } =20 static void ugeth_dump_regs(struct ucc_geth_private *ugeth) @@ -1962,7 +1893,6 @@ static void ucc_geth_set_multi(struct net_device *dev) static void ucc_geth_stop(struct ucc_geth_private *ugeth) { struct ucc_geth __iomem *ug_regs =3D ugeth->ug_regs; - struct phy_device *phydev =3D ugeth->ndev->phydev; =20 ugeth_vdbg("%s: IN", __func__); =20 @@ -1971,7 +1901,7 @@ static void ucc_geth_stop(struct ucc_geth_private *ug= eth) * Must be done before disabling the controller * or deadlock may happen. */ - phy_stop(phydev); + phylink_stop(ugeth->phylink); =20 /* Disable the controller */ ugeth_disable(ugeth, COMM_DIR_RX_AND_TX); @@ -3213,12 +3143,6 @@ static int ucc_geth_init_mac(struct ucc_geth_private= *ugeth) goto err; } =20 - err =3D adjust_enet_interface(ugeth); - if (err) { - netif_err(ugeth, ifup, dev, "Cannot configure net device, aborting\n"); - goto err; - } - /* Set MACSTNADDR1, MACSTNADDR2 */ /* For more details see the hardware spec. */ init_mac_station_addr_regs(dev->dev_addr[0], @@ -3230,12 +3154,6 @@ static int ucc_geth_init_mac(struct ucc_geth_private= *ugeth) &ugeth->ug_regs->macstnaddr1, &ugeth->ug_regs->macstnaddr2); =20 - err =3D ugeth_enable(ugeth, COMM_DIR_RX_AND_TX); - if (err) { - netif_err(ugeth, ifup, dev, "Cannot enable net device, aborting\n"); - goto err; - } - return 0; err: ucc_geth_stop(ugeth); @@ -3258,10 +3176,10 @@ static int ucc_geth_open(struct net_device *dev) return -EINVAL; } =20 - err =3D init_phy(dev); + err =3D phylink_of_phy_connect(ugeth->phylink, ugeth->dev->of_node, 0); if (err) { - netif_err(ugeth, ifup, dev, "Cannot initialize PHY, aborting\n"); - return err; + dev_err(&dev->dev, "Could not attach to PHY\n"); + return -ENODEV; } =20 err =3D ucc_geth_init_mac(ugeth); @@ -3277,7 +3195,7 @@ static int ucc_geth_open(struct net_device *dev) goto err; } =20 - phy_start(dev->phydev); + phylink_start(ugeth->phylink); napi_enable(&ugeth->napi); netdev_reset_queue(dev); netif_start_queue(dev); @@ -3304,7 +3222,7 @@ static int ucc_geth_close(struct net_device *dev) =20 cancel_work_sync(&ugeth->timeout_work); ucc_geth_stop(ugeth); - phy_disconnect(dev->phydev); + phylink_disconnect_phy(ugeth->phylink); =20 free_irq(ugeth->ug_info->uf_info.irq, ugeth->ndev); =20 @@ -3338,7 +3256,7 @@ static void ucc_geth_timeout_work(struct work_struct = *work) ucc_geth_stop(ugeth); ucc_geth_init_mac(ugeth); /* Must start PHY here */ - phy_start(dev->phydev); + phylink_start(ugeth->phylink); netif_tx_start_all_queues(dev); } =20 @@ -3363,6 +3281,7 @@ static int ucc_geth_suspend(struct platform_device *o= fdev, pm_message_t state) { struct net_device *ndev =3D platform_get_drvdata(ofdev); struct ucc_geth_private *ugeth =3D netdev_priv(ndev); + bool mac_wol =3D false; =20 if (!netif_running(ndev)) return 0; @@ -3380,10 +3299,13 @@ static int ucc_geth_suspend(struct platform_device = *ofdev, pm_message_t state) setbits32(ugeth->uccf->p_uccm, UCC_GETH_UCCE_MPD); setbits32(&ugeth->ug_regs->maccfg2, MACCFG2_MPE); ucc_fast_enable(ugeth->uccf, COMM_DIR_RX_AND_TX); - } else if (!ugeth->phy_wol_en) { - phy_stop(ndev->phydev); + mac_wol =3D true; } =20 + rtnl_lock(); + phylink_suspend(ugeth->phylink, mac_wol); + rtnl_unlock(); + return 0; } =20 @@ -3417,12 +3339,9 @@ static int ucc_geth_resume(struct platform_device *o= fdev) } } =20 - ugeth->oldlink =3D 0; - ugeth->oldspeed =3D 0; - ugeth->oldduplex =3D -1; - - phy_stop(ndev->phydev); - phy_start(ndev->phydev); + rtnl_lock(); + phylink_resume(ugeth->phylink); + rtnl_unlock(); =20 napi_enable(&ugeth->napi); netif_device_attach(ndev); @@ -3437,13 +3356,12 @@ static int ucc_geth_resume(struct platform_device *= ofdev) =20 static int ucc_geth_ioctl(struct net_device *dev, struct ifreq *rq, int cm= d) { + struct ucc_geth_private *ugeth =3D netdev_priv(dev); + if (!netif_running(dev)) return -EINVAL; =20 - if (!dev->phydev) - return -ENODEV; - - return phy_mii_ioctl(dev->phydev, rq, cmd); + return phylink_mii_ioctl(ugeth->phylink, rq, cmd); } =20 static const struct net_device_ops ucc_geth_netdev_ops =3D { @@ -3451,7 +3369,6 @@ static const struct net_device_ops ucc_geth_netdev_op= s =3D { .ndo_stop =3D ucc_geth_close, .ndo_start_xmit =3D ucc_geth_start_xmit, .ndo_validate_addr =3D eth_validate_addr, - .ndo_change_carrier =3D fixed_phy_change_carrier, .ndo_set_mac_address =3D ucc_geth_set_mac_addr, .ndo_set_rx_mode =3D ucc_geth_set_multi, .ndo_tx_timeout =3D ucc_geth_timeout, @@ -3491,6 +3408,12 @@ static int ucc_geth_parse_clock(struct device_node *= np, const char *which, return 0; } =20 +struct phylink_mac_ops ugeth_mac_ops =3D { + .mac_link_up =3D ugeth_mac_link_up, + .mac_link_down =3D ugeth_mac_link_down, + .mac_config =3D ugeth_mac_config, +}; + static int ucc_geth_probe(struct platform_device* ofdev) { struct device *device =3D &ofdev->dev; @@ -3498,8 +3421,10 @@ static int ucc_geth_probe(struct platform_device* of= dev) struct net_device *dev =3D NULL; struct ucc_geth_private *ugeth =3D NULL; struct ucc_geth_info *ug_info; + struct device_node *phy_node; + struct phylink *phylink; struct resource res; - int err, ucc_num, max_speed =3D 0; + int err, ucc_num; const unsigned int *prop; phy_interface_t phy_interface; =20 @@ -3537,26 +3462,19 @@ static int ucc_geth_probe(struct platform_device* o= fdev) ug_info->uf_info.regs =3D res.start; ug_info->uf_info.irq =3D irq_of_parse_and_map(np, 0); =20 - ug_info->phy_node =3D of_parse_phandle(np, "phy-handle", 0); - if (!ug_info->phy_node && of_phy_is_fixed_link(np)) { - /* - * In the case of a fixed PHY, the DT node associated - * to the PHY is the Ethernet MAC DT node. - */ - err =3D of_phy_register_fixed_link(np); - if (err) - return err; - ug_info->phy_node =3D of_node_get(np); - } - /* Find the TBI PHY node. If it's not there, we don't support SGMII */ ug_info->tbi_node =3D of_parse_phandle(np, "tbi-handle", 0); =20 - prop =3D of_get_property(ug_info->phy_node, "interface", NULL); - if (prop) { - dev_err(&ofdev->dev, - "Device-tree property 'interface' is no longer supported. Please use 'p= hy-connection-type' instead."); - goto err_put_tbi; + phy_node =3D of_parse_phandle(np, "phy-handle", 0); + if (phy_node) { + prop =3D of_get_property(phy_node, "interface", NULL); + if (prop) { + dev_err(&ofdev->dev, + "Device-tree property 'interface' is no longer supported. Please use '= phy-connection-type' instead."); + of_node_put(phy_node); + goto err_put_tbi; + } + of_node_put(phy_node); } =20 err =3D of_get_phy_mode(np, &phy_interface); @@ -3565,28 +3483,13 @@ static int ucc_geth_probe(struct platform_device* o= fdev) goto err_put_tbi; } =20 - /* get speed, or derive from PHY interface */ - if (max_speed =3D=3D 0) - switch (phy_interface) { - case PHY_INTERFACE_MODE_GMII: - case PHY_INTERFACE_MODE_RGMII: - case PHY_INTERFACE_MODE_RGMII_ID: - case PHY_INTERFACE_MODE_RGMII_RXID: - case PHY_INTERFACE_MODE_RGMII_TXID: - case PHY_INTERFACE_MODE_TBI: - case PHY_INTERFACE_MODE_RTBI: - case PHY_INTERFACE_MODE_SGMII: - max_speed =3D SPEED_1000; - break; - default: - max_speed =3D SPEED_100; - break; - } - - if (max_speed =3D=3D SPEED_1000) { + if (phy_interface =3D=3D PHY_INTERFACE_MODE_GMII || + phy_interface_mode_is_rgmii(phy_interface) || + phy_interface =3D=3D PHY_INTERFACE_MODE_TBI || + phy_interface =3D=3D PHY_INTERFACE_MODE_RTBI || + phy_interface =3D=3D PHY_INTERFACE_MODE_SGMII) { unsigned int snums =3D qe_get_num_of_snums(); =20 - /* configure muram FIFOs for gigabit operation */ ug_info->uf_info.urfs =3D UCC_GETH_URFS_GIGA_INIT; ug_info->uf_info.urfet =3D UCC_GETH_URFET_GIGA_INIT; ug_info->uf_info.urfset =3D UCC_GETH_URFSET_GIGA_INIT; @@ -3615,7 +3518,7 @@ static int ucc_geth_probe(struct platform_device* ofd= ev) dev =3D devm_alloc_etherdev(&ofdev->dev, sizeof(*ugeth)); if (!dev) { err =3D -ENOMEM; - goto err_deregister_fixed_link; + goto err_put_tbi; } =20 ugeth =3D netdev_priv(dev); @@ -3642,23 +3545,50 @@ static int ucc_geth_probe(struct platform_device* o= fdev) dev->max_mtu =3D 1518; =20 ugeth->msg_enable =3D netif_msg_init(debug.msg_enable, UGETH_MSG_DEFAULT); - ugeth->phy_interface =3D phy_interface; - ugeth->max_speed =3D max_speed; =20 - /* Carrier starts down, phylib will bring it up */ - netif_carrier_off(dev); + ugeth->phylink_config.dev =3D &dev->dev; + ugeth->phylink_config.type =3D PHYLINK_NETDEV; + + ugeth->phylink_config.mac_capabilities =3D + MAC_SYM_PAUSE | MAC_10 | MAC_100 | MAC_1000FD; + + __set_bit(PHY_INTERFACE_MODE_MII, + ugeth->phylink_config.supported_interfaces); + __set_bit(PHY_INTERFACE_MODE_RMII, + ugeth->phylink_config.supported_interfaces); + __set_bit(PHY_INTERFACE_MODE_GMII, + ugeth->phylink_config.supported_interfaces); + phy_interface_set_rgmii(ugeth->phylink_config.supported_interfaces); + + if (ug_info->tbi_node) { + __set_bit(PHY_INTERFACE_MODE_SGMII, + ugeth->phylink_config.supported_interfaces); + __set_bit(PHY_INTERFACE_MODE_TBI, + ugeth->phylink_config.supported_interfaces); + __set_bit(PHY_INTERFACE_MODE_RTBI, + ugeth->phylink_config.supported_interfaces); + } + + phylink =3D phylink_create(&ugeth->phylink_config, dev_fwnode(&dev->dev), + phy_interface, &ugeth_mac_ops); + if (IS_ERR(phylink)) { + err =3D PTR_ERR(phylink); + goto err_put_tbi; + } + + ugeth->phylink =3D phylink; =20 err =3D devm_register_netdev(&ofdev->dev, dev); if (err) { if (netif_msg_probe(ugeth)) pr_err("%s: Cannot register net device, aborting\n", dev->name); - goto err_deregister_fixed_link; + goto err_destroy_phylink; } =20 err =3D of_get_ethdev_address(np, dev); if (err =3D=3D -EPROBE_DEFER) - goto err_deregister_fixed_link; + goto err_destroy_phylink; =20 ugeth->ug_info =3D ug_info; ugeth->dev =3D device; @@ -3667,12 +3597,11 @@ static int ucc_geth_probe(struct platform_device* o= fdev) =20 return 0; =20 -err_deregister_fixed_link: - if (of_phy_is_fixed_link(np)) - of_phy_deregister_fixed_link(np); +err_destroy_phylink: + phylink_destroy(phylink); err_put_tbi: of_node_put(ug_info->tbi_node); - of_node_put(ug_info->phy_node); + return err; } =20 @@ -3680,13 +3609,10 @@ static void ucc_geth_remove(struct platform_device*= ofdev) { struct net_device *dev =3D platform_get_drvdata(ofdev); struct ucc_geth_private *ugeth =3D netdev_priv(dev); - struct device_node *np =3D ofdev->dev.of_node; =20 ucc_geth_memclean(ugeth); - if (of_phy_is_fixed_link(np)) - of_phy_deregister_fixed_link(np); + phylink_destroy(ugeth->phylink); of_node_put(ugeth->ug_info->tbi_node); - of_node_put(ugeth->ug_info->phy_node); } =20 static const struct of_device_id ucc_geth_match[] =3D { diff --git a/drivers/net/ethernet/freescale/ucc_geth.h b/drivers/net/ethern= et/freescale/ucc_geth.h index dfb727327093..38789faae706 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.h +++ b/drivers/net/ethernet/freescale/ucc_geth.h @@ -16,6 +16,7 @@ =20 #include #include +#include #include =20 #include @@ -1074,6 +1075,9 @@ struct ucc_geth_tad_params { u16 vid; }; =20 +struct phylink; +struct phylink_config; + /* GETH protocol initialization structure */ struct ucc_geth_info { struct ucc_fast_info uf_info; @@ -1124,7 +1128,6 @@ struct ucc_geth_info { u32 eventRegMask; u16 pausePeriod; u16 extensionField; - struct device_node *phy_node; struct device_node *tbi_node; u8 weightfactor[NUM_TX_QUEUES]; u8 interruptcoalescingmaxvalue[NUM_RX_QUEUES]; @@ -1209,15 +1212,13 @@ struct ucc_geth_private { u16 skb_dirtytx[NUM_TX_QUEUES]; =20 struct ugeth_mii_info *mii_info; - phy_interface_t phy_interface; - int max_speed; uint32_t msg_enable; - int oldspeed; - int oldduplex; - int oldlink; u32 wol_en; u32 phy_wol_en; =20 + struct phylink *phylink; + struct phylink_config phylink_config; + struct device_node *node; }; =20 diff --git a/drivers/net/ethernet/freescale/ucc_geth_ethtool.c b/drivers/ne= t/ethernet/freescale/ucc_geth_ethtool.c index 89b323ef8145..1fb49e5a414a 100644 --- a/drivers/net/ethernet/freescale/ucc_geth_ethtool.c +++ b/drivers/net/ethernet/freescale/ucc_geth_ethtool.c @@ -103,26 +103,18 @@ static const char rx_fw_stat_gstrings[][ETH_GSTRING_L= EN] =3D { static int uec_get_ksettings(struct net_device *netdev, struct ethtool_link_ksettings= *cmd) { - struct phy_device *phydev =3D netdev->phydev; - - if (!phydev) - return -ENODEV; - - phy_ethtool_ksettings_get(phydev, cmd); + struct ucc_geth_private *ugeth =3D netdev_priv(netdev); =20 - return 0; + return phylink_ethtool_ksettings_get(ugeth->phylink, cmd); } =20 static int uec_set_ksettings(struct net_device *netdev, const struct ethtool_link_ksettings *cmd) { - struct phy_device *phydev =3D netdev->phydev; - - if (!phydev) - return -ENODEV; + struct ucc_geth_private *ugeth =3D netdev_priv(netdev); =20 - return phy_ethtool_ksettings_set(phydev, cmd); + return phylink_ethtool_ksettings_set(ugeth->phylink, cmd); } =20 static void @@ -130,15 +122,8 @@ uec_get_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause) { struct ucc_geth_private *ugeth =3D netdev_priv(netdev); - struct phy_device *phydev =3D netdev->phydev; - - if (phydev) - pause->autoneg =3D phydev->autoneg; =20 - if (ugeth->ug_info->receiveFlowControl) - pause->rx_pause =3D 1; - if (ugeth->ug_info->transmitFlowControl) - pause->tx_pause =3D 1; + return phylink_ethtool_get_pauseparam(ugeth->phylink, pause); } =20 static int @@ -146,31 +131,11 @@ uec_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause) { struct ucc_geth_private *ugeth =3D netdev_priv(netdev); - struct phy_device *phydev =3D netdev->phydev; - int ret =3D 0; =20 ugeth->ug_info->receiveFlowControl =3D pause->rx_pause; ugeth->ug_info->transmitFlowControl =3D pause->tx_pause; =20 - if (phydev && phydev->autoneg) { - if (netif_running(netdev)) { - /* FIXME: automatically restart */ - netdev_info(netdev, "Please re-open the interface\n"); - } - } else { - struct ucc_geth_info *ug_info =3D ugeth->ug_info; - - ret =3D init_flow_control_params(ug_info->aufc, - ug_info->receiveFlowControl, - ug_info->transmitFlowControl, - ug_info->pausePeriod, - ug_info->extensionField, - &ugeth->uccf->uf_regs->upsmr, - &ugeth->ug_regs->uempr, - &ugeth->ug_regs->maccfg1); - } - - return ret; + return phylink_ethtool_set_pauseparam(ugeth->phylink, pause); } =20 static uint32_t @@ -344,13 +309,8 @@ uec_get_drvinfo(struct net_device *netdev, static void uec_get_wol(struct net_device *netdev, struct ethtool_wolinfo = *wol) { struct ucc_geth_private *ugeth =3D netdev_priv(netdev); - struct phy_device *phydev =3D netdev->phydev; - - wol->supported =3D 0; - wol->wolopts =3D 0; =20 - if (phydev) - phy_ethtool_get_wol(phydev, wol); + phylink_ethtool_get_wol(ugeth->phylink, wol); =20 if (qe_alive_during_sleep()) wol->supported |=3D WAKE_MAGIC; @@ -361,19 +321,16 @@ static void uec_get_wol(struct net_device *netdev, st= ruct ethtool_wolinfo *wol) static int uec_set_wol(struct net_device *netdev, struct ethtool_wolinfo *= wol) { struct ucc_geth_private *ugeth =3D netdev_priv(netdev); - struct phy_device *phydev =3D netdev->phydev; int ret =3D 0; =20 - if (phydev) { - ret =3D phy_ethtool_set_wol(phydev, wol); - if (ret =3D=3D -EOPNOTSUPP) { - ugeth->phy_wol_en =3D 0; - } else if (ret) { - return ret; - } else { - ugeth->phy_wol_en =3D wol->wolopts; - goto out; - } + ret =3D phylink_ethtool_set_wol(ugeth->phylink, wol); + if (ret =3D=3D -EOPNOTSUPP) { + ugeth->phy_wol_en =3D 0; + } else if (ret) { + return ret; + } else { + ugeth->phy_wol_en =3D wol->wolopts; + goto out; } =20 /* If the PHY isn't handling the WoL and the MAC is asked to more than --=20 2.47.0