From nobody Tue Oct 7 11:39:37 2025 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED16E309DC6; Thu, 10 Jul 2025 20:08:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.154.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752178090; cv=none; b=GRJpnEI9YDOMA6zOqiIkA5triBjIwtDvgVzpb5gEOGxt8RwujpsD/BF6trygMgioWj6ngUYiP+SDVY5bN06Eb2j74lgzWvs1njdJeN3baqm8w6zW4hWOycLwNzgzZmv3JDZD4ruPrYAJDlhj0408eDjdk2i0k+QLvpt3y0IlNkY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752178090; c=relaxed/simple; bh=aMmv092GQeQBtAZmEdJbDY5OV3ksnoMeUpRINntQCic=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RKXyfPTQE5baUfWE/1oae9T0FzfYkVhTazUH8jtxExCU+NsbGCX/IazxtKBFWXn8+Eo/eva3ebUq8dUpW/+OtEovGEH5rywsw2465BZLI+Aoo5LsVFn6p7ucMXRzKrgtzYyYS6N9uU2kxqNsOxmYAVLM9XwFawL2VNjcSI4oRVs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=2jlDXewJ; arc=none smtp.client-ip=68.232.154.123 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="2jlDXewJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1752178088; x=1783714088; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aMmv092GQeQBtAZmEdJbDY5OV3ksnoMeUpRINntQCic=; b=2jlDXewJ6ZYtvGckTBqJOu0wZf8EDVxCDVUkOME6Dps22liS73NuaUC/ xnBIsB8VonOIytgleerT6gzK0/LN3nn6zDSEpdpwnJj7GEqa9qZbTJhjk aHQfTcS4sS4/qJp26h3ainpAbmB4wUkm9oDIXYFDCn/Kv84WLVcvW6bpe 3A0lP8/rkVwuPOST0ioRAOcymb80wJUnnhLWnoxzWDpLye7T/Y/cDATkJ l2L+JrN1D9V/eRT6cuK0sgBX5uvpPkJDXvtZZ1SPdDYzWdK1YxtsF2L9C VrnGgKYiWiqIxMhioSEmt2TNXt2jijnd5r2jI0n+0LbqqErVGAdCQ6zYc A==; X-CSE-ConnectionGUID: VcY24SkbRKSMnNSaLxS1vA== X-CSE-MsgGUID: PvhPmzYTQ0OL19DYvW8p/A== X-IronPort-AV: E=Sophos;i="6.16,301,1744095600"; d="scan'208";a="44448165" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 10 Jul 2025 13:07:54 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.44; Thu, 10 Jul 2025 13:07:31 -0700 Received: from ryan-Precision-3630-Tower.microchip.com (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.44 via Frontend Transport; Thu, 10 Jul 2025 13:07:31 -0700 From: To: , , , , CC: , , , , Subject: [PATCH v3 10/32] clk: at91: clk-generated: use clk_parent_data Date: Thu, 10 Jul 2025 13:07:03 -0700 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Use struct clk_parent_data instead of struct parent_hw as this leads to less usage of __clk_get_hw() in SoC specific clock drivers and simpler conversion of existing SoC specific clock drivers from parent_names to modern clk_parent_data structures. Signed-off-by: Claudiu Beznea [ryan.wanner@microchip.com: Added SAMA7D65 and SAM9X75 SoCs to the clk-generated changes. Adjust clk name variable order.] Signed-off-by: Ryan Wanner --- drivers/clk/at91/clk-generated.c | 8 ++++---- drivers/clk/at91/pmc.h | 2 +- drivers/clk/at91/sam9x7.c | 26 ++++++++++---------------- drivers/clk/at91/sama7d65.c | 31 +++++++++++++------------------ drivers/clk/at91/sama7g5.c | 30 +++++++++++------------------- 5 files changed, 39 insertions(+), 58 deletions(-) diff --git a/drivers/clk/at91/clk-generated.c b/drivers/clk/at91/clk-genera= ted.c index 4b4edeecc889..d9e00167dbc8 100644 --- a/drivers/clk/at91/clk-generated.c +++ b/drivers/clk/at91/clk-generated.c @@ -319,7 +319,7 @@ struct clk_hw * __init at91_clk_register_generated(struct regmap *regmap, spinlock_t *lock, const struct clk_pcr_layout *layout, const char *name, const char **parent_names, - struct clk_hw **parent_hws, + struct clk_parent_data *parent_data, u32 *mux_table, u8 num_parents, u8 id, const struct clk_range *range, int chg_pid) @@ -329,7 +329,7 @@ at91_clk_register_generated(struct regmap *regmap, spin= lock_t *lock, struct clk_hw *hw; int ret; =20 - if (!(parent_names || parent_hws)) + if (!(parent_names || parent_data)) return ERR_PTR(-ENOMEM); =20 gck =3D kzalloc(sizeof(*gck), GFP_KERNEL); @@ -338,8 +338,8 @@ at91_clk_register_generated(struct regmap *regmap, spin= lock_t *lock, =20 init.name =3D name; init.ops =3D &generated_ops; - if (parent_hws) - init.parent_hws =3D (const struct clk_hw **)parent_hws; + if (parent_data) + init.parent_data =3D (const struct clk_parent_data *)parent_data; else init.parent_names =3D parent_names; init.num_parents =3D num_parents; diff --git a/drivers/clk/at91/pmc.h b/drivers/clk/at91/pmc.h index 34036f2d0578..0646775dfb1d 100644 --- a/drivers/clk/at91/pmc.h +++ b/drivers/clk/at91/pmc.h @@ -171,7 +171,7 @@ struct clk_hw * __init at91_clk_register_generated(struct regmap *regmap, spinlock_t *lock, const struct clk_pcr_layout *layout, const char *name, const char **parent_names, - struct clk_hw **parent_hws, u32 *mux_table, + struct clk_parent_data *parent_data, u32 *mux_table, u8 num_parents, u8 id, const struct clk_range *range, int chg_pid); =20 diff --git a/drivers/clk/at91/sam9x7.c b/drivers/clk/at91/sam9x7.c index 86d624cd92b2..c4578944611e 100644 --- a/drivers/clk/at91/sam9x7.c +++ b/drivers/clk/at91/sam9x7.c @@ -739,8 +739,8 @@ static void __init sam9x7_pmc_setup(struct device_node = *np) { u8 td_slck_index =3D 0, md_slck_index =3D 1, main_xtal_index =3D 2; struct clk_range range =3D CLK_RANGE(0, 0); - const char *main_xtal_name =3D "main_xtal"; - const char * const td_slck_name =3D "td_slck"; + const char *const main_xtal_name =3D "main_xtal"; + const char *const td_slck_name =3D "td_slck"; const char *const md_slck_name =3D "md_slck"; struct pmc_data *sam9x7_pmc; const char *parent_names[9]; @@ -748,16 +748,13 @@ static void __init sam9x7_pmc_setup(struct device_nod= e *np) int clk_mux_buffer_size =3D 0; struct regmap *regmap; struct clk_hw *hw, *main_rc_hw, *main_osc_hw, *main_xtal_hw; - struct clk_hw *td_slck_hw, *md_slck_hw, *usbck_hw; + struct clk_hw *usbck_hw; struct clk_parent_data parent_data[9]; - struct clk_hw *parent_hws[9]; int i, j; =20 - td_slck_hw =3D __clk_get_hw(of_clk_get_by_name(np, td_slck_name)); - md_slck_hw =3D __clk_get_hw(of_clk_get_by_name(np, md_slck_name)); main_xtal_hw =3D __clk_get_hw(of_clk_get_by_name(np, main_xtal_name)); =20 - if (!td_slck_hw || !md_slck_hw || !main_xtal_hw) + if (!main_xtal_hw) return; =20 regmap =3D device_node_to_regmap(np); @@ -933,13 +930,12 @@ static void __init sam9x7_pmc_setup(struct device_nod= e *np) sam9x7_pmc->phws[sam9x7_periphck[i].id] =3D hw; } =20 - parent_hws[0] =3D md_slck_hw; - parent_hws[1] =3D td_slck_hw; - parent_hws[2] =3D sam9x7_pmc->chws[PMC_MAIN]; - parent_hws[3] =3D sam9x7_pmc->chws[PMC_MCK]; + parent_data[0] =3D AT91_CLK_PD_NAME(md_slck_name, md_slck_index); + parent_data[1] =3D AT91_CLK_PD_NAME(td_slck_name, td_slck_index); + parent_data[2] =3D AT91_CLK_PD_HW(sam9x7_pmc->chws[PMC_MAIN]); + parent_data[3] =3D AT91_CLK_PD_HW(sam9x7_pmc->chws[PMC_MCK]); for (i =3D 0; i < ARRAY_SIZE(sam9x7_gck); i++) { u8 num_parents =3D 4 + sam9x7_gck[i].pp_count; - struct clk_hw *tmp_parent_hws[6]; u32 *mux_table; =20 mux_table =3D kmalloc_array(num_parents, sizeof(*mux_table), @@ -954,15 +950,13 @@ static void __init sam9x7_pmc_setup(struct device_nod= e *np) u8 pll_id =3D sam9x7_gck[i].pp[j].pll_id; u8 pll_compid =3D sam9x7_gck[i].pp[j].pll_compid; =20 - tmp_parent_hws[j] =3D sam9x7_plls[pll_id][pll_compid].hw; + parent_data[4 + j] =3D AT91_CLK_PD_HW(sam9x7_plls[pll_id][pll_compid].h= w); } - PMC_FILL_TABLE(&parent_hws[4], tmp_parent_hws, - sam9x7_gck[i].pp_count); =20 hw =3D at91_clk_register_generated(regmap, &pmc_pcr_lock, &sam9x7_pcr_layout, sam9x7_gck[i].n, - NULL, parent_hws, mux_table, + NULL, parent_data, mux_table, num_parents, sam9x7_gck[i].id, &sam9x7_gck[i].r, diff --git a/drivers/clk/at91/sama7d65.c b/drivers/clk/at91/sama7d65.c index 7463719260e0..4d47d20e65fb 100644 --- a/drivers/clk/at91/sama7d65.c +++ b/drivers/clk/at91/sama7d65.c @@ -1092,22 +1092,20 @@ static void __init sama7d65_pmc_setup(struct device= _node *np) u8 td_slck_index =3D 0, md_slck_index =3D 1, main_xtal_index =3D 2; struct clk_hw *hw, *main_rc_hw, *main_osc_hw, *main_xtal_hw; const char * const main_xtal_name =3D "main_xtal"; + const char * const td_slck_name =3D "td_slck"; + const char * const md_slck_name =3D "md_slck"; struct clk_parent_data parent_data[10]; struct pmc_data *sama7d65_pmc; const char *parent_names[11]; void **alloc_mem =3D NULL; int alloc_mem_size =3D 0; struct regmap *regmap; - struct clk_hw *td_slck_hw, *md_slck_hw; - struct clk_hw *parent_hws[10]; bool bypass; int i, j; =20 - td_slck_hw =3D __clk_get_hw(of_clk_get_by_name(np, "td_slck")); - md_slck_hw =3D __clk_get_hw(of_clk_get_by_name(np, "md_slck")); main_xtal_hw =3D __clk_get_hw(of_clk_get_by_name(np, main_xtal_name)); =20 - if (!td_slck_hw || !md_slck_hw || !main_xtal_hw) + if (!main_xtal_hw) return; =20 regmap =3D device_node_to_regmap(np); @@ -1216,8 +1214,8 @@ static void __init sama7d65_pmc_setup(struct device_n= ode *np) sama7d65_pmc->chws[PMC_MCK] =3D hw; sama7d65_mckx[PCK_PARENT_HW_MCK0].hw =3D hw; =20 - parent_data[0] =3D AT91_CLK_PD_NAME("md_slck", md_slck_index); - parent_data[1] =3D AT91_CLK_PD_NAME("td_slck", td_slck_index); + parent_data[0] =3D AT91_CLK_PD_NAME(md_slck_name, md_slck_index); + parent_data[1] =3D AT91_CLK_PD_NAME(td_slck_name, td_slck_index); parent_data[2] =3D AT91_CLK_PD_HW(sama7d65_pmc->chws[PMC_MAIN]); for (i =3D PCK_PARENT_HW_MCK1; i < ARRAY_SIZE(sama7d65_mckx); i++) { u8 num_parents =3D 3 + sama7d65_mckx[i].ep_count; @@ -1262,8 +1260,8 @@ static void __init sama7d65_pmc_setup(struct device_n= ode *np) if (IS_ERR(hw)) goto err_free; =20 - parent_data[0] =3D AT91_CLK_PD_NAME("md_slck", md_slck_index); - parent_data[1] =3D AT91_CLK_PD_NAME("td_slck", td_slck_index); + parent_data[0] =3D AT91_CLK_PD_NAME(md_slck_name, md_slck_index); + parent_data[1] =3D AT91_CLK_PD_NAME(td_slck_name, td_slck_index); parent_data[2] =3D AT91_CLK_PD_HW(sama7d65_pmc->chws[PMC_MAIN]); parent_data[3] =3D AT91_CLK_PD_HW(sama7d65_plls[PLL_ID_SYS][PLL_COMPID_DI= V0].hw); parent_data[4] =3D AT91_CLK_PD_HW(sama7d65_plls[PLL_ID_DDR][PLL_COMPID_DI= V0].hw); @@ -1313,13 +1311,12 @@ static void __init sama7d65_pmc_setup(struct device= _node *np) sama7d65_pmc->phws[sama7d65_periphck[i].id] =3D hw; } =20 - parent_hws[0] =3D md_slck_hw; - parent_hws[1] =3D td_slck_hw; - parent_hws[2] =3D sama7d65_pmc->chws[PMC_MAIN]; - parent_hws[3] =3D sama7d65_pmc->chws[PMC_MCK1]; + parent_data[0] =3D AT91_CLK_PD_NAME(md_slck_name, md_slck_index); + parent_data[1] =3D AT91_CLK_PD_NAME(td_slck_name, td_slck_index); + parent_data[2] =3D AT91_CLK_PD_HW(sama7d65_pmc->chws[PMC_MAIN]); + parent_data[3] =3D AT91_CLK_PD_HW(sama7d65_pmc->chws[PMC_MCK1]); for (i =3D 0; i < ARRAY_SIZE(sama7d65_gck); i++) { u8 num_parents =3D 4 + sama7d65_gck[i].pp_count; - struct clk_hw *tmp_parent_hws[8]; u32 *mux_table; =20 mux_table =3D kmalloc_array(num_parents, sizeof(*mux_table), @@ -1336,15 +1333,13 @@ static void __init sama7d65_pmc_setup(struct device= _node *np) u8 pll_id =3D sama7d65_gck[i].pp[j].pll_id; u8 pll_compid =3D sama7d65_gck[i].pp[j].pll_compid; =20 - tmp_parent_hws[j] =3D sama7d65_plls[pll_id][pll_compid].hw; + parent_data[4 + j] =3D AT91_CLK_PD_HW(sama7d65_plls[pll_id][pll_compid]= .hw); } - PMC_FILL_TABLE(&parent_hws[4], tmp_parent_hws, - sama7d65_gck[i].pp_count); =20 hw =3D at91_clk_register_generated(regmap, &pmc_pcr_lock, &sama7d65_pcr_layout, sama7d65_gck[i].n, NULL, - parent_hws, mux_table, + parent_data, mux_table, num_parents, sama7d65_gck[i].id, &sama7d65_gck[i].r, diff --git a/drivers/clk/at91/sama7g5.c b/drivers/clk/at91/sama7g5.c index a6824d0accb9..505db97e989b 100644 --- a/drivers/clk/at91/sama7g5.c +++ b/drivers/clk/at91/sama7g5.c @@ -971,10 +971,10 @@ static void __init sama7g5_pmc_setup(struct device_no= de *np) { u8 td_slck_index =3D 0, md_slck_index =3D 1, main_xtal_index =3D 2; const char * const main_xtal_name =3D "main_xtal"; + const char * const td_slck_name =3D "td_slck"; + const char * const md_slck_name =3D "md_slck"; struct clk_hw *hw, *main_rc_hw, *main_osc_hw; struct clk_parent_data parent_data[10]; - struct clk_hw *td_slck_hw, *md_slck_hw; - struct clk_hw *parent_hws[10]; struct pmc_data *sama7g5_pmc; void **alloc_mem =3D NULL; int alloc_mem_size =3D 0; @@ -983,11 +983,6 @@ static void __init sama7g5_pmc_setup(struct device_nod= e *np) bool bypass; int i, j; =20 - td_slck_hw =3D __clk_get_hw(of_clk_get_by_name(np, "td_slck")); - md_slck_hw =3D __clk_get_hw(of_clk_get_by_name(np, "md_slck")); - if (!td_slck_hw || !md_slck_hw) - return; - main_xtal =3D of_clk_get(np, main_xtal_index); if (IS_ERR(main_xtal)) return; @@ -1097,8 +1092,8 @@ static void __init sama7g5_pmc_setup(struct device_no= de *np) =20 sama7g5_mckx[PCK_PARENT_HW_MCK0].hw =3D sama7g5_pmc->chws[PMC_MCK] =3D hw; =20 - parent_data[0] =3D AT91_CLK_PD_NAME("md_slck", md_slck_index); - parent_data[1] =3D AT91_CLK_PD_NAME("td_slck", td_slck_index); + parent_data[0] =3D AT91_CLK_PD_NAME(md_slck_name, md_slck_index); + parent_data[1] =3D AT91_CLK_PD_NAME(td_slck_name, td_slck_index); parent_data[2] =3D AT91_CLK_PD_HW(sama7g5_pmc->chws[PMC_MAIN]); for (i =3D PCK_PARENT_HW_MCK1; i < ARRAY_SIZE(sama7g5_mckx); i++) { u8 num_parents =3D 3 + sama7g5_mckx[i].ep_count; @@ -1141,8 +1136,8 @@ static void __init sama7g5_pmc_setup(struct device_no= de *np) =20 sama7g5_pmc->chws[PMC_UTMI] =3D hw; =20 - parent_data[0] =3D AT91_CLK_PD_NAME("md_slck", md_slck_index); - parent_data[1] =3D AT91_CLK_PD_NAME("td_slck", td_slck_index); + parent_data[0] =3D AT91_CLK_PD_NAME(md_slck_name, md_slck_index); + parent_data[1] =3D AT91_CLK_PD_NAME(td_slck_name, td_slck_index); parent_data[2] =3D AT91_CLK_PD_HW(sama7g5_pmc->chws[PMC_MAIN]); parent_data[3] =3D AT91_CLK_PD_HW(sama7g5_plls[PLL_ID_SYS][PLL_COMPID_DIV= 0].hw); parent_data[4] =3D AT91_CLK_PD_HW(sama7g5_plls[PLL_ID_DDR][PLL_COMPID_DIV= 0].hw); @@ -1191,12 +1186,11 @@ static void __init sama7g5_pmc_setup(struct device_= node *np) sama7g5_pmc->phws[sama7g5_periphck[i].id] =3D hw; } =20 - parent_hws[0] =3D md_slck_hw; - parent_hws[1] =3D td_slck_hw; - parent_hws[2] =3D sama7g5_pmc->chws[PMC_MAIN]; + parent_data[0] =3D AT91_CLK_PD_NAME(md_slck_name, md_slck_index); + parent_data[1] =3D AT91_CLK_PD_NAME(td_slck_name, td_slck_index); + parent_data[2] =3D AT91_CLK_PD_HW(sama7g5_pmc->chws[PMC_MAIN]); for (i =3D 0; i < ARRAY_SIZE(sama7g5_gck); i++) { u8 num_parents =3D 3 + sama7g5_gck[i].pp_count; - struct clk_hw *tmp_parent_hws[8]; u32 *mux_table; =20 mux_table =3D kmalloc_array(num_parents, sizeof(*mux_table), @@ -1211,15 +1205,13 @@ static void __init sama7g5_pmc_setup(struct device_= node *np) u8 pll_id =3D sama7g5_gck[i].pp[j].pll_id; u8 pll_compid =3D sama7g5_gck[i].pp[j].pll_compid; =20 - tmp_parent_hws[j] =3D sama7g5_plls[pll_id][pll_compid].hw; + parent_data[3 + j] =3D AT91_CLK_PD_HW(sama7g5_plls[pll_id][pll_compid].= hw); } - PMC_FILL_TABLE(&parent_hws[3], tmp_parent_hws, - sama7g5_gck[i].pp_count); =20 hw =3D at91_clk_register_generated(regmap, &pmc_pcr_lock, &sama7g5_pcr_layout, sama7g5_gck[i].n, NULL, - parent_hws, mux_table, + parent_data, mux_table, num_parents, sama7g5_gck[i].id, &sama7g5_gck[i].r, --=20 2.43.0