Add more missing GPL-headers, fix inconsistencies in others.
[coreboot.git] / src / southbridge / amd / amd8151 / amd8151_agp3.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2003 Tyan Computer
5  * Written by Yinghai Lu <yhlu@tyan.com> for Tyan Computer.
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
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
19  */
20
21 #include <console/console.h>
22 #include <device/device.h>
23 #include <device/pci.h>
24 #include <device/pci_ids.h>
25 #include <device/pci_ops.h>
26
27 static void agp3bridge_init(device_t dev)
28 {
29         uint8_t byte;
30
31         /* Enable BM, MEM and IO */
32         byte = pci_read_config32(dev, 0x04);
33         byte |= 0x07;
34         pci_write_config8(dev, 0x04, byte);
35
36         return;
37 }
38
39 static struct device_operations agp3bridge_ops  = {
40         .read_resources   = pci_bus_read_resources,
41         .set_resources    = pci_dev_set_resources,
42         .enable_resources = pci_bus_enable_resources,
43         .init             = agp3bridge_init,
44         .scan_bus         = pci_scan_bridge,
45 };
46
47 static const struct pci_driver agp3bridge_driver __pci_driver = {
48         .ops    = &agp3bridge_ops,
49         .vendor = PCI_VENDOR_ID_AMD,
50         .device = 0x7455, // AGP Bridge
51 };
52
53 static void agp3dev_enable(device_t dev)
54 {
55         uint32_t value;
56
57         /* AGP enable */
58         value = pci_read_config32(dev, 0xa8);
59         value |= (3<<8)|2; //AGP 8x
60         pci_write_config32(dev, 0xa8, value);
61
62         /* enable BM and MEM */
63         value = pci_read_config32(dev, 0x4);
64         value |= 6;
65         pci_write_config32(dev, 0x4, value);
66 #if 0
67         /* FIXME: should we add agp aperture base and size here ?
68          * or it is done by AGP drivers */
69 #endif
70 }
71
72 static struct pci_operations pci_ops_pci_dev = {
73         .set_subsystem    = pci_dev_set_subsystem,
74 };
75
76 static struct device_operations agp3dev_ops = {
77         .read_resources   = pci_dev_read_resources,
78         .set_resources    = pci_dev_set_resources,
79         .enable_resources = pci_dev_enable_resources,
80         .init     = 0,
81         .scan_bus = 0,
82         .enable   = agp3dev_enable,
83         .ops_pci  = &pci_ops_pci_dev,
84 };
85
86 static const struct pci_driver agp3dev_driver __pci_driver = {
87         .ops    = &agp3dev_ops,
88         .vendor = PCI_VENDOR_ID_AMD,
89         .device = 0x7454, //AGP Device
90 };