Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp812568ybn; Tue, 24 Sep 2019 09:53:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqyiYeDKshtsdtJqpxrBiDDJu/AZMl6cbXn59UkUhvHYNL1Vv1g6dNAyoPkyavR8EOxQroJ2 X-Received: by 2002:a17:906:c7c6:: with SMTP id dc6mr3514492ejb.123.1569344019451; Tue, 24 Sep 2019 09:53:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569344019; cv=none; d=google.com; s=arc-20160816; b=qM6LbV1jjZk/lyQRqALBQrBFIIR1wvi8TFTp2YJ7e7/dX3FsaHK4Hsd5ESjXsK6YJR sI+BViwtGlpd20eX7xtPLcPi3DKixlNToLSXBjgMmLgh0Q1cOwFMxxxpmyYkvZHG6Rch a8Lq7deDpzoAHV5i2g1j8rxY9N/rBO3XhFRV1+clVTM15Nw6PMtlWb+PVJ5tM0NmbkUz 1Q/saeVbgPM953JHXCGh8FrM+zsmSpqQXKBNw+PpWENJRvbu4GRz2kdf7zMiNCpGPdbZ doJusuuFwPQdetglX+0JkA6gThAWniKmp1HFkdU9NUFEHTnavciqCTYU/7FDvt00s/C8 4IJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=yGvT3z+mW6+FRQfKO+MHKvVyPX/X/9oAKa04usi2bl4=; b=enlMUHTXti+NtnfGDkp9dPe0JEc72t/rNLi10DTn5+nyYLShUW6jXNkniLoDvpSI0+ +0/D+m2jTimavfffjhQT7kPmE7GTmrWXw4azyF7+W+eMX30hJjIZVz88Q03CMZGMivCt u/B3VdwWWr+VQoq7pz0pqWUewc1JxJTGTs83NybXTFup5+MIe5V5iaVi3zMZFYH7QTDi riGCyhUKGTk6+i+0ZuCOZpLYxvoRE4wJLISzLVQjXslWwgu43JEcwxfkC2yQe+VKA7SD fXVQgcApHn+xRYCLe6VyTdWy9b8IO6pW6aGqd7xR4bOfFqYwonnQEEvlg/nkvtBnLkqF LoAg== 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 b3si1161076eju.357.2019.09.24.09.53.16; Tue, 24 Sep 2019 09:53:39 -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 S2436970AbfIWI1l (ORCPT + 99 others); Mon, 23 Sep 2019 04:27:41 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:41997 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405555AbfIWI1k (ORCPT ); Mon, 23 Sep 2019 04:27:40 -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 1iCJh2-0007k8-EV; Mon, 23 Sep 2019 10:27:36 +0200 Received: from ukl by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1iCJh1-0000Cf-Vo; Mon, 23 Sep 2019 10:27:35 +0200 Date: Mon, 23 Sep 2019 10:27:35 +0200 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Rasmus Villemoes Cc: Thierry Reding , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , devicetree@vger.kernel.org, linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, Rob Herring , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 3/4] pwm: mxs: add support for inverse polarity Message-ID: <20190923082735.tzxyhvjlnztsxhsc@pengutronix.de> References: <20190923081348.6843-1-linux@rasmusvillemoes.dk> <20190923081348.6843-4-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190923081348.6843-4-linux@rasmusvillemoes.dk> 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 On Mon, Sep 23, 2019 at 10:13:47AM +0200, Rasmus Villemoes wrote: > If I'm reading of_pwm_xlate_with_flags() right, existing device trees > that set #pwm-cells = 2 will continue to work. > > Signed-off-by: Rasmus Villemoes > --- > drivers/pwm/pwm-mxs.c | 14 ++++++++++---- > 1 file changed, 10 insertions(+), 4 deletions(-) > > diff --git a/drivers/pwm/pwm-mxs.c b/drivers/pwm/pwm-mxs.c > index 284107784dad..c46697acaf11 100644 > --- a/drivers/pwm/pwm-mxs.c > +++ b/drivers/pwm/pwm-mxs.c > @@ -25,8 +25,11 @@ > #define PERIOD_PERIOD(p) ((p) & 0xffff) > #define PERIOD_PERIOD_MAX 0x10000 > #define PERIOD_ACTIVE_HIGH (3 << 16) > +#define PERIOD_ACTIVE_LOW (2 << 16) > +#define PERIOD_INACTIVE_HIGH (3 << 18) > #define PERIOD_INACTIVE_LOW (2 << 18) > #define PERIOD_POLARITY_NORMAL (PERIOD_ACTIVE_HIGH | PERIOD_INACTIVE_LOW) > +#define PERIOD_POLARITY_INVERSE (PERIOD_ACTIVE_LOW | PERIOD_INACTIVE_HIGH) > #define PERIOD_CDIV(div) (((div) & 0x7) << 20) > #define PERIOD_CDIV_MAX 8 > > @@ -50,9 +53,7 @@ static int mxs_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, > unsigned int period_cycles, duty_cycles; > unsigned long rate; > unsigned long long c; > - > - if (state->polarity != PWM_POLARITY_NORMAL) > - return -ENOTSUPP; > + unsigned int pol_bits; > > rate = clk_get_rate(mxs->clk); > while (1) { > @@ -81,9 +82,12 @@ static int mxs_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, > return ret; > } > > + pol_bits = state->polarity == PWM_POLARITY_NORMAL ? > + PERIOD_POLARITY_NORMAL : PERIOD_POLARITY_INVERSE; > + > writel(duty_cycles << 16, > mxs->base + PWM_ACTIVE0 + pwm->hwpwm * 0x20); > - writel(PERIOD_PERIOD(period_cycles) | PERIOD_POLARITY_NORMAL | PERIOD_CDIV(div), > + writel(PERIOD_PERIOD(period_cycles) | pol_bits | PERIOD_CDIV(div), When will this affect the output? Only on the next start of a period, or immediatly? Can it happen that this results in a mixed output (i.e. a period that has already the new duty cycle from the line above but not the new polarity (or period)? Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |