linux-mediatek.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
To: Dawei Chien <dawei.chien@mediatek.com>,
	Georgi Djakov <georgi.djakov@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Stephen Boyd <swboyd@chromium.org>,
	Ryan Case <ryandcase@chromium.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
	Nicolas Boichat <drinkcat@google.com>,
	devicetree@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	Fan Chen <fan.chen@mediatek.com>,
	Arvin Wang <arvin.wang@mediatek.com>,
	James Liao <jamesjj.liao@mediatek.com>,
	Henry Chen <henryc.chen@mediatek.com>
Subject: Re: [V11,PATCH 04/19] soc: mediatek: add driver for dvfsrc support
Date: Fri, 11 Feb 2022 12:50:09 +0100	[thread overview]
Message-ID: <e7cbca18-a343-4058-6a1e-1e6bfb167bd9@collabora.com> (raw)
In-Reply-To: <3d30fe7f61b558d3c2c8214e0e936903657f8231.camel@mediatek.com>

Il 11/02/22 04:51, Dawei Chien ha scritto:
> On Thu, 2022-02-03 at 16:04 +0100, AngeloGioacchino Del Regno wrote:
>> Il 12/08/21 10:58, Dawei Chien ha scritto:
>>> From: Henry Chen <henryc.chen@mediatek.com>
>>>
>>> Add dvfsrc driver for MT6873/MT8183/MT8192
>>>
>>> Signed-off-by: Henry Chen <henryc.chen@mediatek.com>
>>> Signed-off-by: Dawei Chien <dawei.chien@mediatek.com>
>>> ---
>>>    drivers/soc/mediatek/Kconfig            |  11 +
>>>    drivers/soc/mediatek/Makefile           |   1 +
>>>    drivers/soc/mediatek/mtk-dvfsrc.c       | 421
>>> ++++++++++++++++++++++++++++++++
>>>    include/linux/soc/mediatek/mtk_dvfsrc.h |  35 +++
>>>    4 files changed, 468 insertions(+)
>>>    create mode 100644 drivers/soc/mediatek/mtk-dvfsrc.c
>>>    create mode 100644 include/linux/soc/mediatek/mtk_dvfsrc.h
>>>

..snip..

>>> diff --git a/drivers/soc/mediatek/mtk-dvfsrc.c
>>> b/drivers/soc/mediatek/mtk-dvfsrc.c
>>> new file mode 100644
>>> index 000000000000..6ef167cf55bd
>>> --- /dev/null
>>> +++ b/drivers/soc/mediatek/mtk-dvfsrc.c

..snip..

