linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] can: flexcan: add auto stop mode for IMX93 to support wakeup
@ 2022-11-22 11:32 haibo.chen
  2022-11-22 11:32 ` [PATCH 2/3] dt-bindings: can: fsl,flexcan: add imx93 compatible haibo.chen
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: haibo.chen @ 2022-11-22 11:32 UTC (permalink / raw)
  To: wg, mkl, davem, edumazet, kuba, pabeni, robh+dt,
	krzysztof.kozlowski+dt, shawnguo, s.hauer
  Cc: kernel, festevam, linux-imx, haibo.chen, linux-can, netdev, devicetree

From: Haibo Chen <haibo.chen@nxp.com>

IMX93 do not contain a GPR to config the stop mode, it will set
the flexcan into stop mode automatically once the ARM core go
into low power mode (WFI instruct) and gate off the flexcan
related clock automatically. But to let these logic work as
expect, before ARM core go into low power mode, need to make
sure the flexcan related clock keep on.

To support stop mode and wakeup feature on imx93, this patch
add a new fsl_imx93_devtype_data to separate from imx8mp.

Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
---
 drivers/net/can/flexcan/flexcan-core.c | 37 +++++++++++++++++++++++---
 drivers/net/can/flexcan/flexcan.h      |  2 ++
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/flexcan-core.c
index 9bdadd716f4e..0aeff34e5ae1 100644
--- a/drivers/net/can/flexcan/flexcan-core.c
+++ b/drivers/net/can/flexcan/flexcan-core.c
@@ -345,6 +345,15 @@ static struct flexcan_devtype_data fsl_imx8mp_devtype_data = {
 		FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR,
 };
 
+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_SUPPORT_FD | FLEXCAN_QUIRK_SUPPORT_ECC |
+		FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX |
+		FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR,
+};
+
 static const struct flexcan_devtype_data fsl_vf610_devtype_data = {
 	.quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS |
 		FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_USE_RX_MAILBOX |
@@ -532,9 +541,14 @@ static inline int flexcan_enter_stop_mode(struct flexcan_priv *priv)
 		ret = flexcan_stop_mode_enable_scfw(priv, true);
 		if (ret < 0)
 			return ret;
-	} else {
+	} 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);
@@ -551,7 +565,7 @@ static inline int flexcan_exit_stop_mode(struct flexcan_priv *priv)
 		ret = flexcan_stop_mode_enable_scfw(priv, false);
 		if (ret < 0)
 			return ret;
-	} else {
+	} 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, 0);
 	}
@@ -560,6 +574,12 @@ static inline int flexcan_exit_stop_mode(struct flexcan_priv *priv)
 	reg_mcr &= ~FLEXCAN_MCR_SLF_WAK;
 	priv->write(reg_mcr, &regs->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);
 }
 
@@ -1974,6 +1994,8 @@ 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;
@@ -1992,6 +2014,7 @@ static int flexcan_setup_stop_mode(struct platform_device *pdev)
 static const struct of_device_id flexcan_of_match[] = {
 	{ .compatible = "fsl,imx8qm-flexcan", .data = &fsl_imx8qm_devtype_data, },
 	{ .compatible = "fsl,imx8mp-flexcan", .data = &fsl_imx8mp_devtype_data, },
+	{ .compatible = "fsl,imx93-flexcan", .data = &fsl_imx93_devtype_data, },
 	{ .compatible = "fsl,imx6q-flexcan", .data = &fsl_imx6q_devtype_data, },
 	{ .compatible = "fsl,imx28-flexcan", .data = &fsl_imx28_devtype_data, },
 	{ .compatible = "fsl,imx53-flexcan", .data = &fsl_imx25_devtype_data, },
@@ -2299,8 +2322,16 @@ 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)
diff --git a/drivers/net/can/flexcan/flexcan.h b/drivers/net/can/flexcan/flexcan.h
index 025c3417031f..91402977780b 100644
--- a/drivers/net/can/flexcan/flexcan.h
+++ b/drivers/net/can/flexcan/flexcan.h
@@ -68,6 +68,8 @@
 #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 */
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/3] dt-bindings: can: fsl,flexcan: add imx93 compatible
  2022-11-22 11:32 [PATCH 1/3] can: flexcan: add auto stop mode for IMX93 to support wakeup haibo.chen
@ 2022-11-22 11:32 ` haibo.chen
  2022-11-24 11:01   ` Krzysztof Kozlowski
  2022-11-22 11:32 ` [PATCH 3/3] arm64: dts: imx93: add flexcan nodes haibo.chen
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: haibo.chen @ 2022-11-22 11:32 UTC (permalink / raw)
  To: wg, mkl, davem, edumazet, kuba, pabeni, robh+dt,
	krzysztof.kozlowski+dt, shawnguo, s.hauer
  Cc: kernel, festevam, linux-imx, haibo.chen, linux-can, netdev, devicetree

