From patchwork Mon Apr 12 09:54:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Billy Tsai X-Patchwork-Id: 12197515 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=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, 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 AF5A7C433ED for ; Mon, 12 Apr 2021 09:57:43 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 3E7C8611AD for ; Mon, 12 Apr 2021 09:57:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3E7C8611AD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=aspeedtech.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=GYlydLtPXbm7+5eeYKqRqnSZ3qwKZOPirE4MuvF80jo=; b=g1fKtDgzKG7k3HGPi6fcREfv4 NQJKEqEFk9/IxHGozGlMxSrC7LZa1H2Z1/fCGEVwk0OlvFryMJ9L1OwqtQOpWDPjbo1GMPHSf4nuI cehfd1fg+Zh2YWLzWQx8VrJ1fdR1S3heMtrzRO6ujBV6IgqFYm/7XYmqvBCz0y2XPglb6pMeW0OmQ EhaPWC7AR0TkXvF2SC90d0UOJDxlwyQrzJv/wXuHyX1W8znssktPrNckmIBo/TFBJp9+fGiPSbWcG kIQR/ut9mqX7Ic/VsLUx62rJvdT2dlujzbl9RupicWbZ8Ro8Z79t2cEOK7IQmyUddHBpI8DxMahqo /pTeRWCFg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lVtIX-006NCd-5Q; Mon, 12 Apr 2021 09:56:01 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lVtIG-006NAc-Uw for linux-arm-kernel@desiato.infradead.org; Mon, 12 Apr 2021 09:55:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender :Reply-To:Content-ID:Content-Description; bh=v2mnP70hmBtHBQvYRQbqvrS5Y31X5S+Ga7SDZqQUuD8=; b=exGpWNqCprixcxVxjrBCMKZ135 uDY2aYfgfOeFzcbER0fzx+3dPugwP4cLCdOQ9bnXG9i3pU8uYyp0b5RhzF4ZJpXjdWOtaRF5p5Rvx JHa8c9NiZEiNCiS2rXJwrwn3MZxhdwb3Fz+vwFjNiKLubnubzkZwcLZ+hSj2vIZxatiosdYmFO8tY aJMRL01wBuMI+FtzCcKNhDIqe9zYXex3Bg9c9EGX39+M6nd7naKgaGdQFr5rKNWIMhTYgb1dMJPlX 2RFN9v7vOnHBHgNoP10Ir/ygX1XgGG4tPtt8iQG7LKsnJ8hUvbENTLliz1Dyw+1Zlp3m8eD6mr27o aNyKoB6Q==; Received: from twspam01.aspeedtech.com ([211.20.114.71]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lVtI8-0049Iy-EB for linux-arm-kernel@lists.infradead.org; Mon, 12 Apr 2021 09:55:40 +0000 Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 13C9iS0n096463; Mon, 12 Apr 2021 17:44:28 +0800 (GMT-8) (envelope-from billy_tsai@aspeedtech.com) Received: from BillyTsai-pc.aspeed.com (192.168.2.149) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 12 Apr 2021 17:54:50 +0800 From: Billy Tsai To: , , , , , , , , , , , , CC: Subject: [PATCH 1/4] dt-bindings: Add bindings for aspeed pwm-tach. Date: Mon, 12 Apr 2021 17:54:54 +0800 Message-ID: <20210412095457.15095-2-billy_tsai@aspeedtech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210412095457.15095-1-billy_tsai@aspeedtech.com> References: <20210412095457.15095-1-billy_tsai@aspeedtech.com> MIME-Version: 1.0 X-Originating-IP: [192.168.2.149] X-ClientProxiedBy: TWMBX02.aspeed.com (192.168.0.24) To TWMBX02.aspeed.com (192.168.0.24) X-DNSRBL: X-MAIL: twspam01.aspeedtech.com 13C9iS0n096463 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210412_105538_694503_0F6F6BFA X-CRM114-Status: GOOD ( 10.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch adds device bindings for aspeed pwm-tach device which is a multi-function device include pwn and tach function. Signed-off-by: Billy Tsai --- .../bindings/mfd/aspeed,ast2600-pwm-tach.yaml | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml diff --git a/Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml b/Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml new file mode 100644 index 000000000000..73512ff71d23 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml @@ -0,0 +1,52 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) 2021 ASPEED, Inc. +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/aspeed,ast2600-pwn-tach.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: PWM Tach controller Device Tree Bindings + +description: | + The PWM Tach controller is represented as a multi-function device which includes: + PWM + Tach + +maintainers: + - Billy Tsai + +properties: + compatible: + - items: + - enum: + - aspeed,ast2600-pwn-tach + - const: syscon + - const: simple-mfd + reg: + maxItems: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + pwm_tach: pwm_tach@1e610000 { + compatible = "aspeed,ast2600-pwm-tach", "simple-mfd", "syscon"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0x1e610000 0x100>; + + pwm: pwm@0 { + compatible = "aspeed,ast2600-pwm"; + #pwm-cells = <3>; + reg = <0x0 0x100>; + }; + + tach: tach@0 { + compatible = "aspeed,ast2600-tach"; + reg = <0x0 0x100>; + }; + }; From patchwork Mon Apr 12 09:54:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Billy Tsai X-Patchwork-Id: 12197513 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=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, 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 AED68C433B4 for ; Mon, 12 Apr 2021 09:57:43 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 2BEB56120B for ; Mon, 12 Apr 2021 09:57:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2BEB56120B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=aspeedtech.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=duBqN/o+JpXw1GitWKXiqaUePpuYzo8ioflW7MMw7eA=; b=Qe6w2hgkqqk5uZ6PYttyLwVs3 ncCwnfFu+ee2i6QboJVYop8rQT5Q/AHpH6i+ovckALRKC1HpG7FqZxUNCy7/La7mq7Xiq9FNgAKms nZdNG/eKVW2l7dvbHzMB2xGoWxCC/bn3OkPry/Bo08R17to55JoSkXm7jMNP3Dn7U+essWx9RuKfk 0dQCJCgRL+aLAPCF33QqCjRu2lHiESRRW0h1PYaVF+OHzp94jKY2KQVz7iL3zZUgH+jk19OPemo7S vGZcxf26S3FaIonYhSHO3WUBgSSnrJ013o5E7oXM3YVezsupT202HUsnV6BBS2zD381KsJf3MOACU tSnTPv1Yg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lVtIn-006NF8-8g; Mon, 12 Apr 2021 09:56:17 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lVtIG-006NAd-V8 for linux-arm-kernel@desiato.infradead.org; Mon, 12 Apr 2021 09:55:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender :Reply-To:Content-ID:Content-Description; bh=UYOomuEcze9nXi9tNKySqzEImD9Tuc014M48ZnFFIBk=; b=IxHjRsSpnlPT4oMiOd4J1AUdIv luYpMawb6yyPniAUs4CDpL4QDeZAUwv0utD0HyawsV7D17JCmRqC5BbH0/2upCFe2h8b8MQdzVLgw 5M58n9MNllSubmHXocoCxvbAMEENx2UL9L1U7ZRsRh/Cpa5mF9euGwjpkwirTBh0e+7X/gApiUMPM SKU3I3pu7wc+zKLnt+Y6fE6MeYtQsJD5FBi1xt7bt7EZfTvM+wnvxd5hmhqUj21Ha299zyRxiQMog jm0yoXtDG+1wNdIb3ldTialiWR7cUo+OX3cuM4e4bT+5udSeFRakqRQ3aoYB/sTl9+uDirGvEKN6q yXqESYxw==; Received: from twspam01.aspeedtech.com ([211.20.114.71]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lVtI8-0049Iz-F8 for linux-arm-kernel@lists.infradead.org; Mon, 12 Apr 2021 09:55:40 +0000 Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 13C9iS0o096463; Mon, 12 Apr 2021 17:44:29 +0800 (GMT-8) (envelope-from billy_tsai@aspeedtech.com) Received: from BillyTsai-pc.aspeed.com (192.168.2.149) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 12 Apr 2021 17:54:50 +0800 From: Billy Tsai To: , , , , , , , , , , , , CC: Subject: [PATCH 2/4] dt-bindings: Add bindings for aspeed pwm Date: Mon, 12 Apr 2021 17:54:55 +0800 Message-ID: <20210412095457.15095-3-billy_tsai@aspeedtech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210412095457.15095-1-billy_tsai@aspeedtech.com> References: <20210412095457.15095-1-billy_tsai@aspeedtech.com> MIME-Version: 1.0 X-Originating-IP: [192.168.2.149] X-ClientProxiedBy: TWMBX02.aspeed.com (192.168.0.24) To TWMBX02.aspeed.com (192.168.0.24) X-DNSRBL: X-MAIL: twspam01.aspeedtech.com 13C9iS0o096463 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210412_105538_693946_BF481091 X-CRM114-Status: GOOD ( 11.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch adds device bindings for aspeed pwm device which should be the sub-node of aspeed,ast2600-pwm-tach. Signed-off-by: Billy Tsai --- .../bindings/pwm/aspeed,ast2600-pwm.yaml | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/aspeed,ast2600-pwm.yaml diff --git a/Documentation/devicetree/bindings/pwm/aspeed,ast2600-pwm.yaml b/Documentation/devicetree/bindings/pwm/aspeed,ast2600-pwm.yaml new file mode 100644 index 000000000000..7a7ff0260d27 --- /dev/null +++ b/Documentation/devicetree/bindings/pwm/aspeed,ast2600-pwm.yaml @@ -0,0 +1,47 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) 2021 ASPEED, Inc. +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pwm/aspeed,ast2600-pwm.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ASPEED AST2600 PWM controller + +maintainers: + - Billy Tsai + +description: | + The ASPEED PWM controller can support upto 16 PWM outputs. + +properties: + compatible: + enum: + - aspeed,ast2600-pwm + + "#pwm-cells": + const: 3 + +pwm-cells: + - channel +# period in terms of nanoseconds + - period +# PWM_POLARITY_INVERTED + - flag + +additionalProperties: false + +examples: + - | + // The PWM should be a subnode of a "aspeed,ast2600-pwn-tach" compatible node. + pwm_tach@1e610000 { + compatible = "aspeed,ast2600-pwm-tach", "simple-mfd", "syscon"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0x1e610000 0x100>; + ranges = <0 0x1e610000 0x100>; + pwm: pwm@0 { + compatible = "aspeed,ast2600-pwm"; + #pwm-cells = <3>; + reg = <0x0 0x100>; + }; + }; From patchwork Mon Apr 12 09:54:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Billy Tsai X-Patchwork-Id: 12197519 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=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, 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 16159C433ED for ; Mon, 12 Apr 2021 09:58:38 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 777226120B for ; Mon, 12 Apr 2021 09:58:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 777226120B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=aspeedtech.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=YqoN91oQUZ+YixCjpYdUONMioy9JBnB9PMLMan39pJY=; b=MIONHfsTvrSTBO6SVF15sKhLf JuSyuzUd3yAZ2s8Hc5FDWLi5UmIIHOU0fhQpB5x1KGbEmJZ599ZNATvlBOdP89+4xW61tcwVQ9Ctb DbeAy+tZ20mIqXC40dIcknpk9ojbhXOhrU8i4eAtcQOo5WXRrgT7ebRrkY8F8Farr0KLlXqE+jgKi sFPKX/SaCOUoGpgNTelnI6ERHFCzdg401OwLzBXXaRBUfUAQoXBeEaHLwwNDAHcS59YbwU6pxk5eH NfLwmjJB7Y8UemMAOF7vzGAco+DS34gD5aStImAW6ihKeFeJNdkck7ultYO99dhY4yYECVKhoZ5DT VzazlOLLw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lVtJO-006NN7-Mg; Mon, 12 Apr 2021 09:56:55 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lVtIO-006NBl-6O for linux-arm-kernel@desiato.infradead.org; Mon, 12 Apr 2021 09:55:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender :Reply-To:Content-ID:Content-Description; bh=Y3qY8P8PFyej6pT2J3zm2hi9o9SRUFCEr5ZZctJzxes=; b=Ceru3etaR4N4Yntd0jU4UkzHx8 LnG3BKL3/GHM1Q2cq+TOMiP3YoUN+HGclRAK3KmG/0oGhP0/6fyiGL15fg+oLBembuldcnux0VQWw krwVy6cXiYk09GUbMkFSlj1oybhTpbFCPXsQ4IkUHfzGMDnsSid11tAVBr8uyrDvnpBnO483QfZHd TIqLFqfZgLOKPtWwnB6v3Xf2ruWGga4Jk06YwS4ApK4FTVsBU6QAuGhdkrgumBiJetSsVl9DXHVsV tCM99tdeBRQaFnRfUSVUoQXM1SpN6+j3ZRbopUlhboui88O4C85+gik9DdkWLx6t2Ih7G3GLsVbeK qTMV2e4A==; Received: from twspam01.aspeedtech.com ([211.20.114.71]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lVtIC-0049JK-7k for linux-arm-kernel@lists.infradead.org; Mon, 12 Apr 2021 09:55:44 +0000 Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 13C9iS0p096463; Mon, 12 Apr 2021 17:44:29 +0800 (GMT-8) (envelope-from billy_tsai@aspeedtech.com) Received: from BillyTsai-pc.aspeed.com (192.168.2.149) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 12 Apr 2021 17:54:50 +0800 From: Billy Tsai To: , , , , , , , , , , , , CC: Subject: [PATCH 3/4] pwm: Add Aspeed ast2600 PWM support Date: Mon, 12 Apr 2021 17:54:56 +0800 Message-ID: <20210412095457.15095-4-billy_tsai@aspeedtech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210412095457.15095-1-billy_tsai@aspeedtech.com> References: <20210412095457.15095-1-billy_tsai@aspeedtech.com> MIME-Version: 1.0 X-Originating-IP: [192.168.2.149] X-ClientProxiedBy: TWMBX02.aspeed.com (192.168.0.24) To TWMBX02.aspeed.com (192.168.0.24) X-DNSRBL: X-MAIL: twspam01.aspeedtech.com 13C9iS0p096463 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210412_105541_606230_6F2B6130 X-CRM114-Status: GOOD ( 21.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch add the support of PWM controller which can find at aspeed ast2600 soc chip. This controller supoorts up to 16 channels. Signed-off-by: Billy Tsai --- drivers/pwm/pwm-aspeed-g6.c | 291 ++++++++++++++++++++++++++++++++++++ 1 file changed, 291 insertions(+) create mode 100644 drivers/pwm/pwm-aspeed-g6.c diff --git a/drivers/pwm/pwm-aspeed-g6.c b/drivers/pwm/pwm-aspeed-g6.c new file mode 100644 index 000000000000..4bb4f97453c6 --- /dev/null +++ b/drivers/pwm/pwm-aspeed-g6.c @@ -0,0 +1,291 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) ASPEED Technology Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 or later as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +/* The channel number of Aspeed pwm controller */ +#define ASPEED_NR_PWMS 16 +/* PWM Control Register */ +#define ASPEED_PWM_CTRL_CH(ch) ((ch * 0x10) + 0x00) +#define PWM_LOAD_SEL_AS_WDT BIT(19) +#define LOAD_SEL_FALLING 0 +#define LOAD_SEL_RIGING 1 +#define PWM_DUTY_LOAD_AS_WDT_EN BIT(18) +#define PWM_DUTY_SYNC_DIS BIT(17) +#define PWM_CLK_ENABLE BIT(16) +#define PWM_LEVEL_OUTPUT BIT(15) +#define PWM_INVERSE BIT(14) +#define PWM_OPEN_DRAIN_EN BIT(13) +#define PWM_PIN_EN BIT(12) +#define PWM_CLK_DIV_H_SHIFT 8 +#define PWM_CLK_DIV_H_MASK (0xf << PWM_CLK_DIV_H_SHIFT) +#define PWM_CLK_DIV_L_SHIFT 0 +#define PWM_CLK_DIV_L_MASK (0xff << PWM_CLK_DIV_L_SHIFT) +/* PWM Duty Cycle Register */ +#define ASPEED_PWM_DUTY_CYCLE_CH(ch) ((ch * 0x10) + 0x04) +#define PWM_PERIOD_SHIFT (24) +#define PWM_PERIOD_MASK (0xff << PWM_PERIOD_SHIFT) +#define PWM_POINT_AS_WDT_SHIFT (16) +#define PWM_POINT_AS_WDT_MASK (0xff << PWM_POINT_AS_WDT_SHIFT) +#define PWM_FALLING_POINT_SHIFT (8) +#define PWM_FALLING_POINT_MASK (0xffff << PWM_FALLING_POINT_SHIFT) +#define PWM_RISING_POINT_SHIFT (0) +#define PWM_RISING_POINT_MASK (0xffff << PWM_RISING_POINT_SHIFT) +/* PWM default value */ +#define DEFAULT_PWM_PERIOD 0xff +#define DEFAULT_TARGET_PWM_FREQ 25000 +#define DEFAULT_DUTY_PT 10 +#define DEFAULT_WDT_RELOAD_DUTY_PT 16 + +struct aspeed_pwm_data { + struct pwm_chip chip; + struct regmap *regmap; + unsigned long clk_freq; + struct reset_control *reset; +}; +/** + * struct aspeed_pwm - per-PWM driver data + * @freq: cached pwm freq + */ +struct aspeed_pwm { + u32 freq; +}; + +static void aspeed_set_pwm_channel_enable(struct regmap *regmap, u8 pwm_channel, + bool enable) +{ + regmap_update_bits(regmap, ASPEED_PWM_CTRL_CH(pwm_channel), + (PWM_CLK_ENABLE | PWM_PIN_EN), + enable ? (PWM_CLK_ENABLE | PWM_PIN_EN) : 0); +} +/* + * The PWM frequency = HCLK(200Mhz) / (clock division L bit * + * clock division H bit * (period bit + 1)) + */ +static void aspeed_set_pwm_freq(struct aspeed_pwm_data *priv, + struct pwm_device *pwm, u32 freq) +{ + u32 target_div, cal_freq; + u32 tmp_div_h, tmp_div_l, diff, min_diff = INT_MAX; + u32 div_h = BIT(5) - 1, div_l = BIT(8) - 1; + u8 div_found; + u32 index = pwm->hwpwm; + struct aspeed_pwm *channel = pwm_get_chip_data(pwm); + + cal_freq = priv->clk_freq / (DEFAULT_PWM_PERIOD + 1); + target_div = DIV_ROUND_UP(cal_freq, freq); + div_found = 0; + /* calculate for target frequence */ + for (tmp_div_h = 0; tmp_div_h < 0x10; tmp_div_h++) { + tmp_div_l = target_div / BIT(tmp_div_h) - 1; + + if (tmp_div_l < 0 || tmp_div_l > 255) + continue; + + diff = freq - cal_freq / (BIT(tmp_div_h) * (tmp_div_l + 1)); + if (abs(diff) < abs(min_diff)) { + min_diff = diff; + div_l = tmp_div_l; + div_h = tmp_div_h; + div_found = 1; + if (diff == 0) + break; + } + } + if (div_found == 0) { + pr_debug("target freq: %d too slow set minimal frequency\n", + freq); + } + channel->freq = cal_freq / (BIT(div_h) * (div_l + 1)); + pr_debug("div h %x, l : %x pwm out clk %d\n", div_h, div_l, + channel->freq); + pr_debug("hclk %ld, target pwm freq %d, real pwm freq %d\n", + priv->clk_freq, freq, channel->freq); + + regmap_update_bits(priv->regmap, ASPEED_PWM_CTRL_CH(index), + (PWM_CLK_DIV_H_MASK | PWM_CLK_DIV_L_MASK), + (div_h << PWM_CLK_DIV_H_SHIFT) | + (div_l << PWM_CLK_DIV_L_SHIFT)); +} + +static void aspeed_set_pwm_duty(struct aspeed_pwm_data *priv, + struct pwm_device *pwm, u32 duty_pt) +{ + u32 index = pwm->hwpwm; + + if (duty_pt == 0) { + aspeed_set_pwm_channel_enable(priv->regmap, index, false); + } else { + regmap_update_bits(priv->regmap, + ASPEED_PWM_DUTY_CYCLE_CH(index), + PWM_FALLING_POINT_MASK, + duty_pt << PWM_FALLING_POINT_SHIFT); + aspeed_set_pwm_channel_enable(priv->regmap, index, true); + } +} + +static void aspeed_set_pwm_polarity(struct aspeed_pwm_data *priv, + struct pwm_device *pwm, u8 polarity) +{ + u32 index = pwm->hwpwm; + + regmap_update_bits(priv->regmap, ASPEED_PWM_CTRL_CH(index), PWM_INVERSE, + (polarity) ? PWM_INVERSE : 0); +} + +static int aspeed_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) +{ + struct device *dev = chip->dev; + struct aspeed_pwm_data *priv = dev_get_drvdata(dev); + struct aspeed_pwm *channel; + u32 index = pwm->hwpwm; + /* + * Fixed the period to the max value and rising point to 0 + * for high resolution and simplified frequency calculation. + */ + regmap_update_bits(priv->regmap, ASPEED_PWM_DUTY_CYCLE_CH(index), + PWM_PERIOD_MASK, + DEFAULT_PWM_PERIOD << PWM_PERIOD_SHIFT); + + regmap_update_bits(priv->regmap, ASPEED_PWM_DUTY_CYCLE_CH(index), + PWM_RISING_POINT_MASK, 0); + + channel = devm_kzalloc(dev, sizeof(*channel), GFP_KERNEL); + if (!channel) + return -ENOMEM; + + pwm_set_chip_data(pwm, channel); + + return 0; +} + +static void aspeed_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm) +{ + struct device *dev = chip->dev; + struct aspeed_pwm *channel = pwm_get_chip_data(pwm); + + devm_kfree(dev, channel); +} + +static int aspeed_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, + const struct pwm_state *state) +{ + struct device *dev = chip->dev; + struct aspeed_pwm_data *priv = dev_get_drvdata(dev); + struct pwm_state *cur_state = &pwm->state; + u32 freq = DIV_ROUND_UP_ULL(1000000000, state->period); + u32 duty_pt = DIV_ROUND_UP_ULL( + state->duty_cycle * (DEFAULT_PWM_PERIOD + 1), state->period); + dev_dbg(dev, "freq: %d, duty_pt: %d", freq, duty_pt); + if (state->enabled) { + aspeed_set_pwm_freq(priv, pwm, freq); + aspeed_set_pwm_duty(priv, pwm, duty_pt); + aspeed_set_pwm_polarity(priv, pwm, state->polarity); + } else { + aspeed_set_pwm_duty(priv, pwm, 0); + } + cur_state->period = state->period; + cur_state->duty_cycle = state->duty_cycle; + cur_state->polarity = state->polarity; + cur_state->enabled = state->enabled; + + return 0; +} +static const struct pwm_ops aspeed_pwm_ops = { + .request = aspeed_pwm_request, + .free = aspeed_pwm_free, + .apply = aspeed_pwm_apply, + .owner = THIS_MODULE, +}; + +static int aspeed_pwm_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct clk *clk; + int ret; + struct aspeed_pwm_data *priv; + struct device_node *np; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + np = pdev->dev.parent->of_node; + if (!of_device_is_compatible(np, "aspeed,ast2600-pwm-tach")) { + dev_err(dev, "unsupported pwm device binding\n"); + return -ENODEV; + } + + priv->regmap = syscon_node_to_regmap(np); + if (IS_ERR(priv->regmap)) { + dev_err(dev, "Couldn't get regmap\n"); + return -ENODEV; + } + + clk = devm_clk_get(dev, NULL); + if (IS_ERR(clk)) + return -ENODEV; + priv->clk_freq = clk_get_rate(clk); + + priv->reset = reset_control_get_shared(&pdev->dev, NULL); + if (IS_ERR(priv->reset)) { + dev_err(&pdev->dev, "can't get aspeed_pwm_tacho reset\n"); + return PTR_ERR(priv->reset); + } + reset_control_deassert(priv->reset); + + priv->chip.dev = dev; + priv->chip.ops = &aspeed_pwm_ops; + priv->chip.base = -1; + priv->chip.npwm = ASPEED_NR_PWMS; + priv->chip.of_xlate = of_pwm_xlate_with_flags; + priv->chip.of_pwm_n_cells = 3; + + ret = pwmchip_add(&priv->chip); + if (ret < 0) { + dev_err(&pdev->dev, "failed to add PWM chip: %d\n", ret); + return ret; + } + dev_set_drvdata(dev, priv); + return ret; +} + +static const struct of_device_id of_pwm_match_table[] = { + { + .compatible = "aspeed,ast2600-pwm", + }, + {}, +}; +MODULE_DEVICE_TABLE(of, of_pwm_match_table); + +static struct platform_driver aspeed_pwm_driver = { + .probe = aspeed_pwm_probe, + .driver = { + .name = "aspeed_pwm", + .of_match_table = of_pwm_match_table, + }, +}; + +module_platform_driver(aspeed_pwm_driver); + +MODULE_AUTHOR("Billy Tsai "); +MODULE_DESCRIPTION("ASPEED PWM device driver"); +MODULE_LICENSE("GPL v2"); From patchwork Mon Apr 12 09:54:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Billy Tsai X-Patchwork-Id: 12197517 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=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, 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 0CF4FC43460 for ; Mon, 12 Apr 2021 09:58:13 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 9EE2A611AD for ; Mon, 12 Apr 2021 09:58:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9EE2A611AD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=aspeedtech.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=drM7aTlapGR9I46r1PHnh6lUldLDIciR39Z4HlAknsI=; b=HYEQ5jgqlxzVR/OyDXFExwtyL XEBma0v1SQJ/Yuqle2Lr7z7Fw8la0TyMRSFO6lze/QT1dSAI938VocSTB1ts5I8PZJ3vZrqgYzRZl lAiC3h/6JRTnGK1BNJR3l7Fd4k0PffX0kLXk0E1nQHX6tWPSfUatD1SCKQBfy07XmCLg1Ibk2aO3v yyyls5xY7knJBJ3YxWkB0sogtSnMyDTuQ8UzaNU2UhlRzzPh/3LrTtMPilo3OdiTC9lYJgTHVFRLP xKu62FkVMd1EJ58bbUndSPJbyv0aBrmfJibxZDjXltPQOYorwOSkNKqhPswR+fdjgexvjQyd0zC35 ZWuxQ2wEg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lVtJ4-006NIY-MV; Mon, 12 Apr 2021 09:56:35 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lVtIM-006NBT-HI for linux-arm-kernel@desiato.infradead.org; Mon, 12 Apr 2021 09:55:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender :Reply-To:Content-ID:Content-Description; bh=TFPzM5kDjpEovoV2UiEk4K6MVothE15i/tFn89OotZM=; b=pW+WwXsNUrdOkse2fgxtb5bHTh IljUciEGdziDIauqARKSnzxi746KJJ4yYbhnhfoQ/TW3DXbJawz4EYyQzFKrDZRRU0sQC8RpeJEIi OhOL2SxJPNbMatcoOaLK7YEQ5hwovzQ3xGQ9YS3QhibJ5H8rcO6lhmrAfOQuQ6N2t4DaLbTD8qp6d jYSyCFDMKKQ0CGxZL3M5eAasAN3e30RN2mPVCMV4w9C6wLqaW7RdMAse9Gmfwmq9UD+5xsAHETDfC z9G8JN24E08bD1F2bYi9TMZvUe0B61b8bthfdjDKTl0G5dGWVUJav6n2GuDlFhHbis/HvYTKWzoxn BhzY8GKw==; Received: from twspam01.aspeedtech.com ([211.20.114.71]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lVtIC-0049JL-Br for linux-arm-kernel@lists.infradead.org; Mon, 12 Apr 2021 09:55:43 +0000 Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 13C9iS0q096463; Mon, 12 Apr 2021 17:44:29 +0800 (GMT-8) (envelope-from billy_tsai@aspeedtech.com) Received: from BillyTsai-pc.aspeed.com (192.168.2.149) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 12 Apr 2021 17:54:51 +0800 From: Billy Tsai To: , , , , , , , , , , , , CC: Subject: [PATCH 4/4] pwm: Add support for aspeed pwm controller Date: Mon, 12 Apr 2021 17:54:57 +0800 Message-ID: <20210412095457.15095-5-billy_tsai@aspeedtech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210412095457.15095-1-billy_tsai@aspeedtech.com> References: <20210412095457.15095-1-billy_tsai@aspeedtech.com> MIME-Version: 1.0 X-Originating-IP: [192.168.2.149] X-ClientProxiedBy: TWMBX02.aspeed.com (192.168.0.24) To TWMBX02.aspeed.com (192.168.0.24) X-DNSRBL: X-MAIL: twspam01.aspeedtech.com 13C9iS0q096463 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210412_105541_602273_AE57A82B X-CRM114-Status: GOOD ( 10.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add support for the pwm controller which can be found at aspeed ast2600 soc. This driver is part function of multi-funciton of device "pwm-tach controller". Signed-off-by: Billy Tsai --- drivers/pwm/Kconfig | 6 ++++++ drivers/pwm/Makefile | 1 + 2 files changed, 7 insertions(+) diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index 63be5362fd3a..947ed642debe 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -42,6 +42,12 @@ config PWM_DEBUG It is expected to introduce some runtime overhead and diagnostic output to the kernel log, so only enable while working on a driver. +config PWM_ASPEED_G6 + tristate "ASPEEDG6 PWM support" + help + This driver provides support for ASPEED G6 PWM controllers. + + config PWM_AB8500 tristate "AB8500 PWM support" depends on AB8500_CORE && ARCH_U8500 diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index cbdcd55d69ee..4a74c68547bf 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_PWM) += core.o obj-$(CONFIG_PWM_SYSFS) += sysfs.o +obj-$(CONFIG_PWM_ASPEED_G6) += pwm-aspeed-g6.o obj-$(CONFIG_PWM_AB8500) += pwm-ab8500.o obj-$(CONFIG_PWM_ATMEL) += pwm-atmel.o obj-$(CONFIG_PWM_ATMEL_HLCDC_PWM) += pwm-atmel-hlcdc.o