igd.asl rewrite
[coreboot.git] / src / northbridge / intel / sch / gma.c
blob5540eb1e3d7d65ee527f728c7877fe3de9633705
1 /*
2 * This file is part of the coreboot project.
4 * Copyright (C) 2008-2009 coresystems GmbH
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc.
20 #include <console/console.h>
21 #include <device/device.h>
22 #include <device/pci.h>
23 #include <device/pci_ids.h>
24 #include <drivers/intel/gma/i915.h>
25 #include "chip.h"
27 static void gma_func0_init(struct device *dev)
29 u32 reg32;
31 /* IGD needs to be bus master. */
32 reg32 = pci_read_config32(dev, PCI_COMMAND);
33 pci_write_config32(dev, PCI_COMMAND, reg32 | PCI_COMMAND_MASTER);
35 pci_dev_init(dev);
38 static void gma_set_subsystem(device_t dev, unsigned vendor, unsigned device)
40 if (!vendor || !device) {
41 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
42 pci_read_config32(dev, PCI_VENDOR_ID));
43 } else {
44 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
45 ((device & 0xffff) << 16) | (vendor & 0xffff));
49 const struct i915_gpu_controller_info *
50 intel_gma_get_controller_info(void)
52 device_t dev = dev_find_slot(0, PCI_DEVFN(0x2,0));
53 if (!dev) {
54 return NULL;
56 struct northbridge_intel_sch_config *chip = dev->chip_info;
57 return &chip->gfx;
60 static void gma_ssdt(void)
62 const struct i915_gpu_controller_info *gfx = intel_gma_get_controller_info();
63 if (!gfx) {
64 return;
67 drivers_intel_gma_displays_ssdt_generate(gfx);
70 static struct pci_operations gma_pci_ops = {
71 .set_subsystem = gma_set_subsystem,
74 static struct device_operations gma_func0_ops = {
75 .read_resources = pci_dev_read_resources,
76 .set_resources = pci_dev_set_resources,
77 .enable_resources = pci_dev_enable_resources,
78 .acpi_fill_ssdt_generator = gma_ssdt,
79 .init = gma_func0_init,
80 .scan_bus = 0,
81 .enable = 0,
82 .ops_pci = &gma_pci_ops,
85 static const struct pci_driver sch_gma_func0_driver __pci_driver = {
86 .ops = &gma_func0_ops,
87 .vendor = PCI_VENDOR_ID_INTEL,
88 .device = 0x8108,