From: Haibo Chen <haibo.chen@nxp.com>

Add a new compatible string for imx93.

Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
---
 Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml b/Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml
index e52db841bb8c..6e59bd2a6094 100644
--- a/Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml
+++ b/Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml
@@ -17,6 +17,7 @@ properties:
   compatible:
     oneOf:
       - enum:
+          - fsl,imx93-flexcan
           - fsl,imx8qm-flexcan
           - fsl,imx8mp-flexcan
           - fsl,imx6q-flexcan
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/3] arm64: dts: imx93: add flexcan nodes
  2022-11-22 11:32 [PATCH 1/3] can: flexcan: add auto stop mode for IMX93 to support wakeup haibo.chen
  2022-11-22 11:32 ` [PATCH 2/3] dt-bindings: can: fsl,flexcan: add imx93 compatible haibo.chen
@ 2022-11-22 11:32 ` haibo.chen
  2022-11-24 14:43   ` Marc Kleine-Budde
  2022-12-31  7:24   ` Shawn Guo
  2022-11-24 14:39 ` [PATCH 1/3] can: flexcan: add auto stop mode for IMX93 to support wakeup Marc Kleine-Budde
  2022-11-30 10:54 ` Marc Kleine-Budde
  3 siblings, 2 replies; 9+ messages in thread
From: haibo.chen @ 2022-11-22 11:32 UTC (permalink / raw)
  To: wg, mkl, davem, edumazet, kuba, pabeni, robh+dt,
	krzysztof.kozlowski+dt, shawnguo, s.hauer
  Cc: kernel, festevam, linux-imx, haibo.chen, linux-can, netdev, devicetree

From: Haibo Chen <haibo.chen@nxp.com>

Add flexcan1 and flexcan2 nodes.

Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
---
 arch/arm64/boot/dts/freescale/imx93.dtsi | 28 ++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx93.dtsi b/arch/arm64/boot/dts/freescale/imx93.dtsi
index 5d79663b3b84..6808321ed809 100644
--- a/arch/arm64/boot/dts/freescale/imx93.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx93.dtsi
@@ -223,6 +223,20 @@ lpuart2: serial@44390000 {
 				status = "disabled";
 			};
 
