diff mbox series

[04/18] video: bochs: Avoid using IO instructions to access VGA IO port

Message ID 20230723044041.1089804-5-bmeng@tinylab.org
State Accepted
Commit ffe1c8379e824007a7341381e20e9346c7a5c1ec
Delegated to: Anatolij Gustschin
Headers show
Series video: bochs: Remove the x86 limitation | expand

Commit Message

Bin Meng July 23, 2023, 4:40 a.m. UTC
At present the driver uses IO instructions to access the legacy
VGA IO ports, which unfortunately limits the driver to work only
on x86. It turns out the IO instruction is not necessary as Bochs
VGA card remaps the legacy VGA IO ports (0x3c0 -> 0x3df) to its
memory mapped register space from offset 0x400.

Update the driver to use MMIO access for VGA IO port.

Signed-off-by: Bin Meng <bmeng@tinylab.org>
---

 drivers/video/bochs.c | 6 +++---
 drivers/video/bochs.h | 4 +---
 2 files changed, 4 insertions(+), 6 deletions(-)

Comments

Simon Glass July 23, 2023, 10:58 p.m. UTC | #1
On Sat, 22 Jul 2023 at 22:41, Bin Meng <bmeng@tinylab.org> wrote:
>
> At present the driver uses IO instructions to access the legacy
> VGA IO ports, which unfortunately limits the driver to work only
> on x86. It turns out the IO instruction is not necessary as Bochs
> VGA card remaps the legacy VGA IO ports (0x3c0 -> 0x3df) to its
> memory mapped register space from offset 0x400.
>
> Update the driver to use MMIO access for VGA IO port.
>
> Signed-off-by: Bin Meng <bmeng@tinylab.org>
> ---
>
>  drivers/video/bochs.c | 6 +++---
>  drivers/video/bochs.h | 4 +---
>  2 files changed, 4 insertions(+), 6 deletions(-)
>

Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>  # qemu-x86_64
Anatolij Gustschin Aug. 1, 2023, 12:59 p.m. UTC | #2
On Sun, 23 Jul 2023 12:40:27 +0800
Bin Meng bmeng@tinylab.org wrote:

> At present the driver uses IO instructions to access the legacy
> VGA IO ports, which unfortunately limits the driver to work only
> on x86. It turns out the IO instruction is not necessary as Bochs
> VGA card remaps the legacy VGA IO ports (0x3c0 -> 0x3df) to its
> memory mapped register space from offset 0x400.
> 
> Update the driver to use MMIO access for VGA IO port.
> 
> Signed-off-by: Bin Meng <bmeng@tinylab.org>
> ---
> 
>  drivers/video/bochs.c | 6 +++---
>  drivers/video/bochs.h | 4 +---
>  2 files changed, 4 insertions(+), 6 deletions(-)

applied to u-boot-video/master, thanks!

--
Anatolij
diff mbox series

Patch

diff --git a/drivers/video/bochs.c b/drivers/video/bochs.c
index 2d4526c714..5923ff81c6 100644
--- a/drivers/video/bochs.c
+++ b/drivers/video/bochs.c
@@ -27,9 +27,9 @@  static int bochs_read(void *mmio, int index)
 	return readw(mmio + MMIO_BASE + index * 2);
 }
 
-static void bochs_vga_write(uint8_t val)
+static void bochs_vga_write(void *mmio, int index, uint8_t val)
 {
-	outb(val, VGA_ATT_W);
+	writeb(val, mmio + VGA_BASE + index);
 }
 
 static int bochs_init_fb(struct udevice *dev)
@@ -79,7 +79,7 @@  static int bochs_init_fb(struct udevice *dev)
 	bochs_write(mmio, INDEX_ENABLE, ENABLED | LFB_ENABLED);
 
 	/* disable blanking */
-	bochs_vga_write(VGA_AR_ENABLE_DISPLAY);
+	bochs_vga_write(mmio, VGA_ATT_W - VGA_INDEX, VGA_AR_ENABLE_DISPLAY);
 
 	plat->base = fb;
 
diff --git a/drivers/video/bochs.h b/drivers/video/bochs.h
index 71d3d60141..3facf690e5 100644
--- a/drivers/video/bochs.h
+++ b/drivers/video/bochs.h
@@ -11,9 +11,6 @@ 
 #define VGA_ATT_W		0x3c0
 #define VGA_AR_ENABLE_DISPLAY	0x20
 
-#define IOPORT_INDEX	0x01ce
-#define IOPORT_DATA	0x01cf
-
 enum {
 	INDEX_ID,
 	INDEX_XRES,
@@ -34,6 +31,7 @@  enum {
 #define LFB_ENABLED	BIT(6)
 #define NOCLEARMEM	BIT(7)
 
+#define VGA_BASE	0x400
 #define MMIO_BASE	0x500
 
 #endif