From: Jason-JH Lin <jason-jh.lin@mediatek.com>
To: AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
"Rob Herring" <robh+dt@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
Chun-Kuang Hu <chunkuang.hu@kernel.org>
Cc: devicetree@vger.kernel.org,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
David Airlie <airlied@linux.ie>,
linux-kernel@vger.kernel.org, singo.chang@mediatek.com,
hsinyi@chromium.org,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
postmaster@vger.kernel.org,
Project_Global_Chrome_Upstream_Group@mediatek.com,
Fabien Parent <fparent@baylibre.com>,
moudy.ho@mediatek.com, linux-mediatek@lists.infradead.org,
roy-cw.yeh@mediatek.com, Daniel Vetter <daniel@ffwll.ch>,
John 'Warthog9' Hawley <warthog9@eaglescrag.net>,
CK Hu <ck.hu@mediatek.com>,
Philipp Zabel <p.zabel@pengutronix.de>,
nancy.lin@mediatek.com, linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org
Subject: Re: [RESEND v17 3/7] soc: mediatek: add mtk-mmsys support for mt8195 vdosys0
Date: Fri, 8 Apr 2022 10:42:44 +0800 [thread overview]
Message-ID: <1ee8927744624fb0b6e97190e5a4b78cbee69751.camel@mediatek.com> (raw)
In-Reply-To: <8d5c41c0-ac7c-ed1e-726b-0d738bf22fed@collabora.com>
Hi Angelo,
Thanks for the reviews.
On Thu, 2022-04-07 at 11:11 +0200, AngeloGioacchino Del Regno wrote:
> Il 07/04/22 05:04, jason-jh.lin ha scritto:
> > 1. Add mt8195 mmsys compatible for vdosys0.
> > 2. Add mt8195 routing table settings and fix build fail.
> > 3. Add clock name, clock driver name and routing table into the
> > driver data
> > of mt8195 vdosys0.
> > 4. Add get match data by clock name function and clock platform
> > labels
> > to identify which mmsys node is corresponding to vdosys0.
> >
> > Signed-off-by: jason-jh.lin <jason-jh.lin@mediatek.com>
> > ---
> > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 2 +-
> > drivers/gpu/drm/mediatek/mtk_drm_drv.c | 6 +-
> > drivers/soc/mediatek/mt8167-mmsys.h | 2 +-
> > drivers/soc/mediatek/mt8183-mmsys.h | 2 +-
> > drivers/soc/mediatek/mt8186-mmsys.h | 4 +-
> > drivers/soc/mediatek/mt8192-mmsys.h | 4 +-
> > drivers/soc/mediatek/mt8195-mmsys.h | 370
> > ++++++++++++++++++++
> > drivers/soc/mediatek/mt8365-mmsys.h | 4 +-
> > drivers/soc/mediatek/mtk-mmsys.c | 62 ++++
> > drivers/soc/mediatek/mtk-mmsys.h | 1 +
> > drivers/soc/mediatek/mtk-mutex.c | 8 +-
> > include/linux/soc/mediatek/mtk-mmsys.h | 13 +-
> > 12 files changed, 461 insertions(+), 17 deletions(-)
> > create mode 100644 drivers/soc/mediatek/mt8195-mmsys.h
> >
>
> ..snip..
>
> > diff --git a/drivers/soc/mediatek/mtk-mmsys.c
> > b/drivers/soc/mediatek/mtk-mmsys.c
> > index 4fc4c2c9ea20..b2fa239c5f5f 100644
> > --- a/drivers/soc/mediatek/mtk-mmsys.c
> > +++ b/drivers/soc/mediatek/mtk-mmsys.c
> > @@ -4,6 +4,8 @@
> > * Author: James Liao <jamesjj.liao@mediatek.com>
> > */
> >
> > +#include <linux/clk.h>
> > +#include <linux/clk-provider.h>
> > #include <linux/delay.h>
> > #include <linux/device.h>
> > #include <linux/io.h>
> > @@ -17,6 +19,7 @@
> > #include "mt8183-mmsys.h"
> > #include "mt8186-mmsys.h"
> > #include "mt8192-mmsys.h"
> > +#include "mt8195-mmsys.h"
> > #include "mt8365-mmsys.h"
> >
> > static const struct mtk_mmsys_driver_data
> > mt2701_mmsys_driver_data = {
> > @@ -72,12 +75,24 @@ static const struct mtk_mmsys_driver_data
> > mt8192_mmsys_driver_data = {
> > .num_routes = ARRAY_SIZE(mmsys_mt8192_routing_table),
> > };
> >
> > +static const struct mtk_mmsys_driver_data
> > mt8195_vdosys0_driver_data = {
> > + .clk_name = "cfg_vdo0",
> > + .clk_driver = "clk-mt8195-vdo0",
> > + .routes = mmsys_mt8195_routing_table,
> > + .num_routes = ARRAY_SIZE(mmsys_mt8195_routing_table),
> > +};
> > +
> > static const struct mtk_mmsys_driver_data
> > mt8365_mmsys_driver_data = {
> > .clk_driver = "clk-mt8365-mm",
> > .routes = mt8365_mmsys_routing_table,
> > .num_routes = ARRAY_SIZE(mt8365_mmsys_routing_table),
> > };
> >
> > +static const struct of_device_id mtk_clk_platform_labels[] = {
> > + { .compatible = "mediatek,mt8195-mmsys",
> > + .data = (void *)"clk-mt8195"},
>
> I have a hunch that MT8195 won't be the first and last SoC having
> multiple
> mmsys channels. I would tend to think that there will be more....
>
Yes, there will be another SoC with multiple mmsys channels...
> ....so, to make it clean from the beginning, I think that you should,
> at
> this point, assign a struct to that .data pointer, instead of
> declaring a
> drvdata struct into mtk_mmsys_get_match_data_by_clk_name().
>
> Besides, I think that this kind of usage for __clk_get_name() may be
> an API
> abuse... but I'm not sure about that... in any case:
> - if it's not an abuse, then you should simply pass
> mt8195_vdosys0_driver_data,
> or an array of pointers to mtk_mmsys_driver_data;
> - if this is an abuse, you can do the same checks by looking at the
> iostart
> (mmio base address) of the vdosys{0,1} node(s).
Do you mean that I should change clk_name to iostart like this?
mt8195_vdosys0_driver_data = {
.iostart = 0x1c01a000, // instead of clk_name
.clk_driver = "clk-mt8195-vdo0",
.routes = mmsys_mt8195_routing_table,
.num_routes = ARRAY_SIZE(mmsys_mt8195_routing_table),
};
Just to confirm that address information can be disclosed here.
If it is not appropriate to use address here, I'll keep using clk_name.
> Honestly, though, I'm not even sure that you need this different
> of_device_id
> array here... since you could simply wrap the mtk_mmsys_driver_data
> in the
> of_match_mtk_mmsys that you have below... here's another idea:
>
> struct mtk_mmsys_match_data {
> const struct mtk_mmsys_driver_data *drv_data[];
> unsigned short num_drv_data;
> };
>
> ...so that:
>
> static int some_function_handling_multi_mmsys(struct mtk_mmsys
> *mmsys,
> struct
> mtk_mmsys_match_data *match)
> {
> int i;
>
> i = [ logic to find the right match->drv_data entry here ]
>
> return i;
> }
>
> static int mtk_mmsys_probe()
> {
> .... variables, something else ....
>
> if (match_data->num_drv_data > 1) {
> /* This SoC has multiple mmsys channels */
> ret = some_function_handling_multi_mmsys(mmsys);
> if (ret < 0)
> return ret;
>
> mmsys->data = match_data->drv_data[ret];
> } else {
> dev_dbg(dev, "Using single mmsys channel\n");
> mmsys->data = match_data->drv_data[0];
> }
>
> ...everything else that mtk_mmsys_probe does ...
> }
I've tried this idea in my local environment and it looks good.
So I'll apply this at the next version. Thanks for your idea!
> What I'm trying to communicate with this is that the currently chosen
> solution
> looks a bit fragile and needs to be made robust.
> In comparison, even if it's not technically right to have two
> different compatibles
> for the same hardware (and shall not be done), the former solution,
> even if wrong,
> was more robust than this one, imo.
>
> Regards,
> Angelo
Because we don't have a property to identify the different mmsys
directly (not using multi-mmsys handle function).
Although it make the code more complicated and not robust, but I think
this time it should be implemented for other multi-mmsys SoC in the
feature.
Regards,
Jason-JH.Lin
-
Jason-JH Lin <jason-jh.lin@mediatek.com>
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
next prev parent reply other threads:[~2022-04-08 2:43 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-07 3:04 [RESEND v17 0/7] Add Mediatek Soc DRM (vdosys0) support for mt8195 jason-jh.lin
2022-04-07 3:04 ` [RESEND v17 1/7] dt-bindings: arm: mediatek: mmsys: add power and gce properties jason-jh.lin
2022-04-07 3:04 ` [RESEND v17 2/7] dt-bindings: arm: mediatek: mmsys: add mt8195 SoC binding jason-jh.lin
2022-04-07 5:12 ` CK Hu
2022-04-07 8:30 ` AngeloGioacchino Del Regno
2022-04-07 3:04 ` [RESEND v17 3/7] soc: mediatek: add mtk-mmsys support for mt8195 vdosys0 jason-jh.lin
2022-04-07 5:45 ` CK Hu
2022-04-07 6:27 ` Jason-JH Lin
2022-04-08 1:28 ` CK Hu
2022-04-08 8:49 ` AngeloGioacchino Del Regno
2022-04-12 6:33 ` CK Hu
2022-04-07 5:58 ` CK Hu
2022-04-08 1:42 ` Jason-JH Lin
2022-04-07 9:11 ` AngeloGioacchino Del Regno
2022-04-08 2:42 ` Jason-JH Lin [this message]
2022-04-08 8:34 ` AngeloGioacchino Del Regno
2022-04-07 3:04 ` [RESEND v17 4/7] soc: mediatek: add mtk-mutex " jason-jh.lin
2022-04-07 3:04 ` [RESEND v17 5/7] drm/mediatek: add DSC support for mediatek-drm jason-jh.lin
2022-04-07 3:04 ` [RESEND v17 6/7] drm/mediatek: add MERGE " jason-jh.lin
2022-04-07 3:04 ` [RESEND v17 7/7] drm/mediatek: add mediatek-drm of vdosys0 support for mt8195 jason-jh.lin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1ee8927744624fb0b6e97190e5a4b78cbee69751.camel@mediatek.com \
--to=jason-jh.lin@mediatek.com \
--cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
--cc=airlied@linux.ie \
--cc=alexandre.torgue@foss.st.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=chunkuang.hu@kernel.org \
--cc=ck.hu@mediatek.com \
--cc=daniel@ffwll.ch \
--cc=devicetree@vger.kernel.org \
--cc=fparent@baylibre.com \
--cc=hsinyi@chromium.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=matthias.bgg@gmail.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=moudy.ho@mediatek.com \
--cc=nancy.lin@mediatek.com \
--cc=p.zabel@pengutronix.de \
--cc=postmaster@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=roy-cw.yeh@mediatek.com \
--cc=singo.chang@mediatek.com \
--cc=warthog9@eaglescrag.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox