2022-12-07 10:40:24

by Vivek Yadav

[permalink] [raw]
Subject: [Patch v4 0/2] can: mcan: Add MCAN support for FSD SoC

Add support for MCAN instances present on the FSD platform.

Vivek Yadav (2):
can: m_can: Call the RAM init directly from m_can_chip_config
arm64: dts: fsd: Add MCAN device node

changes since v3:

[PATCH v3 1/2] can: m_can: Move mram init to mcan device setup
https://lore.kernel.org/lkml/[email protected]/
1: Addressed review comment given by Marc Kleine-Budde
a) Call the RAM init directly from m_can_chip_config.
b) If we call m_can_init_ram() from m_can_chip_config(),
then remove it from the tcan's tcan4x5x_init() functions,
and from m_can_class_resume(). It should only be called
once for open and once for resume.

changes since v2:

[PATCH v2 1/6] dt-bindings: Document the SYSREG specific compatibles found
on FSD SoC
link:
https://lore.kernel.org/lkml/[email protected]/
1: Addressed review comment given by Krzysztof Kozlowski
a) As per suggestion separated this patch and posted separately.
ref: https://www.spinics.net/lists/kernel/msg4597970.html

[PATCH v2 2/6] dt-bindings: can: mcan: Add ECC functionality to message ram
link:
https://lore.kernel.org/lkml/[email protected]/
1: Addressed review comment given by Krzysztof Kozlowski
a) For now I am dropping this. I will reconsider the implementation
and will resend as separate patch.

[PATCH v2 3/6] arm64: dts: fsd: add sysreg device node
link:
https://lore.kernel.org/lkml/[email protected]/
1: Addressed review comment given by Krzysztof Kozlowski
a) Dropped Cc from commit message.
b) As per suggestion separated this and corresponding DT-bindin
patch and posted separately.
ref: https://www.spinics.net/lists/kernel/msg4597921.html

[PATCH v2 4/6] arm64: dts: fsd: Add MCAN device node
link:
https://lore.kernel.org/lkml/[email protected]/
1: Addressed review comment given by Krzysztof Kozlowski
a) Aligned the lines.

[PATCH v2 5/6] can: m_can: Add ECC functionality for message RAM
link:
https://lore.kernel.org/lkml/[email protected]/
1: Addressed review comment given by Krzysztof Kozlowski
a) We are dropping this for now and will reconsider it's
implementation and resend as separate patch.

[PATCH v2 6/6] arm64: dts: fsd: Add support for error correction code for
message RAM
link:
https://lore.kernel.org/lkml/[email protected]/
1: Addressed review comment given by Krzysztof Kozlowski
a) Subject is updated and patch go via ARM SOC tree, we will
resend this as separate patch along with ECC patch.

changes since v1:

[PATCH 0/7] can: mcan: Add MCAN support for FSD SoC
1: Addressed review comment given by Marc Kleine-Budde
a) Added my signed off.

[PATCH 2/7] dt-bindings: can: mcan: Add ECC functionality to message ram
link:
https://lore.kernel.org/netdev/[email protected]/
1: Addressed review comment given by Marc Kleine-Budde
a) Added an example to the yaml that makes use of the
mram-ecc-cfg property.
b) Added prefix to "mram-ecc-cfg" property and
"$ref: /schemas/types.yaml#/definitions/phandle".

[PATCH 4/7] can: mcan: enable peripheral clk to access mram
link:
https://lore.kernel.org/netdev/[email protected]/
1: Addressed review comment given by Marc Kleine-Budde
a) Moved mram init into m_can_dev_setup function by then
clocks are enabled and prevent probe failure.
b) Added the platform init ops in m_can_plat_ops and
moved mram init into it.

[PATCH 5/7] arm64: dts: fsd: Add MCAN device node
link:
https://lore.kernel.org/netdev/[email protected]/
1: Addressed review comment given by Marc Kleine-Budde
a) Added the DT people on Cc.

