All of lore.kernel.org
 help / color / mirror / Atom feed
From: "CK Hu (胡俊光)" <ck.hu@mediatek.com>
To: AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	"chunkuang.hu@kernel.org" <chunkuang.hu@kernel.org>
Cc: "dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"kernel@collabora.com" <kernel@collabora.com>,
	"robh@kernel.org" <robh@kernel.org>,
	"Alexandre Mergnat" <amergnat@baylibre.com>,
	"tzimmermann@suse.de" <tzimmermann@suse.de>,
	"dmitry.osipenko@collabora.com" <dmitry.osipenko@collabora.com>,
	"Jitao Shi (石记涛)" <jitao.shi@mediatek.com>,
	"simona@ffwll.ch" <simona@ffwll.ch>,
	"mripard@kernel.org" <mripard@kernel.org>,
	"maarten.lankhorst@linux.intel.com"
	<maarten.lankhorst@linux.intel.com>,
	"conor+dt@kernel.org" <conor+dt@kernel.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"Jason-JH Lin (林睿祥)" <Jason-JH.Lin@mediatek.com>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"krzk+dt@kernel.org" <krzk+dt@kernel.org>,
	"granquet@baylibre.com" <granquet@baylibre.com>,
	"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
	"airlied@gmail.com" <airlied@gmail.com>,
	"Justin Yeh (葉英茂)" <Justin.Yeh@mediatek.com>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"Rex-BC Chen (陳柏辰)" <Rex-BC.Chen@mediatek.com>
Subject: Re: [PATCH v4 08/12] drm/mediatek: mtk_dp: Add support for PHY from devicetree
Date: Fri, 28 Aug 2026 06:07:13 +0000	[thread overview]
Message-ID: <628ec3f674815dcdc85c5cf6d81ffa9da9a178fc.camel@mediatek.com> (raw)
In-Reply-To: <20260709113148.49090-9-angelogioacchino.delregno@collabora.com>

On Thu, 2026-07-09 at 13:31 +0200, AngeloGioacchino Del Regno wrote:
> Add support for specifying `phys` in devicetree to pass handle
> to the DisplayPort PHY.
> 
> In order to retain compatibility with older devicetrees, check if
> `phys` was specified: if not, initialize the regmap_mmio with the
> legacy configuration and register the mediatek-dp-phy platform
> device from this driver, and get the PHY calibration data.

Reviewed-by: CK Hu <ck.hu@mediatek.com>

