Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp5771200rwb; Tue, 17 Jan 2023 18:54:51 -0800 (PST) X-Google-Smtp-Source: AMrXdXslFyHraB8pzd0N+62J7TE9btzDsZW0k+OuzqLEc7UjcOGuRH5AP40pUalDJqX3+WT3/nei X-Received: by 2002:a17:906:5da8:b0:7b2:c227:126d with SMTP id n8-20020a1709065da800b007b2c227126dmr1461189ejv.20.1674010491571; Tue, 17 Jan 2023 18:54:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674010491; cv=none; d=google.com; s=arc-20160816; b=PttUOOMwcjtxqSTzpXcIdb+fW0nfk81hydJvPDhcsgxUDry9Gh4tzbOwbfzwDn+N6f TWBBtsGLhpPwKDNLRC+/lr+zaTt1UzByd0m6rNWIUWhgIPaB978hODqDuA6DG/SvEeVq uZxXPKLZ53dEqT2UMWN35tfGPTJ+V77eEvdob3TaG7L9OGQKVLDS9eCymMUz3sflwZ53 SXPp8AxLmWYw6TycCJT/TvtWz0bdSJELGLuGlScK2bavX8cH7Uvg95QYAM+5RcnRA25K 9EqQT8nU7fyxeee1QJDJHv1Tvm8AdJLkyWvNda6WF2m8VObJ806CPtEEMpGebA3snXg3 Hnww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=qhVRdi04ykAfBKvh2XosikgPFb7sAZbc1JGthKJqlS4=; b=x3kuoGkyhx+SbAImJVFEoLSVn9ipawtowKes3pO1CK+DsIrvJOrAnGgRlrL/Ts8dia jwbB0QPN85pqBSmsoGlpOBJFWj1YWw1JZbAuhB/1Z8uelGdbrjgaWKUbXPTQ+5T625XN ftuygPF69hpWi8NhAdfsQTwWzGynPIXQ0hA6qeHmlgAmWJr5TcUMEHDuWpLRQ3zVKjyz NXMXdQX+sizeH7NtgN2MGO/L2KXBgxhq8yn/p0WHkiBvlqZ5E+RQiTOBstxanfWux6Pq EeOOuP89vSEZUMJmiMrKpvmNcLmDBrFvcVD8lxnRU3ra3zegn7k3CKeVIv5R6QMumjlC NUpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b="Xsfz/HHB"; 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 sb33-20020a1709076da100b0086ea1c7ae21si12772375ejc.54.2023.01.17.18.54.40; Tue, 17 Jan 2023 18:54:51 -0800 (PST) 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; dkim=pass header.i=@sifive.com header.s=google header.b="Xsfz/HHB"; 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 S229585AbjARCcp (ORCPT + 46 others); Tue, 17 Jan 2023 21:32:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229511AbjARCcj (ORCPT ); Tue, 17 Jan 2023 21:32:39 -0500 Received: from mail-yw1-x112e.google.com (mail-yw1-x112e.google.com [IPv6:2607:f8b0:4864:20::112e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0185A4FAF5 for ; Tue, 17 Jan 2023 18:32:38 -0800 (PST) Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-4d0f843c417so336161297b3.7 for ; Tue, 17 Jan 2023 18:32:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=qhVRdi04ykAfBKvh2XosikgPFb7sAZbc1JGthKJqlS4=; b=Xsfz/HHBDO/vDBykab7FsTxQ82hjIhSdfx0E/zL+3YXYxMdPCwksOi8E1/nqlOb7v4 Y/y+0A4dmitkt2zcYOuAEuIwjfYP8CbQYLo7znzidRpFEUpMm9nc1FTkj7YN0GBfizPH 1AZ35hc9Abk2cT75pqRwbuBN50r7mYOrOgv51wT91c4vqJyxqnfOP8NjTroHhwjHt0bT QAwFtUqOtRPOv4sTrZE4IZlZ0GRLGCRQkuG8+HkitDgNLIC7O9kk4MWtFqGIyn5Kv3NO 2i17tWm5g4dJh3IxoksPy8Uw7xjpkAzAoO/32zkSPqKV0556sLX4hP3P9O+C4mw6VLXV B7hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qhVRdi04ykAfBKvh2XosikgPFb7sAZbc1JGthKJqlS4=; b=aSKl1/4L6AacQlUM/c6GRg25iRnHCDGGjQHazRagEvX0g1M2tzLwfNgz7NWPjeyaww j+MrIzrJBaJg6g4kTiMONIL5Kh1n4WpkTW9Dkrb/BBgkHm9y0qtAqMv/EBPit3gmego0 h/JLAhCD4+wrq8Kl/Bp5wETd5kK8a1mR9isGaslRulUSUkbB0akFb8NggIUleZQ9BV+G 4I/fR1ULP6pWOuBU/6F0X+i8Dhpwo0rar1k5HOee2kzELjhbp+lIwIIg0i1wkg9VN7qE qVwrjj0Pix9TgFWtwE3kYuwM1Z1dfsxL1aXLHWcuBLy52NIPJnKEl5AnESTfjs/9V5jp CUpQ== X-Gm-Message-State: AFqh2kqxOvn34ttc8/pRnSAD94MZHyHWcDDE6Qwv9gAcjq6C3LlFLRiS cFeu48R7xd4bqIurBbBWu80625NZ3XRAusKifz3UHVOJqjaUF8g0MS8= X-Received: by 2002:a81:5246:0:b0:3d0:c950:c581 with SMTP id g67-20020a815246000000b003d0c950c581mr505917ywb.304.1674009157129; Tue, 17 Jan 2023 18:32:37 -0800 (PST) MIME-Version: 1.0 References: <20230113083115.2590-1-nylon.chen@sifive.com> <95F1EAA0-D8D6-4F8A-8049-5E7BFDE4C06C@jrtc27.com> In-Reply-To: From: Nylon Chen Date: Wed, 18 Jan 2023 10:32:25 +0800 Message-ID: Subject: Re: [PATCH 0/2] Change PWM-controlled LED pin active mode and algorithm To: Conor Dooley Cc: Jessica Clarke , Paul Walmsley , Palmer Dabbelt , Linux Kernel Mailing List , linux-riscv , nylon7717@gmail.com, zong.li@sifive.com, greentime.hu@sifive.com, vincent.chen@sifive.com, Thierry Reding , =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= , linux-pwm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Conor Dooley =E6=96=BC 2023=E5=B9=B41=E6=9C=8814=E6=97= =A5 =E9=80=B1=E5=85=AD =E4=B8=8B=E5=8D=8810:00=E5=AF=AB=E9=81=93=EF=BC=9A > > Hi Jess! > > On Fri, Jan 13, 2023 at 07:24:56PM +0000, Jessica Clarke wrote: > > On 13 Jan 2023, at 18:32, Conor Dooley wrote: > > > > > > > Please run scripts/get_maintainer.pl before sending patches, you miss= ed > > > both me & the PWM maintainers unfortunately! > > > AFAIK, the PWM maintainers use patchwork, so you will probably have t= o > > > resend this patchset so that it is on their radar. > > > I've marked the series as "Changes Requested" on the RISC-V one. > > > > > > On Fri, Jan 13, 2023 at 04:31:13PM +0800, Nylon Chen wrote: > > > > > >> According to the circuit diagram of User LEDs - RGB described in the > > >> manual hifive-unmatched-schematics-v3.pdf[0]. > > >> The behavior of PWM is acitve-high. > > >> > > >> According to the descriptionof PWM for pwmcmp in SiFive FU740-C000 > > >> Manual[1]. > > >> The pwm algorithm is (PW) pulse active time =3D (D) duty * (T) peri= od[2]. > > >> The `frac` variable is pulse "inactive" time so we need to invert it= . > > >> > > >> So this patchset removes active-low in DTS and adds reverse logic to > > >> the driver. > > >> > > >> [0]:https://sifive-china.oss-cn-zhangjiakou.aliyuncs.com/HiFIve%20Un= matched/hifive-unmatched-schematics-v3.pdf > > >> [1]:https://sifive-china.oss-cn-zhangjiakou.aliyuncs.com/HiFIve%20Un= matched/fu740-c000-manual-v1p2.pdf > > >> [2]:https://en.wikipedia.org/wiki/Duty_cycle > > > > > > Please delete link 2, convert the other two to standard Link: tags an= d > > > put this information in the dts patch. Possibly into the PWM patch to= o, > > > depending on what the PWM maintainers think. > > > This info should be in the commit history IMO and the commit message = for > > > the dts patch says what's obvious from the diff without any explanati= on > > > as to why. > > > > > > I did a bit of looking around on lore, to see if I could figure out > > > why it was done like this in the first place, and I found: > > > https://lore.kernel.org/linux-pwm/CAJ2_jOG2M03aLBgUOgGjWH9CUxq2aTG97e= SX70=3DUaSbGCMMF_g@mail.gmail.com/ > > > > That DTS documentation makes no sense to me, why does what the LED is > > wired to matter? > > ``` > active-low: > description: > For PWMs where the LED is wired to supply rather than ground. > ``` > > > Whether you have your transistor next to ground or > > next to Vdd doesn=E2=80=99t matter, what matters is whether the transis= tor is > > on or off. Maybe what they mean is whether the *PWM's output* / *the > > transistor's input* is pulled to ground or Vdd? In which case the > > property would indeed not apply here. > > > > Unless that=E2=80=99s written assuming the LED is wired directly to the= PWM, in > > which case it would make sense, but that=E2=80=99s a very narrow-minded= view of > > what the PWM output is (directly) driving. > > I would suspect that it was written with that assumption. > Probably was the case on the specific board this property was originally > added for. > Hi Conor As you can see, there is also the same description in U-Boot. But in U-Boot, the DTS of Unmatched/Unleashed has not been added active-low= . This is because active-high should be correct if we look at the circuit dia= gram. > Maybe it'd be a bit more foolproof written as "For LEDs that are > illuminated while the PWM output is low. For example, where an LED is > wired between supply and the PWM output."? >