From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 34BBF4D5AB for ; Tue, 24 Dec 2024 09:27:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735032481; cv=none; b=a/6wZFfhnNZ5qzc5awnQLIiop3pIxVawx95Lbf5JjwToJPsQLGIIXHxveHI7VprStppJkWJQ/IkvaSqNgVMWB2eiqP7qVvCfqBAw+xrGrQwxxwrNpxM4L9dvVunilYDGgsLbjZuVauLijkrnVxUP6UrGA6foC81svzVqgm3/UcE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735032481; c=relaxed/simple; bh=2t+mmYf+qQuZoqCXlanVjaUyuAIlUsomlX9EsaQMzNw=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=hdXVWqlEAV6QLO83AS5VYB0HnjOcuQYtMV5YUcBq2WJoEqUmiHNpwJW3cQMqPlSZ5auklqdWeNpjns1gxYqBnrlT24Be1q4tOh4OhYTAGbeVk2kmXrQHH9AoF+kEkmu21KwZy6w0W9cc1aP/TUxXumNqqc0iQXtiAYvmD4C1PNk= 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=lqgs05bU; arc=none smtp.client-ip=209.85.214.174 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="lqgs05bU" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-21683192bf9so55060745ad.3 for ; Tue, 24 Dec 2024 01:27:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1735032479; x=1735637279; 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=oLPJJm7xVkKFHYMyvGiaT5Jiz+ZLFC1VkzAq6OtMdxs=; b=lqgs05bUVzZHIl2+cdmt8YreyyOW6IU5sRAX9fJ0489UKE5rXZxDlKwEhIPk33eXXr bWxdjLYpu6n6G2x3IAQZej0Qb8N2EdhOstamDSMFTe/NZtsxALI6Hy3sO1BArIBt7aIH wtxSN7wk6mw9w/8R3v++YVpPhdY1fFwH+oPi0GBYrFRAO8hLbm99jiuWix9vlEdEYEfJ NaQIg2B3kl+9L19YYQS5+V0Q5gJigb4R+0lt8KCDVQldxh1ghnN5pd74I+sWv0yC5xxs Ns6nC9FK19x7KSl2VGv5wxaMpZIkbdw37d1L8i4X3hWePjLK0/vZ/V+PIxlpmHPcdc2a p2qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735032479; x=1735637279; 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=oLPJJm7xVkKFHYMyvGiaT5Jiz+ZLFC1VkzAq6OtMdxs=; b=DfjrmdTbG4wdzSGP+iqHtiDtL1HlnatDSi5mXliTUR7noZwWAUBKBFQLf3tT+GURXY JffqpgJLTsVZSyJh2IWV+wAHCbTfqqozX7V5wvo82Ga1t6GDAlf+FAes/ETopyHlWJz1 TG2SQZc7DAmv4/IVD0sh0vjv4HRtKkdsdC1FwfUV53Wma/jiqPUZNBRATfUKdUu3Fyp1 eBXj1D2VT9YOz4WSIHG0c3K88zDD4Njx1NMYrsYgle3/yUMtg5cafSwrQsen3GZVapJ+ 7Zp86NZC+Sxa84/MybVGJO8ac/Q/gNfvQiAMS4FCOkkOENH7v9TL7QnUnJ73zDNhn556 n1+g== X-Gm-Message-State: AOJu0Yy0NRyC9kBLEmzsQ0JFfxe3JSsKieGKcTW0Ezqh8yrTXTj6tVB3 H4oBw2uPaPj680PD8bN+2P1BChCXtH4IKN480Z2RLOFjuKG//JdOUIevG27QK93GTvJUxzg/sX0 5k+RSKJaizD31q+NtrEVKDwcjCtiHECMttfo3/o3KTXrSzw+OWhVu6oWfogw0k8iLhg6wzAEGFv 1NfU6sOg+qfcjSE6hJNWPRFq1/s45Oo+7UPK/ue1jxGXvHVlc= X-Gm-Gg: ASbGncvLahKkf175xnf9KQb3JBgXZL14QEVFNQcEt/OKHdhI+jXhYMaI6HF4XPtWFWf +82g7k4DhJ5T+YbRP1vW4f5wPt8SC65tycgsYl2n7pv/63YEGQfHNCIQRB8flGv7t/NspYlSUL7 QdiPbqU8O3s+EO1o+PbKw47iQNCOug2Ldmd/ZnyzBwhRosyCY1LF6cUk42+EJ8RLFDvz0ImerQN q/gHQMyD6mxg0n7P6R7JjcpKpFemcl5hAElG9cmDsxA8ImT04lQBCVY7cNVT0Rr83MPwJYUrJC/ r/mfkygrXRog59WcZQ== X-Google-Smtp-Source: AGHT+IH+ikoM6foMB1cnNkvpUi/3NR/XA4SwC00DSiVzFNckaK82lZIWct9AHrEMi4yCGHwTjvIZrA== X-Received: by 2002:a05:6a21:670b:b0:1e3:e77d:1431 with SMTP id adf61e73a8af0-1e5e04a3035mr26453787637.23.1735032479006; Tue, 24 Dec 2024 01:27:59 -0800 (PST) Received: from hsinchu36-syssw02.internal.sifive.com ([210.176.154.34]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72af8dcff60sm516341b3a.152.2024.12.24.01.27.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 01:27:58 -0800 (PST) From: Nylon Chen To: linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org, devicetree@vger.kernel.org Cc: Nylon Chen , Paul Walmsley , Palmer Dabbelt , Albert Ou , Samuel Holland , linux-riscv@lists.infradead.org Subject: [PATCH v10 0/3] Change PWM-controlled LED pin active mode and algorithm Date: Tue, 24 Dec 2024 17:38:58 +0800 Message-Id: <20241224093902.1632627-1-nylon.chen@sifive.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 v10: - Add 'inactive' variable in apply() to match pwm_sifive_get_state() style - Update comment about hardware limitation - it cannot generate 0% duty cycle rather than 100% duty cycle 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 (2): pwm: sifive: change the PWM algorithm pwm: sifive: Fix the error in the idempotent test within the pwm_apply_state_debug function NylonChen (1): riscv: dts: sifive: unleashed/unmatched: Remove PWM controlled LED's active-low properties .../boot/dts/sifive/hifive-unleashed-a00.dts | 12 ++++-------- .../boot/dts/sifive/hifive-unmatched-a00.dts | 12 ++++-------- drivers/pwm/pwm-sifive.c | 18 ++++++++++-------- 3 files changed, 18 insertions(+), 24 deletions(-) -- 2.34.1