diff options
Diffstat (limited to 'drivers/char/agp')
-rw-r--r-- | drivers/char/agp/uninorth-agp.c | 77 |
1 files changed, 25 insertions, 52 deletions
diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c index 703959eba45a..d89da4ac061f 100644 --- a/drivers/char/agp/uninorth-agp.c +++ b/drivers/char/agp/uninorth-agp.c | |||
@@ -144,16 +144,13 @@ static int uninorth_configure(void) | |||
144 | return 0; | 144 | return 0; |
145 | } | 145 | } |
146 | 146 | ||
147 | static int uninorth_insert_memory(struct agp_memory *mem, off_t pg_start, | 147 | static int uninorth_insert_memory(struct agp_memory *mem, off_t pg_start, int type) |
148 | int type) | ||
149 | { | 148 | { |
150 | int i, j, num_entries; | 149 | int i, num_entries; |
151 | void *temp; | 150 | void *temp; |
151 | u32 *gp; | ||
152 | int mask_type; | 152 | int mask_type; |
153 | 153 | ||
154 | temp = agp_bridge->current_size; | ||
155 | num_entries = A_SIZE_32(temp)->num_entries; | ||
156 | |||
157 | if (type != mem->type) | 154 | if (type != mem->type) |
158 | return -EINVAL; | 155 | return -EINVAL; |
159 | 156 | ||
@@ -163,49 +160,12 @@ static int uninorth_insert_memory(struct agp_memory *mem, off_t pg_start, | |||
163 | return -EINVAL; | 160 | return -EINVAL; |
164 | } | 161 | } |
165 | 162 | ||
166 | if ((pg_start + mem->page_count) > num_entries) | 163 | if (mem->page_count == 0) |
167 | return -EINVAL; | 164 | return 0; |
168 | |||
169 | j = pg_start; | ||
170 | |||
171 | while (j < (pg_start + mem->page_count)) { | ||
172 | if (agp_bridge->gatt_table[j]) | ||
173 | return -EBUSY; | ||
174 | j++; | ||
175 | } | ||
176 | |||
177 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { | ||
178 | agp_bridge->gatt_table[j] = | ||
179 | cpu_to_le32((page_to_phys(mem->pages[i]) & 0xFFFFF000UL) | 0x1UL); | ||
180 | flush_dcache_range((unsigned long)__va(page_to_phys(mem->pages[i])), | ||
181 | (unsigned long)__va(page_to_phys(mem->pages[i]))+0x1000); | ||
182 | } | ||
183 | (void)in_le32((volatile u32*)&agp_bridge->gatt_table[pg_start]); | ||
184 | mb(); | ||
185 | |||
186 | uninorth_tlbflush(mem); | ||
187 | return 0; | ||
188 | } | ||
189 | |||
190 | static int u3_insert_memory(struct agp_memory *mem, off_t pg_start, int type) | ||
191 | { | ||
192 | int i, num_entries; | ||
193 | void *temp; | ||
194 | u32 *gp; | ||
195 | int mask_type; | ||
196 | 165 | ||
197 | temp = agp_bridge->current_size; | 166 | temp = agp_bridge->current_size; |
198 | num_entries = A_SIZE_32(temp)->num_entries; | 167 | num_entries = A_SIZE_32(temp)->num_entries; |
199 | 168 | ||
200 | if (type != mem->type) | ||
201 | return -EINVAL; | ||
202 | |||
203 | mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type); | ||
204 | if (mask_type != 0) { | ||
205 | /* We know nothing of memory types */ | ||
206 | return -EINVAL; | ||
207 | } | ||
208 | |||
209 | if ((pg_start + mem->page_count) > num_entries) | 169 | if ((pg_start + mem->page_count) > num_entries) |
210 | return -EINVAL; | 170 | return -EINVAL; |
211 | 171 | ||
@@ -213,14 +173,18 @@ static int u3_insert_memory(struct agp_memory *mem, off_t pg_start, int type) | |||
213 | for (i = 0; i < mem->page_count; ++i) { | 173 | for (i = 0; i < mem->page_count; ++i) { |
214 | if (gp[i]) { | 174 | if (gp[i]) { |
215 | dev_info(&agp_bridge->dev->dev, | 175 | dev_info(&agp_bridge->dev->dev, |
216 | "u3_insert_memory: entry 0x%x occupied (%x)\n", | 176 | "uninorth_insert_memory: entry 0x%x occupied (%x)\n", |
217 | i, gp[i]); | 177 | i, gp[i]); |
218 | return -EBUSY; | 178 | return -EBUSY; |
219 | } | 179 | } |
220 | } | 180 | } |
221 | 181 | ||
222 | for (i = 0; i < mem->page_count; i++) { | 182 | for (i = 0; i < mem->page_count; i++) { |
223 | gp[i] = (page_to_phys(mem->pages[i]) >> PAGE_SHIFT) | 0x80000000UL; | 183 | if (is_u3) |
184 | gp[i] = (page_to_phys(mem->pages[i]) >> PAGE_SHIFT) | 0x80000000UL; | ||
185 | else | ||
186 | gp[i] = cpu_to_le32((page_to_phys(mem->pages[i]) & 0xFFFFF000UL) | | ||
187 | 0x1UL); | ||
224 | flush_dcache_range((unsigned long)__va(page_to_phys(mem->pages[i])), | 188 | flush_dcache_range((unsigned long)__va(page_to_phys(mem->pages[i])), |
225 | (unsigned long)__va(page_to_phys(mem->pages[i]))+0x1000); | 189 | (unsigned long)__va(page_to_phys(mem->pages[i]))+0x1000); |
226 | } | 190 | } |
@@ -230,14 +194,23 @@ static int u3_insert_memory(struct agp_memory *mem, off_t pg_start, int type) | |||
230 | return 0; | 194 | return 0; |
231 | } | 195 | } |
232 | 196 | ||
233 | int u3_remove_memory(struct agp_memory *mem, off_t pg_start, int type) | 197 | int uninorth_remove_memory(struct agp_memory *mem, off_t pg_start, int type) |
234 | { | 198 | { |
235 | size_t i; | 199 | size_t i; |
236 | u32 *gp; | 200 | u32 *gp; |
201 | int mask_type; | ||
202 | |||
203 | if (type != mem->type) | ||
204 | return -EINVAL; | ||
237 | 205 | ||
238 | if (type != 0 || mem->type != 0) | 206 | mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type); |
207 | if (mask_type != 0) { | ||
239 | /* We know nothing of memory types */ | 208 | /* We know nothing of memory types */ |
240 | return -EINVAL; | 209 | return -EINVAL; |
210 | } | ||
211 | |||
212 | if (mem->page_count == 0) | ||
213 | return 0; | ||
241 | 214 | ||
242 | gp = (u32 *) &agp_bridge->gatt_table[pg_start]; | 215 | gp = (u32 *) &agp_bridge->gatt_table[pg_start]; |
243 | for (i = 0; i < mem->page_count; ++i) | 216 | for (i = 0; i < mem->page_count; ++i) |
@@ -536,7 +509,7 @@ const struct agp_bridge_driver uninorth_agp_driver = { | |||
536 | .create_gatt_table = uninorth_create_gatt_table, | 509 | .create_gatt_table = uninorth_create_gatt_table, |
537 | .free_gatt_table = uninorth_free_gatt_table, | 510 | .free_gatt_table = uninorth_free_gatt_table, |
538 | .insert_memory = uninorth_insert_memory, | 511 | .insert_memory = uninorth_insert_memory, |
539 | .remove_memory = agp_generic_remove_memory, | 512 | .remove_memory = uninorth_remove_memory, |
540 | .alloc_by_type = agp_generic_alloc_by_type, | 513 | .alloc_by_type = agp_generic_alloc_by_type, |
541 | .free_by_type = agp_generic_free_by_type, | 514 | .free_by_type = agp_generic_free_by_type, |
542 | .agp_alloc_page = agp_generic_alloc_page, | 515 | .agp_alloc_page = agp_generic_alloc_page, |
@@ -562,8 +535,8 @@ const struct agp_bridge_driver u3_agp_driver = { | |||
562 | .agp_enable = uninorth_agp_enable, | 535 | .agp_enable = uninorth_agp_enable, |
563 | .create_gatt_table = uninorth_create_gatt_table, | 536 | .create_gatt_table = uninorth_create_gatt_table, |
564 | .free_gatt_table = uninorth_free_gatt_table, | 537 | .free_gatt_table = uninorth_free_gatt_table, |
565 | .insert_memory = u3_insert_memory, | 538 | .insert_memory = uninorth_insert_memory, |
566 | .remove_memory = u3_remove_memory, | 539 | .remove_memory = uninorth_remove_memory, |
567 | .alloc_by_type = agp_generic_alloc_by_type, | 540 | .alloc_by_type = agp_generic_alloc_by_type, |
568 | .free_by_type = agp_generic_free_by_type, | 541 | .free_by_type = agp_generic_free_by_type, |
569 | .agp_alloc_page = agp_generic_alloc_page, | 542 | .agp_alloc_page = agp_generic_alloc_page, |