From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C4FC6C43334 for ; Mon, 27 Jun 2022 00:48:40 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 406B084475; Mon, 27 Jun 2022 02:48:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 95FC883E7E; Mon, 27 Jun 2022 02:48:07 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 94F60843FD for ; Mon, 27 Jun 2022 02:48:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=andre.przywara@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 504A5D6E; Sun, 26 Jun 2022 17:48:02 -0700 (PDT) Received: from slackpad.lan (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8A7553F5A1; Sun, 26 Jun 2022 17:48:00 -0700 (PDT) Date: Sun, 26 Jun 2022 11:51:16 +0100 From: Andre Przywara To: Samuel Holland Cc: u-boot@lists.denx.de, Jagan Teki , Lukasz Majewski , Sean Anderson , Bin Meng , Heinrich Schuchardt , Maxime Ripard Subject: Re: [PATCH 3/7] reset: sunxi: Get the reset count from the CCU descriptor Message-ID: <20220626115116.4ba47fd6@slackpad.lan> In-Reply-To: <20220509052937.42283-4-samuel@sholland.org> References: <20220509052937.42283-1-samuel@sholland.org> <20220509052937.42283-4-samuel@sholland.org> Organization: Arm Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.31; x86_64-slackware-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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.6 at phobos.denx.de X-Virus-Status: Clean On Mon, 9 May 2022 00:29:33 -0500 Samuel Holland wrote: > This allows all of the clock drivers to use a common bind function. Looks good, and a nice cleanup. Added the F1C100s on the way. > Signed-off-by: Samuel Holland Reviewed-by: Andre Przywara Thanks, Andre > --- > > 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 */