Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4181353pxj; Tue, 15 Jun 2021 17:39:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxtnFsbT3ODadutvvKxKlq9mnOb2jsMy4nAFoKIKi16SvifDTE1G9s28sGamOgQSP7e59h X-Received: by 2002:a92:cacb:: with SMTP id m11mr1494739ilq.133.1623803971922; Tue, 15 Jun 2021 17:39:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623803971; cv=none; d=google.com; s=arc-20160816; b=l4mkKhMa4+Dahrrn3Gb28dT1n2uaa2u9pL93lh+LjPlaDuc0Aozq5NLqEiD/8K/EM4 fdQz/CleyPDBGeDN6e6eeHXpGZM295UJDN1PfHy9Laq+G8HLqzK4NQLaVwc8xb41q2O3 RJpebuDLVXFKzqcGWtZE6iKZFZYWlG/j0209QV5ElDse1Z9oliX6MdimqBz5zJXo+bzG caIz8TKwrbUTJIlmr1lTE2QgCkOfH5QxBos/eR8ZOjpbTOBfNPl7WYQ0/8id0r8yq+Wh CFu8Fg45oQHpdhwZ8N1oVz95fi/WVw3Ebr9ScvUeW+arqd+w1XgnvxqVR7fxmmO7QH03 /PVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=wE2vXkAuKHEIu1YVSLTDHGWj/aLQ4FIz9KPQrZuJINU=; b=oRv5ll4hoki8zN+jivMP7ilhVSYlFkXIa2I5LvsCu8wfQTN2m4Tc6LprzTzPmNKEG5 kzyF4QnK6jwjg+faaLdSFUYU1i8SyoOR4JkuBy5w2zJVe7GSclFsSjs4Yj7E3K/8JhbL BHRQYeUpq3kf0nzbUL77bMW5F1Jsx+OlbXzqYFoVS5tOHYAFmm7VnJVEKh+Nyv/kOEcs yK5Z42ebnEzWvJr0tXDJxpGQVqAo/in5G0/kjHlaZqtFjGBP3ON0clerIXsmqvuKO8cf 3xOh5nztLKXZS9CXrbpd4nAfBINFCa2+mNJ1rtuN40RqVNyNorMnm0CXanTOAXQUCUiv 8CjQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i26si408833iol.73.2021.06.15.17.39.19; Tue, 15 Jun 2021 17:39:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231802AbhFPAkf (ORCPT + 99 others); Tue, 15 Jun 2021 20:40:35 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:49234 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S231800AbhFPAke (ORCPT ); Tue, 15 Jun 2021 20:40:34 -0400 X-UUID: b16f69f561cf481799f445d4068c59c4-20210616 X-UUID: b16f69f561cf481799f445d4068c59c4-20210616 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1014664285; Wed, 16 Jun 2021 08:38:25 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs06n2.mediatek.inc (172.21.101.130) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 16 Jun 2021 08:38:24 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 16 Jun 2021 08:38:24 +0800 From: Chun-Jie Chen To: Matthias Brugger , Stephen Boyd , Nicolas Boichat , Rob Herring CC: , , , , , , , Weiyi Lu , Chun-Jie Chen Subject: [PATCH v10 06/19] clk: mediatek: Add mtk_clk_simple_probe() to simplify clock providers Date: Wed, 16 Jun 2021 08:36:30 +0800 Message-ID: <20210616003643.28648-7-chun-jie.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210616003643.28648-1-chun-jie.chen@mediatek.com> References: <20210616003643.28648-1-chun-jie.chen@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Most of subsystem clock providers only need to register clock gates in their probe() function. To reduce the duplicated code by add a generic function. Signed-off-by: Weiyi Lu Signed-off-by: Chun-Jie Chen --- drivers/clk/mediatek/clk-mtk.c | 23 +++++++++++++++++++++++ drivers/clk/mediatek/clk-mtk.h | 8 ++++++++ 2 files changed, 31 insertions(+) diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index 37d2aa32175e..4b6096c44d74 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "clk-mtk.h" #include "clk-gate.h" @@ -286,3 +287,25 @@ void mtk_clk_register_dividers(const struct mtk_clk_divider *mcds, clk_data->clks[mcd->id] = clk; } } + +int mtk_clk_simple_probe(struct platform_device *pdev) +{ + const struct mtk_clk_desc *mcd; + struct clk_onecell_data *clk_data; + struct device_node *node = pdev->dev.of_node; + int r; + + mcd = of_device_get_match_data(&pdev->dev); + if (!mcd) + return -EINVAL; + + clk_data = mtk_alloc_clk_data(mcd->num_clks); + if (!clk_data) + return -ENOMEM; + + r = mtk_clk_register_gates(node, mcd->clks, mcd->num_clks, clk_data); + if (r) + return r; + + return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); +} diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h index 31c7cb304508..7de41c3b3206 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -10,6 +10,7 @@ #include #include #include +#include struct clk; struct clk_onecell_data; @@ -250,4 +251,11 @@ void mtk_register_reset_controller(struct device_node *np, void mtk_register_reset_controller_set_clr(struct device_node *np, unsigned int num_regs, int regofs); +struct mtk_clk_desc { + const struct mtk_gate *clks; + size_t num_clks; +}; + +int mtk_clk_simple_probe(struct platform_device *pdev); + #endif /* __DRV_CLK_MTK_H */ -- 2.18.0