[PATCH 6/7] can: m_can: Add ECC functionality for message RAM
link:
https://lore.kernel.org/netdev/[email protected]/
1: Addressed review comment given by kernel test robot.
a) Addressed missing prototypes warnings.
2: Addressed review comment given by Marc Kleine-Budde
a) Sorted the declaration of local variable by reverse Christmas
tree.
b) Used syscon_regmap_lookup_by_phandle_args to get the syscon
Base Address and offset.
c) Used FIELD_PREP instead of logical operation.
d) Used regmap_read_poll_timeout API to give timeout condition
for ECC cfg done status instead of using while loop counter.
e) Moved all the ECC mcaros in m_can.c file and changed the name
with a common prefix M_CAN.
f) Moved ECC init into platform init function called during m_can
device setup.

arch/arm64/boot/dts/tesla/fsd-evb.dts | 16 +++++
arch/arm64/boot/dts/tesla/fsd-pinctrl.dtsi | 28 +++++++++
arch/arm64/boot/dts/tesla/fsd.dtsi | 68 ++++++++++++++++++++++
drivers/net/can/m_can/m_can.c | 32 ++++++++--
drivers/net/can/m_can/m_can_platform.c | 4 --
drivers/net/can/m_can/tcan4x5x-core.c | 5 --
6 files changed, 138 insertions(+), 15 deletions(-)

--
2.17.1


2022-12-07 10:40:31

by Vivek Yadav

[permalink] [raw]
Subject: [Patch v4 1/2] 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: Marc Kleine-Budde <[email protected]>
Signed-off-by: Vivek Yadav <[email protected]>
---
drivers/net/can/m_can/m_can.c | 32 +++++++++++++++++++++-----
drivers/net/can/m_can/m_can_platform.c | 4 ----
drivers/net/can/m_can/tcan4x5x-core.c | 5 ----
3 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index a776cab1a5a4..2261d01324f8 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -1233,10 +1233,17 @@ static int m_can_set_bittiming(struct net_device *dev)
* - setup bittiming
* - 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);
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);

@@ -1360,18 +1367,25 @@ static void m_can_chip_config(struct net_device *dev)

if (cdev->ops->init)
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);
+ int ret;

/* 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;

m_can_enable_all_interrupts(cdev);
+
+ return 0;
}

static int m_can_set_mode(struct net_device *dev, enum can_mode mode)
@@ -1799,7 +1813,9 @@ static int m_can_open(struct net_device *dev)
}

/* start the m_can controller */
- m_can_start(dev);
+ err = m_can_start(dev);
+ if (err)
+ goto exit_irq_fail;

if (!cdev->is_peripheral)
napi_enable(&cdev->napi);
@@ -2058,9 +2074,13 @@ int m_can_class_resume(struct device *dev)
ret = m_can_clk_start(cdev);
if (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_start_queue(ndev);
}
diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/m_can_platform.c
index b5a5bedb3116..9c1dcf838006 100644
--- a/drivers/net/can/m_can/m_can_platform.c
+++ b/drivers/net/can/m_can/m_can_platform.c
@@ -140,10 +140,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)
diff --git a/drivers/net/can/m_can/tcan4x5x-core.c b/drivers/net/can/m_can/tcan4x5x-core.c
index 41645a24384c..a3aeb83de152 100644
--- a/drivers/net/can/m_can/tcan4x5x-core.c
+++ b/drivers/net/can/m_can/tcan4x5x-core.c
@@ -234,11 +234,6 @@ static int tcan4x5x_init(struct m_can_classdev *cdev)
if (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,
TCAN4X5X_MODE_SEL_MASK, TCAN4X5X_MODE_NORMAL);
if (ret)
--
2.17.1

2022-12-07 10:40:41

by Vivek Yadav

[permalink] [raw]
Subject: [Patch v4 2/2] arm64: dts: fsd: Add MCAN device node

Add MCAN device node and enable the same for FSD platform.
This also adds the required pin configuration for the same.

Signed-off-by: Sriranjani P <[email protected]>
Signed-off-by: Vivek Yadav <[email protected]>
---
arch/arm64/boot/dts/tesla/fsd-evb.dts | 16 +++++
arch/arm64/boot/dts/tesla/fsd-pinctrl.dtsi | 28 +++++++++
arch/arm64/boot/dts/tesla/fsd.dtsi | 68 ++++++++++++++++++++++
3 files changed, 112 insertions(+)

