Skip to contentSkip to conversation

drm/panel: atna33xc20: Fix the Samsung ATNA33XC20 panel

PATCH In review Douglas Anderson 2 participants 9 messages Jul 30, 2021 – Jul 31, 2021

Subsystems (6)
lore
Share & tools
lore

Douglas Anderson

author reviewer
#0 lore raw

v2 cover drm/panel: atna33xc20: Fix the Samsung ATNA33XC20 panel

The overall goal of this series is to make the Samsung ATNA33XC20 panel work more properly. As part of this, we have:
* A bugfix for the recently abstracted DP AUX backlight code.
* A bugfix for the sequencing of the ti-sn65dsi86 bridge driver.
* Removal of the panel from panel-simple and moving it to its own driver.

If the bugfixes look good but the rest of the series needs work then those could land early on their own. There's no real compile time dependency on the bugfixes, things are just glitchier without them.

NOTE: this series will (slightly) conflict with my other recent series making eDP panels probable [1]. I'll re-post that one atop this one. It should be noted that the fact that the Samsung ATNA33XC20 needs its own panel driver means that it _can't_ handled as a probed driver. I think this is fine, at least for now. I don't think it would be easy to make a unified design with this panel and other panels given that it's an AMOLED panel and has a whole bunch of different components on board.

As discussed in IRC, the only difference in v2 is the addition of a "Fixes" tag to patch #3 and the collection of Reviews/Acks from Sean and Robert.

If people feel that this is ready to land today then I can help land it (please let me know). Otherwise I'm happy for someone else to actually do the commit next week (I'm on vacation) or I can take it when I get back.

[1] https://lore.kernel.org/r/[email protected]/

Changes in v2:
- Added Fixes tag as requested by Sam.

Douglas Anderson (6):
drm/dp: Don't zero PWMGEN_BIT_COUNT when driver_pwm_freq_hz not
specified
drm/bridge: ti-sn65dsi86: Fix power off sequence drm/bridge: ti-sn65dsi86: Add some 100 us delays
Revert "drm/panel-simple: Add Samsung ATNA33XC20"
Revert "drm/panel-simple: Support for delays between GPIO & regulator" drm/panel: atna33xc20: Introduce the Samsung ATNA33XC20 panel

 drivers/gpu/drm/bridge/ti-sn65dsi86.c         |  17 +-
 drivers/gpu/drm/drm_dp_helper.c               |  10 +-
 drivers/gpu/drm/panel/Kconfig                 |  12 +
 drivers/gpu/drm/panel/Makefile                |   1 +
 .../gpu/drm/panel/panel-samsung-atna33xc20.c  | 366 ++++++++++++++++++
 drivers/gpu/drm/panel/panel-simple.c          |  61 ---
 6 files changed, 398 insertions(+), 69 deletions(-)
 create mode 100644 drivers/gpu/drm/panel/panel-samsung-atna33xc20.c
Signature · 1 line
2.32.0.554.ge1b32706d8-goog
author reviewer
#1 lore raw

PATCH v2 1/6 drm/dp: Don't zero PWMGEN_BIT_COUNT when driver_pwm_freq_hz not specified

The function drm_edp_backlight_init() is defined such that the "driver_pwm_freq_hz" parameter is optional--it's 0 if you don't want to futz with it. If you follow this variable through, you'll find out that if it's 0 we won't ever set the "bl->pwmgen_bit_count", leaving it as 0.

That means that before using it in drm_edp_backlight_enable() we need to check to see if it's non-zero.

Programming this field to zero was confusing the panel I tested with (Samsung ATNA33XC20). The backlight still worked somewhat but the brightness values didn't correspond to what they should have been.

Fixes 867cf9cd73c3 ("drm/dp: Extract i915's eDP backlight code into DRM helpers")

---

(no changes since v1)

 drivers/gpu/drm/drm_dp_helper.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_dp_helper.c +6 -4
