mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michal Wilczynski <m.wilczynski@samsung.com>
To: Neil Armstrong <neil.armstrong@linaro.org>,
	 Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	 Andrzej Hajda <andrzej.hajda@intel.com>,
	Robert Foss <rfoss@kernel.org>,
	 Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	 Jonas Karlman <jonas@kwiboo.se>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	 Luca Ceresoli <luca.ceresoli@bootlin.com>,
	 Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	 Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	 Philipp Zabel <p.zabel@pengutronix.de>,
	 Emil Renner Berthing <kernel@esmil.dk>,
	 Hal Feng <hal.feng@starfivetech.com>,
	Heiko Stuebner <heiko@sntech.de>,  Paul Walmsley <pjw@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	 Albert Ou <aou@eecs.berkeley.edu>,
	Alexandre Ghiti <alex@ghiti.fr>,
	 Dominique Belhachemi <db@domibel.de>,
	Andy Yan <andyshrk@163.com>,  David Airlie <airlied@gmail.com>,
	Simona Vetter <simona@ffwll.ch>,
	 Yakir Yang <kuankuan.y@gmail.com>,
	 Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
	 Michal Wilczynski <m.wilczynski@samsung.com>,
	 Conor Dooley <conor@kernel.org>,
	William Qiu <william.qiu@starfivetech.com>,
	 Xingyu Wu <xingyu.wu@starfivetech.com>,
	Sandy Huang <hjc@rock-chips.com>,
	 Manivannan Sadhasivam <mani@kernel.org>
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org,
	linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org,
	linux-riscv@lists.infradead.org,
	"Marek Szyprowski" <m.szyprowski@samsung.com>,
	"Maud Spierings" <maud_spierings@murena.io>,
	"Graham Markall" <hello@big-grey.co.uk>,
	"Icenowy Zheng" <zhengxingda@iscas.ac.cn>,
	"Chaoyi Chen" <chaoyi.chen@rock-chips.com>,
	"Joshua Peisach" <jpeisach@ubuntu.com>,
	"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
	"Cristian Ciocaltea" <cristian.ciocaltea@collabora.com>
Subject: [PATCH v7 09/19] drm/bridge: inno-hdmi: Use a regmap for register access
Date: Fri, 06 Nov 2026 14:58:43 +0100	[thread overview]
Message-ID: <20261106-jh7110-clean-send-v7-9-68f7ea9913db@samsung.com> (raw)
In-Reply-To: <20261106-jh7110-clean-send-v7-0-68f7ea9913db@samsung.com>

On some SoCs the HDMI controller does not own its register window. The
StarFive JH7110 documents one 64 KB block, u0_hdmitx, that holds both
the controller and the PHY, so the parent device maps it and owns the
regmap while the two children share it.

Access the registers through a regmap. Use the one supplied by the
parent device when there is one, and otherwise create an MMIO regmap
over our own resource. The MMIO regmap uses 32-bit accesses with a
4-byte stride, matching the readl_relaxed() and writel_relaxed() calls
it replaces, so the Rockchip platforms see the same register accesses.

Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
---
 drivers/gpu/drm/bridge/Kconfig     |  1 +
 drivers/gpu/drm/bridge/inno-hdmi.c | 39 ++++++++++++++++++++++++++++++++------
 2 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index c7da6b02d7b6b281f328fb3016ea2f167f8da093..34bcee88170317a4796178452ab5d2e673daf1fd 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -105,6 +105,7 @@ config DRM_INNO_HDMI
 	select DRM_DISPLAY_HDMI_HELPER
 	select DRM_DISPLAY_HELPER
 	select DRM_KMS_HELPER
+	select REGMAP_MMIO
 
 config DRM_ITE_IT6263
 	tristate "ITE IT6263 LVDS/HDMI bridge"
