Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3231599imu; Sat, 24 Nov 2018 00:39:48 -0800 (PST) X-Google-Smtp-Source: AFSGD/XB0fzDiLGz9kY8OYGFUXr2yJyYWiFwqJluayLtfRsb+IuuvOgM7BOnFD8YQMFD4+hQS1zX X-Received: by 2002:a63:d301:: with SMTP id b1mr17254251pgg.61.1543048788465; Sat, 24 Nov 2018 00:39:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543048788; cv=none; d=google.com; s=arc-20160816; b=Yt7XuLoFhR1cvTQ2aRkkpU+qW1WYj3dnzv2T17u9w7DMwkS7MGwqVkNSD4JMHJjOyl YpN6BfPdbB1tf/w2j133KUfXqKxSPpuTLCjnW1PeA70/oTPB2Z4l7B3K/0fs8XzCGVmT yJ5LcCJozlNTMjb7/Ol3n8DIe5JsbWAgkWJxdSwvBevQMq+z4os22H1vcw8QW5Ryp+O6 xvLQ3LUTRVVMRU6/T+9r1XEqV63cF0MXiV99E9fOtcXNFU89CWUkfCEFi4wD/HDrnReX T0ZHpJW16EhYD+pY1wrquHEouIZxyQ/qhv/M6GNlIM6wflPiBZmvv+jz8o0lOGpx6+lf hzaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:mime-version:user-agent:date :message-id:subject:autocrypt:openpgp:from:references:cc:to; bh=ib1tz7Hpkz912l7bbtHFIQr4vcAV0mRqIB+12MhdneM=; b=fESA9J1VKEan6JQ5N3OFTZ9TphmrkzRxrMCYbQoBZ/VIMVJ5QC7FYym3nyh9KjY8SN 9hYWHrAx/wS5HhpLfDB0ifvb35lnnNZuaxbD75aD5+gMNtZGS95qC5lTBYZJMFPQcCsO ruc1yxF4sKvS10SWRWZkLvI/v257a3rBDMHtTmOncSfzYqoxjInOb84zOoXhLn0oNtXg Zbtdo+8ZmlB1EL5oL1nqSQhjAfJLP4dH3Zo46QCjAZ7ygebu6A3AHJZmagp1je076MFp 57xKjIN3d8B4ScR+GConaGRbwSJdPz+VOhkEMEpOAxMS8fhHvlex+J3wz9dGQMfBOIId 4HKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g10si24014020plq.371.2018.11.24.00.39.34; Sat, 24 Nov 2018 00:39:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2504725AbeKXBsh (ORCPT + 99 others); Fri, 23 Nov 2018 20:48:37 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:47641 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732166AbeKXBsg (ORCPT ); Fri, 23 Nov 2018 20:48:36 -0500 Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=bjornoya.blackshift.org) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gQCzu-0004s0-9f; Fri, 23 Nov 2018 16:03:58 +0100 Received: from [IPv6:2a03:f580:87bc:d400:e586:a438:6bdb:ffff] (unknown [IPv6:2a03:f580:87bc:d400:e586:a438:6bdb:ffff]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mkl@blackshift.org", Issuer "StartCom Class 1 Client CA" (not verified)) (Authenticated sender: mkl@blackshift.org) by smtp.blackshift.org (Postfix) with ESMTPSA id C6749393FD6; Fri, 23 Nov 2018 15:03:56 +0000 (UTC) To: Joakim Zhang , "linux-can@vger.kernel.org" , "robh+dt@kernel.org" Cc: "wg@grandegger.com" , "mark.rutland@arm.com" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , dl-linux-imx , Aisheng DONG References: <20181123083304.3232-1-qiangqing.zhang@nxp.com> <20181123083304.3232-3-qiangqing.zhang@nxp.com> From: Marc Kleine-Budde Openpgp: preference=signencrypt Autocrypt: addr=mkl@pengutronix.de; prefer-encrypt=mutual; keydata= mQINBFFVq30BEACtnSvtXHoeHJxG6nRULcvlkW6RuNwHKmrqoksispp43X8+nwqIFYgb8UaX zu8T6kZP2wEIpM9RjEL3jdBjZNCsjSS6x1qzpc2+2ivjdiJsqeaagIgvy2JWy7vUa4/PyGfx QyUeXOxdj59DvLwAx8I6hOgeHx2X/ntKAMUxwawYfPZpP3gwTNKc27dJWSomOLgp+gbmOmgc 6U5KwhAxPTEb3CsT5RicsC+uQQFumdl5I6XS+pbeXZndXwnj5t84M+HEj7RN6bUfV2WZO/AB Xt5+qFkC/AVUcj/dcHvZwQJlGeZxoi4veCoOT2MYqfR0ax1MmN+LVRvKm29oSyD4Ts/97cbs XsZDRxnEG3z/7Winiv0ZanclA7v7CQwrzsbpCv+oj+zokGuKasofzKdpywkjAfSE1zTyF+8K nxBAmzwEqeQ3iKqBc3AcCseqSPX53mPqmwvNVS2GqBpnOfY7Mxr1AEmxdEcRYbhG6Xdn+ACq Dq0Db3A++3PhMSaOu125uIAIwMXRJIzCXYSqXo8NIeo9tobk0C/9w3fUfMTrBDtSviLHqlp8 eQEP8+TDSmRP/CwmFHv36jd+XGmBHzW5I7qw0OORRwNFYBeEuiOIgxAfjjbLGHh9SRwEqXAL kw+WVTwh0MN1k7I9/CDVlGvc3yIKS0sA+wudYiselXzgLuP5cQARAQABtCZNYXJjIEtsZWlu ZS1CdWRkZSA8bWtsQHBlbmd1dHJvbml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CEJxn5s9Y5Y31hPGlQnYDPAuYMrDVBRsIQVwAsWpV83vKjp4WFP4wC1LEYj+j/Oorqv ALsMRq49WSclOMvqDdh//wmfSAbkyn3EA6EMv9mxJHJvKW7PMXvO0Mk1uP/+VR3FudMXhZzz MUYlqpO3B/RmA7lPoMY5+Km8c4/6L9Bn0vcbGMH4piH0IuEK0px64oXtKfti47XrCX+EDpSn ZwhEnNjCKyAJTaangebRpvOwJUZUWVh+hpM5FMcwJGKvVXNmrmSj Subject: Re: [PATCH V6 2/2] can: flexcan: add self wakeup support Message-ID: <1be643fb-e966-fc2d-d19f-2a1e45b58641@pengutronix.de> Date: Fri, 23 Nov 2018 16:03:53 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <20181123083304.3232-3-qiangqing.zhang@nxp.com> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="trC1QlQ0mUvy5WJC6BtKgYZWIOhHsXJ07" X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: mkl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --trC1QlQ0mUvy5WJC6BtKgYZWIOhHsXJ07 Content-Type: multipart/mixed; boundary="5ecR1lUw7oiKwKbiJSwsPr7HPuwBbTq2U"; protected-headers="v1" From: Marc Kleine-Budde To: Joakim Zhang , "linux-can@vger.kernel.org" , "robh+dt@kernel.org" Cc: "wg@grandegger.com" , "mark.rutland@arm.com" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , dl-linux-imx , Aisheng DONG Message-ID: <1be643fb-e966-fc2d-d19f-2a1e45b58641@pengutronix.de> Subject: Re: [PATCH V6 2/2] can: flexcan: add self wakeup support References: <20181123083304.3232-1-qiangqing.zhang@nxp.com> <20181123083304.3232-3-qiangqing.zhang@nxp.com> In-Reply-To: <20181123083304.3232-3-qiangqing.zhang@nxp.com> --5ecR1lUw7oiKwKbiJSwsPr7HPuwBbTq2U Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: quoted-printable On 11/23/18 9:35 AM, Joakim Zhang wrote: > From: Aisheng Dong >=20 > If wakeup is enabled, enter stop mode, else enter disabled mode. Self w= ake > can only work on stop mode. >=20 > Starting from IMX6, the flexcan stop mode control bits is SoC specific,= > move it out of IP driver and parse it from devicetree. >=20 > Signed-off-by: Aisheng Dong > Signed-off-by: Joakim Zhang > --- > ChangeLog: > V1->V2: > *add a vendor prefix in property (stop-mode -> fsl,stop-mode). > V2->V3: > *add FLEXCAN_QUIRK_SETUP_STOP_MODE quirk. > *rename function. > *fix system can't be wakeuped during suspend. > V3->V4: > *normalize the code following Aisheng Dong's comments. > V4->V5: > *move enable/disable self wakeup feature into > enter/exit_stop_mode() function. > V5->V6: > *exchange the order of flexcan_enable_wakeup_irq(priv, false) > and disable_irq_wake(dev->irq). > --- > drivers/net/can/flexcan.c | 172 ++++++++++++++++++++++++++++++++++++--= > 1 file changed, 163 insertions(+), 9 deletions(-) >=20 > diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c > index 8e972ef08637..da08a8c113d2 100644 > --- a/drivers/net/can/flexcan.c > +++ b/drivers/net/can/flexcan.c > @@ -19,11 +19,14 @@ > #include > #include > #include > +#include > +#include > #include > #include > #include > #include > #include > +#include > =20 > #define DRV_NAME "flexcan" > =20 > @@ -131,7 +134,8 @@ > (FLEXCAN_ESR_ERR_BUS | FLEXCAN_ESR_ERR_STATE) > #define FLEXCAN_ESR_ALL_INT \ > (FLEXCAN_ESR_TWRN_INT | FLEXCAN_ESR_RWRN_INT | \ > - FLEXCAN_ESR_BOFF_INT | FLEXCAN_ESR_ERR_INT) > + FLEXCAN_ESR_BOFF_INT | FLEXCAN_ESR_ERR_INT | \ > + FLEXCAN_ESR_WAK_INT) I've fixed the indention while applying the patch. > =20 > /* FLEXCAN interrupt flag register (IFLAG) bits */ > /* Errata ERR005829 step7: Reserve first valid MB */ > @@ -190,6 +194,7 @@ > #define FLEXCAN_QUIRK_USE_OFF_TIMESTAMP BIT(5) /* Use timestamp based = offloading */ > #define FLEXCAN_QUIRK_BROKEN_PERR_STATE BIT(6) /* No interrupt for err= or passive */ > #define FLEXCAN_QUIRK_DEFAULT_BIG_ENDIAN BIT(7) /* default to BE regis= ter access */ > +#define FLEXCAN_QUIRK_SETUP_STOP_MODE BIT(8) /* Setup stop mode to su= pport wakeup */ > =20 > /* Structure of the message buffer */ > struct flexcan_mb { > @@ -254,6 +259,14 @@ struct flexcan_devtype_data { > u32 quirks; /* quirks needed for different IP cores */ > }; > =20 > +struct flexcan_stop_mode { > + struct regmap *gpr; > + u8 req_gpr; > + u8 req_bit; > + u8 ack_gpr; > + u8 ack_bit; > +}; > + > struct flexcan_priv { > struct can_priv can; > struct can_rx_offload offload; > @@ -270,6 +283,7 @@ struct flexcan_priv { > struct clk *clk_per; > const struct flexcan_devtype_data *devtype_data; > struct regulator *reg_xceiver; > + struct flexcan_stop_mode stm; > =20 > /* Read and Write APIs */ > u32 (*read)(void __iomem *addr); > @@ -293,7 +307,8 @@ static const struct flexcan_devtype_data fsl_imx28_= devtype_data =3D { > =20 > static const struct flexcan_devtype_data fsl_imx6q_devtype_data =3D { > .quirks =3D FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_R= RS | > - FLEXCAN_QUIRK_USE_OFF_TIMESTAMP | FLEXCAN_QUIRK_BROKEN_PERR_STATE, > + FLEXCAN_QUIRK_USE_OFF_TIMESTAMP | FLEXCAN_QUIRK_BROKEN_PERR_STATE | > + FLEXCAN_QUIRK_SETUP_STOP_MODE, > }; > =20 > static const struct flexcan_devtype_data fsl_vf610_devtype_data =3D { > @@ -353,6 +368,49 @@ static inline void flexcan_write_le(u32 val, void = __iomem *addr) > iowrite32(val, addr); > } > =20 > +static void flexcan_enable_wakeup_irq(struct flexcan_priv *priv, bool = enable) > +{ > + struct flexcan_regs __iomem *regs =3D priv->regs; > + u32 reg_mcr; > + > + reg_mcr =3D priv->read(®s->mcr); > + > + if (enable) > + reg_mcr |=3D FLEXCAN_MCR_WAK_MSK; > + else > + reg_mcr &=3D ~FLEXCAN_MCR_WAK_MSK; > + > + priv->write(reg_mcr, ®s->mcr); > +} > + > +static inline void flexcan_enter_stop_mode(struct flexcan_priv *priv) > +{ > + struct flexcan_regs __iomem *regs =3D priv->regs; > + u32 reg_mcr; > + > + reg_mcr =3D priv->read(®s->mcr); > + reg_mcr |=3D FLEXCAN_MCR_SLF_WAK; > + priv->write(reg_mcr, ®s->mcr); > + > + /* enable stop request */ > + regmap_update_bits(priv->stm.gpr, priv->stm.req_gpr, > + 1 << priv->stm.req_bit, 1 << priv->stm.req_bit); > +} > + > +static inline void flexcan_exit_stop_mode(struct flexcan_priv *priv) > +{ > + struct flexcan_regs __iomem *regs =3D priv->regs; > + u32 reg_mcr; > + > + /* remove stop request */ > + regmap_update_bits(priv->stm.gpr, priv->stm.req_gpr, > + 1 << priv->stm.req_bit, 0); > + > + reg_mcr =3D priv->read(®s->mcr); > + reg_mcr &=3D ~FLEXCAN_MCR_SLF_WAK; > + priv->write(reg_mcr, ®s->mcr); > +} > + > static inline void flexcan_error_irq_enable(const struct flexcan_priv = *priv) > { > struct flexcan_regs __iomem *regs =3D priv->regs; > @@ -1244,6 +1302,57 @@ static void unregister_flexcandev(struct net_dev= ice *dev) > unregister_candev(dev); > } > =20 > +static int flexcan_setup_stop_mode(struct platform_device *pdev) > +{ > + struct net_device *dev =3D platform_get_drvdata(pdev); > + struct device_node *np =3D pdev->dev.of_node; > + struct device_node *gpr_np; > + struct flexcan_priv *priv; > + phandle phandle; > + u32 out_val[5]; > + int ret; > + > + if (!np) > + return -EINVAL; > + > + /* stop mode property format is: > + * <&gpr req_gpr req_bit ack_gpr ack_bit>. > + */ > + ret =3D of_property_read_u32_array(np, "fsl,stop-mode", out_val, 5); I've changed the 5 to ARRAY_SIZE() while applying the patch + rewrap to 80 cols. > + if (ret) { > + dev_dbg(&pdev->dev, "no stop-mode property\n"); > + return ret; > + } > + phandle =3D *out_val; > + > + gpr_np =3D of_find_node_by_phandle(phandle); > + if (!gpr_np) { > + dev_dbg(&pdev->dev, "could not find gpr node by phandle\n"); > + return PTR_ERR(gpr_np); > + } > + > + priv =3D netdev_priv(dev); > + priv->stm.gpr =3D syscon_node_to_regmap(gpr_np); > + of_node_put(gpr_np); > + if (IS_ERR(priv->stm.gpr)) { > + dev_dbg(&pdev->dev, "could not find gpr regmap\n"); > + return PTR_ERR(priv->stm.gpr); > + } > + > + priv->stm.req_gpr =3D out_val[1]; > + priv->stm.req_bit =3D out_val[2]; > + priv->stm.ack_gpr =3D out_val[3]; > + priv->stm.ack_bit =3D out_val[4]; > + > + dev_dbg(&pdev->dev, "gpr %s req_gpr 0x%x req_bit %u ack_gpr 0x%x ack_= bit %u\n", > + gpr_np->full_name, priv->stm.req_gpr, priv->stm.req_bit, priv->stm.a= ck_gpr, > + priv->stm.ack_bit); For the hex values I've changed to 0x%x to 0x%02x + rewarp to 80 cols. > + > + device_set_wakeup_capable(&pdev->dev, true); > + > + return 0; > +} > + > static const struct of_device_id flexcan_of_match[] =3D { > { .compatible =3D "fsl,imx6q-flexcan", .data =3D &fsl_imx6q_devtype_d= ata, }, > { .compatible =3D "fsl,imx28-flexcan", .data =3D &fsl_imx28_devtype_d= ata, }, > @@ -1396,6 +1505,12 @@ static int flexcan_probe(struct platform_device = *pdev) > =20 > devm_can_led_init(dev); > =20 > + if (priv->devtype_data->quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE) { > + err =3D flexcan_setup_stop_mode(pdev); > + if (err) > + dev_dbg(&pdev->dev, "failed to setup stop-mode\n"); > + } > + > dev_info(&pdev->dev, "device registered (reg_base=3D%p, irq=3D%d)\n",= > priv->regs, dev->irq); > =20 > @@ -1426,9 +1541,17 @@ static int __maybe_unused flexcan_suspend(struct= device *device) > int err; > =20 > if (netif_running(dev)) { > - err =3D flexcan_chip_disable(priv); > - if (err) > - return err; > + /* if wakeup is enabled, enter stop mode > + * else enter disabled mode. > + */ > + if (device_may_wakeup(device)) { > + enable_irq_wake(dev->irq); > + flexcan_enter_stop_mode(priv); > + } else { > + err =3D flexcan_chip_disable(priv); > + if (err) > + return err; > + } > netif_stop_queue(dev); > netif_device_detach(dev); > } > @@ -1447,14 +1570,45 @@ static int __maybe_unused flexcan_resume(struct= device *device) > if (netif_running(dev)) { > netif_device_attach(dev); > netif_start_queue(dev); > - err =3D flexcan_chip_enable(priv); > - if (err) > - return err; > + if (device_may_wakeup(device)) { > + disable_irq_wake(dev->irq); > + } else { > + err =3D flexcan_chip_enable(priv); > + if (err) > + return err; > + } > } > return 0; > } > =20 > -static SIMPLE_DEV_PM_OPS(flexcan_pm_ops, flexcan_suspend, flexcan_resu= me); > +static int __maybe_unused flexcan_noirq_suspend(struct device *device)= > +{ > + struct net_device *dev =3D dev_get_drvdata(device); > + struct flexcan_priv *priv =3D netdev_priv(dev); > + > + if (netif_running(dev) && device_may_wakeup(device)) > + flexcan_enable_wakeup_irq(priv, true); > + > + return 0; > +} > + > +static int __maybe_unused flexcan_noirq_resume(struct device *device) > +{ > + struct net_device *dev =3D dev_get_drvdata(device); > + struct flexcan_priv *priv =3D netdev_priv(dev); > + > + if (netif_running(dev) && device_may_wakeup(device)) { > + flexcan_enable_wakeup_irq(priv, false); > + flexcan_exit_stop_mode(priv); > + } > + > + return 0; > +} > + > +static const struct dev_pm_ops flexcan_pm_ops =3D { > + SET_SYSTEM_SLEEP_PM_OPS(flexcan_suspend, flexcan_resume) > + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(flexcan_noirq_suspend, flexcan_noirq_re= sume) > +}; > =20 > static struct platform_driver flexcan_driver =3D { > .driver =3D { >=20 Marc --=20 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 | --5ecR1lUw7oiKwKbiJSwsPr7HPuwBbTq2U-- --trC1QlQ0mUvy5WJC6BtKgYZWIOhHsXJ07 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEENrCndlB/VnAEWuH5k9IU1zQoZfEFAlv4FtkACgkQk9IU1zQo ZfFCKAf/Y+KL119RjC9tHBCaTEjf9yhxWSA/HYA2Rr6Ie8XAhD3OebpAtAAZ0zhi vxKJMfeoDmfcXoOXHsbXgY32/fsjZYCk2rSOi7U1D/mYbSrohBbjXPVabwennkFU mSVMwVQxKwXmiGpc1lNdv8LQHaaO2UJRaommUzKI3MaUqmQh5jZy40xOWtyfhsAj XgunPWyCFPkqh/XJELkOy0czQH6NOWMI8rjE0NAcEhzj1MIe+hCGHaK9a/UEf1/s RRSB4G5zjUZedgHufTOJxOkitLAIWd02tVk6ZqFj3ZdISDgh38ZBzxg8mBlmdjC+ fAQteB3RyuWiHya5VRPl/aa2aqnrsg== =yQhJ -----END PGP SIGNATURE----- --trC1QlQ0mUvy5WJC6BtKgYZWIOhHsXJ07--