Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4425457rwb; Mon, 31 Jul 2023 06:48:25 -0700 (PDT) X-Google-Smtp-Source: APBJJlG3SiNh8SrfA4fR7WD7pX3sdcXIqgbjZ0i5xjkX1x4LAPXRegkzPGqkWUansB7gzOnkmTmG X-Received: by 2002:a17:906:32c9:b0:99c:c59:2283 with SMTP id k9-20020a17090632c900b0099c0c592283mr4445612ejk.60.1690811304931; Mon, 31 Jul 2023 06:48:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690811304; cv=none; d=google.com; s=arc-20160816; b=KlA8cP9kO7OTHy35fbyZBBWLkkIZE3YYW8RNWLSKDKGyNvb1oo2/OLU/fucyLMD95O yQNvxBnj7ZcJjAVBoRSnPH9jxTDA1eNWndfSbzaS92oFb17CxlmZGFoyDjyJ69FnvT+s LZco1u8cXtMgPGLokv8rfn8UpfrfZt2Ua6RO9Vw+4RkJ+Ff7CETXRvucvGcPaiYrzwzx n83EWePr1B5jAnxC9jgf+po6+u6h0ZvfGvvCI5iEamjXJIA4jiNNy4YkNFbQayfifDmP 9vdEEyE5Yy8fiTXrj6iIQFCcGJBdatg/pZFnjY5tH+GazkHihxUIoUW5cFmYkBEZUnbi KdUQ== 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=0MuOuodU2lHTtwqoFZB85wA0J3lkhz0ajlvILK6N/z0=; fh=jI3Q7yktBjtl2ksHX/9EGqaANb6lEblpacKg3RfzuA8=; b=CgAMG20twJSd32JaFQlvM0XoUblFF4zfRNTlkUpkC6CPD1VFn/TruXN7/ogdVu4/YR DxJzbobJkkukIpgDL5Syc948yJLrYM423EcKKtHXaO6U/+dnL7wN2BJhcBLCkd1if6Y0 3IW3JQB+pEFysyVG0wiPqRxrakkdo5/9UrnAoqc7P7wNtptFgYavDIlkp4PLlwAUVR2J bOusri2VoiqsCT+cyU8Vt0TBUrZTiTjh7nleXfYQzTqK+K9tpXuhhDQKTQ3BGUlb/6su +OSScf0QViR8vmddme86/cXcG8eVt00wgLiAZBPRlPBJwIfemqb6Wgh6U6PBc95tk+o3 VNCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=PFkL76Zs; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p15-20020a1709061b4f00b0099bc29dd540si398090ejg.172.2023.07.31.06.47.59; Mon, 31 Jul 2023 06:48:24 -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=@gmail.com header.s=20221208 header.b=PFkL76Zs; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232370AbjGaMUd (ORCPT + 99 others); Mon, 31 Jul 2023 08:20:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231347AbjGaMUb (ORCPT ); Mon, 31 Jul 2023 08:20:31 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE7211726; Mon, 31 Jul 2023 05:20:15 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-686f090316dso2831459b3a.2; Mon, 31 Jul 2023 05:20:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690806015; x=1691410815; 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=0MuOuodU2lHTtwqoFZB85wA0J3lkhz0ajlvILK6N/z0=; b=PFkL76Zsx0n5eK9oXZnRIgCzWW98xO6+Ly1QmWRcAf8vSsgXZlhcym7nK6RxnluJH2 6u7dBeBiAL37cO5vI76ygeXoW3n67chthsU6rHWzcZ0TLie3j8nvpQcCKudrhiEoBXX0 yEtV35mdXAMj6T/Qs+8WcvhRdK9XW6BieccHJXpw/r9fMirX6E45OHYZ3soTbEcLBudS y7n5owFjWjRrSABj5pkr6va5WcFJfnpu2V9k3m5owbYQIzP1ZdFt2wQpZvMUc6U+JiMd 6lL6vFHIEiPpYyOyIZ4ww3oVZ02a9nnE2DOI0w0eX7BUp3utxsm7sTNrdI3kW8OJeK4p 01kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690806015; x=1691410815; 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=0MuOuodU2lHTtwqoFZB85wA0J3lkhz0ajlvILK6N/z0=; b=kJccbbcHsFhIYv6Lwoul3jgj/Qvgc8S5/yk5MTRKBgyBj6WDbw5H4LNiPd0K2ysLc+ qxbdzUGP8uDbTEj+QL1SPLM3t8zLzC2OZDwJgaYtjjPuL1ZmcxbT5qZFDXwVbCUIzIDP 9fg0rwXjYF4RqQoOMLlVAvjy/Zpq2t+jCxx9tYqmqAstmgCrDGcCEMqTcwY0Ono/wTGk MJf54Ji3IpPyAF2tKOtY4fIa0qpYG5PUg/OVBc1ZulgqYiOcRdKEdP6lO+J7+LqU8IXs b8jpc6Q+09cIzcqiWmcrL8MDsVi3KmXmLKPw34xCHU2QaWc3zv1nYGyFQCcrMDDnpm02 7pVA== X-Gm-Message-State: ABy/qLbb+suYIgsXGNWjHKDEgHQm/maYFjHcKmzc3qOOZYfGbI0K2HLe 9eQWEM39iKttrI20xa6bK7yJpIU1W2oJaH58 X-Received: by 2002:a05:6a21:66cb:b0:13b:77e6:4fad with SMTP id ze11-20020a056a2166cb00b0013b77e64fadmr8388237pzb.59.1690806015167; Mon, 31 Jul 2023 05:20:15 -0700 (PDT) Received: from d.home.yangfl.dn42 ([104.28.245.199]) by smtp.gmail.com with ESMTPSA id y23-20020aa78557000000b00687227dd8f1sm3529559pfn.122.2023.07.31.05.20.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 05:20:14 -0700 (PDT) From: David Yang To: linux-clk@vger.kernel.org Cc: David Yang , Michael Turquette , Stephen Boyd , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linux-kernel@vger.kernel.org Subject: [PATCH v6 05/13] clk: hisilicon: hi3519: Use helper functions Date: Mon, 31 Jul 2023 20:18:05 +0800 Message-Id: <20230731121821.22242-6-mmyangfl@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230731121821.22242-1-mmyangfl@gmail.com> References: <20230731121821.22242-1-mmyangfl@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,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 Use common helper functions and register clks with a single of_device_id data. Signed-off-by: David Yang --- drivers/clk/hisilicon/clk-hi3519.c | 127 ++++------------------------- 1 file changed, 15 insertions(+), 112 deletions(-) diff --git a/drivers/clk/hisilicon/clk-hi3519.c b/drivers/clk/hisilicon/clk-hi3519.c index b871872d9960..cb541de752da 100644 --- a/drivers/clk/hisilicon/clk-hi3519.c +++ b/drivers/clk/hisilicon/clk-hi3519.c @@ -10,7 +10,7 @@ #include #include #include "clk.h" -#include "reset.h" +#include "crg.h" #define HI3519_INNER_CLK_OFFSET 64 #define HI3519_FIXED_24M 65 @@ -73,130 +73,33 @@ static const struct hisi_gate_clock hi3519_gate_clks[] = { CLK_SET_RATE_PARENT, 0xe4, 18, 0, }, }; -static struct hisi_clock_data *hi3519_clk_register(struct platform_device *pdev) -{ - struct hisi_clock_data *clk_data; - int ret; - - clk_data = hisi_clk_alloc(pdev, HI3519_NR_CLKS); - if (!clk_data) - return ERR_PTR(-ENOMEM); - - ret = hisi_clk_register_fixed_rate(hi3519_fixed_rate_clks, - ARRAY_SIZE(hi3519_fixed_rate_clks), - clk_data); - if (ret) - return ERR_PTR(ret); - - ret = hisi_clk_register_mux(hi3519_mux_clks, - ARRAY_SIZE(hi3519_mux_clks), - clk_data); - if (ret) - goto unregister_fixed_rate; - - ret = hisi_clk_register_gate(hi3519_gate_clks, - ARRAY_SIZE(hi3519_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_fixed_rate: - hisi_clk_unregister_fixed_rate(hi3519_fixed_rate_clks, - ARRAY_SIZE(hi3519_fixed_rate_clks), - clk_data); - -unregister_mux: - hisi_clk_unregister_mux(hi3519_mux_clks, - ARRAY_SIZE(hi3519_mux_clks), - clk_data); -unregister_gate: - hisi_clk_unregister_gate(hi3519_gate_clks, - ARRAY_SIZE(hi3519_gate_clks), - clk_data); - return ERR_PTR(ret); -} - -static void hi3519_clk_unregister(struct platform_device *pdev) -{ - struct hi3519_crg_data *crg = platform_get_drvdata(pdev); - - of_clk_del_provider(pdev->dev.of_node); - - hisi_clk_unregister_gate(hi3519_gate_clks, - ARRAY_SIZE(hi3519_mux_clks), - crg->clk_data); - hisi_clk_unregister_mux(hi3519_mux_clks, - ARRAY_SIZE(hi3519_mux_clks), - crg->clk_data); - hisi_clk_unregister_fixed_rate(hi3519_fixed_rate_clks, - ARRAY_SIZE(hi3519_fixed_rate_clks), - crg->clk_data); -} - -static int hi3519_clk_probe(struct platform_device *pdev) -{ - struct hi3519_crg_data *crg; - - crg = devm_kmalloc(&pdev->dev, sizeof(*crg), GFP_KERNEL); - if (!crg) - return -ENOMEM; - - crg->rstc = hisi_reset_init(pdev); - if (!crg->rstc) - return -ENOMEM; - - crg->clk_data = hi3519_clk_register(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 hi3519_clk_remove(struct platform_device *pdev) -{ - struct hi3519_crg_data *crg = platform_get_drvdata(pdev); - - hisi_reset_exit(crg->rstc); - hi3519_clk_unregister(pdev); -} - +static const struct hisi_clocks hi3519_crg_clks = { + .nr = HI3519_NR_CLKS, + .fixed_rate_clks = hi3519_fixed_rate_clks, + .fixed_rate_clks_num = ARRAY_SIZE(hi3519_fixed_rate_clks), + .mux_clks = hi3519_mux_clks, + .mux_clks_num = ARRAY_SIZE(hi3519_mux_clks), + .gate_clks = hi3519_gate_clks, + .gate_clks_num = ARRAY_SIZE(hi3519_gate_clks), +}; static const struct of_device_id hi3519_clk_match_table[] = { - { .compatible = "hisilicon,hi3519-crg" }, + { .compatible = "hisilicon,hi3519-crg", + .data = &hi3519_crg_clks }, { } }; MODULE_DEVICE_TABLE(of, hi3519_clk_match_table); static struct platform_driver hi3519_clk_driver = { - .probe = hi3519_clk_probe, - .remove_new = hi3519_clk_remove, + .probe = hisi_crg_probe, + .remove_new = hisi_crg_remove, .driver = { .name = "hi3519-clk", .of_match_table = hi3519_clk_match_table, }, }; -static int __init hi3519_clk_init(void) -{ - return platform_driver_register(&hi3519_clk_driver); -} -core_initcall(hi3519_clk_init); - -static void __exit hi3519_clk_exit(void) -{ - platform_driver_unregister(&hi3519_clk_driver); -} -module_exit(hi3519_clk_exit); +module_platform_driver(hi3519_clk_driver); MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("HiSilicon Hi3519 Clock Driver"); -- 2.40.1