Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp1100193imc; Mon, 11 Mar 2019 06:32:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqwcKum0QcrxSk48dEdtSrfRChrQFPDCuIa/VBTofNSkJ3FaBqbv2LU1RLF5YIVKNcJBJ/K/ X-Received: by 2002:a17:902:bb0c:: with SMTP id l12mr34189183pls.108.1552311122849; Mon, 11 Mar 2019 06:32:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552311122; cv=none; d=google.com; s=arc-20160816; b=ZghuT/WN7L4H8UQPv4r+8bBiFTdutnC4rC2+XeFQL1QyCPF7o9fimCSEPq6ZfEtKPu iuw1c88f6rm6dGtyrBVWsuUtBvwMqFRdimlRwvNSRrvWRK6/3Jcj28y10Jg/nI8VUbkF 4sRHXA+zrcG+GBdwlpMwJ/cxYiDB2njohQqbhKAUneH2STiPuTo6vHTuVoTB1QWs6sMP cuxQuNysdyhA06sKbbLNkBZdNGFi8JpLl+pZAlYWO3dgpry6f9v2n/BJeBThUVPrPODf kquNOx1T8OThTszPreXzuWXifft5tCOYj26mLR19gTLGM3KBrter8xPhzh1l838qr3M6 +fxA== 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=Vpn8J51vyz4JJJOGrQDLsjxbW5BttOIbYTc1aWbd4jI=; b=dUBH0f/uXTywDn8SRTI4wcpi5q4zrJUMua+PCREuReIervOiJ2bfdaKIT2ffL0kkCL 34gwrwhnUg/lb+jsuHGxyh5oz1uHbwmapo1Jddg1oWMDIUkJlmviQ4IsRNSzSOrCAu+r edInXK9qa4VnuTDWx8gFqfVIaGeWY7tlASbjQYR5b0BYkLZphkp9sWSdnpvzH9byThyx 1BeZb0QO5fb3/SKeTOK/b6cEKNwM2IrfU/IxF4z31N0IByqpFvBfeK+38cDgjtpqMm3v 6f6JGdgI8dnOJjgCC1qUMgkRwn8lSTPLFMKI3xIBQqCq+4rjZseuDgp3sXDAnHkZnOim YjEA== 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 c6si5243114plr.166.2019.03.11.06.31.47; Mon, 11 Mar 2019 06:32:02 -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 S1727939AbfCKN32 (ORCPT + 99 others); Mon, 11 Mar 2019 09:29:28 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:36501 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727754AbfCKN31 (ORCPT ); Mon, 11 Mar 2019 09:29:27 -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.89) (envelope-from ) id 1h3Kzb-0001Ck-Sw; Mon, 11 Mar 2019 14:29:23 +0100 Received: from ukl by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1h3Kza-0002xR-NC; Mon, 11 Mar 2019 14:29:22 +0100 Date: Mon, 11 Mar 2019 14:29:22 +0100 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Yash Shah Cc: mark.rutland@arm.com, linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, Palmer Dabbelt , linux-kernel@vger.kernel.org, robh+dt@kernel.org, Sachin Ghadi , Thierry Reding , kernel@pengutronix.de, Paul Walmsley , linux-riscv@lists.infradead.org Subject: Re: [PATCH v8 2/2] pwm: sifive: Add a driver for SiFive SoC PWM Message-ID: <20190311132922.iowselp7qvmroiaa@pengutronix.de> References: <1551437599-29509-1-git-send-email-yash.shah@sifive.com> <1551437599-29509-3-git-send-email-yash.shah@sifive.com> <20190307152745.kaiv6q4ygf2apmuv@pengutronix.de> <20190308115726.smgooacsr37fmxwg@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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, On Mon, Mar 11, 2019 at 05:10:17PM +0530, Yash Shah wrote: > On Fri, Mar 8, 2019 at 5:27 PM Uwe Kleine-K?nig > wrote: > > On Fri, Mar 08, 2019 at 04:59:36PM +0530, Yash Shah wrote: > > > On Thu, Mar 7, 2019 at 8:57 PM Uwe Kleine-K?nig > > > wrote: > > > > > + if (state->period != cur_state.period) { > > > > > > > > Did you test this with more than one consumer? For sure the following > > > > should work: > > > > > > > > pwm1 = pwm_get(.. the first ..); > > > > pwm_apply_state(pwm1, { .enabled = true, .period = 10000000, .... }); > > > > > > > > pwm2 = pwm_get(.. the second ..); > > > > pwm_apply_state(pwm2, { .enabled = true, .period = 10000000, .... }); > > > > > > > > but for the second pwm_apply_state() run state->period is likely not > > > > exactly 10000000. > > > > > > Yes, I have tested multiple consumers using sysfs interface. It is working. > > > > Can you provide details about your testing here? What is the parent clk > > rate? Which settings did you test? Can you confirm my claim that the > > above sequence would fail or point out my error in reasoning? > > > > I have tested on HiFive Unleashed board using sysfs interface. > Parent clk rate is around 512 Mhz. > I have tested scenarios as you mentioned above with various period and > duty_cycle values. > > After considering your below suggestion, > | To get the result independent of the prior configuration you better use > | the real targeted period length as input instead of the last configured > | approximation > I will introduce approx_period feild, which will be used as the > targeted period length. > Also, in pwm_sifive_get_state, I will make below change > - state->period = pwm->real_period; > + state->period = pwm->approx_period. > So with this change in place, I believe the cur_state.period for the > second pwm_apply_state() above (pwm2) will be exactly 10000000 I don't understand your intention completely. Just send a new patch round, then I will gladly take another look. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |