Commit eaacfeac authored by Vivek Yadav's avatar Vivek Yadav Committed by Marc Kleine-Budde

can: m_can: Call the RAM init directly from m_can_chip_config

When we try to access the mcan message ram addresses during the probe,
hclk is gated by any other drivers or disabled, because of that probe
gets failed.

Move the mram init functionality to mcan chip config called by
m_can_start from mcan open function, by that time clocks are
enabled.
Suggested-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: default avatarVivek Yadav <vivek.2311@samsung.com>
Link: https://lore.kernel.org/all/20221207100632.96200-2-vivek.2311@samsung.comSigned-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent bd4a52bf
...@@ -1243,10 +1243,17 @@ static int m_can_set_bittiming(struct net_device *dev) ...@@ -1243,10 +1243,17 @@ static int m_can_set_bittiming(struct net_device *dev)
* - setup bittiming * - setup bittiming
* - configure timestamp generation * - configure timestamp generation
*/ */
static void m_can_chip_config(struct net_device *dev) static int m_can_chip_config(struct net_device *dev)
{ {
struct m_can_classdev *cdev = netdev_priv(dev); struct m_can_classdev *cdev = netdev_priv(dev);
u32 cccr, test; u32 cccr, test;
int err;
err = m_can_init_ram(cdev);
if (err) {
dev_err(cdev->dev, "Message RAM configuration failed\n");
return err;
}
m_can_config_endisable(cdev, true); m_can_config_endisable(cdev, true);
...@@ -1370,18 +1377,25 @@ static void m_can_chip_config(struct net_device *dev) ...@@ -1370,18 +1377,25 @@ static void m_can_chip_config(struct net_device *dev)
if (cdev->ops->init) if (cdev->ops->init)
cdev->ops->init(cdev); cdev->ops->init(cdev);
return 0;
} }
static void m_can_start(struct net_device *dev) static int m_can_start(struct net_device *dev)
{ {
struct m_can_classdev *cdev = netdev_priv(dev); struct m_can_classdev *cdev = netdev_priv(dev);
int ret;
/* basic m_can configuration */ /* basic m_can configuration */
m_can_chip_config(dev); ret = m_can_chip_config(dev);
if (ret)
return ret;
cdev->can.state = CAN_STATE_ERROR_ACTIVE; cdev->can.state = CAN_STATE_ERROR_ACTIVE;
m_can_enable_all_interrupts(cdev); m_can_enable_all_interrupts(cdev);
return 0;
} }
static int m_can_set_mode(struct net_device *dev, enum can_mode mode) static int m_can_set_mode(struct net_device *dev, enum can_mode mode)
...@@ -1809,7 +1823,9 @@ static int m_can_open(struct net_device *dev) ...@@ -1809,7 +1823,9 @@ static int m_can_open(struct net_device *dev)
} }
/* start the m_can controller */ /* start the m_can controller */
m_can_start(dev); err = m_can_start(dev);
if (err)
goto exit_irq_fail;
if (!cdev->is_peripheral) if (!cdev->is_peripheral)
napi_enable(&cdev->napi); napi_enable(&cdev->napi);
...@@ -2068,9 +2084,13 @@ int m_can_class_resume(struct device *dev) ...@@ -2068,9 +2084,13 @@ int m_can_class_resume(struct device *dev)
ret = m_can_clk_start(cdev); ret = m_can_clk_start(cdev);
if (ret) if (ret)
return ret; return ret;
ret = m_can_start(ndev);
if (ret) {
m_can_clk_stop(cdev);
return ret;
}
m_can_init_ram(cdev);
m_can_start(ndev);
netif_device_attach(ndev); netif_device_attach(ndev);
netif_start_queue(ndev); netif_start_queue(ndev);
} }
......
...@@ -140,10 +140,6 @@ static int m_can_plat_probe(struct platform_device *pdev) ...@@ -140,10 +140,6 @@ static int m_can_plat_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, mcan_class); platform_set_drvdata(pdev, mcan_class);
ret = m_can_init_ram(mcan_class);
if (ret)
goto probe_fail;
pm_runtime_enable(mcan_class->dev); pm_runtime_enable(mcan_class->dev);
ret = m_can_class_register(mcan_class); ret = m_can_class_register(mcan_class);
if (ret) if (ret)
......
...@@ -234,11 +234,6 @@ static int tcan4x5x_init(struct m_can_classdev *cdev) ...@@ -234,11 +234,6 @@ static int tcan4x5x_init(struct m_can_classdev *cdev)
if (ret) if (ret)
return ret; return ret;
/* Zero out the MCAN buffers */
ret = m_can_init_ram(cdev);
if (ret)
return ret;
ret = regmap_update_bits(tcan4x5x->regmap, TCAN4X5X_CONFIG, ret = regmap_update_bits(tcan4x5x->regmap, TCAN4X5X_CONFIG,
TCAN4X5X_MODE_SEL_MASK, TCAN4X5X_MODE_NORMAL); TCAN4X5X_MODE_SEL_MASK, TCAN4X5X_MODE_NORMAL);
if (ret) if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment