Skip to content

Commit 048e3a3

Browse files
Joakim Zhangmarckleinebudde
authored andcommitted
can: flexcan: poll MCR_LPM_ACK instead of GPR ACK for stop mode acknowledgment
Stop Mode is entered when Stop Mode is requested at chip level and MCR[LPM_ACK] is asserted by the FlexCAN. Double check with IP owner, the MCR[LPM_ACK] bit should be polled for stop mode acknowledgment, not the acknowledgment from chip level which is used to gate flexcan clocks. This patch depends on: b7603d0 ("can: flexcan: add low power enter/exit acknowledgment helper") Fixes: 5f186c2 (can: flexcan: fix stop mode acknowledgment) Tested-by: Sean Nyekjaer <[email protected]> Signed-off-by: Joakim Zhang <[email protected]> Cc: linux-stable <[email protected]> # >= v5.0 Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent b7603d0 commit 048e3a3

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

drivers/net/can/flexcan.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,6 @@ static void flexcan_enable_wakeup_irq(struct flexcan_priv *priv, bool enable)
435435
static inline int flexcan_enter_stop_mode(struct flexcan_priv *priv)
436436
{
437437
struct flexcan_regs __iomem *regs = priv->regs;
438-
unsigned int ackval;
439438
u32 reg_mcr;
440439

441440
reg_mcr = priv->read(&regs->mcr);
@@ -446,36 +445,24 @@ static inline int flexcan_enter_stop_mode(struct flexcan_priv *priv)
446445
regmap_update_bits(priv->stm.gpr, priv->stm.req_gpr,
447446
1 << priv->stm.req_bit, 1 << priv->stm.req_bit);
448447

449-
/* get stop acknowledgment */
450-
if (regmap_read_poll_timeout(priv->stm.gpr, priv->stm.ack_gpr,
451-
ackval, ackval & (1 << priv->stm.ack_bit),
452-
0, FLEXCAN_TIMEOUT_US))
453-
return -ETIMEDOUT;
454-
455-
return 0;
448+
return flexcan_low_power_enter_ack(priv);
456449
}
457450

458451
static inline int flexcan_exit_stop_mode(struct flexcan_priv *priv)
459452
{
460453
struct flexcan_regs __iomem *regs = priv->regs;
461-
unsigned int ackval;
462454
u32 reg_mcr;
463455

464456
/* remove stop request */
465457
regmap_update_bits(priv->stm.gpr, priv->stm.req_gpr,
466458
1 << priv->stm.req_bit, 0);
467459

468-
/* get stop acknowledgment */
469-
if (regmap_read_poll_timeout(priv->stm.gpr, priv->stm.ack_gpr,
470-
ackval, !(ackval & (1 << priv->stm.ack_bit)),
471-
0, FLEXCAN_TIMEOUT_US))
472-
return -ETIMEDOUT;
473460

474461
reg_mcr = priv->read(&regs->mcr);
475462
reg_mcr &= ~FLEXCAN_MCR_SLF_WAK;
476463
priv->write(reg_mcr, &regs->mcr);
477464

478-
return 0;
465+
return flexcan_low_power_exit_ack(priv);
479466
}
480467

481468
static inline void flexcan_error_irq_enable(const struct flexcan_priv *priv)

0 commit comments

Comments
 (0)