From patchwork Fri Mar 5 18:38:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Wu X-Patchwork-Id: 12119291 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8A42C433DB for ; Fri, 5 Mar 2021 18:48:06 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 234956509A for ; Fri, 5 Mar 2021 18:48:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 234956509A Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=nongnu.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIFUb-0000zD-2h for qemu-devel@archiver.kernel.org; Fri, 05 Mar 2021 13:48:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56168) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3DXtCYAgKChYIG3wAFE32AA270.yA8C08G-z0H079A929G.AD2@flex--wuhaotsh.bounces.google.com>) id 1lIFN7-0006gZ-0p for qemu-devel@nongnu.org; Fri, 05 Mar 2021 13:40:21 -0500 Received: from mail-pg1-x54a.google.com ([2607:f8b0:4864:20::54a]:48360) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3DXtCYAgKChYIG3wAFE32AA270.yA8C08G-z0H079A929G.AD2@flex--wuhaotsh.bounces.google.com>) id 1lIFN4-0006yk-0Y for qemu-devel@nongnu.org; Fri, 05 Mar 2021 13:40:20 -0500 Received: by mail-pg1-x54a.google.com with SMTP id c30so1897232pgl.15 for ; Fri, 05 Mar 2021 10:40:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=Nk7lxsUa75dhQmQF0/5Rl+mVDMFdt+RD2Y9tLIMQ+ZU=; b=uj++KYI3cO26JBtNK9OaXQyniXl6bFpMc9r6aiIaRteih49KeNGj1yRLzNnsRfj7lz pI7XkUhJEsXnWu5M6eY7yysnDyVDLeTYwoO0qYjZoK8JjaQmBDG+c3XwsgRZXrEZ49NK KQMJFV2hoEt9W2r/tFqkJWbJQUQC9l1n6RqbPS5O3FY3pSDxF93Q/j5lJqACR79Si3Gc Ae5/fkMlKIWMrjsVZjHRa730a4tyHlMH6zHPC8rQWrAzYK1v36MrC/vX8lQ6R6VEcevk x3/33TcgIi8jiyyjWZpg7q0tLFNv03ChNeU76uwcBNIcfxbrngcA7F1mVmSF3K5an59x e1qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=Nk7lxsUa75dhQmQF0/5Rl+mVDMFdt+RD2Y9tLIMQ+ZU=; b=h+zp13CMjoqTOqr4TGgsppNwykEC0JKNjpCRo9F8lzh1GAf5pe5RSN7+EX32a2tpsE b3IINKVC4J6PCvXZ/qg+6SE4V1jPkFwJeELn1zmJ2YEYM9s9Tr9/rt7gn8DgBVnZx9a2 vIlmb7LHVuzDqz9soCSFdfpVaGp3/44IQtznZtnZPikaBoZCKGStaWrCPbrbEOZb2TQx POzeSN6G0p5FdDiQnYm58rHlGyrGcWIGJt8uqZFlgyqn6lT8vPZYglugE8WOKSykh7BT /TIMhZNYPL3rRbaHCh+H2UthmlSMgiJnyq4k7YkFHIV3LWhM+nhk2IJN/HefFSTR4oSI 47JQ== X-Gm-Message-State: AOAM531lm0iZi50tjFhpJqbVfbCSC3CwO+lZQyOE4vnPpuY2D8t0Dgr/ ccC7TD81OV6EjKPfgUJ+OcKJbFp35fxoWw== X-Google-Smtp-Source: ABdhPJxDqku34n1P9/1PAPHNpx6AqbsbndnlJuiPoS51aw2i6FSLtJtkXYdTXH59ivFZZWU7at9niAleUa4Cnw== X-Received: from mimik.c.googlers.com ([fda3:e722:ac3:10:7f:e700:c0a8:4e]) (user=wuhaotsh job=sendgmr) by 2002:a62:30c1:0:b029:1ed:a487:4253 with SMTP id w184-20020a6230c10000b02901eda4874253mr10313559pfw.3.1614969613749; Fri, 05 Mar 2021 10:40:13 -0800 (PST) Date: Fri, 5 Mar 2021 10:38:53 -0800 Message-Id: <20210305183857.3120188-1-wuhaotsh@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog Subject: [PATCH 0/4] hw/misc: Add NPCM7XX Tachometer Device To: peter.maydell@linaro.org Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, Avi.Fishman@nuvoton.com, kfting@nuvoton.com, wuhaotsh@google.com, hskinnemoen@google.com, venture@google.com, dje@google.com Received-SPF: pass client-ip=2607:f8b0:4864:20::54a; envelope-from=3DXtCYAgKChYIG3wAFE32AA270.yA8C08G-z0H079A929G.AD2@flex--wuhaotsh.bounces.google.com; helo=mail-pg1-x54a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Reply-to: Hao Wu X-Patchwork-Original-From: Hao Wu via From: Hao Wu This patch set implements the Tachometer (a.k.a Multi Functional Timer/MFT) device in NPCM7XX SoC. This device is used by NPCM7XX boards to measure the RPM of PWM fans. To provide the RPM of a certain fan, since RPM = MAX_RPM * duty_percentage. We convert the duty output in NPCM7XX PWM module into GPIOs and feed them into the MFT module. The connection of PWM modules and fan modules are derived from their specific Linux device trees and coded in hw/arm/npcm7xx_boards.c. We amend the QTest for the PWM module to include verifying the reading from the Tachometer is correct. Hao Wu (4): hw/misc: Add GPIOs for duty in NPCM7xx PWM hw/misc: Add NPCM7XX MFT Module hw/arm: Connect PWM fans in NPCM7XX boards tests/qtest: Test PWM fan RPM using MFT in PWM test docs/system/arm/nuvoton.rst | 2 +- hw/arm/npcm7xx.c | 45 ++- hw/arm/npcm7xx_boards.c | 99 ++++++ hw/misc/meson.build | 1 + hw/misc/npcm7xx_mft.c | 541 +++++++++++++++++++++++++++++++++ hw/misc/npcm7xx_pwm.c | 4 + hw/misc/trace-events | 8 + include/hw/arm/npcm7xx.h | 13 +- include/hw/misc/npcm7xx_mft.h | 70 +++++ include/hw/misc/npcm7xx_pwm.h | 4 +- tests/qtest/npcm7xx_pwm-test.c | 205 ++++++++++++- 11 files changed, 975 insertions(+), 17 deletions(-) create mode 100644 hw/misc/npcm7xx_mft.c create mode 100644 include/hw/misc/npcm7xx_mft.h