Add D_CAN Module RAM Init
PATCH 1/1 net: can: c_can_platform: Add D_CAN Module RAM Init
In reply to [email protected]From: Thor Thayer <[email protected]>
The D_CAN driver was written to support the TI D_CAN implementation which placed the D_CAN RAM reset in a separate register. In the standard D_CAN module case the RAM Init is in the D_CAN module so handle the RAM Init differently.
--- drivers/net/can/c_can/c_can.h | 3 +++ drivers/net/can/c_can/c_can_platform.c | 21 ++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-)
drivers/net/can/c_can/c_can.h +3 -0
@@ -61,6 +61,7 @@ enum reg {C_CAN_INTPND2_REG ,C_CAN_MSGVAL1_REG ,C_CAN_MSGVAL2_REG , + C_CAN_FUNCTION_REG, }; static const u16 reg_map_c_can[] = {
@@ -112,6 +113,7 @@ static const u16 reg_map_d_can[] = { [C_CAN_BRPEXT_REG] = 0x0E, [C_CAN_INT_REG] = 0x10, [C_CAN_TEST_REG] = 0x14, + [C_CAN_FUNCTION_REG] = 0x18, [C_CAN_TXRQST1_REG] = 0x88, [C_CAN_TXRQST2_REG] = 0x8A, [C_CAN_NEWDAT1_REG] = 0x9C,
@@ -172,6 +174,7 @@ struct c_can_priv {u32 __iomem *raminit_ctrlreg;unsigned int instance;void (*raminit) (const struct c_can_priv *priv,bool enable); +unsigned int raminit_bit; };struct net_device *alloc_c_can_dev (void );
drivers/net/can/c_can/c_can_platform.c +18 -3
@@ -38,6 +38,7 @@#include "c_can.h" #define CAN_RAMINIT_START_MASK (i) (1 << (i)) +#define DCAN_RAM_INIT_BIT 3/* * 16-bit c_can registers can be arranged differently in the memory
@@ -75,9 +76,9 @@ static void c_can_hw_raminit(const struct c_can_priv *priv, bool enable) val =readl (priv->raminit_ctrlreg);if (enable) - val |=CAN_RAMINIT_START_MASK (priv->instance); + val |=CAN_RAMINIT_START_MASK (priv->raminit_bit);else - val &= ~CAN_RAMINIT_START_MASK (priv->instance); + val &= ~CAN_RAMINIT_START_MASK (priv->raminit_bit);writel (val, priv->raminit_ctrlreg); }
@@ -194,11 +195,25 @@ static int c_can_plat_probe(struct platform_device *pdev) priv->instance = pdev->id; res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); - priv->raminit_ctrlreg =devm_ioremap_resource (&pdev->dev, res); +/* Not all D_CAN module have a separate register for the D_CAN +* RAM initialization. Use default RAM init bit in D_CAN module +* if not specified in DT. +*/ +if (!res) { + priv->raminit = c_can_hw_raminit; + priv->raminit_bit =DCAN_RAM_INIT_BIT ; + priv->raminit_ctrlreg = addr + + priv->regs[C_CAN_FUNCTION_REG ]; +break ; + }else { + priv->raminit_ctrlreg = +devm_ioremap_resource (&pdev->dev, res); + }if (IS_ERR (priv->raminit_ctrlreg) || (int )priv->instance <0 )dev_info (&pdev->dev,"control memory is not used for raminit\n" );else priv->raminit = c_can_hw_raminit; + priv->raminit_bit = priv->instance;break ;default : ret = -EINVAL ;
Signature · 1 line
1.7.9.5
PATCH 1/1 Add D_CAN Module RAM Init
From: Thor Thayer <[email protected]>
The Bosch D_CAN module supports initializing the RAM memories. The existing D_CAN support was written for a specific D_CAN implementation that placed the RAM Init bit in a separate register. This patch uses the default Bosch D_CAN Module RAM Initialization bit in the CAN Function Register (CFR [offset 0x18]).
Request testing the TI D_CAN module and the C_CAN module.
Thor Thayer (1):
net: can: c_can_platform: Add D_CAN Module RAM Init
drivers/net/can/c_can/c_can.h | 3 +++ drivers/net/can/c_can/c_can_platform.c | 21 ++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-)
Signature · 1 line
1.7.9.5