From: <Arun.Ramadoss@microchip.com>
To: <olteanv@gmail.com>
Cc: <andrew@lunn.ch>, <linux-kernel@vger.kernel.org>,
<UNGLinuxDriver@microchip.com>, <vivien.didelot@gmail.com>,
<linux@armlinux.org.uk>, <f.fainelli@gmail.com>,
<kuba@kernel.org>, <edumazet@google.com>, <pabeni@redhat.com>,
<netdev@vger.kernel.org>, <Woojung.Huh@microchip.com>,
<davem@davemloft.net>
Subject: Re: [RFC Patch net-next v2 02/15] net: dsa: microchip: move switch chip_id detection to ksz_common
Date: Tue, 14 Jun 2022 07:10:33 +0000 [thread overview]
Message-ID: <3c89c4c484839fb45e4e972c94fcc2da77799942.camel@microchip.com> (raw)
In-Reply-To: <20220613091843.yil3swd55w7kwr5s@skbuf>
Hi Vladimir,
Thanks for the comment.
On Mon, 2022-06-13 at 12:18 +0300, Vladimir Oltean wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
>
> On Mon, May 30, 2022 at 04:12:44PM +0530, Arun Ramadoss wrote:
> > KSZ87xx and KSZ88xx have chip_id representation at reg location 0.
> > And
> > KSZ9477 compatible switch and LAN937x switch have same chip_id
> > detection
> > at location 0x01 and 0x02. To have the common switch detect
> > functionality for ksz switches, ksz_switch_detect function is
> > introduced.
> >
> > Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com>
> > ---
> > drivers/net/dsa/microchip/ksz8795.c | 46 ---------------
> > drivers/net/dsa/microchip/ksz8795_reg.h | 13 -----
> > drivers/net/dsa/microchip/ksz9477.c | 21 -------
> > drivers/net/dsa/microchip/ksz9477_reg.h | 1 -
> > drivers/net/dsa/microchip/ksz_common.c | 78
> > +++++++++++++++++++++++--
> > drivers/net/dsa/microchip/ksz_common.h | 19 +++++-
> > 6 files changed, 92 insertions(+), 86 deletions(-)
> >
> > diff --git a/drivers/net/dsa/microchip/ksz8795.c
> > b/drivers/net/dsa/microchip/ksz8795.c
> > index 12a599d5e61a..927db57d02db 100644
> > --- a/drivers/net/dsa/microchip/ksz8795.c
> > +++ b/drivers/net/dsa/microchip/ksz8795.c
> > @@ -1424,51 +1424,6 @@ static u32 ksz8_get_port_addr(int port, int
> > offset)
> > return PORT_CTRL_ADDR(port, offset);
> > }
> >
> > -static int ksz8_switch_detect(struct ksz_device *dev)
> > -{
> > - u8 id1, id2;
> > - u16 id16;
> > - int ret;
> > -
> > - /* read chip id */
> > - ret = ksz_read16(dev, REG_CHIP_ID0, &id16);
> > - if (ret)
> > - return ret;
> > -
> > - id1 = id16 >> 8;
> > - id2 = id16 & SW_CHIP_ID_M;
> > -
> > - switch (id1) {
> > - case KSZ87_FAMILY_ID:
> > - if ((id2 != CHIP_ID_94 && id2 != CHIP_ID_95))
> > - return -ENODEV;
> > -
> > - if (id2 == CHIP_ID_95) {
> > - u8 val;
> > -
> > - id2 = 0x95;
> > - ksz_read8(dev, REG_PORT_STATUS_0, &val);
>
> Could you replace all remaining occurrences of REG_PORT_STATUS_0 and
> PORT_FIBER_MODE with KSZ8_PORT_STATUS_0 and KSZ8_PORT_FIBER_MODE?
> It would be good to not have multiple definitions for the same thing.
Ok. I will update the macro unique for KSZ8 Switches.
> > - if (val & PORT_FIBER_MODE)
> > - id2 = 0x65;
> > - } else if (id2 == CHIP_ID_94) {
> > - id2 = 0x94;
> > - }
> > - break;
> > - case KSZ88_FAMILY_ID:
> > - if (id2 != CHIP_ID_63)
> > - return -ENODEV;
> > - break;
> > - default:
> > - dev_err(dev->dev, "invalid family id: %d\n", id1);
> > - return -ENODEV;
> > - }
> > - id16 &= ~0xff;
> > - id16 |= id2;
> > - dev->chip_id = id16;
> > -
> > - return 0;
> > -}
> > -
> >
> > diff --git a/drivers/net/dsa/microchip/ksz8795_reg.h
> > b/drivers/net/dsa/microchip/ksz8795_reg.h
> > index 4109433b6b6c..50cdc2a09f5a 100644
> > --- a/drivers/net/dsa/microchip/ksz8795_reg.h
> > +++ b/drivers/net/dsa/microchip/ksz8795_reg.h
> > @@ -14,23 +14,10 @@
> > #define KS_PRIO_M 0x3
> > #define KS_PRIO_S 2
> >
> > -#define REG_CHIP_ID0 0x00
> > -
> > -#define KSZ87_FAMILY_ID 0x87
> > -#define KSZ88_FAMILY_ID 0x88
> > -
> > -#define REG_CHIP_ID1 0x01
> > -
> > -#define SW_CHIP_ID_M 0xF0
> > -#define SW_CHIP_ID_S 4
> > #define SW_REVISION_M 0x0E
> > #define SW_REVISION_S 1
> > #define SW_START 0x01
> >
> > -#define CHIP_ID_94 0x60
> > -#define CHIP_ID_95 0x90
> > -#define CHIP_ID_63 0x30
> > -
> > #define KSZ8863_REG_SW_RESET 0x43
> >
> > #define KSZ8863_GLOBAL_SOFTWARE_RESET BIT(4)
> > diff --git a/drivers/net/dsa/microchip/ksz9477.c
> > b/drivers/net/dsa/microchip/ksz9477.c
> > index 7afc06681c02..7d3c8f6908b6 100644
> > --- a/drivers/net/dsa/microchip/ksz9477.c
> > +++ b/drivers/net/dsa/microchip/ksz9477.c
> > @@ -1360,23 +1360,6 @@ static u32 ksz9477_get_port_addr(int port,
> > int offset)
> > return PORT_CTRL_ADDR(port, offset);
> > }
> >
> >
> > diff --git a/drivers/net/dsa/microchip/ksz9477_reg.h
> > b/drivers/net/dsa/microchip/ksz9477_reg.h
> > index 7a2c8d4767af..077e35ab11b5 100644
> > --- a/drivers/net/dsa/microchip/ksz9477_reg.h
> > +++ b/drivers/net/dsa/microchip/ksz9477_reg.h
> > @@ -25,7 +25,6 @@
> >
> > #define REG_CHIP_ID2__1 0x0002
> >
> > -#define CHIP_ID_63 0x63
> > #define CHIP_ID_66 0x66
> > #define CHIP_ID_67 0x67
> > #define CHIP_ID_77 0x77
> > diff --git a/drivers/net/dsa/microchip/ksz_common.c
> > b/drivers/net/dsa/microchip/ksz_common.c
> > index 9ca8c8d7740f..9057cdb5971c 100644
> > --- a/drivers/net/dsa/microchip/ksz_common.c
> > +++ b/drivers/net/dsa/microchip/ksz_common.c
> > @@ -930,6 +930,72 @@ void ksz_port_stp_state_set(struct dsa_switch
> > *ds, int port,
> > }
> > EXPORT_SYMBOL_GPL(ksz_port_stp_state_set);
> >
> >
> > diff --git a/drivers/net/dsa/microchip/ksz_common.h
> > b/drivers/net/dsa/microchip/ksz_common.h
> > index 8500eaedad67..d16c095cdefb 100644
> > --- a/drivers/net/dsa/microchip/ksz_common.h
> > +++ b/drivers/net/dsa/microchip/ksz_common.h
> > @@ -90,6 +90,7 @@ struct ksz_device {
> >
> > /* chip specific data */
> > u32 chip_id;
> > + u8 chip_rev;
> > int cpu_port; /* port connected to CPU */
> > int phy_port_cnt;
> > phy_interface_t compat_interface;
> > @@ -182,7 +183,6 @@ struct ksz_dev_ops {
> > void (*freeze_mib)(struct ksz_device *dev, int port, bool
> > freeze);
> > void (*port_init_cnt)(struct ksz_device *dev, int port);
> > int (*shutdown)(struct ksz_device *dev);
> > - int (*detect)(struct ksz_device *dev);
> > int (*init)(struct ksz_device *dev);
> > void (*exit)(struct ksz_device *dev);
> > };
> > @@ -353,6 +353,23 @@ static inline void ksz_regmap_unlock(void
> > *__mtx)
> > #define PORT_RX_ENABLE BIT(1)
> > #define PORT_LEARN_DISABLE BIT(0)
> >
> > +/* Switch ID Defines */
> > +#define REG_CHIP_ID0 0x00
> > +
> > +#define SW_FAMILY_ID_M GENMASK(15, 8)
> > +#define KSZ87_FAMILY_ID 0x87
> > +#define KSZ88_FAMILY_ID 0x88
> > +
> > +#define KSZ8_PORT_STATUS_0 0x08
> > +#define KSZ8_PORT_FIBER_MODE BIT(7)
> > +
> > +#define SW_CHIP_ID_M GENMASK(7, 4)
> > +#define CHIP_ID_94 0x6
> > +#define CHIP_ID_95 0x9
>
> KSZ87_CHIP_ID_xxx maybe?
Ok. I will update.
>
> > +#define CHIP_ID_63 0x3
>
> And KSZ88_CHIP_ID_63.
I will rename it this.
>
> > +
> > +#define SW_REV_ID_M GENMASK(7, 4)
> > +
> > /* Regmap tables generation */
> > #define KSZ_SPI_OP_RD 3
> > #define KSZ_SPI_OP_WR 2
> > --
> > 2.36.1
> >
>
>
next prev parent reply other threads:[~2022-06-14 7:10 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-30 10:42 [RFC Patch net-next v2 00/15] net: dsa: microchip: common spi probe for the ksz series switches Arun Ramadoss
2022-05-30 10:42 ` [RFC Patch net-next v2 01/15] net: dsa: microchip: ksz9477: cleanup the ksz9477_switch_detect Arun Ramadoss
2022-06-12 14:20 ` Vladimir Oltean
2022-05-30 10:42 ` [RFC Patch net-next v2 02/15] net: dsa: microchip: move switch chip_id detection to ksz_common Arun Ramadoss
2022-06-13 9:18 ` Vladimir Oltean
2022-06-14 7:10 ` Arun.Ramadoss [this message]
2022-05-30 10:42 ` [RFC Patch net-next v2 03/15] net: dsa: microchip: move tag_protocol & phy read/write " Arun Ramadoss
2022-06-13 9:22 ` Vladimir Oltean
2022-06-15 6:36 ` Arun.Ramadoss
2022-05-30 10:42 ` [RFC Patch net-next v2 04/15] net: dsa: microchip: move vlan functionality " Arun Ramadoss
2022-06-13 9:24 ` Vladimir Oltean
2022-05-30 10:42 ` [RFC Patch net-next v2 05/15] net: dsa: microchip: move the port mirror " Arun Ramadoss
2022-06-13 9:28 ` Vladimir Oltean
2022-06-15 6:40 ` Arun.Ramadoss
2022-05-30 10:42 ` [RFC Patch net-next v2 06/15] net: dsa: microchip: get P_STP_CTRL in ksz_port_stp_state by ksz_dev_ops Arun Ramadoss
2022-06-13 9:31 ` Vladimir Oltean
2022-06-15 6:49 ` Arun.Ramadoss
2022-05-30 10:42 ` [RFC Patch net-next v2 07/15] net: dsa: microchip: update the ksz_phylink_get_caps Arun Ramadoss
2022-06-13 9:32 ` Vladimir Oltean
2022-05-30 10:42 ` [RFC Patch net-next v2 08/15] net: dsa: microchip: update the ksz_port_mdb_add/del Arun Ramadoss
2022-06-13 9:36 ` Vladimir Oltean
2022-05-30 10:42 ` [RFC Patch net-next v2 09/15] net: dsa: microchip: update fdb add/del/dump in ksz_common Arun Ramadoss
2022-06-13 9:42 ` Vladimir Oltean
2022-06-15 6:57 ` Arun.Ramadoss
2022-05-30 10:42 ` [RFC Patch net-next v2 10/15] net: dsa: microchip: move the setup, get_phy_flags & mtu to ksz_common Arun Ramadoss
2022-06-14 8:15 ` Vladimir Oltean
2022-06-15 8:36 ` Arun.Ramadoss
2022-05-30 10:42 ` [RFC Patch net-next v2 11/15] net: dsa: microchip: common dsa_switch_ops for ksz switches Arun Ramadoss
2022-05-30 10:42 ` [RFC Patch net-next v2 12/15] net: dsa: microchip: ksz9477: separate phylink mode from switch register Arun Ramadoss
2022-06-14 8:24 ` Vladimir Oltean
2022-06-15 8:49 ` Arun.Ramadoss
2022-06-15 11:14 ` Russell King (Oracle)
2022-05-30 10:42 ` [RFC Patch net-next v2 13/15] net: dsa: microchip: common menuconfig for ksz series switch Arun Ramadoss
2022-05-30 10:42 ` [RFC Patch net-next v2 14/15] net: dsa: microchip: move ksz_dev_ops to ksz_common.c Arun Ramadoss
2022-05-30 10:42 ` [RFC Patch net-next v2 15/15] net: dsa: microchip: common ksz_spi_probe for ksz switches Arun Ramadoss
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=3c89c4c484839fb45e4e972c94fcc2da77799942.camel@microchip.com \
--to=arun.ramadoss@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=Woojung.Huh@microchip.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=vivien.didelot@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®