Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6392326rwn; Tue, 13 Sep 2022 03:43:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR6nuVrKcXqB8xuuFeHGqW/paTaI5x8P/ytRdsm5kn97Y/dn0c8M0pQzUROjDMjMUtSvxCYp X-Received: by 2002:a05:6402:40cc:b0:452:697e:da18 with SMTP id z12-20020a05640240cc00b00452697eda18mr1576947edb.288.1663065819822; Tue, 13 Sep 2022 03:43:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663065819; cv=none; d=google.com; s=arc-20160816; b=bxRidUjCgzFZ4RjmDF0tCiK88t+boNz8/37kToXtl5POESa5HtRci9TpwRck8v3wTt iSYFHr0u8Ko7PysOAKX0FgHKXkVglTloVQmsKw1xQpJyIncNRll5Ens9HTOEbwaAXLcQ iTF/jKPXK+qnoDFdgi8d6nYBAqOx6hMWT2Kakbw+Kh2WFkj4BBQbCvWC2BSxl1Sjjzwi +aBmS5nzKCn0N5XX/gqbLX71ftkmqQ7aEm4JURu8J/a13RIOSXhibOyDa9tEKxKEQt+q 9+GCkG0iWyrJ3lsATZW0i4vOSdzXS3+GWAsQHFL/8SMSP8GN9UraAZEYJa+L00TggWTc UJaw== 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=qE/yUPqN27USK1D4qcljQjMaig8scTWIai6+eYzRE+Y=; b=JXvb2raNJTiyZ5jkyVwQT8J3YEtUq59IIS5dJ6ztH+Q5Cdk1gqQ+w6GGukQy1FZ+5o 6yEKDlooZHmiSNjXqQRdg7sjGb97qk9FcXu+eLQ0yhoWL/V4ymetekfjM+Ad3naloZOT QP+mjE+BmNkTI8JLeMYKSeXVyNUFZJd2+lpr7L+ak2RQjSXIUhLI9q0f+flO2ZmtUhm4 xLNsdfl50FvKgi/0AUw5eWUTKE/nVS6f7TfCDuASfFdcfTJiMdRwSrEqtvEqFWzo3X8o kPJmBuGnVIbX6tEh9BTaLrTgSURr/WWXUR2npy1dDL+dxY4s0veRxyUZOa5UqgvkdnQw 2VRA== 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 cw21-20020a170906479500b007708303d2cdsi5535510ejc.746.2022.09.13.03.43.13; Tue, 13 Sep 2022 03:43:39 -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 S231496AbiIMKWD (ORCPT + 99 others); Tue, 13 Sep 2022 06:22:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230442AbiIMKV6 (ORCPT ); Tue, 13 Sep 2022 06:21:58 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB58456BB7 for ; Tue, 13 Sep 2022 03:21:56 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oY334-0002vk-TH; Tue, 13 Sep 2022 12:21:46 +0200 Received: from [2a0a:edc0:0:1101:1d::28] (helo=dude02.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1oY335-000TmK-In; Tue, 13 Sep 2022 12:21:46 +0200 Received: from mfe by dude02.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1oY333-004prz-BM; Tue, 13 Sep 2022 12:21:45 +0200 From: Marco Felsch To: krzysztof.kozlowski+dt@linaro.org, robh+dt@kernel.org, abelvesa@kernel.org, abel.vesa@linaro.org, mturquette@baylibre.com, sboyd@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com Cc: linux-kernel@vger.kernel.org, Peng Fan , linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org Subject: [RFC PATCH 1/2] clk: add support for critical always-on clocks Date: Tue, 13 Sep 2022 12:21:40 +0200 Message-Id: <20220913102141.971148-2-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220913102141.971148-1-m.felsch@pengutronix.de> References: <20220913102141.971148-1-m.felsch@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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 Add support to mark specific clocks as always-on (critical), like the regulator-alawys-on property. So the platform integrators can specify the property on a per device basis by specifying it within the firmware and not only within the driver. Unlike the regulator framework the clock framework uses a 1:n matching, which means 1 firmware node can provide up to n clock providers. Therefore the binding uses a string-array so we can specify n clock providers as critical. Signed-off-by: Marco Felsch --- drivers/clk/clk.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 7fc191c15507..c3651bf96f90 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -3825,6 +3825,22 @@ static int clk_cpy_name(const char **dst_p, const char *src, bool must_exist) return 0; } +static void clk_core_check_critical(struct clk_core *core) +{ + struct fwnode_handle *fwnode = of_fwnode_handle(core->of_node); + const char *prop = "clocks-always-on"; + int ret; + + /* Very early added clocks don't have a fwnode */ + if (!fwnode || !fwnode_property_present(fwnode, prop)) + return; + + /* Mark clock as critical if listed within the clocks-always-on array */ + ret = fwnode_property_match_string(fwnode, prop, core->name); + if (!ret) + core->flags |= CLK_IS_CRITICAL; +} + static int clk_core_populate_parent_map(struct clk_core *core, const struct clk_init_data *init) { @@ -3946,6 +3962,8 @@ __clk_register(struct device *dev, struct device_node *np, struct clk_hw *hw) core->min_rate = 0; core->max_rate = ULONG_MAX; + clk_core_check_critical(core); + ret = clk_core_populate_parent_map(core, init); if (ret) goto fail_parents; -- 2.30.2