Message ID | 20230113083115.2590-1-nylon.chen@sifive.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp154210wrt; Fri, 13 Jan 2023 00:37:41 -0800 (PST) X-Google-Smtp-Source: AMrXdXun3H/9xR8/12SsJO4ku1OcxUKrbQiyYeVIRXwmyDf60ee9sjAszBRgi6EfcUdLVPEndyM1 X-Received: by 2002:a05:6a20:d686:b0:b6:5d9f:cd8c with SMTP id it6-20020a056a20d68600b000b65d9fcd8cmr9795136pzb.54.1673599061586; Fri, 13 Jan 2023 00:37:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673599061; cv=none; d=google.com; s=arc-20160816; b=VlRgPnAaOaMBu3q3t6IBvN7oinPeZp0RnSrclhq1Ph4v7kZvgTaEADinxhbK8/R0Zb zW7kc4HWsAlYmCplsfqSvUSTXqO1bfB1JG2IwZDdDjoPr9GFUvZ33pdcjNKKbph3cKjE GMySmQYHjV56C22QK6IhpHUncL/MnvQeSALYtS4A8w5UOZG/5Fk3uAB9VwbZZatGpi2G OpWUrl+28H7StN9X62FuCxC2eIBBGn/HnzGks6Zlt9M/4DxQ3LAB6xQ8c/IQXSOP29vX i0wRuP4UWoptNAVfyzcCYj8CgnqsmWs0VoWNa8BTMj13u1oHOeQ7ON5HPTedJbTmztbX EUpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=kBEmviVcUaQ36DwQBsnDSO4G5pwhdVpJ2oN92m3Dybg=; b=x6kr7SLMsifFfw3IUhqWakQ+B0w46ZsgrQHOBkbqwsyTD07I8mL5v2p4jYMPYq+iCu L8SY1fEWrUPWEaMiocwuM7+JN//wp6hkRdUDONEXPJsUnXp6vM9pASc/MDqAilbLq1jn 2rIZbES6/wW30Cqv/xpe9ec6DeZOIqIFLQTC+vSQcuovi1GvV0zjhdC00CJ4prqyxX1w QNcH8rq30qcxQVxep3hRhm2rRzs18RsTe48doYPzo6J/J2z7D0YpCXsW4mIgXWwfhfZG lchL0/3Uh2TAiaz1+VyMXQz64aq1Ya/Ed+R37izjWU9sn8bx9M4963XfTLldzvBT48t8 W2PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=f7++enNZ; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9-20020a63d809000000b004701a950fe7si20325090pgh.551.2023.01.13.00.37.27; Fri, 13 Jan 2023 00:37:41 -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=f7++enNZ; 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 S231745AbjAMIbn (ORCPT <rfc822;zhuangel570@gmail.com> + 99 others); Fri, 13 Jan 2023 03:31:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232913AbjAMIbV (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 13 Jan 2023 03:31:21 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9ABBD44C78 for <linux-kernel@vger.kernel.org>; Fri, 13 Jan 2023 00:31:20 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id p24so22737254plw.11 for <linux-kernel@vger.kernel.org>; Fri, 13 Jan 2023 00:31:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=kBEmviVcUaQ36DwQBsnDSO4G5pwhdVpJ2oN92m3Dybg=; b=f7++enNZEL4SsuxaJnsnZw81kRX/EsImW+eWHRw7liJ4tZ4GxYfSxv/XoDk7ZDd2Kb FLFdF0z+C+Z9lwX4++CP2JAcT8PiOFISW0WmA2vRyABVYWhCZlyXJLkiGFsQ0PvCSeld ddHgzgygcReJgHYxDbmh0xcqFJ72wGizpuPdhUkCpsqC0SuDJcNt5idS0k9q+CxmBM6w hD4M7U/S+6PopWeq7zmA6sv0KTnREJWg5WYpNCW4CFiw4RsPYYD1bqSxknpqxte95XjR 8dAPEV4bkf4hfBHTA7wxFVh6AqQjwjn22CmxskfGyaT5l8HKtvU1gTfjmBsWPcVRfqP6 aMgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=kBEmviVcUaQ36DwQBsnDSO4G5pwhdVpJ2oN92m3Dybg=; b=LS6yDJOafgyEntzeRU69jVqSZsq4qhzYWECdymo71SSp8zfWFXWSffZt8LTujMXjUy qXiYJtN+durbMGLK8dyBYXcXLyw22c9i0vTzcmrlTGYd2wFvWTv9zoPxUCFwFnbUvQDh GBxxR/ljIyz3baKrgCgzLAiv4mOUpYIlXB30aajt0TKEjTp5DtfOkdYn4+BsPTmH0LmM b/UGU39UjMhyPozU8tgwka1LgDrPrjIFQXxthW2zZ06a8hm//30CUr88a0hjGYA0Clch 3tALTUwyquV3oDklkLx6hnmtRdcqNUVQ2XyiG4QG64Q+edmEjY44W9nNd3lz5Ve+dYxH mq8w== X-Gm-Message-State: AFqh2kpgafXUrQFA+shyJCpA9MjXHlIDJuO+/y+kGVY58whSZPuBRFKV af9msHLbxQvGxjuWRbNMShzn0A== X-Received: by 2002:a17:902:d48a:b0:192:48d1:f06c with SMTP id c10-20020a170902d48a00b0019248d1f06cmr13731785plg.35.1673598680109; Fri, 13 Jan 2023 00:31:20 -0800 (PST) Received: from hsinchu15.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id s7-20020a170902988700b0017f73caf588sm13466123plp.218.2023.01.13.00.31.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jan 2023 00:31:19 -0800 (PST) From: Nylon Chen <nylon.chen@sifive.com> To: paul.walmsley@sifive.com, palmer@dabbelt.com, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: nylon7717@gmail.com, zong.li@sifive.com, greentime.hu@sifive.com, vincent.chen@sifive.com, Nylon Chen <nylon.chen@sifive.com> Subject: [PATCH 0/2] Change PWM-controlled LED pin active mode and algorithm Date: Fri, 13 Jan 2023 16:31:13 +0800 Message-Id: <20230113083115.2590-1-nylon.chen@sifive.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754895809803383989?= X-GMAIL-MSGID: =?utf-8?q?1754895809803383989?= |
Series |
Change PWM-controlled LED pin active mode and algorithm
|
|
Message
Nylon Chen
Jan. 13, 2023, 8:31 a.m. UTC
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 = (D) duty * (T) period[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%20Unmatched/hifive-unmatched-schematics-v3.pdf [1]:https://sifive-china.oss-cn-zhangjiakou.aliyuncs.com/HiFIve%20Unmatched/fu740-c000-manual-v1p2.pdf [2]:https://en.wikipedia.org/wiki/Duty_cycle Nylon Chen (2): riscv: dts: sifive unmatched: Remove PWM controlled LED's active-low properties pwm: sifive: change the PWM controlled LED algorithm arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts | 4 ---- drivers/pwm/pwm-sifive.c | 1 + 2 files changed, 1 insertion(+), 4 deletions(-)
Comments
+CC Uwe, Thierry, linux-pwm Hey Nylon, Please run scripts/get_maintainer.pl before sending patches, you missed both me & the PWM maintainers unfortunately! AFAIK, the PWM maintainers use patchwork, so you will probably have to 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 = (D) duty * (T) period[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%20Unmatched/hifive-unmatched-schematics-v3.pdf > [1]:https://sifive-china.oss-cn-zhangjiakou.aliyuncs.com/HiFIve%20Unmatched/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 and put this information in the dts patch. Possibly into the PWM patch too, 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 explanation 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_jOG2M03aLBgUOgGjWH9CUxq2aTG97eSX70=UaSbGCMMF_g@mail.gmail.com/ That doesn't explain the driver, but it does explain the dts being that way. Perhaps a Fixes tag is also in order? But only if both patches get one, otherwise backporting would lead to breakage. The min() construct appears to have been there since the RFC driver was first posted. Thanks, Conor. > > Nylon Chen (2): > riscv: dts: sifive unmatched: Remove PWM controlled LED's active-low nit: s/sifive unmatched:/sifive: unmatched:/ > properties > pwm: sifive: change the PWM controlled LED algorithm > > arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts | 4 ---- > drivers/pwm/pwm-sifive.c | 1 + > 2 files changed, 1 insertion(+), 4 deletions(-) > > -- > 2.36.1 > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv
On 13 Jan 2023, at 18:32, Conor Dooley <conor@kernel.org> wrote: > > +CC Uwe, Thierry, linux-pwm > > Hey Nylon, > > Please run scripts/get_maintainer.pl before sending patches, you missed > both me & the PWM maintainers unfortunately! > AFAIK, the PWM maintainers use patchwork, so you will probably have to > 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 = (D) duty * (T) period[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%20Unmatched/hifive-unmatched-schematics-v3.pdf >> [1]:https://sifive-china.oss-cn-zhangjiakou.aliyuncs.com/HiFIve%20Unmatched/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 and > put this information in the dts patch. Possibly into the PWM patch too, > 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 explanation > 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_jOG2M03aLBgUOgGjWH9CUxq2aTG97eSX70=UaSbGCMMF_g@mail.gmail.com/ That DTS documentation makes no sense to me, why does what the LED is wired to matter? Whether you have your transistor next to ground or next to Vdd doesn’t matter, what matters is whether the transistor 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’s written assuming the LED is wired directly to the PWM, in which case it would make sense, but that’s a very narrow-minded view of what the PWM output is (directly) driving. Jess > That doesn't explain the driver, but it does explain the dts being that > way. Perhaps a Fixes tag is also in order? But only if both patches get > one, otherwise backporting would lead to breakage. > > The min() construct appears to have been there since the RFC driver was > first posted. > > Thanks, > Conor. > >> >> Nylon Chen (2): >> riscv: dts: sifive unmatched: Remove PWM controlled LED's active-low > > nit: s/sifive unmatched:/sifive: unmatched:/ > >> properties >> pwm: sifive: change the PWM controlled LED algorithm >> >> arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts | 4 ---- >> drivers/pwm/pwm-sifive.c | 1 + >> 2 files changed, 1 insertion(+), 4 deletions(-) >> >> -- >> 2.36.1 >> >> >> _______________________________________________ >> linux-riscv mailing list >> linux-riscv@lists.infradead.org >> http://lists.infradead.org/mailman/listinfo/linux-riscv > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv
Hi Jess! On Fri, Jan 13, 2023 at 07:24:56PM +0000, Jessica Clarke wrote: > On 13 Jan 2023, at 18:32, Conor Dooley <conor@kernel.org> wrote: > > > > Please run scripts/get_maintainer.pl before sending patches, you missed > > both me & the PWM maintainers unfortunately! > > AFAIK, the PWM maintainers use patchwork, so you will probably have to > > 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 = (D) duty * (T) period[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%20Unmatched/hifive-unmatched-schematics-v3.pdf > >> [1]:https://sifive-china.oss-cn-zhangjiakou.aliyuncs.com/HiFIve%20Unmatched/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 and > > put this information in the dts patch. Possibly into the PWM patch too, > > 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 explanation > > 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_jOG2M03aLBgUOgGjWH9CUxq2aTG97eSX70=UaSbGCMMF_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’t matter, what matters is whether the transistor 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’s written assuming the LED is wired directly to the PWM, in > which case it would make sense, but that’s 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. 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."?
Hi Conor, Jessica thanks for your reply. Jessica Clarke <jrtc27@jrtc27.com> 於 2023年1月14日 週六 上午3:24寫道: > > On 13 Jan 2023, at 18:32, Conor Dooley <conor@kernel.org> wrote: > > > > +CC Uwe, Thierry, linux-pwm > > > > Hey Nylon, > > > > Please run scripts/get_maintainer.pl before sending patches, you missed > > both me & the PWM maintainers unfortunately! > > AFAIK, the PWM maintainers use patchwork, so you will probably have to > > resend this patchset so that it is on their radar. > > I've marked the series as "Changes Requested" on the RISC-V one. I got it. I will base it on get_maintainer.pl, re-sent it. > > > > 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 = (D) duty * (T) period[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%20Unmatched/hifive-unmatched-schematics-v3.pdf > >> [1]:https://sifive-china.oss-cn-zhangjiakou.aliyuncs.com/HiFIve%20Unmatched/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 and > > put this information in the dts patch. Possibly into the PWM patch too, > > depending on what the PWM maintainers think. I got it. I will fix it. > > 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 explanation > > 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_jOG2M03aLBgUOgGjWH9CUxq2aTG97eSX70=UaSbGCMMF_g@mail.gmail.com/ > > That DTS documentation makes no sense to me, why does what the LED is > wired to matter? Whether you have your transistor next to ground or > next to Vdd doesn’t matter, what matters is whether the transistor 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’s written assuming the LED is wired directly to the PWM, in > which case it would make sense, but that’s a very narrow-minded view of > what the PWM output is (directly) driving. > > Jess > This is a HiFive Unmatched/Unleashed LED-PWM layout VDD | | _____ \ / LED \ / --- | | | ______ | | - | ^ --> |------ PWM |___|___| | | __ - GND - the waveform e.g. duty=30s, period=100s, actvie-high = 30%, active-low = 70% V ^ | | ----------| | | | | |______ |__________ > t When VCC is high, the LED will be illuminated, which is an active-high logic. This is why we need to remove "active-low". So, according to my understanding, Unleashed's DTS should also remove active-low. > > That doesn't explain the driver, but it does explain the dts being that > > way. Perhaps a Fixes tag is also in order? But only if both patches get > > one, otherwise backporting would lead to breakage. > > > > The min() construct appears to have been there since the RFC driver was > > first posted. > > > > Thanks, > > Conor. > > > >> > >> Nylon Chen (2): > >> riscv: dts: sifive unmatched: Remove PWM controlled LED's active-low > > > > nit: s/sifive unmatched:/sifive: unmatched:/ I got it. I will fix it. > > > >> properties > >> pwm: sifive: change the PWM controlled LED algorithm > >> > >> arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts | 4 ---- > >> drivers/pwm/pwm-sifive.c | 1 + > >> 2 files changed, 1 insertion(+), 4 deletions(-) > >> > >> -- > >> 2.36.1 > >> > >> > >> _______________________________________________ > >> linux-riscv mailing list > >> linux-riscv@lists.infradead.org > >> http://lists.infradead.org/mailman/listinfo/linux-riscv > > _______________________________________________ > > linux-riscv mailing list > > linux-riscv@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/linux-riscv >
On 1/17/23 1:32 AM, Nylon Chen wrote: > Hi Conor, Jessica > > thanks for your reply. > > Jessica Clarke <jrtc27@jrtc27.com> 於 2023年1月14日 週六 上午3:24寫道: >> On 13 Jan 2023, at 18:32, Conor Dooley <conor@kernel.org> wrote: >>> +CC Uwe, Thierry, linux-pwm >>> >>> Hey Nylon, >>> >>> Please run scripts/get_maintainer.pl before sending patches, you missed >>> both me & the PWM maintainers unfortunately! >>> AFAIK, the PWM maintainers use patchwork, so you will probably have to >>> resend this patchset so that it is on their radar. >>> I've marked the series as "Changes Requested" on the RISC-V one. > I got it. I will base it on get_maintainer.pl, re-sent it. >>> 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 = (D) duty * (T) period[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%20Unmatched/hifive-unmatched-schematics-v3.pdf >>>> [1]:https://sifive-china.oss-cn-zhangjiakou.aliyuncs.com/HiFIve%20Unmatched/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 and >>> put this information in the dts patch. Possibly into the PWM patch too, >>> depending on what the PWM maintainers think. > I got it. I will fix it. >>> 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 explanation >>> 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_jOG2M03aLBgUOgGjWH9CUxq2aTG97eSX70=UaSbGCMMF_g@mail.gmail.com/ >> That DTS documentation makes no sense to me, why does what the LED is >> wired to matter? Whether you have your transistor next to ground or >> next to Vdd doesn’t matter, what matters is whether the transistor 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’s written assuming the LED is wired directly to the PWM, in >> which case it would make sense, but that’s a very narrow-minded view of >> what the PWM output is (directly) driving. >> >> Jess >> > This is a HiFive Unmatched/Unleashed LED-PWM layout > > VDD > | > | > _____ > \ / LED > \ / > --- > | > | > | > ______ > | | > - | > ^ --> |------ PWM > |___|___| > | > | > __ > - > GND > > - the waveform > e.g. duty=30s, period=100s, actvie-high = 30%, active-low = 70% > > V > ^ > | > | ----------| > | | > | | > |______ |__________ > t > > When VCC is high, the LED will be illuminated, which is an active-high > logic. This is why we need to remove "active-low". > > So, according to my understanding, Unleashed's DTS should also remove > active-low. >>> That doesn't explain the driver, but it does explain the dts being that >>> way. Perhaps a Fixes tag is also in order? But only if both patches get >>> one, otherwise backporting would lead to breakage. >>> >>> The min() construct appears to have been there since the RFC driver was >>> first posted. >>> >>> Thanks, >>> Conor. >>> >>>> Nylon Chen (2): >>>> riscv: dts: sifive unmatched: Remove PWM controlled LED's active-low >>> nit: s/sifive unmatched:/sifive: unmatched:/ > I got it. I will fix it. > >>>> properties >>>> pwm: sifive: change the PWM controlled LED algorithm >>>> >>>> arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts | 4 ---- >>>> drivers/pwm/pwm-sifive.c | 1 + >>>> 2 files changed, 1 insertion(+), 4 deletions(-) >>>> >>>> -- >>>> 2.36.1 I've tested this patch. For some reason, the heartbeat function no longer works for D12. This is my /etc/udev/rules.d/99-pwm-leds.rules file contents: # D12 LED: heartbeat SUBSYSTEM=="leds", KERNEL=="d12", ACTION=="add", ATTR{trigger}="heartbeat" # D2 RGB LED: boot status SUBSYSTEM=="leds", KERNEL=="d2", ACTION=="add", ATTR{trigger}="default-on", ATTR{multi_intensity}="25 25 25" This is from https://github.com/sifive/meta-sifive, but modified for the multi_intensity driver introduced in Linux 6.0.
On 1/17/23 7:08 AM, Ron Economos wrote: > On 1/17/23 1:32 AM, Nylon Chen wrote: >> Hi Conor, Jessica >> >> thanks for your reply. >> >> Jessica Clarke <jrtc27@jrtc27.com> 於 2023年1月14日 週六 上午3:24寫道: >>> On 13 Jan 2023, at 18:32, Conor Dooley <conor@kernel.org> wrote: >>>> +CC Uwe, Thierry, linux-pwm >>>> >>>> Hey Nylon, >>>> >>>> Please run scripts/get_maintainer.pl before sending patches, you >>>> missed >>>> both me & the PWM maintainers unfortunately! >>>> AFAIK, the PWM maintainers use patchwork, so you will probably have to >>>> resend this patchset so that it is on their radar. >>>> I've marked the series as "Changes Requested" on the RISC-V one. >> I got it. I will base it on get_maintainer.pl, re-sent it. >>>> 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 = (D) duty * (T) >>>>> period[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%20Unmatched/hifive-unmatched-schematics-v3.pdf >>>>> >>>>> [1]:https://sifive-china.oss-cn-zhangjiakou.aliyuncs.com/HiFIve%20Unmatched/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 and >>>> put this information in the dts patch. Possibly into the PWM patch >>>> too, >>>> depending on what the PWM maintainers think. >> I got it. I will fix it. >>>> 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 >>>> explanation >>>> 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_jOG2M03aLBgUOgGjWH9CUxq2aTG97eSX70=UaSbGCMMF_g@mail.gmail.com/ >>>> >>> That DTS documentation makes no sense to me, why does what the LED is >>> wired to matter? Whether you have your transistor next to ground or >>> next to Vdd doesn’t matter, what matters is whether the transistor 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’s written assuming the LED is wired directly to the PWM, in >>> which case it would make sense, but that’s a very narrow-minded view of >>> what the PWM output is (directly) driving. >>> >>> Jess >>> >> This is a HiFive Unmatched/Unleashed LED-PWM layout >> >> VDD >> | >> | >> _____ >> \ / LED >> \ / >> --- >> | >> | >> | >> ______ >> | | >> - | >> ^ --> |------ PWM >> |___|___| >> | >> | >> __ >> - >> GND >> >> - the waveform >> e.g. duty=30s, period=100s, actvie-high = 30%, active-low = 70% >> >> V >> ^ >> | >> | ----------| >> | | >> | | >> |______ |__________ > t >> >> When VCC is high, the LED will be illuminated, which is an active-high >> logic. This is why we need to remove "active-low". >> >> So, according to my understanding, Unleashed's DTS should also remove >> active-low. >>>> That doesn't explain the driver, but it does explain the dts being >>>> that >>>> way. Perhaps a Fixes tag is also in order? But only if both patches >>>> get >>>> one, otherwise backporting would lead to breakage. >>>> >>>> The min() construct appears to have been there since the RFC driver >>>> was >>>> first posted. >>>> >>>> Thanks, >>>> Conor. >>>> >>>>> Nylon Chen (2): >>>>> riscv: dts: sifive unmatched: Remove PWM controlled LED's >>>>> active-low >>>> nit: s/sifive unmatched:/sifive: unmatched:/ >> I got it. I will fix it. >> >>>>> properties >>>>> pwm: sifive: change the PWM controlled LED algorithm >>>>> >>>>> arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts | 4 ---- >>>>> drivers/pwm/pwm-sifive.c | 1 + >>>>> 2 files changed, 1 insertion(+), 4 deletions(-) >>>>> >>>>> -- >>>>> 2.36.1 > > I've tested this patch. For some reason, the heartbeat function no > longer works for D12. This is my /etc/udev/rules.d/99-pwm-leds.rules > file contents: > > # D12 LED: heartbeat > SUBSYSTEM=="leds", KERNEL=="d12", ACTION=="add", > ATTR{trigger}="heartbeat" > > # D2 RGB LED: boot status > SUBSYSTEM=="leds", KERNEL=="d2", ACTION=="add", > ATTR{trigger}="default-on", ATTR{multi_intensity}="25 25 25" > > This is from https://github.com/sifive/meta-sifive, but modified for > the multi_intensity driver introduced in Linux 6.0. > I've instrumented this patch with some printks. The reason the heartbeat doesn't work is that setting the LEDs to maximum brightness causes the variable "frac" to be set to -1 instead of 0. You can test it with: # /bin/echo "255" > /sys/class/leds/d12/brightness
Hi Jess, as you said, I use LED directly connected to PWM logic to modify it. As I stated in my previous article, the key is that the lower the PWM output is, the brighter the LED light is(active-low), the higher the PWM output is, the brighter the LED light is(active-high). Therefore, I would point out the waveform diagram below, the output result remains the same for the circuit, but when you use active-low/active-high to look at it, you will get two completely different results of brightness. e.g. duty=30s, period=100s, actvie-high = 30%, active-low = 70% V ^ | | ----------| | | | | |______ |__________ > t Jessica Clarke <jrtc27@jrtc27.com> 於 2023年1月14日 週六 上午3:24寫道: > > On 13 Jan 2023, at 18:32, Conor Dooley <conor@kernel.org> wrote: > > > > +CC Uwe, Thierry, linux-pwm > > > > Hey Nylon, > > > > Please run scripts/get_maintainer.pl before sending patches, you missed > > both me & the PWM maintainers unfortunately! > > AFAIK, the PWM maintainers use patchwork, so you will probably have to > > 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 = (D) duty * (T) period[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%20Unmatched/hifive-unmatched-schematics-v3.pdf > >> [1]:https://sifive-china.oss-cn-zhangjiakou.aliyuncs.com/HiFIve%20Unmatched/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 and > > put this information in the dts patch. Possibly into the PWM patch too, > > 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 explanation > > 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_jOG2M03aLBgUOgGjWH9CUxq2aTG97eSX70=UaSbGCMMF_g@mail.gmail.com/ > > That DTS documentation makes no sense to me, why does what the LED is > wired to matter? Whether you have your transistor next to ground or > next to Vdd doesn’t matter, what matters is whether the transistor 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’s written assuming the LED is wired directly to the PWM, in > which case it would make sense, but that’s a very narrow-minded view of > what the PWM output is (directly) driving. > > Jess > > > That doesn't explain the driver, but it does explain the dts being that > > way. Perhaps a Fixes tag is also in order? But only if both patches get > > one, otherwise backporting would lead to breakage. > > > > The min() construct appears to have been there since the RFC driver was > > first posted. > > > > Thanks, > > Conor. > > > >> > >> Nylon Chen (2): > >> riscv: dts: sifive unmatched: Remove PWM controlled LED's active-low > > > > nit: s/sifive unmatched:/sifive: unmatched:/ > > > >> properties > >> pwm: sifive: change the PWM controlled LED algorithm > >> > >> arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts | 4 ---- > >> drivers/pwm/pwm-sifive.c | 1 + > >> 2 files changed, 1 insertion(+), 4 deletions(-) > >> > >> -- > >> 2.36.1 > >> > >> > >> _______________________________________________ > >> linux-riscv mailing list > >> linux-riscv@lists.infradead.org > >> http://lists.infradead.org/mailman/listinfo/linux-riscv > > _______________________________________________ > > linux-riscv mailing list > > linux-riscv@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/linux-riscv >
Conor Dooley <conor@kernel.org> 於 2023年1月14日 週六 下午10:00寫道: > > Hi Jess! > > On Fri, Jan 13, 2023 at 07:24:56PM +0000, Jessica Clarke wrote: > > On 13 Jan 2023, at 18:32, Conor Dooley <conor@kernel.org> wrote: > > > > > > > Please run scripts/get_maintainer.pl before sending patches, you missed > > > both me & the PWM maintainers unfortunately! > > > AFAIK, the PWM maintainers use patchwork, so you will probably have to > > > 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 = (D) duty * (T) period[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%20Unmatched/hifive-unmatched-schematics-v3.pdf > > >> [1]:https://sifive-china.oss-cn-zhangjiakou.aliyuncs.com/HiFIve%20Unmatched/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 and > > > put this information in the dts patch. Possibly into the PWM patch too, > > > 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 explanation > > > 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_jOG2M03aLBgUOgGjWH9CUxq2aTG97eSX70=UaSbGCMMF_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’t matter, what matters is whether the transistor 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’s written assuming the LED is wired directly to the PWM, in > > which case it would make sense, but that’s 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 diagram. > 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."? >
On 1/17/23 5:46 PM, Ron Economos wrote: > On 1/17/23 7:08 AM, Ron Economos wrote: >> On 1/17/23 1:32 AM, Nylon Chen wrote: >>> Hi Conor, Jessica >>> >>> thanks for your reply. >>> >>> Jessica Clarke <jrtc27@jrtc27.com> 於 2023年1月14日 週六 上午3:24寫道: >>>> On 13 Jan 2023, at 18:32, Conor Dooley <conor@kernel.org> wrote: >>>>> +CC Uwe, Thierry, linux-pwm >>>>> >>>>> Hey Nylon, >>>>> >>>>> Please run scripts/get_maintainer.pl before sending patches, you >>>>> missed >>>>> both me & the PWM maintainers unfortunately! >>>>> AFAIK, the PWM maintainers use patchwork, so you will probably >>>>> have to >>>>> resend this patchset so that it is on their radar. >>>>> I've marked the series as "Changes Requested" on the RISC-V one. >>> I got it. I will base it on get_maintainer.pl, re-sent it. >>>>> 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 = (D) duty * (T) >>>>>> period[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%20Unmatched/hifive-unmatched-schematics-v3.pdf >>>>>> >>>>>> [1]:https://sifive-china.oss-cn-zhangjiakou.aliyuncs.com/HiFIve%20Unmatched/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 >>>>> and >>>>> put this information in the dts patch. Possibly into the PWM patch >>>>> too, >>>>> depending on what the PWM maintainers think. >>> I got it. I will fix it. >>>>> 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 >>>>> explanation >>>>> 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_jOG2M03aLBgUOgGjWH9CUxq2aTG97eSX70=UaSbGCMMF_g@mail.gmail.com/ >>>>> >>>> That DTS documentation makes no sense to me, why does what the LED is >>>> wired to matter? Whether you have your transistor next to ground or >>>> next to Vdd doesn’t matter, what matters is whether the transistor 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’s written assuming the LED is wired directly to the >>>> PWM, in >>>> which case it would make sense, but that’s a very narrow-minded >>>> view of >>>> what the PWM output is (directly) driving. >>>> >>>> Jess >>>> >>> This is a HiFive Unmatched/Unleashed LED-PWM layout >>> >>> VDD >>> | >>> | >>> _____ >>> \ / LED >>> \ / >>> --- >>> | >>> | >>> | >>> ______ >>> | | >>> - | >>> ^ --> |------ PWM >>> |___|___| >>> | >>> | >>> __ >>> - >>> GND >>> >>> - the waveform >>> e.g. duty=30s, period=100s, actvie-high = 30%, active-low = 70% >>> >>> V >>> ^ >>> | >>> | ----------| >>> | | >>> | | >>> |______ |__________ > t >>> >>> When VCC is high, the LED will be illuminated, which is an active-high >>> logic. This is why we need to remove "active-low". >>> >>> So, according to my understanding, Unleashed's DTS should also remove >>> active-low. >>>>> That doesn't explain the driver, but it does explain the dts being >>>>> that >>>>> way. Perhaps a Fixes tag is also in order? But only if both >>>>> patches get >>>>> one, otherwise backporting would lead to breakage. >>>>> >>>>> The min() construct appears to have been there since the RFC >>>>> driver was >>>>> first posted. >>>>> >>>>> Thanks, >>>>> Conor. >>>>> >>>>>> Nylon Chen (2): >>>>>> riscv: dts: sifive unmatched: Remove PWM controlled LED's >>>>>> active-low >>>>> nit: s/sifive unmatched:/sifive: unmatched:/ >>> I got it. I will fix it. >>> >>>>>> properties >>>>>> pwm: sifive: change the PWM controlled LED algorithm >>>>>> >>>>>> arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts | 4 ---- >>>>>> drivers/pwm/pwm-sifive.c | 1 + >>>>>> 2 files changed, 1 insertion(+), 4 deletions(-) >>>>>> >>>>>> -- >>>>>> 2.36.1 >> >> I've tested this patch. For some reason, the heartbeat function no >> longer works for D12. This is my /etc/udev/rules.d/99-pwm-leds.rules >> file contents: >> >> # D12 LED: heartbeat >> SUBSYSTEM=="leds", KERNEL=="d12", ACTION=="add", >> ATTR{trigger}="heartbeat" >> >> # D2 RGB LED: boot status >> SUBSYSTEM=="leds", KERNEL=="d2", ACTION=="add", >> ATTR{trigger}="default-on", ATTR{multi_intensity}="25 25 25" >> >> This is from https://github.com/sifive/meta-sifive, but modified for >> the multi_intensity driver introduced in Linux 6.0. >> > I've instrumented this patch with some printks. The reason the > heartbeat doesn't work is that setting the LEDs to maximum brightness > causes the variable "frac" to be set to -1 instead of 0. > > You can test it with: > > # /bin/echo "255" > /sys/class/leds/d12/brightness > Sorry for the noise, I didn't apply the patch correctly. It works fine.
Hey Nylon, On Wed, Jan 18, 2023 at 10:32:25AM +0800, Nylon Chen wrote: > Conor Dooley <conor@kernel.org> 於 2023年1月14日 週六 下午10:00寫道: > > On Fri, Jan 13, 2023 at 07:24:56PM +0000, Jessica Clarke wrote: > > > On 13 Jan 2023, at 18:32, Conor Dooley <conor@kernel.org> wrote: > > > > Please delete link 2, convert the other two to standard Link: tags and > > > > put this information in the dts patch. Possibly into the PWM patch too, > > > > 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 explanation > > > > 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_jOG2M03aLBgUOgGjWH9CUxq2aTG97eSX70=UaSbGCMMF_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’t matter, what matters is whether the transistor 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’s written assuming the LED is wired directly to the PWM, in > > > which case it would make sense, but that’s 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. > 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 diagram. I am loathe to speak for Jess, but I don't think either of us are disagreeing with your patches. I was just trying to understand why it was wrong in the first place to see if it was intentionally inverted, or if there was something that could be improve to stop it happening again. Apologies if that got lost in translation. > > 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."? Thanks, Conor.