blob: 7e510f8eee1f39970df548f5779f99443bf9cfea [file] [log] [blame]
Uwe Hermannb80dbf02007-04-22 19:08:13 +00001/*
Stefan Reinauer7e61e452008-01-18 10:35:56 +00002 * This file is part of the coreboot project.
Uwe Hermannb80dbf02007-04-22 19:08:13 +00003 *
4 * Copyright (C) 2005 Linux Networx
5 * (Written by Eric Biederman <ebiederman@lnxi.com> for Linux Networx)
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 */
Yinghai Lu13f1c2a2005-07-08 02:49:49 +000020
21#include <console/console.h>
22#include <device/device.h>
23#include <device/pci.h>
24#include <device/pci_ids.h>
25#include <device/agp.h>
26
27static void agp_tune_dev(device_t dev)
28{
Uwe Hermanne4870472010-11-04 23:23:47 +000029 unsigned int cap;
30
Yinghai Lu13f1c2a2005-07-08 02:49:49 +000031 cap = pci_find_capability(dev, PCI_CAP_ID_AGP);
Uwe Hermanne4870472010-11-04 23:23:47 +000032 if (!cap)
Yinghai Lu13f1c2a2005-07-08 02:49:49 +000033 return;
Uwe Hermanne4870472010-11-04 23:23:47 +000034
35 /* The OS is responsible for AGP tuning so do nothing here. */
Yinghai Lu13f1c2a2005-07-08 02:49:49 +000036}
37
Uwe Hermanne4870472010-11-04 23:23:47 +000038unsigned int agp_scan_bus(struct bus *bus, unsigned int min_devfn,
39 unsigned int max_devfn, unsigned int max)
Yinghai Lu13f1c2a2005-07-08 02:49:49 +000040{
41 device_t child;
Uwe Hermanne4870472010-11-04 23:23:47 +000042
Yinghai Lu13f1c2a2005-07-08 02:49:49 +000043 max = pci_scan_bus(bus, min_devfn, max_devfn, max);
Uwe Hermanne4870472010-11-04 23:23:47 +000044
45 for (child = bus->children; child; child = child->sibling) {
46 if ((child->path.pci.devfn < min_devfn) ||
47 (child->path.pci.devfn > max_devfn)) {
Yinghai Lu13f1c2a2005-07-08 02:49:49 +000048 continue;
49 }
50 agp_tune_dev(child);
51 }
Uwe Hermanne4870472010-11-04 23:23:47 +000052
Yinghai Lu13f1c2a2005-07-08 02:49:49 +000053 return max;
54}
55
56unsigned int agp_scan_bridge(device_t dev, unsigned int max)
57{
58 return do_pci_scan_bridge(dev, max, agp_scan_bus);
59}
60
Uwe Hermanne4870472010-11-04 23:23:47 +000061/** Default device operations for AGP bridges. */
Yinghai Lu13f1c2a2005-07-08 02:49:49 +000062static struct pci_operations agp_bus_ops_pci = {
63 .set_subsystem = 0,
64};
65
66struct device_operations default_agp_ops_bus = {
67 .read_resources = pci_bus_read_resources,
68 .set_resources = pci_dev_set_resources,
69 .enable_resources = pci_bus_enable_resources,
Uwe Hermanne4870472010-11-04 23:23:47 +000070 .init = 0,
71 .scan_bus = agp_scan_bridge,
Yinghai Lu13f1c2a2005-07-08 02:49:49 +000072 .enable = 0,
73 .reset_bus = pci_bus_reset,
74 .ops_pci = &agp_bus_ops_pci,
75};