Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1824818imm; Thu, 23 Aug 2018 09:19:50 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwz/OOgUDcf54GLqjuV3qFs3o5DNb/OFR6RKnyLnAvOV0IArZiExfIJQd+l+kf7kQpxlnBM X-Received: by 2002:a63:1644:: with SMTP id 4-v6mr56860008pgw.103.1535041190691; Thu, 23 Aug 2018 09:19:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535041190; cv=none; d=google.com; s=arc-20160816; b=FR5fC4pCkNuu0jFNINzsbHL7s1s8JuZn9iurNUqb76jp1zaJ/+QgvaEsqOLoED4vHb 2CHqkRjvftN+TnbAnsf4YHz7qAcgwFthK9l+MJtbkSXRPd/9Ou+dWORYHO2Df1Ka92GH 6uNrt3ghU+qr706TQS3HkweXaqVgwH4d6cty5++IxjM3VyJ3rFBYJ67T69xKLhuKz6YE Gh398lxvwoei0pGJ0oFuecl69mAEwgRkqezCBzr71xZmOLaerlMxp2OjKhlcwzjwkTrq cv+HSD1ULsn6Vj/UBXY71znSIBbmh+TvGhP5WoKCBqzHba3kPTBXSipvNJdPBjdiH05E LykA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=4UDvRcOtyKUdn9lqPJhN01phFI3rN7IjmfVPQ4da0S0=; b=zaRW6EcbCFlxLhc8LdizO3fUQamdpSvYvapGx1jcJjkS5sXUJ2e5lGgHHzxOC+YxG7 hQb6qd6JpWTDlXzxFzyJGCh/ZBoZD8yivQ+aD/h2zGoYdr8OLjBSLepIgvA6x50mlg/B 7kDnpOMLS8yGzA5NTo/KK05NnmEz1Pjyf897gMZZzGG4aWSiR0w4tCSELFPOTGqxfEQ6 do2lYlwdH0W66gbUn8vy1GbLqdzStNNEtkOYrlXwdSDwCk+Rb7LDmiZfMfu1Vt9Xiic7 sEkIzkguDOZv69DcClEj3578bUJajvyx0loeGH7tu6LsvyD0k2q3GZcl8AINEY6jml8A YcnQ== 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 u32-v6si4030023pgl.348.2018.08.23.09.19.35; Thu, 23 Aug 2018 09:19:50 -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 S1729430AbeHWQFo (ORCPT + 99 others); Thu, 23 Aug 2018 12:05:44 -0400 Received: from mail-out.m-online.net ([212.18.0.9]:45647 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726332AbeHWQFo (ORCPT ); Thu, 23 Aug 2018 12:05:44 -0400 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 41x3mm6VgJz1qyL9; Thu, 23 Aug 2018 14:36:08 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 41x3mm5Vjfz1qr24; Thu, 23 Aug 2018 14:36:08 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id L3dSJPySrUVJ; Thu, 23 Aug 2018 14:36:07 +0200 (CEST) X-Auth-Info: GlNNlTi729EKxEd4MiBMp9ExsIyA4XBuYet35k7lEjg= Received: from jawa (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Thu, 23 Aug 2018 14:36:07 +0200 (CEST) Date: Thu, 23 Aug 2018 14:36:00 +0200 From: Lukasz Majewski To: Michal =?UTF-8?B?Vm9rw6HEjQ==?= Cc: Thierry Reding , Rob Herring , Mark Rutland , devicetree@vger.kernel.org, linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, Fabio Estevam , Lothar =?UTF-8?B?V2HDn21hbm4=?= Subject: Re: [RFC PATCH 1/2] dt-bindings: pwm: imx: Allow switching PWM output between PWM and GPIO Message-ID: <20180823143600.3e417542@jawa> In-Reply-To: <0691e93d-c2e2-21e5-374f-c29e7765de93@ysoft.com> References: <1534862333-27950-1-git-send-email-michal.vokac@ysoft.com> <1534862333-27950-2-git-send-email-michal.vokac@ysoft.com> <20180823123759.68b78e9f@jawa> <0691e93d-c2e2-21e5-374f-c29e7765de93@ysoft.com> Organization: denx.de X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; boundary="Sig_/bSzWo+0iYXRf0ckL35a+C5W"; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --Sig_/bSzWo+0iYXRf0ckL35a+C5W Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Michal, > On 23.8.2018 12:40, Lukasz Majewski wrote: >=20 > Hi Lukasz, thanks for the reply! > > Hi Michal, > > =20 > >> Output of the PWM block of i.MX SoCs is always zero volts when the > >> block is disabled. This can caue issues when inverted PWM polarity > >> is needed. With inverted polarity a duty cycle =3D 0% corresponds to > >> solid high level on the output. If the PWM is dissabled its output > >> instantly goes to solid zero which corresponds to duty cycle =3D > >> 100%. > >> > >> To have a trully inverted PWM output configure the PWM pad as a > >> GPIO with pull-up. Then switch the pad to PWM output whenever > >> non-zero duty cycle is needed. =20 > >=20 > > Just to ask - Is your display equipped with power supply > > enable/disable pin? =20 >=20 > No it is not. The backlight on my display is just a bunch of serial- > parallel connected LEDs with separate GND and VCC pins on a separate > flex cable. And the display itself also does not have a reset or > enable signal. It is a PITA=C2=A0to use it I must say.. Yes, it seems so. I must have had more luck than you with the HW.... > =20 > > As fair as I remember the trick to avoid flickering the display > > was to disable the display (enable-gpio property) and set the PWM > > PIN as GPIO to high in u-boot. =20 >=20 > Yes, I know about that. I can not use this as the PWM output is the > only signal I have to control the backlight. I mentioned that > somewhere in the previous discussion with Lothar. Yes, I've read it. I also find the PWM pinctrl as "default" state more natural. One more idea - though. In iMX6Q it was possible to specify the pinctrl PIN setup as 0x80000000 - this means that it goes untouched to the IP block (configured by bootloader). Maybe it would work to: 1. Setup the PWM output as GPIO in u-boot (high) 2. In PWM IMX probe configure PWM to be 100% duty cycle. And switch iomux to PWM function of the pin 3. Then latter in the code PWM gets configured and we can control it in "normal" way ? Or am I missing some important point? >=20 > I also think this could be useful not only for backlight. Any circuit > that requires truly inverted PWM signal can use it. I see it as an > enhancement to what you with Lothar have already done ;) > =20 > >> > >> Signed-off-by: Michal Vok=C3=A1=C4=8D > >> --- > >> Documentation/devicetree/bindings/pwm/imx-pwm.txt | 44 > >> +++++++++++++++++++++++ 1 file changed, 44 insertions(+) > >> > >> diff --git a/Documentation/devicetree/bindings/pwm/imx-pwm.txt > >> b/Documentation/devicetree/bindings/pwm/imx-pwm.txt index > >> c61bdf8..3b1bc4c 100644 --- > >> a/Documentation/devicetree/bindings/pwm/imx-pwm.txt +++ > >> b/Documentation/devicetree/bindings/pwm/imx-pwm.txt @@ -14,6 +14,12 > >> @@ See the clock consumer binding, > >> Documentation/devicetree/bindings/clock/clock-bindings.txt > >> - interrupts: The interrupt for the pwm controller > >> =20 > >> +Optional properties: > >> +- pinctrl: For i.MX27 and newer SoCs. Add extra pinctrl to > >> configure the PWM > >> + pin to gpio function. It allows control over the pin output > >> level when the > >> + PWM block is disabled. This is meant to be used if inverted > >> polarity of the > >> + PWM signal is required. See "Inverted PWM output" section > >> bellow. + > >> Example: > >> =20 > >> pwm1: pwm@53fb4000 { > >> @@ -25,3 +31,41 @@ pwm1: pwm@53fb4000 { > >> clock-names =3D "ipg", "per"; > >> interrupts =3D <61>; > >> }; > >> + > >> +Inverted PWM output > >> +------------------- > >> + > >> +The i.MX SoC has such limitation that whenever a pad is configured > >> as a PWM +output, the output level is always zero volts when the > >> PWM block is disabled. +The zero output level is actively driven > >> by the output stage of the PWM block +and can not be overridden by > >> pull-up. It also does not matter what PWM polarity +a PWM client > >> (e.g. backlight) requested. + > >> +To gain control of the PWM output level in disabled state two > >> pinctrl states +can be used. The "default" state and the "pwm" > >> state. In the default state the +PWM output is configured as a > >> GPIO with pull-up. In the "pwm" state the output +is configured as > >> a PWM output. This setup assures that the PWM output is at +the > >> required level that corresponds to duty cycle =3D 0 when PWM is > >> disabled. +E.g. at boot. + > >> +Example: > >> + > >> +&pwm1 { > >> + pinctrl-names =3D "default", "pwm"; > >> + pinctrl-0 =3D <&pinctrl_backlight_gpio>; > >> + pinctrl-1 =3D <&pinctrl_backlight_pwm>; > >> +} > >> + > >> +pinctrl_backlight_gpio: pwm1grp-gpio { > >> + fsl,pins =3D < > >> + /* GPIO with 22kOhm pull-up */ > >> + MX6QDL_PAD_GPIO_9__GPIO1_IO09 0xF008 > >> + >; > >> +}; > >> + > >> +pinctrl_backlight_pwm: pwm1grp-pwm { > >> + fsl,pins =3D < > >> + /* PWM output */ > >> + MX6QDL_PAD_GPIO_9__PWM1_OUT 0x8 > >> + >; > >> +}; =20 Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de --Sig_/bSzWo+0iYXRf0ckL35a+C5W Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEgAyFJ+N6uu6+XupJAR8vZIA0zr0FAlt+qjAACgkQAR8vZIA0 zr2jVgf/cT9BMXZrWumniSwKM1BMNZQUsUM5wnxP8jaTMvl0JRS74z7CRbTe3j5J FexaDCLnIf6eE62XjGikn/j3pjMJ43/G7n6sTn/6B2JU1FDVrL+pfXseSLNXuRt3 STW+nAU45T9OO4Q/yM7MY8IziOY7leS+FWdXeP4LN9aoWFAEC08YRKbUrGisiLzt CbJpZ9qGZaMk6rSEjOR792kkmlIqKahpSVqe39VqYJv9/lDkDV2PPc3U5Pi8xR0p 0CSDKBeZnk9opqJC42vqAO6nc9V1xZWxOUGlGK62rZjdwyFHI6gKqJNxGAOLwqlz MDADTr1fgZjQTSnmr73SpoeCdylmyg== =TSWt -----END PGP SIGNATURE----- --Sig_/bSzWo+0iYXRf0ckL35a+C5W--