+			flexcan1: can@443a0000 {
+				compatible = "fsl,imx93-flexcan";
+				reg = <0x443a0000 0x10000>;
+				interrupts = <GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&clk IMX93_CLK_BUS_AON>,
+					 <&clk IMX93_CLK_CAN1_GATE>;
+				clock-names = "ipg", "per";
+				assigned-clocks = <&clk IMX93_CLK_CAN1>;
+				assigned-clock-parents = <&clk IMX93_CLK_SYS_PLL_PFD1_DIV2>;
+				assigned-clock-rates = <40000000>;
+				fsl,clk-source = /bits/ 8 <0>;
+				status = "disabled";
+			};
+
 			iomuxc: pinctrl@443c0000 {
 				compatible = "fsl,imx93-iomuxc";
 				reg = <0x443c0000 0x10000>;
@@ -393,6 +407,20 @@ lpuart6: serial@425a0000 {
 				status = "disabled";
 			};
 
+			flexcan2: can@425b0000 {
+				compatible = "fsl,imx93-flexcan";
+				reg = <0x425b0000 0x10000>;
+				interrupts = <GIC_SPI 51 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&clk IMX93_CLK_BUS_WAKEUP>,
+					 <&clk IMX93_CLK_CAN2_GATE>;
+				clock-names = "ipg", "per";
+				assigned-clocks = <&clk IMX93_CLK_CAN2>;
+				assigned-clock-parents = <&clk IMX93_CLK_SYS_PLL_PFD1_DIV2>;
+				assigned-clock-rates = <40000000>;
+				fsl,clk-source = /bits/ 8 <0>;
+				status = "disabled";
+			};
+
 			lpuart7: serial@42690000 {
 				compatible = "fsl,imx93-lpuart", "fsl,imx7ulp-lpuart";
 				reg = <0x42690000 0x1000>;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/3] dt-bindings: can: fsl,flexcan: add imx93 compatible
  2022-11-22 11:32 ` [PATCH 2/3] dt-bindings: can: fsl,flexcan: add imx93 compatible haibo.chen
@ 2022-11-24 11:01   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 9+ messages in thread
From: Krzysztof Kozlowski @ 2022-11-24 11:01 UTC (permalink / raw)
  To: haibo.chen, wg, mkl, davem, edumazet, kuba, pabeni, robh+dt,
	krzysztof.kozlowski+dt, shawnguo, s.hauer
  Cc: kernel, festevam, linux-imx, linux-can, netdev, devicetree

On 22/11/2022 12:32, haibo.chen@nxp.com wrote:
> From: Haibo Chen <haibo.chen@nxp.com>
> 
> Add a new compatible string for imx93.
> 


Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/3] can: flexcan: add auto stop mode for IMX93 to support wakeup
  2022-11-22 11:32 [PATCH 1/3] can: flexcan: add auto stop mode for IMX93 to support wakeup haibo.chen
  2022-11-22 11:32 ` [PATCH 2/3] dt-bindings: can: fsl,flexcan: add imx93 compatible haibo.chen
  2022-11-22 11:32 ` [PATCH 3/3] arm64: dts: imx93: add flexcan nodes haibo.chen
@ 2022-11-24 14:39 ` Marc Kleine-Budde
  2022-11-30 10:54 ` Marc Kleine-Budde
  3 siblings, 0 replies; 9+ messages in thread
From: Marc Kleine-Budde @ 2022-11-24 14:39 UTC (permalink / raw)
  To: haibo.chen
  Cc: wg, davem, edumazet, kuba, pabeni, robh+dt,
	krzysztof.kozlowski+dt, shawnguo, s.hauer, kernel, festevam,
	linux-imx, linux-can, netdev, devicetree

[-- Attachment #1: Type: text/plain, Size: 3613 bytes --]

On 22.11.2022 19:32:30, haibo.chen@nxp.com wrote:
> From: Haibo Chen <haibo.chen@nxp.com>
> 
> IMX93 do not contain a GPR to config the stop mode, it will set
> the flexcan into stop mode automatically once the ARM core go
> into low power mode (WFI instruct) and gate off the flexcan
> related clock automatically. But to let these logic work as
> expect, before ARM core go into low power mode, need to make
> sure the flexcan related clock keep on.
> 
> To support stop mode and wakeup feature on imx93, this patch
> add a new fsl_imx93_devtype_data to separate from imx8mp.
> 
> Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
> ---
>  drivers/net/can/flexcan/flexcan-core.c | 37 +++++++++++++++++++++++---
>  drivers/net/can/flexcan/flexcan.h      |  2 ++
>  2 files changed, 36 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/flexcan-core.c
> index 9bdadd716f4e..0aeff34e5ae1 100644
> --- a/drivers/net/can/flexcan/flexcan-core.c
> +++ b/drivers/net/can/flexcan/flexcan-core.c
> @@ -345,6 +345,15 @@ static struct flexcan_devtype_data fsl_imx8mp_devtype_data = {
>  		FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR,
>  };
>  
> +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_SUPPORT_FD | FLEXCAN_QUIRK_SUPPORT_ECC |
> +		FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX |
> +		FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR,
> +};
> +
>  static const struct flexcan_devtype_data fsl_vf610_devtype_data = {
>  	.quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS |
>  		FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_USE_RX_MAILBOX |
> @@ -532,9 +541,14 @@ static inline int flexcan_enter_stop_mode(struct flexcan_priv *priv)
>  		ret = flexcan_stop_mode_enable_scfw(priv, true);
>  		if (ret < 0)
>  			return ret;
> -	} else {
> +	} 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);
> @@ -551,7 +565,7 @@ static inline int flexcan_exit_stop_mode(struct flexcan_priv *priv)
>  		ret = flexcan_stop_mode_enable_scfw(priv, false);
>  		if (ret < 0)
>  			return ret;
> -	} else {
> +	} 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, 0);
>  	}
> @@ -560,6 +574,12 @@ static inline int flexcan_exit_stop_mode(struct flexcan_priv *priv)
>  	reg_mcr &= ~FLEXCAN_MCR_SLF_WAK;
>  	priv->write(reg_mcr, &regs->mcr);
>  
> +	/* For the auto stop mode, hardware will exist stop mode
                                                 ^^^^^
                                                 exit?

No need to resend.

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 |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/3] arm64: dts: imx93: add flexcan nodes
  2022-11-22 11:32 ` [PATCH 3/3] arm64: dts: imx93: add flexcan nodes haibo.chen
@ 2022-11-24 14:43   ` Marc Kleine-Budde
  2022-12-31  7:24   ` Shawn Guo
  1 sibling, 0 replies; 9+ messages in thread
From: Marc Kleine-Budde @ 2022-11-24 14:43 UTC (permalink / raw)
  To: haibo.chen
  Cc: wg, davem, edumazet, kuba, pabeni, robh+dt,
	krzysztof.kozlowski+dt, shawnguo, s.hauer, kernel, festevam,
	linux-imx, linux-can, netdev, devicetree

[-- Attachment #1: Type: text/plain, Size: 2380 bytes --]

Shawn,

do you take this patch?

Marc

On 22.11.2022 19:32:32, haibo.chen@nxp.com wrote:
> From: Haibo Chen <haibo.chen@nxp.com>
> 
> Add flexcan1 and flexcan2 nodes.
> 
> Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
> ---
>  arch/arm64/boot/dts/freescale/imx93.dtsi | 28 ++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/freescale/imx93.dtsi b/arch/arm64/boot/dts/freescale/imx93.dtsi
> index 5d79663b3b84..6808321ed809 100644
> --- a/arch/arm64/boot/dts/freescale/imx93.dtsi
> +++ b/arch/arm64/boot/dts/freescale/imx93.dtsi
> @@ -223,6 +223,20 @@ lpuart2: serial@44390000 {
>  				status = "disabled";
>  			};
>  
> +			flexcan1: can@443a0000 {
> +				compatible = "fsl,imx93-flexcan";
> +				reg = <0x443a0000 0x10000>;
> +				interrupts = <GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>;
> +				clocks = <&clk IMX93_CLK_BUS_AON>,
> +					 <&clk IMX93_CLK_CAN1_GATE>;
> +				clock-names = "ipg", "per";
> +				assigned-clocks = <&clk IMX93_CLK_CAN1>;
> +				assigned-clock-parents = <&clk IMX93_CLK_SYS_PLL_PFD1_DIV2>;
> +				assigned-clock-rates = <40000000>;
> +				fsl,clk-source = /bits/ 8 <0>;
> +				status = "disabled";
> +			};
> +
>  			iomuxc: pinctrl@443c0000 {
>  				compatible = "fsl,imx93-iomuxc";
>  				reg = <0x443c0000 0x10000>;
> @@ -393,6 +407,20 @@ lpuart6: serial@425a0000 {
>  				status = "disabled";
>  			};
>  
> +			flexcan2: can@425b0000 {
> +				compatible = "fsl,imx93-flexcan";
> +				reg = <0x425b0000 0x10000>;
> +				interrupts = <GIC_SPI 51 IRQ_TYPE_LEVEL_HIGH>;
> +				clocks = <&clk IMX93_CLK_BUS_WAKEUP>,
> +					 <&clk IMX93_CLK_CAN2_GATE>;
> +				clock-names = "ipg", "per";
> +				assigned-clocks = <&clk IMX93_CLK_CAN2>;
> +				assigned-clock-parents = <&clk IMX93_CLK_SYS_PLL_PFD1_DIV2>;
> +				assigned-clock-rates = <40000000>;
> +				fsl,clk-source = /bits/ 8 <0>;
> +				status = "disabled";
> +			};
> +
>  			lpuart7: serial@42690000 {
>  				compatible = "fsl,imx93-lpuart", "fsl,imx7ulp-lpuart";
>  				reg = <0x42690000 0x1000>;
> -- 
> 2.34.1
> 
> 

-- 
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 |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/3] can: flexcan: add auto stop mode for IMX93 to support wakeup
  2022-11-22 11:32 [PATCH 1/3] can: flexcan: add auto stop mode for IMX93 to support wakeup haibo.chen
                   ` (2 preceding siblings ...)
  2022-11-24 14:39 ` [PATCH 1/3] can: flexcan: add auto stop mode for IMX93 to support wakeup Marc Kleine-Budde
@ 2022-11-30 10:54 ` Marc Kleine-Budde
  2022-11-30 11:39   ` Bough Chen
  3 siblings, 1 reply; 9+ messages in thread
From: Marc Kleine-Budde @ 2022-11-30 10:54 UTC (permalink / raw)
  To: haibo.chen
  Cc: wg, davem, edumazet, kuba, pabeni, robh+dt,
	krzysztof.kozlowski+dt, shawnguo, s.hauer, kernel, festevam,
	linux-imx, linux-can, netdev, devicetree

[-- Attachment #1: Type: text/plain, Size: 2222 bytes --]

On 22.11.2022 19:32:30, haibo.chen@nxp.com wrote:
> From: Haibo Chen <haibo.chen@nxp.com>
> 
> IMX93 do not contain a GPR to config the stop mode, it will set
> the flexcan into stop mode automatically once the ARM core go
> into low power mode (WFI instruct) and gate off the flexcan
> related clock automatically. But to let these logic work as
> expect, before ARM core go into low power mode, need to make
> sure the flexcan related clock keep on.
> 
> To support stop mode and wakeup feature on imx93, this patch
> add a new fsl_imx93_devtype_data to separate from imx8mp.
> 
> Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
> ---
>  drivers/net/can/flexcan/flexcan-core.c | 37 +++++++++++++++++++++++---
>  drivers/net/can/flexcan/flexcan.h      |  2 ++
>  2 files changed, 36 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/flexcan-core.c
> index 9bdadd716f4e..0aeff34e5ae1 100644
> --- a/drivers/net/can/flexcan/flexcan-core.c
> +++ b/drivers/net/can/flexcan/flexcan-core.c

[...]

> @@ -2299,8 +2322,16 @@ 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;
> +		}

With this change the flexcan_noirq_resume() is not symmetrical any more:
pm_runtime_force_suspend() is not called for mx93, but
pm_runtime_force_resume() is called.

>  
>  		err = pm_runtime_force_suspend(device);
>  		if (err)

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 |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH 1/3] can: flexcan: add auto stop mode for IMX93 to support wakeup
  2022-11-30 10:54 ` Marc Kleine-Budde
@ 2022-11-30 11:39   ` Bough Chen
  0 siblings, 0 replies; 9+ messages in thread
From: Bough Chen @ 2022-11-30 11:39 UTC (permalink / raw)
  To: Marc Kleine-Budde
  Cc: wg, davem, edumazet, kuba, pabeni, robh+dt,
	krzysztof.kozlowski+dt, shawnguo, s.hauer, kernel, festevam,
	dl-linux-imx, linux-can, netdev, devicetree

> -----Original Message-----
> From: Marc Kleine-Budde <mkl@pengutronix.de>
> Sent: 2022年11月30日 18:54
> To: Bough Chen <haibo.chen@nxp.com>
> Cc: wg@grandegger.com; davem@davemloft.net; edumazet@google.com;
> kuba@kernel.org; pabeni@redhat.com; robh+dt@kernel.org;
> krzysztof.kozlowski+dt@linaro.org; shawnguo@kernel.org;
> s.hauer@pengutronix.de; kernel@pengutronix.de; festevam@gmail.com;
> dl-linux-imx <linux-imx@nxp.com>; linux-can@vger.kernel.org;
> netdev@vger.kernel.org; devicetree@vger.kernel.org
> Subject: Re: [PATCH 1/3] can: flexcan: add auto stop mode for IMX93 to support
> wakeup
> 
> On 22.11.2022 19:32:30, haibo.chen@nxp.com wrote:
> > From: Haibo Chen <haibo.chen@nxp.com>
> >
> > IMX93 do not contain a GPR to config the stop mode, it will set the
> > flexcan into stop mode automatically once the ARM core go into low
> > power mode (WFI instruct) and gate off the flexcan related clock
> > automatically. But to let these logic work as expect, before ARM core
> > go into low power mode, need to make sure the flexcan related clock
> > keep on.
> >
> > To support stop mode and wakeup feature on imx93, this patch add a new
> > fsl_imx93_devtype_data to separate from imx8mp.
> >
> > Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
> > ---
> >  drivers/net/can/flexcan/flexcan-core.c | 37 +++++++++++++++++++++++---
> >  drivers/net/can/flexcan/flexcan.h      |  2 ++
> >  2 files changed, 36 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/can/flexcan/flexcan-core.c
> > b/drivers/net/can/flexcan/flexcan-core.c
> > index 9bdadd716f4e..0aeff34e5ae1 100644
> > --- a/drivers/net/can/flexcan/flexcan-core.c
> > +++ b/drivers/net/can/flexcan/flexcan-core.c
> 
> [...]
> 
> > @@ -2299,8 +2322,16 @@ 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;
> > +		}
> 
> With this change the flexcan_noirq_resume() is not symmetrical any more:
> pm_runtime_force_suspend() is not called for mx93, but
> pm_runtime_force_resume() is called.

Yes, I do not understand the logic of pm_runtime_force_suspend correctly. I also find there is an unbalance warning show up. My bad.

Will fix this and send a V2 patch.

Best Regards
Haibo Chen
> 
> >
> >  		err = pm_runtime_force_suspend(device);
> >  		if (err)
> 
> 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 |

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/3] arm64: dts: imx93: add flexcan nodes
  2022-11-22 11:32 ` [PATCH 3/3] arm64: dts: imx93: add flexcan nodes haibo.chen
  2022-11-24 14:43   ` Marc Kleine-Budde
