blob: 57699ff1390c767aaa79f4884bc236b22db8fefe [file] [log] [blame]
Ronald G. Minnichfa2df752003-08-27 14:33:13 +00001/*
Uwe Hermannc6a10622010-10-17 19:30:58 +00002 * This file is part of the coreboot project.
Ronald G. Minnichfa2df752003-08-27 14:33:13 +00003 *
Uwe Hermannc6a10622010-10-17 19:30:58 +00004 * 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.
Ronald G. Minnichfa2df752003-08-27 14:33:13 +000015 */
Uwe Hermannc6a10622010-10-17 19:30:58 +000016
Ronald G. Minnichfa2df752003-08-27 14:33:13 +000017#include <console/console.h>
18#include <device/device.h>
19#include <device/pci.h>
20#include <device/pci_ids.h>
21#include <device/pci_ops.h>
22
23static void agp3bridge_init(device_t dev)
24{
Ronald G. Minniche4fc0ab2004-03-12 15:13:38 +000025 uint8_t byte;
Li-Ta Loa60bf672004-05-10 19:33:27 +000026
Li-Ta Lob7ae8cf2004-05-13 20:40:12 +000027 /* Enable BM, MEM and IO */
Ronald G. Minniche4fc0ab2004-03-12 15:13:38 +000028 byte = pci_read_config32(dev, 0x04);
Li-Ta Lob7ae8cf2004-05-13 20:40:12 +000029 byte |= 0x07;
30 pci_write_config8(dev, 0x04, byte);
Li-Ta Loa60bf672004-05-10 19:33:27 +000031
Ronald G. Minnichfa2df752003-08-27 14:33:13 +000032 return;
33}
34
35static struct device_operations agp3bridge_ops = {
Li-Ta Lob7ae8cf2004-05-13 20:40:12 +000036 .read_resources = pci_bus_read_resources,
37 .set_resources = pci_dev_set_resources,
Eric Biedermane9a271e32003-09-02 03:36:25 +000038 .enable_resources = pci_bus_enable_resources,
Li-Ta Lob7ae8cf2004-05-13 20:40:12 +000039 .init = agp3bridge_init,
40 .scan_bus = pci_scan_bridge,
Ronald G. Minnichfa2df752003-08-27 14:33:13 +000041};
42
Stefan Reinauerf1cf1f72007-10-24 09:08:58 +000043static const struct pci_driver agp3bridge_driver __pci_driver = {
Li-Ta Lob7ae8cf2004-05-13 20:40:12 +000044 .ops = &agp3bridge_ops,
45 .vendor = PCI_VENDOR_ID_AMD,
46 .device = 0x7455, // AGP Bridge
Ronald G. Minnichfa2df752003-08-27 14:33:13 +000047};
48
Ronald G. Minnichfa2df752003-08-27 14:33:13 +000049static void agp3dev_enable(device_t dev)
50{
51 uint32_t value;
Stefan Reinauer14e22772010-04-27 06:56:47 +000052
Li-Ta Lob7ae8cf2004-05-13 20:40:12 +000053 /* AGP enable */
54 value = pci_read_config32(dev, 0xa8);
55 value |= (3<<8)|2; //AGP 8x
56 pci_write_config32(dev, 0xa8, value);
Ronald G. Minnichfa2df752003-08-27 14:33:13 +000057
Li-Ta Lob7ae8cf2004-05-13 20:40:12 +000058 /* enable BM and MEM */
59 value = pci_read_config32(dev, 0x4);
60 value |= 6;
61 pci_write_config32(dev, 0x4, value);
62#if 0
63 /* FIXME: should we add agp aperture base and size here ?
64 * or it is done by AGP drivers */
65#endif
Ronald G. Minnichfa2df752003-08-27 14:33:13 +000066}
67
Yinghai Lueefdb032004-10-27 00:37:30 +000068static struct pci_operations pci_ops_pci_dev = {
69 .set_subsystem = pci_dev_set_subsystem,
70};
71
Ronald G. Minnichfa2df752003-08-27 14:33:13 +000072static struct device_operations agp3dev_ops = {
Eric Biedermane9a271e32003-09-02 03:36:25 +000073 .read_resources = pci_dev_read_resources,
74 .set_resources = pci_dev_set_resources,
75 .enable_resources = pci_dev_enable_resources,
Ronald G. Minnichfa2df752003-08-27 14:33:13 +000076 .init = 0,
77 .scan_bus = 0,
78 .enable = agp3dev_enable,
Yinghai Lueefdb032004-10-27 00:37:30 +000079 .ops_pci = &pci_ops_pci_dev,
Ronald G. Minnichfa2df752003-08-27 14:33:13 +000080};
81
Stefan Reinauerf1cf1f72007-10-24 09:08:58 +000082static const struct pci_driver agp3dev_driver __pci_driver = {
Ronald G. Minnichfa2df752003-08-27 14:33:13 +000083 .ops = &agp3dev_ops,
84 .vendor = PCI_VENDOR_ID_AMD,
Stefan Reinauer14e22772010-04-27 06:56:47 +000085 .device = 0x7454, //AGP Device
Ronald G. Minnichfa2df752003-08-27 14:33:13 +000086};