index b5f75ca05774..b8a5c5e49d74 100644
@@ -3229,10 +3229,12 @@ int drm_edp_backlight_enable(struct drm_dp_aux *aux, const struct drm_edp_backli
 		new_dpcd_buf &= ~DP_EDP_BACKLIGHT_CONTROL_MODE_MASK;
 		new_dpcd_buf |= DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD;
 
-		ret = drm_dp_dpcd_writeb(aux, DP_EDP_PWMGEN_BIT_COUNT, bl->pwmgen_bit_count);
-		if (ret != 1)
-			drm_dbg_kms(aux->drm_dev, "%s: Failed to write aux pwmgen bit count: %d\n",
-				    aux->name, ret);
+		if (bl->pwmgen_bit_count) {
+			ret = drm_dp_dpcd_writeb(aux, DP_EDP_PWMGEN_BIT_COUNT, bl->pwmgen_bit_count);
+			if (ret != 1)
+				drm_dbg_kms(aux->drm_dev, "%s: Failed to write aux pwmgen bit count: %d\n",
+					aux->name, ret);
+		}
 	}
 
 	if (bl->pwm_freq_pre_divider) {
Signature · 1 line
2.32.0.554.ge1b32706d8-goog
author reviewer
#2 lore raw

PATCH v2 2/6 drm/bridge: ti-sn65dsi86: Fix power off sequence

In reply to Douglas Anderson

When testing with a panel that's apparently a little more persnickety about the correct power sequence (specifically Samsung ATNA33XC20), we found that the ti-sn65dsi86 was doing things just slightly wrong.

Looking closely at the ti-sn65dsi86's datasheet, the power off sequence is supposed to be:
1. Clear VSTREAM_ENABLE bit
2. Stop DSI stream from GPU. DSI lanes must be placed in LP11 state.
3. Program the ML_TX_MODE to 0x0 (OFF)
4. Program the DP_NUM_LANES register to 0x0
5. Clear the DP_PLL_EN bit.
6. Deassert the EN pin.
7. Remove power from supply pins

Since we were doing the whole sequence in the "disable", I believe that step #2 (stopping the DSI stream from the GPU) wasn't happening. We also weren't setting DP_NUM_LANES to 0.

Let's fix this.

NOTE: things are a little asymmetric now. For instance, we turn the PLL on in "enable" but now we're not turning it off until "post_disable". It would seem to make sense to move the PLL turning on to "pre_enable" to match. Unfortunately, I don't believe that's allowed. It looks as if (in the non-refclk mode which probably nobody is using) we have to wait until the MIPI clock is there before we can enable the PLL. In any case, the way it is here won't really hurt--it'll just leave the PLL on a little longer.

Fixes a095f15c00e2 ("drm/bridge: add support for sn65dsi86 bridge driver")

---

(no changes since v1)

 drivers/gpu/drm/bridge/ti-sn65dsi86.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/gpu/drm/bridge/ti-sn65dsi86.c +7 -4
index 9bf889302bcc..5e932070a1c3 100644
@@ -766,10 +766,6 @@ static void ti_sn_bridge_disable(struct drm_bridge *bridge)
 
 	/* disable video stream */
 	regmap_update_bits(pdata->regmap, SN_ENH_FRAME_REG, VSTREAM_ENABLE, 0);
-	/* semi auto link training mode OFF */
-	regmap_write(pdata->regmap, SN_ML_TX_MODE_REG, 0);
-	/* disable DP PLL */
-	regmap_write(pdata->regmap, SN_PLL_ENABLE_REG, 0);
 }
 
 static void ti_sn_bridge_set_dsi_rate(struct ti_sn65dsi86 *pdata)
@@ -1106,6 +1102,13 @@ static void ti_sn_bridge_post_disable(struct drm_bridge *bridge)
 {
 	struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge);
 
+	/* semi auto link training mode OFF */
+	regmap_write(pdata->regmap, SN_ML_TX_MODE_REG, 0);
+	/* Num lanes to 0 as per power sequencing in data sheet */
+	regmap_update_bits(pdata->regmap, SN_SSC_CONFIG_REG, DP_NUM_LANES_MASK, 0);
+	/* disable DP PLL */
+	regmap_write(pdata->regmap, SN_PLL_ENABLE_REG, 0);
+
 	if (!pdata->refclk)
 		ti_sn65dsi86_disable_comms(pdata);
 
Signature · 1 line
2.32.0.554.ge1b32706d8-goog
author reviewer
#3 lore raw

PATCH v2 3/6 drm/bridge: ti-sn65dsi86: Add some 100 us delays

In reply to Douglas Anderson

The manual has always said that we need 100 us delays in a few places. Though it hasn't seemed to be a big deal to skip these, let's add them in case it makes something happier.

NOTE: this fixes no known issues but it seems good to make it right.

Fixes a095f15c00e2 ("drm/bridge: add support for sn65dsi86 bridge driver")

---

Changes in v2:
- Added Fixes tag as requested by Sam.

 drivers/gpu/drm/bridge/ti-sn65dsi86.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/bridge/ti-sn65dsi86.c +6 -0
index 5e932070a1c3..cd0fccdd8dfd 100644
@@ -307,6 +307,9 @@ static int __maybe_unused ti_sn65dsi86_resume(struct device *dev)
 		return ret;
 	}
 
