On Sun, Nov 15, 2026 at 2:11 PM Jernej Skrabec <[email protected]> wrote:
>
> The shared plane driver and split register resources are now in place.
> Switch DE33 mixer discovery to the new bindings and remove the legacy
> per-mixer plane setup. Mixer register space now covers only display
> blending control, so limit its regmap accordingly.
>
> The old DE33 binding is not supported anymore, since it can't describe
> shared planes and was never used by any device tree. If it's detected,
> print an error asking the user to update the device tree, instead of
> failing silently or misusing the plane register space as blender
> registers.
>
> Signed-off-by: Jernej Skrabec <[email protected]>
> ---
>  drivers/gpu/drm/sun4i/sun8i_mixer.c | 195 ++++++++++++++++++++--------
>  drivers/gpu/drm/sun4i/sun8i_mixer.h |  10 +-
>  2 files changed, 140 insertions(+), 65 deletions(-)
>
> diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.c 
> b/drivers/gpu/drm/sun4i/sun8i_mixer.c
> index dbde80b32080..0970be6aa035 100644
> --- a/drivers/gpu/drm/sun4i/sun8i_mixer.c
> +++ b/drivers/gpu/drm/sun4i/sun8i_mixer.c
> @@ -13,6 +13,7 @@
>  #include <linux/of.h>
>  #include <linux/of_device.h>
>  #include <linux/of_graph.h>
> +#include <linux/of_platform.h>
>  #include <linux/platform_device.h>
>  #include <linux/reset.h>
>
> @@ -25,6 +26,7 @@
>  #include <drm/drm_probe_helper.h>
>
>  #include "sun4i_drv.h"
> +#include "sun50i_planes.h"

Nit: doesn't seem to follow the order we use elsewhere. I think we normally
would do:

    sun4i_drv.h
    sun8i_*
    sun50i_planes.h

>  #include "sun8i_mixer.h"
>  #include "sun8i_ui_layer.h"
>  #include "sun8i_vi_layer.h"

[...]

> @@ -566,12 +582,34 @@ static int sun8i_mixer_bind(struct device *dev, struct 
> device *master,
>         if (!mixer->cfg)
>                 return -EINVAL;
>
> +       if (mixer->cfg->de_type == SUN8I_MIXER_DE33) {
> +               /*
> +                * The original DE33 binding described planes as part of
> +                * the mixer, which can't work with more than one mixer.
> +                * It was never used by any device tree, so it's not
> +                * supported.
> +                */
> +               if (of_property_match_string(dev->of_node, "reg-names",
> +                                            "layers") >= 0 ||

No need to wrap this bit.

> +                   !of_property_present(dev->of_node, "allwinner,planes"))
> +                       return dev_err_probe(dev, -EINVAL,
> +                                            "Unsupported DE33 mixer binding, 
> please update the device tree\n");
> +
> +               mixer->engine.ops = &sun50i_engine_ops;
> +       } else {
> +               mixer->engine.ops = &sun8i_engine_ops;
> +       }
> +
>         regs = devm_platform_ioremap_resource(pdev, 0);
>         if (IS_ERR(regs))
>                 return PTR_ERR(regs);
>
> -       mixer->engine.regs = devm_regmap_init_mmio(dev, regs,
> -                                                  
> &sun8i_mixer_regmap_config);
> +       if (mixer->cfg->de_type == SUN8I_MIXER_DE33)
> +               mixer->engine.regs = devm_regmap_init_mmio(dev, regs,
> +                                                          
> &sun50i_mixer33_regmap_config);
> +       else
> +               mixer->engine.regs = devm_regmap_init_mmio(dev, regs,
> +                                                          
> &sun8i_mixer_regmap_config);

At some point we need to move most of the bind function to the probe function.
None of the devm_* stuff gets released if the bind function fails.

We can also switch to the combined devm_* helpers for clks and resets.

>         if (IS_ERR(mixer->engine.regs)) {
>                 dev_err(dev, "Couldn't create the mixer regmap\n");
>                 return PTR_ERR(mixer->engine.regs);
> @@ -588,17 +626,6 @@ static int sun8i_mixer_bind(struct device *dev, struct 
> device *master,
>                         dev_err(dev, "Couldn't create the top regmap\n");
>                         return PTR_ERR(mixer->top_regs);
>                 }
> -
> -               regs = devm_platform_ioremap_resource_byname(pdev, "display");
> -               if (IS_ERR(regs))
> -                       return PTR_ERR(regs);
> -
> -               mixer->disp_regs = devm_regmap_init_mmio(dev, regs,
> -                                                        
> &sun8i_disp_regmap_config);
> -               if (IS_ERR(mixer->disp_regs)) {
> -                       dev_err(dev, "Couldn't create the disp regmap\n");
> -                       return PTR_ERR(mixer->disp_regs);
> -               }
>         }
>
>         mixer->reset = devm_reset_control_get(dev, NULL);
> @@ -638,6 +665,40 @@ static int sun8i_mixer_bind(struct device *dev, struct 
> device *master,
>
>         clk_prepare_enable(mixer->mod_clk);
>
> +       if (mixer->cfg->de_type == SUN8I_MIXER_DE33) {
> +               struct platform_device *pdev;
> +               struct device_link *link;
> +               struct device_node *np;
> +               void *data;
> +
> +               np = of_parse_phandle(dev->of_node, "allwinner,planes", 0);
> +               if (!np) {
> +                       ret = -ENODEV;
> +                       goto err_disable_mod_clk;
> +               }
> +
> +               pdev = of_find_device_by_node(np);
> +               of_node_put(np);
> +               if (!pdev) {
> +                       ret = -EPROBE_DEFER;
> +                       goto err_disable_mod_clk;
> +               }
> +               mixer->planes_dev = &pdev->dev;
> +
> +               data = platform_get_drvdata(pdev);
> +               if (!data) {

"device_is_bound(&pdev->dev)" is probably more straightforward.

> +                       ret = -EPROBE_DEFER;
> +                       goto err_put_device;
> +               }
> +
> +               link = device_link_add(dev, &pdev->dev,
> +                                      DL_FLAG_AUTOREMOVE_CONSUMER);
> +               if (!link) {
> +                       ret = -EINVAL;
> +                       goto err_put_device;
> +               }
> +       }
> +
>         list_add_tail(&mixer->engine.list, &drv->engine_list);
>
>         /* Reset registers and disable unused sub-engines */
> @@ -672,6 +733,10 @@ static int sun8i_mixer_bind(struct device *dev, struct 
> device *master,
>
>         return 0;
>
> +err_put_device:
> +       put_device(mixer->planes_dev);

Should you have matching "if (mixer->cfg->de_type == SUN8I_MIXER_DE33)"
like in the .unbind callback?

Once fixed,


Reviewed-by: Chen-Yu Tsai <[email protected]>

Reply via email to