>>> +static int mtk_dvfsrc_probe(struct platform_device *pdev)
>>> +{
>>> +	struct arm_smccc_res ares;
>>> +	struct resource *res;
>>> +	struct mtk_dvfsrc *dvfsrc;
>>> +	int ret;
>>> +
>>> +	dvfsrc = devm_kzalloc(&pdev->dev, sizeof(*dvfsrc), GFP_KERNEL);
>>> +	if (!dvfsrc)
>>> +		return -ENOMEM;
>>> +
>>> +	dvfsrc->dvd = of_device_get_match_data(&pdev->dev);
>>> +	dvfsrc->dev = &pdev->dev;
>>> +
>>> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>> +	dvfsrc->regs = devm_ioremap_resource(&pdev->dev, res);
>>> +	if (IS_ERR(dvfsrc->regs))
>>> +		return PTR_ERR(dvfsrc->regs);
>>> +
>>> +	spin_lock_init(&dvfsrc->req_lock);
>>> +	mutex_init(&dvfsrc->pstate_lock);
>>> +
>>> +	arm_smccc_smc(MTK_SIP_VCOREFS_CONTROL, MTK_SIP_DVFSRC_INIT, 0,
>>> 0, 0,
>>> +		0, 0, 0, &ares);
>>> +
>>> +	if (!ares.a0) {
>>> +		dvfsrc->dram_type = ares.a1;
>>> +		dev_info(dvfsrc->dev, "dram_type: %d\n", dvfsrc-
>>>> dram_type);
>>> +	} else {
>>> +		dev_err(dvfsrc->dev, "init fails: %lu\n", ares.a0);
>>> +		return ares.a0;
>>> +	}
>>> +
>>> +	dvfsrc->curr_opps = &dvfsrc->dvd->opps_desc[dvfsrc->dram_type];
>>> +	platform_set_drvdata(pdev, dvfsrc);
>>> +
>>> +	dvfsrc->regulator = platform_device_register_data(dvfsrc->dev,
>>> +			"mtk-dvfsrc-regulator", -1, NULL, 0);
>>
>> Why are you registering platform devices like this?
>>
>> Please use device-tree instead.
>>
> 
> Thank you for advisement. Let me just describe history.
> 
> Actually, we did use device-tree to probe interconnect/regulator driver
> in v4, and reviewer had some advisement
> 
> 
> https://patchwork.kernel.org/project/linux-mediatek/patch/1584092066-24425-12-git-send-email-henryc.chen@mediatek.com/#23243049
> 
> https://patchwork.kernel.org/project/linux-mediatek/patch/1584092066-24425-9-git-send-email-henryc.chen@mediatek.com/#23236945
> 
> so we refer to this driver to use platform_device_register_data after
> v5.
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/soc/qcom/smd-rpm.c?h=next-20220209#n213
> 
> Would you kindly give your advisement, thank you.
> 

Hello Dawei,
I was under the impression that the regulator and EMI were different hardware,
while effectively they are inside of the DVFS Resource Collector IP, and the
registers look like being a bit mixed up, so it's impossible to actually
specify a relative iospace for the regulator, or for the EMI.

In this case, from what I understand right now, the emi and regulator are not
different hardware, but "features of" the DVFS Resource Collector.

I've done some research around the kernel and, effectively, the only way that
makes sense, is to register the feature-drivers (emi/vreg) with
platform_device_register_data(), as per your current approach, even though I
have a hunch that it will look a bit confusing in device-tree, as you'd be using
the same node for both regulator and interconnects...

I would exclude doing it as a MFD driver, as I don't see any very clean way to
actually implement that.

At this point, let's just keep it as it is, or this would probably get a lot
overcomplicated for no good reasons.
So, please ignore the device-tree suggestion and go on with the other suggested
fixes for this driver.

Looking forward to see your v4!

Kind regards,
Angelo

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

  reply	other threads:[~2022-02-11 11:50 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-12  8:58 [PATCH 00/19] Add driver for dvfsrc, support for interconnect Dawei Chien
2021-08-12  8:58 ` [V11,PATCH 01/19] dt-bindings: soc: Add dvfsrc driver bindings Dawei Chien
2021-08-12  8:58 ` [V11, PATCH 02/19] dt-bindings: mediatek: add compatible for MT8195 dvfsrc Dawei Chien
2021-08-17 21:23   ` [V11,PATCH " Rob Herring
2021-08-12  8:58 ` [V11, PATCH 03/19] soc: mediatek: add header for mediatek SIP interface Dawei Chien
2022-02-03 15:14   ` AngeloGioacchino Del Regno
2022-02-11  3:50     ` Dawei Chien
2021-08-12  8:58 ` [V11,PATCH 04/19] soc: mediatek: add driver for dvfsrc support Dawei Chien
2022-02-03 15:04   ` AngeloGioacchino Del Regno
2022-02-11  3:51     ` Dawei Chien
2022-02-11 11:50       ` AngeloGioacchino Del Regno [this message]
2021-08-12  8:58 ` [V11,PATCH 05/19] soc: mediatek: add support for mt6873 Dawei Chien
2022-02-03 15:13   ` AngeloGioacchino Del Regno
2022-02-11  3:50     ` Dawei Chien
2021-08-12  8:58 ` [V11,PATCH 06/19] soc: mediatek: add support for mt8195 Dawei Chien
2021-08-12  8:58 ` [V11,PATCH 07/19] arm64: dts: mt8183: add dvfsrc related nodes Dawei Chien
2021-08-12  8:58 ` [V11,PATCH 08/19] arm64: dts: mt8192: " Dawei Chien
2021-08-12  8:58 ` [V11,PATCH 09/19] arm64: dts: mt8195: " Dawei Chien
2021-08-12  8:58 ` [V11, PATCH 10/19] dt-bindings: interconnect: add MT6873 interconnect dt-bindings Dawei Chien
2021-08-12  8:58 ` [V11, PATCH 11/19] dt-bindings: interconnect: add MT8195 " Dawei Chien
2021-08-17 21:24   ` [V11,PATCH " Rob Herring
2022-02-03 15:22   ` [V11, PATCH " AngeloGioacchino Del Regno
2021-08-12  8:58 ` [V11, PATCH 12/19] interconnect: mediatek: Add interconnect provider driver Dawei Chien
2022-02-03 15:19   ` AngeloGioacchino Del Regno
2022-02-11  3:49     ` Dawei Chien
2021-08-12  8:58 ` [V11,PATCH 13/19] interconnect: mediatek: add support for mt8195 Dawei Chien
2022-02-03 15:19   ` AngeloGioacchino Del Regno
2021-08-12  8:58 ` [V11,PATCH 14/19] interconnect: mediatek: add initial bandwidth Dawei Chien
2021-08-12  8:58 ` [V11,PATCH 15/19] regulator: mediatek: add support for mt8195 Dawei Chien
2022-02-03 15:21   ` AngeloGioacchino Del Regno
2021-08-12  8:58 ` [V11,PATCH 16/19] arm64: dts: mt8183: add dvfsrc related nodes Dawei Chien
2022-02-03 15:16   ` AngeloGioacchino Del Regno
2022-02-11  3:50     ` Dawei Chien
2021-08-12  8:58 ` [V11,PATCH 17/19] arm64: dts: mt8192: " Dawei Chien
2021-08-12  8:58 ` [V11,PATCH 18/19] arm64: dts: mt8192: add dvfsrc regulator nodes Dawei Chien
2021-08-12  8:58 ` [V11,PATCH 19/19] arm64: dts: mt8195: add dvfsrc related nodes Dawei Chien
2022-09-05 10:24 ` [PATCH 00/19] Add driver for dvfsrc, support for interconnect AngeloGioacchino Del Regno

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=e7cbca18-a343-4058-6a1e-1e6bfb167bd9@collabora.com \
    --to=angelogioacchino.delregno@collabora.com \
    --cc=arvin.wang@mediatek.com \
    --cc=dawei.chien@mediatek.com \
    --cc=devicetree@vger.kernel.org \
    --cc=drinkcat@google.com \
    --cc=fan.chen@mediatek.com \
    --cc=georgi.djakov@linaro.org \
    --cc=henryc.chen@mediatek.com \
    --cc=jamesjj.liao@mediatek.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=matthias.bgg@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=ryandcase@chromium.org \
    --cc=swboyd@chromium.org \
    /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;
as well as URLs for NNTP newsgroup(s).