From 510f653f55381cb0efa3be157b2a62571cb3d219 Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Wed, 21 Apr 2021 13:12:48 +0200
Subject: [PATCH 09/11] drm/ast: Add support for AIP200
Patch-mainline: Never, temporary fixes until upstream resolution
References: bsc#1174416
A code snippet forward-ported from A-Speed downstream driver.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
drivers/gpu/drm/ast/ast_drv.c | 1 +
drivers/gpu/drm/ast/ast_drv.h | 2 ++
drivers/gpu/drm/ast/ast_main.c | 6 +++++-
drivers/gpu/drm/ast/ast_mode.c | 7 ++++---
drivers/gpu/drm/ast/ast_post.c | 4 ++--
5 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
index 0b58f7aee6b0..01c3751f9df0 100644
--- a/drivers/gpu/drm/ast/ast_drv.c
+++ b/drivers/gpu/drm/ast/ast_drv.c
@@ -59,6 +59,7 @@ static struct drm_driver driver;
static const struct pci_device_id pciidlist[] = {
AST_VGA_DEVICE(PCI_CHIP_AST2000, NULL),
AST_VGA_DEVICE(PCI_CHIP_AST2100, NULL),
+ AST_VGA_DEVICE(PCI_CHIP_AIP200, NULL),
{0, 0, 0},
};
diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
index 8ec553380e39..883e72f1ef38 100644
--- a/drivers/gpu/drm/ast/ast_drv.h
+++ b/drivers/gpu/drm/ast/ast_drv.h
@@ -52,6 +52,7 @@
#define PCI_CHIP_AST2000 0x2000
#define PCI_CHIP_AST2100 0x2010
+#define PCI_CHIP_AIP200 0xA200
enum ast_chip {
@@ -63,6 +64,7 @@ enum ast_chip {
AST2300,
AST2400,
AST2500,
+ AIP200,
};
enum ast_tx_chip {
diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
index b12746cd6473..62259166f0b5 100644
--- a/drivers/gpu/drm/ast/ast_main.c
+++ b/drivers/gpu/drm/ast/ast_main.c
@@ -157,7 +157,10 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post)
ast_detect_config_mode(dev, &scu_rev);
/* Identify chipset */
- if (dev->pdev->revision >= 0x40) {
+ if (dev->pdev->device == PCI_CHIP_AIP200) {
+ ast->chip = AIP200;
+ drm_info(dev, "AIP 200 detected\n");
+ } else if (dev->pdev->revision >= 0x40) {
ast->chip = AST2500;
drm_info(dev, "AST 2500 detected\n");
} else if (dev->pdev->revision >= 0x30) {
@@ -193,6 +196,7 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post)
/* Check if we support wide screen */
switch (ast->chip) {
+ case AIP200:
case AST2000:
ast->support_wide_screen = false;
break;
diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index 154cd877d9d1..4f6c01d48c2a 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -474,7 +474,7 @@ static void ast_set_crtthd_reg(struct ast_private *ast)
{
/* Set Threshold */
if (ast->chip == AST2300 || ast->chip == AST2400 ||
- ast->chip == AST2500) {
+ ast->chip == AST2500 || ast->chip == AIP200) {
ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa7, 0x78);
ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa6, 0x60);
} else if (ast->chip == AST2100 ||
@@ -980,7 +980,7 @@ static enum drm_mode_status ast_mode_valid(struct drm_connector *connector,
if ((ast->chip == AST2100) || (ast->chip == AST2200) ||
(ast->chip == AST2300) || (ast->chip == AST2400) ||
- (ast->chip == AST2500)) {
+ (ast->chip == AST2500) || (ast->chip == AIP200)) {
if ((mode->hdisplay == 1920) && (mode->vdisplay == 1080))
return MODE_OK;
@@ -1105,7 +1105,8 @@ int ast_mode_config_init(struct ast_private *ast)
ast->chip == AST2200 ||
ast->chip == AST2300 ||
ast->chip == AST2400 ||
- ast->chip == AST2500) {
+ ast->chip == AST2500 ||
+ ast->chip == AIP200) {
dev->mode_config.max_width = 1920;
dev->mode_config.max_height = 2048;
} else {
diff --git a/drivers/gpu/drm/ast/ast_post.c b/drivers/gpu/drm/ast/ast_post.c
index 63a5d7199ca3..30b5403994b4 100644
--- a/drivers/gpu/drm/ast/ast_post.c
+++ b/drivers/gpu/drm/ast/ast_post.c
@@ -81,7 +81,7 @@ ast_set_def_ext_reg(struct drm_device *dev)
ast_set_index_reg(ast, AST_IO_CRTC_PORT, i, 0x00);
if (ast->chip == AST2300 || ast->chip == AST2400 ||
- ast->chip == AST2500) {
+ ast->chip == AST2500 || ast->chip == AIP200) {
if (dev->pdev->revision >= 0x20)
ext_reg_info = extreginfo_ast2300;
else
@@ -106,7 +106,7 @@ ast_set_def_ext_reg(struct drm_device *dev)
/* Enable RAMDAC for A1 */
reg = 0x04;
if (ast->chip == AST2300 || ast->chip == AST2400 ||
- ast->chip == AST2500)
+ ast->chip == AST2500 || ast->chip == AIP200)
reg |= 0x20;
ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb6, 0xff, reg);
--
2.26.2