Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp702730rbb; Sat, 24 Feb 2024 22:54:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVRsmvOv97+Sxb9xv3NKFnE80YcMszL/T1/ZW6ZtO64O/P1cqj8MVqYf3WD4i9G/WA4BtEbs2YiUDBRjbDPnUM+BcAs5Mu3MxPEUdhIiQ== X-Google-Smtp-Source: AGHT+IHZsFbfyHGKHlExUxi0UuBGredQyqRevZkx5aFhxWqsKhHBeLQFIDhr4ALPNT1ZBQKCKRPY X-Received: by 2002:a05:6808:3c87:b0:3c1:9f47:171 with SMTP id gs7-20020a0568083c8700b003c19f470171mr201688oib.12.1708844042360; Sat, 24 Feb 2024 22:54:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708844042; cv=pass; d=google.com; s=arc-20160816; b=O1ScMzqXXqu2tqp4pmb0nnZsreDx3Nt1Y9ciQMIqg0QC3qMBaL5jPCMfTJEJDqxLp0 kUaIO1A/eWpJqcInFHHhTjOsHy+0eqzvLEYyLhLZCCJXjZE52Fsi3NfktHH5wDBxMLTy ZdWF8gULwscJP9vmQu055fXh27RSXGY+lsLkTw4JwvmSVMiedBcMl+1dCHzNGlHMADgf /n8a0NT5o44TfdB2cLECQfCb21+VGgNP3SqYc8ZA+OJuucr596ceIEVUjd+LFB6IC15t mkaNLWiXhMY33uAUve6F5KSleh4py2ZSjaOMLckUi2pVxW5isu/RE0Z2zOceC+6QUsNd C23g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=NNeTl78vZFNcKOErgWglz32ctBFQT/HCoAapAxi94qA=; fh=EKSOPSpU/8T+UiX8Bx23wrEEI60OCosWr3WDoxh0ToI=; b=loRV5w/9UpB04VUSEnJ+zgZeIhQZci58Kbb2iUWDeLfTIJMuZ4M3lLDiGYF72NU+n1 w0fl5xF1VWvyncKRdF+bZ/uNNRXuGJ4Jc3PDK6sSANLWnmSVhLwZPdgNjskJlMz0QFOo w1WD4DLJjb6JruLJPyX/4ckzF5ZaX60JLV9ZMypsxJREwkSn9Cv4xKVMrpAc3imRl8iE nEcJEzHstOVZ4omCU6PlHDXvp9kvXSjwnHs+NN1TGfzjddAJJMRb85noBIXk9AGuHEyC bKLkFDekv2Fr4J3TgcsoZRknQUs3zcRprtjytWpxGWXJL5yu8KxMCwgMrY8Uxg4+/K+h MGgA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UOkIWKVS; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-79998-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79998-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id m10-20020a056a00080a00b006e50d5486f6si329662pfk.94.2024.02.24.22.54.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 22:54:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79998-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UOkIWKVS; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-79998-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79998-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id F3EC2B2125E for ; Sun, 25 Feb 2024 06:53:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9F1BFEEDC; Sun, 25 Feb 2024 06:53:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UOkIWKVS" Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC4CEE55F; Sun, 25 Feb 2024 06:53:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708844004; cv=none; b=BFyh7KMRcs+z308EWz4kd6RZ17RD3tPvR3osBueyk4iNCrIGSr0objy8BD+gpGHmPes15tDYjHt4Ti3Gee0eR7EGtGQF5wMFXZrxj2/Cvxojry5Z1Lpb3mK81eCNPMkPlOD36dnrn1pa6grScK2Zs/mojiQCoQ9CBxIu3bC03Zw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708844004; c=relaxed/simple; bh=T6lQiVWmytZHVQJAW4xa+ziFT/0SMHSrOAt1hAa7bSA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JtVzbJ3IS7FUbX/qoHDuaav7DlA3uVQRyqz3OAEpGhyt8TGh3sss20m/n80OHFcSR5z0Tfw14rTzlSUW6FMWNx2lp4tp29/2+s5z7kLLL9rD1CMTTQi5MW7izrTGOkKSeTvNizwMRd8V2qd+pIYhcItPhOTzoOH8i9D6hZmMH3U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UOkIWKVS; arc=none smtp.client-ip=209.85.210.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-6e445b4f80bso1125232a34.0; Sat, 24 Feb 2024 22:53:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708844002; x=1709448802; darn=vger.kernel.org; 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=NNeTl78vZFNcKOErgWglz32ctBFQT/HCoAapAxi94qA=; b=UOkIWKVSRP+dZWcbzkPwepnMBD6j3h2aA4iOb8Qc9niZMLpw8mAP6jN19Vw86LvWcK vrmW70aiBb3hHD6d47YdF8N6grWRuRZ1qvl5RI7fzac2KSu9pkP/oJP5yv+8lG2i4OpH C6rAGBIz/FF9pkSjwN0tlUNKWBZRnNZLYLMGVTfkBcQkISf0GHIq3Ojd/kIPtLIRfe65 kLdGW8hsy0QkWtUcV2WLkEmN5n/XLcqhgMzk2AJt0dZeLfgf7RXGtC2wqdezp4CH9OJb oV56VcHlV0eyb4x1QL2VA1ncWQKy20n1T+pbEp2y1jMeeaVkYrN4s6w8fAT7qTmi/Z85 Zc1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708844002; x=1709448802; 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=NNeTl78vZFNcKOErgWglz32ctBFQT/HCoAapAxi94qA=; b=M6BPalDAFH+IgxsvSgfocikoabxvDCt78tbn5aerN0+Ob3VPGjGglJ5h6ReI4vOFcR iMdTUWOJ+vlvOwo9Aw9i/xUqWhHOs8JBaDQBeg4Q+tHvPX5Sziv9nES50Lzm1YtSEHe5 vk9+Qly1rzaQzrikS/BgnR8j9IX+8ODvw38tbf7dTWGZvD6yY3YM55UGC5jx7RN4dPmv s1jt2h2FcIRES5F+Czt6DshsN7TKzJGce54UJiRHICfjCsuwBHYm4snLtg5KFRX+N/nn M+lZ4XEnlJ7rdmSSkJm0BXyh6rwAToK/JBD7v7GwRHKQHN5IUsnQX44hJEI7gq85HS5T w6bQ== X-Forwarded-Encrypted: i=1; AJvYcCUM46gWy2OtMGQXVCkq2r5WtAJPh44CAflPtc6sNBcOP8F6PScCBHngajV8efks3QDKbhi8b+gH77cR3V+hb0WXisVIefMjx5AlIcDq X-Gm-Message-State: AOJu0YwvxfyRHouqTtEovJ/o/0Xpo/Iv+DewUiXTuHbqm9JEgTZrlb5i 4umoORR6nRxna7HULSmV43Ip20q9p4P5zhyPyf+EhbEgU8IHv99YBfdrDV0k4kYiBQ== X-Received: by 2002:a05:6830:1645:b0:6e4:6526:e207 with SMTP id h5-20020a056830164500b006e46526e207mr4585831otr.36.1708844001894; Sat, 24 Feb 2024 22:53:21 -0800 (PST) Received: from localhost.localdomain ([171.218.176.26]) by smtp.gmail.com with ESMTPSA id p18-20020a056a0026d200b006e45b910a98sm1930313pfw.6.2024.02.24.22.53.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 22:53:21 -0800 (PST) From: David Yang To: linux-clk@vger.kernel.org Cc: Yang Xiwen , David Yang , Michael Turquette , Stephen Boyd , linux-kernel@vger.kernel.org Subject: [PATCH v7 02/13] clk: hisilicon: hi3516cv300: Use helper functions Date: Sun, 25 Feb 2024 14:52:17 +0800 Message-ID: <20240225065234.413687-3-mmyangfl@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240225065234.413687-1-mmyangfl@gmail.com> References: <20240225065234.413687-1-mmyangfl@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Use common helper functions and register clks with a single of_device_id data. Signed-off-by: David Yang --- drivers/clk/hisilicon/crg-hi3516cv300.c | 171 +++--------------------- 1 file changed, 17 insertions(+), 154 deletions(-) diff --git a/drivers/clk/hisilicon/crg-hi3516cv300.c b/drivers/clk/hisilicon/crg-hi3516cv300.c index e602e65fbc38..0e6b95d00c68 100644 --- a/drivers/clk/hisilicon/crg-hi3516cv300.c +++ b/drivers/clk/hisilicon/crg-hi3516cv300.c @@ -12,7 +12,6 @@ #include #include "clk.h" #include "crg.h" -#include "reset.h" /* hi3516CV300 core CRG */ #define HI3516CV300_INNER_CLK_OFFSET 64 @@ -126,67 +125,14 @@ static const struct hisi_gate_clock hi3516cv300_gate_clks[] = { { HI3516CV300_USB2_PHY_CLK, "clk_usb2_phy", NULL, 0, 0xb8, 7, 0, }, }; -static struct hisi_clock_data *hi3516cv300_clk_register( - struct platform_device *pdev) -{ - struct hisi_clock_data *clk_data; - int ret; - - clk_data = hisi_clk_alloc(pdev, HI3516CV300_CRG_NR_CLKS); - if (!clk_data) - return ERR_PTR(-ENOMEM); - - ret = hisi_clk_register_fixed_rate(hi3516cv300_fixed_rate_clks, - ARRAY_SIZE(hi3516cv300_fixed_rate_clks), clk_data); - if (ret) - return ERR_PTR(ret); - - ret = hisi_clk_register_mux(hi3516cv300_mux_clks, - ARRAY_SIZE(hi3516cv300_mux_clks), clk_data); - if (ret) - goto unregister_fixed_rate; - - ret = hisi_clk_register_gate(hi3516cv300_gate_clks, - ARRAY_SIZE(hi3516cv300_gate_clks), clk_data); - if (ret) - goto unregister_mux; - - ret = of_clk_add_provider(pdev->dev.of_node, - of_clk_src_onecell_get, &clk_data->clk_data); - if (ret) - goto unregister_gate; - - return clk_data; - -unregister_gate: - hisi_clk_unregister_gate(hi3516cv300_gate_clks, - ARRAY_SIZE(hi3516cv300_gate_clks), clk_data); -unregister_mux: - hisi_clk_unregister_mux(hi3516cv300_mux_clks, - ARRAY_SIZE(hi3516cv300_mux_clks), clk_data); -unregister_fixed_rate: - hisi_clk_unregister_fixed_rate(hi3516cv300_fixed_rate_clks, - ARRAY_SIZE(hi3516cv300_fixed_rate_clks), clk_data); - return ERR_PTR(ret); -} - -static void hi3516cv300_clk_unregister(struct platform_device *pdev) -{ - struct hisi_crg_dev *crg = platform_get_drvdata(pdev); - - of_clk_del_provider(pdev->dev.of_node); - - hisi_clk_unregister_gate(hi3516cv300_gate_clks, - ARRAY_SIZE(hi3516cv300_gate_clks), crg->clk_data); - hisi_clk_unregister_mux(hi3516cv300_mux_clks, - ARRAY_SIZE(hi3516cv300_mux_clks), crg->clk_data); - hisi_clk_unregister_fixed_rate(hi3516cv300_fixed_rate_clks, - ARRAY_SIZE(hi3516cv300_fixed_rate_clks), crg->clk_data); -} - -static const struct hisi_crg_funcs hi3516cv300_crg_funcs = { - .register_clks = hi3516cv300_clk_register, - .unregister_clks = hi3516cv300_clk_unregister, +static const struct hisi_clocks hi3516cv300_crg_clks = { + .nr = HI3516CV300_CRG_NR_CLKS, + .fixed_rate_clks = hi3516cv300_fixed_rate_clks, + .fixed_rate_clks_num = ARRAY_SIZE(hi3516cv300_fixed_rate_clks), + .mux_clks = hi3516cv300_mux_clks, + .mux_clks_num = ARRAY_SIZE(hi3516cv300_mux_clks), + .gate_clks = hi3516cv300_gate_clks, + .gate_clks_num = ARRAY_SIZE(hi3516cv300_gate_clks), }; /* hi3516CV300 sysctrl CRG */ @@ -200,118 +146,35 @@ static const struct hisi_mux_clock hi3516cv300_sysctrl_mux_clks[] = { CLK_SET_RATE_PARENT, 0x0, 23, 1, 0, wdt_mux_table, }, }; -static struct hisi_clock_data *hi3516cv300_sysctrl_clk_register( - struct platform_device *pdev) -{ - struct hisi_clock_data *clk_data; - int ret; - - clk_data = hisi_clk_alloc(pdev, HI3516CV300_SYSCTRL_NR_CLKS); - if (!clk_data) - return ERR_PTR(-ENOMEM); - - ret = hisi_clk_register_mux(hi3516cv300_sysctrl_mux_clks, - ARRAY_SIZE(hi3516cv300_sysctrl_mux_clks), clk_data); - if (ret) - return ERR_PTR(ret); - - - ret = of_clk_add_provider(pdev->dev.of_node, - of_clk_src_onecell_get, &clk_data->clk_data); - if (ret) - goto unregister_mux; - - return clk_data; - -unregister_mux: - hisi_clk_unregister_mux(hi3516cv300_sysctrl_mux_clks, - ARRAY_SIZE(hi3516cv300_sysctrl_mux_clks), clk_data); - return ERR_PTR(ret); -} - -static void hi3516cv300_sysctrl_clk_unregister(struct platform_device *pdev) -{ - struct hisi_crg_dev *crg = platform_get_drvdata(pdev); - - of_clk_del_provider(pdev->dev.of_node); - - hisi_clk_unregister_mux(hi3516cv300_sysctrl_mux_clks, - ARRAY_SIZE(hi3516cv300_sysctrl_mux_clks), - crg->clk_data); -} - -static const struct hisi_crg_funcs hi3516cv300_sysctrl_funcs = { - .register_clks = hi3516cv300_sysctrl_clk_register, - .unregister_clks = hi3516cv300_sysctrl_clk_unregister, +static const struct hisi_clocks hi3516cv300_sysctrl_clks = { + .nr = HI3516CV300_SYSCTRL_NR_CLKS, + .mux_clks = hi3516cv300_sysctrl_mux_clks, + .mux_clks_num = ARRAY_SIZE(hi3516cv300_sysctrl_mux_clks), }; static const struct of_device_id hi3516cv300_crg_match_table[] = { { .compatible = "hisilicon,hi3516cv300-crg", - .data = &hi3516cv300_crg_funcs + .data = &hi3516cv300_crg_clks, }, { .compatible = "hisilicon,hi3516cv300-sysctrl", - .data = &hi3516cv300_sysctrl_funcs + .data = &hi3516cv300_sysctrl_clks, }, { } }; MODULE_DEVICE_TABLE(of, hi3516cv300_crg_match_table); -static int hi3516cv300_crg_probe(struct platform_device *pdev) -{ - struct hisi_crg_dev *crg; - - crg = devm_kmalloc(&pdev->dev, sizeof(*crg), GFP_KERNEL); - if (!crg) - return -ENOMEM; - - crg->funcs = of_device_get_match_data(&pdev->dev); - if (!crg->funcs) - return -ENOENT; - - crg->rstc = hisi_reset_init(pdev); - if (!crg->rstc) - return -ENOMEM; - - crg->clk_data = crg->funcs->register_clks(pdev); - if (IS_ERR(crg->clk_data)) { - hisi_reset_exit(crg->rstc); - return PTR_ERR(crg->clk_data); - } - - platform_set_drvdata(pdev, crg); - return 0; -} - -static void hi3516cv300_crg_remove(struct platform_device *pdev) -{ - struct hisi_crg_dev *crg = platform_get_drvdata(pdev); - - hisi_reset_exit(crg->rstc); - crg->funcs->unregister_clks(pdev); -} - static struct platform_driver hi3516cv300_crg_driver = { - .probe = hi3516cv300_crg_probe, - .remove_new = hi3516cv300_crg_remove, + .probe = hisi_crg_probe, + .remove_new = hisi_crg_remove, .driver = { .name = "hi3516cv300-crg", .of_match_table = hi3516cv300_crg_match_table, }, }; -static int __init hi3516cv300_crg_init(void) -{ - return platform_driver_register(&hi3516cv300_crg_driver); -} -core_initcall(hi3516cv300_crg_init); - -static void __exit hi3516cv300_crg_exit(void) -{ - platform_driver_unregister(&hi3516cv300_crg_driver); -} -module_exit(hi3516cv300_crg_exit); +module_platform_driver(hi3516cv300_crg_driver); MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("HiSilicon Hi3516CV300 CRG Driver"); -- 2.43.0