+	/* td2: min 100 us after regulators before enabling the GPIO */
+	usleep_range(100, 110);
+
 	gpiod_set_value(pdata->enable_gpio, 1);
 
 	/*
@@ -1096,6 +1099,9 @@ static void ti_sn_bridge_pre_enable(struct drm_bridge *bridge)
 
 	if (!pdata->refclk)
 		ti_sn65dsi86_enable_comms(pdata);
+
+	/* td7: min 100 us after enable before DSI data */
+	usleep_range(100, 110);
 }
 
 static void ti_sn_bridge_post_disable(struct drm_bridge *bridge)
Signature · 1 line
2.32.0.554.ge1b32706d8-goog
author reviewer
#4 lore raw

PATCH v2 4/6 Revert "drm/panel-simple: Add Samsung ATNA33XC20"

In reply to Douglas Anderson

This reverts commit 4bfe6c8f7c23b01719671b69fd29b87a35ccd9d6.

This panel's power sequencing really can't be handled properly by panel-simple because of the special sequencing needed for the EL_ON3 GPIO. The only way it was sorta working in the past was by trying to jam that signal into the "enable-gpio", but that really wasn't a good fit. We'll add a custom panel driver for this panel to do it right.

---

(no changes since v1)

 drivers/gpu/drm/panel/panel-simple.c | 33 ----------------------------
 1 file changed, 33 deletions(-)
drivers/gpu/drm/panel/panel-simple.c +0 -33
index 9b286bd4444f..c8694f7f8e0f 100644
@@ -3621,36 +3621,6 @@ static const struct panel_desc rocktech_rk101ii01d_ct = {
 	.connector_type = DRM_MODE_CONNECTOR_LVDS,
 };
 
