Skip to content

Commit e3d4ee7

Browse files
Thomas Koppmarckleinebudde
authored andcommitted
can: mcp251xfd: mcp251xfd_regmap_crc_read(): update workaround broken CRC on TBC register
The mcp251xfd compatible chips have an erratum ([1], [2]), where the received CRC doesn't match the calculated CRC. In commit c7eb923 ("can: mcp251xfd: mcp251xfd_regmap_crc_read(): work around broken CRC on TBC register") the following workaround was implementierend. - If a CRC read error on the TBC register is detected and the first byte is 0x00 or 0x80, the most significant bit of the first byte is flipped and the CRC is calculated again. - If the CRC now matches, the _original_ data is passed to the reader. For now we assume transferred data was OK. New investigations and simulations indicate that the CRC send by the device is calculated on correct data, and the data is incorrectly received by the SPI host controller. Use flipped instead of original data and update workaround description in mcp251xfd_regmap_crc_read(). [1] mcp2517fd: DS80000792C: "Incorrect CRC for certain READ_CRC commands" [2] mcp2518fd: DS80000789C: "Incorrect CRC for certain READ_CRC commands" Link: https://lore.kernel.org/all/DM4PR11MB53901D49578FE265B239E55AFB7C9@DM4PR11MB5390.namprd11.prod.outlook.com Fixes: c7eb923 ("can: mcp251xfd: mcp251xfd_regmap_crc_read(): work around broken CRC on TBC register") Cc: [email protected] Signed-off-by: Thomas Kopp <[email protected]> [mkl: split into 2 patches, update patch description and documentation] Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 406cc9c commit e3d4ee7

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

drivers/net/can/spi/mcp251xfd/mcp251xfd-regmap.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,8 @@ mcp251xfd_regmap_crc_read(void *context,
343343
*
344344
* If the highest bit in the lowest byte is flipped
345345
* the transferred CRC matches the calculated one. We
346-
* assume for now the CRC calculation in the chip
347-
* works on wrong data and the transferred data is
348-
* correct.
346+
* assume for now the CRC operates on the correct
347+
* data.
349348
*/
350349
if (reg == MCP251XFD_REG_TBC &&
351350
((buf_rx->data[0] & 0xf8) == 0x0 ||
@@ -359,10 +358,8 @@ mcp251xfd_regmap_crc_read(void *context,
359358
val_len);
360359
if (!err) {
361360
/* If CRC is now correct, assume
362-
* transferred data was OK, flip bit
363-
* back to original value.
361+
* flipped data is OK.
364362
*/
365-
buf_rx->data[0] ^= 0x80;
366363
goto out;
367364
}
368365
}

0 commit comments

Comments
 (0)