From patchwork Wed Apr 19 03:48:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 85174 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp88289vqo; Tue, 18 Apr 2023 21:18:29 -0700 (PDT) X-Google-Smtp-Source: AKy350a9YeWQqQ557LPEcs/zOyGR89I4S/Nki0NVcLRKyEj6u6s2E+yHP/SD7QYfmsLD8gRGKHx1 X-Received: by 2002:a17:90b:3847:b0:23f:7d05:8762 with SMTP id nl7-20020a17090b384700b0023f7d058762mr1509113pjb.23.1681877908993; Tue, 18 Apr 2023 21:18:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681877908; cv=none; d=google.com; s=arc-20160816; b=voan70dIFPlyUcGrhNoHwTYc6xw6SdaWdezmtxvIVU6GD50JaM/NbJeywpl2fKB2sD ewve0eKOr3yH7FdJ6jsaN6ZTWu0dKO89Drdn2IeVLK/qnQLyYenqfb8OYs2iCTtebOB6 +xsikPcNykiNZ6WwZaJVGaDuiEA5RthEPletUTrrNwjlANmfR9F790BBSIkcV7++24iz 32NqpRcSTZ2ekNJCohD9qvt018x94ZaDPaRQrpTcwoIMjYQ4RBLVuv4kjwev3PvmV3W2 lEW7qyttWkzxhc18yqOhbosp6EDYGE0iMTdLJ0PjZrvTYDwrMvh4nbQwVxoJ0Z/cJewp JNOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=m9Flctn0+e6it5urFPvxtd6VGQDrPUllruLEy/rO1pc=; b=VF23VpVOdfv7lGGygBqzDt7w1LL0b9b3zh8nwTmNUOcsPNNnXFA/7VDlWFOjwBK+C4 WBdgl6mukeLOvoh/YRJXgfwM+vVxA8qUz3dkMhjby6rYJqX5txDpcegMqtkP3jXSPjDO pGpJxMfONmKia3EekjoeXneHzLGGHbPvuEPRefuKruktKzwnZGWFxqwD7nB7a3GsWM2M KcTCTFj4G8gnjY/WKLsK4do4Co/3w27xG8Ua2CxZ50LkYUlwiBp3+HTHXudPoiOEA2Y5 nON+xqZDZJ119XkSLUYfGKXrfa5pCLj/QEGCxubyREgcL4HUJI9o1xI4+MmIz/plSv8f Of6A== 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 d9-20020a631d09000000b005138c1f1fd1si11915005pgd.857.2023.04.18.21.18.13; Tue, 18 Apr 2023 21:18:28 -0700 (PDT) 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 S232125AbjDSDtL convert rfc822-to-8bit (ORCPT + 99 others); Tue, 18 Apr 2023 23:49:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231980AbjDSDsq (ORCPT ); Tue, 18 Apr 2023 23:48:46 -0400 Received: from ex01.ufhost.com (ex01.ufhost.com [61.152.239.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7A208E; Tue, 18 Apr 2023 20:48:43 -0700 (PDT) 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 7D40724E24B; Wed, 19 Apr 2023 11:48:42 +0800 (CST) Received: from EXMBX162.cuchost.com (172.16.6.72) by EXMBX165.cuchost.com (172.16.6.75) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Wed, 19 Apr 2023 11:48:35 +0800 Received: from ubuntu.localdomain (113.72.144.253) by EXMBX162.cuchost.com (172.16.6.72) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Wed, 19 Apr 2023 11:48:35 +0800 From: Changhuang Liang To: Rob Herring , Krzysztof Kozlowski , Emil Renner Berthing , Conor Dooley , Paul Walmsley , Palmer Dabbelt , Albert Ou CC: Walker Chen , Changhuang Liang , Hal Feng , , , Subject: [PATCH v2 1/6] dt-bindings: power: Add JH7110 AON PMU support Date: Tue, 18 Apr 2023 20:48:27 -0700 Message-ID: <20230419034833.43243-2-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230419034833.43243-1-changhuang.liang@starfivetech.com> References: <20230419034833.43243-1-changhuang.liang@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [113.72.144.253] X-ClientProxiedBy: EXCAS064.cuchost.com (172.16.6.24) To EXMBX162.cuchost.com (172.16.6.72) X-YovoleRuleAgent: yovoleflag X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1763576810000958635?= X-GMAIL-MSGID: =?utf-8?q?1763576810000958635?= Add AON PMU for StarFive JH7110 SoC, it can be used to turn on/off DPHY rx/tx power switch, and it don't need the properties of reg and interrupts. Signed-off-by: Changhuang Liang Reviewed-by: Krzysztof Kozlowski --- .../bindings/power/starfive,jh7110-pmu.yaml | 15 +++++++++++++-- include/dt-bindings/power/starfive,jh7110-pmu.h | 3 +++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/power/starfive,jh7110-pmu.yaml b/Documentation/devicetree/bindings/power/starfive,jh7110-pmu.yaml index 98eb8b4110e7..c50507c38e14 100644 --- a/Documentation/devicetree/bindings/power/starfive,jh7110-pmu.yaml +++ b/Documentation/devicetree/bindings/power/starfive,jh7110-pmu.yaml @@ -8,6 +8,7 @@ title: StarFive JH7110 Power Management Unit maintainers: - Walker Chen + - Changhuang Liang description: | StarFive JH7110 SoC includes support for multiple power domains which can be @@ -17,6 +18,7 @@ properties: compatible: enum: - starfive,jh7110-pmu + - starfive,jh7110-aon-pmu reg: maxItems: 1 @@ -29,10 +31,19 @@ properties: required: - compatible - - reg - - interrupts - "#power-domain-cells" +allOf: + - if: + properties: + compatible: + contains: + const: starfive,jh7110-pmu + then: + required: + - reg + - interrupts + additionalProperties: false examples: diff --git a/include/dt-bindings/power/starfive,jh7110-pmu.h b/include/dt-bindings/power/starfive,jh7110-pmu.h index 132bfe401fc8..0bfd6700c144 100644 --- a/include/dt-bindings/power/starfive,jh7110-pmu.h +++ b/include/dt-bindings/power/starfive,jh7110-pmu.h @@ -14,4 +14,7 @@ #define JH7110_PD_ISP 5 #define JH7110_PD_VENC 6 +#define JH7110_PD_DPHY_TX 0 +#define JH7110_PD_DPHY_RX 1 + #endif From patchwork Wed Apr 19 03:48:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 85170 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp83956vqo; Tue, 18 Apr 2023 21:09:36 -0700 (PDT) X-Google-Smtp-Source: AKy350Zk1+b7Qqg6R4p+IEyDRtAJC7JWnVgQkwkx0I122DkYkZ/k+pc2msvP8ifodUMFRs2oyazP X-Received: by 2002:a17:90b:3e84:b0:24b:2794:9a31 with SMTP id rj4-20020a17090b3e8400b0024b27949a31mr28609pjb.48.1681877376424; Tue, 18 Apr 2023 21:09:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681877376; cv=none; d=google.com; s=arc-20160816; b=DvMgutcYgC6q6IrGvEpLXsfPCtTaKhJ5nuXLXef+6o/ATyy7oH69cxGR6Fl4WciAek j/kWHizUzrKjkpZh25/yjU24Lo/O/EtHbosl9MSz7HmEtVzNN9W3dy5uE18gi1TyW88j SacMihrAQ0jSSpPCp7Rp+hr0kFxLQzSj9pi+2h47xwEcq+Fwry1VYvtIkglgkSiyikYY MH+SX8I95/jG9D6UPEwpkfxlq0cakJ4xwJQfAAbCAnnoLrsuv3zopwm3Igvs4Z4Mz4PO xaS76xxCx4YHeAEfWfAuMRE22GD9xnJ5/3UyMdQkyy3J5tTEDT18v5raSb8W7TDeX4Tv Q6+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=yLjraBv0R+hcPu8OXcD047J89FdyGplTTiZhgPX21HM=; b=0AqwoHLU4xfKzPl+heZNBQVKRaSefu6SorObyKoqH8Iv6raeGhcvTbp9KGYCN7yMy6 zdeEzmBAPJmrRnaG+HuZEdRE40KaTyhBU20I4g9Ohc6JGUXleWtl13HII6DVzRip0a4d eULKm8Yf9pamqoZ6nd2B946GHnq5sV87NMnvH16aZfuwC4lLb9f3Hal6dwlGbod0R7Df Nn8VSB68qIF7WkLkh1egFAEwBtiIVt65CywTbpOAnL/V0zksJFuJ4IgEE+Uqkj/UeVJR F8UQ7JdVIEhkdmW7gPy39p+6MXW7wMA3d7PiWhspHobCKcES4OL3XLVwDtzbrd72T0pb FkzQ== 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 mh18-20020a17090b4ad200b002471589f0d9si677862pjb.95.2023.04.18.21.09.23; Tue, 18 Apr 2023 21:09:36 -0700 (PDT) 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 S232172AbjDSDtF convert rfc822-to-8bit (ORCPT + 99 others); Tue, 18 Apr 2023 23:49:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231825AbjDSDsm (ORCPT ); Tue, 18 Apr 2023 23:48:42 -0400 Received: from ex01.ufhost.com (ex01.ufhost.com [61.152.239.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25A542688; Tue, 18 Apr 2023 20:48:38 -0700 (PDT) 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 A32E724E23E; Wed, 19 Apr 2023 11:48:36 +0800 (CST) Received: from EXMBX162.cuchost.com (172.16.6.72) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Wed, 19 Apr 2023 11:48:36 +0800 Received: from ubuntu.localdomain (113.72.144.253) by EXMBX162.cuchost.com (172.16.6.72) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Wed, 19 Apr 2023 11:48:35 +0800 From: Changhuang Liang To: Rob Herring , Krzysztof Kozlowski , Emil Renner Berthing , Conor Dooley , Paul Walmsley , Palmer Dabbelt , Albert Ou CC: Walker Chen , Changhuang Liang , Hal Feng , , , Subject: [PATCH v2 2/6] soc: starfive: Replace SOC_STARFIVE with ARCH_STARFIVE Date: Tue, 18 Apr 2023 20:48:28 -0700 Message-ID: <20230419034833.43243-3-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230419034833.43243-1-changhuang.liang@starfivetech.com> References: <20230419034833.43243-1-changhuang.liang@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [113.72.144.253] X-ClientProxiedBy: EXCAS064.cuchost.com (172.16.6.24) To EXMBX162.cuchost.com (172.16.6.72) X-YovoleRuleAgent: yovoleflag X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1763576251591247882?= X-GMAIL-MSGID: =?utf-8?q?1763576251591247882?= Using ARCH_FOO symbol is preferred than SOC_FOO. Reviewed-by: Conor Dooley Reviewed-by: Walker Chen Signed-off-by: Changhuang Liang --- drivers/soc/starfive/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/soc/starfive/Kconfig b/drivers/soc/starfive/Kconfig index bdb96dc4c989..1e9b0c414fec 100644 --- a/drivers/soc/starfive/Kconfig +++ b/drivers/soc/starfive/Kconfig @@ -3,8 +3,8 @@ config JH71XX_PMU bool "Support PMU for StarFive JH71XX Soc" depends on PM - depends on SOC_STARFIVE || COMPILE_TEST - default SOC_STARFIVE + depends on ARCH_STARFIVE || COMPILE_TEST + default ARCH_STARFIVE select PM_GENERIC_DOMAINS help Say 'y' here to enable support power domain support. From patchwork Wed Apr 19 03:48:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 85165 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp78335vqo; Tue, 18 Apr 2023 20:57:29 -0700 (PDT) X-Google-Smtp-Source: AKy350a79T8snqu+0jVljWEjAGwdZvkIJ6A6BBL4DOqnctHtAS4pXGZcV7/Atnt4Q+fkeDAcXmO4 X-Received: by 2002:a05:6a20:9144:b0:ef:d2c1:62a with SMTP id x4-20020a056a20914400b000efd2c1062amr2190140pzc.19.1681876648996; Tue, 18 Apr 2023 20:57:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681876648; cv=none; d=google.com; s=arc-20160816; b=KCcA4Fq9pksv+++e0av04NSOgU8UwA6BZ99UKOHSO43ESWadCcaukOXZ4dFky5PsGz ykWsrySFL6l1nul4LZFO7XBeFBPw3eBI9ipt0gqzotJPyOBqlzaacHy7pkAF7WxYiEvG Z+mWrLVXErRR3Op6Cd9DB8+mkQlHw23x9XiggQtatzWU665T1a+4pNWEJjC3Ta/C4sjS ujBZZBxgnmFW2cR9gRHuT5hxt/48coOyyEfoeFPqjIiCxqhQE0pwCShDbEGB04V7xs9i tvjUo0CBXgWwOFz4DGLomtqHL/F+Ee0ts+6OwKiFZ4AAAkpIQVA2wXaXXA48GmD0r6ax ENFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=B6am3JVk4pOzogMRQja1q/124qcwwqH/qfd6wGiMp8c=; b=VCI9rRAVHXC74VdWt3WPvk+/zu04shTqS3vEK/i6iAgWkS9Gv1lMUwRLnb2/9+6T57 LlLt+Tljgrj8aDKa+SijLb+H3KUWD1A4xz2MmEcvoXr/8icyb6JkpYsRhgTeQSOG9y32 4AaygUTGb3ZD887eu0FXoumT59NKElj1Fuve6NgrDyGtmWsT/R/4c8Fi1CIjif2qpvz2 NDwlCNhFbEMFFeS8qLHWJzSg4pp83BLZrCVxoeamVxY9r2wDN5SxIvAOLztNDn9+78Q0 gGAKDofk2szP9LZioGewKfoU4tQDtA+O9KCaWHp3dH1/Hjp0Pjd57XTgR/Nc2BVFfLuo 8mVQ== 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 b189-20020a6367c6000000b0051f179c48e9si2867066pgc.684.2023.04.18.20.57.16; Tue, 18 Apr 2023 20:57:28 -0700 (PDT) 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 S232070AbjDSDtY convert rfc822-to-8bit (ORCPT + 99 others); Tue, 18 Apr 2023 23:49:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232001AbjDSDsr (ORCPT ); Tue, 18 Apr 2023 23:48:47 -0400 Received: from ex01.ufhost.com (ex01.ufhost.com [61.152.239.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05471D8; Tue, 18 Apr 2023 20:48:44 -0700 (PDT) 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 9189824E250; Wed, 19 Apr 2023 11:48:42 +0800 (CST) Received: from EXMBX162.cuchost.com (172.16.6.72) by EXMBX165.cuchost.com (172.16.6.75) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Wed, 19 Apr 2023 11:48:37 +0800 Received: from ubuntu.localdomain (113.72.144.253) by EXMBX162.cuchost.com (172.16.6.72) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Wed, 19 Apr 2023 11:48:36 +0800 From: Changhuang Liang To: Rob Herring , Krzysztof Kozlowski , Emil Renner Berthing , Conor Dooley , Paul Walmsley , Palmer Dabbelt , Albert Ou CC: Walker Chen , Changhuang Liang , Hal Feng , , , Subject: [PATCH v2 3/6] soc: starfive: Modify ioremap to regmap Date: Tue, 18 Apr 2023 20:48:29 -0700 Message-ID: <20230419034833.43243-4-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230419034833.43243-1-changhuang.liang@starfivetech.com> References: <20230419034833.43243-1-changhuang.liang@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [113.72.144.253] X-ClientProxiedBy: EXCAS064.cuchost.com (172.16.6.24) To EXMBX162.cuchost.com (172.16.6.72) X-YovoleRuleAgent: yovoleflag X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1763575489122497958?= X-GMAIL-MSGID: =?utf-8?q?1763575489122497958?= Modify ioremap to regmap which can be compatible with the syscon interface, such as: struct regmap *syscon_node_to_regmap(struct device_node *np) Convenient introduction of syscon operation. Signed-off-by: Changhuang Liang --- drivers/soc/starfive/jh71xx_pmu.c | 43 +++++++++++++++++-------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/drivers/soc/starfive/jh71xx_pmu.c b/drivers/soc/starfive/jh71xx_pmu.c index 7d5f50d71c0d..306218c83691 100644 --- a/drivers/soc/starfive/jh71xx_pmu.c +++ b/drivers/soc/starfive/jh71xx_pmu.c @@ -6,13 +6,13 @@ */ #include -#include -#include +#include #include #include #include #include #include +#include #include /* register offset */ @@ -59,7 +59,7 @@ struct jh71xx_pmu_match_data { struct jh71xx_pmu { struct device *dev; const struct jh71xx_pmu_match_data *match_data; - void __iomem *base; + struct regmap *base; struct generic_pm_domain **genpd; struct genpd_onecell_data genpd_data; int irq; @@ -75,11 +75,14 @@ struct jh71xx_pmu_dev { static int jh71xx_pmu_get_state(struct jh71xx_pmu_dev *pmd, u32 mask, bool *is_on) { struct jh71xx_pmu *pmu = pmd->pmu; + unsigned int val; if (!mask) return -EINVAL; - *is_on = readl(pmu->base + JH71XX_PMU_CURR_POWER_MODE) & mask; + regmap_read(pmu->base, JH71XX_PMU_CURR_POWER_MODE, &val); + + *is_on = val & mask; return 0; } @@ -130,7 +133,7 @@ static int jh71xx_pmu_set_state(struct jh71xx_pmu_dev *pmd, u32 mask, bool on) encourage_hi = JH71XX_PMU_SW_ENCOURAGE_DIS_HI; } - writel(mask, pmu->base + mode); + regmap_write(pmu->base, mode, mask); /* * 2.Write SW encourage command sequence to the Software Encourage Reg (offset 0x44) @@ -140,21 +143,21 @@ static int jh71xx_pmu_set_state(struct jh71xx_pmu_dev *pmd, u32 mask, bool on) * Then write the lower bits of the command sequence, followed by the upper * bits. The sequence differs between powering on & off a domain. */ - writel(JH71XX_PMU_SW_ENCOURAGE_ON, pmu->base + JH71XX_PMU_SW_ENCOURAGE); - writel(encourage_lo, pmu->base + JH71XX_PMU_SW_ENCOURAGE); - writel(encourage_hi, pmu->base + JH71XX_PMU_SW_ENCOURAGE); + regmap_write(pmu->base, JH71XX_PMU_SW_ENCOURAGE, JH71XX_PMU_SW_ENCOURAGE_ON); + regmap_write(pmu->base, JH71XX_PMU_SW_ENCOURAGE, encourage_lo); + regmap_write(pmu->base, JH71XX_PMU_SW_ENCOURAGE, encourage_hi); spin_unlock_irqrestore(&pmu->lock, flags); /* Wait for the power domain bit to be enabled / disabled */ if (on) { - ret = readl_poll_timeout_atomic(pmu->base + JH71XX_PMU_CURR_POWER_MODE, - val, val & mask, - 1, JH71XX_PMU_TIMEOUT_US); + ret = regmap_read_poll_timeout_atomic(pmu->base, JH71XX_PMU_CURR_POWER_MODE, + val, val & mask, + 1, JH71XX_PMU_TIMEOUT_US); } else { - ret = readl_poll_timeout_atomic(pmu->base + JH71XX_PMU_CURR_POWER_MODE, - val, !(val & mask), - 1, JH71XX_PMU_TIMEOUT_US); + ret = regmap_read_poll_timeout_atomic(pmu->base, JH71XX_PMU_CURR_POWER_MODE, + val, !(val & mask), + 1, JH71XX_PMU_TIMEOUT_US); } if (ret) { @@ -190,14 +193,14 @@ static void jh71xx_pmu_int_enable(struct jh71xx_pmu *pmu, u32 mask, bool enable) unsigned long flags; spin_lock_irqsave(&pmu->lock, flags); - val = readl(pmu->base + JH71XX_PMU_TIMER_INT_MASK); + regmap_read(pmu->base, JH71XX_PMU_TIMER_INT_MASK, &val); if (enable) val &= ~mask; else val |= mask; - writel(val, pmu->base + JH71XX_PMU_TIMER_INT_MASK); + regmap_write(pmu->base, JH71XX_PMU_TIMER_INT_MASK, val); spin_unlock_irqrestore(&pmu->lock, flags); } @@ -206,7 +209,7 @@ static irqreturn_t jh71xx_pmu_interrupt(int irq, void *data) struct jh71xx_pmu *pmu = data; u32 val; - val = readl(pmu->base + JH71XX_PMU_INT_STATUS); + regmap_read(pmu->base, JH71XX_PMU_INT_STATUS, &val); if (val & JH71XX_PMU_INT_SEQ_DONE) dev_dbg(pmu->dev, "sequence done.\n"); @@ -220,8 +223,8 @@ static irqreturn_t jh71xx_pmu_interrupt(int irq, void *data) dev_err(pmu->dev, "p-channel fail event.\n"); /* clear interrupts */ - writel(val, pmu->base + JH71XX_PMU_INT_STATUS); - writel(val, pmu->base + JH71XX_PMU_EVENT_STATUS); + regmap_write(pmu->base, JH71XX_PMU_INT_STATUS, val); + regmap_write(pmu->base, JH71XX_PMU_EVENT_STATUS, val); return IRQ_HANDLED; } @@ -271,7 +274,7 @@ static int jh71xx_pmu_probe(struct platform_device *pdev) if (!pmu) return -ENOMEM; - pmu->base = devm_platform_ioremap_resource(pdev, 0); + pmu->base = device_node_to_regmap(np); if (IS_ERR(pmu->base)) return PTR_ERR(pmu->base); From patchwork Wed Apr 19 03:48:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 85162 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp77823vqo; Tue, 18 Apr 2023 20:56:00 -0700 (PDT) X-Google-Smtp-Source: AKy350aiVJFL3jTZKcpAkQxTopEC8XilmYJToTvrgEPV1a4OCwn6EL6LHRjDGCb4TRQpxbI5EzRQ X-Received: by 2002:a17:902:7c10:b0:1a6:fe25:4138 with SMTP id x16-20020a1709027c1000b001a6fe254138mr3730527pll.59.1681876560252; Tue, 18 Apr 2023 20:56:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681876560; cv=none; d=google.com; s=arc-20160816; b=UP4RIXbas3xbb/nN0ZE35VeMm1eCTMArH4+d1L5zcTiT/85YLPqh9GHMKWrRO7ijAP M+42Y7dlUT1hrnXTCkjjzM+YhCflt9/7uoslqEB+sN1tJ/j18w9WHDwYlMod/MtKJc2+ IqH/6dPNWe7jt7LETUqvOk9c9EX8aMW2ZlmWpKaDdPuYvEMDFzGIlMOk892NZYNmSglc wTcDjXwiigIx/mwUvxRpHUNh5p5BFxffAN1SICghnsJivSQGp6B40Bj0OoG1/IC4IS44 UoG61KG8OvApVYDaLMhBXgUVTm6ZiIX5mRVvktuGkepZxONPMZikx7d+w2lo/Z4qLY02 u3CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=82QnXzNKTa9Wpj00iqDycLkXG/ukc4lK0EcQ0u8+zsA=; b=ybuZQB7iPg+3U1XmZzispoA9K2NjGKG9AecHQgJdnMtdK+exnGW1bUhJcoeR5c1RiK X6zKJ0CozjZcTQbxmeplyUH29nECDY/waLMfmNIQaneQ5W/uWcJ8oJcRfYbMvr2X/Yxe Kwgk5lqqm1eDRl2oLpA4usOGFS81uwE32H+rQieOQ5qE+68KyJEyk4habpZ6iB+KhVQo TRFuOeria+HUSwSc4jAA5VpDYD0BHJBWOxQk/UFsqjicuBpMzLXbQFZXKWJAaC2VxzHu tPELI1mZOxWdbYLwQdDafq+JvvTQ9sryYQeW8/HPijU2z6t/XcRmHRWy9upXndBnwomp VkWQ== 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 f13-20020a170902ce8d00b001a6b341b278si10461299plg.399.2023.04.18.20.55.48; Tue, 18 Apr 2023 20:56:00 -0700 (PDT) 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 S232019AbjDSDtC convert rfc822-to-8bit (ORCPT + 99 others); Tue, 18 Apr 2023 23:49:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231895AbjDSDsm (ORCPT ); Tue, 18 Apr 2023 23:48:42 -0400 Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D9E235BF; Tue, 18 Apr 2023 20:48:39 -0700 (PDT) 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 146A124E227; Wed, 19 Apr 2023 11:48:38 +0800 (CST) Received: from EXMBX162.cuchost.com (172.16.6.72) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Wed, 19 Apr 2023 11:48:37 +0800 Received: from ubuntu.localdomain (113.72.144.253) by EXMBX162.cuchost.com (172.16.6.72) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Wed, 19 Apr 2023 11:48:37 +0800 From: Changhuang Liang To: Rob Herring , Krzysztof Kozlowski , Emil Renner Berthing , Conor Dooley , Paul Walmsley , Palmer Dabbelt , Albert Ou CC: Walker Chen , Changhuang Liang , Hal Feng , , , Subject: [PATCH v2 4/6] soc: starfive: Extract JH7110 pmu private operations Date: Tue, 18 Apr 2023 20:48:30 -0700 Message-ID: <20230419034833.43243-5-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230419034833.43243-1-changhuang.liang@starfivetech.com> References: <20230419034833.43243-1-changhuang.liang@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [113.72.144.253] X-ClientProxiedBy: EXCAS064.cuchost.com (172.16.6.24) To EXMBX162.cuchost.com (172.16.6.72) X-YovoleRuleAgent: yovoleflag X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1763575395965567317?= X-GMAIL-MSGID: =?utf-8?q?1763575395965567317?= Move JH7110 private operation into private data of compatible. Convenient to expand different compatible. Signed-off-by: Changhuang Liang --- drivers/soc/starfive/jh71xx_pmu.c | 98 +++++++++++++++++++++---------- 1 file changed, 67 insertions(+), 31 deletions(-) diff --git a/drivers/soc/starfive/jh71xx_pmu.c b/drivers/soc/starfive/jh71xx_pmu.c index 306218c83691..bb44cc93e822 100644 --- a/drivers/soc/starfive/jh71xx_pmu.c +++ b/drivers/soc/starfive/jh71xx_pmu.c @@ -51,9 +51,17 @@ struct jh71xx_domain_info { u8 bit; }; +struct jh71xx_pmu; +struct jh71xx_pmu_dev; + struct jh71xx_pmu_match_data { const struct jh71xx_domain_info *domain_info; int num_domains; + unsigned int pmu_status; + int (*pmu_parse_dt)(struct platform_device *pdev, + struct jh71xx_pmu *pmu); + int (*pmu_set_state)(struct jh71xx_pmu_dev *pmd, + u32 mask, bool on); }; struct jh71xx_pmu { @@ -80,14 +88,14 @@ static int jh71xx_pmu_get_state(struct jh71xx_pmu_dev *pmd, u32 mask, bool *is_o if (!mask) return -EINVAL; - regmap_read(pmu->base, JH71XX_PMU_CURR_POWER_MODE, &val); + regmap_read(pmu->base, pmu->match_data->pmu_status, &val); *is_on = val & mask; return 0; } -static int jh71xx_pmu_set_state(struct jh71xx_pmu_dev *pmd, u32 mask, bool on) +static int jh7110_pmu_set_state(struct jh71xx_pmu_dev *pmd, u32 mask, bool on) { struct jh71xx_pmu *pmu = pmd->pmu; unsigned long flags; @@ -95,22 +103,8 @@ static int jh71xx_pmu_set_state(struct jh71xx_pmu_dev *pmd, u32 mask, bool on) u32 mode; u32 encourage_lo; u32 encourage_hi; - bool is_on; int ret; - ret = jh71xx_pmu_get_state(pmd, mask, &is_on); - if (ret) { - dev_dbg(pmu->dev, "unable to get current state for %s\n", - pmd->genpd.name); - return ret; - } - - if (is_on == on) { - dev_dbg(pmu->dev, "pm domain [%s] is already %sable status.\n", - pmd->genpd.name, on ? "en" : "dis"); - return 0; - } - spin_lock_irqsave(&pmu->lock, flags); /* @@ -169,6 +163,29 @@ static int jh71xx_pmu_set_state(struct jh71xx_pmu_dev *pmd, u32 mask, bool on) return 0; } +static int jh71xx_pmu_set_state(struct jh71xx_pmu_dev *pmd, u32 mask, bool on) +{ + struct jh71xx_pmu *pmu = pmd->pmu; + const struct jh71xx_pmu_match_data *match_data = pmu->match_data; + bool is_on; + int ret; + + ret = jh71xx_pmu_get_state(pmd, mask, &is_on); + if (ret) { + dev_dbg(pmu->dev, "unable to get current state for %s\n", + pmd->genpd.name); + return ret; + } + + if (is_on == on) { + dev_dbg(pmu->dev, "pm domain [%s] is already %sable status.\n", + pmd->genpd.name, on ? "en" : "dis"); + return 0; + } + + return match_data->pmu_set_state(pmd, mask, on); +} + static int jh71xx_pmu_on(struct generic_pm_domain *genpd) { struct jh71xx_pmu_dev *pmd = container_of(genpd, @@ -229,6 +246,30 @@ static irqreturn_t jh71xx_pmu_interrupt(int irq, void *data) return IRQ_HANDLED; } +static int jh7110_pmu_parse_dt(struct platform_device *pdev, struct jh71xx_pmu *pmu) +{ + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; + int ret; + + pmu->base = device_node_to_regmap(np); + if (IS_ERR(pmu->base)) + return PTR_ERR(pmu->base); + + pmu->irq = platform_get_irq(pdev, 0); + if (pmu->irq < 0) + return pmu->irq; + + ret = devm_request_irq(dev, pmu->irq, jh71xx_pmu_interrupt, + 0, pdev->name, pmu); + if (ret) + dev_err(dev, "failed to request irq\n"); + + jh71xx_pmu_int_enable(pmu, JH71XX_PMU_INT_ALL_MASK & ~JH71XX_PMU_INT_PCH_FAIL, true); + + return 0; +} + static int jh71xx_pmu_init_domain(struct jh71xx_pmu *pmu, int index) { struct jh71xx_pmu_dev *pmd; @@ -274,23 +315,18 @@ static int jh71xx_pmu_probe(struct platform_device *pdev) if (!pmu) return -ENOMEM; - pmu->base = device_node_to_regmap(np); - if (IS_ERR(pmu->base)) - return PTR_ERR(pmu->base); - - pmu->irq = platform_get_irq(pdev, 0); - if (pmu->irq < 0) - return pmu->irq; - - ret = devm_request_irq(dev, pmu->irq, jh71xx_pmu_interrupt, - 0, pdev->name, pmu); - if (ret) - dev_err(dev, "failed to request irq\n"); + spin_lock_init(&pmu->lock); match_data = of_device_get_match_data(dev); if (!match_data) return -EINVAL; + ret = match_data->pmu_parse_dt(pdev, pmu); + if (ret) { + dev_err(dev, "failed to parse dt\n"); + return ret; + } + pmu->genpd = devm_kcalloc(dev, match_data->num_domains, sizeof(struct generic_pm_domain *), GFP_KERNEL); @@ -310,9 +346,6 @@ static int jh71xx_pmu_probe(struct platform_device *pdev) } } - spin_lock_init(&pmu->lock); - jh71xx_pmu_int_enable(pmu, JH71XX_PMU_INT_ALL_MASK & ~JH71XX_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); @@ -360,6 +393,9 @@ static const struct jh71xx_domain_info jh7110_power_domains[] = { static const struct jh71xx_pmu_match_data jh7110_pmu = { .num_domains = ARRAY_SIZE(jh7110_power_domains), .domain_info = jh7110_power_domains, + .pmu_status = JH71XX_PMU_CURR_POWER_MODE, + .pmu_parse_dt = jh7110_pmu_parse_dt, + .pmu_set_state = jh7110_pmu_set_state, }; static const struct of_device_id jh71xx_pmu_of_match[] = { From patchwork Wed Apr 19 03:48:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 85164 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp78318vqo; Tue, 18 Apr 2023 20:57:26 -0700 (PDT) X-Google-Smtp-Source: AKy350ayk8Mig3l6J2BPnTwE2x3Ae5C6gSh5G5syMDVlDrt1oAXxdCU8wrML4WR1281aW/EWkOO2 X-Received: by 2002:a17:902:dacf:b0:1a6:669f:18ae with SMTP id q15-20020a170902dacf00b001a6669f18aemr4333126plx.67.1681876646284; Tue, 18 Apr 2023 20:57:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681876646; cv=none; d=google.com; s=arc-20160816; b=qO7e+hB+9/8zaHgkHQ2k+/Ar1bZfyQeaA1nrXXtbwcpH7rna6gXIcw6NgnWvpAcGtO S3qn0ZR0dL+8kvG+I93sdljvFqc91ysXMPxeZoowYO8A1mD3h5io2vGVwptoei9G4L9H APi16EqBILDWQCpgR/vCj/g23PUb2Co6HOIU0TncQzBWEQPRMZKHgApMYTNN4kwwe73k /3bBdKRoH52K4FZhphL65k/BHXmMznxfgQw5G8TIc2Jpy36eYWzwY7VcLYwfqStE0Tiy VEFNmVozWNI2LP5kDyd7obOVCaZYkEdqNsJX/PaoezQ81/4eJz5lO22312kWXosvCa3O 2AqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=yS+l60BTSWXhS/cRdpAY9b/EKvj/OQJqZYXYJyLCVjs=; b=Lvs88a/fTSDVKEZ05i8WikXaqF3cUvq2LqEbJCRkJ5z8rWvpWC8/ILiuiUyELnlWjx ODUCvPmCR2/Ew3v1Z+BKrBDBGHbhXcfZU43io6ZAqg7qfLHt5NLOZiiuUQrLeC2ZmT71 Kj+twOy/yTu/T8H+MyY21wLTFcOFqUA4a7GtKVlcPi+1zFDyJLU/IaJ0uvFH0+3q6Rn+ RDi5jZw0kggsJtgecWOVCWPmKJWNjNRSmFzF5c2ypRBIZ3sJXxIGKnRimii81eYGmQKW eTxEQlhE7myWfKuZrEhaeNNibFpU3ficphG3DrANRCKrWbdEwNyppnibtfJ833t86RlG 3EfQ== 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 x24-20020a63db58000000b005193a2c7b1esi1983107pgi.447.2023.04.18.20.57.14; Tue, 18 Apr 2023 20:57:26 -0700 (PDT) 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 S232163AbjDSDtV convert rfc822-to-8bit (ORCPT + 99 others); Tue, 18 Apr 2023 23:49:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232000AbjDSDsr (ORCPT ); Tue, 18 Apr 2023 23:48:47 -0400 Received: from ex01.ufhost.com (ex01.ufhost.com [61.152.239.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 238D4558D; Tue, 18 Apr 2023 20:48:44 -0700 (PDT) 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 B30CE24E251; Wed, 19 Apr 2023 11:48:42 +0800 (CST) Received: from EXMBX162.cuchost.com (172.16.6.72) by EXMBX165.cuchost.com (172.16.6.75) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Wed, 19 Apr 2023 11:48:38 +0800 Received: from ubuntu.localdomain (113.72.144.253) by EXMBX162.cuchost.com (172.16.6.72) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Wed, 19 Apr 2023 11:48:37 +0800 From: Changhuang Liang To: Rob Herring , Krzysztof Kozlowski , Emil Renner Berthing , Conor Dooley , Paul Walmsley , Palmer Dabbelt , Albert Ou CC: Walker Chen , Changhuang Liang , Hal Feng , , , Subject: [PATCH v2 5/6] soc: starfive: Add JH7110 AON PMU support Date: Tue, 18 Apr 2023 20:48:31 -0700 Message-ID: <20230419034833.43243-6-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230419034833.43243-1-changhuang.liang@starfivetech.com> References: <20230419034833.43243-1-changhuang.liang@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [113.72.144.253] X-ClientProxiedBy: EXCAS064.cuchost.com (172.16.6.24) To EXMBX162.cuchost.com (172.16.6.72) X-YovoleRuleAgent: yovoleflag X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1763575486077144507?= X-GMAIL-MSGID: =?utf-8?q?1763575486077144507?= Add AON PMU for StarFive JH7110 SoC. It can be used to turn on/off the dphy rx/tx power switch. Reviewed-by: Walker Chen Signed-off-by: Changhuang Liang --- MAINTAINERS | 1 + drivers/soc/starfive/jh71xx_pmu.c | 63 ++++++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 0fafeea8ebdb..8f32d43a9b67 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19950,6 +19950,7 @@ F: include/dt-bindings/reset/starfive?jh71*.h STARFIVE JH71XX PMU CONTROLLER DRIVER M: Walker Chen +M: Changhuang Liang S: Supported F: Documentation/devicetree/bindings/power/starfive* F: drivers/soc/starfive/jh71xx_pmu.c diff --git a/drivers/soc/starfive/jh71xx_pmu.c b/drivers/soc/starfive/jh71xx_pmu.c index bb44cc93e822..1303826aa7b5 100644 --- a/drivers/soc/starfive/jh71xx_pmu.c +++ b/drivers/soc/starfive/jh71xx_pmu.c @@ -2,7 +2,7 @@ /* * StarFive JH71XX PMU (Power Management Unit) Controller Driver * - * Copyright (C) 2022 StarFive Technology Co., Ltd. + * Copyright (C) 2022-2023 StarFive Technology Co., Ltd. */ #include @@ -24,6 +24,9 @@ #define JH71XX_PMU_EVENT_STATUS 0x88 #define JH71XX_PMU_INT_STATUS 0x8C +/* aon pmu register offset */ +#define JH71XX_AON_PMU_SWITCH 0x00 + /* sw encourage cfg */ #define JH71XX_PMU_SW_ENCOURAGE_EN_LO 0x05 #define JH71XX_PMU_SW_ENCOURAGE_EN_HI 0x50 @@ -163,6 +166,23 @@ static int jh7110_pmu_set_state(struct jh71xx_pmu_dev *pmd, u32 mask, bool on) return 0; } +static int jh7110_aon_pmu_set_state(struct jh71xx_pmu_dev *pmd, u32 mask, bool on) +{ + struct jh71xx_pmu *pmu = pmd->pmu; + unsigned long flags; + + spin_lock_irqsave(&pmu->lock, flags); + + if (on) + regmap_update_bits(pmu->base, JH71XX_AON_PMU_SWITCH, mask, mask); + else + regmap_update_bits(pmu->base, JH71XX_AON_PMU_SWITCH, mask, 0); + + spin_unlock_irqrestore(&pmu->lock, flags); + + return 0; +} + static int jh71xx_pmu_set_state(struct jh71xx_pmu_dev *pmd, u32 mask, bool on) { struct jh71xx_pmu *pmu = pmd->pmu; @@ -270,6 +290,24 @@ static int jh7110_pmu_parse_dt(struct platform_device *pdev, struct jh71xx_pmu * return 0; } +static int jh7110_aon_pmu_parse_dt(struct platform_device *pdev, struct jh71xx_pmu *pmu) +{ + struct device *parent; + struct device *dev = &pdev->dev; + + parent = pdev->dev.parent; + if (!parent) { + dev_err(dev, "No parent for syscon pmu\n"); + return -ENODEV; + } + + pmu->base = syscon_node_to_regmap(parent->of_node); + if (IS_ERR(pmu->base)) + return PTR_ERR(pmu->base); + + return 0; +} + static int jh71xx_pmu_init_domain(struct jh71xx_pmu *pmu, int index) { struct jh71xx_pmu_dev *pmd; @@ -398,10 +436,32 @@ static const struct jh71xx_pmu_match_data jh7110_pmu = { .pmu_set_state = jh7110_pmu_set_state, }; +static const struct jh71xx_domain_info jh7110_aon_power_domains[] = { + [JH7110_PD_DPHY_TX] = { + .name = "DPHY-TX", + .bit = 30, + }, + [JH7110_PD_DPHY_RX] = { + .name = "DPHY-RX", + .bit = 31, + }, +}; + +static const struct jh71xx_pmu_match_data jh7110_aon_pmu = { + .num_domains = ARRAY_SIZE(jh7110_aon_power_domains), + .domain_info = jh7110_aon_power_domains, + .pmu_status = JH71XX_AON_PMU_SWITCH, + .pmu_parse_dt = jh7110_aon_pmu_parse_dt, + .pmu_set_state = jh7110_aon_pmu_set_state, +}; + static const struct of_device_id jh71xx_pmu_of_match[] = { { .compatible = "starfive,jh7110-pmu", .data = (void *)&jh7110_pmu, + }, { + .compatible = "starfive,jh7110-aon-pmu", + .data = (void *)&jh7110_aon_pmu, }, { /* sentinel */ } @@ -418,5 +478,6 @@ static struct platform_driver jh71xx_pmu_driver = { builtin_platform_driver(jh71xx_pmu_driver); MODULE_AUTHOR("Walker Chen "); +MODULE_AUTHOR("Changhuang Liang "); MODULE_DESCRIPTION("StarFive JH71XX PMU Driver"); MODULE_LICENSE("GPL"); From patchwork Wed Apr 19 03:48:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 85163 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp78310vqo; Tue, 18 Apr 2023 20:57:25 -0700 (PDT) X-Google-Smtp-Source: AKy350YzDHNhZAUvb4+JEHAECSA/Lw26TEaSPiy/oM9ph0ez7KIuHP9Zc5POFqoS6wgRjgfmkXwO X-Received: by 2002:a05:6a20:258d:b0:d8:bed9:33cf with SMTP id k13-20020a056a20258d00b000d8bed933cfmr994951pzd.17.1681876645540; Tue, 18 Apr 2023 20:57:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681876645; cv=none; d=google.com; s=arc-20160816; b=ItODbuC3kRcm7G6MnX/FfGzP6AszBMhS5EyfQk921PxHgaY4pY5ZrfPKA6uPI9tOT5 KSY41wjg0Df9U7kqaE+QwcIr4OpBjRkUgJWzMK1hS8ZQIFmedGJP4028axyOiFyYOMEJ IUU6KYZdgr6oTVln7BZ96uD30NwtqE86Ewqbfn5rxuoJfyyTYv3sVUJCqyi3X/pFNNct xd/Y9hkYtWcipD1CxN6rr9TaUFb9YbOCxLISmWCIY4NjV9CcZKaZVfqKtVda1jac0YA0 Hw1xvl7LCfIDPajtbXmg/YgAgjAHoA43iOUO6sAghQm6JXGc6jMeV4hfoeokayXYrj4k Mtzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=y3Ezvlq+cuSzJyD7rcdgg8umkcDXzpuOv1lOHZFEqnQ=; b=O/ASZ0yijIWfkCDIU0aSi7t+ALa/ozAhPngd+2GDcXLjUmwJCkzb4G1Sfgka5tivf8 pYWAgfvfSdKF4IR58CmEskrte904W5NvkTGFcPxbQv5WOesBjD4o4vr6MaD7UD32/bLW BER+hIDb1+wJ80SOrgLfsYJCR0smdOG+AD+A39cijtF6o/rdz1Iz8dz8ZQLQBL40J9q3 kBMkJwVa1ebTcDsavk73QEsCYa00XXwphuLOpOnmABbpzs4utLPpjX3STT8FRYEvhnh9 HfHkGIGswXBCWml82PG1twXyOsVk/lna5Q7lI0OJiH3JxPLBW23MjMQ+7l9ZD/thK9FD O4Qg== 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 o5-20020aa79785000000b0063d32d1c0b9si3621139pfp.125.2023.04.18.20.57.12; Tue, 18 Apr 2023 20:57:25 -0700 (PDT) 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 S230248AbjDSDtS convert rfc822-to-8bit (ORCPT + 99 others); Tue, 18 Apr 2023 23:49:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231991AbjDSDsq (ORCPT ); Tue, 18 Apr 2023 23:48:46 -0400 Received: from ex01.ufhost.com (ex01.ufhost.com [61.152.239.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E1D535BF; Tue, 18 Apr 2023 20:48:44 -0700 (PDT) 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 C412124E255; Wed, 19 Apr 2023 11:48:42 +0800 (CST) Received: from EXMBX162.cuchost.com (172.16.6.72) by EXMBX165.cuchost.com (172.16.6.75) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Wed, 19 Apr 2023 11:48:40 +0800 Received: from ubuntu.localdomain (113.72.144.253) by EXMBX162.cuchost.com (172.16.6.72) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Wed, 19 Apr 2023 11:48:39 +0800 From: Changhuang Liang To: Rob Herring , Krzysztof Kozlowski , Emil Renner Berthing , Conor Dooley , Paul Walmsley , Palmer Dabbelt , Albert Ou CC: Walker Chen , Changhuang Liang , Hal Feng , , , Subject: [PATCH v2 6/6] riscv: dts: starfive: jh7110: Add starfive,jh7110-aon-pmu node Date: Tue, 18 Apr 2023 20:48:33 -0700 Message-ID: <20230419034833.43243-8-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230419034833.43243-1-changhuang.liang@starfivetech.com> References: <20230419034833.43243-1-changhuang.liang@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [113.72.144.253] X-ClientProxiedBy: EXCAS064.cuchost.com (172.16.6.24) To EXMBX162.cuchost.com (172.16.6.72) X-YovoleRuleAgent: yovoleflag X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1763575485510846010?= X-GMAIL-MSGID: =?utf-8?q?1763575485510846010?= Add starfive,jh7110-aon-pmu node to configure power. It can be used to turn on/off dphy rx/tx power switch. Reviewed-by: Walker Chen Signed-off-by: Changhuang Liang --- arch/riscv/boot/dts/starfive/jh7110.dtsi | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/riscv/boot/dts/starfive/jh7110.dtsi b/arch/riscv/boot/dts/starfive/jh7110.dtsi index f271c3184d3a..b72cb54f0373 100644 --- a/arch/riscv/boot/dts/starfive/jh7110.dtsi +++ b/arch/riscv/boot/dts/starfive/jh7110.dtsi @@ -499,6 +499,11 @@ aoncrg: clock-controller@17000000 { aon_syscon: syscon@17010000 { compatible = "starfive,jh7110-aon-syscon", "syscon", "simple-mfd"; reg = <0x0 0x17010000 0x0 0x1000>; + + aon_pwrc: power-controller { + compatible = "starfive,jh7110-aon-pmu"; + #power-domain-cells = <1>; + }; }; aongpio: pinctrl@17020000 {