Received: by 2002:ab2:7407:0:b0:1f4:b336:87c4 with SMTP id e7csp230731lqn; Thu, 11 Apr 2024 22:14:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWxQ6EBNsPjGrJK6Xiv/kfOxuhwy7uaOh6DH6cwMnCTtv26YBaeEyXW5oxUdIqPUmer05T8sdZbuya2/VTiA7rlBGa2zBnDafzeOABOdg== X-Google-Smtp-Source: AGHT+IGRjiMT4pXpBDBfrY2MLtQEafoAp0sJALxXlSseXJruHFyX8nDxPc5r0wvm+sBu78VRXjL2 X-Received: by 2002:a05:6a21:620:b0:1a9:22b7:543c with SMTP id ll32-20020a056a21062000b001a922b7543cmr2013398pzb.8.1712898876170; Thu, 11 Apr 2024 22:14:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712898876; cv=pass; d=google.com; s=arc-20160816; b=vyqsgHlma6Ho02oNBMUfSNAJimVqhrFLCpBWzGgmEtS4cGem5/c9rPo1ba/TfiVeHF 41VEsfV/NwfYTtx1N+NQwG9HfSfZZcDC35xq/6Skq4170A05c/J5V2YUqdWxpukAEoUt r+RyE+cJAUlM7TzwfmJCSG2v/Ekl+l+NpLJySTKYyIHmQlEjp3dCW3D9H+snNojw8hnz rSOO7ZlXse64uMP5uw64jtV3gDSXJZpeb17Zk6FZi/lQA8dYtnF6vofrINh2bHEYRHjY wRR+zM5iz7YoavuwaJE2OOWucDjH2/MBmhgHnTppqKeTawaGx0iM6jNfsSiJCLcnPQgV 9Dog== 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=sev+/38n+L4/gBDdcjwcInqWDszvd46uXbGtRmwLbIY=; b=NfZHz/iql16JmLEpeQLMNEggUkpUXMsENoC+nQrJJVybA+1KvxLHOaAPrJHyQqr8Q1 Ew72zpfd/hkeVD3DNEsehNOl0q0hdGqSpF13o/owe3x1PNlFXsONv5poTiWBnvm71oiW QvGCVmTn4tbYVvoLLmCEkULbyw3RUMHf25O1K/jMIKSoDzykUx4pHRrlYtPsHP0ETWRn JGJiOe//0NR+eUGZS95cXbFn4sBgB4s5/Q4jmJ50sp1NKy26T2CTLJcKy4hNs/RQ5Ohn gZlEbjggchtS1gGlsnR6zec7llQTmTPiIWRXi9w3FQWMUaJrZat0WuWltezlidjJADUK Hu6Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="Zm5D3u/u"; 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-141965-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141965-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id p13-20020a17090a348d00b002a5f9c7272asi2559315pjb.105.2024.04.11.22.14.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 22:14:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-141965-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="Zm5D3u/u"; 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-141965-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141965-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id D260328203E for ; Fri, 12 Apr 2024 05:14:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CCC3947F7A; Fri, 12 Apr 2024 05:12:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Zm5D3u/u" Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (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 4FDC94CB35; Fri, 12 Apr 2024 05:12:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712898742; cv=none; b=LhZSvAxIdcSwirOgkumVAd/4QkLKVTV/j1kynUXJ261RAcdRyVQ/nuyFEs5TF1bIJ3nPGN7vbr31j0C5ZtDmsuSOUjeHzyexsXfdKyX3GTCPerxpCXmeule7wiKH91i42+3c4szqaUn+BqXxIT7vUah4kh4RQB53dTVY/kjPmyU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712898742; c=relaxed/simple; bh=4hA8+z3f2ldZmeSXUpUNrydWtdec93hvgrr/De9O8Tg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iNhsr0QHG6ZkJoNPkF2TEFQw18F8NKo57K9rsrjGYVh58msym5MnO3VOTbK7J7OXV1BRKGF8IIDw+gf3/eRReFbNd4AwqTL7aonQWElhRkMpQCsXTf7NKutI1hUEpI08+ghMi5z474nYbq5abdnq1nB/2c38lfcRFXaKBpQMhnc= 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=Zm5D3u/u; arc=none smtp.client-ip=209.85.216.54 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-pj1-f54.google.com with SMTP id 98e67ed59e1d1-2a6ff4f91cbso90246a91.0; Thu, 11 Apr 2024 22:12:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712898740; x=1713503540; 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=Zm5D3u/ubBllrtfprwvTRUqNq7807em/UFt8CdWapymvrhyHaaKJEzfXaFbHU3uPRA 80mIvxy3iWvgHhGS12NtidOT82WnY6WGKeJMMAa3wxdVSDoy9jY4PZsFTWOmCZhxMJou a7TZczwsWzFdwPcPzBg2UHOffh7Nfi2iyZiTGfcKzcMt+JwdU/WT8CiUY5/Kty0ToBs7 47T3e5GeDlHXZsgyIsMEwBahH9Z+GYhMdn0lWtEt3SvnXX4QL/s9hF0Sm6YTuxyBLg/+ 2UzO5qRmZG2OedVW6c9ZCoRGFUK1X1Rf3nclZcbLG9nPM91PWW6YfMMPk1jcKipJybMI fymA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712898740; x=1713503540; 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=r7eYET3uZ3qe+Ga1NhLH5sGH2wObiahspHchmiz2RfNdz6TitS4VSA2ob0UlGGLUQX nPJtQHxY3VvDO4jns/gd6Z5TL17GkGmgf2/HL8azX8rmAiA2FsG9E7hIuRlO6hhMK1JE TE3iBTmTEXFKFTHXG1Kn6GoJiUGewdvlZCy/HQHlU65M6Yu3CFFi30hsCh/+Msv47k3O NK4aTK4BQuly9wncoO0h1xdzqK73XmzpMZXw7e8a++Wxeq/XsMboS9rGbYMUp+iGUPe1 nX5G/FHOLla2pCmgUtKeDfuLEJ9GtHW2bnJdozyksLSixpgBzNISDdti88AAsh38mC/4 cZvw== X-Forwarded-Encrypted: i=1; AJvYcCW6hLiaxyM/t0Fw53X2YIFA2Gj3sd+gXIOiXnNA28kf6uRq+T81j5Xk1wowJDUQe2vnTI6YJhmKLpAT2xLCx7cdWws1nwRSyRc+cirm X-Gm-Message-State: AOJu0Yy2TUGsk/Bg3NROdvsenKDmNyc4ScVqIlGocQoymGTspiDCNet9 OARVhPu5a4VhjwyM2Ce9s+1AhY1LfSt2BVFgsmPgYRxMn8a3f9AkEYGurO8n X-Received: by 2002:a17:90a:e7c1:b0:2a6:fbf5:6d8b with SMTP id kb1-20020a17090ae7c100b002a6fbf56d8bmr396006pjb.3.1712898740269; Thu, 11 Apr 2024 22:12:20 -0700 (PDT) Received: from d.home.yangfl.dn42 ([104.28.213.200]) by smtp.gmail.com with ESMTPSA id fh16-20020a17090b035000b002a53b9cf356sm3734902pjb.0.2024.04.11.22.12.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 22:12:19 -0700 (PDT) From: David Yang To: linux-clk@vger.kernel.org Cc: Michael Turquette , Stephen Boyd , linux-kernel@vger.kernel.org, David Yang Subject: [PATCH v9 12/13] clk: hisilicon: hix5hd2: Convert into platform driver module Date: Fri, 12 Apr 2024 13:10:41 +0800 Message-ID: <20240412051041.90376-14-mmyangfl@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240412051041.90376-2-mmyangfl@gmail.com> References: <20240412051041.90376-2-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