From patchwork Thu Aug 17 17:04:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Xiwen via B4 Relay X-Patchwork-Id: 1822482 X-Patchwork-Delegate: seanga2@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=FyjdG3X1; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RRWZV0Tm0z20Bh for ; Fri, 18 Aug 2023 03:04:34 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CEB9386BB9; Thu, 17 Aug 2023 19:04:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="FyjdG3X1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 49C7786BA1; Thu, 17 Aug 2023 19:04:21 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_REPLYTO, FREEMAIL_REPLYTO_END_DIGIT,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D8CAC86B9A for ; Thu, 17 Aug 2023 19:04:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=devnull+forbidden405.outlook.com@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4EF9361F16; Thu, 17 Aug 2023 17:04:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id AECA0C433C9; Thu, 17 Aug 2023 17:04:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692291853; bh=cKIj3uvlO/l+tZDUra4lHfkBYvbFh7g655JGfg8+a4A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=FyjdG3X1Tq9GdesgWbY/m0tfihw5+ILQo4ugf3VsNyo4duztGQYyHXa52K+yrgS5W LCgHgv1If792B+Prmd8p61NYrZZcq0C3MEXXtU9KWtHbZxbzYllUDnM7Yzlo8t3EzJ tPBuxg2nGBLjxF90K2bDN6o3Sur4oJdj1GFDkgdVGP8GlVXngqXmC6IT9bcsATaV8p UmP2Q+sDIgTOsAKyWGNh6lMX2xttmR22XCFtHbWStq3oMNJmH3duSPmRPS+iwIjAEw ZavKvDjZI7FVQktBw+M0g1yLXBeauB2C7jczNNrMfacTDuuMdHkxa4LcHqF8gHrcUw 0rLsp7Pwbu4FA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C6A6C3DA58; Thu, 17 Aug 2023 17:04:13 +0000 (UTC) From: Yang Xiwen via B4 Relay Date: Fri, 18 Aug 2023 01:04:00 +0800 Subject: [PATCH RESEND 1/5] clk: export clk_register_mux_table() MIME-Version: 1.0 Message-Id: <20230818-clk-fix-v1-1-49ec18f820bf@outlook.com> References: <20230818-clk-fix-v1-0-49ec18f820bf@outlook.com> In-Reply-To: <20230818-clk-fix-v1-0-49ec18f820bf@outlook.com> To: Lukasz Majewski , Sean Anderson Cc: u-boot@lists.denx.de, Yang Xiwen X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1692291852; l=922; i=forbidden405@outlook.com; s=20230724; h=from:subject:message-id; bh=rrxWAZujevzzupl/nb4QWkR3QDVpqMIWdYkkWfQ6VWg=; b=p+Dym4mN6QSYD5cD/WWkx0ItGmcKQP+RF00a0c3G0z85VcPDKFNNGExqXyUKTqsghT5lyVEnk 3MVA6fdSqeYC2xQVXWMzVzalgygVemwDIgfl/78ukSb/vsE6TGxpJVZ X-Developer-Key: i=forbidden405@outlook.com; a=ed25519; pk=qOD5jhp891/Xzc+H/PZ8LWVSWE3O/XCQnAg+5vdU2IU= X-Endpoint-Received: by B4 Relay for forbidden405@outlook.com/20230724 with auth_id=67 X-Original-From: Yang Xiwen X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: forbidden405@outlook.com Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Yang Xiwen It's already implemented in clk-mux.c, export it in the header file. Signed-off-by: Yang Xiwen --- include/linux/clk-provider.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index b8acacd49e..801404480b 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -247,6 +247,12 @@ struct clk *clk_register_mux(struct device *dev, const char *name, void __iomem *reg, u8 shift, u8 width, u8 clk_mux_flags); +struct clk *clk_register_mux_table(struct device *dev, const char *name, + const char * const *parent_names, u8 num_parents, + unsigned long flags, + void __iomem *reg, u8 shift, u32 mask, + u8 clk_mux_flags, u32 *table); + struct clk *clk_register_fixed_rate(struct device *dev, const char *name, ulong rate); From patchwork Thu Aug 17 17:04:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Xiwen via B4 Relay X-Patchwork-Id: 1822485 X-Patchwork-Delegate: seanga2@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=HMaQxNkd; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RRWb64MvBz1yZd for ; Fri, 18 Aug 2023 03:05:06 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B71A386BC5; Thu, 17 Aug 2023 19:04:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="HMaQxNkd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C2D5C86BA0; Thu, 17 Aug 2023 19:04:23 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_REPLYTO, FREEMAIL_REPLYTO_END_DIGIT,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0670D86BA4 for ; Thu, 17 Aug 2023 19:04:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=devnull+forbidden405.outlook.com@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5FBC262DB6; Thu, 17 Aug 2023 17:04:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id C00D8C433CA; Thu, 17 Aug 2023 17:04:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692291853; bh=3rsdCAHmW7bXDABvX1K2uwvqI7fO4x0bP2S1wrRUc58=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=HMaQxNkdydWEE6qoDjsQ+8Z3RqBruKBmEKRc3Q7jkWjs4zDDz0tdUYUUra0rSqejl qw+N2Nxtl5WeS7zyZQi7UYiBVVP2TWdZZpLhOP6bu0mJkr+v9drS3VZp4+Hd+rEifv rQqvXZYDnClBKHx92OFmXpVmE7KyBqCE4DsHqxXw4mX/pYvfidp2sKAH/XdrpPX/lQ 2hpjQ1jHs70jetasa6O83qU8MEJiSaDXmIDFDj6aviIEUryzCIspZV4uQlM4afo4u/ zhCFJ93fZzL2WA//af+stVwGtE3Pmh8MCKIG5FKiJTdrHVdfMIEL6ixjcE5M1Y8fT7 +K+SsMSLchGkw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8F1DC3DA5E; Thu, 17 Aug 2023 17:04:13 +0000 (UTC) From: Yang Xiwen via B4 Relay Date: Fri, 18 Aug 2023 01:04:01 +0800 Subject: [PATCH RESEND 2/5] clk: call log_debug() instead to avoid console log printing MIME-Version: 1.0 Message-Id: <20230818-clk-fix-v1-2-49ec18f820bf@outlook.com> References: <20230818-clk-fix-v1-0-49ec18f820bf@outlook.com> In-Reply-To: <20230818-clk-fix-v1-0-49ec18f820bf@outlook.com> To: Lukasz Majewski , Sean Anderson Cc: u-boot@lists.denx.de, Yang Xiwen X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1692291852; l=944; i=forbidden405@outlook.com; s=20230724; h=from:subject:message-id; bh=rF0dwZvgeJOMiuqcxICJYTlilfkM8yDDIOepIOXVwHY=; b=rSvWzZEYw1wZeS/cixeh4ZFcbGRiAF40fm9cqVlCBXKweMo9QX/eS8eJmOn+bXXvdbjyYpoIY ZExhG7evb7jAMW7FbRqcmsOZEj125Puht4Dusis0PamlH+rXemItOQi X-Developer-Key: i=forbidden405@outlook.com; a=ed25519; pk=qOD5jhp891/Xzc+H/PZ8LWVSWE3O/XCQnAg+5vdU2IU= X-Endpoint-Received: by B4 Relay for forbidden405@outlook.com/20230724 with auth_id=67 X-Original-From: Yang Xiwen X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: forbidden405@outlook.com Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Yang Xiwen it's a very common case to register a clock without a parent, such as clk_register_fixed_rate(). Replace log_error() with log_debug() to avoid useless console log if not debugging. Signed-off-by: Yang Xiwen --- drivers/clk/clk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index a5a3461b66..a38daaac0c 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -24,8 +24,8 @@ int clk_register(struct clk *clk, const char *drv_name, ret = uclass_get_device_by_name(UCLASS_CLK, parent_name, &parent); if (ret) { - log_err("%s: failed to get %s device (parent of %s)\n", - __func__, parent_name, name); + log_debug("%s: failed to get %s device (parent of %s)\n", + __func__, parent_name, name); } else { log_debug("%s: name: %s parent: %s [0x%p]\n", __func__, name, parent->name, parent); From patchwork Thu Aug 17 17:04:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Xiwen via B4 Relay X-Patchwork-Id: 1822483 X-Patchwork-Delegate: seanga2@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=Inpvj879; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RRWZg70fJz20Bh for ; Fri, 18 Aug 2023 03:04:43 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 24C2C86BBF; Thu, 17 Aug 2023 19:04:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="Inpvj879"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4A39F86B9A; Thu, 17 Aug 2023 19:04:21 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_REPLYTO, FREEMAIL_REPLYTO_END_DIGIT,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D792086B99 for ; Thu, 17 Aug 2023 19:04:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=devnull+forbidden405.outlook.com@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 62DDB65271; Thu, 17 Aug 2023 17:04:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id C8092C433CC; Thu, 17 Aug 2023 17:04:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692291853; bh=tM1aYllxcPhGjnSsU4nxGUN3TQPcYe2TbwDmTngls4c=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Inpvj879v85O2xnQd75OQMuYffYRUb2BfIuHCk3j12IreUpOgz23btDXyBHQEpHoq MGLcwTTvF//M/RKZUzZlRtBMCUyPO+QE/32MYmBqF4U5oYS43PdzbbNxT8Pw9MC2+E LcwYoK7GniKgvh3ilqzxwzlYmE1e2uwK/U0WkROa+JyQsBWeKTMVU/J7wDYPjHMIPv cp5wRN32yOUIIFoBS+1c5NtrZ4AFSqsA5oS5skduo+uU7jiNYdD7iV7jJVR5j12/mx LbRHzzZKK3HZwZeVl5gfGnCYMlld0dx9Lz0MZkqvHj1AIjOeB8G5V0mpZbv66TD1Zr r5FxW0b5tUxqw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8FD6C41513; Thu, 17 Aug 2023 17:04:13 +0000 (UTC) From: Yang Xiwen via B4 Relay Date: Fri, 18 Aug 2023 01:04:02 +0800 Subject: [PATCH RESEND 3/5] clk: also handle ENOENT in *_optional functions MIME-Version: 1.0 Message-Id: <20230818-clk-fix-v1-3-49ec18f820bf@outlook.com> References: <20230818-clk-fix-v1-0-49ec18f820bf@outlook.com> In-Reply-To: <20230818-clk-fix-v1-0-49ec18f820bf@outlook.com> To: Lukasz Majewski , Sean Anderson Cc: u-boot@lists.denx.de, Yang Xiwen X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1692291852; l=1405; i=forbidden405@outlook.com; s=20230724; h=from:subject:message-id; bh=Ya3s56yb/uYzBObmNpjkiNoe6oNIwyGOQ0sokgx66Jo=; b=I09kKcG7TodYECmhEd/9wUPheTbxQILBk4u18UtMuyakf9HYnbxB6D86jlfWndXlFrgLv9slZ nXVhbTrBeOVDBCuGs/mGmaFwoA8DbmyhlJPpiKciQzj88HyeVxCFZzU X-Developer-Key: i=forbidden405@outlook.com; a=ed25519; pk=qOD5jhp891/Xzc+H/PZ8LWVSWE3O/XCQnAg+5vdU2IU= X-Endpoint-Received: by B4 Relay for forbidden405@outlook.com/20230724 with auth_id=67 X-Original-From: Yang Xiwen X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: forbidden405@outlook.com Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Yang Xiwen If the device does not specify any clocks in device tree, these functions will return PTR_ERR(-ENOENT). This is not the intended behavior and does not comply with linux kernel CCF. Fix that by returning NULL under such circumstances instead. Signed-off-by: Yang Xiwen Reviewed-by: Sean Anderson --- include/clk.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/clk.h b/include/clk.h index d91285235f..f95da0838d 100644 --- a/include/clk.h +++ b/include/clk.h @@ -223,9 +223,11 @@ struct clk *devm_clk_get(struct udevice *dev, const char *id); static inline struct clk *devm_clk_get_optional(struct udevice *dev, const char *id) { + int ret; struct clk *clk = devm_clk_get(dev, id); - if (PTR_ERR(clk) == -ENODATA) + ret = PTR_ERR(clk); + if (ret == -ENODATA || ret == -ENOENT) return NULL; return clk; @@ -335,7 +337,7 @@ static inline int clk_get_by_name_optional(struct udevice *dev, int ret; ret = clk_get_by_name(dev, name, clk); - if (ret == -ENODATA) + if (ret == -ENODATA || ret == -ENOENT) return 0; return ret; @@ -359,7 +361,7 @@ static inline int clk_get_by_name_nodev_optional(ofnode node, const char *name, int ret; ret = clk_get_by_name_nodev(node, name, clk); - if (ret == -ENODATA) + if (ret == -ENODATA || ret == -ENOENT) return 0; return ret; From patchwork Thu Aug 17 17:04:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Xiwen via B4 Relay X-Patchwork-Id: 1822484 X-Patchwork-Delegate: seanga2@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=TcseoXYj; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RRWZv3ljhz20Bh for ; Fri, 18 Aug 2023 03:04:55 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 706B386BA4; Thu, 17 Aug 2023 19:04:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="TcseoXYj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BBF9086B9D; Thu, 17 Aug 2023 19:04:23 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_REPLYTO, FREEMAIL_REPLYTO_END_DIGIT,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2AA9086BAB for ; Thu, 17 Aug 2023 19:04:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=devnull+forbidden405.outlook.com@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 765F261E59; Thu, 17 Aug 2023 17:04:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id DE04DC433CB; Thu, 17 Aug 2023 17:04:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692291853; bh=8j0xJ0j/hUPZPh3NP9IRQ8iownf7t+ZCdwIn3f/CnUs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=TcseoXYj0BYt5+xGoBH/++H4+Jt7bYd/js4pImY7nDXhixNjW92/2zE5GQHA7OqLH 5fbL2oWeikU/uHujkXu8jrEv6bv/Nr3ZeYSh0SdcBawLS43P63r47GJbbjwwEk5AeZ RXJ2YX8gMB9iqL0tH8CPvevwRn2LFk+/7SLgSxrGfDva0nAxdYReWPGFh3JfMYD6y1 g348aIU5RWIbX9cwPHXs40xTsCa0r8XiWGu8H9xwSwSOwRhUCvoKC67KnxPGCk8T8n Zf2/Cn7h3yx4ES8GbTZTbk99dEHTg4yZoGFblgVKbAqPcKGskBqYbDU9Un5BE7gIYx yh4eUI3MIFe0Q== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCB4AC3DA5C; Thu, 17 Aug 2023 17:04:13 +0000 (UTC) From: Yang Xiwen via B4 Relay Date: Fri, 18 Aug 2023 01:04:03 +0800 Subject: [PATCH RESEND 4/5] clk: promote clk_dev_ops to linux/clk-provider.h MIME-Version: 1.0 Message-Id: <20230818-clk-fix-v1-4-49ec18f820bf@outlook.com> References: <20230818-clk-fix-v1-0-49ec18f820bf@outlook.com> In-Reply-To: <20230818-clk-fix-v1-0-49ec18f820bf@outlook.com> To: Lukasz Majewski , Sean Anderson Cc: u-boot@lists.denx.de, Yang Xiwen X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1692291852; l=1308; i=forbidden405@outlook.com; s=20230724; h=from:subject:message-id; bh=AsXbGKWGRqE3lMjTv3H8xZIwt4yI2mwPFQ61gXMGbNI=; b=fayyID6emo5avyU30zRUPRyYSoRpenqpatkddd/geJBHfYiNS1S3MRgy1EU9KzCSHiR9zzLlw V7lGGLJ5nz+BpXY8ooDmagzV4YaqXhtVobgboCSqGJNavmH+urkNLZq X-Developer-Key: i=forbidden405@outlook.com; a=ed25519; pk=qOD5jhp891/Xzc+H/PZ8LWVSWE3O/XCQnAg+5vdU2IU= X-Endpoint-Received: by B4 Relay for forbidden405@outlook.com/20230724 with auth_id=67 X-Original-From: Yang Xiwen X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: forbidden405@outlook.com Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Yang Xiwen So that it can be used by others. Signed-off-by: Yang Xiwen --- drivers/clk/clk-uclass.c | 5 ----- include/linux/clk-provider.h | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c index dc3e9d6a26..5cc80e5e39 100644 --- a/drivers/clk/clk-uclass.c +++ b/drivers/clk/clk-uclass.c @@ -25,11 +25,6 @@ #include #include -static inline const struct clk_ops *clk_dev_ops(struct udevice *dev) -{ - return (const struct clk_ops *)dev->driver->ops; -} - struct clk *dev_get_clk_ptr(struct udevice *dev) { return (struct clk *)dev_get_uclass_priv(dev); diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 801404480b..dfafb4cc9d 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -21,6 +21,11 @@ static inline void clk_dm(ulong id, struct clk *clk) clk->id = id; } +static inline const struct clk_ops *clk_dev_ops(struct udevice *dev) +{ + return (const struct clk_ops *)dev->driver->ops; +} + /* * flags used across common struct clk. these flags should only affect the * top-level framework. custom flags for dealing with hardware specifics From patchwork Thu Aug 17 17:04:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Xiwen via B4 Relay X-Patchwork-Id: 1822486 X-Patchwork-Delegate: seanga2@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=Rbx5eyDN; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RRWbL0n3Qz1yZd for ; Fri, 18 Aug 2023 03:05:18 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 09A3B86BB2; Thu, 17 Aug 2023 19:04:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="Rbx5eyDN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3E1A786B96; Thu, 17 Aug 2023 19:04:26 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_REPLYTO, FREEMAIL_REPLYTO_END_DIGIT,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3CA4D86BAF for ; Thu, 17 Aug 2023 19:04:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=devnull+forbidden405.outlook.com@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D801F659D6; Thu, 17 Aug 2023 17:04:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id E91FFC433CD; Thu, 17 Aug 2023 17:04:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692291853; bh=ZULwSv0gZmvFfkxtGPegKfiNmBml8BrmAmSw/dE6joU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Rbx5eyDNKsC7UiGTHRl9iJhZa6y2vcCKy4zw6putTZcIGyLXd2iDzpKXgkYiOpmxQ 5/6+doY7NyazN4ydc+cZ/92sXBOfS/l42MSyJlkCZR2sHfiyHo7phUPy1r5p19/x7o u9w2XVLz39f8TB1h9avrJ3jysfecdMng5S3SdfhDuPg4xuM6vdYTXdrOGmUEvXoniH ADbqJtme4S3tAjjbQIG9VoFMiyjsXBm26RCYStz5KNhwtoDdg7wtgrGLOnic5jVjjA cYfAqyDy/2cznSz+q8yrPWRoD6V8EfYN6CFwXwcGOfIDtcA9rdVLW+yCOA0PJwr6oB axkWwzAmdRMzw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id D80E0C3DA58; Thu, 17 Aug 2023 17:04:13 +0000 (UTC) From: Yang Xiwen via B4 Relay Date: Fri, 18 Aug 2023 01:04:04 +0800 Subject: [PATCH RESEND 5/5] clk: ccf: call clock provided ops directly for endisable() MIME-Version: 1.0 Message-Id: <20230818-clk-fix-v1-5-49ec18f820bf@outlook.com> References: <20230818-clk-fix-v1-0-49ec18f820bf@outlook.com> In-Reply-To: <20230818-clk-fix-v1-0-49ec18f820bf@outlook.com> To: Lukasz Majewski , Sean Anderson Cc: u-boot@lists.denx.de, Yang Xiwen X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1692291852; l=1348; i=forbidden405@outlook.com; s=20230724; h=from:subject:message-id; bh=TgVT16K9zaLUEOhpgO1T2uH2QBfAht6D9ePnHRxlfEs=; b=DgxbdUdSnGi1NsOABYobcfpgqoPIRuaxcRMH33Z9D5YGn1+EOVWzdrQuvdGCaY5J1AAJkZjEp VZlKJsqB6xkBGJvGyStWO4qGzsdikE7DMIUOcA9GVbTjKcVk7YwKmyn X-Developer-Key: i=forbidden405@outlook.com; a=ed25519; pk=qOD5jhp891/Xzc+H/PZ8LWVSWE3O/XCQnAg+5vdU2IU= X-Endpoint-Received: by B4 Relay for forbidden405@outlook.com/20230724 with auth_id=67 X-Original-From: Yang Xiwen X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: forbidden405@outlook.com Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Yang Xiwen Calling into CCF framework will cause a clock being enabled twice instead of once (clk->enable_count becomes 2 rather than 1), thus making it hard to disable (needs to call clk_disable() twice). Fix that by calling clock provided ops directly. Signed-off-by: Yang Xiwen --- drivers/clk/clk.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index a38daaac0c..00d082c46f 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -14,6 +14,7 @@ #include #include #include +#include int clk_register(struct clk *clk, const char *drv_name, const char *name, const char *parent_name) @@ -115,11 +116,20 @@ int ccf_clk_set_parent(struct clk *clk, struct clk *parent) static int ccf_clk_endisable(struct clk *clk, bool enable) { struct clk *c; + const struct clk_ops *ops; int err = clk_get_by_id(clk->id, &c); if (err) return err; - return enable ? clk_enable(c) : clk_disable(c); + else + ops = clk_dev_ops(c->dev); + + if (enable && ops->enable) + return ops->enable(c); + else if (!enable && ops->disable) + return ops->disable(c); + + return -ENOSYS; } int ccf_clk_enable(struct clk *clk)