[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221122105455.39294-2-vivek.2311@samsung.com>
Date: Tue, 22 Nov 2022 16:24:54 +0530
From: Vivek Yadav <vivek.2311@...sung.com>
To: rcsekar@...sung.com, krzysztof.kozlowski+dt@...aro.org,
wg@...ndegger.com, mkl@...gutronix.de, davem@...emloft.net,
edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com,
pankaj.dubey@...sung.com, ravi.patel@...sung.com,
alim.akhtar@...sung.com, linux-fsd@...la.com, robh+dt@...nel.org
Cc: linux-can@...r.kernel.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-samsung-soc@...r.kernel.org, devicetree@...r.kernel.org,
aswani.reddy@...sung.com, sriranjani.p@...sung.com,
Vivek Yadav <vivek.2311@...sung.com>
Subject: [PATCH v3 1/2] can: m_can: Move mram init to mcan device setup
When we try to access the mcan message ram addresses, hclk is
gated by any other drivers or disabled, because of that probe gets
failed.
Move the mram init functionality to mcan device setup called by
mcan class register from mcan probe function, by that time clocks
are enabled.
Signed-off-by: Chandrasekar R <rcsekar@...sung.com>
Signed-off-by: Vivek Yadav <vivek.2311@...sung.com>
---
drivers/net/can/m_can/m_can.c | 4 ++--
drivers/net/can/m_can/m_can.h | 1 +
drivers/net/can/m_can/m_can_platform.c | 21 +++++++++++++++++----
3 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index a776cab1a5a4..5956f0b4d5b1 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -1516,9 +1516,9 @@ static int m_can_dev_setup(struct m_can_classdev *cdev)
}
if (cdev->ops->init)
- cdev->ops->init(cdev);
+ err = cdev->ops->init(cdev);
- return 0;
+ return err;
}
static void m_can_stop(struct net_device *dev)
diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h
index 401410022823..c6e77b93f4a2 100644
--- a/drivers/net/can/m_can/m_can.h
+++ b/drivers/net/can/m_can/m_can.h
@@ -93,6 +93,7 @@ struct m_can_classdev {
int is_peripheral;
struct mram_cfg mcfg[MRAM_CFG_NUM];
+ bool mram_cfg_flag;
};
struct m_can_classdev *m_can_class_allocate_dev(struct device *dev, int sizeof_priv);
diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/m_can_platform.c
index b5a5bedb3116..1a65b0d256fb 100644
--- a/drivers/net/can/m_can/m_can_platform.c
+++ b/drivers/net/can/m_can/m_can_platform.c
@@ -67,11 +67,28 @@ static int iomap_write_fifo(struct m_can_classdev *cdev, int offset,
return 0;
}
+static int plat_init(struct m_can_classdev *cdev)
+{
+ int ret = 0;
+
+ if (!cdev->mram_cfg_flag) {
+ /* Initialize mcan message ram */
+ ret = m_can_init_ram(cdev);
+ if (ret)
+ return ret;
+
+ cdev->mram_cfg_flag = true;
+ }
+
+ return 0;
+}
+
static struct m_can_ops m_can_plat_ops = {
.read_reg = iomap_read_reg,
.write_reg = iomap_write_reg,
.write_fifo = iomap_write_fifo,
.read_fifo = iomap_read_fifo,
+ .init = plat_init,
};
static int m_can_plat_probe(struct platform_device *pdev)
@@ -140,10 +157,6 @@ static int m_can_plat_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, mcan_class);
- ret = m_can_init_ram(mcan_class);
- if (ret)
- goto probe_fail;
-
pm_runtime_enable(mcan_class->dev);
ret = m_can_class_register(mcan_class);
if (ret)
--
2.17.1
Powered by blists - more mailing lists