blob: 64407dce1e2be98f6f2a7d0af1c3a049be99a334 [file] [log] [blame]
Gerd Hoffmannee941b382013-06-07 16:03:44 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2004 Stefan Reinauer <stefan.reinauer@coreboot.org>
5 * Copyright (C) 2010 Kevin O'Connor <kevin@koconnor.net>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
Patrick Georgib890a122015-03-26 15:17:45 +010018 * Foundation, Inc.
Gerd Hoffmannee941b382013-06-07 16:03:44 +020019 */
20
21#include <device/device.h>
22#include <device/pci.h>
23#include <device/pci_ids.h>
24#include <device/pci_ops.h>
25#include <pc80/keyboard.h>
26#include <arch/io.h>
27#include <console/console.h>
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +010028#include <drivers/intel/gma/i915.h>
Gerd Hoffmannee941b382013-06-07 16:03:44 +020029
30#define Q35_PAM0 0x90
Gerd Hoffmannee941b382013-06-07 16:03:44 +020031
32static const unsigned char qemu_q35_irqs[] = {
33 10, 10, 11, 11,
34 10, 10, 11, 11,
35};
36
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +010037struct i915_gpu_controller_info gfx_controller_info = {
38 .ndid = 3,
39 .did = {
40 0x80000100, 0x80000240, 0x80000410, 0x80000410, 0x00000005
41 }
42};
43
44const struct i915_gpu_controller_info *
45intel_gma_get_controller_info(void)
Vladimir Serbinenko53be14c2015-05-29 09:16:17 +020046{
Vladimir Serbinenkodd2bc3f2014-10-31 09:16:31 +010047 return &gfx_controller_info;
48}
49
Gerd Hoffmannee941b382013-06-07 16:03:44 +020050static void qemu_nb_init(device_t dev)
51{
52 /* Map memory at 0xc0000 - 0xfffff */
53 int i;
54 uint8_t v = pci_read_config8(dev, Q35_PAM0);
55 v |= 0x30;
56 pci_write_config8(dev, Q35_PAM0, v);
57 pci_write_config8(dev, Q35_PAM0 + 1, 0x33);
58 pci_write_config8(dev, Q35_PAM0 + 2, 0x33);
59 pci_write_config8(dev, Q35_PAM0 + 3, 0x33);
60 pci_write_config8(dev, Q35_PAM0 + 4, 0x33);
61 pci_write_config8(dev, Q35_PAM0 + 5, 0x33);
62 pci_write_config8(dev, Q35_PAM0 + 6, 0x33);
63
64 /* This sneaked in here, because Qemu does not
65 * emulate a SuperIO chip
66 */
Edward O'Callaghandef00be2014-04-30 05:01:52 +100067 pc_keyboard_init();
Gerd Hoffmannee941b382013-06-07 16:03:44 +020068
69 /* setup IRQ routing for pci slots */
70 for (i = 0; i < 25; i++)
71 pci_assign_irqs(0, i, qemu_q35_irqs + (i % 4));
72 /* setup IRQ routing southbridge devices */
73 for (i = 25; i < 32; i++)
74 pci_assign_irqs(0, i, qemu_q35_irqs);
Gerd Hoffmannee941b382013-06-07 16:03:44 +020075}
76
77static void qemu_nb_read_resources(struct device *dev)
78{
79 pci_dev_read_resources(dev);
80
81 /* reserve mmconfig */
Kyösti Mälkkib9646a22013-07-03 08:06:32 +030082 fixed_mem_resource(dev, 2, CONFIG_MMCONF_BASE_ADDRESS >> 10, 0x10000000 >> 10,
Gerd Hoffmannee941b382013-06-07 16:03:44 +020083 IORESOURCE_RESERVE);
84}
85
86
87static struct device_operations nb_operations = {
88 .read_resources = qemu_nb_read_resources,
89 .set_resources = pci_dev_set_resources,
90 .enable_resources = pci_dev_enable_resources,
91 .init = qemu_nb_init,
92 .ops_pci = 0,
93};
94
95static const struct pci_driver nb_driver __pci_driver = {
96 .ops = &nb_operations,
97 .vendor = 0x8086,
98 .device = 0x29c0,
99};