Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3482614pxj; Mon, 24 May 2021 07:45:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrWeSP1LK9IlYE/3xlB9QdDTSNVo+s1c7IY5cP3ClYIWDNQhIlNwD0HWgl+dDYh2kk/nO2 X-Received: by 2002:a17:907:3f28:: with SMTP id hq40mr24027002ejc.283.1621867529886; Mon, 24 May 2021 07:45:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621867529; cv=none; d=google.com; s=arc-20160816; b=XENihB6By6s8aKX0sxRZZ8G0yTS8/gWc2Xy39+vG/QdEyePmSYIeGRVY111IVZv4jz /kq/MmmarOrIFScogbRDlGUYUOYhvyPQ9KgFH5i+buyK+gIkdA9CFWn76q8L63G6pXrk MhRSrXxRM3TKZwWkbi9uXvmShb2ely41snbNE02QcERzSFain0Hg4+vtlyTyq3NEdHph GFVtCu5Sxr6fh/wozearnaufGd4uj/lyCk6Luq3GIBaMzdBraOL8y64JpDTyoXjRoJIw F+MOQ0uFJp5XeU8ARjRTzdeNzV3D5aTX2BWwwxNYVLQdOECUsy8mprnVjoBrnyEfQ0ou i1yA== 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=Xq5FISKVn0knvz1tasUvbSYvfwEbr5D52JHRIPcaEPU=; b=tGoeuPPP+sI0pZIyfhCGXc6YJMEqQh+SlOOsVhBq0uvcIwTObYVB8ergPJktteX++d asjYNyWzM48619QYn5Lxfpnj2euNvUiOQL1J1PA0p2hn26yx8W3dOFNJNN3gT0O+kXJF opD4J8rhL6zxebQvou4uZVQdGzA1zictmR9b/d/FfQRLCHYE1k7ccfTPm1dZb5sdpEpJ bUrS8TX7N/2XDL+dhtaWx4z3BvsP86EWLLGB27iyaRcGRJRNIqlnWvhX+stAFKE5KabG 8pJGucdU7CN16vmzxKaNOcVVabqIl0QxOVJGCIc11T/FyRCYsd46msecsHhBSQ91c+Gt yZUQ== 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 rs28si13282502ejb.19.2021.05.24.07.45.07; Mon, 24 May 2021 07:45:29 -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 S233102AbhEXOol (ORCPT + 99 others); Mon, 24 May 2021 10:44:41 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:40222 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S233073AbhEXOog (ORCPT ); Mon, 24 May 2021 10:44:36 -0400 X-UUID: 2c6acdc5018b41d880d55e17e64e1344-20210524 X-UUID: 2c6acdc5018b41d880d55e17e64e1344-20210524 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 133939751; Mon, 24 May 2021 20:29:12 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 24 May 2021 20:29:11 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 24 May 2021 20:29:11 +0800 From: Chun-Jie Chen To: Matthias Brugger , Stephen Boyd , Nicolas Boichat , Rob Herring CC: , , , , , , , Weiyi Lu , "chun-jie . chen" Subject: [PATCH v9 09/22] clk: mediatek: Add mtk_clk_simple_probe() to simplify clock providers Date: Mon, 24 May 2021 20:20:40 +0800 Message-ID: <20210524122053.17155-10-chun-jie.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210524122053.17155-1-chun-jie.chen@mediatek.com> References: <20210524122053.17155-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 cec1c8a27211..67693b7d66b5 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