diff --git a/drivers/gpu/drm/bridge/inno-hdmi.c b/drivers/gpu/drm/bridge/inno-hdmi.c
index aa64ffdbd30721603aebbcd5d5747851be789911..05007ed1d7af0b0f72721a0fd4def08fa621b525 100644
--- a/drivers/gpu/drm/bridge/inno-hdmi.c
+++ b/drivers/gpu/drm/bridge/inno-hdmi.c
@@ -396,7 +396,7 @@ struct inno_hdmi {
 	struct drm_bridge bridge;
 	struct clk *pclk;
 	struct clk *refclk;
-	void __iomem *regs;
+	struct regmap *regmap;
 	struct regmap *grf;
 
 	struct inno_hdmi_i2c *i2c;
@@ -468,14 +468,25 @@ static int inno_hdmi_find_phy_config(struct inno_hdmi *hdmi,
 	return -EINVAL;
 }
 
+static const struct regmap_config inno_hdmi_regmap_config = {
+	.reg_bits = 32,
+	.val_bits = 32,
+	.reg_stride = 4,
+};
+
 static inline u8 hdmi_readb(struct inno_hdmi *hdmi, u16 offset)
 {
-	return readl_relaxed(hdmi->regs + (offset) * 0x04);
+	u32 val;
+
+	if (regmap_read(hdmi->regmap, offset * 4, &val))
+		return 0;
+
+	return val;
 }
 
 static inline void hdmi_writeb(struct inno_hdmi *hdmi, u16 offset, u32 val)
 {
-	writel_relaxed(val, hdmi->regs + (offset) * 0x04);
+	regmap_write(hdmi->regmap, offset * 4, val);
 }
 
 static inline void hdmi_modb(struct inno_hdmi *hdmi, u16 offset,
@@ -1082,6 +1093,7 @@ struct inno_hdmi *inno_hdmi_probe(struct platform_device *pdev,
 {
 	struct device *dev = &pdev->dev;
 	struct inno_hdmi *hdmi;
+	void __iomem *regs;
 	int irq;
 	int ret;
 
@@ -1097,9 +1109,24 @@ struct inno_hdmi *inno_hdmi_probe(struct platform_device *pdev,
 	hdmi->dev = dev;
 	hdmi->plat_data = plat_data;
 
-	hdmi->regs = devm_platform_ioremap_resource(pdev, 0);
-	if (IS_ERR(hdmi->regs))
-		return ERR_CAST(hdmi->regs);
+	/*
+	 * On platforms where the controller shares a register space with
+	 * other blocks, the parent owns the regmap. Otherwise map our own
+	 * resource.
+	 */
+	if (dev->parent)
+		hdmi->regmap = dev_get_regmap(dev->parent, NULL);
+
+	if (!hdmi->regmap) {
+		regs = devm_platform_ioremap_resource(pdev, 0);
+		if (IS_ERR(regs))
+			return ERR_CAST(regs);
+
+		hdmi->regmap = devm_regmap_init_mmio(dev, regs,
+						     &inno_hdmi_regmap_config);
+		if (IS_ERR(hdmi->regmap))
+			return ERR_CAST(hdmi->regmap);
+	}
 
 	hdmi->pclk = devm_clk_get_enabled(hdmi->dev, "pclk");
 	if (IS_ERR(hdmi->pclk)) {

-- 
2.34.1


  parent reply	other threads:[~2026-11-06 13:59 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20261106135849eucas1p242718d72fa1f38e31477210fd9ee30bc@eucas1p2.samsung.com>
2026-11-06 13:58 ` [PATCH v7 00/19] drm: starfive: jh7110: Enable display subsystem Michal Wilczynski
     [not found]   ` <CGME20261106135851eucas1p29a537bb4785f0a187619958bced510ec@eucas1p2.samsung.com>
2026-11-06 13:58     ` [PATCH v7 01/19] drm/bridge: inno-hdmi: fix swapped HSYNC and VSYNC polarity Michal Wilczynski
     [not found]   ` <CGME20261106135853eucas1p2881daeedcd9c5257f07cd5942b62cb9b@eucas1p2.samsung.com>
2026-11-06 13:58     ` [PATCH v7 02/19] drm/bridge: inno-hdmi: Don't dereference a NULL drm_device on hotplug Michal Wilczynski
     [not found]   ` <CGME20261106135855eucas1p141de720b324f4deb00c73981ffef51f7@eucas1p1.samsung.com>
2026-11-06 13:58     ` [PATCH v7 03/19] dt-bindings: display: bridge: Add starfive,jh7110-inno-hdmi-controller Michal Wilczynski
     [not found]   ` <CGME20261106135857eucas1p2a125bd1549caee008efe88b077873e69@eucas1p2.samsung.com>
2026-11-06 13:58     ` [PATCH v7 04/19] dt-bindings: display: starfive: Add starfive,jh7110-hdmi-subsystem Michal Wilczynski
     [not found]   ` <CGME20261106135858eucas1p25582287f0bc6486b39942f025fecabf6@eucas1p2.samsung.com>
2026-11-06 13:58     ` [PATCH v7 05/19] dt-bindings: soc: starfive: Add starfive,jh7110-vout-syscon Michal Wilczynski
     [not found]   ` <CGME20261106135900eucas1p17159021cc747335b62cad6b3326605be@eucas1p1.samsung.com>
2026-11-06 13:58     ` [PATCH v7 06/19] dt-bindings: display: verisilicon: Add starfive,jh7110-dc8200 Michal Wilczynski
     [not found]   ` <CGME20261106135902eucas1p1d8900fa2623e3230e42a67072602562d@eucas1p1.samsung.com>
2026-11-06 13:58     ` [PATCH v7 07/19] dt-bindings: display: starfive: Add starfive,jh7110-vout-subsystem Michal Wilczynski
     [not found]   ` <CGME20261106135904eucas1p14897dcc411c444d202a38190fdffffe7@eucas1p1.samsung.com>
2026-11-06 13:58     ` [PATCH v7 08/19] drm/bridge: inno-hdmi: Split probe out of bind Michal Wilczynski
     [not found]   ` <CGME20261106135906eucas1p2c3d4a479c32e76358b3421ad18669af1@eucas1p2.samsung.com>
2026-11-06 13:58     ` Michal Wilczynski [this message]
     [not found]   ` <CGME20261106135908eucas1p1327e42a8b4f0367d55353dae77307708@eucas1p1.samsung.com>
2026-11-06 13:58     ` [PATCH v7 10/19] drm/bridge: inno-hdmi: Add .disable platform operation Michal Wilczynski
     [not found]   ` <CGME20261106135910eucas1p2a31e2ed16ef7943a93a53077b539b1c5@eucas1p2.samsung.com>
2026-11-06 13:58     ` [PATCH v7 11/19] drm/bridge: inno-hdmi: Add .mode_valid " Michal Wilczynski
     [not found]   ` <CGME20261106135912eucas1p182016acc39d162adfbb9cb598ed7ca1c@eucas1p1.samsung.com>
2026-11-06 13:58     ` [PATCH v7 12/19] drm/bridge: inno-hdmi: Make the PHY configuration table optional Michal Wilczynski
     [not found]   ` <CGME20261106135915eucas1p23a8fabb523d860d913831836c240837e@eucas1p2.samsung.com>
2026-11-06 13:58     ` [PATCH v7 13/19] drm/bridge: inno-hdmi: Make the register clock source selectable Michal Wilczynski
     [not found]   ` <CGME20261106135917eucas1p260b4a7f05f2787a46d7282ede885401f@eucas1p2.samsung.com>
2026-11-06 13:58     ` [PATCH v7 14/19] drm/bridge: inno-hdmi: Make the supported HDMI version selectable Michal Wilczynski
     [not found]   ` <CGME20261106135918eucas1p1a3d7684adcefdc624b9748469d07e88c@eucas1p1.samsung.com>
2026-11-06 13:58     ` [PATCH v7 15/19] soc: starfive: Add jh7110-hdmi-subsystem driver Michal Wilczynski
     [not found]   ` <CGME20261106135921eucas1p1193f0f620b8b86512ea678919f664194@eucas1p1.samsung.com>
2026-11-06 13:58     ` [PATCH v7 16/19] soc: starfive: Add jh7110-vout-subsystem driver Michal Wilczynski
     [not found]   ` <CGME20261106135922eucas1p1c1bbe20725aff455ed61806af734baa5@eucas1p1.samsung.com>
2026-11-06 13:58     ` [PATCH v7 17/19] drm/bridge: starfive: Add JH7110 HDMI controller driver Michal Wilczynski
     [not found]   ` <CGME20261106135924eucas1p17cd8d0880486f9e932fe1b81ba3eeaf6@eucas1p1.samsung.com>
2026-11-06 13:58     ` [PATCH v7 18/19] riscv: dts: starfive: jh7110: Update DT for display subsystem Michal Wilczynski
     [not found]   ` <CGME20261106135926eucas1p2de40819f5e8307219ae80a96341c90f5@eucas1p2.samsung.com>
2026-11-06 13:58     ` [PATCH v7 19/19] MAINTAINERS: Add StarFive JH7110 display subsystem entry Michal Wilczynski
2026-11-06 19:48   ` [PATCH v7 00/19] drm: starfive: jh7110: Enable display subsystem Owen O'Hehir

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=20261106-jh7110-clean-send-v7-9-68f7ea9913db@samsung.com \
    --to=m.wilczynski@samsung.com \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=airlied@gmail.com \
    --cc=alex@ghiti.fr \
    --cc=andrzej.hajda@intel.com \
    --cc=andyshrk@163.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=chaoyi.chen@rock-chips.com \
    --cc=conor@kernel.org \
    --cc=cristian.ciocaltea@collabora.com \
    --cc=db@domibel.de \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hal.feng@starfivetech.com \
    --cc=heiko@sntech.de \
    --cc=hello@big-grey.co.uk \
    --cc=hjc@rock-chips.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=jpeisach@ubuntu.com \
    --cc=kernel@esmil.dk \
    --cc=krzk+dt@kernel.org \
    --cc=kuankuan.y@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=luca.ceresoli@bootlin.com \
    --cc=m.szyprowski@samsung.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mani@kernel.org \
    --cc=maud_spierings@murena.io \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=p.zabel@pengutronix.de \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=rfoss@kernel.org \
    --cc=robh@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    --cc=u.kleine-koenig@baylibre.com \
    --cc=william.qiu@starfivetech.com \
    --cc=xingyu.wu@starfivetech.com \
    --cc=zhengxingda@iscas.ac.cn \
    /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

all inboxes | Powered by JetHome®