Skip to contentSkip to conversation

drm/aspeed: Preserve DVO configuration bits during initialization

PATCH In review Timothy Pearson 2 participants 3 messages May 2, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 drm/aspeed: Preserve DVO configuration bits during initialization

GFX064 contains DVO enable and mode bits. These are hardware specific, configured via the pinmux from the DT, and should not be cleared during startup.

---
 drivers/gpu/drm/aspeed/aspeed_gfx.h     | 3 +++
 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 5 ++++-
 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/aspeed/aspeed_gfx.h +3 -0
index b7a986e49177..b34c97613aaf 100644
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 // Copyright 2018 IBM Corporation
+// Copyright 2019 Raptor Engineering, LLC
 
 #include <drm/drm_device.h>
 #include <drm/drm_simple_kms_helper.h>
@@ -73,6 +74,8 @@ int aspeed_gfx_create_output(struct drm_device *drm);
 
 /* CTRL2 */
 #define CRT_CTRL_DAC_EN			BIT(0)
+#define CRT_CTRL_DVO_MODE		BIT(6)
+#define CRT_CTRL_DVO_EN			BIT(7)
 #define CRT_CTRL_VBLANK_LINE(x)		(((x) << 20) & CRT_CTRL_VBLANK_LINE_MASK)
 #define CRT_CTRL_VBLANK_LINE_MASK	GENMASK(20, 31)
 
drivers/gpu/drm/aspeed/aspeed_gfx_drv.c +4 -1
index 713a3975852b..7e9072fd0ef0 100644
@@ -98,6 +98,7 @@ static int aspeed_gfx_load(struct drm_device *drm)
 	struct aspeed_gfx *priv;
 	struct resource *res;
 	int ret;
+	u32 reg;
 
 	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
@@ -146,7 +147,9 @@ static int aspeed_gfx_load(struct drm_device *drm)
 
 	/* Sanitize control registers */
 	writel(0, priv->base + CRT_CTRL1);
-	writel(0, priv->base + CRT_CTRL2);
+	/* Preserve CRT_CTRL2[7:6] (DVO configuration) */
+	reg = readl(priv->base + CRT_CTRL2) & (CRT_CTRL_DVO_MODE | CRT_CTRL_DVO_EN);
+	writel(reg, priv->base + CRT_CTRL2);
 
 	aspeed_gfx_setup_mode_config(drm);
 
Signature · 1 line
2.11.0
Reviewed-by on v2 1/2
#1 lore raw

Hi Timothy,

A few of things:

1. Please run ./scripts/checkpatch.pl over your patches before sending
2. Version your series coherently - having [v2] of one patch in the series threw me out. Please use git format-patch -vX, it will handle this for you automatically.
3. For multi-patch series I suggest using a cover letter - this helps thread them in a sane manner. It's also a great place to describe what you're trying to achieve with the series
4. Please use ./scripts/get_maintainer.pl to find the right people and lists to which to send patches.

In this case Joel will pick the patch up, but it's better if you have him either in To: or Cc: as you're more likely to get his attention this way.

Generally, a lot of this is covered in the kernel's documentation - dig around under Documentation/process.

Aside from that, some minor style points below:

Quoted 2 lines · Timothy Pearson

GFX064 contains DVO enable and mode bits. These are hardware specific, configured

This should be wrapped at 75 chars

Quoted 35 lines

via the pinmux from the DT, and should not be cleared during startup.

---
 drivers/gpu/drm/aspeed/aspeed_gfx.h     | 3 +++
 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 5 ++++-
 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/aspeed/aspeed_gfx.h +3 -0
index b7a986e49177..b34c97613aaf 100644
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 // Copyright 2018 IBM Corporation
+// Copyright 2019 Raptor Engineering, LLC
 
 #include <drm/drm_device.h>
 #include <drm/drm_simple_kms_helper.h>
@@ -73,6 +74,8 @@ int aspeed_gfx_create_output(struct drm_device *drm);
 
 /* CTRL2 */
 #define CRT_CTRL_DAC_EN			BIT(0)
+#define CRT_CTRL_DVO_MODE		BIT(6)
+#define CRT_CTRL_DVO_EN			BIT(7)
 #define CRT_CTRL_VBLANK_LINE(x)		(((x) << 20) & CRT_CTRL_VBLANK_LINE_MASK)
 #define CRT_CTRL_VBLANK_LINE_MASK	GENMASK(20, 31)
 
drivers/gpu/drm/aspeed/aspeed_gfx_drv.c +0 -0
index 713a3975852b..7e9072fd0ef0 100644

drivers/gpu/drm/aspeed/aspeed_gfx_drv.c static int aspeed_gfx_load(struct drm_device *drm) · line 101

Quoted 4 lines
drivers/gpu/drm/aspeed/aspeed_gfx_drv.c +1 -0
@@ -98,6 +98,7 @@ static int aspeed_gfx_load(struct drm_device *drm)
 	struct aspeed_gfx *priv;
 	struct resource *res;
 	int ret;
+	u32 reg;

This breaks the reverse-christmas-tree ordering, but that's getting quite pedantic.

drivers/gpu/drm/aspeed/aspeed_gfx_drv.c static int aspeed_gfx_load(struct drm_device *drm) · line 151

Quoted 10 lines
drivers/gpu/drm/aspeed/aspeed_gfx_drv.c +2 -1
 	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
