From patchwork Thu Jul 27 05:31:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13328766 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 76A6DEB64DD for ; Thu, 27 Jul 2023 05:36:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6semRH/gYB5BCS6OJAod4SAZ/ozelEno9Wl962B/M6I=; b=FqVxIRkxzgMxL8 lGFFYOBC5m5ewNGxEsOOiF9VMbkqnIShLOBddAZV3XhHUMBI6rgx9OSwxJ+R6DS3ur2kvbNMM7jHw 18ymVVHgefC5AJRHpS4ICHdEmmtSeUi5GN0dW7mmQQ+t+xbbGWYWLo5QbWVZpt3TYj1IRXpFW8tw8 XOD/JvJJYSN1RnYuCwvhLfW1HsGUqNxsWv/quekESyB0YWcRzxXuSQaRmOtRLX8QYv5s2KER2oAdI Kj17HyQL4Ed8JHYMLfi66UIRACcn08NcdIqmhi28Hn6rg/sLNVHonXXJNKefKCABdGYdCbf/WP7hg rICrzo/1EXlfQqp+7O9Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qOtfj-00CD5g-2b; Thu, 27 Jul 2023 05:36:23 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qOtf1-00CCo2-15 for linux-arm-kernel@lists.infradead.org; Thu, 27 Jul 2023 05:35:42 +0000 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1bb775625e2so3332325ad.1 for ; Wed, 26 Jul 2023 22:35:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1690436139; x=1691040939; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yQlXbwoci/ewwucHyWtCCTQ2+X4L0Fz5xsjb1IQcag4=; b=Bg5yjQAjktp2tJN/SXnI4Hbxj/NHVgUV4xq2Aq1auahzR1Uc+3pqQO1aOt8K2rE2Vh 9S/5SYQbxmkPVwaFQQqurFrabLky1ex30remLU9wCYUbRBhdwNmgsqQCMP9pjh3qJOaF RlLL5pfKUQ6F/HOrNjjebOXkb3+9ZdefSZVrAQiQ7MCW64ortIe3AMxkBysncZBoy/i/ o207ddtT7pYA7NCUIxD/m1AnPWwcjDV31mYa56A9BAD4V1a17UlN23zqU20OAfZ4wcYc IU89p/pQyc9/M6cNV31hcc4J1CoWIi0FSAGWlb73PvUJbjB14GYUhq6oQpRS8852jBn4 YwdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690436139; x=1691040939; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yQlXbwoci/ewwucHyWtCCTQ2+X4L0Fz5xsjb1IQcag4=; b=cpw+/EJhiW1bJbx4iqROzMvhZJFlwnGVIm+NQIYPAYegvIP3+uaxWCDhsqwwDR9CaV BtVEczhFh6xjlfic95FVNWxGK/GRB+NSfTbwf0wyS2v1w6r4RsdqT7RWiOB6vEaX3xY9 yy7EJdPcG6mjsYU5Iyef5bhgD0R7z5//0P9gtg5SmiYg4I2Qz79GzE/WDJSE+Fvx4+K3 FrYAzN/mKN9/8VgWawS1Dtqe8A9zo4SsfbnfKsKLM6LNnxkHdX/oT4fK7/AdwSBlckjT pM63F6aQUtF0YqSbzHvFIJT7TcYUB5h8qOMDv1hMrH2577GPwTzCSrF3CldzfVrFH/QN 9Pvw== X-Gm-Message-State: ABy/qLbAaiXsauOYfbgj3iHQYzc7AbUAZsMbR7amYpTpVt7w8395SOl3 LVOeBOaZbdNTtT1RvbwIYAa8Ng== X-Google-Smtp-Source: APBJJlHsDVCtvEOmrOaGJqf0BjQfeVpMuyWKgqwEHE5zMzyunm3gXSds0Z9gD5iv2xDyHelkUGaIeg== X-Received: by 2002:a17:902:8c86:b0:1b8:c63:4b79 with SMTP id t6-20020a1709028c8600b001b80c634b79mr1658635plo.19.1690436138684; Wed, 26 Jul 2023 22:35:38 -0700 (PDT) Received: from localhost.localdomain ([82.78.167.79]) by smtp.gmail.com with ESMTPSA id 21-20020a170902c11500b001bb889530adsm319059pli.217.2023.07.26.22.35.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 22:35:38 -0700 (PDT) From: Claudiu Beznea To: mturquette@baylibre.com, sboyd@kernel.org, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, mripard@kernel.org Cc: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, varshini.rajendran@microchip.com, Claudiu Beznea Subject: [PATCH 26/42] clk: at91: dt-compat: switch to parent_hw and parent_data Date: Thu, 27 Jul 2023 08:31:40 +0300 Message-Id: <20230727053156.13587-27-claudiu.beznea@tuxon.dev> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230727053156.13587-1-claudiu.beznea@tuxon.dev> References: <20230727053156.13587-1-claudiu.beznea@tuxon.dev> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230726_223539_385881_4ECFF1A4 X-CRM114-Status: GOOD ( 18.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Switch old dt-compat clocks to use parent_hw and parent_data. Having parent_hw instead of parent names improves to clock registration speed and re-parenting. Signed-off-by: Claudiu Beznea --- drivers/clk/at91/dt-compat.c | 328 +++++++++++++++++++++++++---------- 1 file changed, 232 insertions(+), 96 deletions(-) diff --git a/drivers/clk/at91/dt-compat.c b/drivers/clk/at91/dt-compat.c index dbc59ac44828..044e1fc821e2 100644 --- a/drivers/clk/at91/dt-compat.c +++ b/drivers/clk/at91/dt-compat.c @@ -1,4 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 +#include #include #include #include @@ -29,11 +30,11 @@ static DEFINE_SPINLOCK(mck_lock); #ifdef CONFIG_HAVE_AT91_AUDIO_PLL static void __init of_sama5d2_clk_audio_pll_frac_setup(struct device_node *np) { - struct clk_hw *hw; + struct clk_hw *hw, *parent_hw; const char *name = np->name; - const char *parent_name; struct regmap *regmap; struct device_node *parent_np; + struct clk *clk; parent_np = of_get_parent(np); regmap = syscon_node_to_regmap(parent_np); @@ -41,9 +42,15 @@ static void __init of_sama5d2_clk_audio_pll_frac_setup(struct device_node *np) if (IS_ERR(regmap)) return; - parent_name = of_clk_get_parent_name(np, 0); + clk = of_clk_get(np, 0); + if (IS_ERR(clk)) + return; + + parent_hw = __clk_get_hw(clk); + if (!parent_hw) + return; - hw = at91_clk_register_audio_pll_frac(regmap, name, parent_name, NULL); + hw = at91_clk_register_audio_pll_frac(regmap, name, NULL, parent_hw); if (IS_ERR(hw)) return; @@ -55,11 +62,11 @@ CLK_OF_DECLARE(of_sama5d2_clk_audio_pll_frac_setup, static void __init of_sama5d2_clk_audio_pll_pad_setup(struct device_node *np) { - struct clk_hw *hw; + struct clk_hw *hw, *parent_hw; const char *name = np->name; - const char *parent_name; struct regmap *regmap; struct device_node *parent_np; + struct clk *clk; parent_np = of_get_parent(np); regmap = syscon_node_to_regmap(parent_np); @@ -67,9 +74,15 @@ static void __init of_sama5d2_clk_audio_pll_pad_setup(struct device_node *np) if (IS_ERR(regmap)) return; - parent_name = of_clk_get_parent_name(np, 0); + clk = of_clk_get(np, 0); + if (IS_ERR(clk)) + return; + + parent_hw = __clk_get_hw(clk); + if (!parent_hw) + return; - hw = at91_clk_register_audio_pll_pad(regmap, name, parent_name, NULL); + hw = at91_clk_register_audio_pll_pad(regmap, name, NULL, parent_hw); if (IS_ERR(hw)) return; @@ -81,11 +94,11 @@ CLK_OF_DECLARE(of_sama5d2_clk_audio_pll_pad_setup, static void __init of_sama5d2_clk_audio_pll_pmc_setup(struct device_node *np) { - struct clk_hw *hw; + struct clk_hw *hw, *parent_hw; const char *name = np->name; - const char *parent_name; struct regmap *regmap; struct device_node *parent_np; + struct clk *clk; parent_np = of_get_parent(np); regmap = syscon_node_to_regmap(parent_np); @@ -93,9 +106,15 @@ static void __init of_sama5d2_clk_audio_pll_pmc_setup(struct device_node *np) if (IS_ERR(regmap)) return; - parent_name = of_clk_get_parent_name(np, 0); + clk = of_clk_get(np, 0); + if (IS_ERR(clk)) + return; + + parent_hw = __clk_get_hw(clk); + if (!parent_hw) + return; - hw = at91_clk_register_audio_pll_pmc(regmap, name, parent_name, NULL); + hw = at91_clk_register_audio_pll_pmc(regmap, name, NULL, parent_hw); if (IS_ERR(hw)) return; @@ -126,18 +145,26 @@ static void __init of_sama5d2_clk_generated_setup(struct device_node *np) int num; u32 id; const char *name; - struct clk_hw *hw; - unsigned int num_parents; - const char *parent_names[GENERATED_SOURCE_MAX]; + struct clk_hw *hw, *parent_hws[GENERATED_SOURCE_MAX]; + unsigned int num_parents, i; struct device_node *gcknp, *parent_np; struct clk_range range = CLK_RANGE(0, 0); struct regmap *regmap; + struct clk *clk; num_parents = of_clk_get_parent_count(np); if (num_parents == 0 || num_parents > GENERATED_SOURCE_MAX) return; - of_clk_parent_fill(np, parent_names, num_parents); + for (i = 0; i < num_parents; i++) { + clk = of_clk_get(np, i); + if (IS_ERR(clk)) + return; + + parent_hws[i] = __clk_get_hw(clk); + if (!parent_hws[i]) + return; + } num = of_get_child_count(np); if (!num || num > PERIPHERAL_MAX) @@ -171,7 +198,7 @@ static void __init of_sama5d2_clk_generated_setup(struct device_node *np) hw = at91_clk_register_generated(regmap, &pmc_pcr_lock, &dt_pcr_layout, name, - parent_names, NULL, NULL, + NULL, parent_hws, NULL, num_parents, id, &range, chg_pid); if (IS_ERR(hw)) @@ -187,11 +214,11 @@ CLK_OF_DECLARE(of_sama5d2_clk_generated_setup, "atmel,sama5d2-clk-generated", #ifdef CONFIG_HAVE_AT91_H32MX static void __init of_sama5d4_clk_h32mx_setup(struct device_node *np) { - struct clk_hw *hw; + struct clk_hw *hw, *parent_hw; const char *name = np->name; - const char *parent_name; struct regmap *regmap; struct device_node *parent_np; + struct clk *clk; parent_np = of_get_parent(np); regmap = syscon_node_to_regmap(parent_np); @@ -199,9 +226,15 @@ static void __init of_sama5d4_clk_h32mx_setup(struct device_node *np) if (IS_ERR(regmap)) return; - parent_name = of_clk_get_parent_name(np, 0); + clk = of_clk_get(np, 0); + if (IS_ERR(clk)) + return; + + parent_hw = __clk_get_hw(clk); + if (!parent_hw) + return; - hw = at91_clk_register_h32mx(regmap, name, parent_name, NULL); + hw = at91_clk_register_h32mx(regmap, name, NULL, parent_hw); if (IS_ERR(hw)) return; @@ -217,11 +250,10 @@ CLK_OF_DECLARE(of_sama5d4_clk_h32mx_setup, "atmel,sama5d4-clk-h32mx", static void __init of_sama5d2_clk_i2s_mux_setup(struct device_node *np) { struct regmap *regmap_sfr; - u8 bus_id; - const char *parent_names[2]; + u8 bus_id, i; struct device_node *i2s_mux_np; - struct clk_hw *hw; - int ret; + struct clk_hw *hw, *parent_hws[2] = {}; + struct clk *clk; regmap_sfr = syscon_regmap_lookup_by_compatible("atmel,sama5d2-sfr"); if (IS_ERR(regmap_sfr)) @@ -234,16 +266,26 @@ static void __init of_sama5d2_clk_i2s_mux_setup(struct device_node *np) if (bus_id > I2S_BUS_NR) continue; - ret = of_clk_parent_fill(i2s_mux_np, parent_names, 2); - if (ret != 2) + for (i = 0; i < 2; i++) { + clk = of_clk_get(np, i); + if (IS_ERR(clk)) + break; + + parent_hws[i] = __clk_get_hw(clk); + if (!parent_hws[i]) + break; + } + if (!parent_hws[1]) continue; hw = at91_clk_i2s_mux_register(regmap_sfr, i2s_mux_np->name, - parent_names, NULL, 2, bus_id); + NULL, parent_hws, 2, bus_id); if (IS_ERR(hw)) continue; of_clk_add_hw_provider(i2s_mux_np, of_clk_hw_simple_get, hw); + + parent_hws[1] = NULL; } } CLK_OF_DECLARE(sama5d2_clk_i2s_mux, "atmel,sama5d2-clk-i2s-mux", @@ -258,6 +300,7 @@ static void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np) struct regmap *regmap; bool bypass; struct device_node *parent_np; + static struct clk_parent_data parent_data; of_property_read_string(np, "clock-output-names", &name); bypass = of_property_read_bool(np, "atmel,osc-bypass"); @@ -269,7 +312,9 @@ static void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np) if (IS_ERR(regmap)) return; - hw = at91_clk_register_main_osc(regmap, name, parent_name, NULL, bypass); + parent_data.name = parent_name; + parent_data.fw_name = parent_name; + hw = at91_clk_register_main_osc(regmap, name, NULL, &parent_data, bypass); if (IS_ERR(hw)) return; @@ -308,13 +353,12 @@ CLK_OF_DECLARE(at91sam9x5_clk_main_rc_osc, "atmel,at91sam9x5-clk-main-rc-osc", static void __init of_at91rm9200_clk_main_setup(struct device_node *np) { - struct clk_hw *hw; - const char *parent_name; + struct clk_hw *hw, *parent_hw; const char *name = np->name; struct regmap *regmap; struct device_node *parent_np; + struct clk *clk; - parent_name = of_clk_get_parent_name(np, 0); of_property_read_string(np, "clock-output-names", &name); parent_np = of_get_parent(np); @@ -323,7 +367,15 @@ static void __init of_at91rm9200_clk_main_setup(struct device_node *np) if (IS_ERR(regmap)) return; - hw = at91_clk_register_rm9200_main(regmap, name, parent_name, NULL); + clk = of_clk_get(np, 0); + if (IS_ERR(clk)) + return; + + parent_hw = __clk_get_hw(clk); + if (!parent_hw) + return; + + hw = at91_clk_register_rm9200_main(regmap, name, NULL, parent_hw); if (IS_ERR(hw)) return; @@ -334,18 +386,26 @@ CLK_OF_DECLARE(at91rm9200_clk_main, "atmel,at91rm9200-clk-main", static void __init of_at91sam9x5_clk_main_setup(struct device_node *np) { - struct clk_hw *hw; - const char *parent_names[2]; - unsigned int num_parents; + struct clk_hw *hw, *parent_hws[2]; + unsigned int num_parents, i; const char *name = np->name; struct regmap *regmap; struct device_node *parent_np; + struct clk *clk; num_parents = of_clk_get_parent_count(np); if (num_parents == 0 || num_parents > 2) return; - of_clk_parent_fill(np, parent_names, num_parents); + for (i = 0; i < num_parents; i++) { + clk = of_clk_get(np, i); + if (IS_ERR(clk)) + return; + + parent_hws[i] = __clk_get_hw(clk); + if (!parent_hws[i]) + return; + } parent_np = of_get_parent(np); regmap = syscon_node_to_regmap(parent_np); of_node_put(parent_np); @@ -354,7 +414,7 @@ static void __init of_at91sam9x5_clk_main_setup(struct device_node *np) of_property_read_string(np, "clock-output-names", &name); - hw = at91_clk_register_sam9x5_main(regmap, name, parent_names, NULL, + hw = at91_clk_register_sam9x5_main(regmap, name, NULL, parent_hws, num_parents); if (IS_ERR(hw)) return; @@ -393,19 +453,27 @@ static void __init of_at91_clk_master_setup(struct device_node *np, const struct clk_master_layout *layout) { - struct clk_hw *hw; - unsigned int num_parents; - const char *parent_names[MASTER_SOURCE_MAX]; + struct clk_hw *hw, *parent_hws[MASTER_SOURCE_MAX]; + unsigned int num_parents, i; const char *name = np->name; struct clk_master_characteristics *characteristics; struct regmap *regmap; struct device_node *parent_np; + struct clk *clk; num_parents = of_clk_get_parent_count(np); if (num_parents == 0 || num_parents > MASTER_SOURCE_MAX) return; - of_clk_parent_fill(np, parent_names, num_parents); + for (i = 0; i < MASTER_SOURCE_MAX; i++) { + clk = of_clk_get(np, i); + if (IS_ERR(clk)) + return; + + parent_hws[i] = __clk_get_hw(clk); + if (!parent_hws[i]) + return; + } of_property_read_string(np, "clock-output-names", &name); @@ -420,12 +488,12 @@ of_at91_clk_master_setup(struct device_node *np, return; hw = at91_clk_register_master_pres(regmap, "masterck_pres", num_parents, - parent_names, NULL, layout, + NULL, parent_hws, layout, characteristics, &mck_lock); if (IS_ERR(hw)) goto out_free_characteristics; - hw = at91_clk_register_master_div(regmap, name, "masterck_pres", NULL, + hw = at91_clk_register_master_div(regmap, name, NULL, hw, layout, characteristics, &mck_lock, CLK_SET_RATE_GATE, 0); if (IS_ERR(hw)) @@ -457,15 +525,19 @@ of_at91_clk_periph_setup(struct device_node *np, u8 type) { int num; u32 id; - struct clk_hw *hw; - const char *parent_name; + struct clk_hw *hw, *parent_hw; const char *name; struct device_node *periphclknp; struct regmap *regmap; struct device_node *parent_np; + struct clk *clk; - parent_name = of_clk_get_parent_name(np, 0); - if (!parent_name) + clk = of_clk_get(np, 0); + if (IS_ERR(clk)) + return; + + parent_hw = __clk_get_hw(clk); + if (!parent_hw) return; num = of_get_child_count(np); @@ -490,7 +562,7 @@ of_at91_clk_periph_setup(struct device_node *np, u8 type) if (type == PERIPHERAL_AT91RM9200) { hw = at91_clk_register_peripheral(regmap, name, - parent_name, NULL, id); + NULL, parent_hw, id); } else { struct clk_range range = CLK_RANGE(0, 0); unsigned long flags = 0; @@ -511,8 +583,8 @@ of_at91_clk_periph_setup(struct device_node *np, u8 type) &pmc_pcr_lock, &dt_pcr_layout, name, - parent_name, NULL, + parent_hw, id, &range, INT_MIN, flags); @@ -640,17 +712,23 @@ of_at91_clk_pll_setup(struct device_node *np, const struct clk_pll_layout *layout) { u32 id; - struct clk_hw *hw; + struct clk_hw *hw, *parent_hw; struct regmap *regmap; - const char *parent_name; const char *name = np->name; struct device_node *parent_np; struct clk_pll_characteristics *characteristics; + struct clk *clk; if (of_property_read_u32(np, "reg", &id)) return; - parent_name = of_clk_get_parent_name(np, 0); + clk = of_clk_get(np, 0); + if (IS_ERR(clk)) + return; + + parent_hw = __clk_get_hw(clk); + if (!parent_hw) + return; of_property_read_string(np, "clock-output-names", &name); @@ -664,7 +742,7 @@ of_at91_clk_pll_setup(struct device_node *np, if (!characteristics) return; - hw = at91_clk_register_pll(regmap, name, parent_name, NULL, id, layout, + hw = at91_clk_register_pll(regmap, name, NULL, parent_hw, id, layout, characteristics); if (IS_ERR(hw)) goto out_free_characteristics; @@ -707,13 +785,19 @@ CLK_OF_DECLARE(sama5d3_clk_pll, "atmel,sama5d3-clk-pll", static void __init of_at91sam9x5_clk_plldiv_setup(struct device_node *np) { - struct clk_hw *hw; - const char *parent_name; + struct clk_hw *hw, *parent_hw; const char *name = np->name; struct regmap *regmap; struct device_node *parent_np; + struct clk *clk; - parent_name = of_clk_get_parent_name(np, 0); + clk = of_clk_get(np, 0); + if (IS_ERR(clk)) + return; + + parent_hw = __clk_get_hw(clk); + if (!parent_hw) + return; of_property_read_string(np, "clock-output-names", &name); @@ -723,7 +807,7 @@ of_at91sam9x5_clk_plldiv_setup(struct device_node *np) if (IS_ERR(regmap)) return; - hw = at91_clk_register_plldiv(regmap, name, parent_name, NULL); + hw = at91_clk_register_plldiv(regmap, name, NULL, parent_hw); if (IS_ERR(hw)) return; @@ -739,18 +823,26 @@ of_at91_clk_prog_setup(struct device_node *np, { int num; u32 id; - struct clk_hw *hw; - unsigned int num_parents; - const char *parent_names[PROG_SOURCE_MAX]; + struct clk_hw *hw, *parent_hws[PROG_SOURCE_MAX]; + unsigned int num_parents, i; const char *name; struct device_node *progclknp, *parent_np; struct regmap *regmap; + struct clk *clk; num_parents = of_clk_get_parent_count(np); if (num_parents == 0 || num_parents > PROG_SOURCE_MAX) return; - of_clk_parent_fill(np, parent_names, num_parents); + for (i = 0; i < num_parents; i++) { + clk = of_clk_get(np, i); + if (IS_ERR(clk)) + return; + + parent_hws[i] = __clk_get_hw(clk); + if (!parent_hws[i]) + return; + } num = of_get_child_count(np); if (!num || num > (PROG_ID_MAX + 1)) @@ -770,7 +862,7 @@ of_at91_clk_prog_setup(struct device_node *np, name = progclknp->name; hw = at91_clk_register_programmable(regmap, name, - parent_names, NULL, num_parents, + NULL, parent_hws, num_parents, id, layout, mux_table); if (IS_ERR(hw)) continue; @@ -802,18 +894,26 @@ CLK_OF_DECLARE(at91sam9x5_clk_prog, "atmel,at91sam9x5-clk-programmable", static void __init of_at91sam9260_clk_slow_setup(struct device_node *np) { - struct clk_hw *hw; - const char *parent_names[2]; - unsigned int num_parents; + struct clk_hw *hw, *parent_hws[2]; + unsigned int num_parents, i; const char *name = np->name; struct regmap *regmap; struct device_node *parent_np; + struct clk *clk; num_parents = of_clk_get_parent_count(np); if (num_parents != 2) return; - of_clk_parent_fill(np, parent_names, num_parents); + for (i = 0; i < num_parents; i++) { + clk = of_clk_get(np, i); + if (IS_ERR(clk)) + return; + + parent_hws[i] = __clk_get_hw(clk); + if (!parent_hws[i]) + return; + } parent_np = of_get_parent(np); regmap = syscon_node_to_regmap(parent_np); of_node_put(parent_np); @@ -822,7 +922,7 @@ static void __init of_at91sam9260_clk_slow_setup(struct device_node *np) of_property_read_string(np, "clock-output-names", &name); - hw = at91_clk_register_sam9260_slow(regmap, name, parent_names, NULL, + hw = at91_clk_register_sam9260_slow(regmap, name, NULL, parent_hws, num_parents); if (IS_ERR(hw)) return; @@ -837,18 +937,26 @@ CLK_OF_DECLARE(at91sam9260_clk_slow, "atmel,at91sam9260-clk-slow", static void __init of_at91sam9x5_clk_smd_setup(struct device_node *np) { - struct clk_hw *hw; - unsigned int num_parents; - const char *parent_names[SMD_SOURCE_MAX]; + struct clk_hw *hw, *parent_hws[SMD_SOURCE_MAX]; + unsigned int num_parents, i; const char *name = np->name; struct regmap *regmap; struct device_node *parent_np; + struct clk *clk; num_parents = of_clk_get_parent_count(np); if (num_parents == 0 || num_parents > SMD_SOURCE_MAX) return; - of_clk_parent_fill(np, parent_names, num_parents); + for (i = 0; i < num_parents; i++) { + clk = of_clk_get(np, i); + if (IS_ERR(clk)) + return; + + parent_hws[i] = __clk_get_hw(clk); + if (!parent_hws[i]) + return; + } of_property_read_string(np, "clock-output-names", &name); @@ -858,7 +966,7 @@ static void __init of_at91sam9x5_clk_smd_setup(struct device_node *np) if (IS_ERR(regmap)) return; - hw = at91sam9x5_clk_register_smd(regmap, name, parent_names, NULL, + hw = at91sam9x5_clk_register_smd(regmap, name, NULL, parent_hws, num_parents); if (IS_ERR(hw)) return; @@ -873,11 +981,11 @@ static void __init of_at91rm9200_clk_sys_setup(struct device_node *np) { int num; u32 id; - struct clk_hw *hw; + struct clk_hw *hw, *parent_hw; const char *name; struct device_node *sysclknp, *parent_np; - const char *parent_name; struct regmap *regmap; + struct clk *clk; num = of_get_child_count(np); if (num > (SYSTEM_MAX_ID + 1)) @@ -898,7 +1006,13 @@ static void __init of_at91rm9200_clk_sys_setup(struct device_node *np) if (of_property_read_string(np, "clock-output-names", &name)) name = sysclknp->name; - parent_name = of_clk_get_parent_name(sysclknp, 0); + clk = of_clk_get(sysclknp, 0); + if (IS_ERR(clk)) + continue; + + parent_hw = __clk_get_hw(clk); + if (!parent_hw) + continue; /* * ddrck feeds DDR controller and is enabled by bootloader thus @@ -908,7 +1022,7 @@ static void __init of_at91rm9200_clk_sys_setup(struct device_node *np) if (!strcmp(sysclknp->name, "ddrck")) flags = CLK_IS_CRITICAL; - hw = at91_clk_register_system(regmap, name, parent_name, NULL, + hw = at91_clk_register_system(regmap, name, NULL, parent_hw, id, flags); if (IS_ERR(hw)) continue; @@ -924,18 +1038,26 @@ CLK_OF_DECLARE(at91rm9200_clk_sys, "atmel,at91rm9200-clk-system", static void __init of_at91sam9x5_clk_usb_setup(struct device_node *np) { - struct clk_hw *hw; - unsigned int num_parents; - const char *parent_names[USB_SOURCE_MAX]; + struct clk_hw *hw, *parent_hws[USB_SOURCE_MAX]; + unsigned int num_parents, i; const char *name = np->name; struct regmap *regmap; struct device_node *parent_np; + struct clk *clk; num_parents = of_clk_get_parent_count(np); if (num_parents == 0 || num_parents > USB_SOURCE_MAX) return; - of_clk_parent_fill(np, parent_names, num_parents); + for (i = 0; i < num_parents; i++) { + clk = of_clk_get(np, i); + if (IS_ERR(clk)) + return; + + parent_hws[i] = __clk_get_hw(clk); + if (!parent_hws[i]) + return; + } of_property_read_string(np, "clock-output-names", &name); @@ -945,7 +1067,7 @@ static void __init of_at91sam9x5_clk_usb_setup(struct device_node *np) if (IS_ERR(regmap)) return; - hw = at91sam9x5_clk_register_usb(regmap, name, parent_names, NULL, + hw = at91sam9x5_clk_register_usb(regmap, name, NULL, parent_hws, num_parents); if (IS_ERR(hw)) return; @@ -957,14 +1079,18 @@ CLK_OF_DECLARE(at91sam9x5_clk_usb, "atmel,at91sam9x5-clk-usb", static void __init of_at91sam9n12_clk_usb_setup(struct device_node *np) { - struct clk_hw *hw; - const char *parent_name; + struct clk_hw *hw, *parent_hw; const char *name = np->name; struct regmap *regmap; struct device_node *parent_np; + struct clk *clk; - parent_name = of_clk_get_parent_name(np, 0); - if (!parent_name) + clk = of_clk_get(np, 0); + if (IS_ERR(clk)) + return; + + parent_hw = __clk_get_hw(clk); + if (!parent_hw) return; of_property_read_string(np, "clock-output-names", &name); @@ -975,7 +1101,7 @@ static void __init of_at91sam9n12_clk_usb_setup(struct device_node *np) if (IS_ERR(regmap)) return; - hw = at91sam9n12_clk_register_usb(regmap, name, parent_name, NULL); + hw = at91sam9n12_clk_register_usb(regmap, name, NULL, parent_hw); if (IS_ERR(hw)) return; @@ -986,15 +1112,19 @@ CLK_OF_DECLARE(at91sam9n12_clk_usb, "atmel,at91sam9n12-clk-usb", static void __init of_at91rm9200_clk_usb_setup(struct device_node *np) { - struct clk_hw *hw; - const char *parent_name; + struct clk_hw *hw, *parent_hw; const char *name = np->name; u32 divisors[4] = {0, 0, 0, 0}; struct regmap *regmap; struct device_node *parent_np; + struct clk *clk; - parent_name = of_clk_get_parent_name(np, 0); - if (!parent_name) + clk = of_clk_get(np, 0); + if (IS_ERR(clk)) + return; + + parent_hw = __clk_get_hw(clk); + if (!parent_hw) return; of_property_read_u32_array(np, "atmel,clk-divisors", divisors, 4); @@ -1008,7 +1138,7 @@ static void __init of_at91rm9200_clk_usb_setup(struct device_node *np) of_node_put(parent_np); if (IS_ERR(regmap)) return; - hw = at91rm9200_clk_register_usb(regmap, name, parent_name, NULL, divisors); + hw = at91rm9200_clk_register_usb(regmap, name, NULL, parent_hw, divisors); if (IS_ERR(hw)) return; @@ -1021,13 +1151,19 @@ CLK_OF_DECLARE(at91rm9200_clk_usb, "atmel,at91rm9200-clk-usb", #ifdef CONFIG_HAVE_AT91_UTMI static void __init of_at91sam9x5_clk_utmi_setup(struct device_node *np) { - struct clk_hw *hw; - const char *parent_name; + struct clk_hw *hw, *parent_hw; const char *name = np->name; struct regmap *regmap_pmc, *regmap_sfr; struct device_node *parent_np; + struct clk *clk; - parent_name = of_clk_get_parent_name(np, 0); + clk = of_clk_get(np, 0); + if (IS_ERR(clk)) + return; + + parent_hw = __clk_get_hw(clk); + if (!parent_hw) + return; of_property_read_string(np, "clock-output-names", &name); @@ -1055,7 +1191,7 @@ static void __init of_at91sam9x5_clk_utmi_setup(struct device_node *np) regmap_sfr = NULL; } - hw = at91_clk_register_utmi(regmap_pmc, regmap_sfr, name, parent_name, NULL); + hw = at91_clk_register_utmi(regmap_pmc, regmap_sfr, name, NULL, parent_hw); if (IS_ERR(hw)) return;