Re: [PATCH net-next v4 2/7] net: dsa: microchip: Add KSZ8463 switch support to KSZ DSA driver
From: Simon Horman
Date: Sun Jul 20 2025 - 06:24:22 EST
On Fri, Jul 18, 2025 at 06:21:01PM -0700, Tristram.Ha@xxxxxxxxxxxxx wrote:
> From: Tristram Ha <tristram.ha@xxxxxxxxxxxxx>
>
> KSZ8463 switch is a 3-port switch based from KSZ8863. Its major
> difference from other KSZ SPI switches is its register access is not a
> simple continual 8-bit transfer with automatic address increase but uses
> a byte-enable mechanism specifying 8-bit, 16-bit, or 32-bit access. Its
> registers are also defined in 16-bit format because it shares a design
> with a MAC controller using 16-bit access. As a result some common
> register accesses need to be re-arranged. The 64-bit access used by
> other switches needs to be broken into 2 32-bit accesses.
>
> This patch adds the basic structure for using KSZ8463. It cannot use the
> same regmap table for other KSZ switches as it interprets the 16-bit
> value as little-endian and its SPI commands are different.
>
> KSZ8463's internal PHYs use standard PHY register definitions so there is
> no need to remap things. However, the hardware has a bug that the high
> word and low word of the PHY id are swapped. In addition the port
> registers are arranged differently so KSZ8463 has its own mapping for
> port registers and PHY registers.
>
> Signed-off-by: Tristram Ha <tristram.ha@xxxxxxxxxxxxx>
...
> diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/ksz8.c
...
> +static inline u16 ksz8463_get_phy_addr(u16 phy, u16 reg, u16 offset)
> +{
> + return offset + reg * 2 + phy * (P2MBCR - P1MBCR);
> +}
nit: Please do not use the inline keyword in .c files,
unless there is a demonstrable (usually performance) reason to do so.
Rather, let the compiler inline (or not) code as it sees fit.
...