Message ID | 20240222081231.213406-1-nylon.chen@sifive.com |
---|---|
Headers |
Return-Path: <linux-kernel+bounces-76069-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp102511dyb; Thu, 22 Feb 2024 00:13:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWD/9RJDGlSSd+0PCezOYsplMSOk8mjBzxc7daD29gTFHEO+L8TdZZyrXhseSWgLS0P6kiHMDuU/leZd/stTy9W8vgcXQ== X-Google-Smtp-Source: AGHT+IGs/PjtsKkVcriLj9z8FrQKU+u23OVSOBNueR7nHwWfoWJwMtT8KdiFONN8Vwesw7SWoePS X-Received: by 2002:a17:906:3b12:b0:a3e:59e5:a38f with SMTP id g18-20020a1709063b1200b00a3e59e5a38fmr8425491ejf.11.1708589609804; Thu, 22 Feb 2024 00:13:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708589609; cv=pass; d=google.com; s=arc-20160816; b=VG9RNM4MipnoX0rAX/mqsJY6SnGBiGk5k93JYlFtNPM8eAgM0qGr64pllyuEK+xf3Q QgsaWC88QRP/syZb7ZaD2iynFR3YpAQzV0LEn7Q4pWvL5XLY9nnZsaaitOyFP4JswyX+ WdMdtQuYPnu2f5tG4aTyKdh+iRl0TKVU5VC8ScbUwR8/Z6Qjht9t9v2CrRBqRulTc7CM qujKZpDHTMtfkL8PqXUUMymeY9VuXSPgvRzXVmC4rJnGOcmqRcVN3Mbpqw+8PZcCO8NI b0fEttvY4QLWe4IUtGWvhidkXqm5kooVWTTfwpeho9bhzqG0LhwhwWcEzZbgJybTQbgH QPaw== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=srJ7CIKPfZgDl9Um7d4eDADM8otcquGOUbdJDDVwdH0=; fh=bIpyjQj+Ilyb5X+TENpbuOEwkafWb73oAF/oxm8+4Sw=; b=nQY0RrOpsbqQpte6Ka4QuedfkOs/EC1X96UylY3Qmx2zNm7AH2uGGqmDHUD/Q6jImV sYP/hZKX1h/eiZal24GJWg1J5ravFAKmRCbWQRHPjZPN4NyuhyWQheYDqpoEEQQxq7DB L3U0YlI0yNeyJ7/ZdY3wIG33aelGQDwxtp2b1D72sNr2QIBfNjT6HlcLKJXbWdZKWrur ULtDwGwbI2JapWBNTazp+6PTr0fmW2qNdnG+Cf5qT8s8uJNdYe4XWlKgkuNpJzIeSDsW vcbsmgoPCB8SJnQlOX4rbe2msyEi18ZJurDt11d1BIUA3OwaPMyxGdqE2EOeHJRDyjJM b52Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=g6iibLfO; 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-76069-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76069-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a20-20020a170906369400b00a3d83788edbsi5049749ejc.105.2024.02.22.00.13.29 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 00:13:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76069-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=g6iibLfO; 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-76069-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76069-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 682921F21DBD for <ouuuleilei@gmail.com>; Thu, 22 Feb 2024 08:13:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EBE681B59F; Thu, 22 Feb 2024 08:13:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="g6iibLfO" Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) (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 6381018030 for <linux-kernel@vger.kernel.org>; Thu, 22 Feb 2024 08:12:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708589570; cv=none; b=UGmRNjwMAe0l3KMjCLrcjFnNKYlVjKaR3nMmXtuTelMtZr/dPuGoZFPY6tQxUPCy9dd3jmGUvdIzl0nsCzfPpEjAtBE8svWpRc90qUnj29Q85VvuWk8pDrYF9+iAzVoYHFQ7z6u1j5gItoDFMUSwBzSmhNAk/9/JkAyf7n32ajw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708589570; c=relaxed/simple; bh=109AvBUKTCt8zYZv15cJALXjRO+Ds/rqVjdmAlqe6vg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=UN0VToqAoS3X4ZQ/Dcngoe+GknNF6XWmflM3T5XIFf3/GWqnINCl7mZwqhlfyPOKps4HW0ZYCBnI1X3PFvC3w38dhCWcJeTHsPaDxmSU7zay+y2p/5ALagHDWB6YQS+Kp5VLXfkRp2zYHLAb3mb9VukDl1+1ZP3ToOdqAQxQyAI= 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=g6iibLfO; arc=none smtp.client-ip=209.85.215.179 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-pg1-f179.google.com with SMTP id 41be03b00d2f7-5dbd519bde6so6327825a12.1 for <linux-kernel@vger.kernel.org>; Thu, 22 Feb 2024 00:12:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1708589559; x=1709194359; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=srJ7CIKPfZgDl9Um7d4eDADM8otcquGOUbdJDDVwdH0=; b=g6iibLfOw4Rkks5FltYu7w+fYOYqdOL2iu77RB4Cm+Pzk3x2Y/qyLZSlS/+asNa5k+ IOVNOXOwaK1fNRlMeLW9VKnLUi+3Cry98zxxc5y95zcP798xMMAsc0PLD187UxX/k/ms KtLRGKB64/YsZb7uZkQOfmQeH5T6GUF4N9xOF3LmGECKm3YQrtkjPjvAPtN9nT+tmIfM NjvsdaIiIRcz5uGPjvoH40XqM8yjOYHCGo+Hc7kIa4A+vfU9Y+g938mZcBz0vP+wWtA6 6Uwoy4tJ1hFoXrlpshxz7mnBl8szol+ANtd10NwXR4AP+jxZd0hqYTfroZI9qEonZYi+ sD3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708589559; x=1709194359; 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=srJ7CIKPfZgDl9Um7d4eDADM8otcquGOUbdJDDVwdH0=; b=aqPIIEcVuJBc1AdYVpPdNNVR/a5lXTD6R0nDOzeuba2lfWQ4NKQQLrVuH09goGqC4r hi6+GufIzicvNNkq2RhsN32gyZnJqFTOUCrT4XifSiutl+cM2XzKYhrBvL79HdpdPK9u 3oxiuayuwr5Oo76OkeElp1Bm0oYC7xp9f77y2u6/ZtuOaThIzUKLzbk9WzPfuiat38Bz J0CthB5SQeJVGh0zGPs9qPkmxLGmWZdvV/6JJ/xXAgi2HSv6CXTSxli2qLV7LeaKzuEh bfqVHp56KdpPM07iNiw5GOeiDym5LMTRgg7hLt6X2k1DBYHAbr61/WvRIk3rbE8OQKYV UMDg== X-Forwarded-Encrypted: i=1; AJvYcCWE8X3NmchUIwEOjjlkD1zbpbNDN6zcwR8hJhhg5wDtcT0S7MKB7wpbxIg+eTLsFB/G6BwTnTlggyYXv+4/qMw6XDAV7e56lIcGfC1z X-Gm-Message-State: AOJu0YyJAHQE3FKhmLcKjjg2gFRRmTjuqa60bu/ZV8tm9R5APuhkBpmg aTvKzijVJSa/UMl5wm7TxXukolecNiO/9TXPMdWONlmCj/IeE4Fc6vsBeC3Hm2Y= X-Received: by 2002:a05:6a21:31c8:b0:1a0:8a46:c3bf with SMTP id zb8-20020a056a2131c800b001a08a46c3bfmr15856784pzb.21.1708589558614; Thu, 22 Feb 2024 00:12:38 -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.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 00:12:38 -0800 (PST) From: Nylon Chen <nylon.chen@sifive.com> 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 0/3] Change PWM-controlled LED pin active mode and algorithm Date: Thu, 22 Feb 2024 16:12:28 +0800 Message-ID: <20240222081231.213406-1-nylon.chen@sifive.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791586058714311720 X-GMAIL-MSGID: 1791586058714311720 |
Series |
Change PWM-controlled LED pin active mode and algorithm
|
|
Message
Nylon Chen
Feb. 22, 2024, 8:12 a.m. UTC
According to the circuit diagram of User LEDs - RGB described in the manual hifive-unleashed-a00.pdf[0] and hifive-unmatched-schematics-v3.pdf[1]. The behavior of PWM is acitve-high. According to the descriptionof PWM for pwmcmp in SiFive FU740-C000 Manual[2]. The pwm algorithm is (PW) pulse active time = (D) duty * (T) period. 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. Updated patches: 1 New patches: 0 Unchanged patches: 2 Links: - [0]: https://sifive.cdn.prismic.io/sifive/c52a8e32-05ce-4aaf-95c8-7bf8453f8698_hifive-unleashed-a00-schematics-1.pdf - [1]: https://sifive.cdn.prismic.io/sifive/6a06d6c0-6e66-49b5-8e9e-e68ce76f4192_hifive-unmatched-schematics-v3.pdf - [2]: https://sifive.cdn.prismic.io/sifive/1a82e600-1f93-4f41-b2d8-86ed8b16acba_fu740-c000-manual-v1p6.pdf Changed in v9: - Fix commit message to adhere to 75 columns rule. - Update commit message's subject. - Add a variable for inactive logic. Changed in v8: - Fix Signed-off-by and Co-developed-by typo. Changed in v7: - Remove active-low strings from hifive-unleashed-a00.dts file. Changed in v6: - Separate the idempotent test bug fixes into a new patch. - Move the reversing the duty before the line checking state->enabled. - Fix the algorithm and change it to take the minimum value first and then reverse it. Changed in v5: - Add the updates to the PWM algorithm based on version 2 back in. - Replace div64_ul with DIV_ROUND_UP_ULL to correct the error in the period value of the idempotent test in pwm_apply_state_debug. Changed in v4: - Remove previous updates to the PWM algorithm. Changed in v3: - Convert the reference link to standard link. - Move the inverted function before taking the minimum value. - Change polarity check condition(high and low). - Pick the biggest period length possible that is not bigger than the requested period. Changed in v2: - Convert the reference link to standard link. - Fix typo: s/sifive unmatched:/sifive: unmatched:/. - Remove active-low from hifive-unleashed-a00.dts. - Include this reference link in the dts and pwm commit messages. Nylon Chen (3): riscv: dts: sifive: unleashed/unmatched: Remove PWM controlled LED's active-low properties pwm: sifive: change the PWM controlled LED algorithm pwm: sifive: Fix the error in the idempotent test within the pwm_apply_state_debug function arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts | 12 ++++-------- arch/riscv/boot/dts/sifive/hifive-unmatched-a00.dts | 12 ++++-------- drivers/pwm/pwm-sifive.c | 12 +++++++----- 3 files changed, 15 insertions(+), 21 deletions(-)