diff options
author | Wu Zhangjin <wuzhangjin@gmail.com> | 2009-11-11 00:59:23 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2009-12-16 20:57:15 -0500 |
commit | 22f1fdfd62a5f6ab738ffe03dc2ee9f1f25dabc4 (patch) | |
tree | dbfd9b7b9b1a25f31cfb0af42becdb33e7418b4d /arch/mips/loongson/common | |
parent | 55045ff5557bc804752e84dca5d1b1f1d4bb4e31 (diff) |
MIPS: Add support for uncached accelerated mappings.
Loongson2f support video acceleration.
Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
Cc: linux-mips@linux-mips.org
Patchwork: http://patchwork.linux-mips.org/patch/624/
Patchwork: http://patchwork.linux-mips.org/patch/625/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/loongson/common')
-rw-r--r-- | arch/mips/loongson/common/mem.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/arch/mips/loongson/common/mem.c b/arch/mips/loongson/common/mem.c index 981e9190f393..ceacd092b446 100644 --- a/arch/mips/loongson/common/mem.c +++ b/arch/mips/loongson/common/mem.c | |||
@@ -58,3 +58,61 @@ int __uncached_access(struct file *file, unsigned long addr) | |||
58 | ((addr >= LOONGSON_MMIO_MEM_START) && | 58 | ((addr >= LOONGSON_MMIO_MEM_START) && |
59 | (addr < LOONGSON_MMIO_MEM_END)); | 59 | (addr < LOONGSON_MMIO_MEM_END)); |
60 | } | 60 | } |
61 | |||
62 | #ifdef CONFIG_CPU_SUPPORTS_UNCACHED_ACCELERATED | ||
63 | |||
64 | #include <linux/pci.h> | ||
65 | #include <linux/sched.h> | ||
66 | #include <asm/current.h> | ||
67 | |||
68 | static unsigned long uca_start, uca_end; | ||
69 | |||
70 | pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, | ||
71 | unsigned long size, pgprot_t vma_prot) | ||
72 | { | ||
73 | unsigned long offset = pfn << PAGE_SHIFT; | ||
74 | unsigned long end = offset + size; | ||
75 | |||
76 | if (__uncached_access(file, offset)) { | ||
77 | if (((uca_start && offset) >= uca_start) && | ||
78 | (end <= uca_end)) | ||
79 | return __pgprot((pgprot_val(vma_prot) & | ||
80 | ~_CACHE_MASK) | | ||
81 | _CACHE_UNCACHED_ACCELERATED); | ||
82 | else | ||
83 | return pgprot_noncached(vma_prot); | ||
84 | } | ||
85 | return vma_prot; | ||
86 | } | ||
87 | |||
88 | static int __init find_vga_mem_init(void) | ||
89 | { | ||
90 | struct pci_dev *dev = 0; | ||
91 | struct resource *r; | ||
92 | int idx; | ||
93 | |||
94 | if (uca_start) | ||
95 | return 0; | ||
96 | |||
97 | for_each_pci_dev(dev) { | ||
98 | if ((dev->class >> 8) == PCI_CLASS_DISPLAY_VGA) { | ||
99 | for (idx = 0; idx < PCI_NUM_RESOURCES; idx++) { | ||
100 | r = &dev->resource[idx]; | ||
101 | if (!r->start && r->end) | ||
102 | continue; | ||
103 | if (r->flags & IORESOURCE_IO) | ||
104 | continue; | ||
105 | if (r->flags & IORESOURCE_MEM) { | ||
106 | uca_start = r->start; | ||
107 | uca_end = r->end; | ||
108 | return 0; | ||
109 | } | ||
110 | } | ||
111 | } | ||
112 | } | ||
113 | |||
114 | return 0; | ||
115 | } | ||
116 | |||
117 | late_initcall(find_vga_mem_init); | ||
118 | #endif /* !CONFIG_CPU_SUPPORTS_UNCACHED_ACCELERATED */ | ||