[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <c24b0982-13af-ecdd-c3a2-7ec62863483c@pengutronix.de>
Date: Mon, 17 Jun 2019 14:57:31 +0200
From: Marc Kleine-Budde <mkl@...gutronix.de>
To: Joakim Zhang <qiangqing.zhang@....com>,
"linux-can@...r.kernel.org" <linux-can@...r.kernel.org>
Cc: dl-linux-imx <linux-imx@....com>,
"wg@...ndegger.com" <wg@...ndegger.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: Re: [PATCH] can: flexcan: fix stop mode acknowledgment
On 6/11/19 8:47 AM, Joakim Zhang wrote:
> To enter stop mode, the CPU should manually assert a global Stop Mode
> request and check the acknowledgment asserted by FlexCAN. The CPU must
> only consider the FlexCAN in stop mode when both request and
> acknowledgment conditions are satisfied.
>
> Fixes: de3578c198c6 ("can: flexcan: add self wakeup support")
> Reported-by: Marc Kleine-Budde <mkl@...gutronix.de>
> Signed-off-by: Joakim Zhang <qiangqing.zhang@....com>
> ---
> drivers/net/can/flexcan.c | 47 ++++++++++++++++++++++++++++++++-------
> 1 file changed, 39 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
> index e35083ff31ee..282dac1d8f5c 100644
> --- a/drivers/net/can/flexcan.c
> +++ b/drivers/net/can/flexcan.c
> @@ -404,9 +404,11 @@ static void flexcan_enable_wakeup_irq(struct flexcan_priv *priv, bool enable)
> priv->write(reg_mcr, ®s->mcr);
> }
>
> -static inline void flexcan_enter_stop_mode(struct flexcan_priv *priv)
> +static inline int flexcan_enter_stop_mode(struct flexcan_priv *priv)
> {
> struct flexcan_regs __iomem *regs = priv->regs;
> + unsigned int timeout = FLEXCAN_TIMEOUT_US / 10;
> + unsigned int ackval;
> u32 reg_mcr;
>
> reg_mcr = priv->read(®s->mcr);
> @@ -416,20 +418,48 @@ static inline void flexcan_enter_stop_mode(struct flexcan_priv *priv)
> /* enable stop request */
> regmap_update_bits(priv->stm.gpr, priv->stm.req_gpr,
> 1 << priv->stm.req_bit, 1 << priv->stm.req_bit);
> +
> + /* get stop acknowledgment */
> + regmap_read(priv->stm.gpr, priv->stm.ack_gpr, &ackval);
Please make use of regmap_read_poll_timeout().
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists