Path: csiph.com!news.redatomik.org!aioe.org!bofh.it!news.nic.it!robomod From: Thierry Reding Newsgroups: linux.kernel Subject: Re: [PATCH v5 07/11] pwm: imx: Provide atomic PWM support for i.MX PWMv2 Date: Mon, 30 Jan 2017 09:10:02 +0100 Message-ID: References: Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=4tWVndr0nGfRwIx4HRr3LMKNOEqTrr/dl6uyJK9XcIM=; b=E9HnOolGshpXk1wmlUGBB90sBZ1qzK1zJ9/6zZNqcURyL45/eR09EukUirPRJ1Noln Y6EjHstXbCLmIgX48rI7sClurBTbBMTM97UUScFidNUYtTEhZhJQZLRTh6ucRq7kAUWb cle4B5qjezAjznSdwgRWImDhHpVBU8b+70mbXGlaGxvTZeeemCsRx5px2fhhs53xId76 JVSbICa7rTY56wNofs1Is7dPYujKQfZI9cGIJ4PPNm2ecm5mh/aiqW1+L7Idi111fOyL Ex2D5tLkjp075VBgTEmn1SPmrNNCgJxQZWcp4wEG/GM237TfKPfK114Wkm8QfhzzW4Kj Fcug== X-Google-Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=4tWVndr0nGfRwIx4HRr3LMKNOEqTrr/dl6uyJK9XcIM=; b=UnpBIbuuRX71NnYfZMPl/Gz0TII6ShinQCFh5LPs4NP1rEv5Gjp60vKhACkEBGg1Z0 Y1y1yWE9wU2aKPsM4Mi+J8R8/ur+36yx0rTAyKuV85JGwstJ694nytB3wvEywsA/Gw1M CdLMPEdn6ZTvqc8apbOmQDZwCo4jdR9TsvRC1sZKRS5oT0AxEXNkkCoyuPMPb2b6YFBS 2yPPZ4Ds6N5fl8z4R6z6QckZX6TDJULJ7H0tQz3JonfpHnfqtNqQ4+pVvhsTCs/tMUkF nspchxtE+B2XIZlmuKztlgSAg3RvlASCnBP3C4Q3y6b/+PyHKuPmS5xeYttyxAaNbEgW 1JYg== X-Gm-Message-State: AIkVDXK4ZtUIvkmTdWtb+bUHJagIZi/PUxra6pO9fYEeWFbbo1E58pLSuNOM8WpjI9Yzcw== X-Received: by 10.28.99.69 with SMTP id x66mr12120358wmb.91.1485762888458; Sun, 29 Jan 2017 23:54:48 -0800 (PST) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="wA9WyeW1yVBM2Q32" Content-Disposition: inline User-Agent: Mutt/1.7.2 (2016-11-26) Sender: robomod@news.nic.it List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Approved: robomod@news.nic.it Lines: 127 Organization: linux.* mail to news gateway X-Original-Cc: Lukasz Majewski , Sascha Hauer , Stefan Agner , linux-pwm@vger.kernel.org, Bhuvanchandra DV , linux-kernel@vger.kernel.org, Lothar Wassmann , kernel@pengutronix.de, Fabio Estevam , Lukasz Majewski X-Original-Date: Mon, 30 Jan 2017 08:54:46 +0100 X-Original-Message-ID: <20170130075446.GL3585@ulmo.ba.sec> X-Original-References: <1485726855-16236-1-git-send-email-lukma@denx.de> <1485726855-16236-8-git-send-email-lukma@denx.de> <20170130084914.672dd16e@bbrezillon> X-Original-Sender: linux-kernel-owner@vger.kernel.org Xref: csiph.com linux.kernel:1569452 --wA9WyeW1yVBM2Q32 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jan 30, 2017 at 08:49:14AM +0100, Boris Brezillon wrote: > On Sun, 29 Jan 2017 22:54:11 +0100 > Lukasz Majewski wrote: >=20 > > This commit provides apply() callback implementation for i.MX's PWMv2. > >=20 > > Suggested-by: Stefan Agner > > Suggested-by: Boris Brezillon > > Signed-off-by: Lukasz Majewski > > Reviewed-by: Boris Brezillon > > --- > > Changes for v5: > > - Modify ->apply() function to avoid unbalanced clock enabling/disabling > > - Fix preventing iMX7 from hanging > >=20 > > Changes for v4: > > - Avoid recalculation of PWM parameters when disabling PWM signal > > - Unconditionally call clk_prepare_enable(imx->clk_per) and > > clk_disable_unprepare(imx->clk_per) > >=20 > > Changes for v3: > > - Remove ipg clock enable/disable functions > >=20 > > Changes for v2: > > - None > > --- > > drivers/pwm/pwm-imx.c | 68 +++++++++++++++++++++++++++++++++++++++++++= ++++++++ > > 1 file changed, 68 insertions(+) > >=20 > > diff --git a/drivers/pwm/pwm-imx.c b/drivers/pwm/pwm-imx.c > > index 60cdc5c..fdaa11b 100644 > > --- a/drivers/pwm/pwm-imx.c > > +++ b/drivers/pwm/pwm-imx.c > > @@ -249,6 +249,73 @@ static int imx_pwm_config(struct pwm_chip *chip, > > return ret; > > } > > =20 > > +static int imx_pwm_apply_v2(struct pwm_chip *chip, struct pwm_device *= pwm, > > + struct pwm_state *state) > > +{ > > + unsigned long period_cycles, duty_cycles, prescale; > > + struct imx_chip *imx =3D to_imx_chip(chip); > > + struct pwm_state cstate; > > + unsigned long long c; > > + int ret; > > + > > + pwm_get_state(pwm, &cstate); > > + > > + if (state->enabled) { > > + c =3D clk_get_rate(imx->clk_per); > > + c *=3D state->period; > > + > > + do_div(c, 1000000000); > > + period_cycles =3D c; > > + > > + prescale =3D period_cycles / 0x10000 + 1; > > + > > + period_cycles /=3D prescale; > > + c =3D (unsigned long long)period_cycles * state->duty_cycle; > > + do_div(c, state->period); > > + duty_cycles =3D c; > > + > > + /* > > + * according to imx pwm RM, the real period value should be > > + * PERIOD value in PWMPR plus 2. > > + */ > > + if (period_cycles > 2) > > + period_cycles -=3D 2; > > + else > > + period_cycles =3D 0; > > + > > + /* > > + * Wait for a free FIFO slot if the PWM is already enabled, and > > + * flush the FIFO if the PWM was disabled and is about to be > > + * enabled. > > + */ > > + if (cstate.enabled) { > > + imx_pwm_wait_fifo_slot(chip, pwm); > > + } else if (state->enabled) { >=20 > Should just be >=20 > } else { >=20 > since we're already in the 'if (state->enabled)' block (see above). >=20 > I see that Thierry already applied the series, so, just for the record, > with this fixed, the whole series is >=20 > Reviewed-by: Boris Brezillon I haven't gotten to that patch yet because I need to manually apply a bunch of these because of the const pwm_ops patch. I'll apply the change you mentioned and will add your R-b tag. Thanks, Thierry --wA9WyeW1yVBM2Q32 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAliO8UMACgkQ3SOs138+ s6GrKxAAleV2h5bzpMBXOxlOz7vDRw+3GlHvv5k5z07cBIog/aCPgNT39mv8KrlX DqFEtcMowZEvXNoL77TOIzxG8DPnpGwhk+wY5xnJYQTRRZtiUtDnNzKhgk8daZt4 1f0SoI7d/QRuZh4o2OfNQu+iejd1NQO3tN2eo3mI3uyoF3Ua/aMfr9FLNhSazS48 gdPVRVNIDJHvG3ZinHFczcYgCaEDqn4HzK9KKAQpEj1H1aMgiLBqTnJkSngmVUTK Y7yyWD8TtGxTmnMAWXVDgJFVnZNd4SGEggnd/Iw190dGMtusliSd1qPTCDG4+jP7 YJg7ctIRFqriK2ilaA95TGaGXae9+dMWvjT+mGVnVZxH7LNOfbjh9qz7BBRIeK7z bHz0NDbg49RTxVBtxDzMIh4CZEw2hV06i9X3VA7OMsOi63p6Ajxe3qs2X8njORXI rupc6HH3/+0MSCW/X9CVy7shtTzNjtpj8DJSKwNAW+KdIVECi1xyt7/fqQ0XQUO2 ho+Y58Z+omJRyJL2TQMBR9pml4gozL+m4QbVjsnv98L1wiWgmPQiOIg8YDEYlAjM XGtzgaYlR5AgDA/w+0lMgn+HBE9ZgGYGygJBdbPcroMa1QjEdFBdY92yAG7nXWQs nU555PehzSxp1NRkmHtczqR7TKWqvz6719UMeI4nMvjsgWEaUek= =oCdS -----END PGP SIGNATURE----- --wA9WyeW1yVBM2Q32--