sun6i_dsi_attach() only accepts the panel once the DRM device is registered, and returns -EPROBE_DEFER until then. By that time the connector can no longer get a "panel orientation" property: it has to be attached before registration. The fbdev emulation is also set up from the hotplug event of the attach, so it gets no rotation hint either.
As a result the rotation property of a DSI panel on these SoCs is ignored: on the PocketGo S30 (A33, 320x480 panel mounted for landscape use, rotation = <270>) the console and the boot splash stay in portrait. The panel is a child node of the DSI host, so read its orientation from the device tree when binding, before the device is registered, and set it on the connector then. Signed-off-by: Romain TISSERAND <[email protected]> --- Notes: - Testing: built with W=1 for arm (multi_v7_defconfig, DRM_SUN6I_DSI=y and =m) and arm64 (defconfig, =m), no warnings. Tested on a PocketGo S30 (A33, ILI9488 DSI panel, rotation = <270>): on 6.18.54 with the same change (6.18 still calls the helper of_drm_get_panel_orientation()) the console and plymouth come up in landscape, where they were in portrait; on 7.3.1 with this patch the DSI connector reports "panel orientation" = "Left Side Up". Not tested on other boards; boards without a rotation property keep the current behaviour (no property is attached). - Tool disclosure: this patch was prepared with Claude Opus 5.5 (Anthropic) as a coding assistant, in an interactive session where I asked it to fix the console orientation on the PocketGo S30. It traced why the connector never got the orientation, wrote the change and the message. I reviewed and understand it, and tested it as described. drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index d504ae5832..1eb8a4cde0 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -22,6 +22,7 @@ #include <drm/drm_atomic_helper.h> #include <drm/drm_encoder.h> #include <drm/drm_mipi_dsi.h> +#include <drm/drm_of.h> #include <drm/drm_panel.h> #include <drm/drm_print.h> #include <drm/drm_probe_helper.h> @@ -1055,6 +1056,31 @@ static const struct regmap_config sun6i_dsi_regmap_config = { .name = "mipi-dsi", }; +/* + * The panel only attaches once the DRM device is registered, too late to + * give the connector its orientation (the property cannot be added after + * registration), so fbcon and the boot splash would not rotate. Read the + * orientation from the panel node, a child of the DSI node, at bind time. + */ +static void sun6i_dsi_set_panel_orientation(struct sun6i_dsi *dsi) +{ + enum drm_panel_orientation orientation; + struct device_node *np; + + for_each_available_child_of_node(dsi->dev->of_node, np) { + if (of_node_name_eq(np, "port") || of_node_name_eq(np, "ports")) + continue; + + if (!drm_of_get_panel_orientation(np, &orientation) && + orientation != DRM_MODE_PANEL_ORIENTATION_UNKNOWN) { + drm_connector_set_panel_orientation(&dsi->connector, + orientation); + of_node_put(np); + return; + } + } +} + static int sun6i_dsi_bind(struct device *dev, struct device *master, void *data) { @@ -1085,6 +1111,8 @@ static int sun6i_dsi_bind(struct device *dev, struct device *master, drm_connector_attach_encoder(&dsi->connector, &dsi->encoder); + sun6i_dsi_set_panel_orientation(dsi); + dsi->drm = drm; return 0; base-commit: a1e63ab695ad76850ab9787b9eb6aab695dc2965 -- 2.43.0