@@ -146,7 +147,9 @@ static int aspeed_gfx_load(struct drm_device *drm)
 
 	/* Sanitize control registers */
 	writel(0, priv->base + CRT_CTRL1);
-	writel(0, priv->base + CRT_CTRL2);
+	/* Preserve CRT_CTRL2[7:6] (DVO configuration) */
+	reg = readl(priv->base + CRT_CTRL2) & (CRT_CTRL_DVO_MODE | CRT_CTRL_DVO_EN);

Should be wrapped at 80 chars.

Other than that,

Quoted 7 lines
drivers/gpu/drm/aspeed/aspeed_gfx_drv.c +1 -0
+	writel(reg, priv->base + CRT_CTRL2);
 
 	aspeed_gfx_setup_mode_config(drm);
 
Signature · 1 line
2.11.0
#2 lore raw

PATCH v2 1/2 drm/aspeed: Preserve DVO configuration bits during initialization

----- Original Message -----

Quoted 20 lines

From: "Andrew Jeffery" <[email protected]>
To: "Timothy Pearson" <[email protected]>, "linux-aspeed" <[email protected]>
Sent: Thursday, May 2, 2019 5:24:02 PM
Subject: Re: [PATCH 1/2] [v2] drm/aspeed: Preserve DVO configuration bits during initialization

Hi Timothy,

A few of things:

1. Please run ./scripts/checkpatch.pl over your patches before sending
2. Version your series coherently - having [v2] of one patch in the series threw me out. Please use git format-patch -vX, it will handle this for you automatically.
3. For multi-patch series I suggest using a cover letter - this helps thread them
in a sane manner. It's also a great place to describe what you're trying to achieve with the series
4. Please use ./scripts/get_maintainer.pl to find the right people and lists to which to send patches.

Quoted 5 lines

In this case Joel will pick the patch up, but it's better if you have him either in To: or Cc: as you're more likely to get his attention this way.

Generally, a lot of this is covered in the kernel's documentation - dig around under Documentation/process.

No problem, will do. Was taking some shortcuts here to meet a couple of deadlines, and was mostly looking for feedback on approach :) If the patch is good as-is or with minor changes, of course I'm also OK with a merge.

Quoted 74 lines

Aside from that, some minor style points below:

Quoted 2 lines · Timothy Pearson

GFX064 contains DVO enable and mode bits. These are hardware specific, configured

This should be wrapped at 75 chars

Quoted 35 lines

via the pinmux from the DT, and should not be cleared during startup.

---
 drivers/gpu/drm/aspeed/aspeed_gfx.h     | 3 +++
 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 5 ++++-
 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/aspeed/aspeed_gfx.h +3 -0
index b7a986e49177..b34c97613aaf 100644
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 // Copyright 2018 IBM Corporation
+// Copyright 2019 Raptor Engineering, LLC
 
 #include <drm/drm_device.h>
 #include <drm/drm_simple_kms_helper.h>
@@ -73,6 +74,8 @@ int aspeed_gfx_create_output(struct drm_device *drm);
 
 /* CTRL2 */
 #define CRT_CTRL_DAC_EN			BIT(0)
+#define CRT_CTRL_DVO_MODE		BIT(6)
+#define CRT_CTRL_DVO_EN			BIT(7)
 #define CRT_CTRL_VBLANK_LINE(x)		(((x) << 20) & CRT_CTRL_VBLANK_LINE_MASK)
 #define CRT_CTRL_VBLANK_LINE_MASK	GENMASK(20, 31)
 
drivers/gpu/drm/aspeed/aspeed_gfx_drv.c +0 -0
index 713a3975852b..7e9072fd0ef0 100644

drivers/gpu/drm/aspeed/aspeed_gfx_drv.c static int aspeed_gfx_load(struct drm_device *drm) · line 101

Quoted 4 lines
drivers/gpu/drm/aspeed/aspeed_gfx_drv.c +1 -0
@@ -98,6 +98,7 @@ static int aspeed_gfx_load(struct drm_device *drm)
 	struct aspeed_gfx *priv;
 	struct resource *res;
 	int ret;
+	u32 reg;

This breaks the reverse-christmas-tree ordering, but that's getting quite pedantic.

drivers/gpu/drm/aspeed/aspeed_gfx_drv.c static int aspeed_gfx_load(struct drm_device *drm) · line 151

Quoted 10 lines
drivers/gpu/drm/aspeed/aspeed_gfx_drv.c +2 -1
 	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
@@ -146,7 +147,9 @@ static int aspeed_gfx_load(struct drm_device *drm)
 
 	/* Sanitize control registers */
 	writel(0, priv->base + CRT_CTRL1);
-	writel(0, priv->base + CRT_CTRL2);
+	/* Preserve CRT_CTRL2[7:6] (DVO configuration) */
+	reg = readl(priv->base + CRT_CTRL2) & (CRT_CTRL_DVO_MODE | CRT_CTRL_DVO_EN);

Should be wrapped at 80 chars.

Other than that,

Quoted 6 lines
drivers/gpu/drm/aspeed/aspeed_gfx_drv.c +1 -1
+	writel(reg, priv->base + CRT_CTRL2);
 
 	aspeed_gfx_setup_mode_config(drm);
 
--

2.11.0