diff --git a/arch/arm64/boot/dts/tesla/fsd-evb.dts b/arch/arm64/boot/dts/tesla/fsd-evb.dts
index 1db6ddf03f01..af3862e9fe3b 100644
--- a/arch/arm64/boot/dts/tesla/fsd-evb.dts
+++ b/arch/arm64/boot/dts/tesla/fsd-evb.dts
@@ -34,6 +34,22 @@
clock-frequency = <24000000>;
};

+&m_can0 {
+ status = "okay";
+};
+
+&m_can1 {
+ status = "okay";
+};
+
+&m_can2 {
+ status = "okay";
+};
+
+&m_can3 {
+ status = "okay";
+};
+
&serial_0 {
status = "okay";
};
diff --git a/arch/arm64/boot/dts/tesla/fsd-pinctrl.dtsi b/arch/arm64/boot/dts/tesla/fsd-pinctrl.dtsi
index d0abb9aa0e9e..bb5289ebfef3 100644
--- a/arch/arm64/boot/dts/tesla/fsd-pinctrl.dtsi
+++ b/arch/arm64/boot/dts/tesla/fsd-pinctrl.dtsi
@@ -339,6 +339,34 @@
samsung,pin-pud = <FSD_PIN_PULL_UP>;
samsung,pin-drv = <FSD_PIN_DRV_LV1>;
};
+
+ m_can0_bus: m-can0-bus-pins {
+ samsung,pins = "gpd0-0", "gpd0-1";
+ samsung,pin-function = <FSD_PIN_FUNC_2>;
+ samsung,pin-pud = <FSD_PIN_PULL_UP>;
+ samsung,pin-drv = <FSD_PIN_DRV_LV4>;
+ };
+
+ m_can1_bus: m-can1-bus-pins {
+ samsung,pins = "gpd0-2", "gpd0-3";
+ samsung,pin-function = <FSD_PIN_FUNC_2>;
+ samsung,pin-pud = <FSD_PIN_PULL_UP>;
+ samsung,pin-drv = <FSD_PIN_DRV_LV4>;
+ };
+
+ m_can2_bus: m-can2-bus-pins {
+ samsung,pins = "gpd0-4", "gpd0-5";
+ samsung,pin-function = <FSD_PIN_FUNC_2>;
+ samsung,pin-pud = <FSD_PIN_PULL_UP>;
+ samsung,pin-drv = <FSD_PIN_DRV_LV4>;
+ };
+
+ m_can3_bus: m-can3-bus-pins {
+ samsung,pins = "gpd0-6", "gpd0-7";
+ samsung,pin-function = <FSD_PIN_FUNC_2>;
+ samsung,pin-pud = <FSD_PIN_PULL_UP>;
+ samsung,pin-drv = <FSD_PIN_DRV_LV4>;
+ };
};

&pinctrl_pmu {
diff --git a/arch/arm64/boot/dts/tesla/fsd.dtsi b/arch/arm64/boot/dts/tesla/fsd.dtsi
index f35bc5a288c2..dfdb32514887 100644
--- a/arch/arm64/boot/dts/tesla/fsd.dtsi
+++ b/arch/arm64/boot/dts/tesla/fsd.dtsi
@@ -755,6 +755,74 @@
interrupts = <GIC_SPI 79 IRQ_TYPE_LEVEL_HIGH>;
};

