Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp10032pxk; Wed, 2 Sep 2020 12:53:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxog1hm60huGea7rW4fsRKr42TDAGOSrDfw5uKSl1Gva3yLgxIAjH6g8o2/VO58b53BMSp0 X-Received: by 2002:a17:906:49c6:: with SMTP id w6mr1605833ejv.445.1599076432939; Wed, 02 Sep 2020 12:53:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599076432; cv=none; d=google.com; s=arc-20160816; b=Du97V+qqgKPctGlFEE7IRWyU+FFC2GXl95jitCgN0LooXot2tRMLGamjAMpnRqTxzt SCrq7GAqvECSZiPjRootVHhAvhjo3Y5ZDKJoqi/w0uDu7xezS/7YimGp4AB4ymUvxXRv ow3v1MPJ7oyQdAhdNdghW4PB0lqEugXX3/1rE5hP3NbV9QjuGaYCverPmXM8zL70yauZ CXtTe4Y/8o+5kTiwZsnh48BvstbcIxVJ0jkif/LYH1pYHkK1axesIsH0CKWo/1CIE6CH xpbcqKQccLZo5m9GFvsr/PURBXHhj+DW/ULDBCJZK90YIDM3mUpex6VyfOl661DRAmw0 p4wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:message-id :user-agent:references:in-reply-to:subject:cc:to:from:date :mime-version:dkim-signature; bh=KNenMuIKDW/cG/OCNrUxLUJ9j1/2p1rYL+aDVLwuqv4=; b=uQwuL10N576h913pWr7gN6NuSYiS0e4939bM7JkyM+CTVX6U0fU6CeCxb8/XncEJ0L +JKqn4o9VFX9a7bSH9Tls2AbKl84A+Oy40TIwsGSKgWI+qbpy/hDe96GrnKA65gEJKnW sC1G6+ANGCwVMaLaPPoyEergV/M0akkNibXBv8azQ1yGdss9x1FIYoQ2gUnMH7AD0Qdf 0c3BTaXXHz6CsGRyrm8fHJ5zcq4dtTaLIWHsWKvQUbaOps9u7T82nMrCzVCtgF8/sv9k EWZEvKcbr0f/skCpqC3QUtzjEot7vyW0rtPocCD7geJ+LKVEc+tvQBbYaev49WnKpF+f 1CoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@pascalroeleven.nl header.s=x header.b=hdXDtFwY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=pascalroeleven.nl Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f7si372741ejt.351.2020.09.02.12.53.28; Wed, 02 Sep 2020 12:53:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@pascalroeleven.nl header.s=x header.b=hdXDtFwY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=pascalroeleven.nl Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726467AbgIBTwP (ORCPT + 99 others); Wed, 2 Sep 2020 15:52:15 -0400 Received: from pmg01-out1.zxcs.nl ([185.104.30.240]:42747 "EHLO pmg01-out1.zxcs.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726226AbgIBTwO (ORCPT ); Wed, 2 Sep 2020 15:52:14 -0400 X-Greylist: delayed 563 seconds by postgrey-1.27 at vger.kernel.org; Wed, 02 Sep 2020 15:52:14 EDT Received: from pmg01.zxcs.nl (localhost.localdomain [127.0.0.1]) by pmg01.zxcs.nl (ZXCS) with ESMTP id E9240103D74; Wed, 2 Sep 2020 21:42:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=pascalroeleven.nl; s=x; h=Content-Transfer-Encoding:Content-Type:Message-ID :References:In-Reply-To:Subject:Cc:To:From:Date:MIME-Version:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=KNenMuIKDW/cG/OCNrUxLUJ9j1/2p1rYL+aDVLwuqv4=; b=hdXDtFwYQb1ag7/bFm3Zz3rLW7 1qF0TdHjx1k4Ord2Ywa+wPX7L+PSAxxUoxQL+7chtN5gqrIbIgfHxIjcaltzzS1/1j9FbGnIwpJ70 8pm/DOcJvEIk/cAwXgIVsPH3/uSpbw/2fYteubtA3mH2fWsx13CaMF42E4U6/dHRFg9Om4DlNZ/t+ ZalA0iOA/yAIGX63hb/Rjc/jmwa9swMYwGKRM321jwUQA0KnJUVaP5JnkOUrex1txUV4ZdP0mGe7g 1GbI6h3lTq+/kvPA83ovp/d3GsoiN9cksY7bEOH/vtmDmCQzotBFnm8U3Tr0IllzamX/18GQMn5XO 6crHMZqg==; MIME-Version: 1.0 Date: Wed, 02 Sep 2020 21:42:49 +0200 From: Pascal Roeleven To: Andrey Lebedev Cc: Daniel Thompson , Thierry Reding , =?UTF-8?Q?Uwe_Kleine-K=C3=B6nig?= , Lee Jones , Maxime Ripard , Chen-Yu Tsai , Philipp Zabel , "open list:PWM SUBSYSTEM" , "moderated list:ARM/Allwinner sunXi SoC support" , open list , Alexandre Belloni , Emil Lenngren Subject: Re: pwm-sun4i: PWM backlight is not turned off on shutdown In-Reply-To: <913a5324-a7d2-f1d5-701e-1c28359286f2@lebedev.lt> References: <20200902095402.pombrirqqjdew34b@holly.lan> <913a5324-a7d2-f1d5-701e-1c28359286f2@lebedev.lt> User-Agent: Roundcube Webmail/1.4.8 Message-ID: <5302741318a28e39239db08a1f05ecb7@pascalroeleven.nl> X-Sender: dev@pascalroeleven.nl Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-AuthUser: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thank you for adding me. Emil (also added now) and I spent a while on trying to figure out how to solve this. The Allwinner PWM controller has some quirks. Unfortunately I never got around to perform some more tests and fix it indefinitely. It's still on my todo list.. > On 9/2/20 12:54 PM, Daniel Thompson wrote: >> There's some rather odd logic in sun4i_pwm_apply() that results in the >> PWM being disabled twice... once when it applies the initial config >> and again after waiting for a duty_cycle. That's true. To properly turn off the controller you have to turn the controller off first and keep the gate on for at least two full clock cycles. Then the gate must be turned off. Otherwise it might get stuck. That's probably what is trying to be done here. On 2020-09-02 21:05, Andrey Lebedev wrote: > Indeed, this fixes the issue for me. The display goes dark reliably on > writing 4 to "/sys/.../bl_power" as well as when system is halted. I > did > not notice any negative side effects so far. Problems start to arise when combining bl_power and brightness setting in a particular order or at the same time (with for example a backlight driver which sets both bl_power and brightness). I can't recall exactly what caused problems and when, but one thing I was sure of is that timing was of the essence. Once I added some delays here and there it started to work. If this patch works for you then that's great, but unfortunately it isn't a complete solution. Regards, Pascal