From mboxrd@z Thu Jan 1 00:00:00 1970 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 4023F30206F; Tue, 24 Jun 2025 15:09:26 +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=1750777768; cv=none; b=J44Mpaafn6d55n6pO/PczP12wv7cKahgnsJQ2bLN6SfpYvAelrE44+s2LOsfeZXiyvUVq0+8lLZljIUuC9zotz3PHs+18upLzmaIrM3P8Er4UCmOgLu8dC9MNhfL08BW9bAMxZHaUsKlvhaLnh1KjBnsPBmXHEKJlil+9QkwaYA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750777768; c=relaxed/simple; bh=JWotn6zOQ5IW0wDa+ISJNrl2eUUzRYVOewzqf7oerG0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hhaCZOq3SA7dSkrNFG1ONzLsgMUsy0nfzH5ffev4ax+WQWsXgRC8nbm7lAjEesVc9is0oCvZIlygDkQNbPqWuha/egfyIwIbK/baNVWxlaSwmoqBj9IpgY99GhD/8LB5ow0Hs9kGOvJnUn/nRckF6SEKxLYLU6LZQXTs7s6/fbk= 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=Gigfw06I; 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="Gigfw06I" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1750777766; x=1782313766; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JWotn6zOQ5IW0wDa+ISJNrl2eUUzRYVOewzqf7oerG0=; b=Gigfw06IuWHuFPXiv9tMGf5GJ0RXw+nthTe5mZEKBvfLwz9YgWfq5I3h NIp0ojUd899ROxwlRVUFB9gUBk9n6652UIL6elH0W5yBSmHd08xPB55Sz Jin+rMKPr9PVoQKOhPSotpfYP5uwbvKPDGjIVcp1bSAz5g+hoKUwQ+c1q nSL8USlRJVGs5AkYb7ERzUuflseQ+IADngloKq15CFrmmGm3ILJ5R+NHD +YgxR/Ef8TeJt9Qh0DulptpoIqmAqFpXOwDcRsFPVuT/yE6axkY/EJSin snuwftmdCzrfuSHeV/tC25l6abQGeRNJegoBJMr7nk8zIK5mOt05PF1ln A==; X-CSE-ConnectionGUID: ticneE1VRpCt6c5L3blMOw== X-CSE-MsgGUID: jq4Jq8oeRVyyAiCfQ1wnSg== X-IronPort-AV: E=Sophos;i="6.16,262,1744095600"; d="scan'208";a="210641598" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 24 Jun 2025 08:09:20 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.44; Tue, 24 Jun 2025 08:08:40 -0700 Received: from ryan-Precision-3630-Tower.microchip.com (10.10.85.11) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.44 via Frontend Transport; Tue, 24 Jun 2025 08:08:40 -0700 From: To: , , , , CC: , , , , Subject: [PATCH v2 27/32] clk: at91: at91sam9g45: switch to parent_hw and parent_data Date: Tue, 24 Jun 2025 08:08:24 -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: 8bit Content-Type: text/plain From: Claudiu Beznea Switch AT91SAM9G45 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 Signed-off-by: Ryan Wanner --- drivers/clk/at91/at91sam9g45.c | 89 +++++++++++++++++----------------- 1 file changed, 44 insertions(+), 45 deletions(-) diff --git a/drivers/clk/at91/at91sam9g45.c b/drivers/clk/at91/at91sam9g45.c index 684d2bcb36e8..54cc4e1bbdc3 100644 --- a/drivers/clk/at91/at91sam9g45.c +++ b/drivers/clk/at91/at91sam9g45.c @@ -37,9 +37,9 @@ static const struct clk_pll_characteristics plla_characteristics = { .out = plla_out, }; -static const struct { +static struct { char *n; - char *p; + struct clk_hw *parent_hw; unsigned long flags; u8 id; } at91sam9g45_systemck[] = { @@ -47,10 +47,10 @@ static const struct { * ddrck feeds DDR controller and is enabled by bootloader thus we need * to keep it enabled in case there is no Linux consumer for it. */ - { .n = "ddrck", .p = "masterck_div", .id = 2, .flags = CLK_IS_CRITICAL }, - { .n = "uhpck", .p = "usbck", .id = 6 }, - { .n = "pck0", .p = "prog0", .id = 8 }, - { .n = "pck1", .p = "prog1", .id = 9 }, + { .n = "ddrck", .id = 2, .flags = CLK_IS_CRITICAL }, + { .n = "uhpck", .id = 6 }, + { .n = "pck0", .id = 8 }, + { .n = "pck1", .id = 9 }, }; struct pck { @@ -92,24 +92,14 @@ static const struct pck at91sam9g45_periphck[] = { static void __init at91sam9g45_pmc_setup(struct device_node *np) { - const char *slck_name, *mainxtal_name; + const char *slow_clk_name = "slowck", *main_xtal_name = "main_xtal"; + u8 slow_clk_index = 0, main_xtal_index = 1; + struct clk_parent_data parent_data[5]; struct pmc_data *at91sam9g45_pmc; - const char *parent_names[6]; + struct clk_hw *usbck_hw, *hw; struct regmap *regmap; - struct clk_hw *hw; - int i; bool bypass; - - i = of_property_match_string(np, "clock-names", "slow_clk"); - if (i < 0) - return; - - slck_name = of_clk_get_parent_name(np, i); - - i = of_property_match_string(np, "clock-names", "main_xtal"); - if (i < 0) - return; - mainxtal_name = of_clk_get_parent_name(np, i); + int i; regmap = device_node_to_regmap(np); if (IS_ERR(regmap)) @@ -123,40 +113,43 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np) bypass = of_property_read_bool(np, "atmel,osc-bypass"); - hw = at91_clk_register_main_osc(regmap, "main_osc", mainxtal_name, NULL, + hw = at91_clk_register_main_osc(regmap, "main_osc", NULL, + &AT91_CLK_PD_NAME(main_xtal_name, main_xtal_index), bypass); if (IS_ERR(hw)) goto err_free; - hw = at91_clk_register_rm9200_main(regmap, "mainck", "main_osc", NULL); + hw = at91_clk_register_rm9200_main(regmap, "mainck", NULL, &AT91_CLK_PD_HW(hw)); if (IS_ERR(hw)) goto err_free; at91sam9g45_pmc->chws[PMC_MAIN] = hw; - hw = at91_clk_register_pll(regmap, "pllack", "mainck", 0, + hw = at91_clk_register_pll(regmap, "pllack", NULL, + &AT91_CLK_PD_HW(at91sam9g45_pmc->chws[PMC_MAIN]), 0, &at91rm9200_pll_layout, &plla_characteristics); if (IS_ERR(hw)) goto err_free; - hw = at91_clk_register_plldiv(regmap, "plladivck", "pllack"); + hw = at91_clk_register_plldiv(regmap, "plladivck", NULL, &AT91_CLK_PD_HW(hw)); if (IS_ERR(hw)) goto err_free; at91sam9g45_pmc->chws[PMC_PLLACK] = hw; - hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck", NULL); + hw = at91_clk_register_utmi(regmap, NULL, "utmick", NULL, + &AT91_CLK_PD_HW(at91sam9g45_pmc->chws[PMC_MAIN])); if (IS_ERR(hw)) goto err_free; at91sam9g45_pmc->chws[PMC_UTMI] = hw; - parent_names[0] = slck_name; - parent_names[1] = "mainck"; - parent_names[2] = "plladivck"; - parent_names[3] = "utmick"; + parent_data[0] = AT91_CLK_PD_NAME(slow_clk_name, slow_clk_index); + parent_data[1] = AT91_CLK_PD_HW(at91sam9g45_pmc->chws[PMC_MAIN]); + parent_data[2] = AT91_CLK_PD_HW(at91sam9g45_pmc->chws[PMC_PLLACK]); + parent_data[3] = AT91_CLK_PD_HW(at91sam9g45_pmc->chws[PMC_UTMI]); hw = at91_clk_register_master_pres(regmap, "masterck_pres", 4, - parent_names, NULL, + NULL, parent_data, &at91rm9200_master_layout, &mck_characteristics, &at91sam9g45_mck_lock); @@ -164,7 +157,7 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np) goto err_free; hw = at91_clk_register_master_div(regmap, "masterck_div", - "masterck_pres", NULL, + NULL, &AT91_CLK_PD_HW(hw), &at91rm9200_master_layout, &mck_characteristics, &at91sam9g45_mck_lock, @@ -174,24 +167,24 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np) at91sam9g45_pmc->chws[PMC_MCK] = hw; - parent_names[0] = "plladivck"; - parent_names[1] = "utmick"; - hw = at91sam9x5_clk_register_usb(regmap, "usbck", parent_names, NULL, 2); - if (IS_ERR(hw)) + parent_data[0] = AT91_CLK_PD_HW(at91sam9g45_pmc->chws[PMC_PLLACK]); + parent_data[1] = AT91_CLK_PD_HW(at91sam9g45_pmc->chws[PMC_UTMI]); + usbck_hw = at91sam9x5_clk_register_usb(regmap, "usbck", NULL, parent_data, 2); + if (IS_ERR(usbck_hw)) goto err_free; - parent_names[0] = slck_name; - parent_names[1] = "mainck"; - parent_names[2] = "plladivck"; - parent_names[3] = "utmick"; - parent_names[4] = "masterck_div"; + parent_data[0] = AT91_CLK_PD_NAME(slow_clk_name, slow_clk_index); + parent_data[1] = AT91_CLK_PD_HW(at91sam9g45_pmc->chws[PMC_MAIN]); + parent_data[2] = AT91_CLK_PD_HW(at91sam9g45_pmc->chws[PMC_PLLACK]); + parent_data[3] = AT91_CLK_PD_HW(at91sam9g45_pmc->chws[PMC_UTMI]); + parent_data[4] = AT91_CLK_PD_HW(at91sam9g45_pmc->chws[PMC_MCK]); for (i = 0; i < 2; i++) { char name[6]; snprintf(name, sizeof(name), "prog%d", i); hw = at91_clk_register_programmable(regmap, name, - parent_names, NULL, 5, i, + NULL, parent_data, 5, i, &at91sam9g45_programmable_layout, NULL); if (IS_ERR(hw)) @@ -200,9 +193,14 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np) at91sam9g45_pmc->pchws[i] = hw; } + /* Set systemck parent hws. */ + at91sam9g45_systemck[0].parent_hw = at91sam9g45_pmc->chws[PMC_MCK]; + at91sam9g45_systemck[1].parent_hw = usbck_hw; + at91sam9g45_systemck[2].parent_hw = at91sam9g45_pmc->pchws[0]; + at91sam9g45_systemck[3].parent_hw = at91sam9g45_pmc->pchws[1]; for (i = 0; i < ARRAY_SIZE(at91sam9g45_systemck); i++) { - hw = at91_clk_register_system(regmap, at91sam9g45_systemck[i].n, - at91sam9g45_systemck[i].p, NULL, + hw = at91_clk_register_system(regmap, at91sam9g45_systemck[i].n, NULL, + &AT91_CLK_PD_HW(at91sam9g45_systemck[i].parent_hw), at91sam9g45_systemck[i].id, at91sam9g45_systemck[i].flags); if (IS_ERR(hw)) @@ -214,7 +212,8 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np) for (i = 0; i < ARRAY_SIZE(at91sam9g45_periphck); i++) { hw = at91_clk_register_peripheral(regmap, at91sam9g45_periphck[i].n, - "masterck_div", NULL, + NULL, + &AT91_CLK_PD_HW(at91sam9g45_pmc->chws[PMC_MCK]), at91sam9g45_periphck[i].id); if (IS_ERR(hw)) goto err_free; -- 2.43.0