Commit aa4dc3ee authored by Jani Nikula's avatar Jani Nikula
Browse files

drm/i915: merge soc/intel_gmch.[ch] to display/intel_vga.c



The sole user of the remaining functions in intel_gmch.[ch] is in
intel_vga.c. Move everything there.

Since intel_gmch.c hasn't been part of xe, use a dummy function
relocated from xe_display_misc.c, with #ifdef. This is purely to keep
this change non-functional.

This allows us to remove soc/intel_gmch.[ch] from i915, compat
soc/intel_gmch.h from xe, and xe_display_misc.c from xe.

Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patch.msgid.link/b0f853ad7eae686738defa9e8f08a8848df8f226.1763578288.git.jani.nikula@intel.com


Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
parent fff15f68
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -57,10 +57,6 @@ i915-y += \
	vlv_iosf_sb.o \
	vlv_suspend.o

# core peripheral code
i915-y += \
	soc/intel_gmch.o

# core library code
i915-y += \
	i915_memcpy.o \
+50 −2
Original line number Diff line number Diff line
@@ -9,12 +9,12 @@

#include <drm/drm_device.h>
#include <drm/drm_print.h>
#include <drm/intel/i915_drm.h>
#include <video/vga.h>

#include "soc/intel_gmch.h"

#include "intel_de.h"
#include "intel_display.h"
#include "intel_display_types.h"
#include "intel_vga.h"
#include "intel_vga_regs.h"

@@ -95,6 +95,54 @@ void intel_vga_reset_io_mem(struct intel_display *display)
	vga_put(pdev, VGA_RSRC_LEGACY_IO);
}

#ifdef I915
static int intel_gmch_vga_set_state(struct intel_display *display, bool enable_decode)
{
	struct pci_dev *pdev = to_pci_dev(display->drm->dev);
	unsigned int reg = DISPLAY_VER(display) >= 6 ? SNB_GMCH_CTRL : INTEL_GMCH_CTRL;
	u16 gmch_ctrl;

	if (pci_bus_read_config_word(pdev->bus, PCI_DEVFN(0, 0), reg, &gmch_ctrl)) {
		drm_err(display->drm, "failed to read control word\n");
		return -EIO;
	}

	if (!!(gmch_ctrl & INTEL_GMCH_VGA_DISABLE) == !enable_decode)
		return 0;

	if (enable_decode)
		gmch_ctrl &= ~INTEL_GMCH_VGA_DISABLE;
	else
		gmch_ctrl |= INTEL_GMCH_VGA_DISABLE;

	if (pci_bus_write_config_word(pdev->bus, PCI_DEVFN(0, 0), reg, gmch_ctrl)) {
		drm_err(display->drm, "failed to write control word\n");
		return -EIO;
	}

	return 0;
}

static unsigned int intel_gmch_vga_set_decode(struct pci_dev *pdev, bool enable_decode)
{
	struct intel_display *display = to_intel_display(pdev);

	intel_gmch_vga_set_state(display, enable_decode);

	if (enable_decode)
		return VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM |
		       VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
	else
		return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
}
#else
static unsigned int intel_gmch_vga_set_decode(struct pci_dev *pdev, bool enable_decode)
{
	/* ToDo: Implement the actual handling of vga decode */
	return 0;
}
#endif

int intel_vga_register(struct intel_display *display)
{

+0 −56
Original line number Diff line number Diff line
// SPDX-License-Identifier: MIT
/*
 * Copyright © 2023 Intel Corporation
 */

#include <linux/pci.h>
#include <linux/vgaarb.h>

#include <drm/drm_print.h>
#include <drm/intel/i915_drm.h>

#include "../display/intel_display_core.h" /* FIXME */
#include "../display/intel_display_types.h" /* FIXME */

#include "intel_gmch.h"
#include "intel_pci_config.h"

static int intel_gmch_vga_set_state(struct intel_display *display, bool enable_decode)
{
	struct pci_dev *pdev = to_pci_dev(display->drm->dev);
	unsigned int reg = DISPLAY_VER(display) >= 6 ? SNB_GMCH_CTRL : INTEL_GMCH_CTRL;
	u16 gmch_ctrl;

	if (pci_bus_read_config_word(pdev->bus, PCI_DEVFN(0, 0), reg, &gmch_ctrl)) {
		drm_err(display->drm, "failed to read control word\n");
		return -EIO;
	}

	if (!!(gmch_ctrl & INTEL_GMCH_VGA_DISABLE) == !enable_decode)
		return 0;

	if (enable_decode)
		gmch_ctrl &= ~INTEL_GMCH_VGA_DISABLE;
	else
		gmch_ctrl |= INTEL_GMCH_VGA_DISABLE;

	if (pci_bus_write_config_word(pdev->bus, PCI_DEVFN(0, 0), reg, gmch_ctrl)) {
		drm_err(display->drm, "failed to write control word\n");
		return -EIO;
	}

	return 0;
}

unsigned int intel_gmch_vga_set_decode(struct pci_dev *pdev, bool enable_decode)
{
	struct intel_display *display = to_intel_display(pdev);

	intel_gmch_vga_set_state(display, enable_decode);

	if (enable_decode)
		return VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM |
		       VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
	else
		return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
}
+0 −15
Original line number Diff line number Diff line
/* SPDX-License-Identifier: MIT */
/*
 * Copyright © 2023 Intel Corporation
 */

#ifndef __INTEL_GMCH_H__
#define __INTEL_GMCH_H__

#include <linux/types.h>

struct pci_dev;

unsigned int intel_gmch_vga_set_decode(struct pci_dev *pdev, bool enable_decode);

#endif /* __INTEL_GMCH_H__ */
+0 −1
Original line number Diff line number Diff line
@@ -202,7 +202,6 @@ xe-$(CONFIG_DRM_XE_DISPLAY) += \
	display/intel_fb_bo.o \
	display/intel_fbdev_fb.o \
	display/xe_display.o \
	display/xe_display_misc.o \
	display/xe_display_rpm.o \
	display/xe_display_wa.o \
	display/xe_dsb_buffer.o \
Loading