Am Donnerstag, 29. Oktober 2026, 08:53:43 Mitteleuropäische Normalzeit schrieb 
Michal Wilczynski:
> 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.
> 
> Use a regmap supplied by the parent device when there is one, and keep
> mapping our own resource when there is not, so platforms that own their
> register window are unaffected.
> 
> Reviewed-by: Joshua Peisach <[email protected]>
> Tested-by: Byron Stanoszek <[email protected]>
> Tested-by: OOHehir <[email protected]>
> Signed-off-by: Michal Wilczynski <[email protected]>
> ---
>  drivers/gpu/drm/bridge/inno-hdmi.c | 31 ++++++++++++++++++++++++++++---
>  1 file changed, 28 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/inno-hdmi.c 
> b/drivers/gpu/drm/bridge/inno-hdmi.c
> index 
> 222f6522844ee60ae9a07ab2dcca748dbf7403e4..a8905bf627a224d7e3918514195f1810164dc26f
>  100644
> --- a/drivers/gpu/drm/bridge/inno-hdmi.c
> +++ b/drivers/gpu/drm/bridge/inno-hdmi.c
> @@ -397,6 +397,7 @@ struct inno_hdmi {
>       struct clk *pclk;
>       struct clk *refclk;
>       void __iomem *regs;
> +     struct regmap *regmap;
>       struct regmap *grf;
>  
>       struct inno_hdmi_i2c *i2c;
> @@ -470,11 +471,25 @@ static int inno_hdmi_find_phy_config(struct inno_hdmi 
> *hdmi,
>  
>  static inline u8 hdmi_readb(struct inno_hdmi *hdmi, u16 offset)
>  {
> +     u32 val;
> +
> +     if (hdmi->regmap) {
> +             if (regmap_read(hdmi->regmap, offset * 4, &val))
> +                     return 0;
> +
> +             return val;
> +     }
> +
>       return readl_relaxed(hdmi->regs + (offset) * 0x04);
>  }
>  
>  static inline void hdmi_writeb(struct inno_hdmi *hdmi, u16 offset, u32 val)
>  {
> +     if (hdmi->regmap) {
> +             regmap_write(hdmi->regmap, offset * 4, val);
> +             return;
> +     }
> +
>       writel_relaxed(val, hdmi->regs + (offset) * 0x04);
>  }
>  
> @@ -1101,9 +1116,19 @@ 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. Fall back to mapping
> +      * our own resource where it does not.
> +      */
> +     if (dev->parent)
> +             hdmi->regmap = dev_get_regmap(dev->parent, NULL);
> +
> +     if (!hdmi->regmap) {
> +             hdmi->regs = devm_platform_ioremap_resource(pdev, 0);
> +             if (IS_ERR(hdmi->regs))
> +                     return ERR_CAST(hdmi->regs);
> +     }

why can't you just also use a mmio regmap here? Because with this change
the driver now has 2 competing register interfaces and you need those
conditionals all the time.

Just convert the existing user to also use a regmap please.


Heiko



Reply via email to