Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3972366pxu; Wed, 9 Dec 2020 05:27:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJzwzcMj9/4olzykzQNLq2181Skzt/wpmxDFwpyv1piNVQBz/fG90w9gmfDWXD5AUXpBAfdc X-Received: by 2002:a17:906:3099:: with SMTP id 25mr2035809ejv.321.1607520434549; Wed, 09 Dec 2020 05:27:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607520434; cv=none; d=google.com; s=arc-20160816; b=cWTQJrLAqsDnfvrKHC188Nh2OsVuKbIbqhCif2qEAgHqxiOvKTX42SFVjorRLgWZex a92nVKYTM/ZQPh1Wwrt6SchAL7QyFrgiORHSCjtz7FoAY39UxtxdOU2zD2C4rHa1RaEQ 3CnarMCcZrxCTuGWNTLo17HNUR4Uz2I41JHdoeZSdXQaYVqQjdidmvd/RmwNUi/wK2Fi 1lJnW2VEZAKzB8tR/lG//0GyKNf2Hf7BGB6sHCJ1WBvcAnugn7mspn4bg5+SN7OnPQSt dj4Z8rBCPTFn5HoY3ISNox0nW/YsJphKQDI8wv5HctkSKY8wueuyoXrznPVuNWUEGTm1 Y5Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:references:in-reply-to :sensitivity:importance:date:subject:cc:to:from:message-id :mime-version:dkim-signature; bh=YwF00mwibrys4vNtd8Svm1NhKiCvDrd0aEEoIRlKyGQ=; b=nHhKWkZKeCnvifdGT8uyAftailsDV2ueNKQXYg3slNBRUlbFbk+PEZXthx70SMzP8u ZtCDJt9SO8WFPJ1xCQcchFK6WOrZtz+dSKYaGnPposUmTVZH1+NHnItC4HNNaqs63S6u VcTKKWUF+EsmcNKc5ircUq+ItkuFiWN/9U6N2B3dN9Wv8DvQ34ClQoICSaRPsB26BYZq AHs2noqJwPDVZ57NSb8NvIdvHNLQ/73YcMK+51hncm84SJl2kJ7VoX3QMTpw3gr50kVS 4MdRvNAKWhK/g451nm1UY8lIDa3amqH8NJiVzeaf5Fdyq2RqGOEKALLJzJfh+twzqfOU Sqmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=EouvbU0I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p26si745812eja.49.2020.12.09.05.26.52; Wed, 09 Dec 2020 05:27:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=EouvbU0I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732216AbgLINVv (ORCPT + 99 others); Wed, 9 Dec 2020 08:21:51 -0500 Received: from mout.gmx.net ([212.227.17.20]:37853 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728121AbgLINVu (ORCPT ); Wed, 9 Dec 2020 08:21:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1607520006; bh=zAnsVzlKtDFf8rlLGKNYmI2t6mkp8AFROP2Nh83D9wg=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=EouvbU0ImX2++An5OBOZFOm10xCDo4svsKIWRMjnRTchfoQkTZGKKuKUrErkghdFS JBhXToGhRjPH+dr73QGZBHjiSLW2QJp7sF5yWkr13gz9WA8k/flCOtnNGVyT1vDBzI +9+FhCUSE5Ia5nsiiuN85XM5k/q4VDPyuSn/6lCs= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [87.130.101.138] ([87.130.101.138]) by web-mail.gmx.net (3c-app-gmx-bap29.server.lan [172.19.172.99]) (via HTTP); Wed, 9 Dec 2020 14:20:05 +0100 MIME-Version: 1.0 Message-ID: From: Lino Sanfilippo To: =?UTF-8?Q?Uwe_Kleine-K=C3=B6nig?= Cc: thierry.reding@gmail.com, lee.jones@linaro.org, nsaenzjulienne@suse.de, f.fainelli@gmail.com, rjui@broadcom.com, sean@mess.org, sbranden@broadcom.com, bcm-kernel-feedback-list@broadcom.com, linux-pwm@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Aw: Re: [PATCH v3] pwm: bcm2835: Support apply function for atomic configuration Content-Type: text/plain; charset=UTF-8 Date: Wed, 9 Dec 2020 14:20:05 +0100 Importance: normal Sensitivity: Normal In-Reply-To: <20201209070516.yw5bpsh474k7mnfx@pengutronix.de> References: <1607464905-16630-1-git-send-email-LinoSanfilippo@gmx.de> <20201209070516.yw5bpsh474k7mnfx@pengutronix.de> X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:NeLwQDnZjDRL8pPhrfxRVEcfkhdsfwiPMYeKrVMjV4HKBqVeDxW4BRQnyU3BTU4pwIzdo qwj/9n0s31LBsymOdTEFiRxbi6ryFNc1khyxzDSHWG8JFR9G+VcblhAMo5xQUakJ/WdZ7D/39/qi PhhxzrZU4SwT0RW3mp/UVKYYh3LJagKxsMMMR3yWv7KGJZXmt+SdndWlfMykGEM9HkU3ZXazsCcs Hc6MyAghCIIa7VrXzxjOYzobL3sRWtrsOHxpOQW+QHI/Bve4opN+yDkJp4VeILr8jRX1Z+OUjdKG ek= X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:QFlLyWexZ84=:MoIzZjYkgsnTrcAqSQR4Zl n8e2SQ8lc9qo1MUO9BzPwcAIJjDb0D3lU9Kg6vdzuCfHjRI3V1rb8YO2WkhT1Se4oEB9DTaOT wE5X1if1qsuVz9nS75O4BJO3W24V2hlswA+7LDA0x/2rdwyLkZ0SqCROlyJTklIsbnQvp+CUk be80Xo3sOSBVet7IXChXIlkFmQRSTBfcvlehJ749JAIqvGBPokNi5Mz+IH7yYWB5d+PXkE/xo ffhHBrT7RwoYlraojMj6i2ypXOaFYg4YexjJvIPRJphV7SuMtGhHDCumbEOKgr0NOmWPhsryo 9lPhMgW2193bh0NprsWxplha9HNVJIKt6fgHzhluWJIGeKAXGKdBAi5I9OtuYfKc3sI1VvsO/ rmSdTz7j+SozQ+cxLu0QInfr+g2EUj+s0FszW4xPr07t/kKs/Uh4SyD2yTE9+TB/oWU7qvwyM B+KJ6D+BbZwW5gkzZnFQ/7OcWv9Jt/E/35HR/DuHpVyhi8fGqWXmLZG14/NR421TCIj9F+4E2 7J5/FApM9vANn0NuDHtkjr7choqazVRx8vxqLS/Z53uCV+GOxLkmDVqbTEpQ44RLPYp0c/Yo7 20aKSxAMq/BBQ= Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Uwe > Hello Lino, > > On Tue, Dec 08, 2020 at 11:01:45PM +0100, Lino Sanfilippo wrote: > > Use the newer .apply function of pwm_ops instead of .config, .enable, > > .disable and .set_polarity. This guarantees atomic changes of the pwm > > controller configuration. It also reduces the size of the driver. > > > > Since now period is a 64 bit value, add an extra check to reject perio= ds > > that exceed the possible max value for the 32 bit register. > > > > This has been tested on a Raspberry PI 4. > > This looks right, just two small nitpicks below. > > > This cast isn't necessary. (And if it was, I *think* the space between > "(u32)" and "period" is wrong. But my expectation that checkpatch warns > about this is wrong, so take this with a grain of salt.) OK, I will omit the cast in the next patch version (it was primarily meant for documentation purposes but now it seems to me rather unusual for kernel code) > > > - value =3D readl(pc->base + PWM_CONTROL); > > - value &=3D ~(PWM_ENABLE << PWM_CONTROL_SHIFT(pwm->hwpwm)); > > - writel(value, pc->base + PWM_CONTROL); > > -} > > + /* set duty cycle */ > > + val =3D DIV_ROUND_CLOSEST_ULL(state->duty_cycle, scaler); > > + writel(val, pc->base + DUTY(pwm->hwpwm)); > > > > -static int bcm2835_set_polarity(struct pwm_chip *chip, struct pwm_dev= ice *pwm, > > - enum pwm_polarity polarity) > > -{ > > - struct bcm2835_pwm *pc =3D to_bcm2835_pwm(chip); > > - u32 value; > > + /* set polarity */ > > + val =3D readl(pc->base + PWM_CONTROL); > > > > - value =3D readl(pc->base + PWM_CONTROL); > > + if (state->polarity =3D=3D PWM_POLARITY_NORMAL) > > + val &=3D ~(PWM_POLARITY << PWM_CONTROL_SHIFT(pwm->hwpwm)); > > + else > > + val |=3D PWM_POLARITY << PWM_CONTROL_SHIFT(pwm->hwpwm); > > > > - if (polarity =3D=3D PWM_POLARITY_NORMAL) > > - value &=3D ~(PWM_POLARITY << PWM_CONTROL_SHIFT(pwm->hwpwm)); > > + /* enable/disable */ > > + if (state->enabled) > > + val |=3D PWM_ENABLE << PWM_CONTROL_SHIFT(pwm->hwpwm); > > else > > - value |=3D PWM_POLARITY << PWM_CONTROL_SHIFT(pwm->hwpwm); > > + val &=3D ~(PWM_ENABLE << PWM_CONTROL_SHIFT(pwm->hwpwm)); > > > > - writel(value, pc->base + PWM_CONTROL); > > + writel(val, pc->base + PWM_CONTROL); > > > > return 0; > > } > > > > + > > I wouldn't have added this empty line. But I guess that's subjective. Or > did you add this by mistake? I cannot remember that the line was added by intention, so I am fine to re= move it. Thanks and regards, Lino