From: Thomas Zimmermann <tzimmermann@suse.de>
To: daniel@ffwll.ch, airlied@redhat.com, sam@ravnborg.org,
emil.velikov@collabora.com, lyude@redhat.com, krzk@kernel.org,
john.p.donnelly@Oracle.com, rong.a.chen@intel.com,
kraxel@redhat.com, eich@suse.com, tiwai@suse.de
Cc: Thomas Zimmermann <tzimmermann@suse.de>, dri-devel@lists.freedesktop.org
Subject: [PATCH 2/8] drm/mgag200: Move register initialization into helper function
Date: Wed, 15 Jul 2020 16:58:56 +0200 [thread overview]
Message-ID: <20200715145902.13122-3-tzimmermann@suse.de> (raw)
In-Reply-To: <20200715145902.13122-1-tzimmermann@suse.de>
The mgag200 driver maps registers into the address space. Move the
code into a separate helper function. No functional changes.
One small difference is in the handling of SDRAM/SGRAM. MGA devices
can come with either SDRAM or SGRAM. So far, the driver checked for
SDRAM, which is the common case. The patch moves this code into a
separate helper and checks for SGRAM, which is the special case. The
test itself is the same as before.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/gpu/drm/mgag200/mgag200_drv.c | 37 ++++++++++++++++++++++-----
drivers/gpu/drm/mgag200/mgag200_reg.h | 2 ++
2 files changed, 32 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c
index 7189c7745baf..e50c682c4702 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.c
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
@@ -44,18 +44,26 @@ static struct drm_driver mgag200_driver = {
* DRM device
*/
-static int mgag200_device_init(struct mga_device *mdev, unsigned long flags)
+static bool mgag200_has_sgram(struct mga_device *mdev)
{
struct drm_device *dev = &mdev->base;
- int ret, option;
+ u32 option;
+ int ret;
- mdev->flags = mgag200_flags_from_driver_data(flags);
- mdev->type = mgag200_type_from_driver_data(flags);
+ ret = pci_read_config_dword(dev->pdev, PCI_MGA_OPTION, &option);
+ if (drm_WARN(dev, ret, "failed to read PCI config dword: %d\n", ret))
+ return false;
+
+ return !!(option & PCI_MGA_OPTION_HARDPWMSK);
+}
- pci_read_config_dword(dev->pdev, PCI_MGA_OPTION, &option);
- mdev->has_sdram = !(option & (1 << 14));
+static int mgag200_regs_init(struct mga_device *mdev)
+{
+ struct drm_device *dev = &mdev->base;
+
+ mdev->has_sdram = !mgag200_has_sgram(mdev);
- /* BAR 0 is the framebuffer, BAR 1 contains registers */
+ /* BAR 1 contains registers */
mdev->rmmio_base = pci_resource_start(dev->pdev, 1);
mdev->rmmio_size = pci_resource_len(dev->pdev, 1);
@@ -69,6 +77,21 @@ static int mgag200_device_init(struct mga_device *mdev, unsigned long flags)
if (mdev->rmmio == NULL)
return -ENOMEM;
+ return 0;
+}
+
+static int mgag200_device_init(struct mga_device *mdev, unsigned long flags)
+{
+ struct drm_device *dev = &mdev->base;
+ int ret;
+
+ mdev->flags = mgag200_flags_from_driver_data(flags);
+ mdev->type = mgag200_type_from_driver_data(flags);
+
+ ret = mgag200_regs_init(mdev);
+ if (ret)
+ return ret;
+
/* stash G200 SE model number for later use */
if (IS_G200_SE(mdev)) {
mdev->unique_rev_id = RREG32(0x1e24);
diff --git a/drivers/gpu/drm/mgag200/mgag200_reg.h b/drivers/gpu/drm/mgag200/mgag200_reg.h
index c3b7bcad52ed..a44c08bf4074 100644
--- a/drivers/gpu/drm/mgag200/mgag200_reg.h
+++ b/drivers/gpu/drm/mgag200/mgag200_reg.h
@@ -282,6 +282,8 @@
#define PCI_MGA_OPTION2 0x50
#define PCI_MGA_OPTION3 0x54
+#define PCI_MGA_OPTION_HARDPWMSK BIT(14)
+
#define RAMDAC_OFFSET 0x3c00
/* TVP3026 direct registers */
--
2.27.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2020-07-15 14:59 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-15 14:58 [PATCH 0/8] drm/mgag200: Support desktop chips Thomas Zimmermann
2020-07-15 14:58 ` [PATCH 1/8] drm/mgag200: Enable caching for SHMEM pages Thomas Zimmermann
2020-07-15 14:58 ` Thomas Zimmermann [this message]
2020-07-15 14:58 ` [PATCH 3/8] drm/mgag200: Initialize PCI registers early during device setup Thomas Zimmermann
2020-07-15 14:58 ` [PATCH 4/8] drm/mgag200: Enable MGA mode during device register initialization Thomas Zimmermann
2020-07-15 14:58 ` [PATCH 5/8] drm/mgag200: Set MISC memory flags in mm init code Thomas Zimmermann
2020-07-15 14:59 ` [PATCH 6/8] drm/mgag200: Clear <page> field during MM init Thomas Zimmermann
2020-07-15 14:59 ` [PATCH 7/8] drm/mgag200: Move G200SE's unique id into model-specific data Thomas Zimmermann
2020-07-15 14:59 ` [PATCH 8/8] drm/mgag200: Add support for G200 desktop cards Thomas Zimmermann
2020-07-16 22:43 ` Lyude Paul
2020-07-17 5:45 ` Sam Ravnborg
2020-07-20 7:04 ` Thomas Zimmermann
2020-07-20 19:18 ` Lyude Paul
2020-07-20 20:16 ` Sam Ravnborg
2020-07-21 7:19 ` Thomas Zimmermann
2020-07-15 19:56 ` [PATCH 0/8] drm/mgag200: Support desktop chips Dave Airlie
2020-07-15 20:48 ` Daniel Vetter
2020-07-16 5:44 ` Thomas Zimmermann
2020-07-16 5:55 ` Thomas Zimmermann
2020-07-16 8:22 ` Egbert Eich
2020-07-15 22:32 ` Lyude Paul
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200715145902.13122-3-tzimmermann@suse.de \
--to=tzimmermann@suse.de \
--cc=airlied@redhat.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=eich@suse.com \
--cc=emil.velikov@collabora.com \
--cc=john.p.donnelly@Oracle.com \
--cc=kraxel@redhat.com \
--cc=krzk@kernel.org \
--cc=lyude@redhat.com \
--cc=rong.a.chen@intel.com \
--cc=sam@ravnborg.org \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).