Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp703192rbb; Sat, 24 Feb 2024 22:56:17 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWxYXPficq0tnyfO8vtHLEP9SbHAbUIxLL2xhSUJr2BnCZiZrVw1ST0gJLUDKx2ql+dv1tXPnuDr7VQM/Dj0zpKs1vOKQWmjsqrg0tEnw== X-Google-Smtp-Source: AGHT+IH/pMAu3x0Ynwdw0OcEPRgh5Hpl/YQQpI8d5AizT0zXyM8XCCyfMXoDDWsXGfvvY/xRyoxY X-Received: by 2002:a05:620a:136c:b0:785:d80e:491b with SMTP id d12-20020a05620a136c00b00785d80e491bmr4599899qkl.43.1708844177035; Sat, 24 Feb 2024 22:56:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708844177; cv=pass; d=google.com; s=arc-20160816; b=Mcl7U6XeNmHXQAxaJIUEmsszJ1y82GMR06MKNPcxPJltgVbcNXOeMESHJQ2ij8jg0+ wZKV0O0y8eqCHiOZcpKCeHtMX8zTFn6UxEGMyG7T6Dv+IlzVcLJNupoh+O2SHrd9mAdn L769mEXo2StBfrXgJA7ANAKwBaJ1HNPQEP9EgVdruRCcqRqaam3OySXDby5GVHI9yqMI IOucrFVrhGQS2WlZX4yaQf3F84LjJDfknZgjtgu1Oke2W1XkNHIEdJQSbFx9Qv1jurFQ d4Yjo7iCtQXwJShdEcycTFOgth4Pzk2ylylDW5k/Mn0AwCIly87C5FARxtSg9DS1gI74 M45w== 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=uzYAusLgHA5dg3wxY39f8O7jqiLmZIOTBnC6DEHE96c=; fh=0vMVr+v6+341+c1EIcMHQ93AQDrgomj/+dwU78q6lpE=; b=Ul/7jPaNL9838aOBy4bNvkEp0PhzOtmlJLU4iiNnSsd4vGivHkMwJv0hpNby82cr7H Jeu+dEFH0+I7ImuARHENGhH/fhz+Lc+CWnt+UVotdd1DwDKnarNk2v/eFftjjZk/QqEv fujOwSvMa7pbD5FtgtCZ+wVuH33XN3ttcjOXhfNOmGeGyQXAeiixAtbeunmz9RYCwB85 qqsQ2un4is8oUHbdRJr9CMfdvjjKR3/xnreDmtT5H37S0zxa6kJ4DNTVIcUGuJuPZO/c Yc/6J7rL3WehuplcVbJmKwmedIlLFdxnvW7kvKdGw1ys7QTGzco1ZOE5xSvODEnWzegy Xibw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=BG1YdPs1; 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-80008-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80008-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id k20-20020a05620a07f400b00787196ecd3fsi2460972qkk.281.2024.02.24.22.56.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 22:56:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80008-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=BG1YdPs1; 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-80008-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80008-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id BAD281C20B6B for ; Sun, 25 Feb 2024 06:56:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3C463FC0A; Sun, 25 Feb 2024 06:54:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BG1YdPs1" Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (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 8E42A175A1; Sun, 25 Feb 2024 06:54:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708844047; cv=none; b=h+XEKdWK0XuBkhR2qUwa3vWoengylGGVwjB2zV/hJI3duo1QgHzxlkb59qMT4ei/5Q4ofD/HcucgNGxqJeYAwB3dD4X9LnE0CL5jcJTbS/2tW7iVl6hgxKSCF7qS9hGSq3AQuw+gGnCkA/JLgvEVV4DK2gsXVl1P6W5B3jmcCH8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708844047; c=relaxed/simple; bh=4hA8+z3f2ldZmeSXUpUNrydWtdec93hvgrr/De9O8Tg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uzIzDaTAe8oaL+4KWSvRu9DRemmsMuGkHfR+Xar5pLPZ3id94Q2joiu7LrOVVFGgC+rn4bgDpaqsXiLvqjq7Hztyogu+prBkboiV/OBzVDUDeFtH57QWiKBTZHF02jbl64ppUJdjo6MFw9TSieaUbW24o+9RfdUp+PpMxQVN310= 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=BG1YdPs1; arc=none smtp.client-ip=209.85.210.178 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-pf1-f178.google.com with SMTP id d2e1a72fcca58-6e0f803d9dfso1427256b3a.0; Sat, 24 Feb 2024 22:54:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708844044; x=1709448844; 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=uzYAusLgHA5dg3wxY39f8O7jqiLmZIOTBnC6DEHE96c=; b=BG1YdPs1LPmTGKwDBPNBLR150b0CToNfjlnLFaYDgz5io0KBdAbvd1OZpLYXDNmDNW q/q8V2gm1bi1UwlGpw4mvW3vgXcqw2RzZZSGZCR54AFWsBRwAcCRRPHW8ogNABzOfGPy 7zH67UDIkaE+FQvrTM7vib5DA/9L8wVKFkSgy7hQ7tFPvPLlYAx1AlDbyGnp9Pu/nSjT mF9cMzfqLjgzR5uNc2ebr5MUNSA5HYB25H/IMkZAci0i9e8h7PhGmPMwwBWheM9zNaNx END4b28/ap8MMHzZ/PTk7aEe32w/7bNOY1z18U5fTvpnIgWf7cXEbleOIpWzAYgau/O4 gSpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708844044; x=1709448844; 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=uzYAusLgHA5dg3wxY39f8O7jqiLmZIOTBnC6DEHE96c=; b=O0ElsO2Y3fHLep1Pexpe6hmoE7qiUqv6YcAosH1MBKRbj4m+7jt7LqylPb/oqs7OQi B2QISLHswM15+e7q/0NHCytIKuP3NTfS6BVreePFqERSmTpvLLi4N8YJgmxkLFLm/epU xTFTZYw2JYd1HyvaEK+CqCgIbG5mSg/8X9iS68+bamK5nIccxDI1vRVvt/bILJngI8ym 4TE9mXVqj+/lhjbrslQNhZhGty7yRxvLBD0LnD4/VhYBmoBNjeLTY3NKdRlFp2pMYKSj o06OMepEdFUIFiGzCPhhmgRe0Bc1OVsQTGM9Oa3vg0wcmf4wfFRaEtBuLZe5bqTr8P4O 8S1A== X-Forwarded-Encrypted: i=1; AJvYcCXPW9oBbeKPeKT+ruMhpkOBqk9c53K+Cym5GAtKx1SQRMHCfNdokm5cTVUfnlM+RqS/6xoEizsXJU3Oq0z3WfmgQybia1rA1U4gJySX X-Gm-Message-State: AOJu0YzYzap0diAlBekUA9dD2zOYyz1Mof8RbjUjD0ZszDjdCWtD8uxp +rDJzUNzUShbDqDDV5OGcgI7gjmVw4nnIZHsiW4FH0ciWVuLVRldBRK7gWYq+M5nMg== X-Received: by 2002:a05:6a00:178b:b0:6e4:fe2c:d766 with SMTP id s11-20020a056a00178b00b006e4fe2cd766mr3404010pfg.17.1708844044594; Sat, 24 Feb 2024 22:54:04 -0800 (PST) Received: from localhost.localdomain ([171.218.176.26]) by smtp.gmail.com with ESMTPSA id p18-20020a056a0026d200b006e45b910a98sm1930313pfw.6.2024.02.24.22.54.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 22:54:04 -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 12/13] clk: hisilicon: hix5hd2: Convert into platform driver module Date: Sun, 25 Feb 2024 14:52:27 +0800 Message-ID: <20240225065234.413687-13-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/clk-hix5hd2.c | 85 ++++++++++++++++++----------- 1 file changed, 52 insertions(+), 33 deletions(-) diff --git a/drivers/clk/hisilicon/clk-hix5hd2.c b/drivers/clk/hisilicon/clk-hix5hd2.c index 64bdd3f05725..0a3f1320d0d5 100644 --- a/drivers/clk/hisilicon/clk-hix5hd2.c +++ b/drivers/clk/hisilicon/clk-hix5hd2.c @@ -4,13 +4,17 @@ * Copyright (c) 2014 Hisilicon Limited. */ -#include #include + #include #include +#include +#include +#include + #include "clk.h" -static struct hisi_fixed_rate_clock hix5hd2_fixed_rate_clks[] __initdata = { +static struct hisi_fixed_rate_clock hix5hd2_fixed_rate_clks[] = { { HIX5HD2_FIXED_1200M, "1200m", NULL, 0, 1200000000, }, { HIX5HD2_FIXED_400M, "400m", NULL, 0, 400000000, }, { HIX5HD2_FIXED_48M, "48m", NULL, 0, 48000000, }, @@ -43,19 +47,19 @@ static struct hisi_fixed_rate_clock hix5hd2_fixed_rate_clks[] __initdata = { { HIX5HD2_FIXED_83M, "83m", NULL, 0, 83333333, }, }; -static const char *const sfc_mux_p[] __initconst = { +static const char *const sfc_mux_p[] = { "24m", "150m", "200m", "100m", "75m", }; static u32 sfc_mux_table[] = {0, 4, 5, 6, 7}; -static const char *const sdio_mux_p[] __initconst = { +static const char *const sdio_mux_p[] = { "75m", "100m", "50m", "15m", }; static u32 sdio_mux_table[] = {0, 1, 2, 3}; -static const char *const fephy_mux_p[] __initconst = { "25m", "125m"}; +static const char *const fephy_mux_p[] = { "25m", "125m"}; static u32 fephy_mux_table[] = {0, 1}; -static struct hisi_mux_clock hix5hd2_mux_clks[] __initdata = { +static struct hisi_mux_clock hix5hd2_mux_clks[] = { { HIX5HD2_SFC_MUX, "sfc_mux", sfc_mux_p, ARRAY_SIZE(sfc_mux_p), CLK_SET_RATE_PARENT, 0x5c, 8, 3, 0, sfc_mux_table, }, { HIX5HD2_MMC_MUX, "mmc_mux", sdio_mux_p, ARRAY_SIZE(sdio_mux_p), @@ -67,7 +71,7 @@ static struct hisi_mux_clock hix5hd2_mux_clks[] __initdata = { CLK_SET_RATE_PARENT, 0x120, 8, 2, 0, fephy_mux_table, }, }; -static struct hisi_gate_clock hix5hd2_gate_clks[] __initdata = { +static struct hisi_gate_clock hix5hd2_gate_clks[] = { /* sfc */ { HIX5HD2_SFC_CLK, "clk_sfc", "sfc_mux", CLK_SET_RATE_PARENT, 0x5c, 0, 0, }, @@ -153,7 +157,7 @@ struct hix5hd2_clk_complex { u32 phy_rst_mask; }; -static struct hix5hd2_complex_clock hix5hd2_complex_clks[] __initdata = { +static struct hix5hd2_complex_clock hix5hd2_complex_clks[] = { {"clk_mac0", "clk_fephy", HIX5HD2_MAC0_CLK, 0xcc, 0xa, 0x500, 0x120, 0, 0x10, TYPE_ETHER}, {"clk_mac1", "clk_fwd_sys", HIX5HD2_MAC1_CLK, @@ -249,21 +253,22 @@ static const struct clk_ops clk_complex_ops = { .disable = clk_complex_disable, }; -static void __init -hix5hd2_clk_register_complex(struct hix5hd2_complex_clock *clks, int nums, +static int +hix5hd2_clk_register_complex(struct device *dev, const void *clocks, size_t num, struct hisi_clock_data *data) { + const struct hix5hd2_complex_clock *clks = clocks; void __iomem *base = data->base; int i; - for (i = 0; i < nums; i++) { + for (i = 0; i < num; i++) { struct hix5hd2_clk_complex *p_clk; struct clk *clk; struct clk_init_data init; p_clk = kzalloc(sizeof(*p_clk), GFP_KERNEL); if (!p_clk) - return; + return -ENOMEM; init.name = clks[i].name; if (clks[i].type == TYPE_ETHER) @@ -289,31 +294,45 @@ hix5hd2_clk_register_complex(struct hix5hd2_complex_clock *clks, int nums, kfree(p_clk); pr_err("%s: failed to register clock %s\n", __func__, clks[i].name); - continue; + return PTR_ERR(p_clk); } data->clk_data.clks[clks[i].id] = clk; } -} -static void __init hix5hd2_clk_init(struct device_node *np) -{ - struct hisi_clock_data *clk_data; - - clk_data = hisi_clk_init(np, HIX5HD2_NR_CLKS); - if (!clk_data) - return; - - hisi_clk_register_fixed_rate(hix5hd2_fixed_rate_clks, - ARRAY_SIZE(hix5hd2_fixed_rate_clks), - clk_data); - hisi_clk_register_mux(hix5hd2_mux_clks, ARRAY_SIZE(hix5hd2_mux_clks), - clk_data); - hisi_clk_register_gate(hix5hd2_gate_clks, - ARRAY_SIZE(hix5hd2_gate_clks), clk_data); - hix5hd2_clk_register_complex(hix5hd2_complex_clks, - ARRAY_SIZE(hix5hd2_complex_clks), - clk_data); + return 0; } -CLK_OF_DECLARE(hix5hd2_clk, "hisilicon,hix5hd2-clock", hix5hd2_clk_init); +static const struct hisi_clocks hix5hd2_clks = { + .nr = HIX5HD2_NR_CLKS, + .fixed_rate_clks = hix5hd2_fixed_rate_clks, + .fixed_factor_clks_num = ARRAY_SIZE(hix5hd2_fixed_rate_clks), + .mux_clks = hix5hd2_mux_clks, + .mux_clks_num = ARRAY_SIZE(hix5hd2_mux_clks), + .gate_clks = hix5hd2_gate_clks, + .gate_clks_num = ARRAY_SIZE(hix5hd2_gate_clks), + .customized_clks = hix5hd2_complex_clks, + .customized_clks_num = ARRAY_SIZE(hix5hd2_complex_clks), + .clk_register_customized = hix5hd2_clk_register_complex, +}; + +static const struct of_device_id hix5hd2_clk_match_table[] = { + { .compatible = "hisilicon,hix5hd2-clock", + .data = &hix5hd2_clks }, + { } +}; +MODULE_DEVICE_TABLE(of, hix5hd2_clk_match_table); + +static struct platform_driver hix5hd2_clk_driver = { + .probe = hisi_clk_probe, + .remove_new = hisi_clk_remove, + .driver = { + .name = "hix5hd2-clock", + .of_match_table = hix5hd2_clk_match_table, + }, +}; + +module_platform_driver(hix5hd2_clk_driver); + +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("HiSilicon Hix5hd2 Clock Driver"); -- 2.43.0