Skip to contentSkip to conversation

drm: aspeed: Support more chip families

PATCH Superseded Joel Stanley 2 participants 4 messages Feb 2, 2021

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Joel Stanley

author maintainer
#0 lore raw

v2 cover drm: aspeed: Support more chip families

The out of tree vendor driver was recently updated to support the ast2400 and ast2600. These patches begin to add that support to the mainline driver.

With these two cleanups it should be easier to support different families of BMC system on chip with this driver.

I will merge them through drm-misc once they have been reviewed.

v2 fixes review from Jeremy. Thanks!

Joel Stanley (2):
drm/aspeed: Look up syscon by phandle drm/aspeed: Use dt matching for default register values

 drivers/gpu/drm/aspeed/aspeed_gfx.h      |  8 +--
 drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c | 11 ++--
 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c  | 67 ++++++++++++++++++------
 3 files changed, 62 insertions(+), 24 deletions(-)
Signature · 1 line
2.30.0
author maintainer
#1 lore raw

PATCH v2 1/2 drm/aspeed: Look up syscon by phandle

This scales better to multiple families of SoC. The lookup by compatible can be removed in a future change.

The fallback path is for the ast2500 platform only. Other platforms will be added with the new style, so they won't need fallback paths.

---
v2: Fix fallback path to still find ast2500-scu. Thanks jk for the review

---
 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/aspeed/aspeed_gfx_drv.c +7 -3
index 457ec04950f7..54a6bda03c0e 100644
@@ -103,6 +103,7 @@ static int aspeed_gfx_load(struct drm_device *drm)
 {
 	struct platform_device *pdev = to_platform_device(drm->dev);
 	struct aspeed_gfx *priv = to_aspeed_gfx(drm);
+	struct device_node *np = pdev->dev.of_node;
 	struct resource *res;
 	int ret;
 
@@ -111,10 +112,13 @@ static int aspeed_gfx_load(struct drm_device *drm)
 	if (IS_ERR(priv->base))
 		return PTR_ERR(priv->base);
 
-	priv->scu = syscon_regmap_lookup_by_compatible("aspeed,ast2500-scu");
+	priv->scu = syscon_regmap_lookup_by_phandle(np, "syscon");
 	if (IS_ERR(priv->scu)) {
-		dev_err(&pdev->dev, "failed to find SCU regmap\n");
-		return PTR_ERR(priv->scu);
+		priv->scu = syscon_regmap_lookup_by_compatible("aspeed,ast2500-scu");
+		if (IS_ERR(priv->scu)) {
+			dev_err(&pdev->dev, "failed to find SCU regmap\n");
+			return PTR_ERR(priv->scu);
+		}
 	}
 
 	ret = of_reserved_mem_device_init(drm->dev);
Signature · 1 line
2.30.0
author maintainer
#2 lore raw

PATCH v2 2/2 drm/aspeed: Use dt matching for default register values

In reply to Joel Stanley

There are minor differences in the values for the threshold value and the scan line size between families of ASPEED SoC. Additionally the SCU registers for the output control and scratch registers differ between families.

This adds device tree matching to parameterise these values, allowing us to add support for the AST2400 now, and in the future the AST2600.

---
v2:
- Add jk's review
- Clean up comments and unused define
- Add VGA password register

---
 drivers/gpu/drm/aspeed/aspeed_gfx.h      |  8 ++--
 drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c | 11 ++---
 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c  | 57 ++++++++++++++++++------
 3 files changed, 55 insertions(+), 21 deletions(-)
drivers/gpu/drm/aspeed/aspeed_gfx.h +5 -3
index f1e7e56abc02..96501152bafa 100644
@@ -11,6 +11,11 @@ struct aspeed_gfx {
 	struct reset_control		*rst;
 	struct regmap			*scu;
 
+	u32				dac_reg;
+	u32				vga_scratch_reg;
+	u32				throd_val;
+	u32				scan_line_max;
+
 	struct drm_simple_display_pipe	pipe;
 	struct drm_connector		connector;
 };
@@ -100,6 +105,3 @@ int aspeed_gfx_create_output(struct drm_device *drm);
 /* CRT_THROD */
 #define CRT_THROD_LOW(x)		(x)
 #define CRT_THROD_HIGH(x)		((x) << 8)
-
-/* Default Threshold Seting */
-#define G5_CRT_THROD_VAL	(CRT_THROD_LOW(0x24) | CRT_THROD_HIGH(0x3C))
drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c +6 -5
index e54686c31a90..20c2197b270f 100644
@@ -59,8 +59,8 @@ static void aspeed_gfx_enable_controller(struct aspeed_gfx *priv)
 	u32 ctrl1 = readl(priv->base + CRT_CTRL1);
 	u32 ctrl2 = readl(priv->base + CRT_CTRL2);
 
-	/* SCU2C: set DAC source for display output to Graphics CRT (GFX) */
-	regmap_update_bits(priv->scu, 0x2c, BIT(16), BIT(16));
+	/* Set DAC source for display output to Graphics CRT (GFX) */
+	regmap_update_bits(priv->scu, priv->dac_reg, BIT(16), BIT(16));
 
 	writel(ctrl1 | CRT_CTRL_EN, priv->base + CRT_CTRL1);
 	writel(ctrl2 | CRT_CTRL_DAC_EN, priv->base + CRT_CTRL2);
@@ -74,7 +74,7 @@ static void aspeed_gfx_disable_controller(struct aspeed_gfx *priv)
 	writel(ctrl1 & ~CRT_CTRL_EN, priv->base + CRT_CTRL1);
 	writel(ctrl2 & ~CRT_CTRL_DAC_EN, priv->base + CRT_CTRL2);
 
-	regmap_update_bits(priv->scu, 0x2c, BIT(16), 0);
+	regmap_update_bits(priv->scu, priv->dac_reg, BIT(16), 0);
 }
 
 static void aspeed_gfx_crtc_mode_set_nofb(struct aspeed_gfx *priv)
