From patchwork Fri Nov 18 13:32:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Walker Chen X-Patchwork-Id: 22339 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp208488wrr; Fri, 18 Nov 2022 06:00:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf4KIL1ASi8tq3TUs23T/PCzbdBFpz/jQH4P7WyZPCff4OIevZVpqZA9e1w51ueOanB9IGXz X-Received: by 2002:a17:907:918d:b0:78d:2eea:28c7 with SMTP id bp13-20020a170907918d00b0078d2eea28c7mr6115825ejb.266.1668780026951; Fri, 18 Nov 2022 06:00:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668780026; cv=none; d=google.com; s=arc-20160816; b=szB4KaGv+k9ZPsbqQgpDWQOVyvFmgTs4BKTUDCswNUn/Cun6v3HQlGCgKCx/pGfVB+ pDRmOXUDMen3JU89N5Q68MHja6urLkS/C5gJzqctamsCVQu4UQYReYzNQOyqpmComWXP 7wNnRwevIP9x8pNAhyzsBmxwPlOl8v18Ya0zXlvy+5rYTnFdYn8vyyb8EUW9o/SdhvaD TWmlbdYWVaxx+YiA5MI3Z6RJMQIl3tfVNUX5hS+2X6TBN9VxouU+DxnuHUglA7onLDit jFPMkx8+sIGKYksERXZzH88+UzdzvA2cqWj0c3OKChNGvRuc6kzBNV2kX3wMvPsqME4k Fevg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=UK3h/4E5vXBNqY/13Fttvb8p9v9Cj+sX6uMrYNAkG0A=; b=JrwtGlFaUW7OOZO8VOoDpXne904rW+ceds8aBHRNfYVu98/p2AcrwiUpkJZvpvpHMv SbDpLoXib8I2fMq2pDUeayM1CTNJIAgFa1+5d0CxTMq8t4cnL9EBw3mtmkaaZxzk/3Bc CYmJlUxvMfPYO1P99h0Lq2+98uBMxwf4iAnpAjAyx2ENIbM6MMXfAHNmUuOiMvhl8zVF 4IR2kgYUNBxz8tEoyVJMa9XGbbdrQuDGOsW4jcIPVu1ZZp//nJ5HMdRN6GFFq0iwhs9k p1Y6nZmIw6o8nozKyaDkL9fEjcukphCdpFURhu2h8WroiLLxxPklojqDrv1wjTrLN5QS vxYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dr9-20020a170907720900b007877eb5687csi3022380ejc.249.2022.11.18.06.00.01; Fri, 18 Nov 2022 06:00:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241950AbiKRNne (ORCPT + 99 others); Fri, 18 Nov 2022 08:43:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241574AbiKRNnc (ORCPT ); Fri, 18 Nov 2022 08:43:32 -0500 Received: from ex01.ufhost.com (ex01.ufhost.com [61.152.239.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83972CD5; Fri, 18 Nov 2022 05:43:29 -0800 (PST) Received: from EXMBX166.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX166", Issuer "EXMBX166" (not verified)) by ex01.ufhost.com (Postfix) with ESMTP id 421B724DBC2; Fri, 18 Nov 2022 21:32:28 +0800 (CST) Received: from EXMBX068.cuchost.com (172.16.6.68) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 18 Nov 2022 21:32:28 +0800 Received: from localhost.localdomain (183.27.96.116) by EXMBX068.cuchost.com (172.16.6.68) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 18 Nov 2022 21:32:27 +0800 From: Walker Chen To: , , CC: Rob Herring , Krzysztof Kozlowski , Conor Dooley , "Rafael J . Wysocki" , Walker Chen , Subject: [PATCH v1 1/4] dt-bindings: power: Add StarFive JH7110 power domain definitions Date: Fri, 18 Nov 2022 21:32:13 +0800 Message-ID: <20221118133216.17037-2-walker.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221118133216.17037-1-walker.chen@starfivetech.com> References: <20221118133216.17037-1-walker.chen@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [183.27.96.116] X-ClientProxiedBy: EXCAS066.cuchost.com (172.16.6.26) To EXMBX068.cuchost.com (172.16.6.68) X-YovoleRuleAgent: yovoleflag X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749842685870084495?= X-GMAIL-MSGID: =?utf-8?q?1749842685870084495?= Add power domain definitions for the StarFive JH7110 SoC. Signed-off-by: Walker Chen --- include/dt-bindings/power/jh7110-power.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 include/dt-bindings/power/jh7110-power.h diff --git a/include/dt-bindings/power/jh7110-power.h b/include/dt-bindings/power/jh7110-power.h new file mode 100644 index 000000000000..24160c46fbaf --- /dev/null +++ b/include/dt-bindings/power/jh7110-power.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: (GPL-2.0) */ +/* + * Copyright (C) 2022 StarFive Technology Co., Ltd. + * Author: Walker Chen + */ +#ifndef __DT_BINDINGS_POWER_JH7110_POWER_H__ +#define __DT_BINDINGS_POWER_JH7110_POWER_H__ + +#define JH7110_PD_SYSTOP 0 +#define JH7110_PD_CPU 1 +#define JH7110_PD_GPUA 2 +#define JH7110_PD_VDEC 3 +#define JH7110_PD_VOUT 4 +#define JH7110_PD_ISP 5 +#define JH7110_PD_VENC 6 +#define JH7110_PD_GPUB 7 + +#endif From patchwork Fri Nov 18 13:32:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Walker Chen X-Patchwork-Id: 22336 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp206880wrr; Fri, 18 Nov 2022 05:56:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf56tRS8yENPvbncFIV6+wiPQZb6GpS4h3dQmxlz2Ps1cVUzX2ZgcIL90zcTe32RfPgJ4ZNz X-Received: by 2002:a17:906:4e46:b0:7ae:129b:2d3a with SMTP id g6-20020a1709064e4600b007ae129b2d3amr6019486ejw.552.1668779797036; Fri, 18 Nov 2022 05:56:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668779797; cv=none; d=google.com; s=arc-20160816; b=vScnzQkRA75G1adOFpceTtclLCe2e8SJ6oqSj4+yKpvNsyb5VxIZUYDUmk50v9It2R RJ8ciJp3206oglZy7QkC85R576qedjVBGQ8dL502/kBW+1ofIkPQiFauIqSUTavAbiZi kkFGGU+LU6LTzwkQxXvc2Z/urjolf4Fqek2/8sDJeby0FVLgXnwgPuwIwCLi1gypYO6C oO1CbD2IRgucIkV8jZNf71wURPpM2Ijbn6W9NT9wEiTYDqVr0ks//T6x2p6Nm1Gyq6Z8 Ty883CdBVhUVwiyLolZEbiYStqzbeR8PLDdo/fNZWVr9f8DnqbA9bKwCqyVlJASbkxFT BhGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=rjtm2WSWLrn7mLOdGA9xfNJCKMe10GDMHlNLulbKjek=; b=0UdVEGCBL7+wYHp6RzjN0DGdKPkvxY0VDcmrstKXIupVybWAnvZXfNo6cxo1BX1fDS Hv/iomsWa0T1AIffgNXKd/9hUjSNqMiM47l8Y/I4Q0v/KoRWgVPiR/3WN596+UxQs9jH /UPVcI8c+sJTS5fXdFTfOf6UNaKKfUNkav6qOXN+vQ4blX4rFBi/Kaf5CkeAe0d7rIw9 kH/FHjW+qgm8shfamMF2I9rwC1XKCCn5HtR9bmVBeZoBEovxo/+AAkSDS6hTNXz8ulnv jiiS/PINiQDyx5xfsvjOK7JgQOIHPdsDM86O/AqRupKP6hEk/b/qcE15r/XfepVc+wRN D0Og== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id de36-20020a1709069be400b007ad88f87ed6si2686491ejc.993.2022.11.18.05.56.12; Fri, 18 Nov 2022 05:56:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235142AbiKRNgv (ORCPT + 99 others); Fri, 18 Nov 2022 08:36:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241918AbiKRNgR (ORCPT ); Fri, 18 Nov 2022 08:36:17 -0500 Received: from ex01.ufhost.com (ex01.ufhost.com [61.152.239.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AF9D94A5C; Fri, 18 Nov 2022 05:34:29 -0800 (PST) Received: from EXMBX165.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX165", Issuer "EXMBX165" (not verified)) by ex01.ufhost.com (Postfix) with ESMTP id C81FE24E1A6; Fri, 18 Nov 2022 21:32:28 +0800 (CST) Received: from EXMBX068.cuchost.com (172.16.6.68) by EXMBX165.cuchost.com (172.16.6.75) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 18 Nov 2022 21:32:28 +0800 Received: from localhost.localdomain (183.27.96.116) by EXMBX068.cuchost.com (172.16.6.68) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 18 Nov 2022 21:32:27 +0800 From: Walker Chen To: , , CC: Rob Herring , Krzysztof Kozlowski , Conor Dooley , "Rafael J . Wysocki" , Walker Chen , Subject: [PATCH v1 2/4] dt-bindings: power: Add starfive,jh71xx-power bindings Date: Fri, 18 Nov 2022 21:32:14 +0800 Message-ID: <20221118133216.17037-3-walker.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221118133216.17037-1-walker.chen@starfivetech.com> References: <20221118133216.17037-1-walker.chen@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [183.27.96.116] X-ClientProxiedBy: EXCAS066.cuchost.com (172.16.6.26) To EXMBX068.cuchost.com (172.16.6.68) X-YovoleRuleAgent: yovoleflag X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749842444793230048?= X-GMAIL-MSGID: =?utf-8?q?1749842444793230048?= Add bindings for the power domain controller on the StarFive JH71XX SoC. Signed-off-by: Walker Chen --- .../bindings/power/starfive,jh71xx-power.yaml | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/starfive,jh71xx-power.yaml diff --git a/Documentation/devicetree/bindings/power/starfive,jh71xx-power.yaml b/Documentation/devicetree/bindings/power/starfive,jh71xx-power.yaml new file mode 100644 index 000000000000..2537303b4829 --- /dev/null +++ b/Documentation/devicetree/bindings/power/starfive,jh71xx-power.yaml @@ -0,0 +1,46 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/starfive,jh71xx-power.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: StarFive JH71xx Power Domains Controller + +maintainers: + - Walker Chen + +description: | + StarFive JH71xx SoCs include support for multiple power domains which can be + powered on/off by software based on different application scenes to save power. + +properties: + compatible: + items: + - enum: + - starfive,jh7110-pmu + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + "#power-domain-cells": + const: 1 + +required: + - compatible + - reg + - interrupts + - "#power-domain-cells" + +additionalProperties: false + +examples: + - | + pwrc: power-controller@17030000 { + compatible = "starfive,jh7110-pmu"; + reg = <0x17030000 0x10000>; + interrupts = <111>; + #power-domain-cells = <1>; + }; From patchwork Fri Nov 18 13:32:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Walker Chen X-Patchwork-Id: 22334 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp206826wrr; Fri, 18 Nov 2022 05:56:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf6+3pY0RV3ofxV/WAGnsgHzun5zaPXM3nlfbFKFGAbSXuqWqsXlb0V0y80cZmT7LWcENSgd X-Received: by 2002:a17:902:7c10:b0:183:ee9e:4988 with SMTP id x16-20020a1709027c1000b00183ee9e4988mr7796555pll.56.1668779788081; Fri, 18 Nov 2022 05:56:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668779788; cv=none; d=google.com; s=arc-20160816; b=Tk6ISHOmllnxY36ubo1VnUAMlz7z0w+XBX8RmCW6OSgREHGVRHXQxTcsaWl9LZbIRF dmHcnu1EEJSVOW19lTQde2Z6okni96cFDBhtvlkVWcwTo3dl0NmZEd0Qo7Yfy4UM/QCK XshOWpQru8iTygl2O3aMMj/vOewBm5OVwffeIJuUrEvCO9Kv0HA7q+XwGR8fwepauMMx y4ZFdcVjH53jtwLF256YZfV5x3sEjeLgdDBsmjxwWerjIOP686keu5FjLPHTcY/zMhpq lirPa69b/crs2rKTiuEDBaBlyljmdyfflvqqJt194MwYfHX8LgKoZCtegbMWCQE2qN/J iRBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=IopF2qAsxFlVA8V0QGzLlEHsSpUAxZQ7vE3UfNTnL08=; b=u2xqbm76T2MkNlrM19aftt33HE93JpZ20014fj9TS4Jpk3B/nLy/PUk+ENYJP5bMwP arYjluWET/cPtsjKuO68uPBSvxAJf/reE/rMb7xqljOFh2rS4279DH9uSeBiHA2/YxqV qX3dqYBAjpIpzrtv4rj9u7G2X89wrpXXEZMQcPAhy9nKdhA/62lb7f/adkjdW2U3TWyJ Lv6U3SrbpQQzX43JzNrSRX2AU7FYXP43/M6ZdAiv9ScrFVXR58Qob3nvVd9o8ZuJ35Y4 ULeNXujLNPA8HsXNUFGL+Uxy7vW+sW8YxGjsW1rQUdD4jX60/15bZuc3divB52veG8Ew vosg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m66-20020a632645000000b00470274bbc14si3531907pgm.676.2022.11.18.05.56.14; Fri, 18 Nov 2022 05:56:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241863AbiKRNgm (ORCPT + 99 others); Fri, 18 Nov 2022 08:36:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242242AbiKRNgQ (ORCPT ); Fri, 18 Nov 2022 08:36:16 -0500 Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC1D5942E2; Fri, 18 Nov 2022 05:34:18 -0800 (PST) Received: from EXMBX166.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX166", Issuer "EXMBX166" (not verified)) by fd01.gateway.ufhost.com (Postfix) with ESMTP id 6C7AF24DB83; Fri, 18 Nov 2022 21:32:29 +0800 (CST) Received: from EXMBX068.cuchost.com (172.16.6.68) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 18 Nov 2022 21:32:29 +0800 Received: from localhost.localdomain (183.27.96.116) by EXMBX068.cuchost.com (172.16.6.68) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 18 Nov 2022 21:32:28 +0800 From: Walker Chen To: , , CC: Rob Herring , Krzysztof Kozlowski , Conor Dooley , "Rafael J . Wysocki" , Walker Chen , Subject: [PATCH v1 3/4] soc: starfive: Add StarFive JH71XX pmu driver Date: Fri, 18 Nov 2022 21:32:15 +0800 Message-ID: <20221118133216.17037-4-walker.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221118133216.17037-1-walker.chen@starfivetech.com> References: <20221118133216.17037-1-walker.chen@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [183.27.96.116] X-ClientProxiedBy: EXCAS066.cuchost.com (172.16.6.26) To EXMBX068.cuchost.com (172.16.6.68) X-YovoleRuleAgent: yovoleflag X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749842434889737096?= X-GMAIL-MSGID: =?utf-8?q?1749842434889737096?= Add generic power domain driver for the StarFive JH71XX SoC. Signed-off-by: Walker Chen --- MAINTAINERS | 8 + drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/starfive/Kconfig | 9 + drivers/soc/starfive/Makefile | 3 + drivers/soc/starfive/jh71xx_pmu.c | 380 ++++++++++++++++++++++++++++++ include/soc/starfive/pm_domains.h | 15 ++ 7 files changed, 417 insertions(+) create mode 100644 drivers/soc/starfive/Kconfig create mode 100644 drivers/soc/starfive/Makefile create mode 100644 drivers/soc/starfive/jh71xx_pmu.c create mode 100644 include/soc/starfive/pm_domains.h diff --git a/MAINTAINERS b/MAINTAINERS index a70c1d0f303e..112f1e698723 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19623,6 +19623,14 @@ F: Documentation/devicetree/bindings/reset/starfive,jh7100-reset.yaml F: drivers/reset/starfive/ F: include/dt-bindings/reset/starfive* +STARFIVE JH71XX PMU CONTROLLER DRIVER +M: Walker Chen +S: Maintained +F: Documentation/devicetree/bindings/power/starfive* +F: drivers/soc/starfive/jh71xx_pmu.c +F: include/soc/starfive/pm_domains.h +F: include/dt-bindings/power/jh7110-power.h + STATIC BRANCH/CALL M: Peter Zijlstra M: Josh Poimboeuf diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig index e461c071189b..628fda4d5ed9 100644 --- a/drivers/soc/Kconfig +++ b/drivers/soc/Kconfig @@ -21,6 +21,7 @@ source "drivers/soc/renesas/Kconfig" source "drivers/soc/rockchip/Kconfig" source "drivers/soc/samsung/Kconfig" source "drivers/soc/sifive/Kconfig" +source "drivers/soc/starfive/Kconfig" source "drivers/soc/sunxi/Kconfig" source "drivers/soc/tegra/Kconfig" source "drivers/soc/ti/Kconfig" diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile index 534669840858..cbe076f42068 100644 --- a/drivers/soc/Makefile +++ b/drivers/soc/Makefile @@ -27,6 +27,7 @@ obj-y += renesas/ obj-y += rockchip/ obj-$(CONFIG_SOC_SAMSUNG) += samsung/ obj-y += sifive/ +obj-y += starfive/ obj-y += sunxi/ obj-$(CONFIG_ARCH_TEGRA) += tegra/ obj-y += ti/ diff --git a/drivers/soc/starfive/Kconfig b/drivers/soc/starfive/Kconfig new file mode 100644 index 000000000000..2bbcc1397b15 --- /dev/null +++ b/drivers/soc/starfive/Kconfig @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0 + +config JH71XX_PMU + bool "Support PMU for StarFive JH71XX Soc" + depends on PM && (SOC_STARFIVE || COMPILE_TEST) + select PM_GENERIC_DOMAINS + help + Say y here to enable power domain support. + diff --git a/drivers/soc/starfive/Makefile b/drivers/soc/starfive/Makefile new file mode 100644 index 000000000000..13b589d6b5f3 --- /dev/null +++ b/drivers/soc/starfive/Makefile @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_JH71XX_PMU) += jh71xx_pmu.o diff --git a/drivers/soc/starfive/jh71xx_pmu.c b/drivers/soc/starfive/jh71xx_pmu.c new file mode 100644 index 000000000000..e6c0083d166e --- /dev/null +++ b/drivers/soc/starfive/jh71xx_pmu.c @@ -0,0 +1,380 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * StarFive JH71XX Power Domain Controller Driver + * + * Copyright (C) 2022 StarFive Technology Co., Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* register offset */ +#define HW_EVENT_TURN_ON_MASK 0x04 +#define HW_EVENT_TURN_OFF_MASK 0x08 +#define SW_TURN_ON_POWER_MODE 0x0C +#define SW_TURN_OFF_POWER_MODE 0x10 +#define SW_ENCOURAGE 0x44 +#define PMU_INT_MASK 0x48 +#define PCH_BYPASS 0x4C +#define PCH_PSTATE 0x50 +#define PCH_TIMEOUT 0x54 +#define LP_TIMEOUT 0x58 +#define HW_TURN_ON_MODE 0x5C +#define CURR_POWER_MODE 0x80 +#define PMU_EVENT_STATUS 0x88 +#define PMU_INT_STATUS 0x8C + +/* sw encourage cfg */ +#define SW_MODE_ENCOURAGE_EN_LO 0x05 +#define SW_MODE_ENCOURAGE_EN_HI 0x50 +#define SW_MODE_ENCOURAGE_DIS_LO 0x0A +#define SW_MODE_ENCOURAGE_DIS_HI 0xA0 +#define SW_MODE_ENCOURAGE_ON 0xFF + +/* pmu int status */ +#define PMU_INT_SEQ_DONE BIT(0) +#define PMU_INT_HW_REQ BIT(1) +#define PMU_INT_SW_FAIL GENMASK(3, 2) +#define PMU_INT_HW_FAIL GENMASK(5, 4) +#define PMU_INT_PCH_FAIL GENMASK(8, 6) +#define PMU_INT_FAIL_MASK (PMU_INT_SW_FAIL | \ + PMU_INT_HW_FAIL | \ + PMU_INT_PCH_FAIL) +#define PMU_INT_ALL_MASK (PMU_INT_SEQ_DONE | \ + PMU_INT_HW_REQ | \ + PMU_INT_FAIL_MASK) + +#define DELAY_US 10 +#define TIMEOUT_US 100000 + +struct starfive_power_dev { + struct generic_pm_domain genpd; + struct starfive_pmu *power; + uint32_t mask; +}; + +struct starfive_pmu { + void __iomem *base; + spinlock_t lock; + int irq; + struct device *pdev; + struct starfive_power_dev *dev; + struct genpd_onecell_data genpd_data; + struct generic_pm_domain **genpd; +}; + +struct starfive_pmu_data { + const char * const name; + uint8_t bit; + unsigned int flags; +}; + +static void __iomem *pmu_base; + +static inline void pmu_writel(u32 val, u32 offset) +{ + writel(val, pmu_base + offset); +} + +void starfive_pmu_hw_event_turn_on(u32 mask) +{ + pmu_writel(mask, HW_EVENT_TURN_ON_MASK); +} +EXPORT_SYMBOL(starfive_pmu_hw_event_turn_on); + +void starfive_pmu_hw_event_turn_off(u32 mask) +{ + pmu_writel(mask, HW_EVENT_TURN_OFF_MASK); +} +EXPORT_SYMBOL(starfive_pmu_hw_event_turn_off); + +static int starfive_pmu_get_state(struct starfive_power_dev *pmd, bool *is_on) +{ + struct starfive_pmu *pmu = pmd->power; + + if (!pmd->mask) { + *is_on = false; + return -EINVAL; + } + + *is_on = __raw_readl(pmu->base + CURR_POWER_MODE) & pmd->mask; + + return 0; +} + +static int starfive_pmu_set_state(struct starfive_power_dev *pmd, bool on) +{ + struct starfive_pmu *pmu = pmd->power; + unsigned long flags; + uint32_t val; + uint32_t mode; + uint32_t encourage_lo; + uint32_t encourage_hi; + bool is_on; + int ret; + + if (!pmd->mask) + return -EINVAL; + + if (is_on == on) { + dev_info(pmu->pdev, "pm domain [%s] is already %sable status.\n", + pmd->genpd.name, on ? "en" : "dis"); + return 0; + } + + spin_lock_irqsave(&pmu->lock, flags); + + if (on) { + mode = SW_TURN_ON_POWER_MODE; + encourage_lo = SW_MODE_ENCOURAGE_EN_LO; + encourage_hi = SW_MODE_ENCOURAGE_EN_HI; + } else { + mode = SW_TURN_OFF_POWER_MODE; + encourage_lo = SW_MODE_ENCOURAGE_DIS_LO; + encourage_hi = SW_MODE_ENCOURAGE_DIS_HI; + } + + __raw_writel(pmd->mask, pmu->base + mode); + + /* write SW_ENCOURAGE to make the configuration take effect */ + __raw_writel(SW_MODE_ENCOURAGE_ON, pmu->base + SW_ENCOURAGE); + __raw_writel(encourage_lo, pmu->base + SW_ENCOURAGE); + __raw_writel(encourage_hi, pmu->base + SW_ENCOURAGE); + + spin_unlock_irqrestore(&pmu->lock, flags); + + if (on) { + ret = readl_poll_timeout_atomic(pmu->base + CURR_POWER_MODE, val, + val & pmd->mask, DELAY_US, + TIMEOUT_US); + if (ret) { + dev_err(pmu->pdev, "%s: failed to power on\n", pmd->genpd.name); + return -ETIMEDOUT; + } + } else { + ret = readl_poll_timeout_atomic(pmu->base + CURR_POWER_MODE, val, + !(val & pmd->mask), DELAY_US, + TIMEOUT_US); + if (ret) { + dev_err(pmu->pdev, "%s: failed to power off\n", pmd->genpd.name); + return -ETIMEDOUT; + } + } + + return 0; +} + +static int starfive_pmu_on(struct generic_pm_domain *genpd) +{ + struct starfive_power_dev *pmd = container_of(genpd, + struct starfive_power_dev, genpd); + + return starfive_pmu_set_state(pmd, true); +} + +static int starfive_pmu_off(struct generic_pm_domain *genpd) +{ + struct starfive_power_dev *pmd = container_of(genpd, + struct starfive_power_dev, genpd); + + return starfive_pmu_set_state(pmd, false); +} + +static void starfive_pmu_int_enable(struct starfive_pmu *pmu, u32 mask, bool enable) +{ + u32 val = __raw_readl(pmu->base + PMU_INT_MASK); + + if (enable) + val &= ~mask; + else + val |= mask; + + __raw_writel(val, pmu->base + PMU_INT_MASK); +} + +static irqreturn_t starfive_pmu_interrupt(int irq, void *data) +{ + struct starfive_pmu *pmu = data; + unsigned long flags; + u32 val; + + spin_lock_irqsave(&pmu->lock, flags); + val = __raw_readl(pmu->base + PMU_INT_STATUS); + + if (val & PMU_INT_SEQ_DONE) + dev_dbg(pmu->pdev, "sequence done.\n"); + if (val & PMU_INT_HW_REQ) + dev_dbg(pmu->pdev, "hardware encourage requestion.\n"); + if (val & PMU_INT_SW_FAIL) + dev_err(pmu->pdev, "software encourage fail.\n"); + if (val & PMU_INT_HW_FAIL) + dev_err(pmu->pdev, "hardware encourage fail.\n"); + if (val & PMU_INT_PCH_FAIL) + dev_err(pmu->pdev, "p-channel fail event.\n"); + + /* clear interrupts */ + __raw_writel(val, pmu->base + PMU_INT_STATUS); + __raw_writel(val, pmu->base + PMU_EVENT_STATUS); + + spin_unlock_irqrestore(&pmu->lock, flags); + + return IRQ_HANDLED; +} + +static int starfive_pmu_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; + const struct starfive_pmu_data *entry, *table; + struct starfive_pmu *pmu; + unsigned int i; + uint8_t max_bit = 0; + int ret; + + pmu = devm_kzalloc(dev, sizeof(*pmu), GFP_KERNEL); + if (!pmu) + return -ENOMEM; + + pmu_base = pmu->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(pmu->base)) + return PTR_ERR(pmu->base); + + /* initialize pmu interrupt */ + pmu->irq = platform_get_irq(pdev, 0); + if (pmu->irq < 0) + return pmu->irq; + + ret = devm_request_irq(dev, pmu->irq, starfive_pmu_interrupt, + 0, pdev->name, pmu); + if (ret) + dev_err(dev, "request irq failed.\n"); + + table = of_device_get_match_data(dev); + if (!table) + return -EINVAL; + + pmu->pdev = dev; + pmu->genpd_data.num_domains = 0; + i = 0; + for (entry = table; entry->name; entry++) { + max_bit = max(max_bit, entry->bit); + i++; + } + + if (!i) + return -ENODEV; + + pmu->genpd_data.num_domains = max_bit + 1; + + pmu->dev = devm_kcalloc(dev, pmu->genpd_data.num_domains, + sizeof(struct starfive_power_dev), + GFP_KERNEL); + if (!pmu->dev) + return -ENOMEM; + + pmu->genpd = devm_kcalloc(dev, pmu->genpd_data.num_domains, + sizeof(struct generic_pm_domain *), + GFP_KERNEL); + if (!pmu->genpd) + return -ENOMEM; + + pmu->genpd_data.domains = pmu->genpd; + + i = 0; + for (entry = table; entry->name; entry++) { + struct starfive_power_dev *pmd = &pmu->dev[i]; + bool is_on; + + pmd->power = pmu; + pmd->mask = BIT(entry->bit); + pmd->genpd.name = entry->name; + pmd->genpd.flags = entry->flags; + + ret = starfive_pmu_get_state(pmd, &is_on); + if (ret) + dev_warn(dev, "unable to get current state for %s\n", + pmd->genpd.name); + + pmd->genpd.power_on = starfive_pmu_on; + pmd->genpd.power_off = starfive_pmu_off; + + pm_genpd_init(&pmd->genpd, NULL, !is_on); + pmu->genpd[entry->bit] = &pmd->genpd; + + i++; + } + + spin_lock_init(&pmu->lock); + starfive_pmu_int_enable(pmu, PMU_INT_ALL_MASK & ~PMU_INT_PCH_FAIL, true); + + ret = of_genpd_add_provider_onecell(np, &pmu->genpd_data); + if (ret) { + dev_err(dev, "failed to register genpd driver: %d\n", ret); + return ret; + } + + dev_info(dev, "registered %u power domains\n", i); + + return 0; +} + +static const struct starfive_pmu_data jh7110_power_domains[] = { + { + .name = "SYSTOP", + .bit = JH7110_PD_SYSTOP, + .flags = GENPD_FLAG_ALWAYS_ON, + }, { + .name = "CPU", + .bit = JH7110_PD_CPU, + .flags = GENPD_FLAG_ALWAYS_ON, + }, { + .name = "GPUA", + .bit = JH7110_PD_GPUA, + }, { + .name = "VDEC", + .bit = JH7110_PD_VDEC, + }, { + .name = "VOUT", + .bit = JH7110_PD_VOUT, + }, { + .name = "ISP", + .bit = JH7110_PD_ISP, + }, { + .name = "VENC", + .bit = JH7110_PD_VENC, + }, { + .name = "GPUB", + .bit = JH7110_PD_GPUB, + }, { + /* sentinel */ + }, +}; + +static const struct of_device_id starfive_pmu_of_match[] = { + { + .compatible = "starfive,jh7110-pmu", + .data = &jh7110_power_domains, + }, { + /* sentinel */ + } +}; + +static struct platform_driver jh71xx_pmu_driver = { + .driver = { + .name = "jh71xx-pmu", + .of_match_table = starfive_pmu_of_match, + }, + .probe = starfive_pmu_probe, +}; +builtin_platform_driver(jh71xx_pmu_driver); + +MODULE_AUTHOR("Walker Chen "); +MODULE_DESCRIPTION("StarFive JH71XX Power Domain Driver"); +MODULE_LICENSE("GPL"); diff --git a/include/soc/starfive/pm_domains.h b/include/soc/starfive/pm_domains.h new file mode 100644 index 000000000000..a20e28e9baf3 --- /dev/null +++ b/include/soc/starfive/pm_domains.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2022 StarFive Technology Co., Ltd. + * Author: Walker Chen + */ + +#ifndef __SOC_STARFIVE_PMDOMAINS_H__ +#define __SOC_STARFIVE_PMDOMAINS_H__ + +#include + +void starfive_pmu_hw_event_turn_on(u32 mask); +void starfive_pmu_hw_event_turn_off(u32 mask); + +#endif /* __SOC_STARFIVE_PMDOMAINS_H__ */ From patchwork Fri Nov 18 13:32:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Walker Chen X-Patchwork-Id: 22335 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp206861wrr; Fri, 18 Nov 2022 05:56:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf4anKs8DcjEvV8u5sd5Snh5JprqEg2w2fZCZIQZruXHWEQd2EAkSu56/WwBc1ckS7shMDnK X-Received: by 2002:a05:6402:3808:b0:468:c911:d843 with SMTP id es8-20020a056402380800b00468c911d843mr6126298edb.422.1668779793648; Fri, 18 Nov 2022 05:56:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668779793; cv=none; d=google.com; s=arc-20160816; b=nTXaQpi0Rmz6sWv4jvqUIJJyPS+NAE4oznpyY/9GXkykP+Dx3Hxt+4okHTeAF5wtCG ka4JDT3S34z4DfAMokyN9hGDbDiTtjFgxnSVeqD9QbM+jA2Es0lz02G8JhwapyScOthD EVucrBbyZxCJO6QKYkQyzb0cqvPrbptt7GW2GF/Q0gmQzh2PZBHuWJbDo9m43pCSmeFX /1qWsZyMZgH62Jk/VUB0Y/mQoo+KkZ9PWMUY6ie8QsABn/WehcsSozVPMxyL+8BCBuXt jLPiRf0F3NBV+XR3di1Hq8tKLmZq6YQ4UJaDIQEVwXU5R07yXw+IuI6t+Jt7vWUvx3gF Q8QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=6Aq3MelE3dRN7Ly8U4jI2r8oGyjaDJfhD2uDssdFfXw=; b=BkWhQIAsQkvfOaGr10RWGbNupJ1Sa/soKeKGqXnqPnTzR+3IIVXVC11WgE0tKKUuHc Ep+Cful69qV08AUUGpsilRb01jybDLEZP380fbCUsYRlLVtsvZkr/LauBKzk2ly4sMUj 4+hFjIubf/rWkueWSLEbbpAnuFCSZWSaKnareQzNFRUtjKwbltuDX6Rwkjan7IKdmr/w dy/TU7uv8qMDiqYG4tpE3ZJZ28SxOjnDSJ14iS0r8UnlVVYD9cdI1HT8gFC9aGqHOD08 spQnKmPYTf9KQKD44Lmo/5HsEot3dxAyVaCfXc4fNzhckZhH7yOx0/vmD6NcEUZKQaMS NLjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hv11-20020a17090760cb00b007ad6a0afbc6si2934640ejc.7.2022.11.18.05.56.08; Fri, 18 Nov 2022 05:56:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242114AbiKRNgq (ORCPT + 99 others); Fri, 18 Nov 2022 08:36:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242243AbiKRNgQ (ORCPT ); Fri, 18 Nov 2022 08:36:16 -0500 X-Greylist: delayed 108 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 18 Nov 2022 05:34:19 PST Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBBCA942DF; Fri, 18 Nov 2022 05:34:18 -0800 (PST) Received: from EXMBX165.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX165", Issuer "EXMBX165" (not verified)) by fd01.gateway.ufhost.com (Postfix) with ESMTP id 0171224E287; Fri, 18 Nov 2022 21:32:30 +0800 (CST) Received: from EXMBX068.cuchost.com (172.16.6.68) by EXMBX165.cuchost.com (172.16.6.75) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 18 Nov 2022 21:32:30 +0800 Received: from localhost.localdomain (183.27.96.116) by EXMBX068.cuchost.com (172.16.6.68) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 18 Nov 2022 21:32:28 +0800 From: Walker Chen To: , , CC: Rob Herring , Krzysztof Kozlowski , Conor Dooley , "Rafael J . Wysocki" , Walker Chen , Subject: [PATCH v1 4/4] riscv: dts: starfive: add power controller node Date: Fri, 18 Nov 2022 21:32:16 +0800 Message-ID: <20221118133216.17037-5-walker.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221118133216.17037-1-walker.chen@starfivetech.com> References: <20221118133216.17037-1-walker.chen@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [183.27.96.116] X-ClientProxiedBy: EXCAS066.cuchost.com (172.16.6.26) To EXMBX068.cuchost.com (172.16.6.68) X-YovoleRuleAgent: yovoleflag X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749842441150372305?= X-GMAIL-MSGID: =?utf-8?q?1749842441150372305?= This adds the power controller node for the Starfive JH7110 SoC. The pmu needs to be used by other modules such as ISP, VPU, etc. Signed-off-by: Walker Chen --- arch/riscv/boot/dts/starfive/jh7110.dtsi | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/riscv/boot/dts/starfive/jh7110.dtsi b/arch/riscv/boot/dts/starfive/jh7110.dtsi index c22e8f1d2640..fa7b60b82d71 100644 --- a/arch/riscv/boot/dts/starfive/jh7110.dtsi +++ b/arch/riscv/boot/dts/starfive/jh7110.dtsi @@ -356,6 +356,13 @@ #gpio-cells = <2>; }; + pwrc: power-controller@17030000 { + compatible = "starfive,jh7110-pmu"; + reg = <0x0 0x17030000 0x0 0x10000>; + interrupts = <111>; + #power-domain-cells = <1>; + }; + uart0: serial@10000000 { compatible = "snps,dw-apb-uart"; reg = <0x0 0x10000000 0x0 0x10000>;