aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/can/flexcan.c
diff options
context:
space:
mode:
authorPankaj Bansal <pankaj.bansal@nxp.com>2018-08-28 23:19:12 +0530
committerMarc Kleine-Budde <mkl@pengutronix.de>2018-11-28 16:52:25 +0100
commit6cbf76028dcac01129211828d62314285231f79e (patch)
treeb4d366eadf773dd86c964ea6fe5c1ff7283e7fee /drivers/net/can/flexcan.c
parentcan: flexcan: Add provision for variable payload size (diff)
downloadlinux-dev-6cbf76028dcac01129211828d62314285231f79e.tar.xz
linux-dev-6cbf76028dcac01129211828d62314285231f79e.zip
can: flexcan: split the Message Buffer RAM area
The message buffer RAM area is not a contiguous 1KB area but 2 partitions of 512 bytes each. Till now, we used Message buffers with payload size 8 bytes, which translates to 32 MBs per partition and no spare space is left in any partition. However, in upcoming SOC LX2160A the message buffers can have payload size 64 bytes. This results in less than 32 MBs per partition and some empty area is left at the end of each partition.This empty area should not be accessed. Therefore, split the Message Buffer RAM area into two partitions. Signed-off-by: Pankaj Bansal <pankaj.bansal@nxp.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/can/flexcan.c')
-rw-r--r--drivers/net/can/flexcan.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index ecb50b1bd849..0f36eafe3ac1 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -225,7 +225,7 @@ struct flexcan_regs {
u32 rxfgmask; /* 0x48 */
u32 rxfir; /* 0x4c */
u32 _reserved3[12]; /* 0x50 */
- u8 mb[1024]; /* 0x80 */
+ u8 mb[2][512]; /* 0x80 */
/* FIFO-mode:
* MB
* 0x080...0x08f 0 RX message buffer
@@ -369,11 +369,20 @@ static inline void flexcan_write_le(u32 val, void __iomem *addr)
static struct flexcan_mb __iomem *flexcan_get_mb(const struct flexcan_priv *priv,
u8 mb_index)
{
+ u8 bank_size;
+ bool bank;
+
if (WARN_ON(mb_index >= priv->mb_count))
return NULL;
+ bank_size = sizeof(priv->regs->mb[0]) / priv->mb_size;
+
+ bank = mb_index >= bank_size;
+ if (bank)
+ mb_index -= bank_size;
+
return (struct flexcan_mb __iomem *)
- (&priv->regs->mb[priv->mb_size * mb_index]);
+ (&priv->regs->mb[bank][priv->mb_size * mb_index]);
}
static void flexcan_enable_wakeup_irq(struct flexcan_priv *priv, bool enable)
@@ -1223,7 +1232,8 @@ static int flexcan_open(struct net_device *dev)
goto out_close;
priv->mb_size = sizeof(struct flexcan_mb) + CAN_MAX_DLEN;
- priv->mb_count = sizeof(priv->regs->mb) / priv->mb_size;
+ priv->mb_count = (sizeof(priv->regs->mb[0]) / priv->mb_size) +
+ (sizeof(priv->regs->mb[1]) / priv->mb_size);
if (priv->devtype_data->quirks & FLEXCAN_QUIRK_USE_OFF_TIMESTAMP)
priv->tx_mb_reserved =