@@ -127,7 +127,8 @@ static void aspeed_gfx_crtc_mode_set_nofb(struct aspeed_gfx *priv)
 	 * Terminal Count: memory size of one scan line
 	 */
 	d_offset = m->hdisplay * bpp / 8;
-	t_count = (m->hdisplay * bpp + 127) / 128;
+	t_count = DIV_ROUND_UP(m->hdisplay * bpp, priv->scan_line_max);
+
 	writel(CRT_DISP_OFFSET(d_offset) | CRT_TERM_COUNT(t_count),
 			priv->base + CRT_OFFSET);
 
@@ -135,7 +136,7 @@ static void aspeed_gfx_crtc_mode_set_nofb(struct aspeed_gfx *priv)
 	 * Threshold: FIFO thresholds of refill and stop (16 byte chunks
 	 * per line, rounded up)
 	 */
-	writel(G5_CRT_THROD_VAL, priv->base + CRT_THROD);
+	writel(priv->throd_val, priv->base + CRT_THROD);
 }
 
 static void aspeed_gfx_pipe_enable(struct drm_simple_display_pipe *pipe,
drivers/gpu/drm/aspeed/aspeed_gfx_drv.c +44 -13

110 lines not on this page · raw message

Signature · 1 line
2.30.0
#3 lore raw

Re: [PATCH v2 2/2] drm/aspeed: Use dt matching for default register values

I love your patch! Yet something to improve:

Hi Joel,

I love your patch! Yet something to improve:

[auto build test ERROR on drm-intel/for-linux-next]
[also build test ERROR on drm-tip/drm-tip v5.11-rc6 next-20210125] [cannot apply to joel-aspeed/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Joel-Stanley/drm-aspeed-Support-more-chip-families/20210202-134815
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: m68k-allmodconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 9.3.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/d6ef19fa04b9cc1d571e0babb5250c5f8f8da34e
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Joel-Stanley/drm-aspeed-Support-more-chip-families/20210202-134815 git checkout d6ef19fa04b9cc1d571e0babb5250c5f8f8da34e
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

In file included from include/linux/err.h:5,
from include/linux/clk.h:12,
from drivers/gpu/drm/aspeed/aspeed_gfx_drv.c:4:
include/linux/scatterlist.h: In function 'sg_set_buf':
arch/m68k/include/asm/page_mm.h:174:49: warning: ordered comparison of pointer with null pointer [-Wextra]

     174 | #define virt_addr_valid(kaddr) ((void *)(kaddr) >= (void *)PAGE_OFFSET && (void *)(kaddr) < high_memory)
         |                                                 ^~
   include/linux/compiler.h:78:42: note: in definition of macro 'unlikely'
      78 | # define unlikely(x) __builtin_expect(!!(x), 0)
         |                                          ^
   include/linux/scatterlist.h:137:2: note: in expansion of macro 'BUG_ON'
     137 |  BUG_ON(!virt_addr_valid(buf));
         |  ^~~~~~
   include/linux/scatterlist.h:137:10: note: in expansion of macro 'virt_addr_valid'
     137 |  BUG_ON(!virt_addr_valid(buf));
         |          ^~~~~~~~~~~~~~~
   In file included from drivers/gpu/drm/aspeed/aspeed_gfx_drv.c:8:
   drivers/gpu/drm/aspeed/aspeed_gfx_drv.c: At top level:
>> drivers/gpu/drm/aspeed/aspeed_gfx_drv.c:87:25: error: 'aspeed_gfx_of_table' undeclared here (not in a function); did you mean 'aspeed_gfx_match'?
      87 | MODULE_DEVICE_TABLE(of, aspeed_gfx_of_table);
         |                         ^~~~~~~~~~~~~~~~~~~
   include/linux/module.h:241:15: note: in definition of macro 'MODULE_DEVICE_TABLE'
     241 | extern typeof(name) __mod_##type##__##name##_device_table  \
         |               ^~~~
>> include/linux/module.h:241:21: error: '__mod_of__aspeed_gfx_of_table_device_table' aliased to undefined symbol 'aspeed_gfx_of_table'
     241 | extern typeof(name) __mod_##type##__##name##_device_table  \
         |                     ^~~~~~
   drivers/gpu/drm/aspeed/aspeed_gfx_drv.c:87:1: note: in expansion of macro 'MODULE_DEVICE_TABLE'
      87 | MODULE_DEVICE_TABLE(of, aspeed_gfx_of_table);
         | ^~~~~~~~~~~~~~~~~~~

vim +87 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c

    81	
    82	static const struct of_device_id aspeed_gfx_match[] = {
    83		{ .compatible = "aspeed,ast2400-gfx", .data = &ast2400_config },
    84		{ .compatible = "aspeed,ast2500-gfx", .data = &ast2500_config },
    85		{ },
    86	};
  > 87	MODULE_DEVICE_TABLE(of, aspeed_gfx_of_table);
    88	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org