lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <SN1PR11MB0446EA5AFB7D5F63167A1C33EC8B0@SN1PR11MB0446.namprd11.prod.outlook.com>
Date:   Wed, 9 Jan 2019 19:58:32 +0000
From:   <Tristram.Ha@...rochip.com>
To:     <marex@...x.de>
CC:     <f.fainelli@...il.com>, <andrew@...n.ch>,
        <Woojung.Huh@...rochip.com>, <netdev@...r.kernel.org>,
        <UNGLinuxDriver@...rochip.com>
Subject: RE: [RFT][PATCH V2 09/10] net: dsa: microchip: Factor out regmap
 config generation into common header

> This is the regmap_config I used in Linux 4.9:
> 
> 	.reg_bits		= SPI_REGMAP_REG,
> 	.val_bits		= SPI_REGMAP_VAL,
> 	.pad_bits		= SPI_REGMAP_PAD,
> 	.read_flag_mask	= KS_SPIOP_RD << SPI_REGMAP_MASK_S,
> 	.write_flag_mask	= KS_SPIOP_WR << SPI_REGMAP_MASK_S,
> 	.reg_format_endian	= REGMAP_ENDIAN_BIG,
> 	.val_format_endian	= REGMAP_ENDIAN_BIG,
> 
> For KSZ9477:
> 
> SPI_CMD_LEN		4
> SPI_REGMAP_PAD	SPI_TURNAROUND_SHIFT
> SPI_REGMAP_VAL	8
> SPI_REGMAP_REG	\
> 	(SPI_CMD_LEN * SPI_REGMAP_VAL - SPI_TURNAROUND_SHIFT)
> SPI_REGMAP_MASK_S	\
> 	(SPI_ADDR_SHIFT + SPI_TURNAROUND_SHIFT - \
> 	(SPI_CMD_LEN * SPI_REGMAP_VAL - 8))
> 
> For KSZ8795:
> 
> SPI_CMD_LEN		2
> SPI_REGMAP_PAD	SPI_TURNAROUND_S
> SPI_REGMAP_VAL	8
> SPI_REGMAP_REG	\
> 	(SPI_CMD_LEN * SPI_REGMAP_VAL - SPI_TURNAROUND_S)
> SPI_REGMAP_MASK_S	\
> 	(SPI_ADDR_S + SPI_TURNAROUND_S - \
> 	(SPI_CMD_LEN * SPI_REGMAP_VAL - 8))
> 
> So the differences between KSZ9477 and KSZ8795 are SPI_CMD_LEN,
> SPI_ADDR_S, and SPI_TURNAROUND_S.
> 
> KSZ9477:
> 
> .reg_bits = 32 - 5 = 27
> .val_bits = 8
> .pad_bits = 5
> .read_flag_mask = KS_SPIOP_RD << 5,
> 
> KSZ8795:
> 
> .reg_bits = 16 - 1 = 15
> .val_bits = 8
> .pad_bits = 1
> .read_flag_mask = KS_SPIOP_RD << 5,
> 
> The regmap.c code uses reg_bits + reg_shift (which comes from pad_bits) to
> decide whether the register space is 16-bit or 32-bit.  The value space is
> always 8-bit.
> 
> The shift for _flag_mask turns out to be the same for both KSZ9477 and
> KSZ8795.

I just looked at your regmap code and you use 3 regmap pointers for specific 8-bit, 16-bit, and 32-bit accesses.  The switch access is always 8-bit.  It has automatic register increment so that you can access arbitrary length of registers.  The use of 16-bit and 32-bit accesses makes access efficient if it makes sense.

Most older switches define registers in 8-bit.  Exceptions are the default VID and indirect access.

A specific switch mostly defines registers in 16-bit because it shares the core design with an Ethernet controller.

KSZ9477 is the newer designed switch and it gets some designs from older switches and that is why it has a mix of 8-bit, 16-bit, and 32-bit register definitions.

In my code I just use regmap_bulk_read and regmap_bulk_write and still use the old spi access functions for specific 8-bit, 16-bit, and 32-bit accesses.

We can combine the logic of ksz_spi_read8 and others into ksz_read8 and so they can be used for both SPI and I2C accesses.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