[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20230702182744.755467-7-sui.jingfeng@linux.dev>
Date: Mon, 3 Jul 2023 02:27:44 +0800
From: Sui Jingfeng <sui.jingfeng@...ux.dev>
To: Alex Deucher <alexander.deucher@....com>,
David Airlie <airlied@...il.com>,
Daniel Vetter <daniel@...ll.ch>,
Thomas Zimmermann <tzimmermann@...e.de>,
Maxime Ripard <mripard@...nel.org>,
Jani Nikula <jani.nikula@...ux.intel.com>,
Lyude Paul <lyude@...hat.com>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Mario Limonciello <mario.limonciello@....com>
Cc: dri-devel@...ts.freedesktop.org, amd-gfx@...ts.freedesktop.org,
linux-kernel@...r.kernel.org, intel-gfx@...ts.freedesktop.org,
nouveau@...ts.freedesktop.org, linux-pci@...r.kernel.org,
kvm@...r.kernel.org, linux-fbdev@...r.kernel.org,
Sui Jingfeng <suijingfeng@...ngson.cn>,
Jocelyn Falempe <jfalempe@...hat.com>
Subject: [PATCH v2 6/6] drm/ast: Register as a vga client to vgaarb by calling vga_client_register()
From: Sui Jingfeng <suijingfeng@...ngson.cn>
Becasuse the VGA Display Controller in the ASpeed BMC chip is also a PCIe
device, the Software Programming guide of AST2400 say that it is Fully
IBM VGA compliant, thus, it should also particiate in the arbitration.
Cc: Thomas Zimmermann <tzimmermann@...e.de>
Cc: Jocelyn Falempe <jfalempe@...hat.com>
Cc: David Airlie <airlied@...il.com>
Cc: Daniel Vetter <daniel@...ll.ch>
Signed-off-by: Sui Jingfeng <suijingfeng@...ngson.cn>
---
drivers/gpu/drm/ast/ast_drv.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
index e1224ef4ad83..5ce681142679 100644
--- a/drivers/gpu/drm/ast/ast_drv.c
+++ b/drivers/gpu/drm/ast/ast_drv.c
@@ -28,6 +28,7 @@
#include <linux/module.h>
#include <linux/pci.h>
+#include <linux/vgaarb.h>
#include <drm/drm_aperture.h>
#include <drm/drm_atomic_helper.h>
@@ -89,6 +90,32 @@ static const struct pci_device_id ast_pciidlist[] = {
MODULE_DEVICE_TABLE(pci, ast_pciidlist);
+static bool ast_is_boot_device(struct pci_dev *pdev)
+{
+ struct drm_device *drm = pci_get_drvdata(pdev);
+ struct ast_device *ast = to_ast_device(drm);
+
+ return drm_aperture_contain_firmware_fb(ast->vram_base, ast->vram_size);
+}
+
+static unsigned int ast_vga_set_decode(struct pci_dev *pdev, bool state)
+{
+ struct drm_device *drm = pci_get_drvdata(pdev);
+ struct ast_device *ast = to_ast_device(drm);
+
+ if (state) {
+ /* Enable standard VGA decode and Enable normal VGA decode */
+ ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa1, 0x04);
+
+ return VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM |
+ VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
+ }
+
+ ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa1, 0x07);
+
+ return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
+}
+
static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{
struct ast_device *ast;
@@ -112,6 +139,8 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (ret)
return ret;
+ vga_client_register(pdev, ast_vga_set_decode, ast_is_boot_device);
+
drm_fbdev_generic_setup(dev, 32);
return 0;
--
2.25.1
Powered by blists - more mailing lists