Skip to content

Commit 962845d

Browse files
Dong Aishengmarckleinebudde
authored andcommitted
can: m_can: add missing message RAM initialization
The M_CAN message RAM is usually equipped with a parity or ECC functionality. But RAM cells suffer a hardware reset and can therefore hold arbitrary content at startup - including parity and/or ECC bits. To prevent the M_CAN controller detecting checksum errors when reading potentially uninitialized TX message RAM content to transmit CAN frames the TX message RAM has to be written with (any kind of) initial data. Signed-off-by: Dong Aisheng <b29396@freescale.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
1 parent efe2228 commit 962845d

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎drivers/net/can/m_can/m_can.c‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ static int m_can_of_parse_mram(struct platform_device *pdev,
10101010
struct resource *res;
10111011
void __iomem *addr;
10121012
u32 out_val[MRAM_CFG_LEN];
1013-
int ret;
1013+
int i, start, end, ret;
10141014

10151015
/* message ram could be shared */
10161016
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "message_ram");
@@ -1061,6 +1061,15 @@ static int m_can_of_parse_mram(struct platform_device *pdev,
10611061
priv->mcfg[MRAM_TXE].off, priv->mcfg[MRAM_TXE].num,
10621062
priv->mcfg[MRAM_TXB].off, priv->mcfg[MRAM_TXB].num);
10631063

1064+
/* initialize the entire Message RAM in use to avoid possible
1065+
* ECC/parity checksum errors when reading an uninitialized buffer
1066+
*/
1067+
start = priv->mcfg[MRAM_SIDF].off;
1068+
end = priv->mcfg[MRAM_TXB].off +
1069+
priv->mcfg[MRAM_TXB].num * TXB_ELEMENT_SIZE;
1070+
for (i = start; i < end; i += 4)
1071+
writel(0x0, priv->mram_base + i);
1072+
10641073
return 0;
10651074
}
10661075

0 commit comments

Comments
 (0)