diff --git a/arch/arm64/boot/dts/apple/s800x-6s.dtsi b/arch/arm64/boot/dts/apple/s800x-6s.dtsi index c5224126cb8b4b..efc1c84850565e 100644 --- a/arch/arm64/boot/dts/apple/s800x-6s.dtsi +++ b/arch/arm64/boot/dts/apple/s800x-6s.dtsi @@ -289,6 +289,15 @@ power-domains = <&ps_disp0 &ps_mipi_dsi>; }; +/* + * The backlight goes off and on with the pipe. It does not hold up the pipe's + * probe: the driver looks it up when the pipe is next enabled or disabled. + */ +&disp0 { + backlight = <&dwi_bl>; + post-init-providers = <&dwi_bl>; +}; + &i2c0 { status = "okay"; diff --git a/drivers/gpu/drm/adbe/adbe_drv.c b/drivers/gpu/drm/adbe/adbe_drv.c index aadb6128c4c129..cc527669a7db9b 100644 --- a/drivers/gpu/drm/adbe/adbe_drv.c +++ b/drivers/gpu/drm/adbe/adbe_drv.c @@ -1112,11 +1112,36 @@ static void adbe_dsi_panel_set(struct adbe *adbe, bool on) } } +static void adbe_panel_attach(struct adbe *adbe); +static bool adbe_backlight_find(struct adbe *adbe); + +/* + * The backlight follows the pipe: off when the CRTC goes off (a compositor's + * DPMS off, a power-down fbdev blank: this kernel has no FB_BACKLIGHT), on + * when it comes back. A backlight held off after a failed panel wake stays + * off. Never under panel_lock: suspend and resume take it around, not + * inside, the CRTC's disable and enable. + */ +static void adbe_backlight_set(struct adbe *adbe, bool on) +{ + mutex_lock(&adbe->panel_lock); + adbe_panel_attach(adbe); + adbe_backlight_find(adbe); + if (adbe->backlight && !adbe->bl_held) { + if (on) + backlight_enable(adbe->backlight); + else + backlight_disable(adbe->backlight); + } + mutex_unlock(&adbe->panel_lock); +} + static void adbe_crtc_atomic_enable(struct drm_crtc *crtc, struct drm_atomic_commit *state) { drm_crtc_vblank_on(crtc); adbe_dsi_panel_set(to_adbe(crtc->dev), true); + adbe_backlight_set(to_adbe(crtc->dev), true); } static void adbe_crtc_atomic_disable(struct drm_crtc *crtc, @@ -1126,6 +1151,7 @@ static void adbe_crtc_atomic_disable(struct drm_crtc *crtc, struct drm_pending_vblank_event *done; unsigned long flags; + adbe_backlight_set(adbe, false); timer_delete_sync(&adbe->flip_timer); spin_lock_irqsave(&crtc->dev->event_lock, flags); done = adbe->event; @@ -2450,6 +2476,36 @@ static int adbe_link_train(struct adbe *adbe) return ret; } +/* + * Under panel_lock: the backlight the "backlight" phandle names. False while + * it has not registered yet. Boards without a panel supply (the MIPI DSI + * panels) have one too, so this does not depend on the DisplayPort window. + */ +static bool adbe_backlight_find(struct adbe *adbe) +{ + struct device *dev = adbe->drm.dev; + struct device_node *np; + + if (adbe->bl_link) + return true; + np = of_parse_phandle(dev->of_node, "backlight", 0); + if (!np) + return true; + adbe->backlight = of_find_backlight_by_node(np); + of_node_put(np); + if (!adbe->backlight) + return false; + adbe->bl_link = device_link_add(&adbe->backlight->dev, dev, + DL_FLAG_STATELESS); + if (!adbe->bl_link) { + dev_warn(dev, "cannot order the backlight after the panel\n"); + put_device(&adbe->backlight->dev); + adbe->backlight = NULL; + return false; + } + return true; +} + /* * Look up the panel supply and the backlight once, before the first sleep, * and order system sleep: the display pipe suspends before the PMU GPIO @@ -2459,7 +2515,6 @@ static int adbe_link_train(struct adbe *adbe) static void adbe_panel_attach(struct adbe *adbe) { struct device *dev = adbe->drm.dev; - struct device_node *np; struct gpio_desc *ldo; if (adbe->panel_ready || !adbe->dp) @@ -2487,24 +2542,8 @@ static void adbe_panel_attach(struct adbe *adbe) } } - np = of_parse_phandle(dev->of_node, "backlight", 0); - if (np && !adbe->bl_link) { - adbe->backlight = of_find_backlight_by_node(np); - if (!adbe->backlight) { - of_node_put(np); - return; /* not registered yet: next sleep */ - } - adbe->bl_link = device_link_add(&adbe->backlight->dev, dev, - DL_FLAG_STATELESS); - if (!adbe->bl_link) { - dev_warn(dev, "cannot order the backlight after the panel\n"); - put_device(&adbe->backlight->dev); - adbe->backlight = NULL; - of_node_put(np); - return; - } - } - of_node_put(np); + if (!adbe_backlight_find(adbe)) + return; /* not registered yet: next sleep */ adbe->panel_ready = true; }