1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <console/console.h>
5 #include <device/device.h>
6 #include <device/pci.h>
7 #include <device/pci_ids.h>
8 #include <drivers/intel/gma/opregion.h>
9 #include <drivers/intel/gma/i915.h>
10 #include <reg_script.h>
12 #include <soc/pci_devs.h>
13 #include <soc/ramstage.h>
15 static const struct reg_script gpu_pre_vbios_script
[] = {
16 /* Make sure GFX is bus master with MMIO access */
17 REG_PCI_OR32(PCI_COMMAND
, PCI_COMMAND_MASTER
| PCI_COMMAND_MEMORY
),
21 static const struct reg_script gfx_post_vbios_script
[] = {
23 REG_PCI_RMW32(GGC
, 0xffffffff, GGC_GGCLCK
),
24 REG_PCI_RMW32(GSM_BASE
, 0xffffffff, GSM_BDSM_LOCK
),
25 REG_PCI_RMW32(GTT_BASE
, 0xffffffff, GTT_BGSM_LOCK
),
29 static inline void gfx_run_script(struct device
*dev
, const struct reg_script
*ops
)
31 reg_script_run_on_dev(dev
, ops
);
34 static void gfx_pre_vbios_init(struct device
*dev
)
36 printk(BIOS_INFO
, "GFX: Pre VBIOS Init\n");
37 gfx_run_script(dev
, gpu_pre_vbios_script
);
40 static void gfx_post_vbios_init(struct device
*dev
)
42 printk(BIOS_INFO
, "GFX: Post VBIOS Init\n");
43 gfx_run_script(dev
, gfx_post_vbios_script
);
46 static void gfx_init(struct device
*dev
)
48 intel_gma_init_igd_opregion();
50 if (!CONFIG(RUN_FSP_GOP
)) {
52 gfx_pre_vbios_init(dev
);
58 gfx_post_vbios_init(dev
);
62 static void gma_generate_ssdt(const struct device
*dev
)
64 const struct soc_intel_braswell_config
*chip
= dev
->chip_info
;
66 drivers_intel_gma_displays_ssdt_generate(&chip
->gfx
);
69 static struct device_operations gfx_device_ops
= {
70 .read_resources
= pci_dev_read_resources
,
71 .set_resources
= pci_dev_set_resources
,
72 .enable_resources
= pci_dev_enable_resources
,
74 .ops_pci
= &soc_pci_ops
,
75 .acpi_fill_ssdt
= gma_generate_ssdt
,
78 static const struct pci_driver gfx_driver __pci_driver
= {
79 .ops
= &gfx_device_ops
,
80 .vendor
= PCI_VID_INTEL
,