All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Martin Jücker" <martin.juecker@gmail.com>
To: "Krzysztof Kozlowski" <krzysztof.kozlowski@linaro.org>,
	"Alim Akhtar" <alim.akhtar@samsung.com>,
	"Thierry Reding" <thierry.reding@gmail.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Lee Jones" <lee.jones@linaro.org>
Cc: "Martin Jücker" <martin.juecker@gmail.com>,
	linux-samsung-soc@vger.kernel.org
Subject: [RFC PATCH] pwm: pwm-samsung: trigger manual update on 100% duty
Date: Sat, 9 Apr 2022 15:40:05 +0200	[thread overview]
Message-ID: <20220409134005.GA12218@adroid> (raw)

Hello,

I have some trouble with a pwm backlight in the p4note and I'm not sure
what the cause is. The problem is with setting the backlight brightness
to its maximum value, which will actually turn off the display. All the
other values seem to be working just fine.

Looking at the documentation for the pwm driver in the exynos4412
manual, I found that for pwm, the higher the tcmp value, the lower the
pwm value is. Enabling debug logging, this seems to be exactly what's
happening for values below 100% duty, but when the duty reaches 100%,
the tcmp is zero and then gets decreased which causes it to wrap around.
Looking at the rest of the code, this seems to be expected behaviour and
I would assume that it should cause the pwm to never switch the value
from high to low which would also fit.

Now I tried around and found two solutions to my problem, one of them is
attached to the mail and just triggers a manual update if the new value
wrapped around. This makes the display behave as expected but I cannot
explain what's actually happening. Another idea was to check the tcmp
value before decreasing to avoid the wrap around, but then 100% duty
cycle is not possible anymore as the pwm signal will switch from high to
low on the last tick of the counter.

I'd be happy for any input on this issue.

Here is the first solution I found:


Trigger a manual update to the pwm chip when going from any value to
100% duty to avoid the TOUT value staying low.

Signed-off-by: Martin Jücker <martin.juecker@gmail.com>
---
 drivers/pwm/pwm-samsung.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pwm/pwm-samsung.c b/drivers/pwm/pwm-samsung.c
index 0a4ff55fad04..a449e38a24da 100644
--- a/drivers/pwm/pwm-samsung.c
+++ b/drivers/pwm/pwm-samsung.c
@@ -383,7 +383,7 @@ static int __pwm_samsung_config(struct pwm_chip *chip, struct pwm_device *pwm,
 	 * update to prevent the signal staying high if the PWM is disabled
 	 * shortly afer this update (before it autoreloaded the new values).
 	 */
-	if (oldtcmp == (u32) -1) {
+	if (oldtcmp == (u32)-1 || tcmp == (u32)-1) {
 		dev_dbg(our_chip->chip.dev, "Forcing manual update");
 		pwm_samsung_manual_update(our_chip, pwm);
 	}
-- 
2.25.1


             reply	other threads:[~2022-04-09 13:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-09 13:40 Martin Jücker [this message]
2022-04-09 15:01 ` [RFC PATCH] pwm: pwm-samsung: trigger manual update on 100% duty Krzysztof Kozlowski
2022-04-09 15:37   ` Martin Jücker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220409134005.GA12218@adroid \
    --to=martin.juecker@gmail.com \
    --cc=alim.akhtar@samsung.com \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.