Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 1 | /* |
| 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 Corbet | f1b99aa | 2010-04-09 14:06:16 -0600 | [diff] [blame] | 23 | /* |
| 24 | * Figure out an appropriate bytes-per-pixel setting. |
| 25 | */ |
| 26 | static 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 Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 52 | static 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 Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 56 | { |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 57 | u32 ge_cmd = 0, tmp, i; |
Jonathan Corbet | f1b99aa | 2010-04-09 14:06:16 -0600 | [diff] [blame] | 58 | int ret; |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 59 | |
| 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 Corbet | f1b99aa | 2010-04-09 14:06:16 -0600 | [diff] [blame] | 92 | ret = viafb_set_bpp(engine, dst_bpp); |
| 93 | if (ret) |
| 94 | return ret; |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 95 | |
| 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 Post | 97922b5 | 2010-01-15 17:01:06 -0800 | [diff] [blame] | 157 | tmp = VIA_PITCH_ENABLE | (tmp >> 3) | (dst_pitch << (16 - 3)); |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 158 | 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 | |
| 185 | static 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 Corbet | 9ca43cf | 2010-03-27 12:14:52 -0600 | [diff] [blame] | 191 | int ret; |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 192 | |
| 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 Corbet | 9ca43cf | 2010-03-27 12:14:52 -0600 | [diff] [blame] | 225 | ret = viafb_set_bpp(engine, dst_bpp); |
| 226 | if (ret) |
| 227 | return ret; |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 228 | |
| 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 Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 316 | int viafb_init_engine(struct fb_info *info) |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 317 | { |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 318 | 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 Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 332 | 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 Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 342 | viapar->shared->hw_bitblt = hw_bitblt_1; |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 343 | break; |
| 344 | case UNICHROME_VX800: |
Florian Tobias Schandinat | 3a32456 | 2009-09-22 16:47:36 -0700 | [diff] [blame] | 345 | case UNICHROME_VX855: |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 346 | viapar->shared->hw_bitblt = hw_bitblt_2; |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 347 | break; |
| 348 | default: |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 349 | viapar->shared->hw_bitblt = NULL; |
Florian Tobias Schandinat | c3e2567 | 2009-09-22 16:47:26 -0700 | [diff] [blame] | 350 | } |
| 351 | |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 352 | viapar->fbmem_free -= CURSOR_SIZE; |
| 353 | viapar->shared->cursor_vram_addr = viapar->fbmem_free; |
| 354 | viapar->fbmem_used += CURSOR_SIZE; |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 355 | |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 356 | viapar->fbmem_free -= VQ_SIZE; |
| 357 | viapar->shared->vq_vram_addr = viapar->fbmem_free; |
| 358 | viapar->fbmem_used += VQ_SIZE; |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 359 | |
Erik-Jan Post | 97922b5 | 2010-01-15 17:01:06 -0800 | [diff] [blame] | 360 | /* Init 2D engine reg to reset 2D engine */ |
| 361 | writel(0x0, engine + VIA_REG_KEYCONTROL); |
| 362 | |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 363 | /* Init AGP and VQ regs */ |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 364 | switch (chip_name) { |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 365 | case UNICHROME_K8M890: |
| 366 | case UNICHROME_P4M900: |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 367 | writel(0x00100000, engine + VIA_REG_CR_TRANSET); |
| 368 | writel(0x680A0000, engine + VIA_REG_CR_TRANSPACE); |
| 369 | writel(0x02000000, engine + VIA_REG_CR_TRANSPACE); |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 370 | break; |
| 371 | |
| 372 | default: |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 373 | 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 Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 382 | |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 383 | writel(0xFE020000, engine + VIA_REG_TRANSET); |
| 384 | writel(0x00000000, engine + VIA_REG_TRANSPACE); |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 385 | break; |
| 386 | } |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 387 | |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 388 | /* Enable VQ */ |
| 389 | vq_start_addr = viapar->shared->vq_vram_addr; |
| 390 | vq_end_addr = viapar->shared->vq_vram_addr + VQ_SIZE - 1; |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 391 | |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 392 | 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 Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 397 | |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 398 | 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 Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 405 | |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 406 | 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 Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 438 | } |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 439 | |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 440 | /* Set Cursor Image Base Address */ |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 441 | 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 Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 447 | } |
| 448 | |
| 449 | void viafb_show_hw_cursor(struct fb_info *info, int Status) |
| 450 | { |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 451 | struct viafb_par *viapar = info->par; |
| 452 | u32 temp, iga_path = viapar->iga_path; |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 453 | |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 454 | temp = readl(viapar->shared->engine_mmio + VIA_REG_CURSOR_MODE); |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 455 | 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 Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 471 | writel(temp, viapar->shared->engine_mmio + VIA_REG_CURSOR_MODE); |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 472 | } |
| 473 | |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 474 | void viafb_wait_engine_idle(struct fb_info *info) |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 475 | { |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 476 | struct viafb_par *viapar = info->par; |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 477 | int loop = 0; |
| 478 | |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 479 | while (!(readl(viapar->shared->engine_mmio + VIA_REG_STATUS) & |
Roel Kluin | 2bd8c47 | 2009-03-31 15:25:36 -0700 | [diff] [blame] | 480 | VIA_VR_QUEUE_BUSY) && (loop < MAXLOOP)) { |
| 481 | loop++; |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 482 | cpu_relax(); |
Roel Kluin | 2bd8c47 | 2009-03-31 15:25:36 -0700 | [diff] [blame] | 483 | } |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 484 | |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 485 | while ((readl(viapar->shared->engine_mmio + VIA_REG_STATUS) & |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 486 | (VIA_CMD_RGTR_BUSY | VIA_2D_ENG_BUSY | VIA_3D_ENG_BUSY)) && |
Roel Kluin | 2bd8c47 | 2009-03-31 15:25:36 -0700 | [diff] [blame] | 487 | (loop < MAXLOOP)) { |
| 488 | loop++; |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 489 | cpu_relax(); |
Roel Kluin | 2bd8c47 | 2009-03-31 15:25:36 -0700 | [diff] [blame] | 490 | } |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 491 | |
Florian Tobias Schandinat | 31de59d | 2009-09-22 16:47:31 -0700 | [diff] [blame] | 492 | if (loop >= MAXLOOP) |
| 493 | printk(KERN_ERR "viafb_wait_engine_idle: not syncing\n"); |
Joseph Chan | 801b8a8 | 2008-10-15 22:03:21 -0700 | [diff] [blame] | 494 | } |