From 08ece5b3ec6cd4210471d85f883b136d8847260d Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Sun, 23 Jul 2023 12:40:24 +0800 Subject: dm: video: Cosmetic style fix Some coding convention fixes for video_post_bind(). Signed-off-by: Bin Meng Reviewed-by: Simon Glass Tested-by: Simon Glass # qemu-x86_64 --- drivers/video/video-uclass.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index 949595f1bc6..8f268fc4063 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -626,10 +626,12 @@ static int video_post_bind(struct udevice *dev) addr = uc_priv->video_ptr; size = alloc_fb(dev, &addr); if (addr < gd->video_bottom) { - /* Device tree node may need the 'bootph-all' or + /* + * Device tree node may need the 'bootph-all' or * 'bootph-some-ram' tag */ - printf("Video device '%s' cannot allocate frame buffer memory -ensure the device is set up before relocation\n", + printf("Video device '%s' cannot allocate frame buffer memory " + "- ensure the device is set up before relocation\n", dev->name); return -ENOSPC; } -- cgit v1.3.1 From 5ee029a190d5c0bf5dcba2f2138d3fa8466e16d6 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Sun, 23 Jul 2023 12:40:25 +0800 Subject: video: bochs: Drop inclusion of The driver does not call any MTRR APIs. Signed-off-by: Bin Meng Reviewed-by: Simon Glass Tested-by: Simon Glass # qemu-x86_64 --- drivers/video/bochs.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/video/bochs.c b/drivers/video/bochs.c index 2136b511936..fa0283c158a 100644 --- a/drivers/video/bochs.c +++ b/drivers/video/bochs.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include "bochs.h" -- cgit v1.3.1 From caae795a1c6a205498470e9dfc2725ae3052ad12 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Sun, 23 Jul 2023 12:40:26 +0800 Subject: video: bochs: Drop the useless argument of bochs_vga_write() bochs_vga_write() takes 'index' as one argument, but never uses it. While we are here, use macros instead of magic numbers for the VGA IO port register name and value. Signed-off-by: Bin Meng Reviewed-by: Simon Glass Tested-by: Simon Glass # qemu-x86_64 --- drivers/video/bochs.c | 7 ++++--- drivers/video/bochs.h | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/video/bochs.c b/drivers/video/bochs.c index fa0283c158a..2d4526c7143 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(int index, uint8_t val) +static void bochs_vga_write(uint8_t val) { - outb(val, VGA_INDEX); + outb(val, VGA_ATT_W); } static int bochs_init_fb(struct udevice *dev) @@ -78,7 +78,8 @@ static int bochs_init_fb(struct udevice *dev) bochs_write(mmio, INDEX_Y_OFFSET, 0); bochs_write(mmio, INDEX_ENABLE, ENABLED | LFB_ENABLED); - bochs_vga_write(0, 0x20); /* disable blanking */ + /* disable blanking */ + bochs_vga_write(VGA_AR_ENABLE_DISPLAY); plat->base = fb; diff --git a/drivers/video/bochs.h b/drivers/video/bochs.h index 4c8ec83a550..71d3d60141e 100644 --- a/drivers/video/bochs.h +++ b/drivers/video/bochs.h @@ -6,7 +6,10 @@ #ifndef __BOCHS_H #define __BOCHS_H -#define VGA_INDEX 0x3c0 +#define VGA_INDEX 0x3c0 + +#define VGA_ATT_W 0x3c0 +#define VGA_AR_ENABLE_DISPLAY 0x20 #define IOPORT_INDEX 0x01ce #define IOPORT_DATA 0x01cf -- cgit v1.3.1 From ffe1c8379e824007a7341381e20e9346c7a5c1ec Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Sun, 23 Jul 2023 12:40:27 +0800 Subject: video: bochs: Avoid using IO instructions to access VGA IO port 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 Reviewed-by: Simon Glass Tested-by: Simon Glass # qemu-x86_64 --- drivers/video/bochs.c | 6 +++--- drivers/video/bochs.h | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/video/bochs.c b/drivers/video/bochs.c index 2d4526c7143..5923ff81c65 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 71d3d60141e..3facf690e5d 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 -- cgit v1.3.1 From e1b46977deddb56d49656546fe36ec107a2b86f3 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Sun, 23 Jul 2023 12:40:28 +0800 Subject: video: bochs: Remove the x86 dependency Now that the driver is legacy free, remove the x86 dependency so that it can be used on non-x86 architectures. Signed-off-by: Bin Meng Reviewed-by: Simon Glass Tested-by: Simon Glass # qemu-x86_64 --- drivers/video/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index b41dc60cec5..3cdaa5ff270 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -280,7 +280,6 @@ config VIDCONSOLE_AS_NAME config VIDEO_BOCHS bool "Enable Bochs video emulation for QEMU" - depends on X86 help Enable this to use the Bochs video support provided in the QEMU emulator. This appears as a PCI device which U-Boot can set up to -- cgit v1.3.1 From 17cd80237b09c3926c317bd348959f057f8dec7d Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Sun, 23 Jul 2023 12:40:29 +0800 Subject: video: kconfig: Fix wrong text for the PCI default FB size There is an example in the VIDEO_PCI_DEFAULT_FB_SIZE help text to tell people how to calculate its value but the resolution given does not match the value. Fix it. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- drivers/video/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 3cdaa5ff270..43ec7e66955 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -77,7 +77,7 @@ config VIDEO_PCI_DEFAULT_FB_SIZE devices to have a framebuffer allocated by U-Boot. Note: the framebuffer needs to be large enough to store all pixels at - maximum resolution. For example, at 1920 x 1200 with 32 bits per + maximum resolution. For example, at 2560 x 1600 with 32 bits per pixel, 2560 * 1600 * 32 / 8 = 0xfa0000 bytes are needed. config VIDEO_COPY @@ -1049,7 +1049,7 @@ config SPL_VIDEO_PCI_DEFAULT_FB_SIZE devices to have a framebuffer allocated by U-Boot. Note: the framebuffer needs to be large enough to store all pixels at - maximum resolution. For example, at 1920 x 1200 with 32 bits per + maximum resolution. For example, at 2560 x 1600 with 32 bits per pixel, 2560 * 1600 * 32 / 8 = 0xfa0000 bytes are needed. config SPL_CONSOLE_SCROLL_LINES -- cgit v1.3.1 From 185ae84af0cbf69d6253b55b4097c071f932bc16 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Sun, 23 Jul 2023 12:40:30 +0800 Subject: video: kconfig: Drop the superfluous dependency PCI is always selected by X86 architecture hence "X86 && PCI" does not make it better. Signed-off-by: Bin Meng Reviewed-by: Simon Glass Tested-by: Simon Glass # qemu-x86_64 --- drivers/video/Kconfig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 43ec7e66955..3f6b7d71b8e 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -64,8 +64,8 @@ config BACKLIGHT config VIDEO_PCI_DEFAULT_FB_SIZE hex "Default framebuffer size to use if no drivers request it" - default 0x1000000 if X86 && PCI - default 0 if !(X86 && PCI) + default 0x1000000 if X86 + default 0 if !X86 help Generally, video drivers request the amount of memory they need for the frame buffer when they are bound, by setting the size field in @@ -1036,8 +1036,8 @@ config SPL_SYS_WHITE_ON_BLACK config SPL_VIDEO_PCI_DEFAULT_FB_SIZE hex "Default framebuffer size to use if no drivers request it at SPL" - default 0x1000000 if X86 && PCI - default 0 if !(X86 && PCI) + default 0x1000000 if X86 + default 0 if !X86 help Generally, video drivers request the amount of memory they need for the frame buffer when they are bound, by setting the size field in -- cgit v1.3.1 From f91f0e74df814d5c96382d1d8ce29d63c8f0b343 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Sun, 23 Jul 2023 12:40:31 +0800 Subject: video: kconfig: Set default FB size for Bochs Set up a default frame buffer size of 8MiB for Bochs for non-x86 architecturs as PCI is normally not enumerated before relocation on these architectures. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- drivers/video/Kconfig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 3f6b7d71b8e..e32ce13fb6b 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -65,7 +65,8 @@ config BACKLIGHT config VIDEO_PCI_DEFAULT_FB_SIZE hex "Default framebuffer size to use if no drivers request it" default 0x1000000 if X86 - default 0 if !X86 + default 0x800000 if !X86 && VIDEO_BOCHS + default 0 if !X86 && !VIDEO_BOCHS help Generally, video drivers request the amount of memory they need for the frame buffer when they are bound, by setting the size field in @@ -1037,7 +1038,8 @@ config SPL_SYS_WHITE_ON_BLACK config SPL_VIDEO_PCI_DEFAULT_FB_SIZE hex "Default framebuffer size to use if no drivers request it at SPL" default 0x1000000 if X86 - default 0 if !X86 + default 0x800000 if !X86 && VIDEO_BOCHS + default 0 if !X86 && !VIDEO_BOCHS help Generally, video drivers request the amount of memory they need for the frame buffer when they are bound, by setting the size field in -- cgit v1.3.1 From e1a0cafcfb85a681c7ac77c71fed0c392a75fe06 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Sun, 23 Jul 2023 12:40:32 +0800 Subject: video: bochs: Set the frame buffer size per configuration At present the uclass stored frame buffer size is set to a hard coded value, but we can calculate the correct value based on what is configured. Signed-off-by: Bin Meng Reviewed-by: Simon Glass Tested-by: Simon Glass # qemu-x86_64 --- drivers/video/bochs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/video/bochs.c b/drivers/video/bochs.c index 5923ff81c65..022ea38d4cf 100644 --- a/drivers/video/bochs.c +++ b/drivers/video/bochs.c @@ -101,8 +101,8 @@ static int bochs_video_bind(struct udevice *dev) { struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev); - /* Set the maximum supported resolution */ - uc_plat->size = 2560 * 1600 * 4; + /* Set the frame buffer size per configuration */ + uc_plat->size = xsize * ysize * 32 / 8; log_debug("%s: Frame buffer size %x\n", __func__, uc_plat->size); return 0; -- cgit v1.3.1 From 3f9b5a7ffa75871b238f931af37f8f595e998838 Mon Sep 17 00:00:00 2001 From: Nikhil M Jain Date: Thu, 27 Jul 2023 12:01:25 +0530 Subject: drivers: video: tidss: tidss_drv: Change remove method Change remove method of DSS video driver to disable video port instead of performing a soft reset, as soft reset takes longer duration. Video port is disabled by setting enable bit of video port to 0. Signed-off-by: Nikhil M Jain Reviewed-by: Devarsh Thakkar --- drivers/video/tidss/tidss_drv.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/video/tidss/tidss_drv.c b/drivers/video/tidss/tidss_drv.c index 078e3e82e3a..623bf4cf31f 100644 --- a/drivers/video/tidss/tidss_drv.c +++ b/drivers/video/tidss/tidss_drv.c @@ -901,19 +901,9 @@ static int tidss_drv_probe(struct udevice *dev) static int tidss_drv_remove(struct udevice *dev) { - u32 val; - int ret; struct tidss_drv_priv *priv = dev_get_priv(dev); - priv->base_common = dev_remap_addr_index(dev, 0); - REG_FLD_MOD(priv, DSS_SYSCONFIG, 1, 1, 1); - /* Wait for reset to complete */ - ret = readl_poll_timeout(priv->base_common + DSS_SYSSTATUS, - val, val & 1, 5000); - if (ret) { - dev_warn(priv->dev, "failed to reset priv\n"); - return ret; - } + VP_REG_FLD_MOD(priv, 0, DSS_VP_CONTROL, 0, 0, 0); return 0; } -- cgit v1.3.1 From b8d3a6c7d12fc6101f99cde0acedb4a799fdb5f3 Mon Sep 17 00:00:00 2001 From: Nikhil M Jain Date: Thu, 27 Jul 2023 12:01:26 +0530 Subject: drivers: video: tidss: tidss_drv: Use kconfig VIDEO_REMOVE to remove video Perform removal of DSS if kconfigs VIDEO_REMOVE or SPL_VIDEO_REMOVE is set by user. Otherwise if above Kconfigs are not selected, it is assumed that user wants splash screen to be displayed until linux kernel boots up. In such scenario, leave the power domain of DSS as "on" so that splash screen stays intact until kernel boots up. Signed-off-by: Nikhil M Jain Reviewed-by: Devarsh Thakkar --- drivers/video/tidss/tidss_drv.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/video/tidss/tidss_drv.c b/drivers/video/tidss/tidss_drv.c index 623bf4cf31f..e285f255d76 100644 --- a/drivers/video/tidss/tidss_drv.c +++ b/drivers/video/tidss/tidss_drv.c @@ -901,9 +901,11 @@ static int tidss_drv_probe(struct udevice *dev) static int tidss_drv_remove(struct udevice *dev) { - struct tidss_drv_priv *priv = dev_get_priv(dev); + if (CONFIG_IS_ENABLED(VIDEO_REMOVE)) { + struct tidss_drv_priv *priv = dev_get_priv(dev); - VP_REG_FLD_MOD(priv, 0, DSS_VP_CONTROL, 0, 0, 0); + VP_REG_FLD_MOD(priv, 0, DSS_VP_CONTROL, 0, 0, 0); + } return 0; } @@ -929,5 +931,9 @@ U_BOOT_DRIVER(tidss_drv) = { .probe = tidss_drv_probe, .remove = tidss_drv_remove, .priv_auto = sizeof(struct tidss_drv_priv), +#if CONFIG_IS_ENABLED(VIDEO_REMOVE) .flags = DM_FLAG_OS_PREPARE, +#else + .flags = DM_FLAG_OS_PREPARE | DM_FLAG_LEAVE_PD_ON, +#endif }; -- cgit v1.3.1