Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp466912ybn; Wed, 25 Sep 2019 02:45:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqxsycnFWbsOgGEWY4GwWdRcNlPfEagCPlM0o66CcdKDiIx475+j85bB7dZWv4ePu9R5jkW/ X-Received: by 2002:a05:600c:238a:: with SMTP id m10mr6958709wma.51.1569404729184; Wed, 25 Sep 2019 02:45:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569404729; cv=none; d=google.com; s=arc-20160816; b=pX9BuTcggcDXOot04yBO8r/oM5AMzKVUpcgJwrzU3csSRa6VeEKGRgh6UuA1tuU/6a wy+qLqBRCObTjP2uonN4BF62wvZiGyDxtB3XWvoODRkhE5JLftq8+1DQZL41Kwg0SmD7 DK8jo3HM6pHiJrhtxrRjoaJJgvBZ0GEmDUp8LB4Au0vUMVH5Sapri32IbQYacf5xP7Wo Aubz7P80u3eewU+mvlCpblac1M37smAn7767yeEBkGRuh86J7ZdagMhRbM1BdWFckOE+ 2zpsVSpbUQA75w4uPaAKtHryg311Cj+3WvvqTNH1nXuq68lg7+N7WLUU0eVxSJN+Mm07 uiyQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=0JN1h+SdmbTH3kP7+d/LSAM256ls91/0oIY0PsAnI9c=; b=cuXAiJYSUVO0bEKL1/3XyAr3Oh6teETvSM4FgEmUmALWQ4HwC5EkwzZQWOUjpOcHXq l8q8Mxtir/ISRUO2fQTSxT56sUG4DA998/lIK9Ep+PVBp5NPk2sG1QDTLlxqm81VvW73 OMoAY5pg+HsaqUyoBHfXFCKbp1plVrWJFf+FIv5Arpu/D7jun6x7ioxCvfoY8MvoavJT b05ziBRsHRv8C7uc6xtviwA/7tpBP3DHBOtRP114ZDA7L8vyieEvzuGvfpWYi+UlRfYf bYtPZAqPuohWmxS5r2em3Gj00BkmDD11b9PSLqDZw9Y1kh5oqAQYJznPFlSvKhgs/mOM CUKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=aHR6Zeby; 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 g30si2964036eda.2.2019.09.25.02.45.05; Wed, 25 Sep 2019 02:45:29 -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; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=aHR6Zeby; 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 S2393524AbfIWJEo (ORCPT + 99 others); Mon, 23 Sep 2019 05:04:44 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:39518 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393166AbfIWJEm (ORCPT ); Mon, 23 Sep 2019 05:04:42 -0400 Received: by mail-lf1-f68.google.com with SMTP id 72so9485841lfh.6 for ; Mon, 23 Sep 2019 02:04:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=0JN1h+SdmbTH3kP7+d/LSAM256ls91/0oIY0PsAnI9c=; b=aHR6ZebyZ8DZpvzN5FPwizkSeWcTkugKWZ3zU5/wa6l5Q54ddMLdKKjzClEkVBcAIr R9Q0bAQBeD134Z05K7waWJ3GB31hRmYeoFBRNl9zeHVJguBN1TqCMfcnOhtE6FKLfkxC CB14f/dGMHvj7B3B1ElGiiHTXvRW9zUSm2oWo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=0JN1h+SdmbTH3kP7+d/LSAM256ls91/0oIY0PsAnI9c=; b=NGnGZrpiHCQkKq/9WOoGz4Je7WVFevIZv//RZccnFgaCOR2oEPffjqf3Mc85JQ/bEF /Rk63P6bHdPIG6To7uQax48AZV6i2U0tM0OWl4zf9ZaDJojxIn2hljNcNZOa0kwQ0N04 2xUIzZ4i7+JffcvkVI0YHclkazDBCFlut8WD6QT4Pze20VlQ1e3cpVY9ybvZ9BI/ebtp CZyr89iBfclGZTded8WX35QSRqEr7rGaoWzDOLS8Bhz2jG1SPO4qmjR9k0/3c17hjt3/ /vIdk4P3tfFVsmrrkszuX47Hm1ROo1tktcBFgXCGAXWnqqafHjFvOOz75OaWADarRn70 HWBw== X-Gm-Message-State: APjAAAURyTbkbe9zIljcgTM6riE6Ev23mrox+2HWCa2KLHmRnFvLBVH9 MvD8BauHh/wWEYe05Q3+fJ+N0A== X-Received: by 2002:ac2:5091:: with SMTP id f17mr16518413lfm.107.1569229480930; Mon, 23 Sep 2019 02:04:40 -0700 (PDT) Received: from [172.16.11.28] ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id g26sm2174673lje.80.2019.09.23.02.04.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Sep 2019 02:04:40 -0700 (PDT) Subject: Re: [PATCH 1/4] pwm: mxs: implement ->apply To: =?UTF-8?Q?Uwe_Kleine-K=c3=b6nig?= , 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 References: <20190923081348.6843-1-linux@rasmusvillemoes.dk> <20190923081348.6843-2-linux@rasmusvillemoes.dk> <20190923082459.huqpbz5eseonkscv@pengutronix.de> From: Rasmus Villemoes Message-ID: Date: Mon, 23 Sep 2019 11:04:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190923082459.huqpbz5eseonkscv@pengutronix.de> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23/09/2019 10.24, Uwe Kleine-K?nig wrote: > Hello Rasmus, > > On Mon, Sep 23, 2019 at 10:13:45AM +0200, Rasmus Villemoes wrote: >> In preparation for supporting setting the polarity, switch the driver >> to support the ->apply method. >> > > Maybe it would be easier to review when converting from .config + > .enable + .disable to .apply in a single step. (Note this "maybe" is > honest, I'm not entirely sure.) I tried to make .apply do exactly what the old sequence of calls from the core to the individual methods would do, and for that it seemed a little easier to keep the old methods around - but yes, I do need to be more careful than that to provide the atomicity guarantee that the legacy methods did not. It's also much easier to squash than to split, so for now I'll leave them separate - if somebody prefers them squashed, I'll do that. > There is a bug: If the PWM is running at (say) period=100ms, duty=0ms > and we call > pwm_apply_state(pwm, { .enabled = false, duty=100000, period=1000000 }); > the output might get high which it should not. Ah, yes. So I suppose that if we're changing from enabled to disabled, we should simply disable it in the CTRL register before changing the duty/period. > Also there is a bug already in .config: You are not supposed to call > clk_get_rate if the clk might be off. Interesting, I didn't know that. So the prepare_enable logic needs to be moved before we start computing the period/duty cycles. Do you know why it has apparently worked so far? I would have thought such a rule would be enforced by the clock framework, or at least produced a warning. Thanks for the fast review. I'll wait a day or two to see if there are other comments before sending out a v2. Rasmus