Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp4566852rwb; Tue, 17 Jan 2023 02:31:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXs+WycdNUZBESKOC2oOTyTzgSQ2bm+FTDtzTqLyIkUFbiqGn/0PS7DOjAxy8JjXl9+zPLsO X-Received: by 2002:a05:6402:4441:b0:49c:91d8:e989 with SMTP id o1-20020a056402444100b0049c91d8e989mr2223274edb.42.1673951518338; Tue, 17 Jan 2023 02:31:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673951518; cv=none; d=google.com; s=arc-20160816; b=uRic2Tqmt0Rj5hSijXpinSUqfsPaAmJxsiBY/cxvOEaiZ14Io25PMiUrUtu49NG9mv 1qVjHUHRsAxUBJHT7qUkMTWzNW3HMrtsbBuCf8QykZ9wEWLLVoxtpFC2BahUG6e5NoFG /JGYdIgRMfnsaJD0Xz3JajXGcd2rSYCkD38hLuXz9294oRrjSGMcKqXJykzQXm2hQsJG Bd9sfsV9PsmOJvOH9OpACAx+EPGxbTfSNz9n9RRRTMU0SS1kOdBpq7KjEzmnc4jCMhqu f4ikdVqgkAmDzssI6odbDPAEAB1XIpI5w2HJ4dcJZ1C5AePmD3CQOPOw+LJGomlfPm+4 fwcw== 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=sFfBBDksD5f0aGi0WPdpNcdP9gBRsjtgOhKHq559QEI=; b=S1f4iTC/67QVArCDSng5r0F7K05RQuSV9GVtMhGQLvTy3A4mIB3x0lkzICayiFv8+m uE6HwAg7/06dZzO2LY+U+Oxqc6lvR/b58E4SGubSgach9RBb92dCWdevGs8weaOc75xR HTlb78/E86es3naUblWrMHxGpfuhMZbzR7M8KIBJ3TbeUKoTAvPNickNbEiWl5POJhUq D8Mo+rZJt3PCfjMDim54l8IKeMza5AL+WjciImi8f2dpfgXKsTg2nmEDJvFl+reIfco3 u29jNXMpt7xD3usQDXMJOpwKYqvrDFm86cpyALOb/001znz+RDNsEQWe4MaTJ14I6eIl Y4EA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r16-20020a05640251d000b004676034f552si14429807edd.45.2023.01.17.02.31.46; Tue, 17 Jan 2023 02:31:58 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236399AbjAQKJn (ORCPT + 49 others); Tue, 17 Jan 2023 05:09:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236166AbjAQKJ3 (ORCPT ); Tue, 17 Jan 2023 05:09:29 -0500 Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C08F42D17D; Tue, 17 Jan 2023 02:09:25 -0800 (PST) Received: from ip5b412258.dynamic.kabel-deutschland.de ([91.65.34.88] helo=diego.localnet) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pHitr-0006k8-Rj; Tue, 17 Jan 2023 11:09:03 +0100 From: Heiko =?ISO-8859-1?Q?St=FCbner?= To: linux-riscv@lists.infradead.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Emil Renner Berthing , "Rafael J . Wysocki" , Walker Chen , linux-kernel@vger.kernel.org, Walker Chen Subject: Re: [PATCH v3 2/3] soc: starfive: Add StarFive JH71XX pmu driver Date: Tue, 17 Jan 2023 11:09:03 +0100 Message-ID: <10209933.nUPlyArG6x@diego> In-Reply-To: <20230116074259.22874-3-walker.chen@starfivetech.com> References: <20230116074259.22874-1-walker.chen@starfivetech.com> <20230116074259.22874-3-walker.chen@starfivetech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS, T_SPF_HELO_TEMPERROR 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 Hi Walker, Am Montag, 16. Januar 2023, 08:42:58 CET schrieb Walker Chen: > +static int jh71xx_pmu_get_state(struct jh71xx_pmu_dev *pmd, u32 mask, bool *is_on) > +{ > + struct jh71xx_pmu *pmu = pmd->pmu; > + > + if (!mask) { > + *is_on = false; nit: While it's not necessarily bad, I don't think callers of jh71xx_pmu_get_state() should expect this to be set in error case. > + return -EINVAL; > + } > + > + *is_on = readl(pmu->base + JH71XX_PMU_CURR_POWER_MODE) & mask; > + > + return 0; > +} [...] > +static int jh71xx_pmu_probe(struct platform_device *pdev) > +{ > + struct device *dev = &pdev->dev; > + struct device_node *np = dev->of_node; > + const struct jh71xx_pmu_match_data *match_data; > + struct jh71xx_pmu *pmu; > + unsigned int i; > + int ret; > + > + pmu = devm_kzalloc(dev, sizeof(*pmu), GFP_KERNEL); > + if (!pmu) > + return -ENOMEM; > + > + pmu->base = devm_platform_ioremap_resource(pdev, 0); > + 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"); > + > + match_data = of_device_get_match_data(dev); > + if (!match_data) > + return -EINVAL; > + > + pmu->genpd = devm_kcalloc(dev, match_data->num_domains, > + sizeof(struct generic_pm_domain *), > + GFP_KERNEL); > + if (!pmu->genpd) > + return -ENOMEM; > + > + pmu->dev = dev; > + pmu->match_data = match_data; > + pmu->genpd_data.domains = pmu->genpd; > + pmu->genpd_data.num_domains = match_data->num_domains; > + > + for (i = 0; i < match_data->num_domains; i++) { > + ret = jh71xx_pmu_init_domain(pmu, i); > + if (ret) { > + dev_err(dev, "failed to initialize power domain\n"); > + return ret; > + } > + } > + > + 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); > + return ret; > + } > + > + dev_info(dev, "registered %u power domains\n", i); nit: I guess that could be a dev_dbg to not spam the kernel log too much? > + return 0; > +} > + > +static const struct jh71xx_domain_info jh7110_power_domains[] = { > + [JH7110_PD_SYSTOP] = { > + .name = "SYSTOP", > + .bit = 0, > + .flags = GENPD_FLAG_ALWAYS_ON, > + }, > + [JH7110_PD_CPU] = { > + .name = "CPU", > + .bit = 1, > + .flags = GENPD_FLAG_ALWAYS_ON, > + }, > + [JH7110_PD_GPUA] = { > + .name = "GPUA", > + .bit = 2, > + }, > + [JH7110_PD_VDEC] = { > + .name = "VDEC", > + .bit = 3, > + }, > + [JH7110_PD_VOUT] = { > + .name = "VOUT", > + .bit = 4, > + }, > + [JH7110_PD_ISP] = { > + .name = "ISP", > + .bit = 5, > + }, > + [JH7110_PD_VENC] = { > + .name = "VENC", > + .bit = 6, > + }, > +}; > + > +static const struct jh71xx_pmu_match_data jh7110_pmu = { > + .num_domains = ARRAY_SIZE(jh7110_power_domains), > + .domain_info = jh7110_power_domains, > +}; > + > +static const struct of_device_id jh71xx_pmu_of_match[] = { > + { > + .compatible = "starfive,jh7110-pmu", > + .data = (void *)&jh7110_pmu, > + }, { > + /* sentinel */ > + } > +}; > + > +static struct platform_driver jh71xx_pmu_driver = { > + .driver = { > + .name = "jh71xx-pmu", > + .of_match_table = jh71xx_pmu_of_match, In the rockchip pm-domains driver we have /* * We can't forcibly eject devices from the power * domain, so we can't really remove power domains * once they were added. */ .suppress_bind_attrs = true, here, which might be valid for your pmu driver as well. Other than that Reviewed-by: Heiko Stuebner