Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3733463rwb; Fri, 30 Sep 2022 07:38:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6lGw42y/Ar/fPZhzwRumoB2ujWDNR6nyxgmRhahtGVg4e/1yoX6RxeZx27W7NzNhfNqOKr X-Received: by 2002:a05:6402:27d1:b0:44f:2c17:1a44 with SMTP id c17-20020a05640227d100b0044f2c171a44mr8284666ede.18.1664548725926; Fri, 30 Sep 2022 07:38:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664548725; cv=none; d=google.com; s=arc-20160816; b=miGFbV5FBHENAcnQcFHeVlI5wCQXE7coi5te45RGXPEndA99ybl8Li/EPex1mGBjVh wmsheTyYMgGhEGqdTdyPhHQsZAztPJkUNg66KkJ+qFYYjeG2NqMYwXa2JxeLfSxfoS4h iUj9fV0E2PKXgG2UFqsRrGRLMD3HoLrAPvRMh5z+HGNWJY6vFE3+pbMzKhQS+o7Du7KJ 1hkwpv3hqpii+/92JERJo1JXfi4LMFPu0GLkY46IrwWJ3M605gLrv55KzEBs1Dg8pbPB cKJfj5oTmbnM8REO7tjVV2dTpJzUlVO7P771QzfVGT8M3edxoPGwSl/Wo/T8cOIQpFdF JL4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=frTH60lV72ck6IFwwTsCcIraArDa7bhaez7y347+DeQ=; b=w6dvUUdc2+IPN7zksZXkRB4xay4o3FmrbDuj0t4oLHr6R2URpdgUWnTG7LUs/yR4pe JIL14q9QyWYikjM3XuX1iMsks4xUJ41otdpl+hyC+90T0HnUCfqGsv+Bxyprv7yC0hdJ 8i8VPBtFxs5n/VpH2OP4/FSGHrIIqXs6W6jiMQBG+AECpBw7iyEEnydXUJu1uo30kwZd wPtxtu/JZYY7JByVG7i6Cx4UezApa1aF/2iRkaNIGufHbo6Lfpwnu8POgJ7XOQkhgtXo bVTM1f9PDG2grNJKKAe0BYkI0R6JePtekHvQwlDDFPesBnnJZccd+jVfzU7b2XLFT67m DJdw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d1-20020aa7ce01000000b004485cce26d6si1735763edv.190.2022.09.30.07.38.18; Fri, 30 Sep 2022 07:38:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231477AbiI3Njv (ORCPT + 99 others); Fri, 30 Sep 2022 09:39:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231464AbiI3Njt (ORCPT ); Fri, 30 Sep 2022 09:39:49 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEB7E1AD8A for ; Fri, 30 Sep 2022 06:39:46 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oeGEp-0004vB-IS; Fri, 30 Sep 2022 15:39:35 +0200 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1oeGEp-003oPC-LV; Fri, 30 Sep 2022 15:39:34 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1oeGEn-004g8M-Gs; Fri, 30 Sep 2022 15:39:33 +0200 Date: Fri, 30 Sep 2022 15:39:33 +0200 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Conor Dooley Cc: Thierry Reding , Rob Herring , Krzysztof Kozlowski , Daire McNamara , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org, linux-riscv@lists.infradead.org Subject: Re: [PATCH v10 3/4] pwm: add microchip soft ip corePWM driver Message-ID: <20220930133933.br5kanbh3clvahvr@pengutronix.de> References: <20220824091215.141577-1-conor.dooley@microchip.com> <20220824091215.141577-4-conor.dooley@microchip.com> <20220915072152.y346csakn7wetpz5@pengutronix.de> <20220919135008.sahwmwbfwvgplji4@pengutronix.de> <20220930091316.kdkf4oeu6uvxzqa6@pengutronix.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="rtjav5n2d7kuyppr" Content-Disposition: inline In-Reply-To: X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 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 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --rtjav5n2d7kuyppr Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Sep 30, 2022 at 10:45:56AM +0100, Conor Dooley wrote: > On Fri, Sep 30, 2022 at 11:13:16AM +0200, Uwe Kleine-K=F6nig wrote: > > On Mon, Sep 19, 2022 at 03:29:19PM +0100, Conor Dooley wrote: > > > Hey Uwe, > > >=20 > > > On Mon, Sep 19, 2022 at 03:50:08PM +0200, Uwe Kleine-K=F6nig wrote: > > > > On Mon, Sep 19, 2022 at 01:53:56PM +0100, Conor Dooley wrote: > > > > > Because I was running into conflicts between the reporting here a= nd some > > > > > of the checks that I have added to prevent the PWM being put into= an > > > > > invalid state. On boot both negedge and posedge will be zero & th= is was > > > > > preventing me from setting the period at all. > > > >=20 > > > > I don't understood that. > > >=20 > > > On startup, (negedge =3D=3D posedge) is true as both are zero, but th= e reset > > > values for prescale and period are actually 0x8. If on reset I try to > > > set a small period, say "echo 1000 > period" apply() returns -EINVAL > > > because of a check in the pwm core in pwm_apply_state() as I am > > > attempting to set the period to lower than the out-of-reset duty cycl= e. > >=20 > > You're supposed to keep the period for pwm#1 untouched while configuring > > pwm#0 only if pwm#1 already has a consumer. So if pwm#1 isn't requested, > > you can change the period for pwm#0. >=20 > I must have done a bad job of explaining here, as I don't think this is > an answer to my question. >=20 > On reset, the prescale and period_steps registers are set to 0x8. If I > attempt to set the period to do "echo 1000 > period", I get -EINVAL back > from pwm_apply_state() (in next-20220928 it's @ L562 in pwm/core.c) as > the duty cycle is computed as twice the period as, on reset, we have > posedge =3D negedge =3D 0x0. The check of state->duty_cycle > state->peri= od > fails in pwm_apply_state() as a result. So set duty_cycle to 0 first? A problem of the sysfs interface is that you can only set one parameter after the other. So there you have to find a sequence of valid pwm_states that only differ in a single parameter between the initial and the desired state. That's nothing a "normal" pwm consumer would be affected by. (IMHO we should have a userspace API that benefits from the properties of pwm_apply().) Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | https://www.pengutronix.de/ | --rtjav5n2d7kuyppr Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmM28ZIACgkQwfwUeK3K 7AmJ0Af/Uo5rO+tFoSMofiW5sgL/QaXfTixAJCtvamJAfhQDDzksiQLoyMz9Evj9 vPB281oL3yRgjSiLxTRl9jW51jJclF05muLkOkC/yHZgBRKjrrvuPNPsInDLDF3W VLjCvv9F3So7LFQwWkdgbFiGnQcuBGkVvj2DgWPKRUfxmW71J3BV9DLM+aLTIWnl /OTIxdiVtA29+G7Hm00gkbC/d1glG4bC8fHZ15l06457Ab76SDlzy/0z9Pa9/wlZ bJ/HcBPOZNJO5R4C1x1YKGz2HLCRRmaRxnO5aSLorzwlLoGDu3sTZ72JCNSb4mqt 09gY/rxyEwV5Enqk7Ud+OS4XgGOlCA== =BB3H -----END PGP SIGNATURE----- --rtjav5n2d7kuyppr--