aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorHans Rosenfeld <hans.rosenfeld@amd.com>2010-10-29 11:14:31 -0400
committerBorislav Petkov <borislav.petkov@amd.com>2010-11-18 09:53:05 -0500
commit9653a5c76c8677b05b45b3b999d3b39988d2a064 (patch)
tree9224748c69296fc6ac50beae72f20e6e2ae16aca /drivers/char
parenteec1d4fa00c6552ae2fdf71d59f1eded7c88dd89 (diff)
x86, amd-nb: Cleanup AMD northbridge caching code
Support more than just the "Misc Control" part of the northbridges. Support more flags by turning "gart_supported" into a single bit flag that is stored in a flags member. Clean up related code by using a set of functions (amd_nb_num(), amd_nb_has_feature() and node_to_amd_nb()) instead of accessing the NB data structures directly. Reorder the initialization code and put the GART flush words caching in a separate function. Signed-off-by: Hans Rosenfeld <hans.rosenfeld@amd.com> Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/agp/amd64-agp.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index b1f8bb53941a..9252e85706ef 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -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 = amd_northbridges.nb_misc[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,14 +181,13 @@ 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_northbridges.gart_supported) 184 if (!amd_nb_has_feature(AMD_NB_GART))
185 return 0; 185 return 0;
186 186
187 /* Configure AGP regs in each x86-64 host bridge. */ 187 /* Configure AGP regs in each x86-64 host bridge. */
188 for (i = 0; i < amd_northbridges.num; i++) { 188 for (i = 0; i < amd_nb_num(); i++) {
189 agp_bridge->gart_bus_addr = 189 agp_bridge->gart_bus_addr =
190 amd64_configure(amd_northbridges.nb_misc[i], 190 amd64_configure(node_to_amd_nb(i)->misc, gatt_bus);
191 gatt_bus);
192 } 191 }
193 amd_flush_garts(); 192 amd_flush_garts();
194 return 0; 193 return 0;
@@ -200,11 +199,11 @@ static void amd64_cleanup(void)
200 u32 tmp; 199 u32 tmp;
201 int i; 200 int i;
202 201
203 if (!amd_northbridges.gart_supported) 202 if (!amd_nb_has_feature(AMD_NB_GART))
204 return; 203 return;
205 204
206 for (i = 0; i < amd_northbridges.num; i++) { 205 for (i = 0; i < amd_nb_num(); i++) {
207 struct pci_dev *dev = amd_northbridges.nb_misc[i]; 206 struct pci_dev *dev = node_to_amd_nb(i)->misc;
208 /* disable gart translation */ 207 /* disable gart translation */
209 pci_read_config_dword(dev, AMD64_GARTAPERTURECTL, &tmp); 208 pci_read_config_dword(dev, AMD64_GARTAPERTURECTL, &tmp);
210 tmp &= ~GARTEN; 209 tmp &= ~GARTEN;
@@ -331,15 +330,15 @@ static __devinit int cache_nbs(struct pci_dev *pdev, u32 cap_ptr)
331{ 330{
332 int i; 331 int i;
333 332
334 if (cache_amd_northbridges() < 0) 333 if (amd_cache_northbridges() < 0)
335 return -ENODEV; 334 return -ENODEV;
336 335
337 if (!amd_northbridges.gart_supported) 336 if (!amd_nb_has_feature(AMD_NB_GART))
338 return -ENODEV; 337 return -ENODEV;
339 338
340 i = 0; 339 i = 0;
341 for (i = 0; i < amd_northbridges.num; i++) { 340 for (i = 0; i < amd_nb_num(); i++) {
342 struct pci_dev *dev = amd_northbridges.nb_misc[i]; 341 struct pci_dev *dev = node_to_amd_nb(i)->misc;
343 if (fix_northbridge(dev, pdev, cap_ptr) < 0) { 342 if (fix_northbridge(dev, pdev, cap_ptr) < 0) {
344 dev_err(&dev->dev, "no usable aperture found\n"); 343 dev_err(&dev->dev, "no usable aperture found\n");
345#ifdef __x86_64__ 344#ifdef __x86_64__
@@ -416,7 +415,7 @@ static int __devinit uli_agp_init(struct pci_dev *pdev)
416 } 415 }
417 416
418 /* shadow x86-64 registers into ULi registers */ 417 /* shadow x86-64 registers into ULi registers */
419 pci_read_config_dword (amd_northbridges.nb_misc[0], AMD64_GARTAPERTUREBASE, 418 pci_read_config_dword (node_to_amd_nb(0)->misc, AMD64_GARTAPERTUREBASE,
420 &httfea); 419 &httfea);
421 420
422 /* if x86-64 aperture base is beyond 4G, exit here */ 421 /* if x86-64 aperture base is beyond 4G, exit here */
@@ -484,7 +483,7 @@ static int nforce3_agp_init(struct pci_dev *pdev)
484 pci_write_config_dword(dev1, NVIDIA_X86_64_1_APSIZE, tmp); 483 pci_write_config_dword(dev1, NVIDIA_X86_64_1_APSIZE, tmp);
485 484
486 /* shadow x86-64 registers into NVIDIA registers */ 485 /* shadow x86-64 registers into NVIDIA registers */
487 pci_read_config_dword (amd_northbridges.nb_misc[0], AMD64_GARTAPERTUREBASE, 486 pci_read_config_dword (node_to_amd_nb(0)->misc, AMD64_GARTAPERTUREBASE,
488 &apbase); 487 &apbase);
489 488
490 /* if x86-64 aperture base is beyond 4G, exit here */ 489 /* if x86-64 aperture base is beyond 4G, exit here */
@@ -778,7 +777,7 @@ int __init agp_amd64_init(void)
778 } 777 }
779 778
780 /* First check that we have at least one AMD64 NB */ 779 /* First check that we have at least one AMD64 NB */
781 if (!pci_dev_present(amd_nb_ids)) 780 if (!pci_dev_present(amd_nb_misc_ids))
782 return -ENODEV; 781 return -ENODEV;
783 782
784 /* Look for any AGP bridge */ 783 /* Look for any AGP bridge */