From patchwork Thu Feb 22 08:12:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nylon Chen X-Patchwork-Id: 204601 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp102738dyb; Thu, 22 Feb 2024 00:14:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCViECTEJ9S7c93ZaKQNcZBXm67JQ+ovPcyX2vxXCjuTwXffdyOMuZslOxZh11/kctdcXYU+qSmAU2SU/Ir2a6OV4PQRBQ== X-Google-Smtp-Source: AGHT+IGhRwiHmvhLTZ8i9n0Ze8eBzfzwaKX2xR99f8x9GS1JrOAPTyHRrVOpmp/HE6rivgrKttaS X-Received: by 2002:a05:6a21:8ccc:b0:19c:881d:78e6 with SMTP id ta12-20020a056a218ccc00b0019c881d78e6mr21135225pzb.42.1708589646597; Thu, 22 Feb 2024 00:14:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708589646; cv=pass; d=google.com; s=arc-20160816; b=DO7vW4r84nQ3bZ+2xQHih+4ss+5PbQ7rXlqNLi3ghAZwe34Lm4Ecm+v0rhy+IWQ8yY UbBTHHkEDSxsRpDA3iiljwcm6gv7dNe6XbBTdYzzrhAQZcmxCYZINjJQd5cEe8doXCZU E57h1mG2xssYXw7Fksc4+JrIIPhiIbexY9xKooJia0C95AukPG+gAgJcyKqXbSSWM4Sn QwA+rexgrlawsKddJbstLfk2CiIhMJ7prZG8nw086v1JyoTYJDS8xylnf8ce87hK0Oyf JU/4Dwedz7GuAkurmZOGV4Cerl3SE+TYgva720SmjG51qQtQX4NPWH+9Il9ECPSNdG+0 g2XQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=71zlVIznaIfi5FluR/+lVnei3BjKa6CskewcKRtvea4=; fh=RzXubTuI29kDtj8Scwwk8DuMGAS6x7kfehxUY8xGnZY=; b=wDXmUHjd15VvbUIdRebhYyFwNJNP5qHcUh/hHXGUFfxLc17XO6vJYZXiy8Kqii/o1W 5CsXWWMaIdlmjZ4UMKAIfQa3lxRhNj4dlvvjf/nam3FZuDCGYcfto7ME8Eco6b/XVIR8 2nnuLPX6kwCBDUbWXmQlGuIcsjjZi9bPhhFKktAGM+hf2p0EG/2UdE1/TlOqIsbiveVV gwVUWv2P+iYERGJzQ04B+13jreWF9l+qTKesC1JKjbSWDx/5XSJqGnEJv/e8fs9STUzB 5GHbP1HaJ1tnBCKNc3QyMqO8ep4SJmdaZCjpYDqT0PmLkZYTcZt6yWhQsnzERRvgq1sB LsZg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=LAW1J9Cy; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-76070-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76070-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id sc2-20020a17090b510200b002992d6c5331si10108954pjb.92.2024.02.22.00.14.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 00:14:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76070-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=LAW1J9Cy; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-76070-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76070-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 67D1D28310F for ; Thu, 22 Feb 2024 08:14:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D2749199C7; Thu, 22 Feb 2024 08:13:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="LAW1J9Cy" Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4785918E1C for ; Thu, 22 Feb 2024 08:12:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708589583; cv=none; b=amS+4mCxGkusidKnQsNQWQlUisQ1fWTjwhQCMEl/EXZew457RBWBlS053XBs2yn8MMSguqyC5Kn1Rsm/qRW3OSynwlrEbDoP5QvcXU1/G6JUXM5UUS7QQ+bYROAGbkLBtPxPpuE/aalBXTHm0JfP66U2poTrw6MFJI1Z7tFjR0Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708589583; c=relaxed/simple; bh=lACIWIIe6I6XBgEs4axVETypjgF0xMo4A+BUz4dsSHE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uQSjyrI0Uv/7gMqtFOMaw3QHZX9aTJmrNhsnlQM+oyn8u101XB/2OcAuNWqGEZw37Cc2XGABwN1DF1C6nQz3RnLvQgifquhwx2TeblrzSIS0Vnc9XE+ySSGgPvueAb56cd1YZwgVpPm5vuzEiXQUVsRVB0hQdbg6xW7ffe2uwjQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com; spf=pass smtp.mailfrom=sifive.com; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b=LAW1J9Cy; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1d7232dcb3eso46121575ad.2 for ; Thu, 22 Feb 2024 00:12:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1708589566; x=1709194366; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=71zlVIznaIfi5FluR/+lVnei3BjKa6CskewcKRtvea4=; b=LAW1J9Cyv0IPyrQ7ReQwSt2I2kn0uf0klLK7STMVXaXN2OrDIaQe7lPcSEYwCoRaVZ s+BoYwXypRQnLS8B3X2MoYFBf5Jq5gJObjqOtuELGH7+TjxNlwEMt3PDjPmx8i+EI/Zv kqf3qiKNqVnq7xpu3cOuegmCXu+m5WVt6TE9cfBG/lw3S7uOxFFodzJznb4zed6XEgE5 bvO2OCClckpnFfWM7hZeubz+kM286qsMXzkGlTAacgpJ06ppvcyGDcaEZIdygYjDmdy0 F0mTUS01MiGKiKsBMP9FvTeyfmIIkKNIDA8dTmyr/uN07BvUk3Pmi0th1PjP8mGKQo6H BqYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708589566; x=1709194366; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=71zlVIznaIfi5FluR/+lVnei3BjKa6CskewcKRtvea4=; b=gXSkysEde1cp/TdLq2R+BotrgBRzopTQOXypFUmzzFdumU+vu52HhH/HiJCWpxHoZK C+lCgDudP38PVcqz3cU2Vk0+uhF01AlUMlCWRMo40RXoLs1lNKd6R/23Sd0YUDm2SESS ld3dxQ73T44312V8Q6K8Av1zkdr+IgonP8wbuYpHQL9qtqfW0UV1bTV2e0lEliEqrTNx VaG8miKHRScyP59QGRIM0VSaUrVCYQ/dP7eQWvCM7QQiE3ZfIR6fOYZiXsrP3QHdO17a H22GPIWYTjaa6nON6+bsQTq00NDlt7vvnLap1utLuUO039GbBzV3hHzrwon17pdFpGjq 9J8Q== X-Forwarded-Encrypted: i=1; AJvYcCXUR8X3AaB7dXEX1S1YiT5Xnwyk5XwY43R0l4pIVKADoyn/RJnXCWwQXhNMMl0SU40aNpNsLPwNO7z3Uq8Cjlh/FZ/Is/aTIvTg/mVQ X-Gm-Message-State: AOJu0Yw/CijscL71A0FiuxBRsjDpvjyGy+6Xj4saLLT0JgQKp7AFS+Z/ iSvM/tDxwF+WS+6hpcXb5t+hiz1l0kvL044y26Rd8bG5lJXDtGE1sUV7ReLBpDQ= X-Received: by 2002:a17:902:ecc1:b0:1dc:19e:3d9d with SMTP id a1-20020a170902ecc100b001dc019e3d9dmr11278580plh.30.1708589565722; Thu, 22 Feb 2024 00:12:45 -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 lf8-20020a170902fb4800b001db5ea825b2sm9412796plb.123.2024.02.22.00.12.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 00:12:45 -0800 (PST) From: Nylon Chen To: linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org, conor@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, palmer@dabbelt.com, paul.walmsley@sifive.com, aou@eecs.berkeley.edu, thierry.reding@gmail.com, u.kleine-koenig@pengutronix.de Cc: vincent.chen@sifive.com, zong.li@sifive.com, nylon.chen@sifive.com, nylon7717@gmail.com Subject: [PATCH v9 1/3] riscv: dts: sifive: unleashed/unmatched: Remove PWM controlled LED's active-low properties Date: Thu, 22 Feb 2024 16:12:29 +0800 Message-ID: <20240222081231.213406-2-nylon.chen@sifive.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222081231.213406-1-nylon.chen@sifive.com> References: <20240222081231.213406-1-nylon.chen@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791586097167788594 X-GMAIL-MSGID: 1791586097167788594 This removes the active-low properties of the PWM-controlled LEDs in the HiFive Unmatched device tree. The reference is hifive-unleashed-a00.pdf[0] and hifive-unmatched-schematics-v3.pdf[1]. Link: https://sifive.cdn.prismic.io/sifive/c52a8e32-05ce-4aaf-95c8-7bf8453f8698_hifive-unleashed-a00-schematics-1.pdf [0] Link: https://sifive.cdn.prismic.io/sifive/6a06d6c0-6e66-49b5-8e9e-e68ce76f4192_hifive-unmatched-schematics-v3.pdf [1] Co-developed-by: Zong Li Signed-off-by: Zong Li Co-developed-by: Vincent Chen Signed-off-by: Vincent Chen Signed-off-by: Nylon Chen --- arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts | 12 ++++-------- arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts | 12 ++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts b/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts index 900a50526d77..06731b8c7bc3 100644 --- a/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts +++ b/arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts @@ -49,32 +49,28 @@ led-controller { compatible = "pwm-leds"; led-d1 { - pwms = <&pwm0 0 7812500 PWM_POLARITY_INVERTED>; - active-low; + pwms = <&pwm0 0 7812500 0>; color = ; max-brightness = <255>; label = "d1"; }; led-d2 { - pwms = <&pwm0 1 7812500 PWM_POLARITY_INVERTED>; - active-low; + pwms = <&pwm0 1 7812500 0>; color = ; max-brightness = <255>; label = "d2"; }; led-d3 { - pwms = <&pwm0 2 7812500 PWM_POLARITY_INVERTED>; - active-low; + pwms = <&pwm0 2 7812500 0>; color = ; max-brightness = <255>; label = "d3"; }; led-d4 { - pwms = <&pwm0 3 7812500 PWM_POLARITY_INVERTED>; - active-low; + pwms = <&pwm0 3 7812500 0>; color = ; max-brightness = <255>; label = "d4"; diff --git a/arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts b/arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts index 07387f9c135c..b328ee80693f 100644 --- a/arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts +++ b/arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts @@ -51,8 +51,7 @@ led-controller-1 { compatible = "pwm-leds"; led-d12 { - pwms = <&pwm0 0 7812500 PWM_POLARITY_INVERTED>; - active-low; + pwms = <&pwm0 0 7812500 0>; color = ; max-brightness = <255>; label = "d12"; @@ -68,20 +67,17 @@ multi-led { label = "d2"; led-red { - pwms = <&pwm0 2 7812500 PWM_POLARITY_INVERTED>; - active-low; + pwms = <&pwm0 2 7812500 0>; color = ; }; led-green { - pwms = <&pwm0 1 7812500 PWM_POLARITY_INVERTED>; - active-low; + pwms = <&pwm0 1 7812500 0>; color = ; }; led-blue { - pwms = <&pwm0 3 7812500 PWM_POLARITY_INVERTED>; - active-low; + pwms = <&pwm0 3 7812500 0>; color = ; }; }; From patchwork Thu Feb 22 08:12:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nylon Chen X-Patchwork-Id: 204603 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp102847dyb; Thu, 22 Feb 2024 00:14:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUJTUTj/5ZJ8naLCPHx2wzar1boPizPgjjf/R3E8AllP3/ura46gn0LQE+bsfyTD2oMVjGp3Cg2efv9f7GyBp6Jbm/xGA== X-Google-Smtp-Source: AGHT+IE7FNZem70Eri+neCYkl7E6I3mITfmg2ON90GQSFozpFymjeyfUCAbSVGb95QLsR/j0Q8bo X-Received: by 2002:a05:6871:4399:b0:21e:a957:efef with SMTP id lv25-20020a056871439900b0021ea957efefmr16873166oab.19.1708589660773; Thu, 22 Feb 2024 00:14:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708589660; cv=pass; d=google.com; s=arc-20160816; b=GUQm+xuG+uXOYC6mjV+XCBIO1EnZeiOAlUQJMv1PygoVB3/HfgOlxTYkwuzUYDfEjB XzhFWak3w/3aIBxDQPLhiWU0EUYfIQuQ3RnBu7IRHxebC8I02YunZodzXDSEaKdK8HMN gtG2M/EOY8DwJQtfPtMUbHaxcdbz5UuyrxvDsztc6DCAZKL/DiicG+jYOBBxaDQZFQv7 0muCLfmAFhR0nkyXyD7O6yzdwvBOD2mEESHv1AgLBvZP26ZE8cEyw8J2yxj2WK2q9Yi5 981BfreSxWXCvCATHMoOuuGHgO74u7qr3ua7s9ZJAr5cwfEs1GN0Rr8b9BHtl7GlrCU1 KlWg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Thj6USXv+zFZqbn9GMP05XSRBqohJA11glRlwlO2t8E=; fh=FjsLZ1ypKMCSitMweetLf/iSdaHIgc7MtIF05BhGtDU=; b=EdjN1T9MGnTeGLIto6mqggJinqkZb+RPWSNwe902WYpqVkfYH+HYUzfjWi9lYKDst4 iObByGmz/U4p7tw4JuD6I2KZh8DZD/bnYSrtPGBncLwS/BZG2kCZWpyXa00P5Jt0mYkl awyaKR+ogj2aosQvRXAk2ndU8bmiZqWL1JHTHLJ2ZWgsAsYq1exhnvLXMpBw/js57vtB rTtADoKju9pTOJ8WdRm2xEQOWTBEtTRgZor0fQDWqBilGGSQZCZ9K/hyupE5mCfUOKH1 uh8gyQdskQZCEyG+2VK9Iiybtp9FT5wnFCB+V+7WLZXtR6avowkB7mhF40z+CD2uTrpd ZDJQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=JOtT518B; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-76071-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76071-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id e38-20020a631e26000000b005dc0e9aefeasi9492024pge.809.2024.02.22.00.14.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 00:14:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76071-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=JOtT518B; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-76071-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76071-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 4DA27B21CE1 for ; Thu, 22 Feb 2024 08:14:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 55346225AD; Thu, 22 Feb 2024 08:13:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="JOtT518B" Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 657D3219FF for ; Thu, 22 Feb 2024 08:12:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708589587; cv=none; b=m+xnjwLPeyGLbsAEmYVOnAIvq3Vsgm0hZi5TeNOobyyNLxjKy1d6yXpes8lKEUBW0+unK+xTd1AEjGfq1JhrWObhZkIc83xPPyUOAZ0lB2rvwOUaQT+ZOzZReLoM80DXSF/uNpVmxbEaPL/V7Ayag3JFditmCLlRUXVNH/VDlkc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708589587; c=relaxed/simple; bh=Z1dTn0Gkiacy9ygCtMQgZsRONznaH3pmxeR3C8lF2Xk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qYXiwNSMKF4A1lIko/J6bDsA3fCT/v5aTY3F9RzIEtbUy17nP873t31foNTznka1dJ8fnovOHz9xtzJHuSkqaScU6F8PwRaWDe6q5RNfT8Natt+PPCskS8kv2JMQatr3iBs0cvEHwcG/q6aVx/OjjGtL7mNVprmNVMZ3jw8aOzI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com; spf=pass smtp.mailfrom=sifive.com; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b=JOtT518B; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1dbae7b8ff2so35684515ad.3 for ; Thu, 22 Feb 2024 00:12:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1708589570; x=1709194370; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Thj6USXv+zFZqbn9GMP05XSRBqohJA11glRlwlO2t8E=; b=JOtT518Bilsath7/0BagXPuprmaG9kHXt/1L33oBtkRmq5zZyHjb8dsnzjC1iHV92U v+Z5yKj2F73lp/tpnJkoDI6boSbOSvsGgHqEAzysIbg4sK/dSzLxAzEg0W0z0zQ/kF17 V9h9Hx57ZjAZF+D5RIwEpvUj5wRzGx2+VTOhggh6AWof3GC5VnppDyWMiRxpCLng0O3I Os2vyMSddVWPfYwb7wzelELhIFXz1KHPMXvmd8MREuImXIBAfJegm4qCo0IUT70Z/xvE 3KNYS2+pDl9LrAwyAsRJGoELaIRUy78HEwXUq9i34ZRvPOa5kD+kyko/XOFoY1HNHGaR 0GYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708589570; x=1709194370; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Thj6USXv+zFZqbn9GMP05XSRBqohJA11glRlwlO2t8E=; b=W/qfOJ2GUhgWfuniK/Y/Qe6tDXQK37JKybhyMVpyBsFdZZNUDIYgPwXkZWTZaM8tJq gNj2iVjnxLH2hrTFeoMuXm8YlPV9MGgnkaZ+nw5KONUGRmFVZ4nvRINb2pMo1UMNDIMS xlQXXzK5AGUvi+LWgMdZGqnXqV6KzYcmC+glAm3bv+JGwI0EF2z6SSvPVUGwkw1oln6V fKF9is1Adwq5zcvX7oW5/bP5d/iMNZqa7vySM0UJ4WYnfTZKbtjU+4BcOduh4IpHfNAG K7fmzTK3TB0LD9TxWpYmNe1OtWtTp93y8452vADkjz6OlyVamK5uRaeg7V2SrAMvoyBz Jcfg== X-Forwarded-Encrypted: i=1; AJvYcCXMyMGSfJanpWKoAXTxSX4vUlv9b2wbhYkHWBGdXksuRTDPCV1HI5XP+rCd1jjykTClLVVDJSQIKIJorS0qaEQgAtATNnl5wBoT6EXX X-Gm-Message-State: AOJu0Yxk3YDH1ZRYLZZrNjPPBMZgktd7KBGvd4I27VWwnLKiKf360Xsp Xi/6tZLQFA3s1EMLd4U5fnHP6N+xPeRHKq+JU3j4XoL6R2FgR5BNC5IwzCc9Av0= X-Received: by 2002:a17:902:e751:b0:1dc:1e4f:9b3f with SMTP id p17-20020a170902e75100b001dc1e4f9b3fmr7654206plf.24.1708589570167; Thu, 22 Feb 2024 00:12:50 -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 lf8-20020a170902fb4800b001db5ea825b2sm9412796plb.123.2024.02.22.00.12.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 00:12:49 -0800 (PST) From: Nylon Chen To: linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org, conor@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, palmer@dabbelt.com, paul.walmsley@sifive.com, aou@eecs.berkeley.edu, thierry.reding@gmail.com, u.kleine-koenig@pengutronix.de Cc: vincent.chen@sifive.com, zong.li@sifive.com, nylon.chen@sifive.com, nylon7717@gmail.com Subject: [PATCH v9 2/3] pwm: sifive: change the PWM algorithm Date: Thu, 22 Feb 2024 16:12:30 +0800 Message-ID: <20240222081231.213406-3-nylon.chen@sifive.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222081231.213406-1-nylon.chen@sifive.com> References: <20240222081231.213406-1-nylon.chen@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791586112449519466 X-GMAIL-MSGID: 1791586112449519466 The `frac` variable represents the pulse inactive time, and the result of this algorithm is the pulse active time. Therefore, we must reverse the result. The reference is SiFive FU740-C000 Manual[0] Link: https://sifive.cdn.prismic.io/sifive/1a82e600-1f93-4f41-b2d8-86ed8b16acba_fu740-c000-manual-v1p6.pdf [0] Co-developed-by: Zong Li Signed-off-by: Zong Li Co-developed-by: Vincent Chen Signed-off-by: Vincent Chen Signed-off-by: Nylon Chen --- drivers/pwm/pwm-sifive.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c index eabddb7c7820..a586cfe4191b 100644 --- a/drivers/pwm/pwm-sifive.c +++ b/drivers/pwm/pwm-sifive.c @@ -110,9 +110,10 @@ static int pwm_sifive_get_state(struct pwm_chip *chip, struct pwm_device *pwm, struct pwm_state *state) { struct pwm_sifive_ddata *ddata = pwm_sifive_chip_to_ddata(chip); - u32 duty, val; + u32 duty, val, inactive; - duty = readl(ddata->regs + PWM_SIFIVE_PWMCMP(pwm->hwpwm)); + inactive = readl(ddata->regs + PWM_SIFIVE_PWMCMP(pwm->hwpwm)); + duty = (1U << PWM_SIFIVE_CMPWIDTH) - 1 - inactive; state->enabled = duty > 0; @@ -123,7 +124,7 @@ static int pwm_sifive_get_state(struct pwm_chip *chip, struct pwm_device *pwm, state->period = ddata->real_period; state->duty_cycle = (u64)duty * ddata->real_period >> PWM_SIFIVE_CMPWIDTH; - state->polarity = PWM_POLARITY_INVERSED; + state->polarity = PWM_POLARITY_NORMAL; return 0; } @@ -139,7 +140,7 @@ static int pwm_sifive_apply(struct pwm_chip *chip, struct pwm_device *pwm, int ret = 0; u32 frac; - if (state->polarity != PWM_POLARITY_INVERSED) + if (state->polarity != PWM_POLARITY_NORMAL) return -EINVAL; cur_state = pwm->state; @@ -159,6 +160,7 @@ static int pwm_sifive_apply(struct pwm_chip *chip, struct pwm_device *pwm, frac = DIV64_U64_ROUND_CLOSEST(num, state->period); /* The hardware cannot generate a 100% duty cycle */ frac = min(frac, (1U << PWM_SIFIVE_CMPWIDTH) - 1); + frac = (1U << PWM_SIFIVE_CMPWIDTH) - 1 - frac; mutex_lock(&ddata->lock); if (state->period != ddata->approx_period) { From patchwork Thu Feb 22 08:12:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nylon Chen X-Patchwork-Id: 204602 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp102781dyb; Thu, 22 Feb 2024 00:14:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXmwvtxd+uEdRUy7RlIfk9qbtA/zzKg/bUDW2kl8WyQqCHLBtRgFRnhf3C4U4W8/keNj0iHtkKjmqX+2QPh5Fx0jwXzrQ== X-Google-Smtp-Source: AGHT+IFGselA5FXqEKB1tZHRt8T7CiGCuChsc2fcEyej/irHCBn1Tp97IRT9P+BJ9BkR9RGe0PBx X-Received: by 2002:a05:6a00:1303:b0:6e4:bed6:9c2c with SMTP id j3-20020a056a00130300b006e4bed69c2cmr3374072pfu.4.1708589652665; Thu, 22 Feb 2024 00:14:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708589652; cv=pass; d=google.com; s=arc-20160816; b=AHXerqdGO2xrzLGPfJjljg2NuKyzYX/19G0s+rAI1zxlQIkc4LH/Ij2vK5PVmS2XP6 jkYlUlJ26CwwMg/OMuZOyxWzlqGaakJuFWAd7cjjDrqlpSKHFfdG6Wv71ZEEf8l1MyNw YF8JGKmastW5XsIwjw2xDOXw8PhuQjdZU91xLx40obdx2syzu0A69YrcL9eQWCnMQZ85 3BQmaKQi8NVE6XTVqMOKayp52ozeWu7XlXVuK0ZgDkKeLGXCFJFvsSDddrtyNz5NxNuI CyR5SqVhpOg/yMi6UnotzN0nr3cZGcUyUt+msKSvdCeJCC/iqIhmeP2FFg9yak8DSWOO pkZg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=OzNGUpNoXsKa0F+bV/ekx8aAYd7ltTcTmTe5buoxy74=; fh=Wk6exu5XKQpQ0K2vmCa4tKIFBXi6uSlOsMmda7DnfdM=; b=ZIkbNvinRWd1kVUe5fXpH+jqJP57kgUja7FcdlfVEvWwdM7U84On8//HCMgStcmVeC sdZvihk52teGeDzebxEnwOulCY3Hi4B79TFWok740yNmfWyyR2SbBThCm+MIdCT5XnGd rmxn522nEAXmKz52GLmfNUDwlweflw5lNSW/c7chu5m4rt0yJFNRegfohETgQoRE8AAP ue3lr37xtssa+D66PHRK8cYfMotl4G4oZbDZRy016TvtdViaqHpLhHSIyCGiCWc0T917 u5eq6z3MmosDuAZrg1H/bYpema2fLVGJAyg3nvcZkzNZHkRhKrg8T9LyIC96Ggq1D2xg RPvg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=jSGLSRSY; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-76072-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76072-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ko19-20020a056a00461300b006ddbedbbe2dsi9674635pfb.76.2024.02.22.00.14.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 00:14:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76072-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=jSGLSRSY; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-76072-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76072-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7D76A283C85 for ; Thu, 22 Feb 2024 08:14:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D46F222611; Thu, 22 Feb 2024 08:13:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="jSGLSRSY" Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 524E4179A1 for ; Thu, 22 Feb 2024 08:12:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708589590; cv=none; b=MsiYQ/MB7LeBRSVUuNFn58s/AufHZfMY7/sId3v095aDEwPY8SxsU6xJUJjp244ZKa1mNXmJjMIwza2Ox15uRyACmqOADFKqspQGSJY+Ep0GCwhFwej/uKIFakE4w9cB/JvVvattnOCJoWeu6Lbc1sM129DCZCYEe6igaFGfuWM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708589590; c=relaxed/simple; bh=h9kgBQNw1Wr0BxDFXwRL5apSgNSUo0OVqXELAEBrD4s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Sp0KTE7a5kkK1eYFHNvCkq5Pl0fOJAPvgfAn7eMe9QMm0+71yj8SJqTCFCy3qiUR3IBEjFErw4CaBhyMoAqKCST2ElawCXu2BPfgTNKWKTzabUi5nnn3n04tM3n/UByMwNdEwzQhWWf5EASlhT7PuK9inlP95afsjk1gVxFn+S0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com; spf=pass smtp.mailfrom=sifive.com; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b=jSGLSRSY; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1d944e8f367so60487045ad.0 for ; Thu, 22 Feb 2024 00:12:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1708589574; x=1709194374; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OzNGUpNoXsKa0F+bV/ekx8aAYd7ltTcTmTe5buoxy74=; b=jSGLSRSYMtq/I7wf3V4GDaTRmW43zUf4D7Cx2YsYtVoPj5alOTbDjWdA77qXxjQsuX SpAX66uUuIa2MiwBFxqQfywI1PZEZIu+iy3l0kgTnTU6j8jHtTa1JpoL3IFVaLor5cEy SR8INtdM3dkxGBN/pkVVOEOczUZoKELOHD0SVngj3X1O7hZe/g2FB9wFAYzK8QWQybTr OqUj4/qQgnldOntl8Im2ZYJsvn5UKNKG4vZ7jWw4AdGDhpARWayia99vWLZkH0NGxuiy SH2Z5o6Md0wb6YPC84WDQHfcDB9zcSo0NWj027XjVv1HwDgPz+FKUh+UIPq7/Afos7Ad kZuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708589574; x=1709194374; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OzNGUpNoXsKa0F+bV/ekx8aAYd7ltTcTmTe5buoxy74=; b=lFLy89PS8oyl3nQVXHkceXKHQ8dJYQP7cAHNBujoWXTTz+vtUIvLcDfeX9SzYxquEq /0edur8rfgzGhBQMQo4/QSMEN5nhZk6FYOIcsBh6WuRVwB/oV+WXaHkvzyIVxdujHxCB 3BRROksewIc4ZNAb73W/7uvDATCTAa1yeu+hqS7vMUKRfDLIuBzbTubnVFNxbwA8J/AK 4pCwKDEsfeR8bner3X7bQ0O08C1IPF27PvGiNQ0J48lT9H+0z7ktuIMw8J8AY6LTUBDU gw2y8A5fQfIZbeq6fQ8CA73Cmu/gaEds1le/6kW0xM7fELHG3J9bXrC7L6I72uIvr+Zo MHXQ== X-Forwarded-Encrypted: i=1; AJvYcCUXcdct+F/Ex5CCOCYuZ11lMexyDfoYE4G22B5wOn8dtaOIGgBByI6pBVNA31UnTmilEGFpCr7F+eWSMmK9xnJwXCFKOUpUGWHB0UI3 X-Gm-Message-State: AOJu0YzJLclAplJLig/kb0uPX3QzIDUwCIKwK9LJgIGBPZlTFglHCm60 Q10ZmQgOV1IKYFYVjFbg2cw32zA3h6RYHVgySPBW1Rs69t1hxoMj75N5s/V1e1I= X-Received: by 2002:a17:903:22c6:b0:1db:d42f:fde9 with SMTP id y6-20020a17090322c600b001dbd42ffde9mr16038641plg.41.1708589574353; Thu, 22 Feb 2024 00:12:54 -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 lf8-20020a170902fb4800b001db5ea825b2sm9412796plb.123.2024.02.22.00.12.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 00:12:53 -0800 (PST) From: Nylon Chen To: linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org, conor@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, palmer@dabbelt.com, paul.walmsley@sifive.com, aou@eecs.berkeley.edu, thierry.reding@gmail.com, u.kleine-koenig@pengutronix.de Cc: vincent.chen@sifive.com, zong.li@sifive.com, nylon.chen@sifive.com, nylon7717@gmail.com Subject: [PATCH v9 3/3] pwm: sifive: Fix the error in the idempotent test within the pwm_apply_state_debug function Date: Thu, 22 Feb 2024 16:12:31 +0800 Message-ID: <20240222081231.213406-4-nylon.chen@sifive.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222081231.213406-1-nylon.chen@sifive.com> References: <20240222081231.213406-1-nylon.chen@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791586103541448179 X-GMAIL-MSGID: 1791586103541448179 Round the result to the nearest whole number. This ensures that real_period is always a reasonable integer that is not lower than the actual value. e.g. $ echo 110 > /sys/devices/platform/led-controller-1/leds/d12/brightness $ .apply is not idempotent (ena=1 pol=0 1739692/4032985) -> (ena=1 pol=0 1739630/4032985) Co-developed-by: Zong Li Signed-off-by: Zong Li Signed-off-by: Nylon Chen --- drivers/pwm/pwm-sifive.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c index a586cfe4191b..bebcbebacccd 100644 --- a/drivers/pwm/pwm-sifive.c +++ b/drivers/pwm/pwm-sifive.c @@ -101,7 +101,7 @@ static void pwm_sifive_update_clock(struct pwm_sifive_ddata *ddata, /* As scale <= 15 the shift operation cannot overflow. */ num = (unsigned long long)NSEC_PER_SEC << (PWM_SIFIVE_CMPWIDTH + scale); - ddata->real_period = div64_ul(num, rate); + ddata->real_period = DIV_ROUND_UP_ULL(num, rate); dev_dbg(ddata->chip.dev, "New real_period = %u ns\n", ddata->real_period); }