net: dsa: microchip: Factor out regmap config generation into common header
The regmap config tables are rather similar for various generations of the KSZ8xxx/KSZ9xxx switches. Introduce a macro which allows generating those tables without duplication. Note that $regalign parameter is not used right now, but will be used in KSZ87xx series switches. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Andrew Lunn <andrew@lunn.ch> Cc: Florian Fainelli <f.fainelli@gmail.com> Cc: Tristram Ha <Tristram.Ha@microchip.com> Cc: Woojung Huh <Woojung.Huh@microchip.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
ee394fea6f
commit
255b59ad0d
@@ -133,4 +133,36 @@ static inline u32 ksz_pread32_poll(struct ksz_poll_ctx *ctx)
|
||||
return data;
|
||||
}
|
||||
|
||||
/* Regmap tables generation */
|
||||
#define KSZ_SPI_OP_RD 3
|
||||
#define KSZ_SPI_OP_WR 2
|
||||
|
||||
#define KSZ_SPI_OP_FLAG_MASK(opcode, swp, regbits, regpad) \
|
||||
swab##swp((opcode) << ((regbits) + (regpad)))
|
||||
|
||||
#define KSZ_REGMAP_ENTRY(width, swp, regbits, regpad, regalign) \
|
||||
{ \
|
||||
.val_bits = (width), \
|
||||
.reg_stride = (width) / 8, \
|
||||
.reg_bits = (regbits) + (regalign), \
|
||||
.pad_bits = (regpad), \
|
||||
.max_register = BIT(regbits) - 1, \
|
||||
.cache_type = REGCACHE_NONE, \
|
||||
.read_flag_mask = \
|
||||
KSZ_SPI_OP_FLAG_MASK(KSZ_SPI_OP_RD, swp, \
|
||||
regbits, regpad), \
|
||||
.write_flag_mask = \
|
||||
KSZ_SPI_OP_FLAG_MASK(KSZ_SPI_OP_WR, swp, \
|
||||
regbits, regpad), \
|
||||
.reg_format_endian = REGMAP_ENDIAN_BIG, \
|
||||
.val_format_endian = REGMAP_ENDIAN_BIG \
|
||||
}
|
||||
|
||||
#define KSZ_REGMAP_TABLE(ksz, swp, regbits, regpad, regalign) \
|
||||
static const struct regmap_config ksz##_regmap_config[] = { \
|
||||
KSZ_REGMAP_ENTRY(8, swp, (regbits), (regpad), (regalign)), \
|
||||
KSZ_REGMAP_ENTRY(16, swp, (regbits), (regpad), (regalign)), \
|
||||
KSZ_REGMAP_ENTRY(32, swp, (regbits), (regpad), (regalign)), \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user