From patchwork Thu Jun 15 09:32:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 108393 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp511262vqr; Thu, 15 Jun 2023 02:53:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Tq/2n2WpsOf/c2JZ8aTIy3V/RaJEzGpVZq+WbsWFeDPnA+UsfacZ1fe96yZZRpaYylutC X-Received: by 2002:a50:fe98:0:b0:514:9b60:ea65 with SMTP id d24-20020a50fe98000000b005149b60ea65mr6741964edt.16.1686822790941; Thu, 15 Jun 2023 02:53:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686822790; cv=none; d=google.com; s=arc-20160816; b=fYprqi95rRRNPG3NSd/W1LcUVVCzdfXjygLinKwQMq/ifHnuUpbe2EX3jtQcqOld6Y 6sHhEU0+JRr73khaMFPJuZvGIBDI2FNSGMap3NtGg0MbA+5SssFB8EXF0dXjIsFFRq7l v/SsCCRQlWpMRi8KjjFUChQd03B8dfu2m9E5nDdyAiTgW9gWMBAEmqM0EWyTtsP+3KFn 7k88K/kkqu/OCQMnr1Ls/ZglI/yH5JOkD8PiFot04y0in7LzN00CWtYfChFw9fV2OFSQ vNnVp2EzORY7fQxdmcsK88h5gzs6D62em2n170MaQIOb07gPV3mXPcbB/DaBCxxMMYQE 4TDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=m3ahup0gVfpDtox0r084NdeSfxScIUplMigTiLkD3BM=; b=MQ6yn7qOhm/zd9pCt6s8zBVYVhpADlr82SOUDlnfIAN//99LZy3BeM0kL3nc04AvaI 3S6tW/UNV49B2jLo5dweTwh8WOtMKNEeFzpzxoBt0MwP2fKZ9R2mEaAGfGoUy/VSH3D7 IZd8qQ+qnrpON55x2RWQq+bsbW3HmixJJlMWOcz9X7VySSmRnwFL/FLFqjzPBKoZmvvv 4VWqF/yN1BfDYrS0hhfyGnaUuY1jXriOdsnuEZ9vVtmY2XErjaXsCpoGI4Ftn8yPVCBK nknBTCFEKOL2GvaVbzU6aHvc2L6qw6cBcTodohwXyryfcs0Y7c8mqo3uw/nO5eeSN6Q/ nTGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=vkAR01Mw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a6-20020aa7d746000000b005187bd113bcsi2386033eds.354.2023.06.15.02.52.46; Thu, 15 Jun 2023 02:53:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=vkAR01Mw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343490AbjFOJgR (ORCPT + 99 others); Thu, 15 Jun 2023 05:36:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343797AbjFOJfb (ORCPT ); Thu, 15 Jun 2023 05:35:31 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A6842D6B; Thu, 15 Jun 2023 02:35:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1686821703; x=1718357703; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=A1dmJ+pItK/gMLz16UT2MdMrZ6M2X5XJ/pGGBcR7j2U=; b=vkAR01MwNc4zAGttBqiOdHa7liVduxB5cQpheJAbQkm57T6mm6XNjgot Q+uELvs/qXmJ+D5jiNH43QraVo71DhdGYHwt57v+dXn1iMsorWMXu/4H+ GvOa5y5PhhDYbhENqDE2EkFjueoye/3swKUJO9EtrV78/UsLOkRxvoO0a 33oXciWTXYv8fMKBR5pCxA1MSfZgDZlg6j8Ck1rIh3TWr32UwSHditV8u BBCFC3suO0q4nfqX/kaLVK/J93G8Gk0zsgnGMJNm6op/cHDiD3bcq8pIu jDmpcBUTg2MV58+qeTL1IDTJdpMglaKMHMqGOmTJALEq3Soszsnj2zL8n w==; X-IronPort-AV: E=Sophos;i="6.00,244,1681196400"; d="scan'208";a="216166862" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Jun 2023 02:34:31 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) 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.21; Thu, 15 Jun 2023 02:34:20 -0700 Received: from m18063-ThinkPad-T460p.mchp-main.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Thu, 15 Jun 2023 02:34:17 -0700 From: Claudiu Beznea To: , , , , , , CC: , , , Claudiu Beznea Subject: [PATCH 07/11] clk: at91: clk-utmi: add support for parent_hw Date: Thu, 15 Jun 2023 12:32:23 +0300 Message-ID: <20230615093227.576102-8-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230615093227.576102-1-claudiu.beznea@microchip.com> References: <20230615093227.576102-1-claudiu.beznea@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768761894552868492?= X-GMAIL-MSGID: =?utf-8?q?1768761894552868492?= Add support for parent_hw in utmi clock drivers. With this parent-child relation is described with pointers rather than strings making registration a bit faster. All the SoC based drivers that rely on clk-utmi were adapted to the new API change. The switch itself for SoCs will be done in subsequent patches. Signed-off-by: Claudiu Beznea Reviewed-by: Maxime Ripard --- drivers/clk/at91/at91sam9g45.c | 2 +- drivers/clk/at91/at91sam9rl.c | 2 +- drivers/clk/at91/at91sam9x5.c | 2 +- drivers/clk/at91/clk-utmi.c | 24 +++++++++++++++++------- drivers/clk/at91/dt-compat.c | 2 +- drivers/clk/at91/pmc.h | 5 +++-- drivers/clk/at91/sama5d2.c | 2 +- drivers/clk/at91/sama5d3.c | 2 +- drivers/clk/at91/sama5d4.c | 2 +- drivers/clk/at91/sama7g5.c | 2 +- 10 files changed, 28 insertions(+), 17 deletions(-) diff --git a/drivers/clk/at91/at91sam9g45.c b/drivers/clk/at91/at91sam9g45.c index ec2f26c3a80a..f45a7b80f7d8 100644 --- a/drivers/clk/at91/at91sam9g45.c +++ b/drivers/clk/at91/at91sam9g45.c @@ -145,7 +145,7 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np) at91sam9g45_pmc->chws[PMC_PLLACK] = hw; - hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck"); + hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck", NULL); if (IS_ERR(hw)) goto err_free; diff --git a/drivers/clk/at91/at91sam9rl.c b/drivers/clk/at91/at91sam9rl.c index 051b2eeb9276..969f809e7d65 100644 --- a/drivers/clk/at91/at91sam9rl.c +++ b/drivers/clk/at91/at91sam9rl.c @@ -109,7 +109,7 @@ static void __init at91sam9rl_pmc_setup(struct device_node *np) at91sam9rl_pmc->chws[PMC_PLLACK] = hw; - hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck"); + hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck", NULL); if (IS_ERR(hw)) goto err_free; diff --git a/drivers/clk/at91/at91sam9x5.c b/drivers/clk/at91/at91sam9x5.c index e1be2c4c54be..3b801d12fac0 100644 --- a/drivers/clk/at91/at91sam9x5.c +++ b/drivers/clk/at91/at91sam9x5.c @@ -193,7 +193,7 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np, at91sam9x5_pmc->chws[PMC_PLLACK] = hw; - hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck"); + hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck", NULL); if (IS_ERR(hw)) goto err_free; diff --git a/drivers/clk/at91/clk-utmi.c b/drivers/clk/at91/clk-utmi.c index a22c10d9a1b9..40c84f5af5e8 100644 --- a/drivers/clk/at91/clk-utmi.c +++ b/drivers/clk/at91/clk-utmi.c @@ -144,21 +144,30 @@ static struct clk_hw * __init at91_clk_register_utmi_internal(struct regmap *regmap_pmc, struct regmap *regmap_sfr, const char *name, const char *parent_name, + struct clk_hw *parent_hw, const struct clk_ops *ops, unsigned long flags) { struct clk_utmi *utmi; struct clk_hw *hw; - struct clk_init_data init; + struct clk_init_data init = {}; int ret; + if (!(parent_name || parent_hw)) + return ERR_PTR(-EINVAL); + utmi = kzalloc(sizeof(*utmi), GFP_KERNEL); if (!utmi) return ERR_PTR(-ENOMEM); init.name = name; init.ops = ops; - init.parent_names = parent_name ? &parent_name : NULL; - init.num_parents = parent_name ? 1 : 0; + if (parent_hw) { + init.parent_hws = parent_hw ? (const struct clk_hw **)&parent_hw : NULL; + init.num_parents = parent_hw ? 1 : 0; + } else { + init.parent_names = parent_name ? &parent_name : NULL; + init.num_parents = parent_name ? 1 : 0; + } init.flags = flags; utmi->hw.init = &init; @@ -177,10 +186,11 @@ at91_clk_register_utmi_internal(struct regmap *regmap_pmc, struct clk_hw * __init at91_clk_register_utmi(struct regmap *regmap_pmc, struct regmap *regmap_sfr, - const char *name, const char *parent_name) + const char *name, const char *parent_name, + struct clk_hw *parent_hw) { return at91_clk_register_utmi_internal(regmap_pmc, regmap_sfr, name, - parent_name, &utmi_ops, CLK_SET_RATE_GATE); + parent_name, parent_hw, &utmi_ops, CLK_SET_RATE_GATE); } static int clk_utmi_sama7g5_prepare(struct clk_hw *hw) @@ -279,8 +289,8 @@ static const struct clk_ops sama7g5_utmi_ops = { struct clk_hw * __init at91_clk_sama7g5_register_utmi(struct regmap *regmap_pmc, const char *name, - const char *parent_name) + const char *parent_name, struct clk_hw *parent_hw) { return at91_clk_register_utmi_internal(regmap_pmc, NULL, name, - parent_name, &sama7g5_utmi_ops, 0); + parent_name, parent_hw, &sama7g5_utmi_ops, 0); } diff --git a/drivers/clk/at91/dt-compat.c b/drivers/clk/at91/dt-compat.c index e5fcf2e0d235..a32dc2111b90 100644 --- a/drivers/clk/at91/dt-compat.c +++ b/drivers/clk/at91/dt-compat.c @@ -1055,7 +1055,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); + hw = at91_clk_register_utmi(regmap_pmc, regmap_sfr, name, parent_name, NULL); if (IS_ERR(hw)) return; diff --git a/drivers/clk/at91/pmc.h b/drivers/clk/at91/pmc.h index 101e005a9550..8e32be004843 100644 --- a/drivers/clk/at91/pmc.h +++ b/drivers/clk/at91/pmc.h @@ -269,10 +269,11 @@ at91rm9200_clk_register_usb(struct regmap *regmap, const char *name, struct clk_hw * __init at91_clk_register_utmi(struct regmap *regmap_pmc, struct regmap *regmap_sfr, - const char *name, const char *parent_name); + const char *name, const char *parent_name, + struct clk_hw *parent_hw); struct clk_hw * __init at91_clk_sama7g5_register_utmi(struct regmap *regmap, const char *name, - const char *parent_name); + const char *parent_name, struct clk_hw *parent_hw); #endif /* __PMC_H_ */ diff --git a/drivers/clk/at91/sama5d2.c b/drivers/clk/at91/sama5d2.c index c5df06190e1c..c16594fce90c 100644 --- a/drivers/clk/at91/sama5d2.c +++ b/drivers/clk/at91/sama5d2.c @@ -249,7 +249,7 @@ static void __init sama5d2_pmc_setup(struct device_node *np) if (IS_ERR(regmap_sfr)) regmap_sfr = NULL; - hw = at91_clk_register_utmi(regmap, regmap_sfr, "utmick", "mainck"); + hw = at91_clk_register_utmi(regmap, regmap_sfr, "utmick", "mainck", NULL); if (IS_ERR(hw)) goto err_free; diff --git a/drivers/clk/at91/sama5d3.c b/drivers/clk/at91/sama5d3.c index 15fa180a3f58..522ce6031446 100644 --- a/drivers/clk/at91/sama5d3.c +++ b/drivers/clk/at91/sama5d3.c @@ -172,7 +172,7 @@ static void __init sama5d3_pmc_setup(struct device_node *np) sama5d3_pmc->chws[PMC_PLLACK] = hw; - hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck"); + hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck", NULL); if (IS_ERR(hw)) goto err_free; diff --git a/drivers/clk/at91/sama5d4.c b/drivers/clk/at91/sama5d4.c index 2440a34d1d67..160c0bddb6a3 100644 --- a/drivers/clk/at91/sama5d4.c +++ b/drivers/clk/at91/sama5d4.c @@ -187,7 +187,7 @@ static void __init sama5d4_pmc_setup(struct device_node *np) sama5d4_pmc->chws[PMC_PLLACK] = hw; - hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck"); + hw = at91_clk_register_utmi(regmap, NULL, "utmick", "mainck", NULL); if (IS_ERR(hw)) goto err_free; diff --git a/drivers/clk/at91/sama7g5.c b/drivers/clk/at91/sama7g5.c index b606d642a22b..42f2f61cc6d1 100644 --- a/drivers/clk/at91/sama7g5.c +++ b/drivers/clk/at91/sama7g5.c @@ -1035,7 +1035,7 @@ static void __init sama7g5_pmc_setup(struct device_node *np) sama7g5_pmc->chws[sama7g5_mckx[i].eid] = hw; } - hw = at91_clk_sama7g5_register_utmi(regmap, "utmick", "main_xtal"); + hw = at91_clk_sama7g5_register_utmi(regmap, "utmick", "main_xtal", NULL); if (IS_ERR(hw)) goto err_free;