2020-04-05 15:46:45 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2015-05-06 00:07:29 +02:00
|
|
|
|
2015-04-21 00:20:28 +02:00
|
|
|
#include "chip.h"
|
2015-05-06 00:07:29 +02:00
|
|
|
#include <console/console.h>
|
|
|
|
#include <device/device.h>
|
|
|
|
#include <device/pci.h>
|
|
|
|
#include <device/pci_ids.h>
|
2017-07-01 20:02:47 +02:00
|
|
|
#include <drivers/intel/gma/opregion.h>
|
2020-03-29 23:58:48 +02:00
|
|
|
#include <drivers/intel/gma/i915.h>
|
2015-05-06 00:07:29 +02:00
|
|
|
#include <reg_script.h>
|
|
|
|
#include <soc/gfx.h>
|
|
|
|
#include <soc/pci_devs.h>
|
|
|
|
#include <soc/ramstage.h>
|
|
|
|
|
|
|
|
static const struct reg_script gpu_pre_vbios_script[] = {
|
|
|
|
/* Make sure GFX is bus master with MMIO access */
|
2020-07-25 02:46:39 +02:00
|
|
|
REG_PCI_OR32(PCI_COMMAND, PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY),
|
2015-05-06 00:07:29 +02:00
|
|
|
REG_SCRIPT_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct reg_script gfx_post_vbios_script[] = {
|
|
|
|
/* Set Lock bits */
|
2020-03-19 00:31:58 +01:00
|
|
|
REG_PCI_RMW32(GGC, 0xffffffff, GGC_GGCLCK),
|
2015-04-21 00:20:28 +02:00
|
|
|
REG_PCI_RMW32(GSM_BASE, 0xffffffff, GSM_BDSM_LOCK),
|
|
|
|
REG_PCI_RMW32(GTT_BASE, 0xffffffff, GTT_BGSM_LOCK),
|
2015-05-06 00:07:29 +02:00
|
|
|
REG_SCRIPT_END
|
|
|
|
};
|
|
|
|
|
2020-03-19 00:31:58 +01:00
|
|
|
static inline void gfx_run_script(struct device *dev, const struct reg_script *ops)
|
2015-05-06 00:07:29 +02:00
|
|
|
{
|
|
|
|
reg_script_run_on_dev(dev, ops);
|
|
|
|
}
|
|
|
|
|
2018-05-24 22:29:44 +02:00
|
|
|
static void gfx_pre_vbios_init(struct device *dev)
|
2015-05-06 00:07:29 +02:00
|
|
|
{
|
|
|
|
printk(BIOS_INFO, "GFX: Pre VBIOS Init\n");
|
|
|
|
gfx_run_script(dev, gpu_pre_vbios_script);
|
|
|
|
}
|
|
|
|
|
2018-05-24 22:29:44 +02:00
|
|
|
static void gfx_post_vbios_init(struct device *dev)
|
2015-05-06 00:07:29 +02:00
|
|
|
{
|
|
|
|
printk(BIOS_INFO, "GFX: Post VBIOS Init\n");
|
|
|
|
gfx_run_script(dev, gfx_post_vbios_script);
|
|
|
|
}
|
|
|
|
|
2018-05-24 22:29:44 +02:00
|
|
|
static void gfx_init(struct device *dev)
|
2015-05-06 00:07:29 +02:00
|
|
|
{
|
2020-04-26 17:01:25 +02:00
|
|
|
intel_gma_init_igd_opregion();
|
|
|
|
|
2019-03-06 01:53:33 +01:00
|
|
|
if (!CONFIG(RUN_FSP_GOP)) {
|
2018-06-20 07:40:48 +02:00
|
|
|
/* Pre VBIOS Init */
|
|
|
|
gfx_pre_vbios_init(dev);
|
2015-05-06 00:07:29 +02:00
|
|
|
|
2018-06-20 07:40:48 +02:00
|
|
|
/* Run VBIOS */
|
|
|
|
pci_dev_init(dev);
|
2017-07-01 20:02:47 +02:00
|
|
|
|
2018-06-20 07:40:48 +02:00
|
|
|
/* Post VBIOS Init */
|
|
|
|
gfx_post_vbios_init(dev);
|
|
|
|
}
|
2015-05-06 00:07:29 +02:00
|
|
|
}
|
|
|
|
|
2020-04-25 06:59:21 +02:00
|
|
|
static void gma_generate_ssdt(const struct device *dev)
|
2020-03-29 23:58:48 +02:00
|
|
|
{
|
|
|
|
const struct soc_intel_braswell_config *chip = dev->chip_info;
|
|
|
|
|
|
|
|
drivers_intel_gma_displays_ssdt_generate(&chip->gfx);
|
|
|
|
}
|
|
|
|
|
2015-05-06 00:07:29 +02:00
|
|
|
static struct device_operations gfx_device_ops = {
|
2015-11-05 23:27:06 +01:00
|
|
|
.read_resources = pci_dev_read_resources,
|
2015-05-06 00:07:29 +02:00
|
|
|
.set_resources = pci_dev_set_resources,
|
|
|
|
.enable_resources = pci_dev_enable_resources,
|
|
|
|
.init = gfx_init,
|
|
|
|
.ops_pci = &soc_pci_ops,
|
2020-03-29 23:58:48 +02:00
|
|
|
.acpi_fill_ssdt = gma_generate_ssdt,
|
2015-05-06 00:07:29 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct pci_driver gfx_driver __pci_driver = {
|
|
|
|
.ops = &gfx_device_ops,
|
|
|
|
.vendor = PCI_VENDOR_ID_INTEL,
|
|
|
|
.device = GFX_DEVID,
|
|
|
|
};
|