arm64: dts: imx93: add the Flex-CAN stop mode by GPR
Subsystems (5)
PATCH v2 1/3 arm64: dts: imx93: add the Flex-CAN stop mode by GPR
From: Haibo Chen <[email protected]>
imx93 A0 chip use the internal q-channel handshake signal in LPCG and CCM to automatically handle the Flex-CAN stop mode. But this method meet issue when do the system PM stress test. IC can't fix it easily. So in the new imx93 A1 chip, IC drop this method, and involve back the old way,use the GPR method to trigger the Flex-CAN stop mode signal. Now NXP claim to drop imx93 A0, and only support imx93 A1. So here add the stop mode through GPR.
--- arch/arm64/boot/dts/freescale/imx93.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/freescale/imx93.dtsi +2 -0
@@ -319,6 +319,7 @@ flexcan1: can@443a0000 { assigned-clock-parents = <&clk IMX93_CLK_SYS_PLL_PFD1_DIV2>; assigned-clock-rates = <40000000>; fsl,clk-source = /bits/ 8 <0>; + fsl,stop-mode = <&anomix_ns_gpr 0x14 0>; status = "disabled"; };
@@ -591,6 +592,7 @@ flexcan2: can@425b0000 { assigned-clock-parents = <&clk IMX93_CLK_SYS_PLL_PFD1_DIV2>; assigned-clock-rates = <40000000>; fsl,clk-source = /bits/ 8 <0>; + fsl,stop-mode = <&wakeupmix_gpr 0x0C 2>; status = "disabled"; };
Signature · 1 line
2.34.1
PATCH v2 2/3 can: flexcan: remove the auto stop mode for IMX93
From: Haibo Chen <[email protected]>
IMX93 A0 chip involve the internal q-channel handshake in LPCG and CCM to automatically handle the Flex-CAN IPG STOP signal. Only after FLEX-CAN enter stop mode then can support the self-wakeup feature. But meet issue when do the continue system PM stress test. When config the CAN as wakeup source, the first time after system suspend, any data on CAN bus can wakeup the system, this is as expect. But the second time when system suspend, data on CAN bus can't wakeup the system. If continue this test, we find in odd time system enter suspend, CAN can wakeup the system, but in even number system enter suspend, CAN can't wakeup the system. IC find a bug in the auto stop mode logic, and can't fix it easily. So for the new imx93 A1, IC drop the auto stop mode and involve the GPR to support stop mode (used before). IC define a bit in GPR which can trigger the IPG STOP signal to Flex-CAN, let it go into stop mode. And NXP claim to drop IMX93 A0, and only support IMX93 A1. So this patch remove the auto stop mode, and add flag FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR to imx93.
--- drivers/net/can/flexcan/flexcan-core.c | 37 ++++---------------------- drivers/net/can/flexcan/flexcan.h | 2 -- 2 files changed, 5 insertions(+), 34 deletions(-)
drivers/net/can/flexcan/flexcan-core.c +5 -32
@@ -348,7 +348,7 @@ static struct flexcan_devtype_data fsl_imx8mp_devtype_data = {static struct flexcan_devtype_data fsl_imx93_devtype_data = { .quirks =FLEXCAN_QUIRK_DISABLE_RXFG |FLEXCAN_QUIRK_ENABLE_EACEN_RRS |FLEXCAN_QUIRK_DISABLE_MECR |FLEXCAN_QUIRK_USE_RX_MAILBOX | -FLEXCAN_QUIRK_BROKEN_PERR_STATE |FLEXCAN_QUIRK_AUTO_STOP_MODE | +FLEXCAN_QUIRK_BROKEN_PERR_STATE |FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR |FLEXCAN_QUIRK_SUPPORT_FD |FLEXCAN_QUIRK_SUPPORT_ECC |FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX |FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR ,
@@ -544,11 +544,6 @@ static inline int flexcan_enter_stop_mode(struct flexcan_priv *priv) }else if (priv->devtype_data.quirks &FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR ) {regmap_update_bits (priv->stm.gpr, priv->stm.req_gpr,1 << priv->stm.req_bit,1 << priv->stm.req_bit); - }else if (priv->devtype_data.quirks &FLEXCAN_QUIRK_AUTO_STOP_MODE ) { -/* For the auto stop mode, software do nothing, hardware will cover -* all the operation automatically after system go into low power mode. -*/ -return 0 ; }return flexcan_low_power_enter_ack (priv);
@@ -574,12 +569,6 @@ static inline int flexcan_exit_stop_mode(struct flexcan_priv *priv) reg_mcr &= ~FLEXCAN_MCR_SLF_WAK ; priv->write (reg_mcr, ®s->mcr); -/* For the auto stop mode, hardware will exist stop mode -* automatically after system go out of low power mode. -*/ -if (priv->devtype_data.quirks &FLEXCAN_QUIRK_AUTO_STOP_MODE ) -return 0 ; -return flexcan_low_power_exit_ack (priv); }
@@ -1994,8 +1983,6 @@ static int flexcan_setup_stop_mode(struct platform_device *pdev) ret =flexcan_setup_stop_mode_scfw (pdev); else if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR) ret =flexcan_setup_stop_mode_gpr (pdev); - else if (priv->devtype_data.quirks & FLEXCAN_QUIRK_AUTO_STOP_MODE) - ret =0 ; else/* return 0 directly if doesn't support stop mode feature */ return 0;
@@ -2320,16 +2307,8 @@ static int __maybe_unused flexcan_noirq_suspend(struct device *device)if (netif_running (dev)) {int err; -if (device_may_wakeup (device)) { +if (device_may_wakeup (device))flexcan_enable_wakeup_irq (priv, true); -/* For auto stop mode, need to keep the clock on before -* system go into low power mode. After system go into -* low power mode, hardware will config the flexcan into -* stop mode, and gate off the clock automatically. -*/ -if (priv->devtype_data.quirks &FLEXCAN_QUIRK_AUTO_STOP_MODE ) -return 0 ; - } err =pm_runtime_force_suspend (device);if (err)
@@ -2347,15 +2326,9 @@ static int __maybe_unused flexcan_noirq_resume(struct device *device)if (netif_running (dev)) {int err; -/* For the wakeup in auto stop mode, no need to gate on the -* clock here, hardware will do this automatically. -*/ -if (!(device_may_wakeup (device) && - priv->devtype_data.quirks &FLEXCAN_QUIRK_AUTO_STOP_MODE )) { - err =pm_runtime_force_resume (device); -if (err) -return err; - } + err =pm_runtime_force_resume (device); +if (err) +return err;if (device_may_wakeup (device))flexcan_enable_wakeup_irq (priv, false);
drivers/net/can/flexcan/flexcan.h +0 -2
@@ -68,8 +68,6 @@#define FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR BIT(15)/* Device supports RX via FIFO */ #define FLEXCAN_QUIRK_SUPPORT_RX_FIFO BIT(16) -/* auto enter stop mode to support wakeup */ -#define FLEXCAN_QUIRK_AUTO_STOP_MODE BIT(17)struct flexcan_devtype_data {u32 quirks;/* quirks needed for different IP cores */
Signature · 1 line
2.34.1
PATCH v2 3/3 can: flexcan: lack of stop mode dts properity should not block driver probe
In reply to [email protected]From: Haibo Chen <[email protected]>
If SoC claim to support stop mode, but dts file do not contain the stop mode properity, this should not block the driver probe. For this case, the driver only need to skip the wakeup capable setting which means this device do not support the feature to wakeup system.
--- drivers/net/can/flexcan/flexcan-core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/can/flexcan/flexcan-core.c +8 -1
@@ -1987,7 +1987,14 @@ static int flexcan_setup_stop_mode(struct platform_device *pdev)/* return 0 directly if doesn't support stop mode feature */ return 0 ; -if (ret) +/* If ret is -EINVAL, this means SoC claim to support stop mode, but +* dts file lack the stop mode property definition. For this case, +* directly return 0, this will skip the wakeup capable setting and +* will not block the driver probe. +*/ +if (ret == -EINVAL ) +return 0 ; +else if (ret)return ret;device_set_wakeup_capable (&pdev->dev, true);
Signature · 1 line
2.34.1
Marc Kleine-Budde
maintainerRe: [PATCH v2 3/3] can: flexcan: lack of stop mode dts properity should not block driver probe
Quoted 6 lines · On 26.07.2023 17:09:09, [email protected] wrote:
From: Haibo Chen <[email protected]>
If SoC claim to support stop mode, but dts file do not contain the stop mode properity, this should not block the driver probe. For this case, the driver only need to skip the wakeup capable setting which means this device do not support the feature to wakeup system.
This still breaks old DTS on kernels with patch 2 applied, but not 3. Please squash this into 2.
Quoted 30 lines
Signed-off-by Haibo Chen <[email protected]>--- drivers/net/can/flexcan/flexcan-core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/net/can/flexcan/flexcan-core.c +8
-1@@ -1987,7 +1987,14 @@ static int flexcan_setup_stop_mode(struct platform_device *pdev)/* return 0 directly if doesn't support stop mode feature */ return 0 ; -if (ret) +/* If ret is -EINVAL, this means SoC claim to support stop mode, but +* dts file lack the stop mode property definition. For this case, +* directly return 0, this will skip the wakeup capable setting and +* will not block the driver probe. +*/ +if (ret == -EINVAL ) +return 0 ; +else if (ret)return ret;device_set_wakeup_capable (&pdev->dev, true);Signature · 1 line
2.34.1
regards,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung Nürnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
RE: [PATCH v2 3/3] can: flexcan: lack of stop mode dts properity should not block driver probe
Quoted 16 lines
-----Original Message-----
From: Marc Kleine-Budde <[email protected]>
Sent: 2023年7月26日 18:17
To: Bough Chen <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; dl-linux-imx <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2 3/3] can: flexcan: lack of stop mode dts properity should not block driver probeQuoted 2 lines · On 26.07.2023 17:09:09, [email protected] wrote:
From: Haibo Chen <[email protected]>
Quoted 7 lines
Quoted 4 lines
If SoC claim to support stop mode, but dts file do not contain the stop mode properity, this should not block the driver probe. For this case, the driver only need to skip the wakeup capable setting which means this device do not support the feature to wakeup system.
This still breaks old DTS on kernels with patch 2 applied, but not 3. Please squash this into 2.
Okay.
Quoted 42 lines
drivers/net/can/flexcan/flexcan-core.c static int flexcan_setup_stop_mode(struct
Quoted 13 lines
Signed-off-by Haibo Chen <[email protected]>--- drivers/net/can/flexcan/flexcan-core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/net/can/flexcan/flexcan-core.c +0
-0@@ -1987,7 +1987,14 @@ static int flexcan_setup_stop_mode(struct
platform_device*pdev)Quoted 16 lines
drivers/net/can/flexcan/flexcan-core.c +8
-2/* return 0 directly if doesn't support stop mode feature */ return 0 ; -if (ret) +/* If ret is -EINVAL, this means SoC claim to support stop mode, but +* dts file lack the stop mode property definition. For this case, +* directly return 0, this will skip the wakeup capable setting and +* will not block the driver probe. +*/ +if (ret == -EINVAL ) +return 0 ; +else if (ret)return ret;device_set_wakeup_capable (&pdev->dev, true); --Quoted 3 lines
2.34.1
regards,
Marc--
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de |Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
Marc Kleine-Budde
maintainerQuoted 20 lines · On 26.07.2023 17:09:07, [email protected] wrote:
From: Haibo Chen <[email protected]>
imx93 A0 chip use the internal q-channel handshake signal in LPCG and CCM to automatically handle the Flex-CAN stop mode. But this method meet issue when do the system PM stress test. IC can't fix it easily. So in the new imx93 A1 chip, IC drop this method, and involve back the old way,use the GPR method to trigger the Flex-CAN stop mode signal. Now NXP claim to drop imx93 A0, and only support imx93 A1. So here add the stop mode through GPR.
Signed-off-by Haibo Chen <[email protected]>--- arch/arm64/boot/dts/freescale/imx93.dtsi | 2 ++ 1 file changed, 2 insertions(+)arch/arm64/boot/dts/freescale/imx93.dtsi +0
-0
arch/arm64/boot/dts/freescale/imx93.dtsi flexcan1: can@443a0000 { · line 322
Quoted 4 lines
arch/arm64/boot/dts/freescale/imx93.dtsi +1
-0@@ -319,6 +319,7 @@ flexcan1: can@443a0000 { assigned-clock-parents = <&clk IMX93_CLK_SYS_PLL_PFD1_DIV2>; assigned-clock-rates = <40000000>; fsl,clk-source = /bits/ 8 <0>; + fsl,stop-mode = <&anomix_ns_gpr 0x14 0>;
I think there's a typo in the mainline imx93.dtsi. AFAICS it's supposed to be "aonmix_ns_gpr", not "anomix_ns_gpr". But that's a different problem to patch :)
AFAICS, according to imx93, rev2 data sheet, offset 0x14 is 76.6.1.3 QCHANNEL DISABLE (QCH_DIS) and bit 0 is "GPIO1". Are you sure this is the correct reg?
arch/arm64/boot/dts/freescale/imx93.dtsi flexcan2: can@425b0000 { · line 595
Quoted 8 lines
arch/arm64/boot/dts/freescale/imx93.dtsi +1
-0status = "disabled"; };@@ -591,6 +592,7 @@ flexcan2: can@425b0000 { assigned-clock-parents = <&clk IMX93_CLK_SYS_PLL_PFD1_DIV2>; assigned-clock-rates = <40000000>; fsl,clk-source = /bits/ 8 <0>; + fsl,stop-mode = <&wakeupmix_gpr 0x0C 2>;
looks plausible, please use lower case for hex addresses.
Quoted 7 lines
arch/arm64/boot/dts/freescale/imx93.dtsi +0
-0status = "disabled"; };Signature · 1 line
2.34.1
regards,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung Nürnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
Quoted 37 lines
-----Original Message-----
From: Marc Kleine-Budde <[email protected]>
Sent: 2023年7月26日 17:57
To: Bough Chen <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; dl-linux-imx <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2 1/3] arm64: dts: imx93: add the Flex-CAN stop mode by GPRQuoted 21 lines · On 26.07.2023 17:09:07, [email protected] wrote:
From: Haibo Chen <[email protected]>
imx93 A0 chip use the internal q-channel handshake signal in LPCG and CCM to automatically handle the Flex-CAN stop mode. But this method meet issue when do the system PM stress test. IC can't fix it easily. So in the new imx93 A1 chip, IC drop this method, and involve back the old way,use the GPR method to trigger the Flex-CAN stop mode signal. Now NXP claim to drop imx93 A0, and only support
imx93 A1. So here add the stop mode through GPR.Signed-off-by Haibo Chen <[email protected]>--- arch/arm64/boot/dts/freescale/imx93.dtsi | 2 ++ 1 file changed, 2 insertions(+)arch/arm64/boot/dts/freescale/imx93.dtsi +0
-0arch/arm64/boot/dts/freescale/imx93.dtsi flexcan1: can@443a0000 { · line 319
Quoted 1 line
arch/arm64/boot/dts/freescale/imx93.dtsi +0
-0@@ -319,6 +319,7 @@ flexcan1: can@443a0000 { assigned-clock-parents = <&clk
IMX93_CLK_SYS_PLL_PFD1_DIV2>;
Quoted 7 lines
arch/arm64/boot/dts/freescale/imx93.dtsi flexcan1: can@443a0000 { · line 322
Quoted 3 lines
arch/arm64/boot/dts/freescale/imx93.dtsi +1
-0assigned-clock-rates = <40000000>; fsl,clk-source = /bits/ 8 <0>; + fsl,stop-mode = <&anomix_ns_gpr 0x14 0>;I think there's a typo in the mainline
imx93.dtsi. AFAICS it's supposed to be "aonmix_ns_gpr", not "anomix_ns_gpr". But that's a different problem to patch :)
Yes, this is a typo.
Quoted 4 lines
AFAICS, according to imx93, rev2 data sheet, offset
0x14is 76.6.1.3 QCHANNEL DISABLE (QCH_DIS) and bit 0 is "GPIO1". Are you sure this is the correct reg?
Imx93 A1 doc has some update, I double confirm with the internal doc and IC team, the setting is correct. I also test on imx93-9x9 qsb board, system can be wakeup by this setting.
Quoted 11 lines
arch/arm64/boot/dts/freescale/imx93.dtsi flexcan2: can@425b0000 { · line 592
Quoted 5 lines
arch/arm64/boot/dts/freescale/imx93.dtsi +0
-0status = "disabled"; };@@ -591,6 +592,7 @@ flexcan2: can@425b0000 { assigned-clock-parents = <&clk
IMX93_CLK_SYS_PLL_PFD1_DIV2>;arch/arm64/boot/dts/freescale/imx93.dtsi flexcan2: can@425b0000 { · line 595
Quoted 3 lines
arch/arm64/boot/dts/freescale/imx93.dtsi +1
-0assigned-clock-rates = <40000000>; fsl,clk-source = /bits/ 8 <0>; + fsl,stop-mode = <&wakeupmix_gpr 0x0C 2>;looks plausible, please use lower case for hex addresses.
My bad, will fix.
Best Regards
Haibo Chen
Quoted 17 lines
Quoted 8 lines
arch/arm64/boot/dts/freescale/imx93.dtsi +0
-1status = "disabled"; }; --2.34.1
regards,
Marc--
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de |Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
Marc Kleine-Budde
maintainerQuoted 19 lines · Bough Chen
Quoted 11 lines
arch/arm64/boot/dts/freescale/imx93.dtsi flexcan1: can@443a0000 { · line 319
Quoted 10 lines
arch/arm64/boot/dts/freescale/imx93.dtsi | 2 ++ 1 file changed, 2 insertions(+)arch/arm64/boot/dts/freescale/imx93.dtsi +0
-0@@ -319,6 +319,7 @@ flexcan1: can@443a0000 { assigned-clock-parents = <&clk
IMX93_CLK_SYS_PLL_PFD1_DIV2>;Quoted 7 lines
arch/arm64/boot/dts/freescale/imx93.dtsi flexcan1: can@443a0000 { · line 322
Quoted 3 lines
arch/arm64/boot/dts/freescale/imx93.dtsi +1
-0assigned-clock-rates = <40000000>; fsl,clk-source = /bits/ 8 <0>; + fsl,stop-mode = <&anomix_ns_gpr 0x14 0>;I think there's a typo in the mainline
imx93.dtsi. AFAICS it's supposed to be "aonmix_ns_gpr", not "anomix_ns_gpr". But that's a different problem to patch :)
Quoted 8 lines
Yes, this is a typo.
Quoted 4 lines
AFAICS, according to imx93, rev2 data sheet, offset
0x14is 76.6.1.3 QCHANNEL DISABLE (QCH_DIS) and bit 0 is "GPIO1". Are you sure this is the correct reg?Imx93 A1 doc has some update, I double confirm with the internal doc and IC team, the setting is correct. I also test on imx93-9x9 qsb board, system can be wakeup by this setting.
Thanks for double checking.
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung Nürnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |