From: Andrew Lunn <andrew@lunn.ch>
To: Prasanna Vengateshan <prasanna.vengateshan@microchip.com>
Cc: netdev@vger.kernel.org, olteanv@gmail.com, robh+dt@kernel.org,
UNGLinuxDriver@microchip.com, woojung.huh@microchip.com,
hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net,
kuba@kernel.org, linux-kernel@vger.kernel.org,
vivien.didelot@gmail.com, f.fainelli@gmail.com,
devicetree@vger.kernel.org
Subject: Re: [PATCH v9 net-next 06/11] net: dsa: microchip: add DSA support for microchip lan937x
Date: Sun, 20 Mar 2022 02:17:29 +0100 [thread overview]
Message-ID: <YjaAqXfiBrMggIdA@lunn.ch> (raw)
In-Reply-To: <20220318085540.281721-7-prasanna.vengateshan@microchip.com>
> +int lan937x_reset_switch(struct ksz_device *dev)
> +{
> + u32 data32;
> + u8 data8;
> + int ret;
> +
> + /* reset switch */
> + ret = lan937x_cfg(dev, REG_SW_OPERATION, SW_RESET, true);
> + if (ret < 0)
> + return ret;
> +
> + ret = ksz_read8(dev, REG_SW_LUE_CTRL_1, &data8);
> + if (ret < 0)
> + return ret;
> +
> + /* Enable Auto Aging */
> + ret = ksz_write8(dev, REG_SW_LUE_CTRL_1, data8 | SW_LINK_AUTO_AGING);
> + if (ret < 0)
> + return ret;
> +
> + /* disable interrupts */
> + ret = ksz_write32(dev, REG_SW_INT_MASK__4, SWITCH_INT_MASK);
> + if (ret < 0)
> + return ret;
> +
> + ret = ksz_write32(dev, REG_SW_PORT_INT_MASK__4, 0xFF);
> + if (ret < 0)
> + return ret;
> +
> + return ksz_read32(dev, REG_SW_PORT_INT_STATUS__4, &data32);
I would probably enable auto aging in the setup routing, not the
reset. Disabling interrupts is less clear, maybe it also belongs in
setup?
> +static void lan937x_switch_exit(struct ksz_device *dev)
> +{
> + lan937x_reset_switch(dev);
> +}
Humm. Does a reset leave the switch in a dumb mode, or is it totally
disabled?
> +int lan937x_internal_phy_write(struct ksz_device *dev, int addr, int reg,
> + u16 val)
> +{
> + u16 temp, addr_base;
> + unsigned int value;
> + int ret;
> +
> + /* Check for internal phy port */
> + if (!lan937x_is_internal_phy_port(dev, addr))
> + return -EOPNOTSUPP;
> +
> + if (lan937x_is_internal_base_tx_phy_port(dev, addr))
> + addr_base = REG_PORT_TX_PHY_CTRL_BASE;
> + else
> + addr_base = REG_PORT_T1_PHY_CTRL_BASE;
> +
> + temp = PORT_CTRL_ADDR(addr, (addr_base + (reg << 2)));
> +
> + ret = ksz_write16(dev, REG_VPHY_IND_ADDR__2, temp);
> + if (ret < 0)
> + return ret;
...
> +}
> +
> +int lan937x_internal_phy_read(struct ksz_device *dev, int addr, int reg,
> + u16 *val)
> +{
> + u16 temp, addr_base;
> + unsigned int value;
> + int ret;
> +
> + /* Check for internal phy port, return 0xffff for non-existent phy */
> + if (!lan937x_is_internal_phy_port(dev, addr))
> + return 0xffff;
> +
> + if (lan937x_is_internal_base_tx_phy_port(dev, addr))
> + addr_base = REG_PORT_TX_PHY_CTRL_BASE;
> + else
> + addr_base = REG_PORT_T1_PHY_CTRL_BASE;
> +
> + /* get register address based on the logical port */
> + temp = PORT_CTRL_ADDR(addr, (addr_base + (reg << 2)));
> +
> + ret = ksz_write16(dev, REG_VPHY_IND_ADDR__2, temp);
> + if (ret < 0)
> + return ret;
Looks pretty similar to me. You should pull this out into a helper.
> +void lan937x_port_setup(struct ksz_device *dev, int port, bool cpu_port)
> +{
> + struct dsa_switch *ds = dev->ds;
> + u8 member;
> +
> + /* enable tag tail for host port */
> + if (cpu_port) {
> + lan937x_port_cfg(dev, port, REG_PORT_CTRL_0,
> + PORT_TAIL_TAG_ENABLE, true);
> + }
Checkpatch probably warns here that the {} are not needed.
> +
> + /* disable frame check length field */
> + lan937x_port_cfg(dev, port, REG_PORT_MAC_CTRL_0, PORT_FR_CHK_LENGTH,
> + false);
> +
> + /* set back pressure for half duplex */
> + lan937x_port_cfg(dev, port, REG_PORT_MAC_CTRL_1, PORT_BACK_PRESSURE,
> + true);
> +
> + /* enable 802.1p priority */
> + lan937x_port_cfg(dev, port, P_PRIO_CTRL, PORT_802_1P_PRIO_ENABLE, true);
> +
> + if (!lan937x_is_internal_phy_port(dev, port)) {
> + /* enable flow control */
> + lan937x_port_cfg(dev, port, REG_PORT_XMII_CTRL_0,
> + PORT_TX_FLOW_CTRL | PORT_RX_FLOW_CTRL,
> + true);
> + }
Here as well.
> +struct lan_alu_struct {
> + /* entry 1 */
> + u8 is_static:1;
> + u8 is_src_filter:1;
> + u8 is_dst_filter:1;
> + u8 prio_age:3;
> + u32 _reserv_0_1:23;
> + u8 mstp:3;
I assume this works O.K, but bitfields are nornaly defined using one
type. I would of used u32 for them all. Is there some advantage of
missing u8 and u32?
> + /* entry 2 */
> + u8 is_override:1;
> + u8 is_use_fid:1;
> + u32 _reserv_1_1:22;
> + u8 port_forward:8;
> + /* entry 3 & 4*/
> + u32 _reserv_2_1:9;
> + u8 fid:7;
> + u8 mac[ETH_ALEN];
> +};
Andrew
next prev parent reply other threads:[~2022-03-20 1:17 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-18 8:55 [PATCH v9 net-next 00/11] net: dsa: microchip: DSA driver support for LAN937x switch Prasanna Vengateshan
2022-03-18 8:55 ` [PATCH v9 net-next 01/11] dt-bindings: net: make internal-delay-ps based on phy-mode Prasanna Vengateshan
2022-03-20 0:41 ` Andrew Lunn
2022-03-20 2:13 ` Rob Herring
2022-03-18 8:55 ` [PATCH v9 net-next 02/11] dt-bindings: net: add mdio property Prasanna Vengateshan
2022-03-20 0:41 ` Andrew Lunn
2022-03-21 23:27 ` Rob Herring
2022-03-22 14:46 ` Prasanna Vengateshan
2022-03-22 14:56 ` Rob Herring
2022-03-18 8:55 ` [PATCH v9 net-next 03/11] dt-bindings: net: dsa: dt bindings for microchip lan937x Prasanna Vengateshan
2022-03-20 0:49 ` Andrew Lunn
2022-03-21 20:19 ` Prasanna Vengateshan
2022-03-18 8:55 ` [PATCH v9 net-next 04/11] net: dsa: move mib->cnt_ptr reset code to ksz_common.c Prasanna Vengateshan
2022-03-18 8:55 ` [PATCH v9 net-next 05/11] net: dsa: tag_ksz: add tag handling for Microchip LAN937x Prasanna Vengateshan
2022-03-18 8:55 ` [PATCH v9 net-next 06/11] net: dsa: microchip: add DSA support for microchip lan937x Prasanna Vengateshan
2022-03-20 1:17 ` Andrew Lunn [this message]
2022-03-21 20:09 ` Prasanna Vengateshan
2022-03-18 8:55 ` [PATCH v9 net-next 07/11] net: dsa: microchip: add support for phylink management Prasanna Vengateshan
2022-03-18 8:55 ` [PATCH v9 net-next 08/11] net: dsa: microchip: add support for ethtool port counters Prasanna Vengateshan
2022-03-20 1:26 ` Andrew Lunn
2022-03-21 19:33 ` Prasanna Vengateshan
2022-03-18 8:55 ` [PATCH v9 net-next 09/11] net: dsa: microchip: add support for port mirror operations Prasanna Vengateshan
2022-03-18 11:00 ` Vladimir Oltean
2022-03-21 20:22 ` Prasanna Vengateshan
2022-03-18 8:55 ` [PATCH v9 net-next 10/11] net: dsa: microchip: add support for fdb and mdb management Prasanna Vengateshan
2022-03-18 8:55 ` [PATCH v9 net-next 11/11] net: dsa: microchip: add support for vlan operations Prasanna Vengateshan
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=YjaAqXfiBrMggIdA@lunn.ch \
--to=andrew@lunn.ch \
--cc=UNGLinuxDriver@microchip.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@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=prasanna.vengateshan@microchip.com \
--cc=robh+dt@kernel.org \
--cc=vivien.didelot@gmail.com \
--cc=woojung.huh@microchip.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).