From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36BD6C7618B for ; Wed, 24 Jul 2019 06:47:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 094252190F for ; Wed, 24 Jul 2019 06:47:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726031AbfGXGrz (ORCPT ); Wed, 24 Jul 2019 02:47:55 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:56091 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725878AbfGXGrz (ORCPT ); Wed, 24 Jul 2019 02:47:55 -0400 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1hqB41-0006XM-CV; Wed, 24 Jul 2019 08:47:49 +0200 Received: from ukl by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1hqB3x-0004ZG-Mb; Wed, 24 Jul 2019 08:47:45 +0200 Date: Wed, 24 Jul 2019 08:47:45 +0200 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Paul Cercueil Cc: Thierry Reding , Rob Herring , Mark Rutland , od@zcrc.me, linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de Subject: Re: [PATCH v2 3/6] pwm: jz4740: Apply configuration atomically Message-ID: <20190724064745.7ghecdpg3gmxsiim@pengutronix.de> References: <20190607154410.10633-1-paul@crapouillou.net> <20190607154410.10633-4-paul@crapouillou.net> <20190722193456.h4hfte5cczucermd@pengutronix.de> <1563914800.1918.0@crapouillou.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1563914800.1918.0@crapouillou.net> User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: ukl@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 Hello Paul, On Tue, Jul 23, 2019 at 04:46:40PM -0400, Paul Cercueil wrote: > Le lun. 22 juil. 2019 ā 15:34, Uwe =?iso-8859-1?q?Kleine-K=F6nig?= > a écrit : > > On Fri, Jun 07, 2019 at 05:44:07PM +0200, Paul Cercueil wrote: > > > - is_enabled = jz4740_timer_is_enabled(pwm->hwpwm); > > > - if (is_enabled) > > > - jz4740_pwm_disable(chip, pwm); > > > + jz4740_pwm_disable(chip, pwm); > > > > I assume this stops the PWM. Does this complete the currently running > > period? How does the PWM behave then? (Does it still drive the output? > > If so, on which level?) > > Some PWM channels work in one mode "TCU1" and others work in "TCU2". The > mode in which channels work depends on the version of the SoC. > > When stopped, the pins of TCU1 channels will be driven to the inactive > level (which depends on the polarity). It is unknown whether or not the > currently running period is completed. We set a bit to configure for > "abrupt shutdown", so I expect that it's not, but somebody would need > to hook up a logic analyzer to see what's the exact behaviour with > and without that bit. This might be done even without a logic analyzer. Just do something like: pwm_apply_state(pwm, { .enabled = 1, .period = 5s }) pwm_apply_state(pwm, { .enabled = 1, .period = 5s, .duty = 5s }) and if that takes less then 5s the period is not completed. And note that "abrupt shutdown" is a bug. > TCU2 channels on the other hand will stop in the middle of a period, > leaving the pin hanging at whatever level it was before the stop. > That's the rationale behind the trick in commit 6580fd173070 ("pwm: > jz4740: Force TCU2 channels to return to their init level"). Strange, but ok. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |