Ronald G. Minnich | fa2df75 | 2003-08-27 14:33:13 +0000 | [diff] [blame] | 1 | /* |
Uwe Hermann | c6a1062 | 2010-10-17 19:30:58 +0000 | [diff] [blame] | 2 | * This file is part of the coreboot project. |
Ronald G. Minnich | fa2df75 | 2003-08-27 14:33:13 +0000 | [diff] [blame] | 3 | * |
Uwe Hermann | c6a1062 | 2010-10-17 19:30:58 +0000 | [diff] [blame] | 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. |
Ronald G. Minnich | fa2df75 | 2003-08-27 14:33:13 +0000 | [diff] [blame] | 15 | */ |
Uwe Hermann | c6a1062 | 2010-10-17 19:30:58 +0000 | [diff] [blame] | 16 | |
Ronald G. Minnich | fa2df75 | 2003-08-27 14:33:13 +0000 | [diff] [blame] | 17 | #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 | |
| 23 | static void agp3bridge_init(device_t dev) |
| 24 | { |
Ronald G. Minnich | e4fc0ab | 2004-03-12 15:13:38 +0000 | [diff] [blame] | 25 | uint8_t byte; |
Li-Ta Lo | a60bf67 | 2004-05-10 19:33:27 +0000 | [diff] [blame] | 26 | |
Li-Ta Lo | b7ae8cf | 2004-05-13 20:40:12 +0000 | [diff] [blame] | 27 | /* Enable BM, MEM and IO */ |
Ronald G. Minnich | e4fc0ab | 2004-03-12 15:13:38 +0000 | [diff] [blame] | 28 | byte = pci_read_config32(dev, 0x04); |
Li-Ta Lo | b7ae8cf | 2004-05-13 20:40:12 +0000 | [diff] [blame] | 29 | byte |= 0x07; |
| 30 | pci_write_config8(dev, 0x04, byte); |
Li-Ta Lo | a60bf67 | 2004-05-10 19:33:27 +0000 | [diff] [blame] | 31 | |
Ronald G. Minnich | fa2df75 | 2003-08-27 14:33:13 +0000 | [diff] [blame] | 32 | return; |
| 33 | } |
| 34 | |
| 35 | static struct device_operations agp3bridge_ops = { |
Li-Ta Lo | b7ae8cf | 2004-05-13 20:40:12 +0000 | [diff] [blame] | 36 | .read_resources = pci_bus_read_resources, |
| 37 | .set_resources = pci_dev_set_resources, |
Eric Biederman | e9a271e3 | 2003-09-02 03:36:25 +0000 | [diff] [blame] | 38 | .enable_resources = pci_bus_enable_resources, |
Li-Ta Lo | b7ae8cf | 2004-05-13 20:40:12 +0000 | [diff] [blame] | 39 | .init = agp3bridge_init, |
| 40 | .scan_bus = pci_scan_bridge, |
Ronald G. Minnich | fa2df75 | 2003-08-27 14:33:13 +0000 | [diff] [blame] | 41 | }; |
| 42 | |
Stefan Reinauer | f1cf1f7 | 2007-10-24 09:08:58 +0000 | [diff] [blame] | 43 | static const struct pci_driver agp3bridge_driver __pci_driver = { |
Li-Ta Lo | b7ae8cf | 2004-05-13 20:40:12 +0000 | [diff] [blame] | 44 | .ops = &agp3bridge_ops, |
| 45 | .vendor = PCI_VENDOR_ID_AMD, |
| 46 | .device = 0x7455, // AGP Bridge |
Ronald G. Minnich | fa2df75 | 2003-08-27 14:33:13 +0000 | [diff] [blame] | 47 | }; |
| 48 | |
Ronald G. Minnich | fa2df75 | 2003-08-27 14:33:13 +0000 | [diff] [blame] | 49 | static void agp3dev_enable(device_t dev) |
| 50 | { |
| 51 | uint32_t value; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 52 | |
Li-Ta Lo | b7ae8cf | 2004-05-13 20:40:12 +0000 | [diff] [blame] | 53 | /* 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. Minnich | fa2df75 | 2003-08-27 14:33:13 +0000 | [diff] [blame] | 57 | |
Li-Ta Lo | b7ae8cf | 2004-05-13 20:40:12 +0000 | [diff] [blame] | 58 | /* 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. Minnich | fa2df75 | 2003-08-27 14:33:13 +0000 | [diff] [blame] | 66 | } |
| 67 | |
Yinghai Lu | eefdb03 | 2004-10-27 00:37:30 +0000 | [diff] [blame] | 68 | static struct pci_operations pci_ops_pci_dev = { |
| 69 | .set_subsystem = pci_dev_set_subsystem, |
| 70 | }; |
| 71 | |
Ronald G. Minnich | fa2df75 | 2003-08-27 14:33:13 +0000 | [diff] [blame] | 72 | static struct device_operations agp3dev_ops = { |
Eric Biederman | e9a271e3 | 2003-09-02 03:36:25 +0000 | [diff] [blame] | 73 | .read_resources = pci_dev_read_resources, |
| 74 | .set_resources = pci_dev_set_resources, |
| 75 | .enable_resources = pci_dev_enable_resources, |
Ronald G. Minnich | fa2df75 | 2003-08-27 14:33:13 +0000 | [diff] [blame] | 76 | .init = 0, |
| 77 | .scan_bus = 0, |
| 78 | .enable = agp3dev_enable, |
Yinghai Lu | eefdb03 | 2004-10-27 00:37:30 +0000 | [diff] [blame] | 79 | .ops_pci = &pci_ops_pci_dev, |
Ronald G. Minnich | fa2df75 | 2003-08-27 14:33:13 +0000 | [diff] [blame] | 80 | }; |
| 81 | |
Stefan Reinauer | f1cf1f7 | 2007-10-24 09:08:58 +0000 | [diff] [blame] | 82 | static const struct pci_driver agp3dev_driver __pci_driver = { |
Ronald G. Minnich | fa2df75 | 2003-08-27 14:33:13 +0000 | [diff] [blame] | 83 | .ops = &agp3dev_ops, |
| 84 | .vendor = PCI_VENDOR_ID_AMD, |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 85 | .device = 0x7454, //AGP Device |
Ronald G. Minnich | fa2df75 | 2003-08-27 14:33:13 +0000 | [diff] [blame] | 86 | }; |