blob: 7c1d9c41623d00a33b6ce4d2143f1638b2cc2f58 [file] [log] [blame]
Joseph Chan801b8a82008-10-15 22:03:21 -07001/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * A PARTICULAR PURPOSE.See the GNU General Public License
14 * for more details.
15
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21#include "global.h"
22
Jonathan Corbetf1b99aa2010-04-09 14:06:16 -060023/*
24 * Figure out an appropriate bytes-per-pixel setting.
25 */
26static int viafb_set_bpp(void __iomem *engine, u8 bpp)
27{
28 u32 gemode;
29
30 /* Preserve the reserved bits */
31 /* Lowest 2 bits to zero gives us no rotation */
32 gemode = readl(engine + VIA_REG_GEMODE) & 0xfffffcfc;
33 switch (bpp) {
34 case 8:
35 gemode |= VIA_GEM_8bpp;
36 break;
37 case 16:
38 gemode |= VIA_GEM_16bpp;
39 break;
40 case 32:
41 gemode |= VIA_GEM_32bpp;
42 break;
43 default:
44 printk(KERN_WARNING "viafb_set_bpp: Unsupported bpp %d\n", bpp);
45 return -EINVAL;
46 }
47 writel(gemode, engine + VIA_REG_GEMODE);
48 return 0;
49}
50
51
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -070052static int hw_bitblt_1(void __iomem *engine, u8 op, u32 width, u32 height,
53 u8 dst_bpp, u32 dst_addr, u32 dst_pitch, u32 dst_x, u32 dst_y,
54 u32 *src_mem, u32 src_addr, u32 src_pitch, u32 src_x, u32 src_y,
55 u32 fg_color, u32 bg_color, u8 fill_rop)
Joseph Chan801b8a82008-10-15 22:03:21 -070056{
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -070057 u32 ge_cmd = 0, tmp, i;
Jonathan Corbetf1b99aa2010-04-09 14:06:16 -060058 int ret;
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -070059
60 if (!op || op > 3) {
61 printk(KERN_WARNING "hw_bitblt_1: Invalid operation: %d\n", op);
62 return -EINVAL;
63 }
64
65 if (op != VIA_BITBLT_FILL && !src_mem && src_addr == dst_addr) {
66 if (src_x < dst_x) {
67 ge_cmd |= 0x00008000;
68 src_x += width - 1;
69 dst_x += width - 1;
70 }
71 if (src_y < dst_y) {
72 ge_cmd |= 0x00004000;
73 src_y += height - 1;
74 dst_y += height - 1;
75 }
76 }
77
78 if (op == VIA_BITBLT_FILL) {
79 switch (fill_rop) {
80 case 0x00: /* blackness */
81 case 0x5A: /* pattern inversion */
82 case 0xF0: /* pattern copy */
83 case 0xFF: /* whiteness */
84 break;
85 default:
86 printk(KERN_WARNING "hw_bitblt_1: Invalid fill rop: "
87 "%u\n", fill_rop);
88 return -EINVAL;
89 }
90 }
91
Jonathan Corbetf1b99aa2010-04-09 14:06:16 -060092 ret = viafb_set_bpp(engine, dst_bpp);
93 if (ret)
94 return ret;
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -070095
96 if (op != VIA_BITBLT_FILL) {
97 if (src_x & (op == VIA_BITBLT_MONO ? 0xFFFF8000 : 0xFFFFF000)
98 || src_y & 0xFFFFF000) {
99 printk(KERN_WARNING "hw_bitblt_1: Unsupported source "
100 "x/y %d %d\n", src_x, src_y);
101 return -EINVAL;
102 }
103 tmp = src_x | (src_y << 16);
104 writel(tmp, engine + 0x08);
105 }
106
107 if (dst_x & 0xFFFFF000 || dst_y & 0xFFFFF000) {
108 printk(KERN_WARNING "hw_bitblt_1: Unsupported destination x/y "
109 "%d %d\n", dst_x, dst_y);
110 return -EINVAL;
111 }
112 tmp = dst_x | (dst_y << 16);
113 writel(tmp, engine + 0x0C);
114
115 if ((width - 1) & 0xFFFFF000 || (height - 1) & 0xFFFFF000) {
116 printk(KERN_WARNING "hw_bitblt_1: Unsupported width/height "
117 "%d %d\n", width, height);
118 return -EINVAL;
119 }
120 tmp = (width - 1) | ((height - 1) << 16);
121 writel(tmp, engine + 0x10);
122
123 if (op != VIA_BITBLT_COLOR)
124 writel(fg_color, engine + 0x18);
125
126 if (op == VIA_BITBLT_MONO)
127 writel(bg_color, engine + 0x1C);
128
129 if (op != VIA_BITBLT_FILL) {
130 tmp = src_mem ? 0 : src_addr;
131 if (dst_addr & 0xE0000007) {
132 printk(KERN_WARNING "hw_bitblt_1: Unsupported source "
133 "address %X\n", tmp);
134 return -EINVAL;
135 }
136 tmp >>= 3;
137 writel(tmp, engine + 0x30);
138 }
139
140 if (dst_addr & 0xE0000007) {
141 printk(KERN_WARNING "hw_bitblt_1: Unsupported destination "
142 "address %X\n", dst_addr);
143 return -EINVAL;
144 }
145 tmp = dst_addr >> 3;
146 writel(tmp, engine + 0x34);
147
148 if (op == VIA_BITBLT_FILL)
149 tmp = 0;
150 else
151 tmp = src_pitch;
152 if (tmp & 0xFFFFC007 || dst_pitch & 0xFFFFC007) {
153 printk(KERN_WARNING "hw_bitblt_1: Unsupported pitch %X %X\n",
154 tmp, dst_pitch);
155 return -EINVAL;
156 }
Erik-Jan Post97922b52010-01-15 17:01:06 -0800157 tmp = VIA_PITCH_ENABLE | (tmp >> 3) | (dst_pitch << (16 - 3));
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700158 writel(tmp, engine + 0x38);
159
160 if (op == VIA_BITBLT_FILL)
161 ge_cmd |= fill_rop << 24 | 0x00002000 | 0x00000001;
162 else {
163 ge_cmd |= 0xCC000000; /* ROP=SRCCOPY */
164 if (src_mem)
165 ge_cmd |= 0x00000040;
166 if (op == VIA_BITBLT_MONO)
167 ge_cmd |= 0x00000002 | 0x00000100 | 0x00020000;
168 else
169 ge_cmd |= 0x00000001;
170 }
171 writel(ge_cmd, engine);
172
173 if (op == VIA_BITBLT_FILL || !src_mem)
174 return 0;
175
176 tmp = (width * height * (op == VIA_BITBLT_MONO ? 1 : (dst_bpp >> 3)) +
177 3) >> 2;
178
179 for (i = 0; i < tmp; i++)
180 writel(src_mem[i], engine + VIA_MMIO_BLTBASE);
181
182 return 0;
183}
184
185static int hw_bitblt_2(void __iomem *engine, u8 op, u32 width, u32 height,
186 u8 dst_bpp, u32 dst_addr, u32 dst_pitch, u32 dst_x, u32 dst_y,
187 u32 *src_mem, u32 src_addr, u32 src_pitch, u32 src_x, u32 src_y,
188 u32 fg_color, u32 bg_color, u8 fill_rop)
189{
190 u32 ge_cmd = 0, tmp, i;
Jonathan Corbet9ca43cf2010-03-27 12:14:52 -0600191 int ret;
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700192
193 if (!op || op > 3) {
194 printk(KERN_WARNING "hw_bitblt_2: Invalid operation: %d\n", op);
195 return -EINVAL;
196 }
197
198 if (op != VIA_BITBLT_FILL && !src_mem && src_addr == dst_addr) {
199 if (src_x < dst_x) {
200 ge_cmd |= 0x00008000;
201 src_x += width - 1;
202 dst_x += width - 1;
203 }
204 if (src_y < dst_y) {
205 ge_cmd |= 0x00004000;
206 src_y += height - 1;
207 dst_y += height - 1;
208 }
209 }
210
211 if (op == VIA_BITBLT_FILL) {
212 switch (fill_rop) {
213 case 0x00: /* blackness */
214 case 0x5A: /* pattern inversion */
215 case 0xF0: /* pattern copy */
216 case 0xFF: /* whiteness */
217 break;
218 default:
219 printk(KERN_WARNING "hw_bitblt_2: Invalid fill rop: "
220 "%u\n", fill_rop);
221 return -EINVAL;
222 }
223 }
224
Jonathan Corbet9ca43cf2010-03-27 12:14:52 -0600225 ret = viafb_set_bpp(engine, dst_bpp);
226 if (ret)
227 return ret;
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700228
229 if (op == VIA_BITBLT_FILL)
230 tmp = 0;
231 else
232 tmp = src_pitch;
233 if (tmp & 0xFFFFC007 || dst_pitch & 0xFFFFC007) {
234 printk(KERN_WARNING "hw_bitblt_2: Unsupported pitch %X %X\n",
235 tmp, dst_pitch);
236 return -EINVAL;
237 }
238 tmp = (tmp >> 3) | (dst_pitch << (16 - 3));
239 writel(tmp, engine + 0x08);
240
241 if ((width - 1) & 0xFFFFF000 || (height - 1) & 0xFFFFF000) {
242 printk(KERN_WARNING "hw_bitblt_2: Unsupported width/height "
243 "%d %d\n", width, height);
244 return -EINVAL;
245 }
246 tmp = (width - 1) | ((height - 1) << 16);
247 writel(tmp, engine + 0x0C);
248
249 if (dst_x & 0xFFFFF000 || dst_y & 0xFFFFF000) {
250 printk(KERN_WARNING "hw_bitblt_2: Unsupported destination x/y "
251 "%d %d\n", dst_x, dst_y);
252 return -EINVAL;
253 }
254 tmp = dst_x | (dst_y << 16);
255 writel(tmp, engine + 0x10);
256
257 if (dst_addr & 0xE0000007) {
258 printk(KERN_WARNING "hw_bitblt_2: Unsupported destination "
259 "address %X\n", dst_addr);
260 return -EINVAL;
261 }
262 tmp = dst_addr >> 3;
263 writel(tmp, engine + 0x14);
264
265 if (op != VIA_BITBLT_FILL) {
266 if (src_x & (op == VIA_BITBLT_MONO ? 0xFFFF8000 : 0xFFFFF000)
267 || src_y & 0xFFFFF000) {
268 printk(KERN_WARNING "hw_bitblt_2: Unsupported source "
269 "x/y %d %d\n", src_x, src_y);
270 return -EINVAL;
271 }
272 tmp = src_x | (src_y << 16);
273 writel(tmp, engine + 0x18);
274
275 tmp = src_mem ? 0 : src_addr;
276 if (dst_addr & 0xE0000007) {
277 printk(KERN_WARNING "hw_bitblt_2: Unsupported source "
278 "address %X\n", tmp);
279 return -EINVAL;
280 }
281 tmp >>= 3;
282 writel(tmp, engine + 0x1C);
283 }
284
285 if (op != VIA_BITBLT_COLOR)
286 writel(fg_color, engine + 0x4C);
287
288 if (op == VIA_BITBLT_MONO)
289 writel(bg_color, engine + 0x50);
290
291 if (op == VIA_BITBLT_FILL)
292 ge_cmd |= fill_rop << 24 | 0x00002000 | 0x00000001;
293 else {
294 ge_cmd |= 0xCC000000; /* ROP=SRCCOPY */
295 if (src_mem)
296 ge_cmd |= 0x00000040;
297 if (op == VIA_BITBLT_MONO)
298 ge_cmd |= 0x00000002 | 0x00000100 | 0x00020000;
299 else
300 ge_cmd |= 0x00000001;
301 }
302 writel(ge_cmd, engine);
303
304 if (op == VIA_BITBLT_FILL || !src_mem)
305 return 0;
306
307 tmp = (width * height * (op == VIA_BITBLT_MONO ? 1 : (dst_bpp >> 3)) +
308 3) >> 2;
309
310 for (i = 0; i < tmp; i++)
311 writel(src_mem[i], engine + VIA_MMIO_BLTBASE);
312
313 return 0;
314}
315
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700316int viafb_init_engine(struct fb_info *info)
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700317{
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700318 struct viafb_par *viapar = info->par;
319 void __iomem *engine;
320 u32 vq_start_addr, vq_end_addr, vq_start_low, vq_end_low, vq_high,
321 vq_len, chip_name = viapar->shared->chip_info.gfx_chip_name;
322
323 engine = ioremap_nocache(info->fix.mmio_start, info->fix.mmio_len);
324 viapar->shared->engine_mmio = engine;
325 if (!engine) {
326 printk(KERN_WARNING "viafb_init_accel: ioremap failed, "
327 "hardware acceleration disabled\n");
328 return -ENOMEM;
329 }
330
331 switch (chip_name) {
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700332 case UNICHROME_CLE266:
333 case UNICHROME_K400:
334 case UNICHROME_K800:
335 case UNICHROME_PM800:
336 case UNICHROME_CN700:
337 case UNICHROME_CX700:
338 case UNICHROME_CN750:
339 case UNICHROME_K8M890:
340 case UNICHROME_P4M890:
341 case UNICHROME_P4M900:
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700342 viapar->shared->hw_bitblt = hw_bitblt_1;
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700343 break;
344 case UNICHROME_VX800:
Florian Tobias Schandinat3a324562009-09-22 16:47:36 -0700345 case UNICHROME_VX855:
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700346 viapar->shared->hw_bitblt = hw_bitblt_2;
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700347 break;
348 default:
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700349 viapar->shared->hw_bitblt = NULL;
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700350 }
351
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700352 viapar->fbmem_free -= CURSOR_SIZE;
353 viapar->shared->cursor_vram_addr = viapar->fbmem_free;
354 viapar->fbmem_used += CURSOR_SIZE;
Joseph Chan801b8a82008-10-15 22:03:21 -0700355
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700356 viapar->fbmem_free -= VQ_SIZE;
357 viapar->shared->vq_vram_addr = viapar->fbmem_free;
358 viapar->fbmem_used += VQ_SIZE;
Joseph Chan801b8a82008-10-15 22:03:21 -0700359
Erik-Jan Post97922b52010-01-15 17:01:06 -0800360 /* Init 2D engine reg to reset 2D engine */
361 writel(0x0, engine + VIA_REG_KEYCONTROL);
362
Joseph Chan801b8a82008-10-15 22:03:21 -0700363 /* Init AGP and VQ regs */
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700364 switch (chip_name) {
Joseph Chan801b8a82008-10-15 22:03:21 -0700365 case UNICHROME_K8M890:
366 case UNICHROME_P4M900:
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700367 writel(0x00100000, engine + VIA_REG_CR_TRANSET);
368 writel(0x680A0000, engine + VIA_REG_CR_TRANSPACE);
369 writel(0x02000000, engine + VIA_REG_CR_TRANSPACE);
Joseph Chan801b8a82008-10-15 22:03:21 -0700370 break;
371
372 default:
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700373 writel(0x00100000, engine + VIA_REG_TRANSET);
374 writel(0x00000000, engine + VIA_REG_TRANSPACE);
375 writel(0x00333004, engine + VIA_REG_TRANSPACE);
376 writel(0x60000000, engine + VIA_REG_TRANSPACE);
377 writel(0x61000000, engine + VIA_REG_TRANSPACE);
378 writel(0x62000000, engine + VIA_REG_TRANSPACE);
379 writel(0x63000000, engine + VIA_REG_TRANSPACE);
380 writel(0x64000000, engine + VIA_REG_TRANSPACE);
381 writel(0x7D000000, engine + VIA_REG_TRANSPACE);
Joseph Chan801b8a82008-10-15 22:03:21 -0700382
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700383 writel(0xFE020000, engine + VIA_REG_TRANSET);
384 writel(0x00000000, engine + VIA_REG_TRANSPACE);
Joseph Chan801b8a82008-10-15 22:03:21 -0700385 break;
386 }
Joseph Chan801b8a82008-10-15 22:03:21 -0700387
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700388 /* Enable VQ */
389 vq_start_addr = viapar->shared->vq_vram_addr;
390 vq_end_addr = viapar->shared->vq_vram_addr + VQ_SIZE - 1;
Joseph Chan801b8a82008-10-15 22:03:21 -0700391
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700392 vq_start_low = 0x50000000 | (vq_start_addr & 0xFFFFFF);
393 vq_end_low = 0x51000000 | (vq_end_addr & 0xFFFFFF);
394 vq_high = 0x52000000 | ((vq_start_addr & 0xFF000000) >> 24) |
395 ((vq_end_addr & 0xFF000000) >> 16);
396 vq_len = 0x53000000 | (VQ_SIZE >> 3);
Joseph Chan801b8a82008-10-15 22:03:21 -0700397
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700398 switch (chip_name) {
399 case UNICHROME_K8M890:
400 case UNICHROME_P4M900:
401 vq_start_low |= 0x20000000;
402 vq_end_low |= 0x20000000;
403 vq_high |= 0x20000000;
404 vq_len |= 0x20000000;
Joseph Chan801b8a82008-10-15 22:03:21 -0700405
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700406 writel(0x00100000, engine + VIA_REG_CR_TRANSET);
407 writel(vq_high, engine + VIA_REG_CR_TRANSPACE);
408 writel(vq_start_low, engine + VIA_REG_CR_TRANSPACE);
409 writel(vq_end_low, engine + VIA_REG_CR_TRANSPACE);
410 writel(vq_len, engine + VIA_REG_CR_TRANSPACE);
411 writel(0x74301001, engine + VIA_REG_CR_TRANSPACE);
412 writel(0x00000000, engine + VIA_REG_CR_TRANSPACE);
413 break;
414 default:
415 writel(0x00FE0000, engine + VIA_REG_TRANSET);
416 writel(0x080003FE, engine + VIA_REG_TRANSPACE);
417 writel(0x0A00027C, engine + VIA_REG_TRANSPACE);
418 writel(0x0B000260, engine + VIA_REG_TRANSPACE);
419 writel(0x0C000274, engine + VIA_REG_TRANSPACE);
420 writel(0x0D000264, engine + VIA_REG_TRANSPACE);
421 writel(0x0E000000, engine + VIA_REG_TRANSPACE);
422 writel(0x0F000020, engine + VIA_REG_TRANSPACE);
423 writel(0x1000027E, engine + VIA_REG_TRANSPACE);
424 writel(0x110002FE, engine + VIA_REG_TRANSPACE);
425 writel(0x200F0060, engine + VIA_REG_TRANSPACE);
426
427 writel(0x00000006, engine + VIA_REG_TRANSPACE);
428 writel(0x40008C0F, engine + VIA_REG_TRANSPACE);
429 writel(0x44000000, engine + VIA_REG_TRANSPACE);
430 writel(0x45080C04, engine + VIA_REG_TRANSPACE);
431 writel(0x46800408, engine + VIA_REG_TRANSPACE);
432
433 writel(vq_high, engine + VIA_REG_TRANSPACE);
434 writel(vq_start_low, engine + VIA_REG_TRANSPACE);
435 writel(vq_end_low, engine + VIA_REG_TRANSPACE);
436 writel(vq_len, engine + VIA_REG_TRANSPACE);
437 break;
Joseph Chan801b8a82008-10-15 22:03:21 -0700438 }
Joseph Chan801b8a82008-10-15 22:03:21 -0700439
Joseph Chan801b8a82008-10-15 22:03:21 -0700440 /* Set Cursor Image Base Address */
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700441 writel(viapar->shared->cursor_vram_addr, engine + VIA_REG_CURSOR_MODE);
442 writel(0x0, engine + VIA_REG_CURSOR_POS);
443 writel(0x0, engine + VIA_REG_CURSOR_ORG);
444 writel(0x0, engine + VIA_REG_CURSOR_BG);
445 writel(0x0, engine + VIA_REG_CURSOR_FG);
446 return 0;
Joseph Chan801b8a82008-10-15 22:03:21 -0700447}
448
449void viafb_show_hw_cursor(struct fb_info *info, int Status)
450{
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700451 struct viafb_par *viapar = info->par;
452 u32 temp, iga_path = viapar->iga_path;
Joseph Chan801b8a82008-10-15 22:03:21 -0700453
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700454 temp = readl(viapar->shared->engine_mmio + VIA_REG_CURSOR_MODE);
Joseph Chan801b8a82008-10-15 22:03:21 -0700455 switch (Status) {
456 case HW_Cursor_ON:
457 temp |= 0x1;
458 break;
459 case HW_Cursor_OFF:
460 temp &= 0xFFFFFFFE;
461 break;
462 }
463 switch (iga_path) {
464 case IGA2:
465 temp |= 0x80000000;
466 break;
467 case IGA1:
468 default:
469 temp &= 0x7FFFFFFF;
470 }
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700471 writel(temp, viapar->shared->engine_mmio + VIA_REG_CURSOR_MODE);
Joseph Chan801b8a82008-10-15 22:03:21 -0700472}
473
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700474void viafb_wait_engine_idle(struct fb_info *info)
Joseph Chan801b8a82008-10-15 22:03:21 -0700475{
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700476 struct viafb_par *viapar = info->par;
Joseph Chan801b8a82008-10-15 22:03:21 -0700477 int loop = 0;
478
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700479 while (!(readl(viapar->shared->engine_mmio + VIA_REG_STATUS) &
Roel Kluin2bd8c472009-03-31 15:25:36 -0700480 VIA_VR_QUEUE_BUSY) && (loop < MAXLOOP)) {
481 loop++;
Joseph Chan801b8a82008-10-15 22:03:21 -0700482 cpu_relax();
Roel Kluin2bd8c472009-03-31 15:25:36 -0700483 }
Joseph Chan801b8a82008-10-15 22:03:21 -0700484
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700485 while ((readl(viapar->shared->engine_mmio + VIA_REG_STATUS) &
Joseph Chan801b8a82008-10-15 22:03:21 -0700486 (VIA_CMD_RGTR_BUSY | VIA_2D_ENG_BUSY | VIA_3D_ENG_BUSY)) &&
Roel Kluin2bd8c472009-03-31 15:25:36 -0700487 (loop < MAXLOOP)) {
488 loop++;
Joseph Chan801b8a82008-10-15 22:03:21 -0700489 cpu_relax();
Roel Kluin2bd8c472009-03-31 15:25:36 -0700490 }
Joseph Chan801b8a82008-10-15 22:03:21 -0700491
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700492 if (loop >= MAXLOOP)
493 printk(KERN_ERR "viafb_wait_engine_idle: not syncing\n");
Joseph Chan801b8a82008-10-15 22:03:21 -0700494}