@@ -354,6 +354,14 @@ static struct flexcan_devtype_data fsl_imx93_devtype_data = {
354
354
FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR ,
355
355
};
356
356
357
+ static const struct flexcan_devtype_data fsl_imx95_devtype_data = {
358
+ .quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS |
359
+ FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_USE_RX_MAILBOX |
360
+ FLEXCAN_QUIRK_BROKEN_PERR_STATE | FLEXCAN_QUIRK_SUPPORT_FD |
361
+ FLEXCAN_QUIRK_SUPPORT_ECC | FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX |
362
+ FLEXCAN_QUIRK_SUPPORT_RX_MAILBOX_RTR | FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI ,
363
+ };
364
+
357
365
static const struct flexcan_devtype_data fsl_vf610_devtype_data = {
358
366
.quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS |
359
367
FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_USE_RX_MAILBOX |
@@ -544,6 +552,13 @@ static inline int flexcan_enter_stop_mode(struct flexcan_priv *priv)
544
552
} else if (priv -> devtype_data .quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR ) {
545
553
regmap_update_bits (priv -> stm .gpr , priv -> stm .req_gpr ,
546
554
1 << priv -> stm .req_bit , 1 << priv -> stm .req_bit );
555
+ } else if (priv -> devtype_data .quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI ) {
556
+ /* For the SCMI mode, driver do nothing, ATF will send request to
557
+ * SM(system manager, M33 core) through SCMI protocol after linux
558
+ * suspend. Once SM get this request, it will send IPG_STOP signal
559
+ * to Flex_CAN, let CAN in STOP mode.
560
+ */
561
+ return 0 ;
547
562
}
548
563
549
564
return flexcan_low_power_enter_ack (priv );
@@ -555,7 +570,11 @@ static inline int flexcan_exit_stop_mode(struct flexcan_priv *priv)
555
570
u32 reg_mcr ;
556
571
int ret ;
557
572
558
- /* remove stop request */
573
+ /* Remove stop request, for FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI,
574
+ * do nothing here, because ATF already send request to SM before
575
+ * linux resume. Once SM get this request, it will deassert the
576
+ * IPG_STOP signal to Flex_CAN.
577
+ */
559
578
if (priv -> devtype_data .quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_SCFW ) {
560
579
ret = flexcan_stop_mode_enable_scfw (priv , false);
561
580
if (ret < 0 )
@@ -1983,6 +2002,9 @@ static int flexcan_setup_stop_mode(struct platform_device *pdev)
1983
2002
ret = flexcan_setup_stop_mode_scfw (pdev );
1984
2003
else if (priv -> devtype_data .quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR )
1985
2004
ret = flexcan_setup_stop_mode_gpr (pdev );
2005
+ else if (priv -> devtype_data .quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI )
2006
+ /* ATF will handle all STOP_IPG related work */
2007
+ ret = 0 ;
1986
2008
else
1987
2009
/* return 0 directly if doesn't support stop mode feature */
1988
2010
return 0 ;
@@ -2009,6 +2031,7 @@ static const struct of_device_id flexcan_of_match[] = {
2009
2031
{ .compatible = "fsl,imx8qm-flexcan" , .data = & fsl_imx8qm_devtype_data , },
2010
2032
{ .compatible = "fsl,imx8mp-flexcan" , .data = & fsl_imx8mp_devtype_data , },
2011
2033
{ .compatible = "fsl,imx93-flexcan" , .data = & fsl_imx93_devtype_data , },
2034
+ { .compatible = "fsl,imx95-flexcan" , .data = & fsl_imx95_devtype_data , },
2012
2035
{ .compatible = "fsl,imx6q-flexcan" , .data = & fsl_imx6q_devtype_data , },
2013
2036
{ .compatible = "fsl,imx28-flexcan" , .data = & fsl_imx28_devtype_data , },
2014
2037
{ .compatible = "fsl,imx53-flexcan" , .data = & fsl_imx25_devtype_data , },
@@ -2309,9 +2332,19 @@ static int __maybe_unused flexcan_noirq_suspend(struct device *device)
2309
2332
if (device_may_wakeup (device ))
2310
2333
flexcan_enable_wakeup_irq (priv , true);
2311
2334
2312
- err = pm_runtime_force_suspend (device );
2313
- if (err )
2314
- return err ;
2335
+ /* For FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI, it need ATF to send
2336
+ * to SM through SCMI protocol, SM will assert the IPG_STOP
2337
+ * signal. But all this works need the CAN clocks keep on.
2338
+ * After the CAN module get the IPG_STOP mode, and switch to
2339
+ * STOP mode, whether still keep the CAN clocks on or gate them
2340
+ * off depend on the Hardware design.
2341
+ */
2342
+ if (!(device_may_wakeup (device ) &&
2343
+ priv -> devtype_data .quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI )) {
2344
+ err = pm_runtime_force_suspend (device );
2345
+ if (err )
2346
+ return err ;
2347
+ }
2315
2348
}
2316
2349
2317
2350
return 0 ;
@@ -2325,9 +2358,12 @@ static int __maybe_unused flexcan_noirq_resume(struct device *device)
2325
2358
if (netif_running (dev )) {
2326
2359
int err ;
2327
2360
2328
- err = pm_runtime_force_resume (device );
2329
- if (err )
2330
- return err ;
2361
+ if (!(device_may_wakeup (device ) &&
2362
+ priv -> devtype_data .quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI )) {
2363
+ err = pm_runtime_force_resume (device );
2364
+ if (err )
2365
+ return err ;
2366
+ }
2331
2367
2332
2368
if (device_may_wakeup (device ))
2333
2369
flexcan_enable_wakeup_irq (priv , false);
0 commit comments