Re: [PATCH net-next v5 2/6] net: dsa: microchip: Add KSZ8463 switch support to KSZ DSA driver

From: Andrew Lunn
Date: Wed Jul 23 2025 - 13:16:22 EST


> 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.

> + if (ksz_is_ksz8463(dev)) {
> + int i;
> +
> + for (i = 0; i < 2; i++)
> + ret = regmap_read(ksz_regmap_32(dev), reg + i * 4,
> + &value[i]);
> + *val = (u64)value[0] << 32 | value[1];
> + return ret;
> + }
> ret = regmap_bulk_read(ksz_regmap_32(dev), reg, value, 2);

This needs a bit more explanation. When i look at

https://elixir.bootlin.com/linux/v6.15.7/source/drivers/base/regmap/regmap.c#L3117

It appears to do something similar, looping over count doing
_regmap_read().

There is also:

https://elixir.bootlin.com/linux/v6.15.7/source/include/linux/regmap.h#L370

* @use_single_read: If set, converts the bulk read operation into a series of
* single read operations. This is useful for a device that
* does not support bulk read.
* @use_single_write: If set, converts the bulk write operation into a series of
* single write operations. This is useful for a device that
* does not support bulk write.

It would be better if regmap_bulk_read() could be made to work, and
hide away the differences, which is what regmap is all about.

Andrew