From patchwork Mon May 9 05:29:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1628307 X-Patchwork-Delegate: andre.przywara@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.a=rsa-sha256 header.s=fm2 header.b=es1Lb+PM; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm1 header.b=aSTrQHmE; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KxV9z0SHYz9sG6 for ; Mon, 9 May 2022 15:30:14 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C45A883E59; Mon, 9 May 2022 07:29:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.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=sholland.org header.i=@sholland.org header.b="es1Lb+PM"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="aSTrQHmE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DB99B83F34; Mon, 9 May 2022 07:29:46 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (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 469A583DFE for ; Mon, 9 May 2022 07:29:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 803DE5C00DD; Mon, 9 May 2022 01:29:40 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 09 May 2022 01:29:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1652074180; x=1652160580; bh=XO ZOxLl+BMKoZtVH88eQ9UzMwTbd4+1FjutYfgzkgzI=; b=es1Lb+PM629QbOBwKK BGkHsjz2gyve4W9tREJ3WXFeqhgWNSessLpAjhvVrCmZXhs9+LQWOXHDrt9Ukpz/ aiqGa0pR2EUCSsFM2lZrO1x7fFIxBO21V0fr4FrcUbyM80dEDD5OAzgyPQZe+Apv dofyhgfddV0eB3EUhegZChtZZWpQIKvRhgMmnlO6ElMfPQNhcmimgZSBPOy+wd+I 2zRVKbfIf/SDNzuFDuplru+RylcBt+JJhMLohQi/HkZD983NE2UzQ0h7ARcJ85k7 oHaqkCOCD6/KmHjUrdGPfsl1LNByDbnblNLpfXdqlz5ob5IEclb30vgGVu+Pel0S Cxyw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1652074180; x=1652160580; bh=XOZOxLl+BMKoZtVH88eQ9UzMwTbd4+1Fjut YfgzkgzI=; b=aSTrQHmEbl0LUgGyNp9Kgz31YkbZdI4kepPjmyFypW0uoXAgIrY NQpeV/Ztg1KrNqmDYSeG0Ie4iKE+WdZafWSkqcdO8nq+G4y2fQ3rcSOguRGwGh0Q 3x0FQTEu5fTfw4AsyaZ7CnXpT6APOEliEhu4/UP6mpb6TdUXfky96ZT78l17mZ+1 HhSBUZr0RWeSxotXpB7OZDeJTSE1k6HGruxjb2Xo19L2v3p/1Ql9vur/2kUx4iyU cR3WV3XWCVkNDn0+8gYn4UfZZEoCOv//+867aJcvMuhQ5pxdaHU3y0/KoBJ4YrcO 1pAI1LLZkk17mnWEGj8/uvHb4zYkS+Qv4Qw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeekgdeljecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpedukeetueduhedtleetvefguddvvdejhfefudelgfduveeggeehgfdu feeitdevteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 9 May 2022 01:29:39 -0400 (EDT) From: Samuel Holland To: u-boot@lists.denx.de, Jagan Teki , Andre Przywara , Lukasz Majewski , Sean Anderson Cc: Samuel Holland , Bin Meng , Heinrich Schuchardt , Maxime Ripard Subject: [PATCH 1/7] clk: sunxi: Store the array sizes in the CCU descriptor Date: Mon, 9 May 2022 00:29:31 -0500 Message-Id: <20220509052937.42283-2-samuel@sholland.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220509052937.42283-1-samuel@sholland.org> References: <20220509052937.42283-1-samuel@sholland.org> MIME-Version: 1.0 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean The reset array size is currently used for bounds checking in the reset driver. The same bounds check should really be done in the clock driver. Currently, the array size is provided to the reset driver separately from the CCU descriptor, which is a bit strange. Let's do this the usual way, with the array sizes next to the arrays themselves. Signed-off-by: Samuel Holland Reviewed-by: Andre Przywara --- drivers/clk/sunxi/clk_a10.c | 2 ++ drivers/clk/sunxi/clk_a10s.c | 2 ++ drivers/clk/sunxi/clk_a23.c | 2 ++ drivers/clk/sunxi/clk_a31.c | 2 ++ drivers/clk/sunxi/clk_a31_r.c | 2 ++ drivers/clk/sunxi/clk_a64.c | 2 ++ drivers/clk/sunxi/clk_a80.c | 4 ++++ drivers/clk/sunxi/clk_a83t.c | 2 ++ drivers/clk/sunxi/clk_h3.c | 2 ++ drivers/clk/sunxi/clk_h6.c | 2 ++ drivers/clk/sunxi/clk_h616.c | 2 ++ drivers/clk/sunxi/clk_h6_r.c | 2 ++ drivers/clk/sunxi/clk_r40.c | 2 ++ drivers/clk/sunxi/clk_v3s.c | 2 ++ include/clk/sunxi.h | 2 ++ 15 files changed, 32 insertions(+) diff --git a/drivers/clk/sunxi/clk_a10.c b/drivers/clk/sunxi/clk_a10.c index 90b929d3d3..6b58cffc8a 100644 --- a/drivers/clk/sunxi/clk_a10.c +++ b/drivers/clk/sunxi/clk_a10.c @@ -65,6 +65,8 @@ static struct ccu_reset a10_resets[] = { static const struct ccu_desc a10_ccu_desc = { .gates = a10_gates, .resets = a10_resets, + .num_gates = ARRAY_SIZE(a10_gates), + .num_resets = ARRAY_SIZE(a10_resets), }; static int a10_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_a10s.c b/drivers/clk/sunxi/clk_a10s.c index addf4f4d5c..81b146ce1e 100644 --- a/drivers/clk/sunxi/clk_a10s.c +++ b/drivers/clk/sunxi/clk_a10s.c @@ -50,6 +50,8 @@ static struct ccu_reset a10s_resets[] = { static const struct ccu_desc a10s_ccu_desc = { .gates = a10s_gates, .resets = a10s_resets, + .num_gates = ARRAY_SIZE(a10s_gates), + .num_resets = ARRAY_SIZE(a10s_resets), }; static int a10s_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_a23.c b/drivers/clk/sunxi/clk_a23.c index c45d2c3529..c7c78bc7d8 100644 --- a/drivers/clk/sunxi/clk_a23.c +++ b/drivers/clk/sunxi/clk_a23.c @@ -69,6 +69,8 @@ static struct ccu_reset a23_resets[] = { static const struct ccu_desc a23_ccu_desc = { .gates = a23_gates, .resets = a23_resets, + .num_gates = ARRAY_SIZE(a23_gates), + .num_resets = ARRAY_SIZE(a23_resets), }; static int a23_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_a31.c b/drivers/clk/sunxi/clk_a31.c index 251fc3b705..c8c7f4ecf5 100644 --- a/drivers/clk/sunxi/clk_a31.c +++ b/drivers/clk/sunxi/clk_a31.c @@ -90,6 +90,8 @@ static struct ccu_reset a31_resets[] = { static const struct ccu_desc a31_ccu_desc = { .gates = a31_gates, .resets = a31_resets, + .num_gates = ARRAY_SIZE(a31_gates), + .num_resets = ARRAY_SIZE(a31_resets), }; static int a31_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_a31_r.c b/drivers/clk/sunxi/clk_a31_r.c index 1f08ea956f..7bf1c4578c 100644 --- a/drivers/clk/sunxi/clk_a31_r.c +++ b/drivers/clk/sunxi/clk_a31_r.c @@ -31,6 +31,8 @@ static struct ccu_reset a31_r_resets[] = { static const struct ccu_desc a31_r_ccu_desc = { .gates = a31_r_gates, .resets = a31_r_resets, + .num_gates = ARRAY_SIZE(a31_r_gates), + .num_resets = ARRAY_SIZE(a31_r_resets), }; static int a31_r_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_a64.c b/drivers/clk/sunxi/clk_a64.c index 1004a79503..6da861ddc1 100644 --- a/drivers/clk/sunxi/clk_a64.c +++ b/drivers/clk/sunxi/clk_a64.c @@ -76,6 +76,8 @@ static const struct ccu_reset a64_resets[] = { static const struct ccu_desc a64_ccu_desc = { .gates = a64_gates, .resets = a64_resets, + .num_gates = ARRAY_SIZE(a64_gates), + .num_resets = ARRAY_SIZE(a64_resets), }; static int a64_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_a80.c b/drivers/clk/sunxi/clk_a80.c index 8a0834d83a..7025d3cbe6 100644 --- a/drivers/clk/sunxi/clk_a80.c +++ b/drivers/clk/sunxi/clk_a80.c @@ -75,11 +75,15 @@ static const struct ccu_reset a80_mmc_resets[] = { static const struct ccu_desc a80_ccu_desc = { .gates = a80_gates, .resets = a80_resets, + .num_gates = ARRAY_SIZE(a80_gates), + .num_resets = ARRAY_SIZE(a80_resets), }; static const struct ccu_desc a80_mmc_clk_desc = { .gates = a80_mmc_gates, .resets = a80_mmc_resets, + .num_gates = ARRAY_SIZE(a80_mmc_gates), + .num_resets = ARRAY_SIZE(a80_mmc_resets), }; static int a80_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_a83t.c b/drivers/clk/sunxi/clk_a83t.c index 8c6043f51e..c50d253f84 100644 --- a/drivers/clk/sunxi/clk_a83t.c +++ b/drivers/clk/sunxi/clk_a83t.c @@ -73,6 +73,8 @@ static struct ccu_reset a83t_resets[] = { static const struct ccu_desc a83t_ccu_desc = { .gates = a83t_gates, .resets = a83t_resets, + .num_gates = ARRAY_SIZE(a83t_gates), + .num_resets = ARRAY_SIZE(a83t_resets), }; static int a83t_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_h3.c b/drivers/clk/sunxi/clk_h3.c index 59afba53ee..22c2b236a8 100644 --- a/drivers/clk/sunxi/clk_h3.c +++ b/drivers/clk/sunxi/clk_h3.c @@ -89,6 +89,8 @@ static struct ccu_reset h3_resets[] = { static const struct ccu_desc h3_ccu_desc = { .gates = h3_gates, .resets = h3_resets, + .num_gates = ARRAY_SIZE(h3_gates), + .num_resets = ARRAY_SIZE(h3_resets), }; static int h3_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_h6.c b/drivers/clk/sunxi/clk_h6.c index 4a53788352..6521811215 100644 --- a/drivers/clk/sunxi/clk_h6.c +++ b/drivers/clk/sunxi/clk_h6.c @@ -90,6 +90,8 @@ static struct ccu_reset h6_resets[] = { static const struct ccu_desc h6_ccu_desc = { .gates = h6_gates, .resets = h6_resets, + .num_gates = ARRAY_SIZE(h6_gates), + .num_resets = ARRAY_SIZE(h6_resets), }; static int h6_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_h616.c b/drivers/clk/sunxi/clk_h616.c index af97d3bb9f..26f74c0fa0 100644 --- a/drivers/clk/sunxi/clk_h616.c +++ b/drivers/clk/sunxi/clk_h616.c @@ -108,6 +108,8 @@ static struct ccu_reset h616_resets[] = { static const struct ccu_desc h616_ccu_desc = { .gates = h616_gates, .resets = h616_resets, + .num_gates = ARRAY_SIZE(h616_gates), + .num_resets = ARRAY_SIZE(h616_resets), }; static int h616_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_h6_r.c b/drivers/clk/sunxi/clk_h6_r.c index b9e527e16a..fee9604551 100644 --- a/drivers/clk/sunxi/clk_h6_r.c +++ b/drivers/clk/sunxi/clk_h6_r.c @@ -35,6 +35,8 @@ static struct ccu_reset h6_r_resets[] = { static const struct ccu_desc h6_r_ccu_desc = { .gates = h6_r_gates, .resets = h6_r_resets, + .num_gates = ARRAY_SIZE(h6_r_gates), + .num_resets = ARRAY_SIZE(h6_r_resets), }; static int h6_r_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_r40.c b/drivers/clk/sunxi/clk_r40.c index 4d5b69a976..456a38a159 100644 --- a/drivers/clk/sunxi/clk_r40.c +++ b/drivers/clk/sunxi/clk_r40.c @@ -100,6 +100,8 @@ static struct ccu_reset r40_resets[] = { static const struct ccu_desc r40_ccu_desc = { .gates = r40_gates, .resets = r40_resets, + .num_gates = ARRAY_SIZE(r40_gates), + .num_resets = ARRAY_SIZE(r40_resets), }; static int r40_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_v3s.c b/drivers/clk/sunxi/clk_v3s.c index cce5c658ca..ab21cd791b 100644 --- a/drivers/clk/sunxi/clk_v3s.c +++ b/drivers/clk/sunxi/clk_v3s.c @@ -50,6 +50,8 @@ static struct ccu_reset v3s_resets[] = { static const struct ccu_desc v3s_ccu_desc = { .gates = v3s_gates, .resets = v3s_resets, + .num_gates = ARRAY_SIZE(v3s_gates), + .num_resets = ARRAY_SIZE(v3s_resets), }; static int v3s_clk_bind(struct udevice *dev) diff --git a/include/clk/sunxi.h b/include/clk/sunxi.h index a2239b990b..5471b9c831 100644 --- a/include/clk/sunxi.h +++ b/include/clk/sunxi.h @@ -65,6 +65,8 @@ struct ccu_reset { struct ccu_desc { const struct ccu_clk_gate *gates; const struct ccu_reset *resets; + u8 num_gates; + u8 num_resets; }; /** From patchwork Mon May 9 05:29:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1628306 X-Patchwork-Delegate: andre.przywara@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.a=rsa-sha256 header.s=fm2 header.b=LNUtiW03; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm1 header.b=Is5Y+jKI; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KxV9p4jS0z9sG6 for ; Mon, 9 May 2022 15:30:06 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F2BD683DE4; Mon, 9 May 2022 07:29:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.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=sholland.org header.i=@sholland.org header.b="LNUtiW03"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="Is5Y+jKI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A081483F40; Mon, 9 May 2022 07:29:47 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (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 3001C83E49 for ; Mon, 9 May 2022 07:29:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 6BA2B5C00FF; Mon, 9 May 2022 01:29:41 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 09 May 2022 01:29:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1652074181; x=1652160581; bh=5W x0ImnXHjcujdHA0L950s8MNPDK76SF3VGW9F2sD74=; b=LNUtiW03nCDm1ac6u5 rs4F8tlQsnA2Lg8dflHNqRj34v32ojFhlslsydiNX616eW6dw7PsF1rG/Y/XEH41 kCCLu1YBCqvUOyvrs1/PaW3UiCIvkNL4EJ5zisVjPaXYAF65MuR7E6FRnCzai74T 3ZGFt4A/JKN0whdL37ZaoFex42K7j+ts5UF5GbPsWPwE7lctfFALm2NBKt6QZsHE kPf7X9mxXqLfFeYg3f/b7LVCsktULA+xPUVbjtsWV4JoALpjUZ+0TpllZx/IH0c/ UJ9xAIMYv7ZbQOtEUf/bmW4h8x9CILaht9Cq9iXXT/5hTld1e4AH6TdE2FTFXnE1 qj8g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1652074181; x=1652160581; bh=5Wx0ImnXHjcujdHA0L950s8MNPDK76SF3VG W9F2sD74=; b=Is5Y+jKIkO5g1RcV6AyMSt/AztLwNUtBA8SIQDJ5xlC6pprGYrz VTW9uYOWjHEBbviGg3sJYl4PUXVpQN9YmIDt+MIYOZ1VBsbdMT/6DOoyj773FzGZ XbpK6GRMsoYDk+bdkMYaOZJ5bM3hAT0y4J7hKQNijnImA4C3CBEiXBBThNSwi6AY SEgnKuWOcZ8GFx4FqsV6j3SwrRl/VJpMxJglbxhH9MyZk6NZZQTPU114ikh9S8GE ytxidj9IW5sfUP4Zr6OTzOQDf9d47MCHWL7Ozmk/9Pmz+YR8f/Az31U6wcV47r76 DvHBkM7AkDk7UKjlMf9e73nv9FaMhA9MMxA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeekgdelkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpedukeetueduhedtleetvefguddvvdejhfefudelgfduveeggeehgfdu feeitdevteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 9 May 2022 01:29:40 -0400 (EDT) From: Samuel Holland To: u-boot@lists.denx.de, Jagan Teki , Andre Przywara , Lukasz Majewski , Sean Anderson Cc: Samuel Holland , Bin Meng , Heinrich Schuchardt , Maxime Ripard Subject: [PATCH 2/7] clk: sunxi: Prevent out-of-bounds gate array access Date: Mon, 9 May 2022 00:29:32 -0500 Message-Id: <20220509052937.42283-3-samuel@sholland.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220509052937.42283-1-samuel@sholland.org> References: <20220509052937.42283-1-samuel@sholland.org> MIME-Version: 1.0 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Because the gate arrays are not given explicit sizes, the arrays are only as large as the highest-numbered gate described in the driver. However, only a subset of the CCU clocks are needed by U-Boot. So there are valid clock specifiers with indexes greater than the size of the arrays. Referencing any of these clocks causes out-of-bounds access. Fix this by checking the identifier against the size of the array. Fixes: 0d47bc705651 ("clk: Add Allwinner A64 CLK driver") Signed-off-by: Samuel Holland Reviewed-by: Andre Przywara --- drivers/clk/sunxi/clk_sunxi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/clk/sunxi/clk_sunxi.c b/drivers/clk/sunxi/clk_sunxi.c index 9673b58a49..3108e5b66d 100644 --- a/drivers/clk/sunxi/clk_sunxi.c +++ b/drivers/clk/sunxi/clk_sunxi.c @@ -18,6 +18,9 @@ static const struct ccu_clk_gate *priv_to_gate(struct ccu_priv *priv, unsigned long id) { + if (id >= priv->desc->num_gates) + return NULL; + return &priv->desc->gates[id]; } @@ -27,7 +30,7 @@ static int sunxi_set_gate(struct clk *clk, bool on) const struct ccu_clk_gate *gate = priv_to_gate(priv, clk->id); u32 reg; - if (!(gate->flags & CCU_CLK_F_IS_VALID)) { + if (!gate || !(gate->flags & CCU_CLK_F_IS_VALID)) { printf("%s: (CLK#%ld) unhandled\n", __func__, clk->id); return 0; } From patchwork Mon May 9 05:29:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1628308 X-Patchwork-Delegate: andre.przywara@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.a=rsa-sha256 header.s=fm2 header.b=wqX/XvmR; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm1 header.b=aejdxLp6; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KxVB95CXVz9sG6 for ; Mon, 9 May 2022 15:30:25 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3566083E97; Mon, 9 May 2022 07:30:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.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=sholland.org header.i=@sholland.org header.b="wqX/XvmR"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="aejdxLp6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 17EF883E0F; Mon, 9 May 2022 07:29:51 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (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 18CCC802EB for ; Mon, 9 May 2022 07:29:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 5478B5C0124; Mon, 9 May 2022 01:29:42 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Mon, 09 May 2022 01:29:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1652074182; x=1652160582; bh=/u lppyiWCrgdvDGXkeOF/eY8KqqMx0cmaLthq0J5Fbc=; b=wqX/XvmR38bNvT76xP SIfK3/QTgsMwPrxmJ89Uw8YxguCfiH8GDpvidt+vvbgBECq//uO7ilzDkQq+1Wtz yQeGkEqbUFwVk9w0Hgv/48A4XmFjE2dElui2UKkK2dMzN827q/ipr4qOscmZI31O lI5AAUtxqF54s8H1Vkh1/dtEyHLs9HDR3pZrjq5Q29dm7o9h2etvd+MwjQw6sHT+ yXSBUTkwW/XcwQz1tPbr18KPPz1d7LK7sgV28arJSPmAc14JvmBkYclUpdzBEvWf A27jaCOa7PdcHJrPz+kr9HJVvMWOOUQ/aMMWLwn6Xe+so9m8+hsM2xnOIW0weEK/ yasA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1652074182; x=1652160582; bh=/ulppyiWCrgdvDGXkeOF/eY8KqqMx0cmaLt hq0J5Fbc=; b=aejdxLp6btVifkNazOfL1avau/M0dPyMWrK7gJdezSpesmFufRm y4A9UlM7e+Za5cGbDqBxYl6eT4pu3C/5+pW8ZS0vEtG50uZ2TJaQN905MKHq9Eyu fAdtYioRB+IvKPOLG6fRXsNBqJXSbylWyq7R09W4vsLI832qqlJECgGad0EJJ+rp 1ZYkK2WNliFjY4/sPSUNvU9GluBudLuqFMeMaAyhHLujgK/5zywLxV2dP8L+DgAi 36V9rwWZhrKEHWOBfTqWBxX74x0yTea9c+d10ocw7OTzV17u5VjGFiB9481k2ujR CRNT0oFRKhQqm5trfPdHM4qBnmgJp++F3Jw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeekgdeljecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpedukeetueduhedtleetvefguddvvdejhfefudelgfduveeggeehgfdu feeitdevteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 9 May 2022 01:29:41 -0400 (EDT) From: Samuel Holland To: u-boot@lists.denx.de, Jagan Teki , Andre Przywara , Lukasz Majewski , Sean Anderson Cc: Samuel Holland , Bin Meng , Heinrich Schuchardt , Maxime Ripard Subject: [PATCH 3/7] reset: sunxi: Get the reset count from the CCU descriptor Date: Mon, 9 May 2022 00:29:33 -0500 Message-Id: <20220509052937.42283-4-samuel@sholland.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220509052937.42283-1-samuel@sholland.org> References: <20220509052937.42283-1-samuel@sholland.org> MIME-Version: 1.0 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean This allows all of the clock drivers to use a common bind function. Signed-off-by: Samuel Holland Reviewed-by: Andre Przywara --- drivers/clk/sunxi/clk_a10.c | 7 +------ drivers/clk/sunxi/clk_a10s.c | 7 +------ drivers/clk/sunxi/clk_a23.c | 7 +------ drivers/clk/sunxi/clk_a31.c | 7 +------ drivers/clk/sunxi/clk_a31_r.c | 7 +------ drivers/clk/sunxi/clk_a64.c | 7 +------ drivers/clk/sunxi/clk_a80.c | 12 +----------- drivers/clk/sunxi/clk_a83t.c | 7 +------ drivers/clk/sunxi/clk_h3.c | 7 +------ drivers/clk/sunxi/clk_h6.c | 7 +------ drivers/clk/sunxi/clk_h616.c | 7 +------ drivers/clk/sunxi/clk_h6_r.c | 7 +------ drivers/clk/sunxi/clk_r40.c | 7 +------ drivers/clk/sunxi/clk_sunxi.c | 5 +++++ drivers/clk/sunxi/clk_v3s.c | 7 +------ drivers/reset/reset-sunxi.c | 6 ++---- include/clk/sunxi.h | 9 +++++++-- 17 files changed, 28 insertions(+), 95 deletions(-) diff --git a/drivers/clk/sunxi/clk_a10.c b/drivers/clk/sunxi/clk_a10.c index 6b58cffc8a..e5374f6cf0 100644 --- a/drivers/clk/sunxi/clk_a10.c +++ b/drivers/clk/sunxi/clk_a10.c @@ -69,11 +69,6 @@ static const struct ccu_desc a10_ccu_desc = { .num_resets = ARRAY_SIZE(a10_resets), }; -static int a10_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(a10_resets)); -} - static const struct udevice_id a10_ccu_ids[] = { { .compatible = "allwinner,sun4i-a10-ccu", .data = (ulong)&a10_ccu_desc }, @@ -89,5 +84,5 @@ U_BOOT_DRIVER(clk_sun4i_a10) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = a10_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_a10s.c b/drivers/clk/sunxi/clk_a10s.c index 81b146ce1e..07d518c121 100644 --- a/drivers/clk/sunxi/clk_a10s.c +++ b/drivers/clk/sunxi/clk_a10s.c @@ -54,11 +54,6 @@ static const struct ccu_desc a10s_ccu_desc = { .num_resets = ARRAY_SIZE(a10s_resets), }; -static int a10s_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(a10s_resets)); -} - static const struct udevice_id a10s_ccu_ids[] = { { .compatible = "allwinner,sun5i-a10s-ccu", .data = (ulong)&a10s_ccu_desc }, @@ -74,5 +69,5 @@ U_BOOT_DRIVER(clk_sun5i_a10s) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = a10s_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_a23.c b/drivers/clk/sunxi/clk_a23.c index c7c78bc7d8..9c0e5db07c 100644 --- a/drivers/clk/sunxi/clk_a23.c +++ b/drivers/clk/sunxi/clk_a23.c @@ -73,11 +73,6 @@ static const struct ccu_desc a23_ccu_desc = { .num_resets = ARRAY_SIZE(a23_resets), }; -static int a23_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(a23_resets)); -} - static const struct udevice_id a23_clk_ids[] = { { .compatible = "allwinner,sun8i-a23-ccu", .data = (ulong)&a23_ccu_desc }, @@ -93,5 +88,5 @@ U_BOOT_DRIVER(clk_sun8i_a23) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = a23_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_a31.c b/drivers/clk/sunxi/clk_a31.c index c8c7f4ecf5..3d0767e290 100644 --- a/drivers/clk/sunxi/clk_a31.c +++ b/drivers/clk/sunxi/clk_a31.c @@ -94,11 +94,6 @@ static const struct ccu_desc a31_ccu_desc = { .num_resets = ARRAY_SIZE(a31_resets), }; -static int a31_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(a31_resets)); -} - static const struct udevice_id a31_clk_ids[] = { { .compatible = "allwinner,sun6i-a31-ccu", .data = (ulong)&a31_ccu_desc }, @@ -112,5 +107,5 @@ U_BOOT_DRIVER(clk_sun6i_a31) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = a31_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_a31_r.c b/drivers/clk/sunxi/clk_a31_r.c index 7bf1c4578c..04c238204d 100644 --- a/drivers/clk/sunxi/clk_a31_r.c +++ b/drivers/clk/sunxi/clk_a31_r.c @@ -35,11 +35,6 @@ static const struct ccu_desc a31_r_ccu_desc = { .num_resets = ARRAY_SIZE(a31_r_resets), }; -static int a31_r_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(a31_r_resets)); -} - static const struct udevice_id a31_r_clk_ids[] = { { .compatible = "allwinner,sun8i-a83t-r-ccu", .data = (ulong)&a31_r_ccu_desc }, @@ -57,5 +52,5 @@ U_BOOT_DRIVER(clk_sun6i_a31_r) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = a31_r_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_a64.c b/drivers/clk/sunxi/clk_a64.c index 6da861ddc1..b41260cbe6 100644 --- a/drivers/clk/sunxi/clk_a64.c +++ b/drivers/clk/sunxi/clk_a64.c @@ -80,11 +80,6 @@ static const struct ccu_desc a64_ccu_desc = { .num_resets = ARRAY_SIZE(a64_resets), }; -static int a64_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(a64_resets)); -} - static const struct udevice_id a64_ccu_ids[] = { { .compatible = "allwinner,sun50i-a64-ccu", .data = (ulong)&a64_ccu_desc }, @@ -98,5 +93,5 @@ U_BOOT_DRIVER(clk_sun50i_a64) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = a64_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_a80.c b/drivers/clk/sunxi/clk_a80.c index 7025d3cbe6..a3ad3b7804 100644 --- a/drivers/clk/sunxi/clk_a80.c +++ b/drivers/clk/sunxi/clk_a80.c @@ -86,16 +86,6 @@ static const struct ccu_desc a80_mmc_clk_desc = { .num_resets = ARRAY_SIZE(a80_mmc_resets), }; -static int a80_clk_bind(struct udevice *dev) -{ - ulong count = ARRAY_SIZE(a80_resets); - - if (device_is_compatible(dev, "allwinner,sun9i-a80-mmc-config-clk")) - count = ARRAY_SIZE(a80_mmc_resets); - - return sunxi_reset_bind(dev, count); -} - static const struct udevice_id a80_ccu_ids[] = { { .compatible = "allwinner,sun9i-a80-ccu", .data = (ulong)&a80_ccu_desc }, @@ -111,5 +101,5 @@ U_BOOT_DRIVER(clk_sun9i_a80) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = a80_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_a83t.c b/drivers/clk/sunxi/clk_a83t.c index c50d253f84..cad5b484cf 100644 --- a/drivers/clk/sunxi/clk_a83t.c +++ b/drivers/clk/sunxi/clk_a83t.c @@ -77,11 +77,6 @@ static const struct ccu_desc a83t_ccu_desc = { .num_resets = ARRAY_SIZE(a83t_resets), }; -static int a83t_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(a83t_resets)); -} - static const struct udevice_id a83t_clk_ids[] = { { .compatible = "allwinner,sun8i-a83t-ccu", .data = (ulong)&a83t_ccu_desc }, @@ -95,5 +90,5 @@ U_BOOT_DRIVER(clk_sun8i_a83t) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = a83t_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_h3.c b/drivers/clk/sunxi/clk_h3.c index 22c2b236a8..3b4e9af111 100644 --- a/drivers/clk/sunxi/clk_h3.c +++ b/drivers/clk/sunxi/clk_h3.c @@ -93,11 +93,6 @@ static const struct ccu_desc h3_ccu_desc = { .num_resets = ARRAY_SIZE(h3_resets), }; -static int h3_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(h3_resets)); -} - static const struct udevice_id h3_ccu_ids[] = { { .compatible = "allwinner,sun8i-h3-ccu", .data = (ulong)&h3_ccu_desc }, @@ -113,5 +108,5 @@ U_BOOT_DRIVER(clk_sun8i_h3) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = h3_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_h6.c b/drivers/clk/sunxi/clk_h6.c index 6521811215..93343b090d 100644 --- a/drivers/clk/sunxi/clk_h6.c +++ b/drivers/clk/sunxi/clk_h6.c @@ -94,11 +94,6 @@ static const struct ccu_desc h6_ccu_desc = { .num_resets = ARRAY_SIZE(h6_resets), }; -static int h6_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(h6_resets)); -} - static const struct udevice_id h6_ccu_ids[] = { { .compatible = "allwinner,sun50i-h6-ccu", .data = (ulong)&h6_ccu_desc }, @@ -112,5 +107,5 @@ U_BOOT_DRIVER(clk_sun50i_h6) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = h6_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_h616.c b/drivers/clk/sunxi/clk_h616.c index 26f74c0fa0..e791736093 100644 --- a/drivers/clk/sunxi/clk_h616.c +++ b/drivers/clk/sunxi/clk_h616.c @@ -112,11 +112,6 @@ static const struct ccu_desc h616_ccu_desc = { .num_resets = ARRAY_SIZE(h616_resets), }; -static int h616_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(h616_resets)); -} - static const struct udevice_id h616_ccu_ids[] = { { .compatible = "allwinner,sun50i-h616-ccu", .data = (ulong)&h616_ccu_desc }, @@ -130,5 +125,5 @@ U_BOOT_DRIVER(clk_sun50i_h616) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = h616_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_h6_r.c b/drivers/clk/sunxi/clk_h6_r.c index fee9604551..0f5cefd687 100644 --- a/drivers/clk/sunxi/clk_h6_r.c +++ b/drivers/clk/sunxi/clk_h6_r.c @@ -39,11 +39,6 @@ static const struct ccu_desc h6_r_ccu_desc = { .num_resets = ARRAY_SIZE(h6_r_resets), }; -static int h6_r_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(h6_r_resets)); -} - static const struct udevice_id h6_r_clk_ids[] = { { .compatible = "allwinner,sun50i-h6-r-ccu", .data = (ulong)&h6_r_ccu_desc }, @@ -59,5 +54,5 @@ U_BOOT_DRIVER(clk_sun6i_h6_r) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = h6_r_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_r40.c b/drivers/clk/sunxi/clk_r40.c index 456a38a159..a59ac06975 100644 --- a/drivers/clk/sunxi/clk_r40.c +++ b/drivers/clk/sunxi/clk_r40.c @@ -104,11 +104,6 @@ static const struct ccu_desc r40_ccu_desc = { .num_resets = ARRAY_SIZE(r40_resets), }; -static int r40_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(r40_resets)); -} - static const struct udevice_id r40_clk_ids[] = { { .compatible = "allwinner,sun8i-r40-ccu", .data = (ulong)&r40_ccu_desc }, @@ -122,5 +117,5 @@ U_BOOT_DRIVER(clk_sun8i_r40) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = r40_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_sunxi.c b/drivers/clk/sunxi/clk_sunxi.c index 3108e5b66d..e1129f6ccf 100644 --- a/drivers/clk/sunxi/clk_sunxi.c +++ b/drivers/clk/sunxi/clk_sunxi.c @@ -64,6 +64,11 @@ struct clk_ops sunxi_clk_ops = { .disable = sunxi_clk_disable, }; +int sunxi_clk_bind(struct udevice *dev) +{ + return sunxi_reset_bind(dev); +} + int sunxi_clk_probe(struct udevice *dev) { struct ccu_priv *priv = dev_get_priv(dev); diff --git a/drivers/clk/sunxi/clk_v3s.c b/drivers/clk/sunxi/clk_v3s.c index ab21cd791b..c6a17b4535 100644 --- a/drivers/clk/sunxi/clk_v3s.c +++ b/drivers/clk/sunxi/clk_v3s.c @@ -54,11 +54,6 @@ static const struct ccu_desc v3s_ccu_desc = { .num_resets = ARRAY_SIZE(v3s_resets), }; -static int v3s_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(v3s_resets)); -} - static const struct udevice_id v3s_clk_ids[] = { { .compatible = "allwinner,sun8i-v3s-ccu", .data = (ulong)&v3s_ccu_desc }, @@ -74,5 +69,5 @@ U_BOOT_DRIVER(clk_sun8i_v3s) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = v3s_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/reset/reset-sunxi.c b/drivers/reset/reset-sunxi.c index 8b95938dfe..4d02d02834 100644 --- a/drivers/reset/reset-sunxi.c +++ b/drivers/reset/reset-sunxi.c @@ -19,7 +19,6 @@ struct sunxi_reset_priv { void *base; - ulong count; const struct ccu_desc *desc; }; @@ -35,7 +34,7 @@ static int sunxi_reset_request(struct reset_ctl *reset_ctl) debug("%s: (RST#%ld)\n", __func__, reset_ctl->id); - if (reset_ctl->id >= priv->count) + if (reset_ctl->id >= priv->desc->num_resets) return -EINVAL; return 0; @@ -99,7 +98,7 @@ static int sunxi_reset_probe(struct udevice *dev) return 0; } -int sunxi_reset_bind(struct udevice *dev, ulong count) +int sunxi_reset_bind(struct udevice *dev) { struct udevice *rst_dev; struct sunxi_reset_priv *priv; @@ -112,7 +111,6 @@ int sunxi_reset_bind(struct udevice *dev, ulong count) return ret; } priv = malloc(sizeof(struct sunxi_reset_priv)); - priv->count = count; priv->desc = (const struct ccu_desc *)dev_get_driver_data(dev); dev_set_priv(rst_dev, priv); diff --git a/include/clk/sunxi.h b/include/clk/sunxi.h index 5471b9c831..c798c226f5 100644 --- a/include/clk/sunxi.h +++ b/include/clk/sunxi.h @@ -80,6 +80,12 @@ struct ccu_priv { const struct ccu_desc *desc; }; +/** + * sunxi_clk_bind - common sunxi clock bind + * @dev: clock device + */ +int sunxi_clk_bind(struct udevice *dev); + /** * sunxi_clk_probe - common sunxi clock probe * @dev: clock device @@ -92,9 +98,8 @@ extern struct clk_ops sunxi_clk_ops; * sunxi_reset_bind() - reset binding * * @dev: reset device - * @count: reset count * Return: 0 success, or error value */ -int sunxi_reset_bind(struct udevice *dev, ulong count); +int sunxi_reset_bind(struct udevice *dev); #endif /* _CLK_SUNXI_H */ From patchwork Mon May 9 05:29:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1628310 X-Patchwork-Delegate: andre.przywara@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.a=rsa-sha256 header.s=fm2 header.b=kA7P1dTa; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm1 header.b=FSrHLvMM; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KxVBd6FlYz9sG6 for ; Mon, 9 May 2022 15:30:49 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6590A83F0A; Mon, 9 May 2022 07:30:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.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=sholland.org header.i=@sholland.org header.b="kA7P1dTa"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="FSrHLvMM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B1FAC83E96; Mon, 9 May 2022 07:29:52 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (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 0AF7583EB7 for ; Mon, 9 May 2022 07:29:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 307285C00E9; Mon, 9 May 2022 01:29:43 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 09 May 2022 01:29:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1652074183; x=1652160583; bh=vt N6iWPf/2QSmtyiSUOCuVs5meJjg8s2G+RnGKU4rOM=; b=kA7P1dTayoS0r6DCrx KziEZSNdffTQRkKQCEZuEauroNhzGyMTGimOoz1AuzX4o+USQHw9PSM5DKMET+BJ NdW4xkoLzXmUDd0VWX+SrnJjIPaz1lpfXhZxh27s7Z4/ssRZAaBwlwuwXbmaIYbT 4H/oKDPFRNhVm9OHhKyIBBaN7i1kIc0YUX7IBDX7sSWIFB9fV4mgwE3uJ7Eadads 8bk3R+cqcTvlKluIBjSoqhRJXL3KPpTiD28fbwQFYSYzfMoquqlhtFZ7kdIm6kQy dusXhDP7okDQN2LTKKbZWSK+VTeXO/UpCxTIhxRZrXQUt/+WCfy8UFno2a68PJ9j h1KA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1652074183; x=1652160583; bh=vtN6iWPf/2QSmtyiSUOCuVs5meJjg8s2G+R nGKU4rOM=; b=FSrHLvMMTX1CjPMQuHT3T38fd5gUdpHZtPGFQU40fPBShVbLllC 4VZj5BBMhPTNilXDhrH7P9gKZWfTFL4mZ3ZvhRqrSiFEKO9qh/BVjAUmYaKu1wIJ VVWsMA1Q7eQIOzaOp587kgkdzsMQkPoOC9rk95CrE6ezr2mxEFiCQ9xgL60k+QBi ikRazMST2vrYXCFEXf3r4DfOvqWakpREiDjy4BTj6oi5TR1QoYqoCZNJl7fWa5Ot +0Rr/wCXdkdwu6PncKbL9f34TOekA/Ul3M+Ta2ynNl+4cSErS2Axpb0aXsXMe4ew 3LfvddWoFS1qNO5ugrdSAptXdQ4c57rqaHA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeekgdeljecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpedukeetueduhedtleetvefguddvvdejhfefudelgfduveeggeehgfdu feeitdevteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 9 May 2022 01:29:42 -0400 (EDT) From: Samuel Holland To: u-boot@lists.denx.de, Jagan Teki , Andre Przywara , Lukasz Majewski , Sean Anderson Cc: Samuel Holland , Bin Meng , Heinrich Schuchardt , Maxime Ripard Subject: [PATCH 4/7] clk: sunxi: Use a single driver for all variants Date: Mon, 9 May 2022 00:29:34 -0500 Message-Id: <20220509052937.42283-5-samuel@sholland.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220509052937.42283-1-samuel@sholland.org> References: <20220509052937.42283-1-samuel@sholland.org> MIME-Version: 1.0 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Now that all of the variants use the same bind/probe functions and ops, there is no need to have a separate driver for each variant. Since most SoCs contain two variants (the main CCU and PRCM CCU), this saves a bit of firmware size and RAM. Signed-off-by: Samuel Holland Reviewed-by: Andre Przywara --- drivers/clk/sunxi/clk_a10.c | 20 +----- drivers/clk/sunxi/clk_a10s.c | 20 +----- drivers/clk/sunxi/clk_a23.c | 20 +----- drivers/clk/sunxi/clk_a31.c | 18 +----- drivers/clk/sunxi/clk_a31_r.c | 22 +------ drivers/clk/sunxi/clk_a64.c | 18 +----- drivers/clk/sunxi/clk_a80.c | 22 +------ drivers/clk/sunxi/clk_a83t.c | 18 +----- drivers/clk/sunxi/clk_h3.c | 20 +----- drivers/clk/sunxi/clk_h6.c | 18 +----- drivers/clk/sunxi/clk_h616.c | 18 +----- drivers/clk/sunxi/clk_h6_r.c | 20 +----- drivers/clk/sunxi/clk_r40.c | 18 +----- drivers/clk/sunxi/clk_sunxi.c | 118 +++++++++++++++++++++++++++++++++- drivers/clk/sunxi/clk_v3s.c | 20 +----- include/clk/sunxi.h | 12 ---- 16 files changed, 131 insertions(+), 271 deletions(-) diff --git a/drivers/clk/sunxi/clk_a10.c b/drivers/clk/sunxi/clk_a10.c index e5374f6cf0..4752a1167b 100644 --- a/drivers/clk/sunxi/clk_a10.c +++ b/drivers/clk/sunxi/clk_a10.c @@ -62,27 +62,9 @@ static struct ccu_reset a10_resets[] = { [RST_USB_PHY2] = RESET(0x0cc, BIT(2)), }; -static const struct ccu_desc a10_ccu_desc = { +const struct ccu_desc a10_ccu_desc = { .gates = a10_gates, .resets = a10_resets, .num_gates = ARRAY_SIZE(a10_gates), .num_resets = ARRAY_SIZE(a10_resets), }; - -static const struct udevice_id a10_ccu_ids[] = { - { .compatible = "allwinner,sun4i-a10-ccu", - .data = (ulong)&a10_ccu_desc }, - { .compatible = "allwinner,sun7i-a20-ccu", - .data = (ulong)&a10_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun4i_a10) = { - .name = "sun4i_a10_ccu", - .id = UCLASS_CLK, - .of_match = a10_ccu_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_a10s.c b/drivers/clk/sunxi/clk_a10s.c index 07d518c121..9619c5f935 100644 --- a/drivers/clk/sunxi/clk_a10s.c +++ b/drivers/clk/sunxi/clk_a10s.c @@ -47,27 +47,9 @@ static struct ccu_reset a10s_resets[] = { [RST_USB_PHY1] = RESET(0x0cc, BIT(1)), }; -static const struct ccu_desc a10s_ccu_desc = { +const struct ccu_desc a10s_ccu_desc = { .gates = a10s_gates, .resets = a10s_resets, .num_gates = ARRAY_SIZE(a10s_gates), .num_resets = ARRAY_SIZE(a10s_resets), }; - -static const struct udevice_id a10s_ccu_ids[] = { - { .compatible = "allwinner,sun5i-a10s-ccu", - .data = (ulong)&a10s_ccu_desc }, - { .compatible = "allwinner,sun5i-a13-ccu", - .data = (ulong)&a10s_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun5i_a10s) = { - .name = "sun5i_a10s_ccu", - .id = UCLASS_CLK, - .of_match = a10s_ccu_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_a23.c b/drivers/clk/sunxi/clk_a23.c index 9c0e5db07c..5e19c11c23 100644 --- a/drivers/clk/sunxi/clk_a23.c +++ b/drivers/clk/sunxi/clk_a23.c @@ -66,27 +66,9 @@ static struct ccu_reset a23_resets[] = { [RST_BUS_UART4] = RESET(0x2d8, BIT(20)), }; -static const struct ccu_desc a23_ccu_desc = { +const struct ccu_desc a23_ccu_desc = { .gates = a23_gates, .resets = a23_resets, .num_gates = ARRAY_SIZE(a23_gates), .num_resets = ARRAY_SIZE(a23_resets), }; - -static const struct udevice_id a23_clk_ids[] = { - { .compatible = "allwinner,sun8i-a23-ccu", - .data = (ulong)&a23_ccu_desc }, - { .compatible = "allwinner,sun8i-a33-ccu", - .data = (ulong)&a23_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun8i_a23) = { - .name = "sun8i_a23_ccu", - .id = UCLASS_CLK, - .of_match = a23_clk_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_a31.c b/drivers/clk/sunxi/clk_a31.c index 3d0767e290..0aaaaf58ea 100644 --- a/drivers/clk/sunxi/clk_a31.c +++ b/drivers/clk/sunxi/clk_a31.c @@ -87,25 +87,9 @@ static struct ccu_reset a31_resets[] = { [RST_APB2_UART5] = RESET(0x2d8, BIT(21)), }; -static const struct ccu_desc a31_ccu_desc = { +const struct ccu_desc a31_ccu_desc = { .gates = a31_gates, .resets = a31_resets, .num_gates = ARRAY_SIZE(a31_gates), .num_resets = ARRAY_SIZE(a31_resets), }; - -static const struct udevice_id a31_clk_ids[] = { - { .compatible = "allwinner,sun6i-a31-ccu", - .data = (ulong)&a31_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun6i_a31) = { - .name = "sun6i_a31_ccu", - .id = UCLASS_CLK, - .of_match = a31_clk_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_a31_r.c b/drivers/clk/sunxi/clk_a31_r.c index 04c238204d..fa6887fa75 100644 --- a/drivers/clk/sunxi/clk_a31_r.c +++ b/drivers/clk/sunxi/clk_a31_r.c @@ -28,29 +28,9 @@ static struct ccu_reset a31_r_resets[] = { [RST_APB0_I2C] = RESET(0x0b0, BIT(6)), }; -static const struct ccu_desc a31_r_ccu_desc = { +const struct ccu_desc a31_r_ccu_desc = { .gates = a31_r_gates, .resets = a31_r_resets, .num_gates = ARRAY_SIZE(a31_r_gates), .num_resets = ARRAY_SIZE(a31_r_resets), }; - -static const struct udevice_id a31_r_clk_ids[] = { - { .compatible = "allwinner,sun8i-a83t-r-ccu", - .data = (ulong)&a31_r_ccu_desc }, - { .compatible = "allwinner,sun8i-h3-r-ccu", - .data = (ulong)&a31_r_ccu_desc }, - { .compatible = "allwinner,sun50i-a64-r-ccu", - .data = (ulong)&a31_r_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun6i_a31_r) = { - .name = "sun6i_a31_r_ccu", - .id = UCLASS_CLK, - .of_match = a31_r_clk_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_a64.c b/drivers/clk/sunxi/clk_a64.c index b41260cbe6..bd50cd4dda 100644 --- a/drivers/clk/sunxi/clk_a64.c +++ b/drivers/clk/sunxi/clk_a64.c @@ -73,25 +73,9 @@ static const struct ccu_reset a64_resets[] = { [RST_BUS_UART4] = RESET(0x2d8, BIT(20)), }; -static const struct ccu_desc a64_ccu_desc = { +const struct ccu_desc a64_ccu_desc = { .gates = a64_gates, .resets = a64_resets, .num_gates = ARRAY_SIZE(a64_gates), .num_resets = ARRAY_SIZE(a64_resets), }; - -static const struct udevice_id a64_ccu_ids[] = { - { .compatible = "allwinner,sun50i-a64-ccu", - .data = (ulong)&a64_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun50i_a64) = { - .name = "sun50i_a64_ccu", - .id = UCLASS_CLK, - .of_match = a64_ccu_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_a80.c b/drivers/clk/sunxi/clk_a80.c index a3ad3b7804..561380c817 100644 --- a/drivers/clk/sunxi/clk_a80.c +++ b/drivers/clk/sunxi/clk_a80.c @@ -72,34 +72,16 @@ static const struct ccu_reset a80_mmc_resets[] = { [3] = GATE(0xc, BIT(18)), }; -static const struct ccu_desc a80_ccu_desc = { +const struct ccu_desc a80_ccu_desc = { .gates = a80_gates, .resets = a80_resets, .num_gates = ARRAY_SIZE(a80_gates), .num_resets = ARRAY_SIZE(a80_resets), }; -static const struct ccu_desc a80_mmc_clk_desc = { +const struct ccu_desc a80_mmc_clk_desc = { .gates = a80_mmc_gates, .resets = a80_mmc_resets, .num_gates = ARRAY_SIZE(a80_mmc_gates), .num_resets = ARRAY_SIZE(a80_mmc_resets), }; - -static const struct udevice_id a80_ccu_ids[] = { - { .compatible = "allwinner,sun9i-a80-ccu", - .data = (ulong)&a80_ccu_desc }, - { .compatible = "allwinner,sun9i-a80-mmc-config-clk", - .data = (ulong)&a80_mmc_clk_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun9i_a80) = { - .name = "sun9i_a80_ccu", - .id = UCLASS_CLK, - .of_match = a80_ccu_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_a83t.c b/drivers/clk/sunxi/clk_a83t.c index cad5b484cf..e246437af2 100644 --- a/drivers/clk/sunxi/clk_a83t.c +++ b/drivers/clk/sunxi/clk_a83t.c @@ -70,25 +70,9 @@ static struct ccu_reset a83t_resets[] = { [RST_BUS_UART4] = RESET(0x2d8, BIT(20)), }; -static const struct ccu_desc a83t_ccu_desc = { +const struct ccu_desc a83t_ccu_desc = { .gates = a83t_gates, .resets = a83t_resets, .num_gates = ARRAY_SIZE(a83t_gates), .num_resets = ARRAY_SIZE(a83t_resets), }; - -static const struct udevice_id a83t_clk_ids[] = { - { .compatible = "allwinner,sun8i-a83t-ccu", - .data = (ulong)&a83t_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun8i_a83t) = { - .name = "sun8i_a83t_ccu", - .id = UCLASS_CLK, - .of_match = a83t_clk_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_h3.c b/drivers/clk/sunxi/clk_h3.c index 3b4e9af111..5d2a53185e 100644 --- a/drivers/clk/sunxi/clk_h3.c +++ b/drivers/clk/sunxi/clk_h3.c @@ -86,27 +86,9 @@ static struct ccu_reset h3_resets[] = { [RST_BUS_UART3] = RESET(0x2d8, BIT(19)), }; -static const struct ccu_desc h3_ccu_desc = { +const struct ccu_desc h3_ccu_desc = { .gates = h3_gates, .resets = h3_resets, .num_gates = ARRAY_SIZE(h3_gates), .num_resets = ARRAY_SIZE(h3_resets), }; - -static const struct udevice_id h3_ccu_ids[] = { - { .compatible = "allwinner,sun8i-h3-ccu", - .data = (ulong)&h3_ccu_desc }, - { .compatible = "allwinner,sun50i-h5-ccu", - .data = (ulong)&h3_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun8i_h3) = { - .name = "sun8i_h3_ccu", - .id = UCLASS_CLK, - .of_match = h3_ccu_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_h6.c b/drivers/clk/sunxi/clk_h6.c index 93343b090d..02ba07bdaf 100644 --- a/drivers/clk/sunxi/clk_h6.c +++ b/drivers/clk/sunxi/clk_h6.c @@ -87,25 +87,9 @@ static struct ccu_reset h6_resets[] = { [RST_BUS_OTG] = RESET(0xa8c, BIT(24)), }; -static const struct ccu_desc h6_ccu_desc = { +const struct ccu_desc h6_ccu_desc = { .gates = h6_gates, .resets = h6_resets, .num_gates = ARRAY_SIZE(h6_gates), .num_resets = ARRAY_SIZE(h6_resets), }; - -static const struct udevice_id h6_ccu_ids[] = { - { .compatible = "allwinner,sun50i-h6-ccu", - .data = (ulong)&h6_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun50i_h6) = { - .name = "sun50i_h6_ccu", - .id = UCLASS_CLK, - .of_match = h6_ccu_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_h616.c b/drivers/clk/sunxi/clk_h616.c index e791736093..abcc6fc264 100644 --- a/drivers/clk/sunxi/clk_h616.c +++ b/drivers/clk/sunxi/clk_h616.c @@ -105,25 +105,9 @@ static struct ccu_reset h616_resets[] = { [RST_BUS_OTG] = RESET(0xa8c, BIT(24)), }; -static const struct ccu_desc h616_ccu_desc = { +const struct ccu_desc h616_ccu_desc = { .gates = h616_gates, .resets = h616_resets, .num_gates = ARRAY_SIZE(h616_gates), .num_resets = ARRAY_SIZE(h616_resets), }; - -static const struct udevice_id h616_ccu_ids[] = { - { .compatible = "allwinner,sun50i-h616-ccu", - .data = (ulong)&h616_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun50i_h616) = { - .name = "sun50i_h616_ccu", - .id = UCLASS_CLK, - .of_match = h616_ccu_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_h6_r.c b/drivers/clk/sunxi/clk_h6_r.c index 0f5cefd687..d82f791e79 100644 --- a/drivers/clk/sunxi/clk_h6_r.c +++ b/drivers/clk/sunxi/clk_h6_r.c @@ -32,27 +32,9 @@ static struct ccu_reset h6_r_resets[] = { [RST_R_APB1_W1] = RESET(0x1ec, BIT(16)), }; -static const struct ccu_desc h6_r_ccu_desc = { +const struct ccu_desc h6_r_ccu_desc = { .gates = h6_r_gates, .resets = h6_r_resets, .num_gates = ARRAY_SIZE(h6_r_gates), .num_resets = ARRAY_SIZE(h6_r_resets), }; - -static const struct udevice_id h6_r_clk_ids[] = { - { .compatible = "allwinner,sun50i-h6-r-ccu", - .data = (ulong)&h6_r_ccu_desc }, - { .compatible = "allwinner,sun50i-h616-r-ccu", - .data = (ulong)&h6_r_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun6i_h6_r) = { - .name = "sun6i_h6_r_ccu", - .id = UCLASS_CLK, - .of_match = h6_r_clk_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_r40.c b/drivers/clk/sunxi/clk_r40.c index a59ac06975..a5b756be40 100644 --- a/drivers/clk/sunxi/clk_r40.c +++ b/drivers/clk/sunxi/clk_r40.c @@ -97,25 +97,9 @@ static struct ccu_reset r40_resets[] = { [RST_BUS_UART7] = RESET(0x2d8, BIT(23)), }; -static const struct ccu_desc r40_ccu_desc = { +const struct ccu_desc r40_ccu_desc = { .gates = r40_gates, .resets = r40_resets, .num_gates = ARRAY_SIZE(r40_gates), .num_resets = ARRAY_SIZE(r40_resets), }; - -static const struct udevice_id r40_clk_ids[] = { - { .compatible = "allwinner,sun8i-r40-ccu", - .data = (ulong)&r40_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun8i_r40) = { - .name = "sun8i_r40_ccu", - .id = UCLASS_CLK, - .of_match = r40_clk_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_sunxi.c b/drivers/clk/sunxi/clk_sunxi.c index e1129f6ccf..7d9e6029ff 100644 --- a/drivers/clk/sunxi/clk_sunxi.c +++ b/drivers/clk/sunxi/clk_sunxi.c @@ -64,12 +64,12 @@ struct clk_ops sunxi_clk_ops = { .disable = sunxi_clk_disable, }; -int sunxi_clk_bind(struct udevice *dev) +static int sunxi_clk_bind(struct udevice *dev) { return sunxi_reset_bind(dev); } -int sunxi_clk_probe(struct udevice *dev) +static int sunxi_clk_probe(struct udevice *dev) { struct ccu_priv *priv = dev_get_priv(dev); struct clk_bulk clk_bulk; @@ -94,3 +94,117 @@ int sunxi_clk_probe(struct udevice *dev) return 0; } + +extern const struct ccu_desc a10_ccu_desc; +extern const struct ccu_desc a10s_ccu_desc; +extern const struct ccu_desc a23_ccu_desc; +extern const struct ccu_desc a31_ccu_desc; +extern const struct ccu_desc a31_r_ccu_desc; +extern const struct ccu_desc a64_ccu_desc; +extern const struct ccu_desc a80_ccu_desc; +extern const struct ccu_desc a80_mmc_clk_desc; +extern const struct ccu_desc a83t_ccu_desc; +extern const struct ccu_desc h3_ccu_desc; +extern const struct ccu_desc h6_ccu_desc; +extern const struct ccu_desc h616_ccu_desc; +extern const struct ccu_desc h6_r_ccu_desc; +extern const struct ccu_desc r40_ccu_desc; +extern const struct ccu_desc v3s_ccu_desc; + +static const struct udevice_id sunxi_clk_ids[] = { +#ifdef CONFIG_CLK_SUN4I_A10 + { .compatible = "allwinner,sun4i-a10-ccu", + .data = (ulong)&a10_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN5I_A10S + { .compatible = "allwinner,sun5i-a10s-ccu", + .data = (ulong)&a10s_ccu_desc }, + { .compatible = "allwinner,sun5i-a13-ccu", + .data = (ulong)&a10s_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN6I_A31 + { .compatible = "allwinner,sun6i-a31-ccu", + .data = (ulong)&a31_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN4I_A10 + { .compatible = "allwinner,sun7i-a20-ccu", + .data = (ulong)&a10_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN8I_A23 + { .compatible = "allwinner,sun8i-a23-ccu", + .data = (ulong)&a23_ccu_desc }, + { .compatible = "allwinner,sun8i-a33-ccu", + .data = (ulong)&a23_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN8I_A83T + { .compatible = "allwinner,sun8i-a83t-ccu", + .data = (ulong)&a83t_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN6I_A31_R + { .compatible = "allwinner,sun8i-a83t-r-ccu", + .data = (ulong)&a31_r_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN8I_H3 + { .compatible = "allwinner,sun8i-h3-ccu", + .data = (ulong)&h3_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN6I_A31_R + { .compatible = "allwinner,sun8i-h3-r-ccu", + .data = (ulong)&a31_r_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN8I_R40 + { .compatible = "allwinner,sun8i-r40-ccu", + .data = (ulong)&r40_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN8I_V3S + { .compatible = "allwinner,sun8i-v3-ccu", + .data = (ulong)&v3s_ccu_desc }, + { .compatible = "allwinner,sun8i-v3s-ccu", + .data = (ulong)&v3s_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN9I_A80 + { .compatible = "allwinner,sun9i-a80-ccu", + .data = (ulong)&a80_ccu_desc }, + { .compatible = "allwinner,sun9i-a80-mmc-config-clk", + .data = (ulong)&a80_mmc_clk_desc }, +#endif +#ifdef CONFIG_CLK_SUN50I_A64 + { .compatible = "allwinner,sun50i-a64-ccu", + .data = (ulong)&a64_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN6I_A31_R + { .compatible = "allwinner,sun50i-a64-r-ccu", + .data = (ulong)&a31_r_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN8I_H3 + { .compatible = "allwinner,sun50i-h5-ccu", + .data = (ulong)&h3_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN50I_H6 + { .compatible = "allwinner,sun50i-h6-ccu", + .data = (ulong)&h6_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN50I_H6_R + { .compatible = "allwinner,sun50i-h6-r-ccu", + .data = (ulong)&h6_r_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN50I_H616 + { .compatible = "allwinner,sun50i-h616-ccu", + .data = (ulong)&h616_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN50I_H6_R + { .compatible = "allwinner,sun50i-h616-r-ccu", + .data = (ulong)&h6_r_ccu_desc }, +#endif + { } +}; + +U_BOOT_DRIVER(sunxi_clk) = { + .name = "sunxi_clk", + .id = UCLASS_CLK, + .of_match = sunxi_clk_ids, + .bind = sunxi_clk_bind, + .probe = sunxi_clk_probe, + .priv_auto = sizeof(struct ccu_priv), + .ops = &sunxi_clk_ops, +}; diff --git a/drivers/clk/sunxi/clk_v3s.c b/drivers/clk/sunxi/clk_v3s.c index c6a17b4535..e632afc083 100644 --- a/drivers/clk/sunxi/clk_v3s.c +++ b/drivers/clk/sunxi/clk_v3s.c @@ -47,27 +47,9 @@ static struct ccu_reset v3s_resets[] = { [RST_BUS_UART2] = RESET(0x2d8, BIT(18)), }; -static const struct ccu_desc v3s_ccu_desc = { +const struct ccu_desc v3s_ccu_desc = { .gates = v3s_gates, .resets = v3s_resets, .num_gates = ARRAY_SIZE(v3s_gates), .num_resets = ARRAY_SIZE(v3s_resets), }; - -static const struct udevice_id v3s_clk_ids[] = { - { .compatible = "allwinner,sun8i-v3s-ccu", - .data = (ulong)&v3s_ccu_desc }, - { .compatible = "allwinner,sun8i-v3-ccu", - .data = (ulong)&v3s_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun8i_v3s) = { - .name = "sun8i_v3s_ccu", - .id = UCLASS_CLK, - .of_match = v3s_clk_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/include/clk/sunxi.h b/include/clk/sunxi.h index c798c226f5..11caf12b17 100644 --- a/include/clk/sunxi.h +++ b/include/clk/sunxi.h @@ -80,18 +80,6 @@ struct ccu_priv { const struct ccu_desc *desc; }; -/** - * sunxi_clk_bind - common sunxi clock bind - * @dev: clock device - */ -int sunxi_clk_bind(struct udevice *dev); - -/** - * sunxi_clk_probe - common sunxi clock probe - * @dev: clock device - */ -int sunxi_clk_probe(struct udevice *dev); - extern struct clk_ops sunxi_clk_ops; /** From patchwork Mon May 9 05:29:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1628309 X-Patchwork-Delegate: andre.przywara@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.a=rsa-sha256 header.s=fm2 header.b=k2GcRSQJ; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm1 header.b=E5MUhJCp; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KxVBR3dPRz9sG6 for ; Mon, 9 May 2022 15:30:39 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1EB4F83F35; Mon, 9 May 2022 07:30:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.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=sholland.org header.i=@sholland.org header.b="k2GcRSQJ"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="E5MUhJCp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3CE1683DE7; Mon, 9 May 2022 07:29:52 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (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 D84D683F06 for ; Mon, 9 May 2022 07:29:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 1B7B55C0063; Mon, 9 May 2022 01:29:44 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Mon, 09 May 2022 01:29:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1652074184; x=1652160584; bh=80 cM76YGXy/wIS93yYTPpvqpvDteASqWolKPWQWcbDM=; b=k2GcRSQJZi22uNbbyH 2uAzat2i2JrBL5fQRe8baL6eycCsWzM0mG9PwaXr/3RpDp1lp2/Shz9XgqEAXid3 uBPkzUVLzXz/I+SvZ3BV40bV85LHftd3JyQJJWd1zHsPRF5+CQVvtUCQY2xsxNtZ 7ruAiZFW4BjpwGixhpBVGYfXv9e3ilwCFGNbDveBiG4fePJUeDPXyWqfiyiZ5Ibk Ldnc3KPOeKZYbqbx6D7/A9xDJoDFi6PIkAL96R+5VSyLbLta16KU7tr/SaTfcZHv FXJBCMJOPaGMy1w31YMQjfXYsT46SG5ZbQTKM11hXZXVNlmCxEi989wUT1B99Lrf gEXQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1652074184; x=1652160584; bh=80cM76YGXy/wIS93yYTPpvqpvDteASqWolK PWQWcbDM=; b=E5MUhJCpQoY5V/6gSnfJKgLoOPY+msq86YObaE8aG/5+1Ru6UGF 0jh7IaMGD8KH0iOAJ2VVZGB5qjKT3BmJCGedmvVt0NdZxBF3LXqYbo51doFWBSD0 5XU13qIbeypfU1Hzj1s5hNKU+exj2GDaKSSyD6IjjPq9NlHoFUtGnq3YJ4jbOymv FkE6SHg2Y6ffNsJun7r3tFwe0ZlnRzZIOk/gA+SHuRu38ZbwZICj3KI5H0N+dYfK S9qpdxtuF3Oal6+B7Ks1tibkOWyJVP9YAXzYurNfwVEDCvipfF+9KhETh62lmrmz MYdCZxcnnN8rCqpkcM1J6KFSQx3CIlOOBXg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeekgdeljecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpedukeetueduhedtleetvefguddvvdejhfefudelgfduveeggeehgfdu feeitdevteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 9 May 2022 01:29:43 -0400 (EDT) From: Samuel Holland To: u-boot@lists.denx.de, Jagan Teki , Andre Przywara , Lukasz Majewski , Sean Anderson Cc: Samuel Holland , Bin Meng , Heinrich Schuchardt , Maxime Ripard Subject: [PATCH 5/7] clk: sunxi: Convert driver private data to platform data Date: Mon, 9 May 2022 00:29:35 -0500 Message-Id: <20220509052937.42283-6-samuel@sholland.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220509052937.42283-1-samuel@sholland.org> References: <20220509052937.42283-1-samuel@sholland.org> MIME-Version: 1.0 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean All of the driver private data should really be platform data since it is determined statically (selected by the compatible string or extracted from the devicetree). Move everything to platform data, so it can be provided when binding the driver. This is useful for SPL, or for instantiating the driver as part of an MFD. Signed-off-by: Samuel Holland Reviewed-by: Andre Przywara --- drivers/clk/sunxi/clk_sunxi.c | 41 ++++++++++++++++++++--------------- include/clk/sunxi.h | 4 ++-- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/drivers/clk/sunxi/clk_sunxi.c b/drivers/clk/sunxi/clk_sunxi.c index 7d9e6029ff..cadfca767b 100644 --- a/drivers/clk/sunxi/clk_sunxi.c +++ b/drivers/clk/sunxi/clk_sunxi.c @@ -15,19 +15,19 @@ #include #include -static const struct ccu_clk_gate *priv_to_gate(struct ccu_priv *priv, +static const struct ccu_clk_gate *plat_to_gate(struct ccu_plat *plat, unsigned long id) { - if (id >= priv->desc->num_gates) + if (id >= plat->desc->num_gates) return NULL; - return &priv->desc->gates[id]; + return &plat->desc->gates[id]; } static int sunxi_set_gate(struct clk *clk, bool on) { - struct ccu_priv *priv = dev_get_priv(clk->dev); - const struct ccu_clk_gate *gate = priv_to_gate(priv, clk->id); + struct ccu_plat *plat = dev_get_plat(clk->dev); + const struct ccu_clk_gate *gate = plat_to_gate(plat, clk->id); u32 reg; if (!gate || !(gate->flags & CCU_CLK_F_IS_VALID)) { @@ -38,13 +38,13 @@ static int sunxi_set_gate(struct clk *clk, bool on) debug("%s: (CLK#%ld) off#0x%x, BIT(%d)\n", __func__, clk->id, gate->off, ilog2(gate->bit)); - reg = readl(priv->base + gate->off); + reg = readl(plat->base + gate->off); if (on) reg |= gate->bit; else reg &= ~gate->bit; - writel(reg, priv->base + gate->off); + writel(reg, plat->base + gate->off); return 0; } @@ -71,19 +71,10 @@ static int sunxi_clk_bind(struct udevice *dev) static int sunxi_clk_probe(struct udevice *dev) { - struct ccu_priv *priv = dev_get_priv(dev); struct clk_bulk clk_bulk; struct reset_ctl_bulk rst_bulk; int ret; - priv->base = dev_read_addr_ptr(dev); - if (!priv->base) - return -ENOMEM; - - priv->desc = (const struct ccu_desc *)dev_get_driver_data(dev); - if (!priv->desc) - return -EINVAL; - ret = clk_get_bulk(dev, &clk_bulk); if (!ret) clk_enable_bulk(&clk_bulk); @@ -95,6 +86,21 @@ static int sunxi_clk_probe(struct udevice *dev) return 0; } +static int sunxi_clk_of_to_plat(struct udevice *dev) +{ + struct ccu_plat *plat = dev_get_plat(dev); + + plat->base = dev_read_addr_ptr(dev); + if (!plat->base) + return -ENOMEM; + + plat->desc = (const struct ccu_desc *)dev_get_driver_data(dev); + if (!plat->desc) + return -EINVAL; + + return 0; +} + extern const struct ccu_desc a10_ccu_desc; extern const struct ccu_desc a10s_ccu_desc; extern const struct ccu_desc a23_ccu_desc; @@ -205,6 +211,7 @@ U_BOOT_DRIVER(sunxi_clk) = { .of_match = sunxi_clk_ids, .bind = sunxi_clk_bind, .probe = sunxi_clk_probe, - .priv_auto = sizeof(struct ccu_priv), + .of_to_plat = sunxi_clk_of_to_plat, + .plat_auto = sizeof(struct ccu_plat), .ops = &sunxi_clk_ops, }; diff --git a/include/clk/sunxi.h b/include/clk/sunxi.h index 11caf12b17..e90e078972 100644 --- a/include/clk/sunxi.h +++ b/include/clk/sunxi.h @@ -70,12 +70,12 @@ struct ccu_desc { }; /** - * struct ccu_priv - sunxi clock control unit + * struct ccu_plat - sunxi clock control unit platform data * * @base: base address * @desc: ccu descriptor */ -struct ccu_priv { +struct ccu_plat { void *base; const struct ccu_desc *desc; }; From patchwork Mon May 9 05:29:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1628312 X-Patchwork-Delegate: andre.przywara@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.a=rsa-sha256 header.s=fm2 header.b=dIDbKyZn; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm1 header.b=BTYd6o8C; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KxVBs2TNxz9sG6 for ; Mon, 9 May 2022 15:31:01 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E042F83F71; Mon, 9 May 2022 07:30:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.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=sholland.org header.i=@sholland.org header.b="dIDbKyZn"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="BTYd6o8C"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4570F83E0F; Mon, 9 May 2022 07:29:54 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (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 BE0CA83F2D for ; Mon, 9 May 2022 07:29:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 0372F5C00FF; Mon, 9 May 2022 01:29:45 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 09 May 2022 01:29:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1652074184; x=1652160584; bh=HP 0pGOqvs85EaXRLNF1MrquMqBM1WFd3LAYrD1A19ms=; b=dIDbKyZnBIXkhict+h 7Q38Xwdrr8zy6Az9y13e6sSqptEdxGcdMVavmdLNeE+QDHnGrEYd6bTk1dkayeJj XJnDB50rfbdN4Ly0ibS8UNcMSKpNBhKDO1I1/vSX3a5vDutHhPBaPUq/zdzJqwsW RtchpOJNnIcgk4NPGpzuOaVzYRpG4qCEuGSRmbViCQTyDZ+lItQ6BUojVz5MP6SW rPP7SR5uHo1FCbd8KIH0LWkYdRvFokb9NyYDLO39V55Gl+uah+bu+j5CRe1xjomw aVunz1yHI9sLqZeGSvlXG3l8AYFSdgJ8ieTxHGZlgwlaHkJtmq5N7o07IRpVeZVb Iqtw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1652074184; x=1652160584; bh=HP0pGOqvs85EaXRLNF1MrquMqBM1WFd3LAY rD1A19ms=; b=BTYd6o8C2o76jGRVg5aAQt4TtZn/NopgNIvEBOIycsHIaCvCodL 77ruV0von+BuoUtljMg/LkApaWcwUFZ/ggqai7pFUbjizs1I6ryyCxXjtLqgzvI4 3kw0eBtIWNZg0ES5uycUuin7CdzCRAHCjaJXzNWtaalazhzcUWx8HxaZxKkEOv0e tgm6oruFx2i82VTB4ZhDxaf2trSmVd9Cte87wJR/HZwdKszxvZHFPwXwumzJpHlx TytZLRFcpm4d999mPljz2BHrcINfEmigdbIgeut/0xqP+1ArpthgzFGQ63o1COUZ P8im57Ufq0uIozLmwJpfyXrINoGq/LQRKcA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeekgdeljecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpedukeetueduhedtleetvefguddvvdejhfefudelgfduveeggeehgfdu feeitdevteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 9 May 2022 01:29:44 -0400 (EDT) From: Samuel Holland To: u-boot@lists.denx.de, Jagan Teki , Andre Przywara , Lukasz Majewski , Sean Anderson Cc: Samuel Holland , Bin Meng , Heinrich Schuchardt , Maxime Ripard Subject: [PATCH 6/7] reset: sunxi: Convert driver private data to platform data Date: Mon, 9 May 2022 00:29:36 -0500 Message-Id: <20220509052937.42283-7-samuel@sholland.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220509052937.42283-1-samuel@sholland.org> References: <20220509052937.42283-1-samuel@sholland.org> MIME-Version: 1.0 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean The reason here is the same as the reason for changing the clock driver: platform data can be provided when binding the driver. Signed-off-by: Samuel Holland Reviewed-by: Andre Przywara --- drivers/reset/reset-sunxi.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/reset/reset-sunxi.c b/drivers/reset/reset-sunxi.c index 4d02d02834..b060d7f5ed 100644 --- a/drivers/reset/reset-sunxi.c +++ b/drivers/reset/reset-sunxi.c @@ -17,24 +17,24 @@ #include #include -struct sunxi_reset_priv { +struct sunxi_reset_plat { void *base; const struct ccu_desc *desc; }; -static const struct ccu_reset *priv_to_reset(struct sunxi_reset_priv *priv, +static const struct ccu_reset *plat_to_reset(struct sunxi_reset_plat *plat, unsigned long id) { - return &priv->desc->resets[id]; + return &plat->desc->resets[id]; } static int sunxi_reset_request(struct reset_ctl *reset_ctl) { - struct sunxi_reset_priv *priv = dev_get_priv(reset_ctl->dev); + struct sunxi_reset_plat *plat = dev_get_plat(reset_ctl->dev); debug("%s: (RST#%ld)\n", __func__, reset_ctl->id); - if (reset_ctl->id >= priv->desc->num_resets) + if (reset_ctl->id >= plat->desc->num_resets) return -EINVAL; return 0; @@ -49,8 +49,8 @@ static int sunxi_reset_free(struct reset_ctl *reset_ctl) static int sunxi_set_reset(struct reset_ctl *reset_ctl, bool on) { - struct sunxi_reset_priv *priv = dev_get_priv(reset_ctl->dev); - const struct ccu_reset *reset = priv_to_reset(priv, reset_ctl->id); + struct sunxi_reset_plat *plat = dev_get_plat(reset_ctl->dev); + const struct ccu_reset *reset = plat_to_reset(plat, reset_ctl->id); u32 reg; if (!(reset->flags & CCU_RST_F_IS_VALID)) { @@ -61,13 +61,13 @@ static int sunxi_set_reset(struct reset_ctl *reset_ctl, bool on) debug("%s: (RST#%ld) off#0x%x, BIT(%d)\n", __func__, reset_ctl->id, reset->off, ilog2(reset->bit)); - reg = readl(priv->base + reset->off); + reg = readl(plat->base + reset->off); if (on) reg |= reset->bit; else reg &= ~reset->bit; - writel(reg, priv->base + reset->off); + writel(reg, plat->base + reset->off); return 0; } @@ -89,11 +89,11 @@ struct reset_ops sunxi_reset_ops = { .rst_deassert = sunxi_reset_deassert, }; -static int sunxi_reset_probe(struct udevice *dev) +static int sunxi_reset_of_to_plat(struct udevice *dev) { - struct sunxi_reset_priv *priv = dev_get_priv(dev); + struct sunxi_reset_plat *plat = dev_get_plat(dev); - priv->base = dev_read_addr_ptr(dev); + plat->base = dev_read_addr_ptr(dev); return 0; } @@ -101,7 +101,7 @@ static int sunxi_reset_probe(struct udevice *dev) int sunxi_reset_bind(struct udevice *dev) { struct udevice *rst_dev; - struct sunxi_reset_priv *priv; + struct sunxi_reset_plat *plat; int ret; ret = device_bind_driver_to_node(dev, "sunxi_reset", "reset", @@ -110,9 +110,9 @@ int sunxi_reset_bind(struct udevice *dev) debug("failed to bind sunxi_reset driver (ret=%d)\n", ret); return ret; } - priv = malloc(sizeof(struct sunxi_reset_priv)); - priv->desc = (const struct ccu_desc *)dev_get_driver_data(dev); - dev_set_priv(rst_dev, priv); + plat = malloc(sizeof(struct sunxi_reset_plat)); + plat->desc = (const struct ccu_desc *)dev_get_driver_data(dev); + dev_set_plat(rst_dev, plat); return 0; } @@ -121,6 +121,6 @@ U_BOOT_DRIVER(sunxi_reset) = { .name = "sunxi_reset", .id = UCLASS_RESET, .ops = &sunxi_reset_ops, - .probe = sunxi_reset_probe, - .priv_auto = sizeof(struct sunxi_reset_priv), + .of_to_plat = sunxi_reset_of_to_plat, + .plat_auto = sizeof(struct sunxi_reset_plat), }; From patchwork Mon May 9 05:29:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1628313 X-Patchwork-Delegate: andre.przywara@arm.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.a=rsa-sha256 header.s=fm2 header.b=r5P40z3h; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm1 header.b=d/QRaH+7; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KxVCB3Cjhz9sG6 for ; Mon, 9 May 2022 15:31:18 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1A00E83F57; Mon, 9 May 2022 07:30:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.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=sholland.org header.i=@sholland.org header.b="r5P40z3h"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="d/QRaH+7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 77A6C83E96; Mon, 9 May 2022 07:29:59 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (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 A259B83F33 for ; Mon, 9 May 2022 07:29:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id E1B915C00E7; Mon, 9 May 2022 01:29:45 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Mon, 09 May 2022 01:29:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1652074185; x=1652160585; bh=m+ fsXgVjfdlM3/f6wFChS8DvggrPsnrLUqpdRIT04kE=; b=r5P40z3hAy/kdDMsQp aaFhd9FOTX959GbmcQJyyk63be1AqWsxlM865soc9kUbT/SAXvvTOHsP34v+pbBy OpgRQ9RxfRBg/WuhATKUiZiABybDUf7Ty67uHm638wg/jvUxcD/y7OoNkW2mYvYT 16/84PBsqsgnBEqCK2ZcwuogbjQ/SnskICFIBDCgQGFx4B51QuQnMPbsRCh/yO/8 bHJXPk16d+bD6IjM8+T72WH4b8n68vPUOGGnqafG45IfeiokgyheqV6Nv1Fhx94u tAcg+GosexZGbK1KuZ8BcYC1mGV8syx8dS9G7PrB++kHNkXrO5HEoX3XTmHNHsbc mV2w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1652074185; x=1652160585; bh=m+fsXgVjfdlM3/f6wFChS8DvggrPsnrLUqp dRIT04kE=; b=d/QRaH+7yz6usDZg84eqi02kXvXa4CL9P7nCCoteHNgGL0VrblV C4FRWQXDztJjfOW5+FF2okKZMLmENzzPJCmBkkElHcrP6cRcaSz21tPlht7VPfcg fGCekgjJkkPvcLMlYUne6t061XzSHcboDZK60CsENidAtS2efSiqbZtMChJigkL5 w12yvLAACwMpw5IX1X2OsfRj3Fb68SeBxU9wOZgOuvy0aOdF2LbzBgH7H831l43t dFWoo6kO/7xAML18w1gfLNukDFY6IJ4HsPajgdmyK5P/HT9oUQ9iCTeg2ySKxWPJ AZN+cWLd2F7Zi5EU3/2swXt327hV29goTaw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeekgdeljecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpedukeetueduhedtleetvefguddvvdejhfefudelgfduveeggeehgfdu feeitdevteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 9 May 2022 01:29:45 -0400 (EDT) From: Samuel Holland To: u-boot@lists.denx.de, Jagan Teki , Andre Przywara , Lukasz Majewski , Sean Anderson Cc: Samuel Holland , Bin Meng , Heinrich Schuchardt , Maxime Ripard Subject: [PATCH 7/7] reset: sunxi: Reuse the platform data from the clock driver Date: Mon, 9 May 2022 00:29:37 -0500 Message-Id: <20220509052937.42283-8-samuel@sholland.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220509052937.42283-1-samuel@sholland.org> References: <20220509052937.42283-1-samuel@sholland.org> MIME-Version: 1.0 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean The clock and reset drivers use the exact same platform data. Simplify them by sharing the object. This is safe because the parent device (the clock device) always gets its driver model callbacks run first. Signed-off-by: Samuel Holland Acked-by: Andre Przywara --- drivers/clk/sunxi/clk_sunxi.c | 7 +++++- drivers/reset/reset-sunxi.c | 43 +++-------------------------------- include/clk/sunxi.h | 8 ------- 3 files changed, 9 insertions(+), 49 deletions(-) diff --git a/drivers/clk/sunxi/clk_sunxi.c b/drivers/clk/sunxi/clk_sunxi.c index cadfca767b..10c5d2f4b6 100644 --- a/drivers/clk/sunxi/clk_sunxi.c +++ b/drivers/clk/sunxi/clk_sunxi.c @@ -12,9 +12,12 @@ #include #include #include +#include #include #include +extern U_BOOT_DRIVER(sunxi_reset); + static const struct ccu_clk_gate *plat_to_gate(struct ccu_plat *plat, unsigned long id) { @@ -66,7 +69,9 @@ struct clk_ops sunxi_clk_ops = { static int sunxi_clk_bind(struct udevice *dev) { - return sunxi_reset_bind(dev); + /* Reuse the platform data for the reset driver. */ + return device_bind(dev, DM_DRIVER_REF(sunxi_reset), "reset", + dev_get_plat(dev), dev_ofnode(dev), NULL); } static int sunxi_clk_probe(struct udevice *dev) diff --git a/drivers/reset/reset-sunxi.c b/drivers/reset/reset-sunxi.c index b060d7f5ed..5d4b8dc92f 100644 --- a/drivers/reset/reset-sunxi.c +++ b/drivers/reset/reset-sunxi.c @@ -12,17 +12,10 @@ #include #include #include -#include -#include #include #include -struct sunxi_reset_plat { - void *base; - const struct ccu_desc *desc; -}; - -static const struct ccu_reset *plat_to_reset(struct sunxi_reset_plat *plat, +static const struct ccu_reset *plat_to_reset(struct ccu_plat *plat, unsigned long id) { return &plat->desc->resets[id]; @@ -30,7 +23,7 @@ static const struct ccu_reset *plat_to_reset(struct sunxi_reset_plat *plat, static int sunxi_reset_request(struct reset_ctl *reset_ctl) { - struct sunxi_reset_plat *plat = dev_get_plat(reset_ctl->dev); + struct ccu_plat *plat = dev_get_plat(reset_ctl->dev); debug("%s: (RST#%ld)\n", __func__, reset_ctl->id); @@ -49,7 +42,7 @@ static int sunxi_reset_free(struct reset_ctl *reset_ctl) static int sunxi_set_reset(struct reset_ctl *reset_ctl, bool on) { - struct sunxi_reset_plat *plat = dev_get_plat(reset_ctl->dev); + struct ccu_plat *plat = dev_get_plat(reset_ctl->dev); const struct ccu_reset *reset = plat_to_reset(plat, reset_ctl->id); u32 reg; @@ -89,38 +82,8 @@ struct reset_ops sunxi_reset_ops = { .rst_deassert = sunxi_reset_deassert, }; -static int sunxi_reset_of_to_plat(struct udevice *dev) -{ - struct sunxi_reset_plat *plat = dev_get_plat(dev); - - plat->base = dev_read_addr_ptr(dev); - - return 0; -} - -int sunxi_reset_bind(struct udevice *dev) -{ - struct udevice *rst_dev; - struct sunxi_reset_plat *plat; - int ret; - - ret = device_bind_driver_to_node(dev, "sunxi_reset", "reset", - dev_ofnode(dev), &rst_dev); - if (ret) { - debug("failed to bind sunxi_reset driver (ret=%d)\n", ret); - return ret; - } - plat = malloc(sizeof(struct sunxi_reset_plat)); - plat->desc = (const struct ccu_desc *)dev_get_driver_data(dev); - dev_set_plat(rst_dev, plat); - - return 0; -} - U_BOOT_DRIVER(sunxi_reset) = { .name = "sunxi_reset", .id = UCLASS_RESET, .ops = &sunxi_reset_ops, - .of_to_plat = sunxi_reset_of_to_plat, - .plat_auto = sizeof(struct sunxi_reset_plat), }; diff --git a/include/clk/sunxi.h b/include/clk/sunxi.h index e90e078972..b9587050d9 100644 --- a/include/clk/sunxi.h +++ b/include/clk/sunxi.h @@ -82,12 +82,4 @@ struct ccu_plat { extern struct clk_ops sunxi_clk_ops; -/** - * sunxi_reset_bind() - reset binding - * - * @dev: reset device - * Return: 0 success, or error value - */ -int sunxi_reset_bind(struct udevice *dev); - #endif /* _CLK_SUNXI_H */