+ m_can0: can@14088000 {
+ compatible = "bosch,m_can";
+ reg = <0x0 0x14088000 0x0 0x0200>,
+ <0x0 0x14080000 0x0 0x8000>;
+ reg-names = "m_can", "message_ram";
+ interrupts = <GIC_SPI 159 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 160 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "int0", "int1";
+ pinctrl-names = "default";
+ pinctrl-0 = <&m_can0_bus>;
+ clocks = <&clock_peric PERIC_MCAN0_IPCLKPORT_PCLK>,
+ <&clock_peric PERIC_MCAN0_IPCLKPORT_CCLK>;
+ clock-names = "hclk", "cclk";
+ bosch,mram-cfg = <0x0 128 64 64 64 64 32 32>;
+ status = "disabled";
+ };
+
+ m_can1: can@14098000 {
+ compatible = "bosch,m_can";
+ reg = <0x0 0x14098000 0x0 0x0200>,
+ <0x0 0x14090000 0x0 0x8000>;
+ reg-names = "m_can", "message_ram";
+ interrupts = <GIC_SPI 162 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 163 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "int0", "int1";
+ pinctrl-names = "default";
+ pinctrl-0 = <&m_can1_bus>;
+ clocks = <&clock_peric PERIC_MCAN1_IPCLKPORT_PCLK>,
+ <&clock_peric PERIC_MCAN1_IPCLKPORT_CCLK>;
+ clock-names = "hclk", "cclk";
+ bosch,mram-cfg = <0x0 128 64 64 64 64 32 32>;
+ status = "disabled";
+ };
+
+ m_can2: can@140a8000 {
+ compatible = "bosch,m_can";
+ reg = <0x0 0x140a8000 0x0 0x0200>,
+ <0x0 0x140a0000 0x0 0x8000>;
+ reg-names = "m_can", "message_ram";
+ interrupts = <GIC_SPI 165 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 166 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "int0", "int1";
+ pinctrl-names = "default";
+ pinctrl-0 = <&m_can2_bus>;
+ clocks = <&clock_peric PERIC_MCAN2_IPCLKPORT_PCLK>,
+ <&clock_peric PERIC_MCAN2_IPCLKPORT_CCLK>;
+ clock-names = "hclk", "cclk";
+ bosch,mram-cfg = <0x0 128 64 64 64 64 32 32>;
+ status = "disabled";
+ };
+
+ m_can3: can@140b8000 {
+ compatible = "bosch,m_can";
+ reg = <0x0 0x140b8000 0x0 0x0200>,
+ <0x0 0x140b0000 0x0 0x8000>;
+ reg-names = "m_can", "message_ram";
+ interrupts = <GIC_SPI 168 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 169 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "int0", "int1";
+ pinctrl-names = "default";
+ pinctrl-0 = <&m_can3_bus>;
+ clocks = <&clock_peric PERIC_MCAN3_IPCLKPORT_PCLK>,
+ <&clock_peric PERIC_MCAN3_IPCLKPORT_CCLK>;
+ clock-names = "hclk", "cclk";
+ bosch,mram-cfg = <0x0 128 64 64 64 64 32 32>;
+ status = "disabled";
+ };
+
spi_0: spi@14140000 {
compatible = "tesla,fsd-spi";
reg = <0x0 0x14140000 0x0 0x100>;
--
2.17.1

2022-12-07 11:54:38

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [Patch v4 2/2] arm64: dts: fsd: Add MCAN device node

On 07/12/2022 11:06, Vivek Yadav wrote:
> Add MCAN device node and enable the same for FSD platform.
> This also adds the required pin configuration for the same.
>
> Signed-off-by: Sriranjani P <[email protected]>
> Signed-off-by: Vivek Yadav <[email protected]>

This is a friendly reminder during the review process.

It looks like you received a tag and forgot to add it.

If you do not know the process, here is a short explanation:
Please add Acked-by/Reviewed-by/Tested-by tags when posting new
versions. However, there's no need to repost patches *only* to add the
tags. The upstream maintainer will do that for acks received on the
version they apply.

https://elixir.bootlin.com/linux/v5.17/source/Documentation/process/submitting-patches.rst#L540

If a tag was not added on purpose, please state why and what changed.


Applied for v6.3.

Best regards,
Krzysztof

2022-12-07 11:55:25

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: (subset) [Patch v4 2/2] arm64: dts: fsd: Add MCAN device node

On Wed, 7 Dec 2022 15:36:32 +0530, Vivek Yadav wrote:
> Add MCAN device node and enable the same for FSD platform.
> This also adds the required pin configuration for the same.
>
>

Applied, thanks!

[2/2] arm64: dts: fsd: Add MCAN device node
https://git.kernel.org/krzk/linux/c/142c693e6bd63d8dfaf7f808b015fc46180af731

Best regards,
--
Krzysztof Kozlowski <[email protected]>

2022-12-08 09:32:33

by Marc Kleine-Budde

[permalink] [raw]
Subject: Re: [Patch v4 1/2] can: m_can: Call the RAM init directly from m_can_chip_config

On 07.12.2022 15:36:31, Vivek Yadav wrote:
> 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: Marc Kleine-Budde <[email protected]>
> Signed-off-by: Vivek Yadav <[email protected]>

Applied to linux-can-next.

Thanks,
Marc

--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |


Attachments:
(No filename) (786.00 B)
signature.asc (499.00 B)
Download all attachments