Commit 2021708e authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/mgag200: Initialize PCI registers early during device setup

So far, PCI option registers were initialized as part of modesetting,
which is late in the process. As these registers control fundamental
operation, they should be set early.

The patch moves the PCI option handling into device register setup,
before even the device MMIO memory is being mapped. No functional
changes made.

Moving the PCI code next to the device-register setup also allows to
remove the has_sdram field from struct mga_device. The state is now
local to the init helper.
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200730102844.10995-4-tzimmermann@suse.de
parent 42452165
...@@ -60,8 +60,38 @@ static bool mgag200_has_sgram(struct mga_device *mdev) ...@@ -60,8 +60,38 @@ static bool mgag200_has_sgram(struct mga_device *mdev)
static int mgag200_regs_init(struct mga_device *mdev) static int mgag200_regs_init(struct mga_device *mdev)
{ {
struct drm_device *dev = &mdev->base; struct drm_device *dev = &mdev->base;
u32 option, option2;
switch (mdev->type) {
case G200_SE_A:
case G200_SE_B:
if (mgag200_has_sgram(mdev))
option |= PCI_MGA_OPTION_HARDPWMSK;
option2 = 0x00008000;
break;
case G200_WB:
case G200_EW3:
option = 0x41049120;
option2 = 0x0000b000;
break;
case G200_EV:
option = 0x00000120;
option2 = 0x0000b000;
break;
case G200_EH:
case G200_EH3:
option = 0x00000120;
option2 = 0x0000b000;
break;
default:
option = 0;
option2 = 0;
}
mdev->has_sdram = !mgag200_has_sgram(mdev); if (option)
pci_write_config_dword(dev->pdev, PCI_MGA_OPTION, option);
if (option2)
pci_write_config_dword(dev->pdev, PCI_MGA_OPTION2, option2);
/* BAR 1 contains registers */ /* BAR 1 contains registers */
mdev->rmmio_base = pci_resource_start(dev->pdev, 1); mdev->rmmio_base = pci_resource_start(dev->pdev, 1);
......
...@@ -161,7 +161,6 @@ struct mga_device { ...@@ -161,7 +161,6 @@ struct mga_device {
size_t vram_fb_available; size_t vram_fb_available;
enum mga_type type; enum mga_type type;
int has_sdram;
int bpp_shifts[4]; int bpp_shifts[4];
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
*/ */
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/pci.h>
#include <drm/drm_atomic_helper.h> #include <drm/drm_atomic_helper.h>
#include <drm/drm_atomic_state_helper.h> #include <drm/drm_atomic_state_helper.h>
...@@ -877,45 +876,6 @@ static void mgag200_set_startadd(struct mga_device *mdev, ...@@ -877,45 +876,6 @@ static void mgag200_set_startadd(struct mga_device *mdev,
WREG_ECRT(0x00, crtcext0); WREG_ECRT(0x00, crtcext0);
} }
static void mgag200_set_pci_regs(struct mga_device *mdev)
{
uint32_t option = 0, option2 = 0;
struct drm_device *dev = &mdev->base;
switch (mdev->type) {
case G200_SE_A:
case G200_SE_B:
if (mdev->has_sdram)
option = 0x40049120;
else
option = 0x4004d120;
option2 = 0x00008000;
break;
case G200_WB:
case G200_EW3:
option = 0x41049120;
option2 = 0x0000b000;
break;
case G200_EV:
option = 0x00000120;
option2 = 0x0000b000;
break;
case G200_EH:
case G200_EH3:
option = 0x00000120;
option2 = 0x0000b000;
break;
case G200_ER:
break;
}
if (option)
pci_write_config_dword(dev->pdev, PCI_MGA_OPTION, option);
if (option2)
pci_write_config_dword(dev->pdev, PCI_MGA_OPTION2, option2);
}
static void mgag200_set_dac_regs(struct mga_device *mdev) static void mgag200_set_dac_regs(struct mga_device *mdev)
{ {
size_t i; size_t i;
...@@ -988,7 +948,6 @@ static void mgag200_init_regs(struct mga_device *mdev) ...@@ -988,7 +948,6 @@ static void mgag200_init_regs(struct mga_device *mdev)
{ {
u8 crtc11, crtcext3, crtcext4, misc; u8 crtc11, crtcext3, crtcext4, misc;
mgag200_set_pci_regs(mdev);
mgag200_set_dac_regs(mdev); mgag200_set_dac_regs(mdev);
WREG_SEQ(2, 0x0f); WREG_SEQ(2, 0x0f);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment