Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2032999rwd; Thu, 18 May 2023 23:13:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ50m5dD5y/pQ0JEIlU0W9+AMepNENue2BCauxK60xdA9aSvAUZcf6aqn7u6Ixq1zllPUmkV X-Received: by 2002:a05:6a21:9992:b0:104:2d89:8f5d with SMTP id ve18-20020a056a21999200b001042d898f5dmr1176407pzb.10.1684476779964; Thu, 18 May 2023 23:12:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684476779; cv=none; d=google.com; s=arc-20160816; b=Tl4zxFGlS1EvgL6NgiGnByhbbSSTGMn31bOdxNGIn0P6bnhTogKKsJgeMQRlJNLgF6 0ufK7dZdS5C0E3Juj/0HRybdxx1jU1WrxukNLLkEQoqFZ/NdBufX+rBd3VmzXG8ceuzS KyWFdO8vfpvLGtwT35Cn0GYPgi6ukT/9eqrWIJ88q6ZRBzC20P9s/gsGBKnjJuKQ2Sjw eyDTpPz98dnmFkL2dCVE3D2vJfKTs2m8zWvfmIqtKqRSvj3UN2zWbphmbcK7xS61/ho5 idApFNa75zkIJKWaCnd/1daxYz/mJZUu3U2djnLsD8fiv5r/NzsNVp1itgPlrZUjUtOC BWAA== 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=ZuqvjtpEkaQV6jCNhq8ohf51u7Dt/p2kNYLdLDNYieQ=; b=muPq3vnkSweVjbCLtSSWnNps5iSMvZ33bfcINKQI2tvlLM7vkE7pcHJFBzpJ7c2QyA V6ygjsx4I+jsfKIQDvq4pkBZD92TllwhomrMVvMnHStJ5w/NYS5v8AxUNKn2+K/JOm6T kNKMvfKCCZ1Y2LVf+qH9zv+GuXx+k9E3URPIg1tURbjAInSk54wujUXzvpYlfh47jmsX 7RarlIEDmKoCD6Mk15nOYJ41iq4OCyWyKAox4fFpLdmAAJ6bWoQDp1nznDgn4IstcGe2 J2UQQOLq9tX+69yefNVz17p9m4Rpq2+s4E3hr2QOEyhhuxd8dgcIFmGEv48jBX1jaQEU b/XQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9-20020a63d809000000b0053476d72498si2739935pgh.322.2023.05.18.23.12.47; Thu, 18 May 2023 23:12:59 -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 S230107AbjESGCU convert rfc822-to-8bit (ORCPT + 99 others); Fri, 19 May 2023 02:02:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbjESGCL (ORCPT ); Fri, 19 May 2023 02:02:11 -0400 Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F267F10E0; Thu, 18 May 2023 23:02:07 -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 C070F24DBE4; Fri, 19 May 2023 14:02:06 +0800 (CST) Received: from EXMBX062.cuchost.com (172.16.6.62) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 19 May 2023 14:02:06 +0800 Received: from ubuntu.localdomain (113.72.146.100) by EXMBX062.cuchost.com (172.16.6.62) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 19 May 2023 14:02:06 +0800 From: Changhuang Liang To: Rob Herring , Krzysztof Kozlowski , Conor Dooley CC: Walker Chen , Changhuang Liang , Hal Feng , , Subject: [PATCH v4 4/4] soc: starfive: Add JH7110 AON PMU support Date: Thu, 18 May 2023 23:02:02 -0700 Message-ID: <20230519060202.15296-5-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230519060202.15296-1-changhuang.liang@starfivetech.com> References: <20230519060202.15296-1-changhuang.liang@starfivetech.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [113.72.146.100] X-ClientProxiedBy: EXCAS062.cuchost.com (172.16.6.22) To EXMBX062.cuchost.com (172.16.6.62) X-YovoleRuleAgent: yovoleflag Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 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 | 57 ++++++++++++++++++++++++++++--- 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 60bbc3a05d79..d64e1b3b14f5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20127,6 +20127,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 0dbdcc0d2c91..c7b474409cf7 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 @@ -160,6 +163,26 @@ 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; + u32 val; + + spin_lock_irqsave(&pmu->lock, flags); + val = readl(pmu->base + JH71XX_AON_PMU_SWITCH); + + if (on) + val |= mask; + else + val &= ~mask; + + writel(val, pmu->base + JH71XX_AON_PMU_SWITCH); + 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; @@ -317,10 +340,12 @@ static int jh71xx_pmu_probe(struct platform_device *pdev) if (!match_data) return -EINVAL; - ret = match_data->pmu_parse_irq(pdev, pmu); - if (ret) { - dev_err(dev, "failed to parse irq\n"); - return ret; + if (match_data->pmu_parse_irq) { + ret = match_data->pmu_parse_irq(pdev, pmu); + if (ret) { + dev_err(dev, "failed to parse irq\n"); + return ret; + } } pmu->genpd = devm_kcalloc(dev, match_data->num_domains, @@ -394,10 +419,31 @@ 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_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-syscon", + .data = (void *)&jh7110_aon_pmu, }, { /* sentinel */ } @@ -414,5 +460,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"); -- 2.25.1