-static const struct drm_display_mode samsung_atna33xc20_mode = {
-	.clock = 138770,
-	.hdisplay = 1920,
-	.hsync_start = 1920 + 48,
-	.hsync_end = 1920 + 48 + 32,
-	.htotal = 1920 + 48 + 32 + 80,
-	.vdisplay = 1080,
-	.vsync_start = 1080 + 8,
-	.vsync_end = 1080 + 8 + 8,
-	.vtotal = 1080 + 8 + 8 + 16,
-	.flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC,
-};
-
-static const struct panel_desc samsung_atna33xc20 = {
-	.modes = &samsung_atna33xc20_mode,
-	.num_modes = 1,
-	.bpc = 10,
-	.size = {
-		.width = 294,
-		.height = 165,
-	},
-	.delay = {
-		.disable_to_power_off = 200,
-		.power_to_enable = 400,
-		.hpd_absent_delay = 200,
-		.unprepare = 500,
-	},
-	.connector_type = DRM_MODE_CONNECTOR_eDP,
-};
-
 static const struct drm_display_mode samsung_lsn122dl01_c01_mode = {
 	.clock = 271560,
 	.hdisplay = 2560,
@@ -4657,9 +4627,6 @@ static const struct of_device_id platform_of_match[] = {
 	}, {
 		.compatible = "rocktech,rk101ii01d-ct",
 		.data = &rocktech_rk101ii01d_ct,
-	}, {
-		.compatible = "samsung,atna33xc20",
-		.data = &samsung_atna33xc20,
 	}, {
 		.compatible = "samsung,lsn122dl01-c01",
 		.data = &samsung_lsn122dl01_c01,
Signature · 1 line
2.32.0.554.ge1b32706d8-goog
author reviewer
#5 lore raw

PATCH v2 5/6 Revert "drm/panel-simple: Support for delays between GPIO & regulator"

In reply to Douglas Anderson

This reverts commit 18a1488bf1e13fc3fc96d7948466b2166067c6c8.

Those delays were added to support the Samsung ATNA33XC20 panel. However, we've moving that to its own panel driver and out of panel-simple. That means we don't need the ability to specify this delay.

NOTE: it's unlikely we want to keep this delay "just in case" some other panel needs it. The enable-gpio and the power supply are really supposed to be different ways to specify the same thing: the main enable of the panel. Supporting a delay between them doesn't really make sense.

---

(no changes since v1)

 drivers/gpu/drm/panel/panel-simple.c | 28 ----------------------------
 1 file changed, 28 deletions(-)
drivers/gpu/drm/panel/panel-simple.c +0 -28
index c8694f7f8e0f..ff8b59471c71 100644
@@ -132,22 +132,6 @@ struct panel_desc {
 		 */
 		unsigned int prepare_to_enable;
 
-		/**
-		 * @delay.power_to_enable: Time for the power to enable the display on.
-		 *
-		 * The time (in milliseconds) to wait after powering up the display
-		 * before asserting its enable pin.
-		 */
-		unsigned int power_to_enable;
-
-		/**
-		 * @delay.disable_to_power_off: Time for the disable to power the display off.
-		 *
-		 * The time (in milliseconds) to wait before powering off the display
-		 * after deasserting its enable pin.
-		 */
-		unsigned int disable_to_power_off;
-
 		/**
 		 * @delay.enable: Time for the panel to display a valid frame.
 		 *
@@ -363,10 +347,6 @@ static int panel_simple_suspend(struct device *dev)
 	struct panel_simple *p = dev_get_drvdata(dev);
 
 	gpiod_set_value_cansleep(p->enable_gpio, 0);
-
-	if (p->desc->delay.disable_to_power_off)
-		msleep(p->desc->delay.disable_to_power_off);
-
 	regulator_disable(p->supply);
 	p->unprepared_time = ktime_get();
 
@@ -427,9 +407,6 @@ static int panel_simple_prepare_once(struct panel_simple *p)
 		return err;
 	}
 
-	if (p->desc->delay.power_to_enable)
-		msleep(p->desc->delay.power_to_enable);
-
 	gpiod_set_value_cansleep(p->enable_gpio, 1);
 
 	delay = p->desc->delay.prepare;
@@ -803,11 +780,6 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc,
 		break;
 	}
 
-	if (!panel->enable_gpio && desc->delay.disable_to_power_off)
-		dev_warn(dev, "Need a delay after disabling panel GPIO, but a GPIO wasn't provided\n");
-	if (!panel->enable_gpio && desc->delay.power_to_enable)
-		dev_warn(dev, "Need a delay before enabling panel GPIO, but a GPIO wasn't provided\n");
-
 	dev_set_drvdata(dev, panel);
 
 	/*
Signature · 1 line
2.32.0.554.ge1b32706d8-goog
author reviewer
#6 lore raw

PATCH v2 6/6 drm/panel: atna33xc20: Introduce the Samsung ATNA33XC20 panel

In reply to Douglas Anderson

The Samsung ATNA33XC20 panel is an AMOLED eDP panel that has backlight control over the DP AUX channel.

This panel is _almost_ able to be controlled in a "simple" way (and it originally was implemented in panel-simple.c), but it's really impossible to get the backlight semantics right there without adding wacky special-case code to panel-simple. Let's give up and clone the parts of panel-simple that we need and implement the power sequence that this panel needs.

NOTE: we'll still leave the devicetree bindings alone. Even though the power-sequencing is non-standard the bindings are still "simple".

---

(no changes since v1)

 drivers/gpu/drm/panel/Kconfig                 |  12 +
 drivers/gpu/drm/panel/Makefile                |   1 +
 .../gpu/drm/panel/panel-samsung-atna33xc20.c  | 366 ++++++++++++++++++
 3 files changed, 379 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-samsung-atna33xc20.c
drivers/gpu/drm/panel/Kconfig +12 -0
index 6b3eb041182c..58430d358489 100644
@@ -353,6 +353,18 @@ config DRM_PANEL_RONBO_RB070D30
 	  Say Y here if you want to enable support for Ronbo Electronics
 	  RB070D30 1024x600 DSI panel.
 
+config DRM_PANEL_SAMSUNG_ATNA33XC20
+	tristate "Samsung ATNA33XC20 eDP panel"
+	depends on OF
+	depends on BACKLIGHT_CLASS_DEVICE
+	depends on PM
+	select VIDEOMODE_HELPERS
+	select DRM_DP_AUX_BUS
+	help
+	  DRM panel driver for the Samsung ATNA33XC20 panel. This panel can't
+	  be handled by the DRM_PANEL_SIMPLE driver because its power
+	  sequencing is non-standard.
+
 config DRM_PANEL_SAMSUNG_DB7430
 	tristate "Samsung DB7430-based DPI panels"
 	depends on OF && SPI && GPIOLIB
drivers/gpu/drm/panel/Makefile +1 -0
index 08debae9b314..1b6fe2008861 100644
@@ -34,6 +34,7 @@ obj-$(CONFIG_DRM_PANEL_RASPBERRYPI_TOUCHSCREEN) += panel-raspberrypi-touchscreen
 obj-$(CONFIG_DRM_PANEL_RAYDIUM_RM67191) += panel-raydium-rm67191.o
 obj-$(CONFIG_DRM_PANEL_RAYDIUM_RM68200) += panel-raydium-rm68200.o
 obj-$(CONFIG_DRM_PANEL_RONBO_RB070D30) += panel-ronbo-rb070d30.o
+obj-$(CONFIG_DRM_PANEL_SAMSUNG_ATNA33XC20) += panel-samsung-atna33xc20.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_DB7430) += panel-samsung-db7430.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_LD9040) += panel-samsung-ld9040.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6D16D0) += panel-samsung-s6d16d0.o
drivers/gpu/drm/panel/panel-samsung-atna33xc20.c new file +366 -0

366 lines not on this page · raw message

Signature · 1 line
2.32.0.554.ge1b32706d8-goog
#7 lore raw
In reply to Douglas Anderson

Hi Douglas,

Quoted 35 lines · Douglas Anderson

The overall goal of this series is to make the Samsung ATNA33XC20 panel work more properly. As part of this, we have:
* A bugfix for the recently abstracted DP AUX backlight code.
* A bugfix for the sequencing of the ti-sn65dsi86 bridge driver.
* Removal of the panel from panel-simple and moving it to its own driver.

If the bugfixes look good but the rest of the series needs work then those could land early on their own. There's no real compile time dependency on the bugfixes, things are just glitchier without them.

NOTE: this series will (slightly) conflict with my other recent series making eDP panels probable [1]. I'll re-post that one atop this one. It should be noted that the fact that the Samsung ATNA33XC20 needs its own panel driver means that it _can't_ handled as a probed driver. I think this is fine, at least for now. I don't think it would be easy to make a unified design with this panel and other panels given that it's an AMOLED panel and has a whole bunch of different components on board.

As discussed in IRC, the only difference in v2 is the addition of a "Fixes" tag to patch #3 and the collection of Reviews/Acks from Sean and Robert.

If people feel that this is ready to land today then I can help land it (please let me know). Otherwise I'm happy for someone else to actually do the commit next week (I'm on vacation) or I can take it when I get back.

[1] https://lore.kernel.org/r/[email protected]/

Changes in v2:
- Added Fixes tag as requested by Sam.

Quoted 8 lines

Douglas Anderson (6):
drm/dp: Don't zero PWMGEN_BIT_COUNT when driver_pwm_freq_hz not
specified
drm/bridge: ti-sn65dsi86: Fix power off sequence drm/bridge: ti-sn65dsi86: Add some 100 us delays
Revert "drm/panel-simple: Add Samsung ATNA33XC20"
Revert "drm/panel-simple: Support for delays between GPIO & regulator" drm/panel: atna33xc20: Introduce the Samsung ATNA33XC20 panel

I have now applied the first three patches to drm-misc-next.

Sam

#8 lore raw
In reply to Douglas Anderson

Hi Douglas,

Quoted 35 lines · Douglas Anderson

The overall goal of this series is to make the Samsung ATNA33XC20 panel work more properly. As part of this, we have:
* A bugfix for the recently abstracted DP AUX backlight code.
* A bugfix for the sequencing of the ti-sn65dsi86 bridge driver.
* Removal of the panel from panel-simple and moving it to its own driver.

If the bugfixes look good but the rest of the series needs work then those could land early on their own. There's no real compile time dependency on the bugfixes, things are just glitchier without them.

NOTE: this series will (slightly) conflict with my other recent series making eDP panels probable [1]. I'll re-post that one atop this one. It should be noted that the fact that the Samsung ATNA33XC20 needs its own panel driver means that it _can't_ handled as a probed driver. I think this is fine, at least for now. I don't think it would be easy to make a unified design with this panel and other panels given that it's an AMOLED panel and has a whole bunch of different components on board.

As discussed in IRC, the only difference in v2 is the addition of a "Fixes" tag to patch #3 and the collection of Reviews/Acks from Sean and Robert.

If people feel that this is ready to land today then I can help land it (please let me know). Otherwise I'm happy for someone else to actually do the commit next week (I'm on vacation) or I can take it when I get back.

[1] https://lore.kernel.org/r/[email protected]/

Changes in v2:
- Added Fixes tag as requested by Sam.

Quoted 8 lines

Douglas Anderson (6):
drm/dp: Don't zero PWMGEN_BIT_COUNT when driver_pwm_freq_hz not
specified
drm/bridge: ti-sn65dsi86: Fix power off sequence drm/bridge: ti-sn65dsi86: Add some 100 us delays
Revert "drm/panel-simple: Add Samsung ATNA33XC20"
Revert "drm/panel-simple: Support for delays between GPIO & regulator" drm/panel: atna33xc20: Introduce the Samsung ATNA33XC20 panel

I have applied the last three patches to drm-misc-next too. The "select VIDEO_MODEHELPERS" in the last patch was not needed as we discussed on irc, so I deleted it while applying.

Sam