Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1277475pxb; Wed, 10 Feb 2021 04:50:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJy0QlmPxYcY/5te2jw6fJmoCLNpeUBL9whEljqBJxwSjO/Q/azTUA4T+qUHE5EbwX91pmlt X-Received: by 2002:a50:e14d:: with SMTP id i13mr2973394edl.106.1612961430018; Wed, 10 Feb 2021 04:50:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612961430; cv=none; d=google.com; s=arc-20160816; b=fZpn026dGnoaa54DiozcwaVMgf+kH4w1AzasTQ3AqlWbA5Li/SR9uqOwnS5sdO0crR xdTX+hktw1TJrNqKFRABpNRoYNBFwjpOwx7J11HXtsEdap9ypuR8L4eBBCkkjnqtjlmY 7vBFlkMPeifzHdcDayEux0JwXCc1xmhN44AOckWUkRJnrSqOrC3pqXyKaC/PvzEGnFKR 5WmA3QT85qEGDR1SQLm9gV4q/2k6UJ3IQ2iyxssXp+zm7hhNQs/CarcU48B15P3jKxbr hlNhuWLlxeCYYZ1MWcm6HAcaCqDRe89OYwD1OAdAs7cMTF6INSWrLP4vwTcldHpLyLw8 ng2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:cc:to:dkim-signature; bh=rjLWgX3Eg/gC3RV2khv5c8f9NWNyEch31NnXlurt3Ss=; b=SCQ6cP399UTIG5UeNA0qew4dunvSfDGVCKnNI/8gea2Yaa4r9UCh+OlL6haB4dN7C7 9T2FfEx8mFOwPZxWqHrV7qGkUGY1xxJdATnfqP1niBGzkOlZhDWoXt3yQhWGeD5IjaKi 5UD0+8lm8I9oc181dpI8r7ChVa7qTjWTCZQHpoY/bNZ9heEcYbSJpMwd0I4ZWMFZxb2E MDdquxnXlc53IcUGL+kbsEnMSFzNgEyVQcN0saImOXX1rLyavbY6B9kkUPJFMJBWEk3w 8ie0WsviKnGNJwFP4RxP0IDhlllNs3Q1OXzAJusrZvfZQShjtHuKlCq9CW4kOhdtXiwB dLlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GSU8nJJH; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g13si1211383ejx.443.2021.02.10.04.50.06; Wed, 10 Feb 2021 04:50:30 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GSU8nJJH; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230290AbhBJMr1 (ORCPT + 99 others); Wed, 10 Feb 2021 07:47:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230419AbhBJMqn (ORCPT ); Wed, 10 Feb 2021 07:46:43 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDB87C061786; Wed, 10 Feb 2021 04:46:02 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id 7so2407757wrz.0; Wed, 10 Feb 2021 04:46:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:references:from:subject:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=rjLWgX3Eg/gC3RV2khv5c8f9NWNyEch31NnXlurt3Ss=; b=GSU8nJJHRxGKxEYvAVHgEZ99IaPo0P82K2x/ng7rcD0jt+NV3L03A27i1H57yxSIxh /ix5ODPDpCQiJftDGoj9wOWsLSy5xcMrn+tClntvA+wmxdJmfrzx/MUqJJiXEwHDeC0I dtbDh2tJORkIrYHkE0g9fUS4N7old4ebGv+D75QpkkmjRxu5mBL4hkboAi4chmFY1GCe Y2dfPmWdzLtFxoNTJ9JD7aJkXPQY2iwoVdYi1dtnv87ZxOfDg2VxkIe6rfQj0mrAKf3Z HpJwhtERMHvMhNT7nvtQiVT7CsRyqedvV18w1GxtWP3xZNK7/ghrnLa+gxewO8yaMSeU lzjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:subject:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=rjLWgX3Eg/gC3RV2khv5c8f9NWNyEch31NnXlurt3Ss=; b=XQD+J3CWZkOCaoKxZgvq4F6rPAyPbAt1gkxXewuLbk/2P7pqeW0U92c3MgOo0Ge+hj YQgWfZIzumaGAiWQzmO0DWm5JReqXhCThSEC7J7rkYxewodEV7lXLvcNlSHn/joPs0vG KCAfLh8KxmIk+YTRURPiSi8gJlDthBNS0WTi8f4f0szslQtOrzBK3pdy4lHz9hSbN0hY D7lcpfDbx41Em9pUhrId68FTqpQcz5jsRNMjWFJ54wnsjZafnpubq8Vjaqq99wyhZRhu 2COX2YSj+8zd5LLWF/JzaVQodjGQwf3sbwHV+z5EH4JSdf8kzXKDmnlR8sWxiL17RjDw caMA== X-Gm-Message-State: AOAM531oS+GPgJFnTtSqS+51NVeAAAFNuFCevmHVt/bxd4+izJL5zFbV O/aqkdZR4x360co/iadf558= X-Received: by 2002:a5d:4d8d:: with SMTP id b13mr3334138wru.178.1612961161574; Wed, 10 Feb 2021 04:46:01 -0800 (PST) Received: from ziggy.stardust (static-188-169-27-46.ipcom.comunitel.net. [46.27.169.188]) by smtp.gmail.com with ESMTPSA id f17sm2826671wrx.57.2021.02.10.04.46.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 10 Feb 2021 04:46:01 -0800 (PST) To: Weiyi Lu , Rob Herring , Stephen Boyd , Nicolas Boichat Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-clk@vger.kernel.org, srv_heupstream@mediatek.com, Project_Global_Chrome_Upstream_Group@mediatek.com References: <1608642587-15634-1-git-send-email-weiyi.lu@mediatek.com> <1608642587-15634-11-git-send-email-weiyi.lu@mediatek.com> From: Matthias Brugger Subject: Re: [PATCH v6 10/22] clk: mediatek: Add MT8192 basic clocks support Message-ID: Date: Wed, 10 Feb 2021 13:46:00 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <1608642587-15634-11-git-send-email-weiyi.lu@mediatek.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22/12/2020 14:09, Weiyi Lu wrote: > Add MT8192 basic clock providers, include topckgen, apmixedsys, > infracfg and pericfg. > > Signed-off-by: Weiyi Lu > --- > drivers/clk/mediatek/Kconfig | 8 + > drivers/clk/mediatek/Makefile | 1 + > drivers/clk/mediatek/clk-mt8192.c | 1326 +++++++++++++++++++++++++++++++++++++ > drivers/clk/mediatek/clk-mux.h | 15 + > 4 files changed, 1350 insertions(+) > create mode 100644 drivers/clk/mediatek/clk-mt8192.c > [...] > +static int clk_mt8192_apmixed_probe(struct platform_device *pdev) > +{ > + struct clk_onecell_data *clk_data; > + struct device_node *node = pdev->dev.of_node; > + int r; > + > + clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK); > + if (!clk_data) > + return -ENOMEM; > + > + mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data); > + r = mtk_clk_register_gates(node, apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); > + if (r) > + return r; > + > + return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); > +} > + > +static const struct of_device_id of_match_clk_mt8192[] = { > + { > + .compatible = "mediatek,mt8192-apmixedsys", > + .data = clk_mt8192_apmixed_probe, > + }, { > + .compatible = "mediatek,mt8192-topckgen", > + .data = clk_mt8192_top_probe, > + }, { > + .compatible = "mediatek,mt8192-infracfg", > + .data = clk_mt8192_infra_probe, > + }, { > + .compatible = "mediatek,mt8192-pericfg", > + .data = clk_mt8192_peri_probe, > + }, { > + /* sentinel */ > + } > +}; > + > +static int clk_mt8192_probe(struct platform_device *pdev) > +{ > + int (*clk_probe)(struct platform_device *pdev); > + int r; > + > + clk_probe = of_device_get_match_data(&pdev->dev); > + if (!clk_probe) > + return -EINVAL; > + > + r = clk_probe(pdev); > + if (r) > + dev_err(&pdev->dev, "could not register clock provider: %s: %d\n", pdev->name, r); > + > + return r; > +} > + > +static struct platform_driver clk_mt8192_drv = { > + .probe = clk_mt8192_probe, > + .driver = { > + .name = "clk-mt8192", > + .of_match_table = of_match_clk_mt8192, > + }, > +}; > + > +static int __init clk_mt8192_init(void) > +{ > + return platform_driver_register(&clk_mt8192_drv); > +} > + > +arch_initcall(clk_mt8192_init); Do we really need all these clocks that early? Why don't we use CLK_OF_DECLARE_DRIVER() then and why do we initialize some clocks CLK_OF_DECLARE_DRIVER and other with arch_initcall? I know that this is in other drivers for MediaTek SoCs, but that does not mean it's the right approach. > diff --git a/drivers/clk/mediatek/clk-mux.h b/drivers/clk/mediatek/clk-mux.h > index f5625f4..afbc7df 100644 > --- a/drivers/clk/mediatek/clk-mux.h > +++ b/drivers/clk/mediatek/clk-mux.h > @@ -77,6 +77,21 @@ struct mtk_mux { > _width, _gate, _upd_ofs, _upd, \ > CLK_SET_RATE_PARENT) > > +#define MUX_CLR_SET_UPD_FLAGS(_id, _name, _parents, _mux_ofs, \ > + _mux_set_ofs, _mux_clr_ofs, _shift, _width, \ > + _upd_ofs, _upd, _flags) \ > + GATE_CLR_SET_UPD_FLAGS(_id, _name, _parents, _mux_ofs, \ > + _mux_set_ofs, _mux_clr_ofs, _shift, _width, \ > + 0, _upd_ofs, _upd, _flags, \ > + mtk_mux_clr_set_upd_ops) > + > +#define MUX_CLR_SET_UPD(_id, _name, _parents, _mux_ofs, \ > + _mux_set_ofs, _mux_clr_ofs, _shift, _width, \ > + _upd_ofs, _upd) \ > + MUX_CLR_SET_UPD_FLAGS(_id, _name, _parents, \ > + _mux_ofs, _mux_set_ofs, _mux_clr_ofs, _shift, \ > + _width, _upd_ofs, _upd, CLK_SET_RATE_PARENT) > + Why can't we do something like: #define MUX_CLR_SET_UPD(_id, _name, _parents, _mux_ofs, \ _mux_set_ofs, _mux_clr_ofs, _shift, _width, \ _upd_ofs, _upd) \ GATE_CLR_SET_UPD_FLAGS(_id, _name, _parents, _mux_ofs, \ _mux_set_ofs, _mux_clr_ofs, _shift, _width, \ 0, _upd_ofs, _upd, CLK_SET_RATE_PARENT, \ mtk_mux_clr_set_upd_ops) > struct clk *mtk_clk_register_mux(const struct mtk_mux *mux, > struct regmap *regmap, > spinlock_t *lock); >