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 81E8FC433EF for ; Mon, 9 May 2022 05:30:37 +0000 (UTC) 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) 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 Content-Transfer-Encoding: 8bit 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 --- 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; }; -- 2.35.1