diff options
author | Pavel Machek <pavel@ucw.cz> | 2008-04-15 06:43:57 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-05-12 15:28:10 -0400 |
commit | 3bb6fbf9969a8bbe4892968659239273d092e78a (patch) | |
tree | 26ede22e0622abfbb585cd83199b2615b4b4542d | |
parent | 330fce23dab6e6a3d1979e55f27aba4c0c301331 (diff) |
x86 gart: factor out common code
Cleanup gart handling on amd64 a bit: move common code into
enable_gart_translation , and use symbolic register names where
appropriate.
Signed-off-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | arch/x86/kernel/pci-gart_64.c | 23 | ||||
-rw-r--r-- | drivers/char/agp/amd64-agp.c | 29 | ||||
-rw-r--r-- | include/asm-x86/gart.h | 17 |
3 files changed, 32 insertions, 37 deletions
diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c index bffcf455c857..1f99b62ff616 100644 --- a/arch/x86/kernel/pci-gart_64.c +++ b/arch/x86/kernel/pci-gart_64.c | |||
@@ -533,8 +533,8 @@ static __init unsigned read_aperture(struct pci_dev *dev, u32 *size) | |||
533 | unsigned aper_size = 0, aper_base_32, aper_order; | 533 | unsigned aper_size = 0, aper_base_32, aper_order; |
534 | u64 aper_base; | 534 | u64 aper_base; |
535 | 535 | ||
536 | pci_read_config_dword(dev, 0x94, &aper_base_32); | 536 | pci_read_config_dword(dev, AMD64_GARTAPERTUREBASE, &aper_base_32); |
537 | pci_read_config_dword(dev, 0x90, &aper_order); | 537 | pci_read_config_dword(dev, AMD64_GARTAPERTURECTL, &aper_order); |
538 | aper_order = (aper_order >> 1) & 7; | 538 | aper_order = (aper_order >> 1) & 7; |
539 | 539 | ||
540 | aper_base = aper_base_32 & 0x7fff; | 540 | aper_base = aper_base_32 & 0x7fff; |
@@ -592,19 +592,8 @@ static __init int init_k8_gatt(struct agp_kern_info *info) | |||
592 | agp_gatt_table = gatt; | 592 | agp_gatt_table = gatt; |
593 | 593 | ||
594 | for (i = 0; i < num_k8_northbridges; i++) { | 594 | for (i = 0; i < num_k8_northbridges; i++) { |
595 | u32 gatt_reg; | ||
596 | u32 ctl; | ||
597 | |||
598 | dev = k8_northbridges[i]; | 595 | dev = k8_northbridges[i]; |
599 | gatt_reg = __pa(gatt) >> 12; | 596 | enable_gart_translation(dev, __pa(gatt)); |
600 | gatt_reg <<= 4; | ||
601 | pci_write_config_dword(dev, AMD64_GARTTABLEBASE, gatt_reg); | ||
602 | pci_read_config_dword(dev, AMD64_GARTAPERTURECTL, &ctl); | ||
603 | |||
604 | ctl |= GARTEN; | ||
605 | ctl &= ~(DISGARTCPU | DISGARTIO); | ||
606 | |||
607 | pci_write_config_dword(dev, AMD64_GARTAPERTURECTL, ctl); | ||
608 | } | 597 | } |
609 | flush_gart(); | 598 | flush_gart(); |
610 | 599 | ||
@@ -648,11 +637,11 @@ void gart_iommu_shutdown(void) | |||
648 | u32 ctl; | 637 | u32 ctl; |
649 | 638 | ||
650 | dev = k8_northbridges[i]; | 639 | dev = k8_northbridges[i]; |
651 | pci_read_config_dword(dev, 0x90, &ctl); | 640 | pci_read_config_dword(dev, AMD64_GARTAPERTURECTL, &ctl); |
652 | 641 | ||
653 | ctl &= ~1; | 642 | ctl &= ~GARTEN; |
654 | 643 | ||
655 | pci_write_config_dword(dev, 0x90, ctl); | 644 | pci_write_config_dword(dev, AMD64_GARTAPERTURECTL, ctl); |
656 | } | 645 | } |
657 | } | 646 | } |
658 | 647 | ||
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c index 9c24470a8252..e3c7ea07f57c 100644 --- a/drivers/char/agp/amd64-agp.c +++ b/drivers/char/agp/amd64-agp.c | |||
@@ -150,25 +150,14 @@ static u64 amd64_configure(struct pci_dev *hammer, u64 gatt_table) | |||
150 | { | 150 | { |
151 | u64 aperturebase; | 151 | u64 aperturebase; |
152 | u32 tmp; | 152 | u32 tmp; |
153 | u64 addr, aper_base; | 153 | u64 aper_base; |
154 | 154 | ||
155 | /* Address to map to */ | 155 | /* Address to map to */ |
156 | pci_read_config_dword (hammer, AMD64_GARTAPERTUREBASE, &tmp); | 156 | pci_read_config_dword(hammer, AMD64_GARTAPERTUREBASE, &tmp); |
157 | aperturebase = tmp << 25; | 157 | aperturebase = tmp << 25; |
158 | aper_base = (aperturebase & PCI_BASE_ADDRESS_MEM_MASK); | 158 | aper_base = (aperturebase & PCI_BASE_ADDRESS_MEM_MASK); |
159 | 159 | ||
160 | /* address of the mappings table */ | 160 | enable_gart_translation(hammer, gatt_table); |
161 | addr = (u64) gatt_table; | ||
162 | addr >>= 12; | ||
163 | tmp = (u32) addr<<4; | ||
164 | tmp &= ~0xf; | ||
165 | pci_write_config_dword(hammer, AMD64_GARTTABLEBASE, tmp); | ||
166 | |||
167 | /* Enable GART translation for this hammer. */ | ||
168 | pci_read_config_dword(hammer, AMD64_GARTAPERTURECTL, &tmp); | ||
169 | tmp |= GARTEN; | ||
170 | tmp &= ~(DISGARTCPU | DISGARTIO); | ||
171 | pci_write_config_dword(hammer, AMD64_GARTAPERTURECTL, tmp); | ||
172 | 161 | ||
173 | return aper_base; | 162 | return aper_base; |
174 | } | 163 | } |
@@ -207,9 +196,9 @@ static void amd64_cleanup(void) | |||
207 | for (i = 0; i < num_k8_northbridges; i++) { | 196 | for (i = 0; i < num_k8_northbridges; i++) { |
208 | struct pci_dev *dev = k8_northbridges[i]; | 197 | struct pci_dev *dev = k8_northbridges[i]; |
209 | /* disable gart translation */ | 198 | /* disable gart translation */ |
210 | pci_read_config_dword (dev, AMD64_GARTAPERTURECTL, &tmp); | 199 | pci_read_config_dword(dev, AMD64_GARTAPERTURECTL, &tmp); |
211 | tmp &= ~AMD64_GARTEN; | 200 | tmp &= ~AMD64_GARTEN; |
212 | pci_write_config_dword (dev, AMD64_GARTAPERTURECTL, tmp); | 201 | pci_write_config_dword(dev, AMD64_GARTAPERTURECTL, tmp); |
213 | } | 202 | } |
214 | } | 203 | } |
215 | 204 | ||
@@ -289,9 +278,9 @@ static __devinit int fix_northbridge(struct pci_dev *nb, struct pci_dev *agp, | |||
289 | u32 nb_order, nb_base; | 278 | u32 nb_order, nb_base; |
290 | u16 apsize; | 279 | u16 apsize; |
291 | 280 | ||
292 | pci_read_config_dword(nb, 0x90, &nb_order); | 281 | pci_read_config_dword(nb, AMD64_GARTAPERTURECTL, &nb_order); |
293 | nb_order = (nb_order >> 1) & 7; | 282 | nb_order = (nb_order >> 1) & 7; |
294 | pci_read_config_dword(nb, 0x94, &nb_base); | 283 | pci_read_config_dword(nb, AMD64_GARTAPERTUREBASE, &nb_base); |
295 | nb_aper = nb_base << 25; | 284 | nb_aper = nb_base << 25; |
296 | if (aperture_valid(nb_aper, (32*1024*1024)<<nb_order)) { | 285 | if (aperture_valid(nb_aper, (32*1024*1024)<<nb_order)) { |
297 | return 0; | 286 | return 0; |
@@ -327,8 +316,8 @@ static __devinit int fix_northbridge(struct pci_dev *nb, struct pci_dev *agp, | |||
327 | if (order < 0 || !aperture_valid(aper, (32*1024*1024)<<order)) | 316 | if (order < 0 || !aperture_valid(aper, (32*1024*1024)<<order)) |
328 | return -1; | 317 | return -1; |
329 | 318 | ||
330 | pci_write_config_dword(nb, 0x90, order << 1); | 319 | pci_write_config_dword(nb, AMD64_GARTAPERTURECTL, order << 1); |
331 | pci_write_config_dword(nb, 0x94, aper >> 25); | 320 | pci_write_config_dword(nb, AMD64_GARTAPERTUREBASE, aper >> 25); |
332 | 321 | ||
333 | return 0; | 322 | return 0; |
334 | } | 323 | } |
diff --git a/include/asm-x86/gart.h b/include/asm-x86/gart.h index 248e5778e928..6f22786d2f0c 100644 --- a/include/asm-x86/gart.h +++ b/include/asm-x86/gart.h | |||
@@ -52,4 +52,21 @@ static inline void gart_iommu_shutdown(void) | |||
52 | #define AMD64_GARTCACHECTL 0x9c | 52 | #define AMD64_GARTCACHECTL 0x9c |
53 | #define AMD64_GARTEN (1<<0) | 53 | #define AMD64_GARTEN (1<<0) |
54 | 54 | ||
55 | static inline void enable_gart_translation(struct pci_dev *dev, u64 addr) | ||
56 | { | ||
57 | u32 tmp, ctl; | ||
58 | |||
59 | /* address of the mappings table */ | ||
60 | addr >>= 12; | ||
61 | tmp = (u32) addr<<4; | ||
62 | tmp &= ~0xf; | ||
63 | pci_write_config_dword(dev, AMD64_GARTTABLEBASE, tmp); | ||
64 | |||
65 | /* Enable GART translation for this hammer. */ | ||
66 | pci_read_config_dword(dev, AMD64_GARTAPERTURECTL, &ctl); | ||
67 | ctl |= GARTEN; | ||
68 | ctl &= ~(DISGARTCPU | DISGARTIO); | ||
69 | pci_write_config_dword(dev, AMD64_GARTAPERTURECTL, ctl); | ||
70 | } | ||
71 | |||
55 | #endif | 72 | #endif |