aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/agp/amd64-agp.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/agp/amd64-agp.c')
-rw-r--r--drivers/char/agp/amd64-agp.c53
1 files changed, 35 insertions, 18 deletions
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index 70312da4c968..780498d76581 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -15,7 +15,7 @@
15#include <linux/mmzone.h> 15#include <linux/mmzone.h>
16#include <asm/page.h> /* PAGE_SIZE */ 16#include <asm/page.h> /* PAGE_SIZE */
17#include <asm/e820.h> 17#include <asm/e820.h>
18#include <asm/k8.h> 18#include <asm/amd_nb.h>
19#include <asm/gart.h> 19#include <asm/gart.h>
20#include "agp.h" 20#include "agp.h"
21 21
@@ -38,7 +38,7 @@ static int agp_bridges_found;
38 38
39static void amd64_tlbflush(struct agp_memory *temp) 39static void amd64_tlbflush(struct agp_memory *temp)
40{ 40{
41 k8_flush_garts(); 41 amd_flush_garts();
42} 42}
43 43
44static int amd64_insert_memory(struct agp_memory *mem, off_t pg_start, int type) 44static int amd64_insert_memory(struct agp_memory *mem, off_t pg_start, int type)
@@ -124,7 +124,7 @@ static int amd64_fetch_size(void)
124 u32 temp; 124 u32 temp;
125 struct aper_size_info_32 *values; 125 struct aper_size_info_32 *values;
126 126
127 dev = k8_northbridges[0]; 127 dev = node_to_amd_nb(0)->misc;
128 if (dev==NULL) 128 if (dev==NULL)
129 return 0; 129 return 0;
130 130
@@ -181,12 +181,15 @@ static int amd_8151_configure(void)
181 unsigned long gatt_bus = virt_to_phys(agp_bridge->gatt_table_real); 181 unsigned long gatt_bus = virt_to_phys(agp_bridge->gatt_table_real);
182 int i; 182 int i;
183 183
184 if (!amd_nb_has_feature(AMD_NB_GART))
185 return 0;
186
184 /* Configure AGP regs in each x86-64 host bridge. */ 187 /* Configure AGP regs in each x86-64 host bridge. */
185 for (i = 0; i < num_k8_northbridges; i++) { 188 for (i = 0; i < amd_nb_num(); i++) {
186 agp_bridge->gart_bus_addr = 189 agp_bridge->gart_bus_addr =
187 amd64_configure(k8_northbridges[i], gatt_bus); 190 amd64_configure(node_to_amd_nb(i)->misc, gatt_bus);
188 } 191 }
189 k8_flush_garts(); 192 amd_flush_garts();
190 return 0; 193 return 0;
191} 194}
192 195
@@ -195,11 +198,15 @@ static void amd64_cleanup(void)
195{ 198{
196 u32 tmp; 199 u32 tmp;
197 int i; 200 int i;
198 for (i = 0; i < num_k8_northbridges; i++) { 201
199 struct pci_dev *dev = k8_northbridges[i]; 202 if (!amd_nb_has_feature(AMD_NB_GART))
203 return;
204
205 for (i = 0; i < amd_nb_num(); i++) {
206 struct pci_dev *dev = node_to_amd_nb(i)->misc;
200 /* disable gart translation */ 207 /* disable gart translation */
201 pci_read_config_dword(dev, AMD64_GARTAPERTURECTL, &tmp); 208 pci_read_config_dword(dev, AMD64_GARTAPERTURECTL, &tmp);
202 tmp &= ~AMD64_GARTEN; 209 tmp &= ~GARTEN;
203 pci_write_config_dword(dev, AMD64_GARTAPERTURECTL, tmp); 210 pci_write_config_dword(dev, AMD64_GARTAPERTURECTL, tmp);
204 } 211 }
205} 212}
@@ -313,22 +320,25 @@ static __devinit int fix_northbridge(struct pci_dev *nb, struct pci_dev *agp,
313 if (order < 0 || !agp_aperture_valid(aper, (32*1024*1024)<<order)) 320 if (order < 0 || !agp_aperture_valid(aper, (32*1024*1024)<<order))
314 return -1; 321 return -1;
315 322
316 pci_write_config_dword(nb, AMD64_GARTAPERTURECTL, order << 1); 323 gart_set_size_and_enable(nb, order);
317 pci_write_config_dword(nb, AMD64_GARTAPERTUREBASE, aper >> 25); 324 pci_write_config_dword(nb, AMD64_GARTAPERTUREBASE, aper >> 25);
318 325
319 return 0; 326 return 0;
320} 327}
321 328
322static __devinit int cache_nbs (struct pci_dev *pdev, u32 cap_ptr) 329static __devinit int cache_nbs(struct pci_dev *pdev, u32 cap_ptr)
323{ 330{
324 int i; 331 int i;
325 332
326 if (cache_k8_northbridges() < 0) 333 if (amd_cache_northbridges() < 0)
334 return -ENODEV;
335
336 if (!amd_nb_has_feature(AMD_NB_GART))
327 return -ENODEV; 337 return -ENODEV;
328 338
329 i = 0; 339 i = 0;
330 for (i = 0; i < num_k8_northbridges; i++) { 340 for (i = 0; i < amd_nb_num(); i++) {
331 struct pci_dev *dev = k8_northbridges[i]; 341 struct pci_dev *dev = node_to_amd_nb(i)->misc;
332 if (fix_northbridge(dev, pdev, cap_ptr) < 0) { 342 if (fix_northbridge(dev, pdev, cap_ptr) < 0) {
333 dev_err(&dev->dev, "no usable aperture found\n"); 343 dev_err(&dev->dev, "no usable aperture found\n");
334#ifdef __x86_64__ 344#ifdef __x86_64__
@@ -405,7 +415,8 @@ static int __devinit uli_agp_init(struct pci_dev *pdev)
405 } 415 }
406 416
407 /* shadow x86-64 registers into ULi registers */ 417 /* shadow x86-64 registers into ULi registers */
408 pci_read_config_dword (k8_northbridges[0], AMD64_GARTAPERTUREBASE, &httfea); 418 pci_read_config_dword (node_to_amd_nb(0)->misc, AMD64_GARTAPERTUREBASE,
419 &httfea);
409 420
410 /* if x86-64 aperture base is beyond 4G, exit here */ 421 /* if x86-64 aperture base is beyond 4G, exit here */
411 if ((httfea & 0x7fff) >> (32 - 25)) { 422 if ((httfea & 0x7fff) >> (32 - 25)) {
@@ -472,7 +483,8 @@ static int nforce3_agp_init(struct pci_dev *pdev)
472 pci_write_config_dword(dev1, NVIDIA_X86_64_1_APSIZE, tmp); 483 pci_write_config_dword(dev1, NVIDIA_X86_64_1_APSIZE, tmp);
473 484
474 /* shadow x86-64 registers into NVIDIA registers */ 485 /* shadow x86-64 registers into NVIDIA registers */
475 pci_read_config_dword (k8_northbridges[0], AMD64_GARTAPERTUREBASE, &apbase); 486 pci_read_config_dword (node_to_amd_nb(0)->misc, AMD64_GARTAPERTUREBASE,
487 &apbase);
476 488
477 /* if x86-64 aperture base is beyond 4G, exit here */ 489 /* if x86-64 aperture base is beyond 4G, exit here */
478 if ( (apbase & 0x7fff) >> (32 - 25) ) { 490 if ( (apbase & 0x7fff) >> (32 - 25) ) {
@@ -761,18 +773,23 @@ int __init agp_amd64_init(void)
761#else 773#else
762 printk(KERN_INFO PFX "You can boot with agp=try_unsupported\n"); 774 printk(KERN_INFO PFX "You can boot with agp=try_unsupported\n");
763#endif 775#endif
776 pci_unregister_driver(&agp_amd64_pci_driver);
764 return -ENODEV; 777 return -ENODEV;
765 } 778 }
766 779
767 /* First check that we have at least one AMD64 NB */ 780 /* First check that we have at least one AMD64 NB */
768 if (!pci_dev_present(k8_nb_ids)) 781 if (!pci_dev_present(amd_nb_misc_ids)) {
782 pci_unregister_driver(&agp_amd64_pci_driver);
769 return -ENODEV; 783 return -ENODEV;
784 }
770 785
771 /* Look for any AGP bridge */ 786 /* Look for any AGP bridge */
772 agp_amd64_pci_driver.id_table = agp_amd64_pci_promisc_table; 787 agp_amd64_pci_driver.id_table = agp_amd64_pci_promisc_table;
773 err = driver_attach(&agp_amd64_pci_driver.driver); 788 err = driver_attach(&agp_amd64_pci_driver.driver);
774 if (err == 0 && agp_bridges_found == 0) 789 if (err == 0 && agp_bridges_found == 0) {
790 pci_unregister_driver(&agp_amd64_pci_driver);
775 err = -ENODEV; 791 err = -ENODEV;
792 }
776 } 793 }
777 return err; 794 return err;
778} 795}