From patchwork Thu Nov 26 12:40:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 11933451 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14604C56202 for ; Thu, 26 Nov 2020 12:45:01 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AA6782173E for ; Thu, 26 Nov 2020 12:45:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="G8/o8Gxd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AA6782173E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=X8uwo8AQIbc0k5gb8kWB25OxW7i+nosdua0LT7lpvIE=; b=G8/o8Gxde0JIbfPXmqkcg8bGp6 D/Ez1PAE74AsDkqQ0/Cx+G38T3IqOX70A9SDStMlrVHmsiSl/kyynYJ9AGPGWtvxaElXnFP+tIHCL ZnzfPX/8fwaDdzEFlBGtsIUW1OD+SL1QKQL05ac4pSjTR4fTCBa9vhiW94M8e6KbY0fqmAhGRRvbW Q8u+bDQpHpzUMNUJodDIE6f5fbd3s6ws1nv8cjgl68nvd+0WCg8PShw0fUAFKpvuegTw0se2agwiL uR0GgZ7rp436PqW/a0BLqzX/54GEhlTYyhyklHs8rAdYt3o0lkBtuej3c6WCjbqFJc/jInI5uCAJF cuiOLPuw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kiGc4-0002p9-7G; Thu, 26 Nov 2020 12:43:05 +0000 Received: from inva020.nxp.com ([92.121.34.13]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kiGar-0002Qy-3g for linux-arm-kernel@lists.infradead.org; Thu, 26 Nov 2020 12:41:58 +0000 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 50B6C1A0B97; Thu, 26 Nov 2020 13:41:45 +0100 (CET) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 392551A0BA9; Thu, 26 Nov 2020 13:41:45 +0100 (CET) Received: from fsr-ub1664-175.ea.freescale.net (fsr-ub1664-175.ea.freescale.net [10.171.82.40]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id B9EBC2026B; Thu, 26 Nov 2020 13:41:44 +0100 (CET) From: Abel Vesa To: Stephen Boyd , Sascha Hauer , Peng Fan , Fabio Estevam , Anson Huang , Dong Aisheng , Jacky Bai Subject: [PATCH v2 2/5] clk: Add CLK_GET_PARENT_NOCACHE flag Date: Thu, 26 Nov 2020 14:40:06 +0200 Message-Id: <1606394409-12755-3-git-send-email-abel.vesa@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1606394409-12755-1-git-send-email-abel.vesa@nxp.com> References: <1606394409-12755-1-git-send-email-abel.vesa@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201126_074149_567439_3549CFA8 X-CRM114-Status: GOOD ( 19.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Linux Kernel Mailing List , Abel Vesa , NXP Linux Team , linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This can be used by the clocks that have their parents changed from EL3. This way the clk_get_parent will read the value from register instead of using the value stored in the core framework. Signed-off-by: Abel Vesa Suggested-by: Peng Fan --- drivers/clk/clk.c | 31 +++++++++++++++++-------------- include/linux/clk-provider.h | 1 + 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index c77feb6..2dd4bf4 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2401,6 +2401,16 @@ int clk_set_max_rate(struct clk *clk, unsigned long rate) } EXPORT_SYMBOL_GPL(clk_set_max_rate); +static struct clk_core *__clk_get_parent(struct clk_core *core) +{ + u8 index = 0; + + if (core->num_parents > 1 && core->ops->get_parent) + index = core->ops->get_parent(core->hw); + + return clk_core_get_parent_by_index(core, index); +} + /** * clk_get_parent - return the parent of a clk * @clk: the clk whose parent gets returned @@ -2415,24 +2425,17 @@ struct clk *clk_get_parent(struct clk *clk) return NULL; clk_prepare_lock(); - /* TODO: Create a per-user clk and change callers to call clk_put */ - parent = !clk->core->parent ? NULL : clk->core->parent->hw->clk; + if (clk->core && (clk->core->flags & CLK_GET_PARENT_NOCACHE)) + parent = __clk_get_parent(clk->core)->hw->clk; + else + /* TODO: Create a per-user clk and change callers to call clk_put */ + parent = !clk->core->parent ? NULL : clk->core->parent->hw->clk; clk_prepare_unlock(); return parent; } EXPORT_SYMBOL_GPL(clk_get_parent); -static struct clk_core *__clk_init_parent(struct clk_core *core) -{ - u8 index = 0; - - if (core->num_parents > 1 && core->ops->get_parent) - index = core->ops->get_parent(core->hw); - - return clk_core_get_parent_by_index(core, index); -} - static void clk_core_reparent(struct clk_core *core, struct clk_core *new_parent) { @@ -3352,7 +3355,7 @@ static void clk_core_reparent_orphans_nolock(void) * parent. */ hlist_for_each_entry_safe(orphan, tmp2, &clk_orphan_list, child_node) { - struct clk_core *parent = __clk_init_parent(orphan); + struct clk_core *parent = __clk_get_parent(orphan); /* * We need to use __clk_set_parent_before() and _after() to @@ -3453,7 +3456,7 @@ static int __clk_core_init(struct clk_core *core) goto out; } - parent = core->parent = __clk_init_parent(core); + parent = core->parent = __clk_get_parent(core); /* * Populate core->parent if parent has already been clk_core_init'd. If diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 81ba1aa..f871991b 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -32,6 +32,7 @@ #define CLK_OPS_PARENT_ENABLE BIT(12) /* duty cycle call may be forwarded to the parent clock */ #define CLK_DUTY_CYCLE_PARENT BIT(13) +#define CLK_GET_PARENT_NOCACHE BIT(14) /* read the parent from reg */ struct clk; struct clk_hw;