@ 2022-12-31  7:24   ` Shawn Guo
  1 sibling, 0 replies; 9+ messages in thread
From: Shawn Guo @ 2022-12-31  7:24 UTC (permalink / raw)
  To: haibo.chen
  Cc: wg, mkl, davem, edumazet, kuba, pabeni, robh+dt,
	krzysztof.kozlowski+dt, s.hauer, kernel, festevam, linux-imx,
	linux-can, netdev, devicetree

On Tue, Nov 22, 2022 at 07:32:32PM +0800, haibo.chen@nxp.com wrote:
> From: Haibo Chen <haibo.chen@nxp.com>
> 
> Add flexcan1 and flexcan2 nodes.
> 
> Signed-off-by: Haibo Chen <haibo.chen@nxp.com>

Applied, thanks!

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-12-31  7:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-22 11:32 [PATCH 1/3] can: flexcan: add auto stop mode for IMX93 to support wakeup haibo.chen
2022-11-22 11:32 ` [PATCH 2/3] dt-bindings: can: fsl,flexcan: add imx93 compatible haibo.chen
2022-11-24 11:01   ` Krzysztof Kozlowski
2022-11-22 11:32 ` [PATCH 3/3] arm64: dts: imx93: add flexcan nodes haibo.chen
2022-11-24 14:43   ` Marc Kleine-Budde
2022-12-31  7:24   ` Shawn Guo
2022-11-24 14:39 ` [PATCH 1/3] can: flexcan: add auto stop mode for IMX93 to support wakeup Marc Kleine-Budde
2022-11-30 10:54 ` Marc Kleine-Budde
2022-11-30 11:39   ` Bough Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).