> 
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_dp.c | 50 ++++++++++++++++++++++++++-----
>  1 file changed, 43 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c
> index 383c8e66b527..e2a6001fc0cc 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dp.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dp.c
> @@ -426,6 +426,15 @@ static const struct regmap_config mtk_dp_regmap_legacy_config = {
>  	.name = "mtk-dp-registers",
>  };
>  
> +static const struct regmap_config mtk_dp_regmap_config = {
> +	.reg_bits = 32,
> +	.val_bits = 32,
> +	.reg_stride = 4,
> +	.max_register = SEC_OFFSET + 0x90,
> +	.name = "mtk-dp-registers",
> +};
> +
> +
>  static struct mtk_dp *mtk_dp_from_bridge(struct drm_bridge *b)
>  {
>  	return container_of(b, struct mtk_dp, bridge);
> @@ -1287,7 +1296,13 @@ static int mtk_dp_phy_configure(struct mtk_dp *mtk_dp,
>  	if (ret)
>  		return ret;
>  
> -	mtk_dp_set_calibration_data(mtk_dp);
> +	/*
> +	 * For legacy, deprecated strategy, set partial PHY calibration here.
> +	 * New-style will set all PHY calibrations with phy ops instead.
> +	 */
> +	if (mtk_dp->phy_dev)
> +		mtk_dp_set_calibration_data(mtk_dp);
> +
>  	mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE,
>  			   DP_PWR_STATE_BANDGAP_TPLL_LANE, DP_PWR_STATE_MASK);
>  
> @@ -2120,8 +2135,9 @@ static int mtk_dp_wait_hpd_asserted(struct drm_dp_aux *mtk_aux, unsigned long wa
>  static int mtk_dp_dt_parse(struct mtk_dp *mtk_dp,
>  			   struct platform_device *pdev)
>  {
> -	struct device_node *endpoint;
> +	const struct regmap_config *regmap_cfg;
>  	struct device *dev = &pdev->dev;
> +	struct device_node *endpoint;
>  	int ret;
>  	void __iomem *base;
>  	u32 linkrate;
> @@ -2131,7 +2147,12 @@ static int mtk_dp_dt_parse(struct mtk_dp *mtk_dp,
>  	if (IS_ERR(base))
>  		return PTR_ERR(base);
>  
> -	mtk_dp->regs = devm_regmap_init_mmio(dev, base, &mtk_dp_regmap_legacy_config);
> +	if (!mtk_dp->legacy_regoff)
> +		regmap_cfg = &mtk_dp_regmap_config;
> +	else
> +		regmap_cfg = &mtk_dp_regmap_legacy_config;
> +
> +	mtk_dp->regs = devm_regmap_init_mmio(dev, base, regmap_cfg);
>  	if (IS_ERR(mtk_dp->regs))
>  		return PTR_ERR(mtk_dp->regs);
>  
> @@ -2754,6 +2775,7 @@ static int mtk_dp_register_phy(struct mtk_dp *mtk_dp)
>  		return dev_err_probe(dev, ret,
>  				     "Failed to add phy unregister devm action");
>  
> +	/* PHY calibration data is in mtk_dp only for legacy devicetree */
>  	mtk_dp_get_calibration_data(mtk_dp);
>  
>  	mtk_dp->phy = devm_phy_get(&mtk_dp->phy_dev->dev, "dp");
> @@ -2804,7 +2826,12 @@ static int mtk_dp_probe(struct platform_device *pdev)
>  
>  	mtk_dp->dev = dev;
>  	mtk_dp->data = (struct mtk_dp_data *)of_device_get_match_data(dev);
> -	mtk_dp->legacy_regoff = MTK_DP_TOP_OFFSET_LEGACY;
> +
> +	/* Prefer PHY from devicetree - if not found, this is legacy */
> +	if (of_property_present(dev->of_node, "phys"))
> +		mtk_dp->legacy_regoff = 0;
> +	else
> +		mtk_dp->legacy_regoff = MTK_DP_TOP_OFFSET_LEGACY;
>  
>  	ret = mtk_dp_dt_parse(mtk_dp, pdev);
>  	if (ret)
> @@ -2855,9 +2882,18 @@ static int mtk_dp_probe(struct platform_device *pdev)
>  					     "Failed to register audio driver\n");
>  	}
>  
> -	ret = mtk_dp_register_phy(mtk_dp);
> -	if (ret)
> -		return ret;
> +	if (!mtk_dp->legacy_regoff) {
> +		mtk_dp->phy = devm_phy_get(dev, NULL);
> +		if (IS_ERR(mtk_dp->phy))
> +			return dev_err_probe(dev, PTR_ERR(mtk_dp->phy),
> +					     "Failed to get phy\n");
> +
> +		mtk_dp->phy_dev = NULL;
> +	} else {
> +		ret = mtk_dp_register_phy(mtk_dp);
> +		if (ret)
> +			return ret;
> +	}
>  
>  	mtk_dp->bridge.of_node = dev->of_node;
>  	mtk_dp->bridge.type = mtk_dp->data->bridge_type;


  reply	other threads:[~2026-08-28  6:07 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09 11:31 [PATCH v4 00/12] drm: MediaTek DisplayPort cleanups and MT8196 eDP AngeloGioacchino Del Regno
2026-07-09 11:31 ` [PATCH v4 01/12] dt-bindings: display: mediatek: dp: Deprecate nvmem efuse data AngeloGioacchino Del Regno
2026-07-11 15:08   ` Krzysztof Kozlowski
2026-08-27  6:03   ` CK Hu (胡俊光)
2026-07-09 11:31 ` [PATCH v4 02/12] dt-bindings: display: mediatek: dp: Add compatible for MT8196 eDP AngeloGioacchino Del Regno
2026-07-11 15:08   ` Krzysztof Kozlowski
2026-08-27  6:17   ` CK Hu (胡俊光)
2026-07-09 11:31 ` [PATCH v4 03/12] drm/mediatek: mtk_dp: Call pm_runtime_put_sync() in removal path AngeloGioacchino Del Regno
2026-07-09 11:42   ` sashiko-bot
2026-08-27  6:23   ` CK Hu (胡俊光)
2026-07-09 11:31 ` [PATCH v4 04/12] drm/mediatek: mtk_dp: Fix hdmi codec and phy driver unregistration AngeloGioacchino Del Regno
2026-07-09 11:48   ` sashiko-bot
2026-08-27  7:22   ` CK Hu (胡俊光)
2026-07-09 11:31 ` [PATCH v4 05/12] drm/mediatek: mtk_dp: Clarify SMC eDP/DP video unmute commands AngeloGioacchino Del Regno
2026-08-27  7:28   ` CK Hu (胡俊光)
2026-07-09 11:31 ` [PATCH v4 06/12] drm/mediatek: mtk_dp: Rework register offsets for proper PHY usage AngeloGioacchino Del Regno
2026-08-28  3:32   ` CK Hu (胡俊光)
2026-07-09 11:31 ` [PATCH v4 07/12] drm/mediatek: mtk_dp: Use PHY API for PHY power sequences AngeloGioacchino Del Regno
2026-07-09 11:53   ` sashiko-bot
2026-08-28  3:40   ` CK Hu (胡俊光)
2026-07-09 11:31 ` [PATCH v4 08/12] drm/mediatek: mtk_dp: Add support for PHY from devicetree AngeloGioacchino Del Regno
2026-08-28  6:07   ` CK Hu (胡俊光) [this message]
2026-07-09 11:31 ` [PATCH v4 09/12] drm/mediatek: mtk_dp: Move max link rate to SoC specific data AngeloGioacchino Del Regno
2026-07-09 11:53   ` sashiko-bot
2026-08-28  6:17   ` CK Hu (胡俊光)
2026-07-09 11:31 ` [PATCH v4 10/12] drm/mediatek: mtk_dp: Add support for HotPlug Detection in DP AUX AngeloGioacchino Del Regno
2026-07-09 12:00   ` sashiko-bot
2026-07-09 12:05     ` AngeloGioacchino Del Regno
2026-08-28  6:48   ` CK Hu (胡俊光)
2026-07-09 11:31 ` [PATCH v4 11/12] drm/mediatek: mtk_dp: Add support for eDP1.5 IPs and MT8196 SoC AngeloGioacchino Del Regno
2026-07-09 12:11   ` sashiko-bot
2026-07-09 12:17     ` AngeloGioacchino Del Regno
2026-08-28  7:13   ` CK Hu (胡俊光)
2026-07-09 11:31 ` [PATCH v4 12/12] drm/mediatek: mtk_dp: Clarify XTAL freq and Debounce registers AngeloGioacchino Del Regno
2026-07-09 11:57   ` sashiko-bot
2026-08-28  8:33   ` CK Hu (胡俊光)

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=628ec3f674815dcdc85c5cf6d81ffa9da9a178fc.camel@mediatek.com \
    --to=ck.hu@mediatek.com \
    --cc=Jason-JH.Lin@mediatek.com \
    --cc=Justin.Yeh@mediatek.com \
    --cc=Rex-BC.Chen@mediatek.com \
    --cc=airlied@gmail.com \
    --cc=amergnat@baylibre.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=chunkuang.hu@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.osipenko@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=granquet@baylibre.com \
    --cc=jitao.shi@mediatek.com \
    --cc=kernel@collabora.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=matthias.bgg@gmail.com \
    --cc=mripard@kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.