From 4090d7ab2e7282ff5680c3e574e644964a8ae7d6 Mon Sep 17 00:00:00 2001 From: Jae Hyun Yoo Date: Wed, 20 Nov 2019 14:58:24 -0800 Subject: [PATCH] drm: add AST2600 GFX support This commit adds support for AST2600 GFX. Signed-off-by: Jae Hyun Yoo --- drivers/gpu/drm/aspeed/aspeed_gfx.h | 4 ++++ drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c | 6 +++--- drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 18 +++++++++++------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx.h b/drivers/gpu/drm/aspeed/aspeed_gfx.h index a10358b..eebd72e 100644 --- a/drivers/gpu/drm/aspeed/aspeed_gfx.h +++ b/drivers/gpu/drm/aspeed/aspeed_gfx.h @@ -13,11 +13,15 @@ struct aspeed_gfx { struct drm_simple_display_pipe pipe; struct drm_connector connector; struct drm_fbdev_cma *fbdev; + u32 scu_misc_offset; }; int aspeed_gfx_create_pipe(struct drm_device *drm); int aspeed_gfx_create_output(struct drm_device *drm); +#define SCU_MISC_AST2500 0x2c /* SCU Misc of AST2500 */ +#define SCU_MISC_AST2600 0xc0 /* SCU Misc1 of AST2600 */ + #define CRT_CTRL1 0x60 /* CRT Control I */ #define CRT_CTRL2 0x64 /* CRT Control II */ #define CRT_STATUS 0x68 /* CRT Status */ diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c b/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c index 15db9e4..2c95c72 100644 --- a/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c @@ -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->scu_misc_offset, 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->scu_misc_offset, BIT(16), 0); } static void aspeed_gfx_crtc_mode_set_nofb(struct aspeed_gfx *priv) diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c index eeb22ec..aa44e01 100644 --- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c @@ -112,8 +112,14 @@ static int aspeed_gfx_load(struct drm_device *drm) 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); + priv->scu = syscon_regmap_lookup_by_compatible("aspeed,ast2600-scu"); + if (IS_ERR(priv->scu)) { + dev_err(&pdev->dev, "failed to find SCU regmap\n"); + return PTR_ERR(priv->scu); + } + priv->scu_misc_offset = SCU_MISC_AST2600; + } else { + priv->scu_misc_offset = SCU_MISC_AST2500; } ret = of_reserved_mem_device_init(drm->dev); @@ -130,12 +136,9 @@ static int aspeed_gfx_load(struct drm_device *drm) } priv->rst = devm_reset_control_get_exclusive(&pdev->dev, NULL); - if (IS_ERR(priv->rst)) { - dev_err(&pdev->dev, - "missing or invalid reset controller device tree entry"); - return PTR_ERR(priv->rst); + if (!IS_ERR_OR_NULL(priv->rst)) { + reset_control_deassert(priv->rst); } - reset_control_deassert(priv->rst); priv->clk = devm_clk_get(drm->dev, NULL); if (IS_ERR(priv->clk)) { @@ -212,6 +215,7 @@ static struct drm_driver aspeed_gfx_driver = { static const struct of_device_id aspeed_gfx_match[] = { { .compatible = "aspeed,ast2500-gfx" }, + { .compatible = "aspeed,ast2600-gfx" }, { } }; -- 2.7.4