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=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 D007CC433B4 for ; Fri, 23 Apr 2021 17:06:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AA09C6113B for ; Fri, 23 Apr 2021 17:06:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243310AbhDWRHW (ORCPT ); Fri, 23 Apr 2021 13:07:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243246AbhDWRHW (ORCPT ); Fri, 23 Apr 2021 13:07:22 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6056C061574 for ; Fri, 23 Apr 2021 10:06:45 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id z6so8596068wmg.1 for ; Fri, 23 Apr 2021 10:06:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=GeNC38T5dHxMBu24uT7gyu9gPGAEn5EuXtFTyIHTKi4=; b=fEef3xffsw/n5iQsrsHSQZgQXjnvsbaVRAO4VE2+7wxjQQ6FECQMtdvUlGDzBj/QKz U809nXjkxX4hPeYu6kMhBCQketBBJf4tYFOb2ABDTe/M7qMEZJGhA5od76BFjaURef5X AP+Nl5uUqqnMlYz1sMjuL3iAcXbuqzbTuLP3kkMDBJkQVoLoEr5rt/PJb/rYrSadEtLU OYbKd9R3RbmdpourUfYc84Agf4DdzCKCGxPCR1lZ4YUH2zm4xjetkilntTFq037w/4yy X3VeFMJym+7Jr+PdtONjc9ztMg7Smg0wzNKb0h5H3iqS+CnqXTew2ql4Tyw66GsaJa/k K1Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=GeNC38T5dHxMBu24uT7gyu9gPGAEn5EuXtFTyIHTKi4=; b=YW1zCbRPfuYjVxGns4GwKVR1M546TAUdpj18aKNqdEtzAu0z0dmXGo+xOQfqWOUdn1 edqJSeFmsXBkigpvRUic+f62mCd/9C/qmKuDrxlfrHlF3TBXEAu3ZSMLzB7aKAuJNJOE i8+UJ5iZAN95RBmzTfY035TMMLLB4nfBRT/Cibb/1HY4d39iujDlwi4LdkP4iJjVFg5W dujkmEXR60Xv73kTi6UrqUkoQXJRTWHuqZ3eu31mAn3+54oiqw+jEHh5yeJ7k7HGbGpq zMwPjdspHSv3LTUNkpbw+LzkBG1/xHVaFGz13l04VtN6pMMZZcfTejlCQiCTRRcHjR68 lwdg== X-Gm-Message-State: AOAM533obw27+eZnIIgiScgrTLVxr91oY31uB2vhJZDLk5F5UDyXhPmU 2WKQbVMm9Svq7uaOBnsXo3A= X-Google-Smtp-Source: ABdhPJw9aKdppA2puyid2A9p4VUDmBhqP7xfd5sjLy1KB2OKeexu6hzE4hB0c+HdfbxNNxsm+tePdg== X-Received: by 2002:a1c:a9d5:: with SMTP id s204mr5422623wme.24.1619197604475; Fri, 23 Apr 2021 10:06:44 -0700 (PDT) Received: from localhost ([62.96.65.119]) by smtp.gmail.com with ESMTPSA id x2sm10539976wrg.31.2021.04.23.10.06.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 10:06:43 -0700 (PDT) Date: Fri, 23 Apr 2021 19:07:32 +0200 From: Thierry Reding To: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= Cc: Claudiu Beznea , Lee Jones , Nicolas Ferre , Alexandre Belloni , Ludovic Desroches , linux-arm-kernel@lists.infradead.org, linux-pwm@vger.kernel.org, kernel@pengutronix.de Subject: Re: [PATCH 2/2] pwm: atmel: Improve duty cycle calculation in .apply() Message-ID: References: <20210420095118.1571344-1-u.kleine-koenig@pengutronix.de> <20210420095118.1571344-2-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="yZbWICAcXqer7Kjy" Content-Disposition: inline In-Reply-To: <20210420095118.1571344-2-u.kleine-koenig@pengutronix.de> User-Agent: Mutt/2.0.6 (98f8cb83) (2021-03-06) Precedence: bulk List-ID: X-Mailing-List: linux-pwm@vger.kernel.org --yZbWICAcXqer7Kjy Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 20, 2021 at 11:51:18AM +0200, Uwe Kleine-K=C3=B6nig wrote: > In the calculation of the register value determining the duty cycle the > requested period is used instead of the actually implemented period which > results in suboptimal settings. >=20 > The following example assumes an input clock of 133333333 Hz on one of > the SoCs with 16 bit period. >=20 > When the following state is to be applied: >=20 > .period =3D 414727681 > .duty_cycle =3D 652806 >=20 > the following register values used to be calculated: >=20 > PRES =3D 10 > CPRD =3D 54000 > CDTY =3D 53916 >=20 > which yields an actual duty cycle of a bit more than 645120 ns. >=20 > The setting >=20 > PRES =3D 10 > CPRD =3D 54000 > CDTY =3D 53915 >=20 > however yields a duty of 652800 ns which is between the current result > and the requested value and so is a better approximation. >=20 > The reason for this error is that for the calculation of CDTY the > requested period was used instead of the actually implemented one. >=20 > Signed-off-by: Uwe Kleine-K=C3=B6nig > --- > drivers/pwm/pwm-atmel.c | 23 ++++++++++++++++------- > 1 file changed, 16 insertions(+), 7 deletions(-) Applied, thanks. Thierry --yZbWICAcXqer7Kjy Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAmCC/tQACgkQ3SOs138+ s6EneBAAiYyw7jW7tEb5ZqjfZ/YbBSeYPHnRYC8Cm2tzLVldsyFf7QruHnqzDRb+ MtrhwVT97N1/g575JcxsCuKm3dYGny75LcnjewwY2dEMz85aL0YhEdZeZdzYd6Zo XpOr7xQXq4xSdCjKhcZEQn66ZJKfzaTCtOwUqSbCujgU6Vpliucxkf0a3/nEohXt mAVOkbir1zzRZVo5mV9h5rRUhd6SMfDzdvFafclnm+LcxVj8lYrCF6W4GZSimt95 1SG/YRs78QWTB3fR7R5TY1oWEnBPOLzc4BIvNDHOw1/0c3zT3Hh6qmjbxoK9FGUY m0fBMO9uswnYIlD5CyRs47k+bn5HzykOh6wAOnqX3SqAy3CDi/s1bwwqm4EatSjM vNgJ7lRxfcl0GrihpyWEdCEkgN7E03ThGYpHD8XZtKnCvv3nXdMnpX6apakMyr0O p8IFA11hmGKffOxFIclpMBCAlkio1TPWX9rBGmqXrt7x3uuGiV37hAcSxFIPuMqn 2gj/Vuellx/VLR8VQEdiSSSh6STsaV2g1nC4MttcHORnQQTN9o9UdVi2L7a2rMDw sfQApdrcxPktx8R5nrmuoAXh1N8rLMf6zvzoh+aEWZotedimEfQu7ifLki22p9QS D/Y2l1LJHVgRE91pV1q7KgKM1DSnC3imSslFCp4BFSj90WKAxsg= =J+nG -----END PGP SIGNATURE----- --yZbWICAcXqer7Kjy-- 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=-12.2 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham 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 94ACFC433ED for ; Fri, 23 Apr 2021 17:08:30 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0831F61153 for ; Fri, 23 Apr 2021 17:08:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0831F61153 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Type:Cc: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VxJ8FQNPyu9VAozAQmerVrVWCI9P/VblloMGZmwFN6w=; b=UdBOV42ky48F3Cr5AcKSsxo/Q bB+R2Pjjfv9j5WmQySZ0AmcOmoNcPe1/EDW3yKsHy7V0ZychPVmRx3y5mgFV5bFFUraWjOYWWb7yO WDeuAF2dIZThZns0X6/owujQ4vTb+YNjStshrESG2JSQE4aJciAJnF5OQf/De5UDOSkX6XvkdSLx9 0G9UIw6aCuiCpq/hjyT/o09hLpfeseGMWU52uIl70HA33vn386P2ivcFCLynVMQCA2j+ybCilvKqR JbZjP66o/GNCRVeuIdU4hlS1GoUxJra4PwSA/Jma1RKFhvA5/0LXj8bwJlLo1Ot5piTcp7nfpiKaC UYgI5pGLg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZzGX-001xMC-9B; Fri, 23 Apr 2021 17:06:55 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZzGT-001xLb-Kc for linux-arm-kernel@desiato.infradead.org; Fri, 23 Apr 2021 17:06:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=GeNC38T5dHxMBu24uT7gyu9gPGAEn5EuXtFTyIHTKi4=; b=gWhUyC2fzxK7eoVjKGLgXJlLAB 0mWOlM7oMAzf0VOFbPZLwKFD+D+8rDq2J/jDRnaWrgOO2nMSZkOW2X/yYvn5mZgknVJQJ5Go75n4q ElYdk8ncY5Ov7rziZjUQLSFz1l+xSSqSNTzBIeCKsCxzDB6HlcsjKB7yWwHUJOkAF7lyBZ1LdD0hF ZloTih1hJ+G9yPhmO81k4yK1woAqOn4Q4gx01QHh8F4ZXXqXy7SOmYjRsaS4QIk5Kr8i3E1+Q+Ztd 7zvfShr0WgfB4hhDVumG0c2WPXXuqtuLroU6VEy8znIuK+fOPewpbJQ6D2wRA3evjxPiMkjBWR4+6 kjz6yrzw==; Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZzGR-00EZu2-62 for linux-arm-kernel@lists.infradead.org; Fri, 23 Apr 2021 17:06:48 +0000 Received: by mail-wm1-x335.google.com with SMTP id n127so14592921wmb.5 for ; Fri, 23 Apr 2021 10:06:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=GeNC38T5dHxMBu24uT7gyu9gPGAEn5EuXtFTyIHTKi4=; b=fEef3xffsw/n5iQsrsHSQZgQXjnvsbaVRAO4VE2+7wxjQQ6FECQMtdvUlGDzBj/QKz U809nXjkxX4hPeYu6kMhBCQketBBJf4tYFOb2ABDTe/M7qMEZJGhA5od76BFjaURef5X AP+Nl5uUqqnMlYz1sMjuL3iAcXbuqzbTuLP3kkMDBJkQVoLoEr5rt/PJb/rYrSadEtLU OYbKd9R3RbmdpourUfYc84Agf4DdzCKCGxPCR1lZ4YUH2zm4xjetkilntTFq037w/4yy X3VeFMJym+7Jr+PdtONjc9ztMg7Smg0wzNKb0h5H3iqS+CnqXTew2ql4Tyw66GsaJa/k K1Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=GeNC38T5dHxMBu24uT7gyu9gPGAEn5EuXtFTyIHTKi4=; b=XpW3o+b61WxfMrgRZQcqnA4r8pSODQQJXcJyZSXFnZxjy+nlVSHvCeJuTOGgDSLNSk ko1KnFPMxqpRxfZFdrFfapaDzXHRC+ukKerLKzho62v9pNR/64yZIEMwF+3bFM8rlvHb /7XNZFZdaNvxEPzVccGavFLGeGNEgkLPcTAzgWL8BSxQzLmD41g15nLl5Jiakn2M+GGF sHujFRxgcxr77d0NBoNQX6FtVTodhkttRpd91l+j5w5pemUGYuodmYShCGEL/wDKm92f RBnkW7lke+f2m1hGH6Y6jTWIKtLUmD5tjNQ8FC6K1dNC9Em9o9/3SDtKS7ODXUbABy6C 7m4A== X-Gm-Message-State: AOAM531+dGX5GFSWmwXhA8ZAZaG4jSgAh1pgTe2VMPoffy1I9xJehHix iiPfNs3M5zN+wM6+OuWfGG4= X-Google-Smtp-Source: ABdhPJw9aKdppA2puyid2A9p4VUDmBhqP7xfd5sjLy1KB2OKeexu6hzE4hB0c+HdfbxNNxsm+tePdg== X-Received: by 2002:a1c:a9d5:: with SMTP id s204mr5422623wme.24.1619197604475; Fri, 23 Apr 2021 10:06:44 -0700 (PDT) Received: from localhost ([62.96.65.119]) by smtp.gmail.com with ESMTPSA id x2sm10539976wrg.31.2021.04.23.10.06.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 10:06:43 -0700 (PDT) Date: Fri, 23 Apr 2021 19:07:32 +0200 From: Thierry Reding To: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= Subject: Re: [PATCH 2/2] pwm: atmel: Improve duty cycle calculation in .apply() Message-ID: References: <20210420095118.1571344-1-u.kleine-koenig@pengutronix.de> <20210420095118.1571344-2-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 In-Reply-To: <20210420095118.1571344-2-u.kleine-koenig@pengutronix.de> User-Agent: Mutt/2.0.6 (98f8cb83) (2021-03-06) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210423_100647_249524_A79B146D X-CRM114-Status: GOOD ( 18.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, Alexandre Belloni , Ludovic Desroches , kernel@pengutronix.de, Lee Jones , Claudiu Beznea , linux-arm-kernel@lists.infradead.org Content-Type: multipart/mixed; boundary="===============0378378799496462757==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============0378378799496462757== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="yZbWICAcXqer7Kjy" Content-Disposition: inline --yZbWICAcXqer7Kjy Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 20, 2021 at 11:51:18AM +0200, Uwe Kleine-K=C3=B6nig wrote: > In the calculation of the register value determining the duty cycle the > requested period is used instead of the actually implemented period which > results in suboptimal settings. >=20 > The following example assumes an input clock of 133333333 Hz on one of > the SoCs with 16 bit period. >=20 > When the following state is to be applied: >=20 > .period =3D 414727681 > .duty_cycle =3D 652806 >=20 > the following register values used to be calculated: >=20 > PRES =3D 10 > CPRD =3D 54000 > CDTY =3D 53916 >=20 > which yields an actual duty cycle of a bit more than 645120 ns. >=20 > The setting >=20 > PRES =3D 10 > CPRD =3D 54000 > CDTY =3D 53915 >=20 > however yields a duty of 652800 ns which is between the current result > and the requested value and so is a better approximation. >=20 > The reason for this error is that for the calculation of CDTY the > requested period was used instead of the actually implemented one. >=20 > Signed-off-by: Uwe Kleine-K=C3=B6nig > --- > drivers/pwm/pwm-atmel.c | 23 ++++++++++++++++------- > 1 file changed, 16 insertions(+), 7 deletions(-) Applied, thanks. Thierry --yZbWICAcXqer7Kjy Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAmCC/tQACgkQ3SOs138+ s6EneBAAiYyw7jW7tEb5ZqjfZ/YbBSeYPHnRYC8Cm2tzLVldsyFf7QruHnqzDRb+ MtrhwVT97N1/g575JcxsCuKm3dYGny75LcnjewwY2dEMz85aL0YhEdZeZdzYd6Zo XpOr7xQXq4xSdCjKhcZEQn66ZJKfzaTCtOwUqSbCujgU6Vpliucxkf0a3/nEohXt mAVOkbir1zzRZVo5mV9h5rRUhd6SMfDzdvFafclnm+LcxVj8lYrCF6W4GZSimt95 1SG/YRs78QWTB3fR7R5TY1oWEnBPOLzc4BIvNDHOw1/0c3zT3Hh6qmjbxoK9FGUY m0fBMO9uswnYIlD5CyRs47k+bn5HzykOh6wAOnqX3SqAy3CDi/s1bwwqm4EatSjM vNgJ7lRxfcl0GrihpyWEdCEkgN7E03ThGYpHD8XZtKnCvv3nXdMnpX6apakMyr0O p8IFA11hmGKffOxFIclpMBCAlkio1TPWX9rBGmqXrt7x3uuGiV37hAcSxFIPuMqn 2gj/Vuellx/VLR8VQEdiSSSh6STsaV2g1nC4MttcHORnQQTN9o9UdVi2L7a2rMDw sfQApdrcxPktx8R5nrmuoAXh1N8rLMf6zvzoh+aEWZotedimEfQu7ifLki22p9QS D/Y2l1LJHVgRE91pV1q7KgKM1DSnC3imSslFCp4BFSj90WKAxsg= =J+nG -----END PGP SIGNATURE----- --yZbWICAcXqer7Kjy-- --===============0378378799496462757== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --===============0378378799496462757==--