Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp4737927imd; Tue, 30 Oct 2018 06:46:28 -0700 (PDT) X-Google-Smtp-Source: AJdET5eqEYNWD4xy1CYDWvorBCaCYM3bYi9wJS/EvBtaJVzyc2UZVtxN1/XPvXhl4ELK7bTbO+Jx X-Received: by 2002:a62:8c93:: with SMTP id m141-v6mr2954661pfd.239.1540907188006; Tue, 30 Oct 2018 06:46:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540907187; cv=none; d=google.com; s=arc-20160816; b=hbGwgai9gj60WWI+RXPhPS3vRtE+3W3Yqzo6+03iXXkpFDVwP/Rlwd0wvAti2X/EJd /OxKMMFX26Sjy8qwe9ytfblc5tZVA46Efy4LDY9dvl+3PM2uYwMKyDY960Hzdob1xsmZ SOmdLRXUlAo5KrOE6hHToum2qmWBetwmby3Yot+h+KxpaxatMv66Xb4EpL0QYIC7JMzJ QnoD6XYibGsLB0E3nLuhRxhztVb9QQ4XGkWKEmiTejuaLA1IfcDi30MFEMxZxrceHFSV AMBqKnOe2bLNLCuaPtLbtKeJ421tueswBLmeWA82V86lLGabyPXWgTQBU9Uh0D6zBFdm C4ig== 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=WccC+BC8nHNN2FfWsDE24aAJmCWu7titF4NrvN+h4KY=; b=NSH9yrKzY+WtOAz5m70PckWsuDQ3ZghXOWZosTnWZDXOYmfcKUXmJULMh0EXB8Z+7N Sr17jfLKpwYPkP+82fekUuvg7WW4EonWQVXcOX3D1jMzMkfjEeTCMPpmK7m+Ba+yYq+v C66G1t7tHtcXfoJ0Z0PpQKqaWeq6XxwEDPgOB9CT+xJhki/WEW7N+qHgZQuho1BtPL+t zaluhY27UJF2gO22CpIIjmRzEKWtPkIVzvzrubya12QWlH2xjo2Wyb3cP4Sgl5ikLEL+ bGc72G3ML0i2N/FM4HiEHqcgxtwKNxEH08ioG31FUtuT3aeopwqiLmhtXcn2YyTe3QwB GnPA== 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 j7-v6si23182521pgj.532.2018.10.30.06.46.11; Tue, 30 Oct 2018 06:46:27 -0700 (PDT) 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 S1728053AbeJ3Wic (ORCPT + 99 others); Tue, 30 Oct 2018 18:38:32 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:51349 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727450AbeJ3Wib (ORCPT ); Tue, 30 Oct 2018 18:38:31 -0400 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 1gHUK9-0003hS-Nv; Tue, 30 Oct 2018 14:44:49 +0100 Received: from [IPv6:2a03:f580:87bc:d400:e586:a438:6bdb:ffff] (unknown [IPv6:2a03:f580:87bc:d400:e586:a438:6bdb:ffff]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (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 78F19381A38; Tue, 30 Oct 2018 13:44:48 +0000 (UTC) To: Joakim Zhang , "linux-can@vger.kernel.org" Cc: "wg@grandegger.com" , "robh+dt@kernel.org" , "mark.rutland@arm.com" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , dl-linux-imx , "A.s. Dong" References: <20181026085814.23370-1-qiangqing.zhang@nxp.com> <20181026085814.23370-2-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 ZS1CdWRkZSA8bWtsQ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G2FdGzy 6mXwwCEJxn5s9Y5Y31hPGlQnYDPAuYMrDVBRsIQVwAsWpV83vKjp4WFP4wC1LEYj+j/Oorqv ALsMRq49WSclOMvqDdh//wmfSAbkyn3EA6EMv9mxJHJvKW7PMXvO0Mk1uP/+VR3FudMXhZzz MUYlqpO3B/RmA7lPoMY5+Km8c4/6L9Bn0vcbGMH4piH0IuEK0px64oXtKfti47XrCX+EDpSn ZwhEnNjCKyAJTaangebRpvOwJUZUWVh+hpM5FMcwJGKvVXNmrmSj Subject: Re: [PATCH V2 1/2] can: flexcan: Add self wakeup support Message-ID: Date: Tue, 30 Oct 2018 14:44:45 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181026085814.23370-2-qiangqing.zhang@nxp.com> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="YkG2zGMbIh1v6OzZoI17gLKdRglWKyPjq" 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) --YkG2zGMbIh1v6OzZoI17gLKdRglWKyPjq Content-Type: multipart/mixed; boundary="sJuwh9D2cdwW2SVRTx6CKeLEAPTEcw3C4"; protected-headers="v1" From: Marc Kleine-Budde To: Joakim Zhang , "linux-can@vger.kernel.org" Cc: "wg@grandegger.com" , "robh+dt@kernel.org" , "mark.rutland@arm.com" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , dl-linux-imx , "A.s. Dong" Message-ID: Subject: Re: [PATCH V2 1/2] can: flexcan: Add self wakeup support References: <20181026085814.23370-1-qiangqing.zhang@nxp.com> <20181026085814.23370-2-qiangqing.zhang@nxp.com> In-Reply-To: <20181026085814.23370-2-qiangqing.zhang@nxp.com> --sJuwh9D2cdwW2SVRTx6CKeLEAPTEcw3C4 Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: quoted-printable On 10/26/2018 11:00 AM, Joakim Zhang wrote: > From: Dong Aisheng >=20 > If wakeup is enabled, enter stop mode, else enter disabled mode. > Self wake 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: Dong Aisheng > Signed-off-by: Joakim Zhang > --- > drivers/net/can/flexcan.c | 141 +++++++++++++++++++++++++++++++++++---= > 1 file changed, 132 insertions(+), 9 deletions(-) >=20 > diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c > index 3813f6708201..d4708ba28c44 100644 > --- a/drivers/net/can/flexcan.c > +++ b/drivers/net/can/flexcan.c > @@ -19,12 +19,17 @@ > #include > #include > #include > +#include > +#include > +#include > +#include > #include > #include > #include > #include > #include > #include > +#include > =20 > #define DRV_NAME "flexcan" > =20 > @@ -132,7 +137,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) > =20 > /* FLEXCAN interrupt flag register (IFLAG) bits */ > /* Errata ERR005829 step7: Reserve first valid MB */ > @@ -255,6 +261,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; > @@ -272,6 +286,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); > @@ -392,6 +407,22 @@ static void flexcan_clks_disable(const struct flex= can_priv *priv) > clk_disable_unprepare(priv->clk_per); > } > =20 > +static inline void flexcan_enter_stop_mode(struct flexcan_priv *priv) > +{ > + /* enable stop request */ > + if (priv->devtype_data->quirks & FLEXCAN_QUIRK_USE_OFF_TIMESTAMP) Why do you check the quirk here? This should only be called if the device is wakeup capable. > + regmap_update_bits(priv->stm.gpr, priv->stm.req_gpr, > + 1 << priv->stm.req_bit, 1 << priv->stm.req_bit); Please align with the opening bracket of "regmap_update_bits(". > +} > + > +static inline void flexcan_exit_stop_mode(struct flexcan_priv *priv) > +{ > + /* remove stop request */ > + if (priv->devtype_data->quirks & FLEXCAN_QUIRK_USE_OFF_TIMESTAMP) same here > + regmap_update_bits(priv->stm.gpr, priv->stm.req_gpr, > + 1 << priv->stm.req_bit, 0); same here > +} > + > static inline int flexcan_transceiver_enable(const struct flexcan_priv= *priv) > { > if (!priv->reg_xceiver) > @@ -955,6 +986,10 @@ static int flexcan_chip_start(struct net_device *d= ev) > reg_mcr |=3D FLEXCAN_MCR_FEN | > FLEXCAN_MCR_MAXMB(priv->tx_mb_idx); > } > + > + /* enable self wakeup */ > + reg_mcr |=3D FLEXCAN_MCR_WAK_MSK | FLEXCAN_MCR_SLF_WAK; > + > netdev_dbg(dev, "%s: writing mcr=3D0x%08x", __func__, reg_mcr); > priv->write(reg_mcr, ®s->mcr); > =20 > @@ -1240,6 +1275,56 @@ static void unregister_flexcandev(struct net_dev= ice *dev) > unregister_candev(dev); > } > =20 > +static int flexcan_of_parse_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 *node; > + 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); > + if (ret) { > + dev_dbg(&pdev->dev, "no stop-mode property\n"); > + return ret; > + } > + phandle =3D *out_val; > + > + node =3D of_find_node_by_phandle(phandle); > + if (!node) { > + dev_dbg(&pdev->dev, "could not find gpr node by phandle\n"); > + return PTR_ERR(node); > + } > + > + priv =3D netdev_priv(dev); > + priv->stm.gpr =3D syscon_node_to_regmap(node); > + if (IS_ERR(priv->stm.gpr)) { > + dev_dbg(&pdev->dev, "could not find gpr regmap\n"); > + return PTR_ERR(priv->stm.gpr); > + } > + > + of_node_put(node); > + > + 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", > + node->full_name, priv->stm.req_gpr, > + priv->stm.req_bit, priv->stm.ack_gpr, > + priv->stm.ack_bit); > + 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, }, > @@ -1271,6 +1356,7 @@ static int flexcan_probe(struct platform_device *= pdev) > struct flexcan_regs __iomem *regs; > int err, irq; > u32 clock_freq =3D 0; > + int wakeup =3D 1; Make it a bool. Why is is default enabled? See below. > =20 > reg_xceiver =3D devm_regulator_get(&pdev->dev, "xceiver"); > if (PTR_ERR(reg_xceiver) =3D=3D -EPROBE_DEFER) > @@ -1400,6 +1486,16 @@ static int flexcan_probe(struct platform_device = *pdev) > =20 > devm_can_led_init(dev); > =20 > + if (priv->devtype_data->quirks & FLEXCAN_QUIRK_USE_OFF_TIMESTAMP) { Please add another QUIRK. > + err =3D flexcan_of_parse_stop_mode(pdev); > + if (err) { > + wakeup =3D 0; > + dev_dbg(&pdev->dev, "failed to parse stop-mode\n"); > + } > + } > + > + device_set_wakeup_capable(&pdev->dev, wakeup); What about moving this into "flexcan_of_parse_stop_mode(pdev);", and rename this function into ..._setup_stop_mode() or something similar. > + > pm_runtime_put(&pdev->dev); > =20 > dev_info(&pdev->dev, "device registered (reg_base=3D%p, irq=3D%d)\n",= > @@ -1437,10 +1533,18 @@ static int __maybe_unused flexcan_suspend(struc= t device *device) > int err =3D 0; > =20 > if (netif_running(dev)) { > - err =3D flexcan_chip_disable(priv); > - if (err) > - return err; > - err =3D pm_runtime_force_suspend(device); > + /* 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; > + err =3D pm_runtime_force_suspend(device); > + } > =20 > netif_stop_queue(dev); > netif_device_detach(dev); > @@ -1461,10 +1565,12 @@ static int __maybe_unused flexcan_resume(struct= device *device) > netif_device_attach(dev); > netif_start_queue(dev); > =20 > - err =3D pm_runtime_force_resume(device); > - if (err) > - return err; > - err =3D flexcan_chip_enable(priv); > + if (!device_may_wakeup(device)) { > + err =3D pm_runtime_force_resume(device); > + if (err) > + return err; > + err =3D flexcan_chip_enable(priv); > + } > } > return err; > } > @@ -1489,10 +1595,27 @@ static int __maybe_unused flexcan_runtime_resum= e(struct device *device) > return 0; > } > =20 > +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); > + > + /* exit stop mode during noirq stage avoid continuously entering > + * wakeup ISR before CAN resume back. > + */ > + if (netif_running(dev) && device_may_wakeup(device)) { > + disable_irq_wake(dev->irq); > + 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_RUNTIME_PM_OPS(flexcan_runtime_suspend, flexcan_runtime_resume, > NULL) > + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(NULL, flexcan_noirq_resume) > }; > =20 > static struct platform_driver flexcan_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 | --sJuwh9D2cdwW2SVRTx6CKeLEAPTEcw3C4-- --YkG2zGMbIh1v6OzZoI17gLKdRglWKyPjq Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEENrCndlB/VnAEWuH5k9IU1zQoZfEFAlvYYE0ACgkQk9IU1zQo ZfEbLAgAlXK7bMDCQX0TBaWReJR+ACwfqt+Qijih6qMMGmjoT8VpB9gLQJ21i+9+ mEdze1lVXqVIsjGxAEtkDBDwDtZ6r2l5b517tC0RG+UD2g3QVkfxv/WmlWAA3GWX aQd65nfkr3LppCk4I75rk6Zey8o/XD6KdTRbuRLoPb85jf/jvrCLLX+nIqZQ663K iXFJErceVhNmktjXdtpFDeyUhqxy1Ee81hDJjr2FiBnzxcHpEjutZc6pMazzUS1l FOYNJV7vWek9aub1/SfkX/mKhjtKyCwsL0zy5NvLYfDJlCBl3DQIhvjgkgwn/zRp jkKYV9Bu25yQjZbJpz+eWMin1777kg== =zHc/ -----END PGP SIGNATURE----- --YkG2zGMbIh1v6OzZoI17gLKdRglWKyPjq--