From: Vladimir Oltean <olteanv@gmail.com>
To: Michael Walle <michael@walle.cc>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
"David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Andrew Lunn <andrew@lunn.ch>,
Alex Marginean <alexandru.marginean@nxp.com>,
Claudiu Manoil <claudiu.manoil@nxp.com>,
Heiko Thiery <heiko.thiery@gmail.com>,
Russell King - ARM Linux admin <linux@armlinux.org.uk>,
Ioana Ciornei <ioana.ciornei@nxp.com>,
Microchip Linux Driver Support <UNGLinuxDriver@microchip.com>
Subject: Re: [PATCH net-next v6 2/4] net: dsa: felix: (re)use already existing constants
Date: Mon, 13 Jul 2020 19:33:21 +0300 [thread overview]
Message-ID: <20200713163321.5mvc7k6td3t7b4qo@skbuf> (raw)
In-Reply-To: <20200709213526.21972-3-michael@walle.cc>
On Thu, Jul 09, 2020 at 11:35:24PM +0200, Michael Walle wrote:
> Now that there are USXGMII constants available, drop the old definitions
> and reuse the generic ones.
>
> Signed-off-by: Michael Walle <michael@walle.cc>
> ---
I did regression-testing of this on an LS1028A-QDS with SerDes protocol
0x13bb.
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
There was a regression, but it wasn't caused by you.
> drivers/net/dsa/ocelot/felix_vsc9959.c | 45 +++++++-------------------
> 1 file changed, 12 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c
> index 19614537b1ba..a3ddb1394540 100644
> --- a/drivers/net/dsa/ocelot/felix_vsc9959.c
> +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c
> @@ -10,35 +10,15 @@
> #include <soc/mscc/ocelot.h>
> #include <net/pkt_sched.h>
> #include <linux/iopoll.h>
> +#include <linux/mdio.h>
> #include <linux/pci.h>
> #include "felix.h"
>
> #define VSC9959_VCAP_IS2_CNT 1024
> #define VSC9959_VCAP_IS2_ENTRY_WIDTH 376
> #define VSC9959_VCAP_PORT_CNT 6
> -
> -/* TODO: should find a better place for these */
> -#define USXGMII_BMCR_RESET BIT(15)
> -#define USXGMII_BMCR_AN_EN BIT(12)
> -#define USXGMII_BMCR_RST_AN BIT(9)
> -#define USXGMII_BMSR_LNKS(status) (((status) & GENMASK(2, 2)) >> 2)
> -#define USXGMII_BMSR_AN_CMPL(status) (((status) & GENMASK(5, 5)) >> 5)
> -#define USXGMII_ADVERTISE_LNKS(x) (((x) << 15) & BIT(15))
> -#define USXGMII_ADVERTISE_FDX BIT(12)
> -#define USXGMII_ADVERTISE_SPEED(x) (((x) << 9) & GENMASK(11, 9))
> -#define USXGMII_LPA_LNKS(lpa) ((lpa) >> 15)
> -#define USXGMII_LPA_DUPLEX(lpa) (((lpa) & GENMASK(12, 12)) >> 12)
> -#define USXGMII_LPA_SPEED(lpa) (((lpa) & GENMASK(11, 9)) >> 9)
> -
> #define VSC9959_TAS_GCL_ENTRY_MAX 63
>
> -enum usxgmii_speed {
> - USXGMII_SPEED_10 = 0,
> - USXGMII_SPEED_100 = 1,
> - USXGMII_SPEED_1000 = 2,
> - USXGMII_SPEED_2500 = 4,
> -};
> -
> static const u32 vsc9959_ana_regmap[] = {
> REG(ANA_ADVLEARN, 0x0089a0),
> REG(ANA_VLANMASK, 0x0089a4),
> @@ -787,11 +767,10 @@ static void vsc9959_pcs_config_usxgmii(struct phy_device *pcs,
> {
> /* Configure device ability for the USXGMII Replicator */
> phy_write_mmd(pcs, MDIO_MMD_VEND2, MII_ADVERTISE,
> - USXGMII_ADVERTISE_SPEED(USXGMII_SPEED_2500) |
> - USXGMII_ADVERTISE_LNKS(1) |
> + MDIO_LPA_USXGMII_2500FULL |
> + MDIO_LPA_USXGMII_LINK |
> ADVERTISE_SGMII |
> - ADVERTISE_LPACK |
> - USXGMII_ADVERTISE_FDX);
> + ADVERTISE_LPACK);
> }
>
> static void vsc9959_pcs_config(struct ocelot *ocelot, int port,
> @@ -1005,8 +984,8 @@ static void vsc9959_pcs_link_state_usxgmii(struct phy_device *pcs,
> return;
>
> pcs->autoneg = true;
> - pcs->autoneg_complete = USXGMII_BMSR_AN_CMPL(status);
> - pcs->link = USXGMII_BMSR_LNKS(status);
> + pcs->autoneg_complete = !!(status & BMSR_ANEGCOMPLETE);
> + pcs->link = !!(status & BMSR_LSTATUS);
>
> if (!pcs->link || !pcs->autoneg_complete)
> return;
> @@ -1015,24 +994,24 @@ static void vsc9959_pcs_link_state_usxgmii(struct phy_device *pcs,
> if (lpa < 0)
> return;
>
> - switch (USXGMII_LPA_SPEED(lpa)) {
> - case USXGMII_SPEED_10:
> + switch (lpa & MDIO_LPA_USXGMII_SPD_MASK) {
> + case MDIO_LPA_USXGMII_10:
> pcs->speed = SPEED_10;
> break;
> - case USXGMII_SPEED_100:
> + case MDIO_LPA_USXGMII_100:
> pcs->speed = SPEED_100;
> break;
> - case USXGMII_SPEED_1000:
> + case MDIO_LPA_USXGMII_1000:
> pcs->speed = SPEED_1000;
> break;
> - case USXGMII_SPEED_2500:
> + case MDIO_LPA_USXGMII_2500:
> pcs->speed = SPEED_2500;
> break;
> default:
> break;
> }
>
> - if (USXGMII_LPA_DUPLEX(lpa))
> + if (lpa & MDIO_LPA_USXGMII_FULL_DUPLEX)
> pcs->duplex = DUPLEX_FULL;
> else
> pcs->duplex = DUPLEX_HALF;
> --
> 2.20.1
>
next prev parent reply other threads:[~2020-07-13 16:33 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-09 21:35 [PATCH net-next v6 0/4] net: enetc: remove bootloader dependency Michael Walle
2020-07-09 21:35 ` [PATCH net-next v6 1/4] net: phy: add USXGMII link partner ability constants Michael Walle
2020-07-13 16:34 ` Vladimir Oltean
2020-07-13 17:01 ` Andrew Lunn
2020-07-13 17:07 ` Michael Walle
2020-07-13 18:16 ` Russell King - ARM Linux admin
2020-07-13 18:23 ` Russell King - ARM Linux admin
2020-07-13 18:37 ` Michael Walle
2020-07-15 20:33 ` Michael Walle
2020-07-15 22:44 ` Vladimir Oltean
2020-07-16 7:49 ` Michael Walle
2020-07-09 21:35 ` [PATCH net-next v6 2/4] net: dsa: felix: (re)use already existing constants Michael Walle
2020-07-13 16:33 ` Vladimir Oltean [this message]
2020-07-09 21:35 ` [PATCH net-next v6 3/4] net: enetc: Initialize SerDes for SGMII and USXGMII protocols Michael Walle
2020-07-13 16:38 ` Vladimir Oltean
2020-07-09 21:35 ` [PATCH net-next v6 4/4] net: enetc: Use DT protocol information to set up the ports Michael Walle
2020-07-13 16:39 ` Vladimir Oltean
2020-07-11 7:52 ` [PATCH net-next v6 0/4] net: enetc: remove bootloader dependency Vladimir Oltean
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200713163321.5mvc7k6td3t7b4qo@skbuf \
--to=olteanv@gmail.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandru.marginean@nxp.com \
--cc=andrew@lunn.ch \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=heiko.thiery@gmail.com \
--cc=ioana.ciornei@nxp.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=michael@walle.cc \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox