[PATCH v2] drm/ast: Add option to initialize palette on driver load
Non-x86 systems, such as OpenPOWER and ARM machines, do not execute the ASPEED- provided option ROM on system start. As a result, the VGA palette registers remain uninitialized, leading to odd colors and generally hard to read output on the VGA port. Add a new module option, ast_resetpalette, to enable loading a linear greyscale palette into the VGA RAMDAC. This option is intended for use by the first Linux kernel to load after initial power on, such as the skiroot kernel on OpenPOWER systems. --- drivers/gpu/drm/ast/ast_drv.c | 4 drivers/gpu/drm/ast/ast_drv.h | 14 ++ drivers/gpu/drm/ast/ast_main.c | 8 drivers/gpu/drm/ast/ast_mode.c | 14 -- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c index 69dab82a3771..8124eaa92ed3 100644 --- a/drivers/gpu/drm/ast/ast_drv.c +++ b/drivers/gpu/drm/ast/ast_drv.c @@ -1,5 +1,6 @@ /* * Copyright 2012 Red Hat Inc. + * Copyright 2018 Raptor Engineering, LLC. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the @@ -34,9 +35,12 @@ #include "ast_drv.h" int ast_modeset = -1; +int ast_resetpalette = -1; MODULE_PARM_DESC(modeset, "Disable/Enable modesetting"); +MODULE_PARM_DESC(resetpalette, "Disable/Enable palette reset on load"); module_param_named(modeset, ast_modeset, int, 0400); +module_param_named(resetpalette, ast_resetpalette, int, 0400); #define PCI_VENDOR_ASPEED 0x1a03 diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h index e6c4cd3dc50e..5e834e466b65 100644 --- a/drivers/gpu/drm/ast/ast_drv.h +++ b/drivers/gpu/drm/ast/ast_drv.h @@ -383,6 +383,20 @@ static inline int ast_bo_reserve(struct ast_bo *bo, bool no_wait) return 0; } +static inline void ast_load_palette_index(struct ast_private *ast, +u8 index, u8 red, u8 green, +u8 blue) +{ + ast_io_write8(ast, AST_IO_DAC_INDEX_WRITE, index); + ast_io_read8(ast, AST_IO_SEQ_PORT); + ast_io_write8(ast, AST_IO_DAC_DATA, red); + ast_io_read8(ast, AST_IO_SEQ_PORT); + ast_io_write8(ast, AST_IO_DAC_DATA, green); + ast_io_read8(ast, AST_IO_SEQ_PORT); + ast_io_write8(ast, AST_IO_DAC_DATA, blue); + ast_io_read8(ast, AST_IO_SEQ_PORT); +} + static inline void ast_bo_unreserve(struct ast_bo *bo) { ttm_bo_unreserve(&bo->bo); diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c index dac355812adc..f13329b9a14d 100644 --- a/drivers/gpu/drm/ast/ast_main.c +++ b/drivers/gpu/drm/ast/ast_main.c @@ -1,5 +1,6 @@ /* * Copyright 2012 Red Hat Inc. + * Copyright 2018 Raptor Engineering, LLC. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the @@ -32,6 +33,8 @@ #include #include +extern int ast_resetpalette; + void ast_set_index_reg_mask(struct ast_private *ast, uint32_t base, uint8_t index, uint8_t mask, uint8_t val) @@ -483,6 +486,7 @@ int ast_driver_load(struct drm_device *dev, unsigned long flags) struct ast_private *ast; bool need_post; int ret = 0; + int index = 0; ast = kzalloc(sizeof(struct ast_private), GFP_KERNEL); if (!ast) @@ -565,6 +569,10 @@ int ast_driver_load(struct drm_device *dev, unsigned long flags) if (ret) goto out_free; + if (ast_resetpalette == 1) + for (index = 0x00; index < 0x100; index++) + ast_load_palette_index(ast, index, index, index, index); + return 0; out_free: kfree(ast); diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c index 9555a3542022..9afc4d53bd60 100644 --- a/drivers/gpu/drm/ast/ast_mode.c +++ b/drivers/gpu/drm/ast/ast_mode.c @@ -46,20 +46,6 @@ static int ast_cursor_set(struct drm_crtc *crtc, static int ast_cursor_move(struct drm_crtc *crtc, int x, int y); -static inline void ast_load_palette_index(struct ast_private *ast, -u8 index, u8 red, u8 green, -u8 blue) -{ - ast_io_write8(ast, AST_IO_DAC_INDEX_WRITE, index); - ast_io_read8(ast, AST_IO_SEQ_PORT); - ast_io_write8(ast, AST_IO_DAC_DATA, red); - ast_io_read8(ast, AST_IO_SEQ_PORT); - ast_io_write8(ast, AST_IO_DAC_DATA, green); - ast_io_read8(ast, AST_IO_SEQ_PORT); - ast_io_write8(ast, AST_IO_DAC_DATA, blue); - ast_io_read8(ast, AST_IO_SEQ_PORT); -} - static void ast_crtc_load_lut(struct drm_crtc *crtc) { struct ast_private *ast = crtc->dev->dev_private; -- 2.15.1 ___ dri-devel mailing list dri-devel@lists.freedesktop.org ht
[PATCH v2] drm/ast: Add option to initialize palette on driver load
Non-x86 systems, such as OpenPOWER and ARM machines, do not execute the ASPEED- provided option ROM on system start. As a result, the VGA palette registers remain uninitialized, leading to odd colors and generally hard to read output on the VGA port. Add a new module option, ast_resetpalette, to enable loading a linear greyscale palette into the VGA RAMDAC. This option is intended for use by the first Linux kernel to load after initial power on, such as the skiroot kernel on OpenPOWER systems. Signed-off-by: Timothy Pearson --- drivers/gpu/drm/ast/ast_drv.c | 4 drivers/gpu/drm/ast/ast_drv.h | 14 ++ drivers/gpu/drm/ast/ast_main.c | 8 drivers/gpu/drm/ast/ast_mode.c | 14 -- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c index 69dab82a3771..8124eaa92ed3 100644 --- a/drivers/gpu/drm/ast/ast_drv.c +++ b/drivers/gpu/drm/ast/ast_drv.c @@ -1,5 +1,6 @@ /* * Copyright 2012 Red Hat Inc. + * Copyright 2018 Raptor Engineering, LLC. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the @@ -34,9 +35,12 @@ #include "ast_drv.h" int ast_modeset = -1; +int ast_resetpalette = -1; MODULE_PARM_DESC(modeset, "Disable/Enable modesetting"); +MODULE_PARM_DESC(resetpalette, "Disable/Enable palette reset on load"); module_param_named(modeset, ast_modeset, int, 0400); +module_param_named(resetpalette, ast_resetpalette, int, 0400); #define PCI_VENDOR_ASPEED 0x1a03 diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h index e6c4cd3dc50e..5e834e466b65 100644 --- a/drivers/gpu/drm/ast/ast_drv.h +++ b/drivers/gpu/drm/ast/ast_drv.h @@ -383,6 +383,20 @@ static inline int ast_bo_reserve(struct ast_bo *bo, bool no_wait) return 0; } +static inline void ast_load_palette_index(struct ast_private *ast, +u8 index, u8 red, u8 green, +u8 blue) +{ + ast_io_write8(ast, AST_IO_DAC_INDEX_WRITE, index); + ast_io_read8(ast, AST_IO_SEQ_PORT); + ast_io_write8(ast, AST_IO_DAC_DATA, red); + ast_io_read8(ast, AST_IO_SEQ_PORT); + ast_io_write8(ast, AST_IO_DAC_DATA, green); + ast_io_read8(ast, AST_IO_SEQ_PORT); + ast_io_write8(ast, AST_IO_DAC_DATA, blue); + ast_io_read8(ast, AST_IO_SEQ_PORT); +} + static inline void ast_bo_unreserve(struct ast_bo *bo) { ttm_bo_unreserve(&bo->bo); diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c index dac355812adc..f13329b9a14d 100644 --- a/drivers/gpu/drm/ast/ast_main.c +++ b/drivers/gpu/drm/ast/ast_main.c @@ -1,5 +1,6 @@ /* * Copyright 2012 Red Hat Inc. + * Copyright 2018 Raptor Engineering, LLC. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the @@ -32,6 +33,8 @@ #include #include +extern int ast_resetpalette; + void ast_set_index_reg_mask(struct ast_private *ast, uint32_t base, uint8_t index, uint8_t mask, uint8_t val) @@ -483,6 +486,7 @@ int ast_driver_load(struct drm_device *dev, unsigned long flags) struct ast_private *ast; bool need_post; int ret = 0; + int index = 0; ast = kzalloc(sizeof(struct ast_private), GFP_KERNEL); if (!ast) @@ -565,6 +569,10 @@ int ast_driver_load(struct drm_device *dev, unsigned long flags) if (ret) goto out_free; + if (ast_resetpalette == 1) + for (index = 0x00; index < 0x100; index++) + ast_load_palette_index(ast, index, index, index, index); + return 0; out_free: kfree(ast); diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c index 9555a3542022..9afc4d53bd60 100644 --- a/drivers/gpu/drm/ast/ast_mode.c +++ b/drivers/gpu/drm/ast/ast_mode.c @@ -46,20 +46,6 @@ static int ast_cursor_set(struct drm_crtc *crtc, static int ast_cursor_move(struct drm_crtc *crtc, int x, int y); -static inline void ast_load_palette_index(struct ast_private *ast, -u8 index, u8 red, u8 green, -u8 blue) -{ - ast_io_write8(ast, AST_IO_DAC_INDEX_WRITE, index); - ast_io_read8(ast, AST_IO_SEQ_PORT); - ast_io_write8(ast, AST_IO_DAC_DATA, red); - ast_io_read8(ast, AST_IO_SEQ_PORT); - ast_io_write8(ast, AST_IO_DAC_DATA, green); - ast_io_read8(ast, AST_IO_SEQ_PORT); - ast_io_write8(ast, AST_IO_DAC_DATA, blue); - ast_io_read8(ast, AST_IO_SEQ_PORT); -} - static void ast_crtc_load_lut(struct drm_crtc *crtc) { struct ast_private *ast = crtc->dev->dev_private; -- 2.15.1
[PATCH] drm/ast: Add option to initialize palette on driver load
Non-x86, such as OpenPOWER and ARM machines, do not execute the ASPEED-provided option ROM on system start. As a result, the VGA palette registers remain uninitialized, leading to odd colors and generally hard to read output on the VGA port. Add a new module option, ast_resetpalette, to enable loading a linear greyscale palette into the VGA RAMDAC. This option is intended for use by the first Linux kernel to load after initial power on, such as the skiroot kernel on OpenPOWER systems. Signed-off-by: Timothy Pearson --- drivers/gpu/drm/ast/ast_drv.c | 4 drivers/gpu/drm/ast/ast_drv.h | 14 ++ drivers/gpu/drm/ast/ast_main.c | 8 drivers/gpu/drm/ast/ast_mode.c | 14 -- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c index 69dab82a3771..8124eaa92ed3 100644 --- a/drivers/gpu/drm/ast/ast_drv.c +++ b/drivers/gpu/drm/ast/ast_drv.c @@ -1,5 +1,6 @@ /* * Copyright 2012 Red Hat Inc. + * Copyright 2018 Raptor Engineering, LLC. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the @@ -34,9 +35,12 @@ #include "ast_drv.h" int ast_modeset = -1; +int ast_resetpalette = -1; MODULE_PARM_DESC(modeset, "Disable/Enable modesetting"); +MODULE_PARM_DESC(resetpalette, "Disable/Enable palette reset on load"); module_param_named(modeset, ast_modeset, int, 0400); +module_param_named(resetpalette, ast_resetpalette, int, 0400); #define PCI_VENDOR_ASPEED 0x1a03 diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h index e6c4cd3dc50e..5e834e466b65 100644 --- a/drivers/gpu/drm/ast/ast_drv.h +++ b/drivers/gpu/drm/ast/ast_drv.h @@ -383,6 +383,20 @@ static inline int ast_bo_reserve(struct ast_bo *bo, bool no_wait) return 0; } +static inline void ast_load_palette_index(struct ast_private *ast, +u8 index, u8 red, u8 green, +u8 blue) +{ + ast_io_write8(ast, AST_IO_DAC_INDEX_WRITE, index); + ast_io_read8(ast, AST_IO_SEQ_PORT); + ast_io_write8(ast, AST_IO_DAC_DATA, red); + ast_io_read8(ast, AST_IO_SEQ_PORT); + ast_io_write8(ast, AST_IO_DAC_DATA, green); + ast_io_read8(ast, AST_IO_SEQ_PORT); + ast_io_write8(ast, AST_IO_DAC_DATA, blue); + ast_io_read8(ast, AST_IO_SEQ_PORT); +} + static inline void ast_bo_unreserve(struct ast_bo *bo) { ttm_bo_unreserve(&bo->bo); diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c index dac355812adc..c15c55f69e38 100644 --- a/drivers/gpu/drm/ast/ast_main.c +++ b/drivers/gpu/drm/ast/ast_main.c @@ -1,5 +1,6 @@ /* * Copyright 2012 Red Hat Inc. + * Copyright 2018 Raptor Engineering, LLC. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the @@ -32,6 +33,8 @@ #include #include +extern int ast_resetpalette; + void ast_set_index_reg_mask(struct ast_private *ast, uint32_t base, uint8_t index, uint8_t mask, uint8_t val) @@ -483,6 +486,7 @@ int ast_driver_load(struct drm_device *dev, unsigned long flags) struct ast_private *ast; bool need_post; int ret = 0; + int index = 0; ast = kzalloc(sizeof(struct ast_private), GFP_KERNEL); if (!ast) @@ -516,6 +520,10 @@ int ast_driver_load(struct drm_device *dev, unsigned long flags) } } + if (ast_resetpalette == 1) + for (index = 0x00; index < 0x100; index++) + ast_load_palette_index(ast, index, index, index, index); + ast_detect_chip(dev, &need_post); if (need_post) diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c index 9555a3542022..9afc4d53bd60 100644 --- a/drivers/gpu/drm/ast/ast_mode.c +++ b/drivers/gpu/drm/ast/ast_mode.c @@ -46,20 +46,6 @@ static int ast_cursor_set(struct drm_crtc *crtc, static int ast_cursor_move(struct drm_crtc *crtc, int x, int y); -static inline void ast_load_palette_index(struct ast_private *ast, -u8 index, u8 red, u8 green, -u8 blue) -{ - ast_io_write8(ast, AST_IO_DAC_INDEX_WRITE, index); - ast_io_read8(ast, AST_IO_SEQ_PORT); - ast_io_write8(ast, AST_IO_DAC_DATA, red); - ast_io_read8(ast, AST_IO_SEQ_PORT); - ast_io_write8(ast, AST_IO_DAC_DATA, green); - ast_io_read8(ast, AST_IO_SEQ_PORT); - ast_io_write8(ast, AST_IO_DAC_DATA, blue); - ast_io_read8(ast, AST_IO_SEQ_PORT); -} - static void ast_crtc_load_lut(struct drm_crtc *crtc) { struct ast_private *ast = crtc->dev->dev_private; -- 2.15.1 __
[PATCH] drm/ast: Fix incorrect memory size detection with analog VGA
On mainboards with analog VGA output the memory size is incorrectly detected due to an invalid register probe. This leads to a corrupted and unusable framebuffer on the analog VGA output. Do not probe the DP501-related VGA scratch register if the DP501 device was not detected. Tested-on: ASUS KGPE-D16 (AST2050) w/ 8MB VRAM. Signed-off-by: Timothy Pearson --- drivers/gpu/drm/ast/ast_main.c | 24 +--- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c index 7bc3aa6..090b571 100644 --- a/drivers/gpu/drm/ast/ast_main.c +++ b/drivers/gpu/drm/ast/ast_main.c @@ -372,17 +372,19 @@ static u32 ast_get_vram_info(struct drm_device *dev) case 3: vram_size = AST_VIDMEM_SIZE_64M; break; } - jreg = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0x99, 0xff); - switch (jreg & 0x03) { - case 1: - vram_size -= 0x10; - break; - case 2: - vram_size -= 0x20; - break; - case 3: - vram_size -= 0x40; - break; + if (ast->tx_chip_type == AST_TX_DP501) { + jreg = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0x99, 0xff); + switch (jreg & 0x03) { + case 1: + vram_size -= 0x10; + break; + case 2: + vram_size -= 0x20; + break; + case 3: + vram_size -= 0x40; + break; + } } return vram_size; -- 2.8.1
[PATCH] drm/ast: Fix incorrect register check for DRAM width
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 02/26/2016 03:29 PM, Timothy Pearson wrote: > During DRAM initialization on certain ASpeed devices, an incorrect > bit (bit 10) was checked in the "SDRAM Bus Width Status" register > to determine DRAM width. > > Query bit 6 instead in accordance with the Aspeed AST2050 datasheet v1.05. > > Signed-off-by: Timothy Pearson > --- > drivers/gpu/drm/ast/ast_main.c |2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c > index 9759009..b1480ac 100644 > --- a/drivers/gpu/drm/ast/ast_main.c > +++ b/drivers/gpu/drm/ast/ast_main.c > @@ -227,7 +227,7 @@ static int ast_get_dram_info(struct drm_device *dev) > } while (ast_read32(ast, 0x1) != 0x01); > data = ast_read32(ast, 0x10004); > > - if (data & 0x400) > + if (data & 0x40) > ast->dram_bus_width = 16; > else > ast->dram_bus_width = 32; Just wanted to give this a bump since I have not received any feedback on it. Thanks! - -- Timothy Pearson Raptor Engineering +1 (415) 727-8645 (direct line) +1 (512) 690-0200 (switchboard) http://www.raptorengineeringinc.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJW1eZsAAoJEK+E3vEXDOFbusEH/2HXEJ4MfTsV5FRmXQpqv4rh iqGbd/whbOl9HAwWwz1DgfDIoqjBvBUlrq4C/UEmkFIVo5cqZQQsUIHejsz/GEIx 2mpf1pTIaNnW8oK6w8QX2wxFiV4XOUallOHh+OPmUTZQFpDiJH7MgqWhZ7HNEsRi lyjYILfPw5Q1cRHKxCn+IPGgStPDr6ds5EbAlNNZKTgdRuUoPLW3LLAyZ6Gtjkwr FVSe4uIiLC1/HNlrhryFvsAPA6N5hUqFDxAZ7pLFKoRLJpteJnhr5tBJLnwScZlN 6zYZRmDieHHIomFK462SGo8lhyxc8bnbJkYuEKvNvOzdI7B4rriCUMWpIgw1ISg= =JWPN -END PGP SIGNATURE-
[PATCH] drm/ast: Fix incorrect register check for DRAM width
During DRAM initialization on certain ASpeed devices, an incorrect bit (bit 10) was checked in the "SDRAM Bus Width Status" register to determine DRAM width. Query bit 6 instead in accordance with the Aspeed AST2050 datasheet v1.05. Signed-off-by: Timothy Pearson --- drivers/gpu/drm/ast/ast_main.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c index 9759009..b1480ac 100644 --- a/drivers/gpu/drm/ast/ast_main.c +++ b/drivers/gpu/drm/ast/ast_main.c @@ -227,7 +227,7 @@ static int ast_get_dram_info(struct drm_device *dev) } while (ast_read32(ast, 0x1) != 0x01); data = ast_read32(ast, 0x10004); - if (data & 0x400) + if (data & 0x40) ast->dram_bus_width = 16; else ast->dram_bus_width = 32; -- 1.7.9.5
[PATCH] drm/ast: Fix incorrect register check for DRAM width
During DRAM initialization on certain ASpeed devices, an incorrect bit (bit 10) was checked in the "SDRAM Bus Width Status" register to determine DRAM width. Query bit 6 instead in accordance with the Aspeed AST2050 datasheet v1.05. Signed-off-by: Timothy Pearson --- drivers/gpu/drm/ast/ast_main.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c index 9759009..b1480ac 100644 --- a/drivers/gpu/drm/ast/ast_main.c +++ b/drivers/gpu/drm/ast/ast_main.c @@ -227,7 +227,7 @@ static int ast_get_dram_info(struct drm_device *dev) } while (ast_read32(ast, 0x1) != 0x01); data = ast_read32(ast, 0x10004); - if (data & 0x400) + if (data & 0x40) ast->dram_bus_width = 16; else ast->dram_bus_width = 32; -- 1.7.9.5