radeon_cp.c revision 152909
1139749Simp/* radeon_cp.c -- CP support for Radeon -*- linux-c -*- */ 2139749Simp/*- 395584Sanholt * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas. 495584Sanholt * Copyright 2000 VA Linux Systems, Inc., Fremont, California. 595584Sanholt * All Rights Reserved. 695584Sanholt * 795584Sanholt * Permission is hereby granted, free of charge, to any person obtaining a 895584Sanholt * copy of this software and associated documentation files (the "Software"), 995584Sanholt * to deal in the Software without restriction, including without limitation 1095584Sanholt * the rights to use, copy, modify, merge, publish, distribute, sublicense, 1195584Sanholt * and/or sell copies of the Software, and to permit persons to whom the 1295584Sanholt * Software is furnished to do so, subject to the following conditions: 1395584Sanholt * 1495584Sanholt * The above copyright notice and this permission notice (including the next 1595584Sanholt * paragraph) shall be included in all copies or substantial portions of the 1695584Sanholt * Software. 1795584Sanholt * 1895584Sanholt * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1995584Sanholt * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 2095584Sanholt * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 2195584Sanholt * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 2295584Sanholt * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 2395584Sanholt * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 2495584Sanholt * DEALINGS IN THE SOFTWARE. 2595584Sanholt * 2695584Sanholt * Authors: 2795584Sanholt * Kevin E. Martin <martin@valinux.com> 2895584Sanholt * Gareth Hughes <gareth@valinux.com> 2995584Sanholt */ 3095584Sanholt 31152909Sanholt#include <sys/cdefs.h> 32152909Sanholt__FBSDID("$FreeBSD: head/sys/dev/drm/radeon_cp.c 152909 2005-11-28 23:13:57Z anholt $"); 33152909Sanholt 3495584Sanholt#include "dev/drm/drmP.h" 35112015Sanholt#include "dev/drm/drm.h" 3695746Sanholt#include "dev/drm/radeon_drm.h" 3795584Sanholt#include "dev/drm/radeon_drv.h" 38148211Sanholt#include "dev/drm/r300_reg.h" 3995584Sanholt 4095584Sanholt#define RADEON_FIFO_DEBUG 0 4195584Sanholt 42145132Sanholtstatic int radeon_do_cleanup_cp(drm_device_t * dev); 4395584Sanholt 4495584Sanholt/* CP microcode (from ATI) */ 45112015Sanholtstatic u32 R200_cp_microcode[][2] = { 46145132Sanholt {0x21007000, 0000000000}, 47145132Sanholt {0x20007000, 0000000000}, 48145132Sanholt {0x000000ab, 0x00000004}, 49145132Sanholt {0x000000af, 0x00000004}, 50145132Sanholt {0x66544a49, 0000000000}, 51145132Sanholt {0x49494174, 0000000000}, 52145132Sanholt {0x54517d83, 0000000000}, 53145132Sanholt {0x498d8b64, 0000000000}, 54145132Sanholt {0x49494949, 0000000000}, 55145132Sanholt {0x49da493c, 0000000000}, 56145132Sanholt {0x49989898, 0000000000}, 57145132Sanholt {0xd34949d5, 0000000000}, 58145132Sanholt {0x9dc90e11, 0000000000}, 59145132Sanholt {0xce9b9b9b, 0000000000}, 60145132Sanholt {0x000f0000, 0x00000016}, 61145132Sanholt {0x352e232c, 0000000000}, 62145132Sanholt {0x00000013, 0x00000004}, 63145132Sanholt {0x000f0000, 0x00000016}, 64145132Sanholt {0x352e272c, 0000000000}, 65145132Sanholt {0x000f0001, 0x00000016}, 66145132Sanholt {0x3239362f, 0000000000}, 67145132Sanholt {0x000077ef, 0x00000002}, 68145132Sanholt {0x00061000, 0x00000002}, 69145132Sanholt {0x00000020, 0x0000001a}, 70145132Sanholt {0x00004000, 0x0000001e}, 71145132Sanholt {0x00061000, 0x00000002}, 72145132Sanholt {0x00000020, 0x0000001a}, 73145132Sanholt {0x00004000, 0x0000001e}, 74145132Sanholt {0x00061000, 0x00000002}, 75145132Sanholt {0x00000020, 0x0000001a}, 76145132Sanholt {0x00004000, 0x0000001e}, 77145132Sanholt {0x00000016, 0x00000004}, 78145132Sanholt {0x0003802a, 0x00000002}, 79145132Sanholt {0x040067e0, 0x00000002}, 80145132Sanholt {0x00000016, 0x00000004}, 81145132Sanholt {0x000077e0, 0x00000002}, 82145132Sanholt {0x00065000, 0x00000002}, 83145132Sanholt {0x000037e1, 0x00000002}, 84145132Sanholt {0x040067e1, 0x00000006}, 85145132Sanholt {0x000077e0, 0x00000002}, 86145132Sanholt {0x000077e1, 0x00000002}, 87145132Sanholt {0x000077e1, 0x00000006}, 88145132Sanholt {0xffffffff, 0000000000}, 89145132Sanholt {0x10000000, 0000000000}, 90145132Sanholt {0x0003802a, 0x00000002}, 91145132Sanholt {0x040067e0, 0x00000006}, 92145132Sanholt {0x00007675, 0x00000002}, 93145132Sanholt {0x00007676, 0x00000002}, 94145132Sanholt {0x00007677, 0x00000002}, 95145132Sanholt {0x00007678, 0x00000006}, 96145132Sanholt {0x0003802b, 0x00000002}, 97145132Sanholt {0x04002676, 0x00000002}, 98145132Sanholt {0x00007677, 0x00000002}, 99145132Sanholt {0x00007678, 0x00000006}, 100145132Sanholt {0x0000002e, 0x00000018}, 101145132Sanholt {0x0000002e, 0x00000018}, 102145132Sanholt {0000000000, 0x00000006}, 103145132Sanholt {0x0000002f, 0x00000018}, 104145132Sanholt {0x0000002f, 0x00000018}, 105145132Sanholt {0000000000, 0x00000006}, 106145132Sanholt {0x01605000, 0x00000002}, 107145132Sanholt {0x00065000, 0x00000002}, 108145132Sanholt {0x00098000, 0x00000002}, 109145132Sanholt {0x00061000, 0x00000002}, 110145132Sanholt {0x64c0603d, 0x00000004}, 111145132Sanholt {0x00080000, 0x00000016}, 112145132Sanholt {0000000000, 0000000000}, 113145132Sanholt {0x0400251d, 0x00000002}, 114145132Sanholt {0x00007580, 0x00000002}, 115145132Sanholt {0x00067581, 0x00000002}, 116145132Sanholt {0x04002580, 0x00000002}, 117145132Sanholt {0x00067581, 0x00000002}, 118145132Sanholt {0x00000046, 0x00000004}, 119145132Sanholt {0x00005000, 0000000000}, 120145132Sanholt {0x00061000, 0x00000002}, 121145132Sanholt {0x0000750e, 0x00000002}, 122145132Sanholt {0x00019000, 0x00000002}, 123145132Sanholt {0x00011055, 0x00000014}, 124145132Sanholt {0x00000055, 0x00000012}, 125145132Sanholt {0x0400250f, 0x00000002}, 126145132Sanholt {0x0000504a, 0x00000004}, 127145132Sanholt {0x00007565, 0x00000002}, 128145132Sanholt {0x00007566, 0x00000002}, 129145132Sanholt {0x00000051, 0x00000004}, 130145132Sanholt {0x01e655b4, 0x00000002}, 131145132Sanholt {0x4401b0dc, 0x00000002}, 132145132Sanholt {0x01c110dc, 0x00000002}, 133145132Sanholt {0x2666705d, 0x00000018}, 134145132Sanholt {0x040c2565, 0x00000002}, 135145132Sanholt {0x0000005d, 0x00000018}, 136145132Sanholt {0x04002564, 0x00000002}, 137145132Sanholt {0x00007566, 0x00000002}, 138145132Sanholt {0x00000054, 0x00000004}, 139145132Sanholt {0x00401060, 0x00000008}, 140145132Sanholt {0x00101000, 0x00000002}, 141145132Sanholt {0x000d80ff, 0x00000002}, 142145132Sanholt {0x00800063, 0x00000008}, 143145132Sanholt {0x000f9000, 0x00000002}, 144145132Sanholt {0x000e00ff, 0x00000002}, 145145132Sanholt {0000000000, 0x00000006}, 146145132Sanholt {0x00000080, 0x00000018}, 147145132Sanholt {0x00000054, 0x00000004}, 148145132Sanholt {0x00007576, 0x00000002}, 149145132Sanholt {0x00065000, 0x00000002}, 150145132Sanholt {0x00009000, 0x00000002}, 151145132Sanholt {0x00041000, 0x00000002}, 152145132Sanholt {0x0c00350e, 0x00000002}, 153145132Sanholt {0x00049000, 0x00000002}, 154145132Sanholt {0x00051000, 0x00000002}, 155145132Sanholt {0x01e785f8, 0x00000002}, 156145132Sanholt {0x00200000, 0x00000002}, 157145132Sanholt {0x00600073, 0x0000000c}, 158145132Sanholt {0x00007563, 0x00000002}, 159145132Sanholt {0x006075f0, 0x00000021}, 160145132Sanholt {0x20007068, 0x00000004}, 161145132Sanholt {0x00005068, 0x00000004}, 162145132Sanholt {0x00007576, 0x00000002}, 163145132Sanholt {0x00007577, 0x00000002}, 164145132Sanholt {0x0000750e, 0x00000002}, 165145132Sanholt {0x0000750f, 0x00000002}, 166145132Sanholt {0x00a05000, 0x00000002}, 167145132Sanholt {0x00600076, 0x0000000c}, 168145132Sanholt {0x006075f0, 0x00000021}, 169145132Sanholt {0x000075f8, 0x00000002}, 170145132Sanholt {0x00000076, 0x00000004}, 171145132Sanholt {0x000a750e, 0x00000002}, 172145132Sanholt {0x0020750f, 0x00000002}, 173145132Sanholt {0x00600079, 0x00000004}, 174145132Sanholt {0x00007570, 0x00000002}, 175145132Sanholt {0x00007571, 0x00000002}, 176145132Sanholt {0x00007572, 0x00000006}, 177145132Sanholt {0x00005000, 0x00000002}, 178145132Sanholt {0x00a05000, 0x00000002}, 179145132Sanholt {0x00007568, 0x00000002}, 180145132Sanholt {0x00061000, 0x00000002}, 181145132Sanholt {0x00000084, 0x0000000c}, 182145132Sanholt {0x00058000, 0x00000002}, 183145132Sanholt {0x0c607562, 0x00000002}, 184145132Sanholt {0x00000086, 0x00000004}, 185145132Sanholt {0x00600085, 0x00000004}, 186145132Sanholt {0x400070dd, 0000000000}, 187145132Sanholt {0x000380dd, 0x00000002}, 188145132Sanholt {0x00000093, 0x0000001c}, 189145132Sanholt {0x00065095, 0x00000018}, 190145132Sanholt {0x040025bb, 0x00000002}, 191145132Sanholt {0x00061096, 0x00000018}, 192145132Sanholt {0x040075bc, 0000000000}, 193145132Sanholt {0x000075bb, 0x00000002}, 194145132Sanholt {0x000075bc, 0000000000}, 195145132Sanholt {0x00090000, 0x00000006}, 196145132Sanholt {0x00090000, 0x00000002}, 197145132Sanholt {0x000d8002, 0x00000006}, 198145132Sanholt {0x00005000, 0x00000002}, 199145132Sanholt {0x00007821, 0x00000002}, 200145132Sanholt {0x00007800, 0000000000}, 201145132Sanholt {0x00007821, 0x00000002}, 202145132Sanholt {0x00007800, 0000000000}, 203145132Sanholt {0x01665000, 0x00000002}, 204145132Sanholt {0x000a0000, 0x00000002}, 205145132Sanholt {0x000671cc, 0x00000002}, 206145132Sanholt {0x0286f1cd, 0x00000002}, 207145132Sanholt {0x000000a3, 0x00000010}, 208145132Sanholt {0x21007000, 0000000000}, 209145132Sanholt {0x000000aa, 0x0000001c}, 210145132Sanholt {0x00065000, 0x00000002}, 211145132Sanholt {0x000a0000, 0x00000002}, 212145132Sanholt {0x00061000, 0x00000002}, 213145132Sanholt {0x000b0000, 0x00000002}, 214145132Sanholt {0x38067000, 0x00000002}, 215145132Sanholt {0x000a00a6, 0x00000004}, 216145132Sanholt {0x20007000, 0000000000}, 217145132Sanholt {0x01200000, 0x00000002}, 218145132Sanholt {0x20077000, 0x00000002}, 219145132Sanholt {0x01200000, 0x00000002}, 220145132Sanholt {0x20007000, 0000000000}, 221145132Sanholt {0x00061000, 0x00000002}, 222145132Sanholt {0x0120751b, 0x00000002}, 223145132Sanholt {0x8040750a, 0x00000002}, 224145132Sanholt {0x8040750b, 0x00000002}, 225145132Sanholt {0x00110000, 0x00000002}, 226145132Sanholt {0x000380dd, 0x00000002}, 227145132Sanholt {0x000000bd, 0x0000001c}, 228145132Sanholt {0x00061096, 0x00000018}, 229145132Sanholt {0x844075bd, 0x00000002}, 230145132Sanholt {0x00061095, 0x00000018}, 231145132Sanholt {0x840075bb, 0x00000002}, 232145132Sanholt {0x00061096, 0x00000018}, 233145132Sanholt {0x844075bc, 0x00000002}, 234145132Sanholt {0x000000c0, 0x00000004}, 235145132Sanholt {0x804075bd, 0x00000002}, 236145132Sanholt {0x800075bb, 0x00000002}, 237145132Sanholt {0x804075bc, 0x00000002}, 238145132Sanholt {0x00108000, 0x00000002}, 239145132Sanholt {0x01400000, 0x00000002}, 240145132Sanholt {0x006000c4, 0x0000000c}, 241145132Sanholt {0x20c07000, 0x00000020}, 242145132Sanholt {0x000000c6, 0x00000012}, 243145132Sanholt {0x00800000, 0x00000006}, 244145132Sanholt {0x0080751d, 0x00000006}, 245145132Sanholt {0x000025bb, 0x00000002}, 246145132Sanholt {0x000040c0, 0x00000004}, 247145132Sanholt {0x0000775c, 0x00000002}, 248145132Sanholt {0x00a05000, 0x00000002}, 249145132Sanholt {0x00661000, 0x00000002}, 250145132Sanholt {0x0460275d, 0x00000020}, 251145132Sanholt {0x00004000, 0000000000}, 252145132Sanholt {0x00007999, 0x00000002}, 253145132Sanholt {0x00a05000, 0x00000002}, 254145132Sanholt {0x00661000, 0x00000002}, 255145132Sanholt {0x0460299b, 0x00000020}, 256145132Sanholt {0x00004000, 0000000000}, 257145132Sanholt {0x01e00830, 0x00000002}, 258145132Sanholt {0x21007000, 0000000000}, 259145132Sanholt {0x00005000, 0x00000002}, 260145132Sanholt {0x00038042, 0x00000002}, 261145132Sanholt {0x040025e0, 0x00000002}, 262145132Sanholt {0x000075e1, 0000000000}, 263145132Sanholt {0x00000001, 0000000000}, 264145132Sanholt {0x000380d9, 0x00000002}, 265145132Sanholt {0x04007394, 0000000000}, 266145132Sanholt {0000000000, 0000000000}, 267145132Sanholt {0000000000, 0000000000}, 268145132Sanholt {0000000000, 0000000000}, 269145132Sanholt {0000000000, 0000000000}, 270145132Sanholt {0000000000, 0000000000}, 271145132Sanholt {0000000000, 0000000000}, 272145132Sanholt {0000000000, 0000000000}, 273145132Sanholt {0000000000, 0000000000}, 274145132Sanholt {0000000000, 0000000000}, 275145132Sanholt {0000000000, 0000000000}, 276145132Sanholt {0000000000, 0000000000}, 277145132Sanholt {0000000000, 0000000000}, 278145132Sanholt {0000000000, 0000000000}, 279145132Sanholt {0000000000, 0000000000}, 280145132Sanholt {0000000000, 0000000000}, 281145132Sanholt {0000000000, 0000000000}, 282145132Sanholt {0000000000, 0000000000}, 283145132Sanholt {0000000000, 0000000000}, 284145132Sanholt {0000000000, 0000000000}, 285145132Sanholt {0000000000, 0000000000}, 286145132Sanholt {0000000000, 0000000000}, 287145132Sanholt {0000000000, 0000000000}, 288145132Sanholt {0000000000, 0000000000}, 289145132Sanholt {0000000000, 0000000000}, 290145132Sanholt {0000000000, 0000000000}, 291145132Sanholt {0000000000, 0000000000}, 292145132Sanholt {0000000000, 0000000000}, 293145132Sanholt {0000000000, 0000000000}, 294145132Sanholt {0000000000, 0000000000}, 295145132Sanholt {0000000000, 0000000000}, 296145132Sanholt {0000000000, 0000000000}, 297145132Sanholt {0000000000, 0000000000}, 298145132Sanholt {0000000000, 0000000000}, 299145132Sanholt {0000000000, 0000000000}, 300145132Sanholt {0000000000, 0000000000}, 301145132Sanholt {0000000000, 0000000000}, 302112015Sanholt}; 303112015Sanholt 304145132Sanholtstatic u32 radeon_cp_microcode[][2] = { 305145132Sanholt {0x21007000, 0000000000}, 306145132Sanholt {0x20007000, 0000000000}, 307145132Sanholt {0x000000b4, 0x00000004}, 308145132Sanholt {0x000000b8, 0x00000004}, 309145132Sanholt {0x6f5b4d4c, 0000000000}, 310145132Sanholt {0x4c4c427f, 0000000000}, 311145132Sanholt {0x5b568a92, 0000000000}, 312145132Sanholt {0x4ca09c6d, 0000000000}, 313145132Sanholt {0xad4c4c4c, 0000000000}, 314145132Sanholt {0x4ce1af3d, 0000000000}, 315145132Sanholt {0xd8afafaf, 0000000000}, 316145132Sanholt {0xd64c4cdc, 0000000000}, 317145132Sanholt {0x4cd10d10, 0000000000}, 318145132Sanholt {0x000f0000, 0x00000016}, 319145132Sanholt {0x362f242d, 0000000000}, 320145132Sanholt {0x00000012, 0x00000004}, 321145132Sanholt {0x000f0000, 0x00000016}, 322145132Sanholt {0x362f282d, 0000000000}, 323145132Sanholt {0x000380e7, 0x00000002}, 324145132Sanholt {0x04002c97, 0x00000002}, 325145132Sanholt {0x000f0001, 0x00000016}, 326145132Sanholt {0x333a3730, 0000000000}, 327145132Sanholt {0x000077ef, 0x00000002}, 328145132Sanholt {0x00061000, 0x00000002}, 329145132Sanholt {0x00000021, 0x0000001a}, 330145132Sanholt {0x00004000, 0x0000001e}, 331145132Sanholt {0x00061000, 0x00000002}, 332145132Sanholt {0x00000021, 0x0000001a}, 333145132Sanholt {0x00004000, 0x0000001e}, 334145132Sanholt {0x00061000, 0x00000002}, 335145132Sanholt {0x00000021, 0x0000001a}, 336145132Sanholt {0x00004000, 0x0000001e}, 337145132Sanholt {0x00000017, 0x00000004}, 338145132Sanholt {0x0003802b, 0x00000002}, 339145132Sanholt {0x040067e0, 0x00000002}, 340145132Sanholt {0x00000017, 0x00000004}, 341145132Sanholt {0x000077e0, 0x00000002}, 342145132Sanholt {0x00065000, 0x00000002}, 343145132Sanholt {0x000037e1, 0x00000002}, 344145132Sanholt {0x040067e1, 0x00000006}, 345145132Sanholt {0x000077e0, 0x00000002}, 346145132Sanholt {0x000077e1, 0x00000002}, 347145132Sanholt {0x000077e1, 0x00000006}, 348145132Sanholt {0xffffffff, 0000000000}, 349145132Sanholt {0x10000000, 0000000000}, 350145132Sanholt {0x0003802b, 0x00000002}, 351145132Sanholt {0x040067e0, 0x00000006}, 352145132Sanholt {0x00007675, 0x00000002}, 353145132Sanholt {0x00007676, 0x00000002}, 354145132Sanholt {0x00007677, 0x00000002}, 355145132Sanholt {0x00007678, 0x00000006}, 356145132Sanholt {0x0003802c, 0x00000002}, 357145132Sanholt {0x04002676, 0x00000002}, 358145132Sanholt {0x00007677, 0x00000002}, 359145132Sanholt {0x00007678, 0x00000006}, 360145132Sanholt {0x0000002f, 0x00000018}, 361145132Sanholt {0x0000002f, 0x00000018}, 362145132Sanholt {0000000000, 0x00000006}, 363145132Sanholt {0x00000030, 0x00000018}, 364145132Sanholt {0x00000030, 0x00000018}, 365145132Sanholt {0000000000, 0x00000006}, 366145132Sanholt {0x01605000, 0x00000002}, 367145132Sanholt {0x00065000, 0x00000002}, 368145132Sanholt {0x00098000, 0x00000002}, 369145132Sanholt {0x00061000, 0x00000002}, 370145132Sanholt {0x64c0603e, 0x00000004}, 371145132Sanholt {0x000380e6, 0x00000002}, 372145132Sanholt {0x040025c5, 0x00000002}, 373145132Sanholt {0x00080000, 0x00000016}, 374145132Sanholt {0000000000, 0000000000}, 375145132Sanholt {0x0400251d, 0x00000002}, 376145132Sanholt {0x00007580, 0x00000002}, 377145132Sanholt {0x00067581, 0x00000002}, 378145132Sanholt {0x04002580, 0x00000002}, 379145132Sanholt {0x00067581, 0x00000002}, 380145132Sanholt {0x00000049, 0x00000004}, 381145132Sanholt {0x00005000, 0000000000}, 382145132Sanholt {0x000380e6, 0x00000002}, 383145132Sanholt {0x040025c5, 0x00000002}, 384145132Sanholt {0x00061000, 0x00000002}, 385145132Sanholt {0x0000750e, 0x00000002}, 386145132Sanholt {0x00019000, 0x00000002}, 387145132Sanholt {0x00011055, 0x00000014}, 388145132Sanholt {0x00000055, 0x00000012}, 389145132Sanholt {0x0400250f, 0x00000002}, 390145132Sanholt {0x0000504f, 0x00000004}, 391145132Sanholt {0x000380e6, 0x00000002}, 392145132Sanholt {0x040025c5, 0x00000002}, 393145132Sanholt {0x00007565, 0x00000002}, 394145132Sanholt {0x00007566, 0x00000002}, 395145132Sanholt {0x00000058, 0x00000004}, 396145132Sanholt {0x000380e6, 0x00000002}, 397145132Sanholt {0x040025c5, 0x00000002}, 398145132Sanholt {0x01e655b4, 0x00000002}, 399145132Sanholt {0x4401b0e4, 0x00000002}, 400145132Sanholt {0x01c110e4, 0x00000002}, 401145132Sanholt {0x26667066, 0x00000018}, 402145132Sanholt {0x040c2565, 0x00000002}, 403145132Sanholt {0x00000066, 0x00000018}, 404145132Sanholt {0x04002564, 0x00000002}, 405145132Sanholt {0x00007566, 0x00000002}, 406145132Sanholt {0x0000005d, 0x00000004}, 407145132Sanholt {0x00401069, 0x00000008}, 408145132Sanholt {0x00101000, 0x00000002}, 409145132Sanholt {0x000d80ff, 0x00000002}, 410145132Sanholt {0x0080006c, 0x00000008}, 411145132Sanholt {0x000f9000, 0x00000002}, 412145132Sanholt {0x000e00ff, 0x00000002}, 413145132Sanholt {0000000000, 0x00000006}, 414145132Sanholt {0x0000008f, 0x00000018}, 415145132Sanholt {0x0000005b, 0x00000004}, 416145132Sanholt {0x000380e6, 0x00000002}, 417145132Sanholt {0x040025c5, 0x00000002}, 418145132Sanholt {0x00007576, 0x00000002}, 419145132Sanholt {0x00065000, 0x00000002}, 420145132Sanholt {0x00009000, 0x00000002}, 421145132Sanholt {0x00041000, 0x00000002}, 422145132Sanholt {0x0c00350e, 0x00000002}, 423145132Sanholt {0x00049000, 0x00000002}, 424145132Sanholt {0x00051000, 0x00000002}, 425145132Sanholt {0x01e785f8, 0x00000002}, 426145132Sanholt {0x00200000, 0x00000002}, 427145132Sanholt {0x0060007e, 0x0000000c}, 428145132Sanholt {0x00007563, 0x00000002}, 429145132Sanholt {0x006075f0, 0x00000021}, 430145132Sanholt {0x20007073, 0x00000004}, 431145132Sanholt {0x00005073, 0x00000004}, 432145132Sanholt {0x000380e6, 0x00000002}, 433145132Sanholt {0x040025c5, 0x00000002}, 434145132Sanholt {0x00007576, 0x00000002}, 435145132Sanholt {0x00007577, 0x00000002}, 436145132Sanholt {0x0000750e, 0x00000002}, 437145132Sanholt {0x0000750f, 0x00000002}, 438145132Sanholt {0x00a05000, 0x00000002}, 439145132Sanholt {0x00600083, 0x0000000c}, 440145132Sanholt {0x006075f0, 0x00000021}, 441145132Sanholt {0x000075f8, 0x00000002}, 442145132Sanholt {0x00000083, 0x00000004}, 443145132Sanholt {0x000a750e, 0x00000002}, 444145132Sanholt {0x000380e6, 0x00000002}, 445145132Sanholt {0x040025c5, 0x00000002}, 446145132Sanholt {0x0020750f, 0x00000002}, 447145132Sanholt {0x00600086, 0x00000004}, 448145132Sanholt {0x00007570, 0x00000002}, 449145132Sanholt {0x00007571, 0x00000002}, 450145132Sanholt {0x00007572, 0x00000006}, 451145132Sanholt {0x000380e6, 0x00000002}, 452145132Sanholt {0x040025c5, 0x00000002}, 453145132Sanholt {0x00005000, 0x00000002}, 454145132Sanholt {0x00a05000, 0x00000002}, 455145132Sanholt {0x00007568, 0x00000002}, 456145132Sanholt {0x00061000, 0x00000002}, 457145132Sanholt {0x00000095, 0x0000000c}, 458145132Sanholt {0x00058000, 0x00000002}, 459145132Sanholt {0x0c607562, 0x00000002}, 460145132Sanholt {0x00000097, 0x00000004}, 461145132Sanholt {0x000380e6, 0x00000002}, 462145132Sanholt {0x040025c5, 0x00000002}, 463145132Sanholt {0x00600096, 0x00000004}, 464145132Sanholt {0x400070e5, 0000000000}, 465145132Sanholt {0x000380e6, 0x00000002}, 466145132Sanholt {0x040025c5, 0x00000002}, 467145132Sanholt {0x000380e5, 0x00000002}, 468145132Sanholt {0x000000a8, 0x0000001c}, 469145132Sanholt {0x000650aa, 0x00000018}, 470145132Sanholt {0x040025bb, 0x00000002}, 471145132Sanholt {0x000610ab, 0x00000018}, 472145132Sanholt {0x040075bc, 0000000000}, 473145132Sanholt {0x000075bb, 0x00000002}, 474145132Sanholt {0x000075bc, 0000000000}, 475145132Sanholt {0x00090000, 0x00000006}, 476145132Sanholt {0x00090000, 0x00000002}, 477145132Sanholt {0x000d8002, 0x00000006}, 478145132Sanholt {0x00007832, 0x00000002}, 479145132Sanholt {0x00005000, 0x00000002}, 480145132Sanholt {0x000380e7, 0x00000002}, 481145132Sanholt {0x04002c97, 0x00000002}, 482145132Sanholt {0x00007820, 0x00000002}, 483145132Sanholt {0x00007821, 0x00000002}, 484145132Sanholt {0x00007800, 0000000000}, 485145132Sanholt {0x01200000, 0x00000002}, 486145132Sanholt {0x20077000, 0x00000002}, 487145132Sanholt {0x01200000, 0x00000002}, 488145132Sanholt {0x20007000, 0x00000002}, 489145132Sanholt {0x00061000, 0x00000002}, 490145132Sanholt {0x0120751b, 0x00000002}, 491145132Sanholt {0x8040750a, 0x00000002}, 492145132Sanholt {0x8040750b, 0x00000002}, 493145132Sanholt {0x00110000, 0x00000002}, 494145132Sanholt {0x000380e5, 0x00000002}, 495145132Sanholt {0x000000c6, 0x0000001c}, 496145132Sanholt {0x000610ab, 0x00000018}, 497145132Sanholt {0x844075bd, 0x00000002}, 498145132Sanholt {0x000610aa, 0x00000018}, 499145132Sanholt {0x840075bb, 0x00000002}, 500145132Sanholt {0x000610ab, 0x00000018}, 501145132Sanholt {0x844075bc, 0x00000002}, 502145132Sanholt {0x000000c9, 0x00000004}, 503145132Sanholt {0x804075bd, 0x00000002}, 504145132Sanholt {0x800075bb, 0x00000002}, 505145132Sanholt {0x804075bc, 0x00000002}, 506145132Sanholt {0x00108000, 0x00000002}, 507145132Sanholt {0x01400000, 0x00000002}, 508145132Sanholt {0x006000cd, 0x0000000c}, 509145132Sanholt {0x20c07000, 0x00000020}, 510145132Sanholt {0x000000cf, 0x00000012}, 511145132Sanholt {0x00800000, 0x00000006}, 512145132Sanholt {0x0080751d, 0x00000006}, 513145132Sanholt {0000000000, 0000000000}, 514145132Sanholt {0x0000775c, 0x00000002}, 515145132Sanholt {0x00a05000, 0x00000002}, 516145132Sanholt {0x00661000, 0x00000002}, 517145132Sanholt {0x0460275d, 0x00000020}, 518145132Sanholt {0x00004000, 0000000000}, 519145132Sanholt {0x01e00830, 0x00000002}, 520145132Sanholt {0x21007000, 0000000000}, 521145132Sanholt {0x6464614d, 0000000000}, 522145132Sanholt {0x69687420, 0000000000}, 523145132Sanholt {0x00000073, 0000000000}, 524145132Sanholt {0000000000, 0000000000}, 525145132Sanholt {0x00005000, 0x00000002}, 526145132Sanholt {0x000380d0, 0x00000002}, 527145132Sanholt {0x040025e0, 0x00000002}, 528145132Sanholt {0x000075e1, 0000000000}, 529145132Sanholt {0x00000001, 0000000000}, 530145132Sanholt {0x000380e0, 0x00000002}, 531145132Sanholt {0x04002394, 0x00000002}, 532145132Sanholt {0x00005000, 0000000000}, 533145132Sanholt {0000000000, 0000000000}, 534145132Sanholt {0000000000, 0000000000}, 535145132Sanholt {0x00000008, 0000000000}, 536145132Sanholt {0x00000004, 0000000000}, 537145132Sanholt {0000000000, 0000000000}, 538145132Sanholt {0000000000, 0000000000}, 539145132Sanholt {0000000000, 0000000000}, 540145132Sanholt {0000000000, 0000000000}, 541145132Sanholt {0000000000, 0000000000}, 542145132Sanholt {0000000000, 0000000000}, 543145132Sanholt {0000000000, 0000000000}, 544145132Sanholt {0000000000, 0000000000}, 545145132Sanholt {0000000000, 0000000000}, 546145132Sanholt {0000000000, 0000000000}, 547145132Sanholt {0000000000, 0000000000}, 548145132Sanholt {0000000000, 0000000000}, 549145132Sanholt {0000000000, 0000000000}, 550145132Sanholt {0000000000, 0000000000}, 551145132Sanholt {0000000000, 0000000000}, 552145132Sanholt {0000000000, 0000000000}, 553145132Sanholt {0000000000, 0000000000}, 554145132Sanholt {0000000000, 0000000000}, 555145132Sanholt {0000000000, 0000000000}, 556145132Sanholt {0000000000, 0000000000}, 557145132Sanholt {0000000000, 0000000000}, 558145132Sanholt {0000000000, 0000000000}, 559145132Sanholt {0000000000, 0000000000}, 560145132Sanholt {0000000000, 0000000000}, 561145132Sanholt}; 562112015Sanholt 563145132Sanholtstatic u32 R300_cp_microcode[][2] = { 564145132Sanholt { 0x4200e000, 0000000000 }, 565145132Sanholt { 0x4000e000, 0000000000 }, 566145132Sanholt { 0x000000af, 0x00000008 }, 567145132Sanholt { 0x000000b3, 0x00000008 }, 568145132Sanholt { 0x6c5a504f, 0000000000 }, 569145132Sanholt { 0x4f4f497a, 0000000000 }, 570145132Sanholt { 0x5a578288, 0000000000 }, 571145132Sanholt { 0x4f91906a, 0000000000 }, 572145132Sanholt { 0x4f4f4f4f, 0000000000 }, 573145132Sanholt { 0x4fe24f44, 0000000000 }, 574145132Sanholt { 0x4f9c9c9c, 0000000000 }, 575145132Sanholt { 0xdc4f4fde, 0000000000 }, 576145132Sanholt { 0xa1cd4f4f, 0000000000 }, 577145132Sanholt { 0xd29d9d9d, 0000000000 }, 578145132Sanholt { 0x4f0f9fd7, 0000000000 }, 579145132Sanholt { 0x000ca000, 0x00000004 }, 580145132Sanholt { 0x000d0012, 0x00000038 }, 581145132Sanholt { 0x0000e8b4, 0x00000004 }, 582145132Sanholt { 0x000d0014, 0x00000038 }, 583145132Sanholt { 0x0000e8b6, 0x00000004 }, 584145132Sanholt { 0x000d0016, 0x00000038 }, 585145132Sanholt { 0x0000e854, 0x00000004 }, 586145132Sanholt { 0x000d0018, 0x00000038 }, 587145132Sanholt { 0x0000e855, 0x00000004 }, 588145132Sanholt { 0x000d001a, 0x00000038 }, 589145132Sanholt { 0x0000e856, 0x00000004 }, 590145132Sanholt { 0x000d001c, 0x00000038 }, 591145132Sanholt { 0x0000e857, 0x00000004 }, 592145132Sanholt { 0x000d001e, 0x00000038 }, 593145132Sanholt { 0x0000e824, 0x00000004 }, 594145132Sanholt { 0x000d0020, 0x00000038 }, 595145132Sanholt { 0x0000e825, 0x00000004 }, 596145132Sanholt { 0x000d0022, 0x00000038 }, 597145132Sanholt { 0x0000e830, 0x00000004 }, 598145132Sanholt { 0x000d0024, 0x00000038 }, 599145132Sanholt { 0x0000f0c0, 0x00000004 }, 600145132Sanholt { 0x000d0026, 0x00000038 }, 601145132Sanholt { 0x0000f0c1, 0x00000004 }, 602145132Sanholt { 0x000d0028, 0x00000038 }, 603145132Sanholt { 0x0000f041, 0x00000004 }, 604145132Sanholt { 0x000d002a, 0x00000038 }, 605145132Sanholt { 0x0000f184, 0x00000004 }, 606145132Sanholt { 0x000d002c, 0x00000038 }, 607145132Sanholt { 0x0000f185, 0x00000004 }, 608145132Sanholt { 0x000d002e, 0x00000038 }, 609145132Sanholt { 0x0000f186, 0x00000004 }, 610145132Sanholt { 0x000d0030, 0x00000038 }, 611145132Sanholt { 0x0000f187, 0x00000004 }, 612145132Sanholt { 0x000d0032, 0x00000038 }, 613145132Sanholt { 0x0000f180, 0x00000004 }, 614145132Sanholt { 0x000d0034, 0x00000038 }, 615145132Sanholt { 0x0000f393, 0x00000004 }, 616145132Sanholt { 0x000d0036, 0x00000038 }, 617145132Sanholt { 0x0000f38a, 0x00000004 }, 618145132Sanholt { 0x000d0038, 0x00000038 }, 619145132Sanholt { 0x0000f38e, 0x00000004 }, 620145132Sanholt { 0x0000e821, 0x00000004 }, 621145132Sanholt { 0x0140a000, 0x00000004 }, 622145132Sanholt { 0x00000043, 0x00000018 }, 623145132Sanholt { 0x00cce800, 0x00000004 }, 624145132Sanholt { 0x001b0001, 0x00000004 }, 625145132Sanholt { 0x08004800, 0x00000004 }, 626145132Sanholt { 0x001b0001, 0x00000004 }, 627145132Sanholt { 0x08004800, 0x00000004 }, 628145132Sanholt { 0x001b0001, 0x00000004 }, 629145132Sanholt { 0x08004800, 0x00000004 }, 630145132Sanholt { 0x0000003a, 0x00000008 }, 631145132Sanholt { 0x0000a000, 0000000000 }, 632145132Sanholt { 0x02c0a000, 0x00000004 }, 633145132Sanholt { 0x000ca000, 0x00000004 }, 634145132Sanholt { 0x00130000, 0x00000004 }, 635145132Sanholt { 0x000c2000, 0x00000004 }, 636145132Sanholt { 0xc980c045, 0x00000008 }, 637145132Sanholt { 0x2000451d, 0x00000004 }, 638145132Sanholt { 0x0000e580, 0x00000004 }, 639145132Sanholt { 0x000ce581, 0x00000004 }, 640145132Sanholt { 0x08004580, 0x00000004 }, 641145132Sanholt { 0x000ce581, 0x00000004 }, 642145132Sanholt { 0x0000004c, 0x00000008 }, 643145132Sanholt { 0x0000a000, 0000000000 }, 644145132Sanholt { 0x000c2000, 0x00000004 }, 645145132Sanholt { 0x0000e50e, 0x00000004 }, 646145132Sanholt { 0x00032000, 0x00000004 }, 647145132Sanholt { 0x00022056, 0x00000028 }, 648145132Sanholt { 0x00000056, 0x00000024 }, 649145132Sanholt { 0x0800450f, 0x00000004 }, 650145132Sanholt { 0x0000a050, 0x00000008 }, 651145132Sanholt { 0x0000e565, 0x00000004 }, 652145132Sanholt { 0x0000e566, 0x00000004 }, 653145132Sanholt { 0x00000057, 0x00000008 }, 654145132Sanholt { 0x03cca5b4, 0x00000004 }, 655145132Sanholt { 0x05432000, 0x00000004 }, 656145132Sanholt { 0x00022000, 0x00000004 }, 657145132Sanholt { 0x4ccce063, 0x00000030 }, 658145132Sanholt { 0x08274565, 0x00000004 }, 659145132Sanholt { 0x00000063, 0x00000030 }, 660145132Sanholt { 0x08004564, 0x00000004 }, 661145132Sanholt { 0x0000e566, 0x00000004 }, 662145132Sanholt { 0x0000005a, 0x00000008 }, 663145132Sanholt { 0x00802066, 0x00000010 }, 664145132Sanholt { 0x00202000, 0x00000004 }, 665145132Sanholt { 0x001b00ff, 0x00000004 }, 666145132Sanholt { 0x01000069, 0x00000010 }, 667145132Sanholt { 0x001f2000, 0x00000004 }, 668145132Sanholt { 0x001c00ff, 0x00000004 }, 669145132Sanholt { 0000000000, 0x0000000c }, 670145132Sanholt { 0x00000085, 0x00000030 }, 671145132Sanholt { 0x0000005a, 0x00000008 }, 672145132Sanholt { 0x0000e576, 0x00000004 }, 673145132Sanholt { 0x000ca000, 0x00000004 }, 674145132Sanholt { 0x00012000, 0x00000004 }, 675145132Sanholt { 0x00082000, 0x00000004 }, 676145132Sanholt { 0x1800650e, 0x00000004 }, 677145132Sanholt { 0x00092000, 0x00000004 }, 678145132Sanholt { 0x000a2000, 0x00000004 }, 679145132Sanholt { 0x000f0000, 0x00000004 }, 680145132Sanholt { 0x00400000, 0x00000004 }, 681145132Sanholt { 0x00000079, 0x00000018 }, 682145132Sanholt { 0x0000e563, 0x00000004 }, 683145132Sanholt { 0x00c0e5f9, 0x000000c2 }, 684145132Sanholt { 0x0000006e, 0x00000008 }, 685145132Sanholt { 0x0000a06e, 0x00000008 }, 686145132Sanholt { 0x0000e576, 0x00000004 }, 687145132Sanholt { 0x0000e577, 0x00000004 }, 688145132Sanholt { 0x0000e50e, 0x00000004 }, 689145132Sanholt { 0x0000e50f, 0x00000004 }, 690145132Sanholt { 0x0140a000, 0x00000004 }, 691145132Sanholt { 0x0000007c, 0x00000018 }, 692145132Sanholt { 0x00c0e5f9, 0x000000c2 }, 693145132Sanholt { 0x0000007c, 0x00000008 }, 694145132Sanholt { 0x0014e50e, 0x00000004 }, 695145132Sanholt { 0x0040e50f, 0x00000004 }, 696145132Sanholt { 0x00c0007f, 0x00000008 }, 697145132Sanholt { 0x0000e570, 0x00000004 }, 698145132Sanholt { 0x0000e571, 0x00000004 }, 699145132Sanholt { 0x0000e572, 0x0000000c }, 700145132Sanholt { 0x0000a000, 0x00000004 }, 701145132Sanholt { 0x0140a000, 0x00000004 }, 702145132Sanholt { 0x0000e568, 0x00000004 }, 703145132Sanholt { 0x000c2000, 0x00000004 }, 704145132Sanholt { 0x00000089, 0x00000018 }, 705145132Sanholt { 0x000b0000, 0x00000004 }, 706145132Sanholt { 0x18c0e562, 0x00000004 }, 707145132Sanholt { 0x0000008b, 0x00000008 }, 708145132Sanholt { 0x00c0008a, 0x00000008 }, 709145132Sanholt { 0x000700e4, 0x00000004 }, 710145132Sanholt { 0x00000097, 0x00000038 }, 711145132Sanholt { 0x000ca099, 0x00000030 }, 712145132Sanholt { 0x080045bb, 0x00000004 }, 713145132Sanholt { 0x000c209a, 0x00000030 }, 714145132Sanholt { 0x0800e5bc, 0000000000 }, 715145132Sanholt { 0x0000e5bb, 0x00000004 }, 716145132Sanholt { 0x0000e5bc, 0000000000 }, 717145132Sanholt { 0x00120000, 0x0000000c }, 718145132Sanholt { 0x00120000, 0x00000004 }, 719145132Sanholt { 0x001b0002, 0x0000000c }, 720145132Sanholt { 0x0000a000, 0x00000004 }, 721145132Sanholt { 0x0000e821, 0x00000004 }, 722145132Sanholt { 0x0000e800, 0000000000 }, 723145132Sanholt { 0x0000e821, 0x00000004 }, 724145132Sanholt { 0x0000e82e, 0000000000 }, 725145132Sanholt { 0x02cca000, 0x00000004 }, 726145132Sanholt { 0x00140000, 0x00000004 }, 727145132Sanholt { 0x000ce1cc, 0x00000004 }, 728145132Sanholt { 0x050de1cd, 0x00000004 }, 729145132Sanholt { 0x000000a7, 0x00000020 }, 730145132Sanholt { 0x4200e000, 0000000000 }, 731145132Sanholt { 0x000000ae, 0x00000038 }, 732145132Sanholt { 0x000ca000, 0x00000004 }, 733145132Sanholt { 0x00140000, 0x00000004 }, 734145132Sanholt { 0x000c2000, 0x00000004 }, 735145132Sanholt { 0x00160000, 0x00000004 }, 736145132Sanholt { 0x700ce000, 0x00000004 }, 737145132Sanholt { 0x001400aa, 0x00000008 }, 738145132Sanholt { 0x4000e000, 0000000000 }, 739145132Sanholt { 0x02400000, 0x00000004 }, 740145132Sanholt { 0x400ee000, 0x00000004 }, 741145132Sanholt { 0x02400000, 0x00000004 }, 742145132Sanholt { 0x4000e000, 0000000000 }, 743145132Sanholt { 0x000c2000, 0x00000004 }, 744145132Sanholt { 0x0240e51b, 0x00000004 }, 745145132Sanholt { 0x0080e50a, 0x00000005 }, 746145132Sanholt { 0x0080e50b, 0x00000005 }, 747145132Sanholt { 0x00220000, 0x00000004 }, 748145132Sanholt { 0x000700e4, 0x00000004 }, 749145132Sanholt { 0x000000c1, 0x00000038 }, 750145132Sanholt { 0x000c209a, 0x00000030 }, 751145132Sanholt { 0x0880e5bd, 0x00000005 }, 752145132Sanholt { 0x000c2099, 0x00000030 }, 753145132Sanholt { 0x0800e5bb, 0x00000005 }, 754145132Sanholt { 0x000c209a, 0x00000030 }, 755145132Sanholt { 0x0880e5bc, 0x00000005 }, 756145132Sanholt { 0x000000c4, 0x00000008 }, 757145132Sanholt { 0x0080e5bd, 0x00000005 }, 758145132Sanholt { 0x0000e5bb, 0x00000005 }, 759145132Sanholt { 0x0080e5bc, 0x00000005 }, 760145132Sanholt { 0x00210000, 0x00000004 }, 761145132Sanholt { 0x02800000, 0x00000004 }, 762145132Sanholt { 0x00c000c8, 0x00000018 }, 763145132Sanholt { 0x4180e000, 0x00000040 }, 764145132Sanholt { 0x000000ca, 0x00000024 }, 765145132Sanholt { 0x01000000, 0x0000000c }, 766145132Sanholt { 0x0100e51d, 0x0000000c }, 767145132Sanholt { 0x000045bb, 0x00000004 }, 768145132Sanholt { 0x000080c4, 0x00000008 }, 769145132Sanholt { 0x0000f3ce, 0x00000004 }, 770145132Sanholt { 0x0140a000, 0x00000004 }, 771145132Sanholt { 0x00cc2000, 0x00000004 }, 772145132Sanholt { 0x08c053cf, 0x00000040 }, 773145132Sanholt { 0x00008000, 0000000000 }, 774145132Sanholt { 0x0000f3d2, 0x00000004 }, 775145132Sanholt { 0x0140a000, 0x00000004 }, 776145132Sanholt { 0x00cc2000, 0x00000004 }, 777145132Sanholt { 0x08c053d3, 0x00000040 }, 778145132Sanholt { 0x00008000, 0000000000 }, 779145132Sanholt { 0x0000f39d, 0x00000004 }, 780145132Sanholt { 0x0140a000, 0x00000004 }, 781145132Sanholt { 0x00cc2000, 0x00000004 }, 782145132Sanholt { 0x08c0539e, 0x00000040 }, 783145132Sanholt { 0x00008000, 0000000000 }, 784145132Sanholt { 0x03c00830, 0x00000004 }, 785145132Sanholt { 0x4200e000, 0000000000 }, 786145132Sanholt { 0x0000a000, 0x00000004 }, 787145132Sanholt { 0x200045e0, 0x00000004 }, 788145132Sanholt { 0x0000e5e1, 0000000000 }, 789145132Sanholt { 0x00000001, 0000000000 }, 790145132Sanholt { 0x000700e1, 0x00000004 }, 791145132Sanholt { 0x0800e394, 0000000000 }, 79295584Sanholt { 0000000000, 0000000000 }, 79395584Sanholt { 0000000000, 0000000000 }, 79495584Sanholt { 0000000000, 0000000000 }, 79595584Sanholt { 0000000000, 0000000000 }, 79695584Sanholt { 0000000000, 0000000000 }, 79795584Sanholt { 0000000000, 0000000000 }, 79895584Sanholt { 0000000000, 0000000000 }, 79995584Sanholt { 0000000000, 0000000000 }, 80095584Sanholt { 0000000000, 0000000000 }, 80195584Sanholt { 0000000000, 0000000000 }, 80295584Sanholt { 0000000000, 0000000000 }, 80395584Sanholt { 0000000000, 0000000000 }, 80495584Sanholt { 0000000000, 0000000000 }, 80595584Sanholt { 0000000000, 0000000000 }, 80695584Sanholt { 0000000000, 0000000000 }, 80795584Sanholt { 0000000000, 0000000000 }, 80895584Sanholt { 0000000000, 0000000000 }, 80995584Sanholt { 0000000000, 0000000000 }, 81095584Sanholt { 0000000000, 0000000000 }, 81195584Sanholt { 0000000000, 0000000000 }, 81295584Sanholt { 0000000000, 0000000000 }, 81395584Sanholt { 0000000000, 0000000000 }, 81495584Sanholt { 0000000000, 0000000000 }, 81595584Sanholt { 0000000000, 0000000000 }, 81695584Sanholt { 0000000000, 0000000000 }, 81795584Sanholt { 0000000000, 0000000000 }, 81895584Sanholt { 0000000000, 0000000000 }, 81995584Sanholt { 0000000000, 0000000000 }, 82095584Sanholt}; 82195584Sanholt 822145132Sanholtstatic int RADEON_READ_PLL(drm_device_t * dev, int addr) 82395584Sanholt{ 82495584Sanholt drm_radeon_private_t *dev_priv = dev->dev_private; 82595584Sanholt 82695584Sanholt RADEON_WRITE8(RADEON_CLOCK_CNTL_INDEX, addr & 0x1f); 82795584Sanholt return RADEON_READ(RADEON_CLOCK_CNTL_DATA); 82895584Sanholt} 82995584Sanholt 830148211Sanholtstatic int RADEON_READ_PCIE(drm_radeon_private_t *dev_priv, int addr) 831148211Sanholt{ 832148211Sanholt RADEON_WRITE8(RADEON_PCIE_INDEX, addr & 0xff); 833148211Sanholt return RADEON_READ(RADEON_PCIE_DATA); 834148211Sanholt} 835148211Sanholt 83695584Sanholt#if RADEON_FIFO_DEBUG 837145132Sanholtstatic void radeon_status(drm_radeon_private_t * dev_priv) 83895584Sanholt{ 839145132Sanholt printk("%s:\n", __FUNCTION__); 840145132Sanholt printk("RBBM_STATUS = 0x%08x\n", 841145132Sanholt (unsigned int)RADEON_READ(RADEON_RBBM_STATUS)); 842145132Sanholt printk("CP_RB_RTPR = 0x%08x\n", 843145132Sanholt (unsigned int)RADEON_READ(RADEON_CP_RB_RPTR)); 844145132Sanholt printk("CP_RB_WTPR = 0x%08x\n", 845145132Sanholt (unsigned int)RADEON_READ(RADEON_CP_RB_WPTR)); 846145132Sanholt printk("AIC_CNTL = 0x%08x\n", 847145132Sanholt (unsigned int)RADEON_READ(RADEON_AIC_CNTL)); 848145132Sanholt printk("AIC_STAT = 0x%08x\n", 849145132Sanholt (unsigned int)RADEON_READ(RADEON_AIC_STAT)); 850145132Sanholt printk("AIC_PT_BASE = 0x%08x\n", 851145132Sanholt (unsigned int)RADEON_READ(RADEON_AIC_PT_BASE)); 852145132Sanholt printk("TLB_ADDR = 0x%08x\n", 853145132Sanholt (unsigned int)RADEON_READ(RADEON_AIC_TLB_ADDR)); 854145132Sanholt printk("TLB_DATA = 0x%08x\n", 855145132Sanholt (unsigned int)RADEON_READ(RADEON_AIC_TLB_DATA)); 85695584Sanholt} 85795584Sanholt#endif 85895584Sanholt 85995584Sanholt/* ================================================================ 86095584Sanholt * Engine, FIFO control 86195584Sanholt */ 86295584Sanholt 863145132Sanholtstatic int radeon_do_pixcache_flush(drm_radeon_private_t * dev_priv) 86495584Sanholt{ 86595584Sanholt u32 tmp; 86695584Sanholt int i; 86795584Sanholt 868112015Sanholt dev_priv->stats.boxes |= RADEON_BOX_WAIT_IDLE; 869112015Sanholt 870145132Sanholt tmp = RADEON_READ(RADEON_RB2D_DSTCACHE_CTLSTAT); 87195584Sanholt tmp |= RADEON_RB2D_DC_FLUSH_ALL; 872145132Sanholt RADEON_WRITE(RADEON_RB2D_DSTCACHE_CTLSTAT, tmp); 87395584Sanholt 874145132Sanholt for (i = 0; i < dev_priv->usec_timeout; i++) { 875145132Sanholt if (!(RADEON_READ(RADEON_RB2D_DSTCACHE_CTLSTAT) 876145132Sanholt & RADEON_RB2D_DC_BUSY)) { 87795584Sanholt return 0; 87895584Sanholt } 879145132Sanholt DRM_UDELAY(1); 88095584Sanholt } 88195584Sanholt 88295584Sanholt#if RADEON_FIFO_DEBUG 883145132Sanholt DRM_ERROR("failed!\n"); 884145132Sanholt radeon_status(dev_priv); 88595584Sanholt#endif 886112015Sanholt return DRM_ERR(EBUSY); 88795584Sanholt} 88895584Sanholt 889145132Sanholtstatic int radeon_do_wait_for_fifo(drm_radeon_private_t * dev_priv, int entries) 89095584Sanholt{ 89195584Sanholt int i; 89295584Sanholt 893112015Sanholt dev_priv->stats.boxes |= RADEON_BOX_WAIT_IDLE; 894112015Sanholt 895145132Sanholt for (i = 0; i < dev_priv->usec_timeout; i++) { 896145132Sanholt int slots = (RADEON_READ(RADEON_RBBM_STATUS) 897145132Sanholt & RADEON_RBBM_FIFOCNT_MASK); 898145132Sanholt if (slots >= entries) 899145132Sanholt return 0; 900145132Sanholt DRM_UDELAY(1); 90195584Sanholt } 90295584Sanholt 90395584Sanholt#if RADEON_FIFO_DEBUG 904145132Sanholt DRM_ERROR("failed!\n"); 905145132Sanholt radeon_status(dev_priv); 90695584Sanholt#endif 907112015Sanholt return DRM_ERR(EBUSY); 90895584Sanholt} 90995584Sanholt 910145132Sanholtstatic int radeon_do_wait_for_idle(drm_radeon_private_t * dev_priv) 91195584Sanholt{ 91295584Sanholt int i, ret; 91395584Sanholt 914112015Sanholt dev_priv->stats.boxes |= RADEON_BOX_WAIT_IDLE; 915112015Sanholt 916145132Sanholt ret = radeon_do_wait_for_fifo(dev_priv, 64); 917145132Sanholt if (ret) 918145132Sanholt return ret; 919112015Sanholt 920145132Sanholt for (i = 0; i < dev_priv->usec_timeout; i++) { 921145132Sanholt if (!(RADEON_READ(RADEON_RBBM_STATUS) 922145132Sanholt & RADEON_RBBM_ACTIVE)) { 923145132Sanholt radeon_do_pixcache_flush(dev_priv); 92495584Sanholt return 0; 92595584Sanholt } 926145132Sanholt DRM_UDELAY(1); 92795584Sanholt } 92895584Sanholt 92995584Sanholt#if RADEON_FIFO_DEBUG 930145132Sanholt DRM_ERROR("failed!\n"); 931145132Sanholt radeon_status(dev_priv); 93295584Sanholt#endif 933112015Sanholt return DRM_ERR(EBUSY); 93495584Sanholt} 93595584Sanholt 93695584Sanholt/* ================================================================ 93795584Sanholt * CP control, initialization 93895584Sanholt */ 93995584Sanholt 94095584Sanholt/* Load the microcode for the CP */ 941145132Sanholtstatic void radeon_cp_load_microcode(drm_radeon_private_t * dev_priv) 94295584Sanholt{ 94395584Sanholt int i; 944145132Sanholt DRM_DEBUG("\n"); 94595584Sanholt 946145132Sanholt radeon_do_wait_for_idle(dev_priv); 94795584Sanholt 948145132Sanholt RADEON_WRITE(RADEON_CP_ME_RAM_ADDR, 0); 949112015Sanholt 950145132Sanholt if (dev_priv->microcode_version==UCODE_R200) { 951112015Sanholt DRM_INFO("Loading R200 Microcode\n"); 952145132Sanholt for (i = 0; i < 256; i++) { 953145132Sanholt RADEON_WRITE(RADEON_CP_ME_RAM_DATAH, 954145132Sanholt R200_cp_microcode[i][1]); 955145132Sanholt RADEON_WRITE(RADEON_CP_ME_RAM_DATAL, 956145132Sanholt R200_cp_microcode[i][0]); 957112015Sanholt } 958145132Sanholt } else if (dev_priv->microcode_version==UCODE_R300) { 959145132Sanholt DRM_INFO("Loading R300 Microcode\n"); 960112015Sanholt for ( i = 0 ; i < 256 ; i++ ) { 961112015Sanholt RADEON_WRITE( RADEON_CP_ME_RAM_DATAH, 962145132Sanholt R300_cp_microcode[i][1] ); 963112015Sanholt RADEON_WRITE( RADEON_CP_ME_RAM_DATAL, 964145132Sanholt R300_cp_microcode[i][0] ); 965112015Sanholt } 966145132Sanholt } else { 967145132Sanholt for (i = 0; i < 256; i++) { 968145132Sanholt RADEON_WRITE(RADEON_CP_ME_RAM_DATAH, 969145132Sanholt radeon_cp_microcode[i][1]); 970145132Sanholt RADEON_WRITE(RADEON_CP_ME_RAM_DATAL, 971145132Sanholt radeon_cp_microcode[i][0]); 972145132Sanholt } 973112015Sanholt } 97495584Sanholt} 97595584Sanholt 97695584Sanholt/* Flush any pending commands to the CP. This should only be used just 97795584Sanholt * prior to a wait for idle, as it informs the engine that the command 97895584Sanholt * stream is ending. 97995584Sanholt */ 980145132Sanholtstatic void radeon_do_cp_flush(drm_radeon_private_t * dev_priv) 98195584Sanholt{ 982145132Sanholt DRM_DEBUG("\n"); 98395584Sanholt#if 0 98495584Sanholt u32 tmp; 98595584Sanholt 986145132Sanholt tmp = RADEON_READ(RADEON_CP_RB_WPTR) | (1 << 31); 987145132Sanholt RADEON_WRITE(RADEON_CP_RB_WPTR, tmp); 98895584Sanholt#endif 98995584Sanholt} 99095584Sanholt 99195584Sanholt/* Wait for the CP to go idle. 99295584Sanholt */ 993145132Sanholtint radeon_do_cp_idle(drm_radeon_private_t * dev_priv) 99495584Sanholt{ 99595584Sanholt RING_LOCALS; 996145132Sanholt DRM_DEBUG("\n"); 99795584Sanholt 998145132Sanholt BEGIN_RING(6); 99995584Sanholt 100095584Sanholt RADEON_PURGE_CACHE(); 100195584Sanholt RADEON_PURGE_ZCACHE(); 100295584Sanholt RADEON_WAIT_UNTIL_IDLE(); 100395584Sanholt 100495584Sanholt ADVANCE_RING(); 1005112015Sanholt COMMIT_RING(); 100695584Sanholt 1007145132Sanholt return radeon_do_wait_for_idle(dev_priv); 100895584Sanholt} 100995584Sanholt 101095584Sanholt/* Start the Command Processor. 101195584Sanholt */ 1012145132Sanholtstatic void radeon_do_cp_start(drm_radeon_private_t * dev_priv) 101395584Sanholt{ 101495584Sanholt RING_LOCALS; 1015145132Sanholt DRM_DEBUG("\n"); 101695584Sanholt 1017145132Sanholt radeon_do_wait_for_idle(dev_priv); 101895584Sanholt 1019145132Sanholt RADEON_WRITE(RADEON_CP_CSQ_CNTL, dev_priv->cp_mode); 102095584Sanholt 102195584Sanholt dev_priv->cp_running = 1; 102295584Sanholt 1023145132Sanholt BEGIN_RING(6); 102495584Sanholt 102595584Sanholt RADEON_PURGE_CACHE(); 102695584Sanholt RADEON_PURGE_ZCACHE(); 102795584Sanholt RADEON_WAIT_UNTIL_IDLE(); 102895584Sanholt 102995584Sanholt ADVANCE_RING(); 1030112015Sanholt COMMIT_RING(); 103195584Sanholt} 103295584Sanholt 103395584Sanholt/* Reset the Command Processor. This will not flush any pending 103495584Sanholt * commands, so you must wait for the CP command stream to complete 103595584Sanholt * before calling this routine. 103695584Sanholt */ 1037145132Sanholtstatic void radeon_do_cp_reset(drm_radeon_private_t * dev_priv) 103895584Sanholt{ 103995584Sanholt u32 cur_read_ptr; 1040145132Sanholt DRM_DEBUG("\n"); 104195584Sanholt 1042145132Sanholt cur_read_ptr = RADEON_READ(RADEON_CP_RB_RPTR); 1043145132Sanholt RADEON_WRITE(RADEON_CP_RB_WPTR, cur_read_ptr); 1044145132Sanholt SET_RING_HEAD(dev_priv, cur_read_ptr); 104595584Sanholt dev_priv->ring.tail = cur_read_ptr; 104695584Sanholt} 104795584Sanholt 104895584Sanholt/* Stop the Command Processor. This will not flush any pending 104995584Sanholt * commands, so you must flush the command stream and wait for the CP 105095584Sanholt * to go idle before calling this routine. 105195584Sanholt */ 1052145132Sanholtstatic void radeon_do_cp_stop(drm_radeon_private_t * dev_priv) 105395584Sanholt{ 1054145132Sanholt DRM_DEBUG("\n"); 105595584Sanholt 1056145132Sanholt RADEON_WRITE(RADEON_CP_CSQ_CNTL, RADEON_CSQ_PRIDIS_INDDIS); 105795584Sanholt 105895584Sanholt dev_priv->cp_running = 0; 105995584Sanholt} 106095584Sanholt 106195584Sanholt/* Reset the engine. This will stop the CP if it is running. 106295584Sanholt */ 1063145132Sanholtstatic int radeon_do_engine_reset(drm_device_t * dev) 106495584Sanholt{ 106595584Sanholt drm_radeon_private_t *dev_priv = dev->dev_private; 106695584Sanholt u32 clock_cntl_index, mclk_cntl, rbbm_soft_reset; 1067145132Sanholt DRM_DEBUG("\n"); 106895584Sanholt 1069145132Sanholt radeon_do_pixcache_flush(dev_priv); 107095584Sanholt 1071145132Sanholt clock_cntl_index = RADEON_READ(RADEON_CLOCK_CNTL_INDEX); 1072145132Sanholt mclk_cntl = RADEON_READ_PLL(dev, RADEON_MCLK_CNTL); 107395584Sanholt 1074145132Sanholt RADEON_WRITE_PLL(RADEON_MCLK_CNTL, (mclk_cntl | 1075145132Sanholt RADEON_FORCEON_MCLKA | 1076145132Sanholt RADEON_FORCEON_MCLKB | 1077145132Sanholt RADEON_FORCEON_YCLKA | 1078145132Sanholt RADEON_FORCEON_YCLKB | 1079145132Sanholt RADEON_FORCEON_MC | 1080145132Sanholt RADEON_FORCEON_AIC)); 108195584Sanholt 1082145132Sanholt rbbm_soft_reset = RADEON_READ(RADEON_RBBM_SOFT_RESET); 108395584Sanholt 1084145132Sanholt RADEON_WRITE(RADEON_RBBM_SOFT_RESET, (rbbm_soft_reset | 1085145132Sanholt RADEON_SOFT_RESET_CP | 1086145132Sanholt RADEON_SOFT_RESET_HI | 1087145132Sanholt RADEON_SOFT_RESET_SE | 1088145132Sanholt RADEON_SOFT_RESET_RE | 1089145132Sanholt RADEON_SOFT_RESET_PP | 1090145132Sanholt RADEON_SOFT_RESET_E2 | 1091145132Sanholt RADEON_SOFT_RESET_RB)); 1092145132Sanholt RADEON_READ(RADEON_RBBM_SOFT_RESET); 1093145132Sanholt RADEON_WRITE(RADEON_RBBM_SOFT_RESET, (rbbm_soft_reset & 1094145132Sanholt ~(RADEON_SOFT_RESET_CP | 109595584Sanholt RADEON_SOFT_RESET_HI | 109695584Sanholt RADEON_SOFT_RESET_SE | 109795584Sanholt RADEON_SOFT_RESET_RE | 109895584Sanholt RADEON_SOFT_RESET_PP | 109995584Sanholt RADEON_SOFT_RESET_E2 | 1100145132Sanholt RADEON_SOFT_RESET_RB))); 1101145132Sanholt RADEON_READ(RADEON_RBBM_SOFT_RESET); 110295584Sanholt 1103145132Sanholt RADEON_WRITE_PLL(RADEON_MCLK_CNTL, mclk_cntl); 1104145132Sanholt RADEON_WRITE(RADEON_CLOCK_CNTL_INDEX, clock_cntl_index); 1105145132Sanholt RADEON_WRITE(RADEON_RBBM_SOFT_RESET, rbbm_soft_reset); 110695584Sanholt 110795584Sanholt /* Reset the CP ring */ 1108145132Sanholt radeon_do_cp_reset(dev_priv); 110995584Sanholt 111095584Sanholt /* The CP is no longer running after an engine reset */ 111195584Sanholt dev_priv->cp_running = 0; 111295584Sanholt 111395584Sanholt /* Reset any pending vertex, indirect buffers */ 1114145132Sanholt radeon_freelist_reset(dev); 111595584Sanholt 111695584Sanholt return 0; 111795584Sanholt} 111895584Sanholt 1119145132Sanholtstatic void radeon_cp_init_ring_buffer(drm_device_t * dev, 1120145132Sanholt drm_radeon_private_t * dev_priv) 112195584Sanholt{ 112295584Sanholt u32 ring_start, cur_read_ptr; 112395584Sanholt u32 tmp; 112495584Sanholt 112595584Sanholt /* Initialize the memory controller */ 1126145132Sanholt RADEON_WRITE(RADEON_MC_FB_LOCATION, 1127145132Sanholt ((dev_priv->gart_vm_start - 1) & 0xffff0000) 1128145132Sanholt | (dev_priv->fb_location >> 16)); 112995584Sanholt 1130145132Sanholt#if __OS_HAS_AGP 1131145132Sanholt if (dev_priv->flags & CHIP_IS_AGP) { 1132145132Sanholt RADEON_WRITE(RADEON_MC_AGP_LOCATION, 1133145132Sanholt (((dev_priv->gart_vm_start - 1 + 1134145132Sanholt dev_priv->gart_size) & 0xffff0000) | 1135145132Sanholt (dev_priv->gart_vm_start >> 16))); 113695584Sanholt 113795584Sanholt ring_start = (dev_priv->cp_ring->offset 1138145132Sanholt - dev->agp->base + dev_priv->gart_vm_start); 1139145132Sanholt } else 114095584Sanholt#endif 114195584Sanholt ring_start = (dev_priv->cp_ring->offset 1142152909Sanholt - (unsigned long)dev->sg->virtual + dev_priv->gart_vm_start); 114395584Sanholt 1144148211Sanholt 1145145132Sanholt RADEON_WRITE(RADEON_CP_RB_BASE, ring_start); 114695584Sanholt 114795584Sanholt /* Set the write pointer delay */ 1148145132Sanholt RADEON_WRITE(RADEON_CP_RB_WPTR_DELAY, 0); 114995584Sanholt 115095584Sanholt /* Initialize the ring buffer's read and write pointers */ 1151145132Sanholt cur_read_ptr = RADEON_READ(RADEON_CP_RB_RPTR); 1152145132Sanholt RADEON_WRITE(RADEON_CP_RB_WPTR, cur_read_ptr); 1153145132Sanholt SET_RING_HEAD(dev_priv, cur_read_ptr); 115495584Sanholt dev_priv->ring.tail = cur_read_ptr; 115595584Sanholt 1156145132Sanholt#if __OS_HAS_AGP 1157145132Sanholt if (dev_priv->flags & CHIP_IS_AGP) { 1158145132Sanholt /* set RADEON_AGP_BASE here instead of relying on X from user space */ 1159145132Sanholt RADEON_WRITE(RADEON_AGP_BASE, (unsigned int)dev->agp->base); 1160145132Sanholt RADEON_WRITE(RADEON_CP_RB_RPTR_ADDR, 1161145132Sanholt dev_priv->ring_rptr->offset 1162145132Sanholt - dev->agp->base + dev_priv->gart_vm_start); 1163113995Sanholt } else 1164113995Sanholt#endif 1165113995Sanholt { 116695584Sanholt drm_sg_mem_t *entry = dev->sg; 116795584Sanholt unsigned long tmp_ofs, page_ofs; 116895584Sanholt 1169152909Sanholt tmp_ofs = dev_priv->ring_rptr->offset - (unsigned long)dev->sg->virtual; 117095584Sanholt page_ofs = tmp_ofs >> PAGE_SHIFT; 117195584Sanholt 1172145132Sanholt RADEON_WRITE(RADEON_CP_RB_RPTR_ADDR, entry->busaddr[page_ofs]); 1173145132Sanholt DRM_DEBUG("ring rptr: offset=0x%08lx handle=0x%08lx\n", 1174145132Sanholt (unsigned long)entry->busaddr[page_ofs], 1175145132Sanholt entry->handle + tmp_ofs); 117695584Sanholt } 117795584Sanholt 1178112015Sanholt /* Initialize the scratch register pointer. This will cause 1179112015Sanholt * the scratch register values to be written out to memory 1180112015Sanholt * whenever they are updated. 1181112015Sanholt * 1182112015Sanholt * We simply put this behind the ring read pointer, this works 1183112015Sanholt * with PCI GART as well as (whatever kind of) AGP GART 1184112015Sanholt */ 1185145132Sanholt RADEON_WRITE(RADEON_SCRATCH_ADDR, RADEON_READ(RADEON_CP_RB_RPTR_ADDR) 1186145132Sanholt + RADEON_SCRATCH_REG_OFFSET); 1187112015Sanholt 1188112015Sanholt dev_priv->scratch = ((__volatile__ u32 *) 1189113995Sanholt dev_priv->ring_rptr->handle + 1190112015Sanholt (RADEON_SCRATCH_REG_OFFSET / sizeof(u32))); 1191112015Sanholt 1192145132Sanholt RADEON_WRITE(RADEON_SCRATCH_UMSK, 0x7); 1193112015Sanholt 1194112015Sanholt /* Writeback doesn't seem to work everywhere, test it first */ 1195145132Sanholt DRM_WRITE32(dev_priv->ring_rptr, RADEON_SCRATCHOFF(1), 0); 1196145132Sanholt RADEON_WRITE(RADEON_SCRATCH_REG1, 0xdeadbeef); 1197112015Sanholt 1198145132Sanholt for (tmp = 0; tmp < dev_priv->usec_timeout; tmp++) { 1199145132Sanholt if (DRM_READ32(dev_priv->ring_rptr, RADEON_SCRATCHOFF(1)) == 1200145132Sanholt 0xdeadbeef) 1201112015Sanholt break; 1202145132Sanholt DRM_UDELAY(1); 1203112015Sanholt } 1204112015Sanholt 1205145132Sanholt if (tmp < dev_priv->usec_timeout) { 1206112015Sanholt dev_priv->writeback_works = 1; 1207145132Sanholt DRM_DEBUG("writeback test succeeded, tmp=%d\n", tmp); 1208112015Sanholt } else { 1209112015Sanholt dev_priv->writeback_works = 0; 1210145132Sanholt DRM_DEBUG("writeback test failed\n"); 1211112015Sanholt } 1212152909Sanholt if (radeon_no_wb == 1) { 1213152909Sanholt dev_priv->writeback_works = 0; 1214152909Sanholt DRM_DEBUG("writeback forced off\n"); 1215152909Sanholt } 1216112015Sanholt 1217112015Sanholt dev_priv->sarea_priv->last_frame = dev_priv->scratch[0] = 0; 1218145132Sanholt RADEON_WRITE(RADEON_LAST_FRAME_REG, dev_priv->sarea_priv->last_frame); 1219112015Sanholt 1220112015Sanholt dev_priv->sarea_priv->last_dispatch = dev_priv->scratch[1] = 0; 1221145132Sanholt RADEON_WRITE(RADEON_LAST_DISPATCH_REG, 1222145132Sanholt dev_priv->sarea_priv->last_dispatch); 1223112015Sanholt 1224112015Sanholt dev_priv->sarea_priv->last_clear = dev_priv->scratch[2] = 0; 1225145132Sanholt RADEON_WRITE(RADEON_LAST_CLEAR_REG, dev_priv->sarea_priv->last_clear); 1226112015Sanholt 122795584Sanholt /* Set ring buffer size */ 1228112015Sanholt#ifdef __BIG_ENDIAN 1229145132Sanholt RADEON_WRITE(RADEON_CP_RB_CNTL, 1230145132Sanholt dev_priv->ring.size_l2qw | RADEON_BUF_SWAP_32BIT); 1231112015Sanholt#else 1232145132Sanholt RADEON_WRITE(RADEON_CP_RB_CNTL, dev_priv->ring.size_l2qw); 1233112015Sanholt#endif 123495584Sanholt 1235145132Sanholt radeon_do_wait_for_idle(dev_priv); 123695584Sanholt 123795584Sanholt /* Turn on bus mastering */ 1238145132Sanholt tmp = RADEON_READ(RADEON_BUS_CNTL) & ~RADEON_BUS_MASTER_DIS; 1239145132Sanholt RADEON_WRITE(RADEON_BUS_CNTL, tmp); 124095584Sanholt 124195584Sanholt /* Sync everything up */ 1242145132Sanholt RADEON_WRITE(RADEON_ISYNC_CNTL, 1243145132Sanholt (RADEON_ISYNC_ANY2D_IDLE3D | 1244145132Sanholt RADEON_ISYNC_ANY3D_IDLE2D | 1245145132Sanholt RADEON_ISYNC_WAIT_IDLEGUI | 1246145132Sanholt RADEON_ISYNC_CPSCRATCH_IDLEGUI)); 124795584Sanholt} 124895584Sanholt 1249148211Sanholt/* Enable or disable PCI-E GART on the chip */ 1250148211Sanholtstatic void radeon_set_pciegart(drm_radeon_private_t * dev_priv, int on) 1251148211Sanholt{ 1252148211Sanholt u32 tmp = RADEON_READ_PCIE(dev_priv, RADEON_PCIE_TX_GART_CNTL); 1253148211Sanholt if (on) { 1254148211Sanholt 1255152909Sanholt DRM_DEBUG("programming pcie %08X %08lX %08X\n", 1256152909Sanholt dev_priv->gart_vm_start, (long)dev_priv->gart_info.bus_addr, 1257152909Sanholt dev_priv->gart_size); 1258148211Sanholt RADEON_WRITE_PCIE(RADEON_PCIE_TX_DISCARD_RD_ADDR_LO, dev_priv->gart_vm_start); 1259152909Sanholt RADEON_WRITE_PCIE(RADEON_PCIE_TX_GART_BASE, dev_priv->gart_info.bus_addr); 1260148211Sanholt RADEON_WRITE_PCIE(RADEON_PCIE_TX_GART_START_LO, dev_priv->gart_vm_start); 1261148211Sanholt RADEON_WRITE_PCIE(RADEON_PCIE_TX_GART_END_LO, dev_priv->gart_vm_start 1262148211Sanholt + dev_priv->gart_size - 1); 1263148211Sanholt 1264148211Sanholt RADEON_WRITE(RADEON_MC_AGP_LOCATION, 0xffffffc0); /* ?? */ 1265148211Sanholt 1266152909Sanholt RADEON_WRITE_PCIE(RADEON_PCIE_TX_GART_CNTL, RADEON_PCIE_TX_GART_EN); 1267148211Sanholt } else { 1268152909Sanholt RADEON_WRITE_PCIE(RADEON_PCIE_TX_GART_CNTL, (tmp & ~RADEON_PCIE_TX_GART_EN) | RADEON_PCIE_TX_GART_INVALIDATE_TLB); 1269148211Sanholt } 1270148211Sanholt} 1271148211Sanholt 1272119098Sanholt/* Enable or disable PCI GART on the chip */ 1273145132Sanholtstatic void radeon_set_pcigart(drm_radeon_private_t * dev_priv, int on) 1274119098Sanholt{ 1275152909Sanholt u32 tmp; 1276119098Sanholt 1277148211Sanholt if (dev_priv->flags & CHIP_IS_PCIE) 1278148211Sanholt { 1279148211Sanholt radeon_set_pciegart(dev_priv, on); 1280148211Sanholt return; 1281148211Sanholt } 1282148211Sanholt 1283152909Sanholt tmp = RADEON_READ(RADEON_AIC_CNTL); 1284152909Sanholt 1285145132Sanholt if (on) { 1286145132Sanholt RADEON_WRITE(RADEON_AIC_CNTL, 1287145132Sanholt tmp | RADEON_PCIGART_TRANSLATE_EN); 1288119098Sanholt 1289119098Sanholt /* set PCI GART page-table base address 1290119098Sanholt */ 1291152909Sanholt RADEON_WRITE(RADEON_AIC_PT_BASE, dev_priv->gart_info.bus_addr); 1292119098Sanholt 1293119098Sanholt /* set address range for PCI address translate 1294119098Sanholt */ 1295145132Sanholt RADEON_WRITE(RADEON_AIC_LO_ADDR, dev_priv->gart_vm_start); 1296145132Sanholt RADEON_WRITE(RADEON_AIC_HI_ADDR, dev_priv->gart_vm_start 1297145132Sanholt + dev_priv->gart_size - 1); 1298119098Sanholt 1299119895Sanholt /* Turn off AGP aperture -- is this required for PCI GART? 1300119098Sanholt */ 1301145132Sanholt RADEON_WRITE(RADEON_MC_AGP_LOCATION, 0xffffffc0); /* ?? */ 1302145132Sanholt RADEON_WRITE(RADEON_AGP_COMMAND, 0); /* clear AGP_COMMAND */ 1303119098Sanholt } else { 1304145132Sanholt RADEON_WRITE(RADEON_AIC_CNTL, 1305145132Sanholt tmp & ~RADEON_PCIGART_TRANSLATE_EN); 1306119098Sanholt } 1307119098Sanholt} 1308119098Sanholt 1309145132Sanholtstatic int radeon_do_init_cp(drm_device_t * dev, drm_radeon_init_t * init) 131095584Sanholt{ 1311145132Sanholt drm_radeon_private_t *dev_priv = dev->dev_private; 1312145132Sanholt DRM_DEBUG("\n"); 131395584Sanholt 1314152909Sanholt if (init->is_pci && (dev_priv->flags & CHIP_IS_AGP)) 1315152909Sanholt { 1316152909Sanholt DRM_DEBUG("Forcing AGP card to PCI mode\n"); 1317152909Sanholt dev_priv->flags &= ~CHIP_IS_AGP; 1318152909Sanholt } 1319152909Sanholt 1320145132Sanholt if ((!(dev_priv->flags & CHIP_IS_AGP)) && !dev->sg) { 1321145132Sanholt DRM_ERROR("PCI GART memory not allocated!\n"); 132295584Sanholt radeon_do_cleanup_cp(dev); 1323112015Sanholt return DRM_ERR(EINVAL); 132495584Sanholt } 132595584Sanholt 132695584Sanholt dev_priv->usec_timeout = init->usec_timeout; 1327145132Sanholt if (dev_priv->usec_timeout < 1 || 1328145132Sanholt dev_priv->usec_timeout > RADEON_MAX_USEC_TIMEOUT) { 1329145132Sanholt DRM_DEBUG("TIMEOUT problem!\n"); 133095584Sanholt radeon_do_cleanup_cp(dev); 1331112015Sanholt return DRM_ERR(EINVAL); 133295584Sanholt } 133395584Sanholt 1334145132Sanholt switch(init->func) { 1335145132Sanholt case RADEON_INIT_R200_CP: 1336145132Sanholt dev_priv->microcode_version=UCODE_R200; 1337145132Sanholt break; 1338145132Sanholt case RADEON_INIT_R300_CP: 1339145132Sanholt dev_priv->microcode_version=UCODE_R300; 1340145132Sanholt break; 1341145132Sanholt default: 1342145132Sanholt dev_priv->microcode_version=UCODE_R100; 1343145132Sanholt break; 1344145132Sanholt } 1345145132Sanholt 1346112015Sanholt dev_priv->do_boxes = 0; 134795584Sanholt dev_priv->cp_mode = init->cp_mode; 134895584Sanholt 134995584Sanholt /* We don't support anything other than bus-mastering ring mode, 135095584Sanholt * but the ring can be in either AGP or PCI space for the ring 135195584Sanholt * read pointer. 135295584Sanholt */ 1353145132Sanholt if ((init->cp_mode != RADEON_CSQ_PRIBM_INDDIS) && 1354145132Sanholt (init->cp_mode != RADEON_CSQ_PRIBM_INDBM)) { 1355145132Sanholt DRM_DEBUG("BAD cp_mode (%x)!\n", init->cp_mode); 135695584Sanholt radeon_do_cleanup_cp(dev); 1357112015Sanholt return DRM_ERR(EINVAL); 135895584Sanholt } 135995584Sanholt 1360145132Sanholt switch (init->fb_bpp) { 136195584Sanholt case 16: 136295584Sanholt dev_priv->color_fmt = RADEON_COLOR_FORMAT_RGB565; 136395584Sanholt break; 136495584Sanholt case 32: 136595584Sanholt default: 136695584Sanholt dev_priv->color_fmt = RADEON_COLOR_FORMAT_ARGB8888; 136795584Sanholt break; 136895584Sanholt } 1369145132Sanholt dev_priv->front_offset = init->front_offset; 1370145132Sanholt dev_priv->front_pitch = init->front_pitch; 1371145132Sanholt dev_priv->back_offset = init->back_offset; 1372145132Sanholt dev_priv->back_pitch = init->back_pitch; 137395584Sanholt 1374145132Sanholt switch (init->depth_bpp) { 137595584Sanholt case 16: 137695584Sanholt dev_priv->depth_fmt = RADEON_DEPTH_FORMAT_16BIT_INT_Z; 137795584Sanholt break; 137895584Sanholt case 32: 137995584Sanholt default: 138095584Sanholt dev_priv->depth_fmt = RADEON_DEPTH_FORMAT_24BIT_INT_Z; 138195584Sanholt break; 138295584Sanholt } 1383145132Sanholt dev_priv->depth_offset = init->depth_offset; 1384145132Sanholt dev_priv->depth_pitch = init->depth_pitch; 138595584Sanholt 138695584Sanholt /* Hardware state for depth clears. Remove this if/when we no 138795584Sanholt * longer clear the depth buffer with a 3D rectangle. Hard-code 138895584Sanholt * all values to prevent unwanted 3D state from slipping through 138995584Sanholt * and screwing with the clear operation. 139095584Sanholt */ 139195584Sanholt dev_priv->depth_clear.rb3d_cntl = (RADEON_PLANE_MASK_ENABLE | 139295584Sanholt (dev_priv->color_fmt << 10) | 1393145132Sanholt (dev_priv->microcode_version == UCODE_R100 ? 1394145132Sanholt RADEON_ZBLOCK16 : 0)); 139595584Sanholt 1396145132Sanholt dev_priv->depth_clear.rb3d_zstencilcntl = 1397145132Sanholt (dev_priv->depth_fmt | 1398145132Sanholt RADEON_Z_TEST_ALWAYS | 1399145132Sanholt RADEON_STENCIL_TEST_ALWAYS | 1400145132Sanholt RADEON_STENCIL_S_FAIL_REPLACE | 1401145132Sanholt RADEON_STENCIL_ZPASS_REPLACE | 1402145132Sanholt RADEON_STENCIL_ZFAIL_REPLACE | RADEON_Z_WRITE_ENABLE); 140395584Sanholt 140495584Sanholt dev_priv->depth_clear.se_cntl = (RADEON_FFACE_CULL_CW | 140595584Sanholt RADEON_BFACE_SOLID | 140695584Sanholt RADEON_FFACE_SOLID | 140795584Sanholt RADEON_FLAT_SHADE_VTX_LAST | 140895584Sanholt RADEON_DIFFUSE_SHADE_FLAT | 140995584Sanholt RADEON_ALPHA_SHADE_FLAT | 141095584Sanholt RADEON_SPECULAR_SHADE_FLAT | 141195584Sanholt RADEON_FOG_SHADE_FLAT | 141295584Sanholt RADEON_VTX_PIX_CENTER_OGL | 141395584Sanholt RADEON_ROUND_MODE_TRUNC | 141495584Sanholt RADEON_ROUND_PREC_8TH_PIX); 141595584Sanholt 1416112015Sanholt DRM_GETSAREA(); 1417113995Sanholt 1418113995Sanholt dev_priv->ring_offset = init->ring_offset; 1419113995Sanholt dev_priv->ring_rptr_offset = init->ring_rptr_offset; 1420113995Sanholt dev_priv->buffers_offset = init->buffers_offset; 1421119895Sanholt dev_priv->gart_textures_offset = init->gart_textures_offset; 1422145132Sanholt 1423145132Sanholt if (!dev_priv->sarea) { 142495584Sanholt DRM_ERROR("could not find sarea!\n"); 142595584Sanholt radeon_do_cleanup_cp(dev); 1426112015Sanholt return DRM_ERR(EINVAL); 142795584Sanholt } 142895584Sanholt 1429145132Sanholt dev_priv->cp_ring = drm_core_findmap(dev, init->ring_offset); 1430145132Sanholt if (!dev_priv->cp_ring) { 143195584Sanholt DRM_ERROR("could not find cp ring region!\n"); 143295584Sanholt radeon_do_cleanup_cp(dev); 1433112015Sanholt return DRM_ERR(EINVAL); 143495584Sanholt } 1435145132Sanholt dev_priv->ring_rptr = drm_core_findmap(dev, init->ring_rptr_offset); 1436145132Sanholt if (!dev_priv->ring_rptr) { 143795584Sanholt DRM_ERROR("could not find ring read pointer!\n"); 143895584Sanholt radeon_do_cleanup_cp(dev); 1439112015Sanholt return DRM_ERR(EINVAL); 144095584Sanholt } 1441152909Sanholt dev->agp_buffer_token = init->buffers_offset; 1442145132Sanholt dev->agp_buffer_map = drm_core_findmap(dev, init->buffers_offset); 1443145132Sanholt if (!dev->agp_buffer_map) { 144495584Sanholt DRM_ERROR("could not find dma buffer region!\n"); 144595584Sanholt radeon_do_cleanup_cp(dev); 1446112015Sanholt return DRM_ERR(EINVAL); 144795584Sanholt } 144895584Sanholt 1449145132Sanholt if (init->gart_textures_offset) { 1450145132Sanholt dev_priv->gart_textures = 1451145132Sanholt drm_core_findmap(dev, init->gart_textures_offset); 1452145132Sanholt if (!dev_priv->gart_textures) { 1453119895Sanholt DRM_ERROR("could not find GART texture region!\n"); 145495584Sanholt radeon_do_cleanup_cp(dev); 1455112015Sanholt return DRM_ERR(EINVAL); 145695584Sanholt } 145795584Sanholt } 145895584Sanholt 145995584Sanholt dev_priv->sarea_priv = 1460145132Sanholt (drm_radeon_sarea_t *) ((u8 *) dev_priv->sarea->handle + 1461145132Sanholt init->sarea_priv_offset); 146295584Sanholt 1463145132Sanholt#if __OS_HAS_AGP 1464145132Sanholt if (dev_priv->flags & CHIP_IS_AGP) { 1465145132Sanholt drm_core_ioremap(dev_priv->cp_ring, dev); 1466145132Sanholt drm_core_ioremap(dev_priv->ring_rptr, dev); 1467145132Sanholt drm_core_ioremap(dev->agp_buffer_map, dev); 1468145132Sanholt if (!dev_priv->cp_ring->handle || 1469145132Sanholt !dev_priv->ring_rptr->handle || 1470145132Sanholt !dev->agp_buffer_map->handle) { 147195584Sanholt DRM_ERROR("could not find ioremap agp regions!\n"); 147295584Sanholt radeon_do_cleanup_cp(dev); 1473112015Sanholt return DRM_ERR(EINVAL); 147495584Sanholt } 1475119098Sanholt } else 1476119098Sanholt#endif 1477119098Sanholt { 1478145132Sanholt dev_priv->cp_ring->handle = (void *)dev_priv->cp_ring->offset; 147995584Sanholt dev_priv->ring_rptr->handle = 1480145132Sanholt (void *)dev_priv->ring_rptr->offset; 1481145132Sanholt dev->agp_buffer_map->handle = 1482145132Sanholt (void *)dev->agp_buffer_map->offset; 148395584Sanholt 1484145132Sanholt DRM_DEBUG("dev_priv->cp_ring->handle %p\n", 1485145132Sanholt dev_priv->cp_ring->handle); 1486145132Sanholt DRM_DEBUG("dev_priv->ring_rptr->handle %p\n", 1487145132Sanholt dev_priv->ring_rptr->handle); 1488145132Sanholt DRM_DEBUG("dev->agp_buffer_map->handle %p\n", 1489145132Sanholt dev->agp_buffer_map->handle); 149095584Sanholt } 149195584Sanholt 1492145132Sanholt dev_priv->fb_location = (RADEON_READ(RADEON_MC_FB_LOCATION) 1493145132Sanholt & 0xffff) << 16; 149495584Sanholt 1495145132Sanholt dev_priv->front_pitch_offset = (((dev_priv->front_pitch / 64) << 22) | 1496145132Sanholt ((dev_priv->front_offset 1497145132Sanholt + dev_priv->fb_location) >> 10)); 1498122580Sanholt 1499145132Sanholt dev_priv->back_pitch_offset = (((dev_priv->back_pitch / 64) << 22) | 1500145132Sanholt ((dev_priv->back_offset 1501145132Sanholt + dev_priv->fb_location) >> 10)); 1502122580Sanholt 1503145132Sanholt dev_priv->depth_pitch_offset = (((dev_priv->depth_pitch / 64) << 22) | 1504145132Sanholt ((dev_priv->depth_offset 1505145132Sanholt + dev_priv->fb_location) >> 10)); 1506122580Sanholt 1507119895Sanholt dev_priv->gart_size = init->gart_size; 1508122580Sanholt dev_priv->gart_vm_start = dev_priv->fb_location 1509145132Sanholt + RADEON_READ(RADEON_CONFIG_APER_SIZE); 1510122580Sanholt 1511145132Sanholt#if __OS_HAS_AGP 1512145132Sanholt if (dev_priv->flags & CHIP_IS_AGP) 1513145132Sanholt dev_priv->gart_buffers_offset = (dev->agp_buffer_map->offset 1514145132Sanholt - dev->agp->base 1515145132Sanholt + dev_priv->gart_vm_start); 151695584Sanholt else 151795584Sanholt#endif 1518145132Sanholt dev_priv->gart_buffers_offset = (dev->agp_buffer_map->offset 1519152909Sanholt - (unsigned long)dev->sg->virtual 1520145132Sanholt + dev_priv->gart_vm_start); 152195584Sanholt 1522145132Sanholt DRM_DEBUG("dev_priv->gart_size %d\n", dev_priv->gart_size); 1523145132Sanholt DRM_DEBUG("dev_priv->gart_vm_start 0x%x\n", dev_priv->gart_vm_start); 1524145132Sanholt DRM_DEBUG("dev_priv->gart_buffers_offset 0x%lx\n", 1525145132Sanholt dev_priv->gart_buffers_offset); 152695584Sanholt 1527145132Sanholt dev_priv->ring.start = (u32 *) dev_priv->cp_ring->handle; 1528145132Sanholt dev_priv->ring.end = ((u32 *) dev_priv->cp_ring->handle 152995584Sanholt + init->ring_size / sizeof(u32)); 153095584Sanholt dev_priv->ring.size = init->ring_size; 1531145132Sanholt dev_priv->ring.size_l2qw = drm_order(init->ring_size / 8); 153295584Sanholt 1533145132Sanholt dev_priv->ring.tail_mask = (dev_priv->ring.size / sizeof(u32)) - 1; 153495584Sanholt 153595584Sanholt dev_priv->ring.high_mark = RADEON_RING_HIGH_MARK; 153695584Sanholt 1537145132Sanholt#if __OS_HAS_AGP 1538145132Sanholt if (dev_priv->flags & CHIP_IS_AGP) { 1539119098Sanholt /* Turn off PCI GART */ 1540145132Sanholt radeon_set_pcigart(dev_priv, 0); 1541119098Sanholt } else 1542119098Sanholt#endif 1543119098Sanholt { 1544152909Sanholt /* if we have an offset set from userspace */ 1545152909Sanholt if (dev_priv->pcigart_offset) { 1546152909Sanholt dev_priv->gart_info.bus_addr = dev_priv->pcigart_offset + dev_priv->fb_location; 1547152909Sanholt dev_priv->gart_info.mapping.offset = dev_priv->gart_info.bus_addr; 1548152909Sanholt dev_priv->gart_info.mapping.size = RADEON_PCIGART_TABLE_SIZE; 1549152909Sanholt drm_core_ioremap(&dev_priv->gart_info.mapping, dev); 1550152909Sanholt dev_priv->gart_info.addr = dev_priv->gart_info.mapping.handle; 1551152909Sanholt 1552152909Sanholt dev_priv->gart_info.is_pcie = !!(dev_priv->flags & CHIP_IS_PCIE); 1553152909Sanholt dev_priv->gart_info.gart_table_location = DRM_ATI_GART_FB; 1554152909Sanholt 1555152909Sanholt DRM_DEBUG("Setting phys_pci_gart to %p %08lX\n", dev_priv->gart_info.addr, dev_priv->pcigart_offset); 1556152909Sanholt } 1557152909Sanholt else { 1558152909Sanholt dev_priv->gart_info.gart_table_location = DRM_ATI_GART_MAIN; 1559152909Sanholt dev_priv->gart_info.addr = NULL; 1560152909Sanholt dev_priv->gart_info.bus_addr = 0; 1561152909Sanholt if (dev_priv->flags & CHIP_IS_PCIE) 1562152909Sanholt { 1563152909Sanholt DRM_ERROR("Cannot use PCI Express without GART in FB memory\n"); 1564152909Sanholt radeon_do_cleanup_cp(dev); 1565152909Sanholt return DRM_ERR(EINVAL); 1566152909Sanholt } 1567152909Sanholt } 1568152909Sanholt 1569152909Sanholt if (!drm_ati_pcigart_init(dev, &dev_priv->gart_info)) { 1570145132Sanholt DRM_ERROR("failed to init PCI GART!\n"); 157195584Sanholt radeon_do_cleanup_cp(dev); 1572112015Sanholt return DRM_ERR(ENOMEM); 157395584Sanholt } 157495584Sanholt 1575119098Sanholt /* Turn on PCI GART */ 1576145132Sanholt radeon_set_pcigart(dev_priv, 1); 157795584Sanholt } 157895584Sanholt 1579145132Sanholt radeon_cp_load_microcode(dev_priv); 1580145132Sanholt radeon_cp_init_ring_buffer(dev, dev_priv); 158195584Sanholt 158295584Sanholt dev_priv->last_buf = 0; 158395584Sanholt 1584145132Sanholt radeon_do_engine_reset(dev); 158595584Sanholt 158695584Sanholt return 0; 158795584Sanholt} 158895584Sanholt 1589145132Sanholtstatic int radeon_do_cleanup_cp(drm_device_t * dev) 159095584Sanholt{ 1591145132Sanholt drm_radeon_private_t *dev_priv = dev->dev_private; 1592145132Sanholt DRM_DEBUG("\n"); 159395584Sanholt 1594119098Sanholt /* Make sure interrupts are disabled here because the uninstall ioctl 1595119098Sanholt * may not have been called from userspace and after dev_private 1596119098Sanholt * is freed, it's too late. 1597119098Sanholt */ 1598145132Sanholt if (dev->irq_enabled) 1599145132Sanholt drm_irq_uninstall(dev); 1600119098Sanholt 1601145132Sanholt#if __OS_HAS_AGP 1602145132Sanholt if (dev_priv->flags & CHIP_IS_AGP) { 1603145132Sanholt if (dev_priv->cp_ring != NULL) { 1604145132Sanholt drm_core_ioremapfree(dev_priv->cp_ring, dev); 1605145132Sanholt dev_priv->cp_ring = NULL; 1606145132Sanholt } 1607145132Sanholt if (dev_priv->ring_rptr != NULL) { 1608145132Sanholt drm_core_ioremapfree(dev_priv->ring_rptr, dev); 1609145132Sanholt dev_priv->ring_rptr = NULL; 1610145132Sanholt } 1611145132Sanholt if (dev->agp_buffer_map != NULL) { 1612145132Sanholt drm_core_ioremapfree(dev->agp_buffer_map, dev); 1613145132Sanholt dev->agp_buffer_map = NULL; 1614145132Sanholt } 1615145132Sanholt } else 1616119098Sanholt#endif 1617145132Sanholt { 1618152909Sanholt 1619152909Sanholt if (dev_priv->gart_info.bus_addr) { 1620152909Sanholt /* Turn off PCI GART */ 1621152909Sanholt radeon_set_pcigart(dev_priv, 0); 1622152909Sanholt if (!drm_ati_pcigart_cleanup(dev, &dev_priv->gart_info)) 1623152909Sanholt DRM_ERROR("failed to cleanup PCI GART!\n"); 1624152909Sanholt } 1625152909Sanholt 1626152909Sanholt if (dev_priv->gart_info.gart_table_location == DRM_ATI_GART_FB) 1627152909Sanholt { 1628152909Sanholt drm_core_ioremapfree(&dev_priv->gart_info.mapping, dev); 1629152909Sanholt dev_priv->gart_info.addr = 0; 1630152909Sanholt } 163195584Sanholt } 1632145132Sanholt /* only clear to the start of flags */ 1633145132Sanholt memset(dev_priv, 0, offsetof(drm_radeon_private_t, flags)); 163495584Sanholt 163595584Sanholt return 0; 163695584Sanholt} 163795584Sanholt 1638145132Sanholt/* This code will reinit the Radeon CP hardware after a resume from disc. 1639145132Sanholt * AFAIK, it would be very difficult to pickle the state at suspend time, so 1640119098Sanholt * here we make sure that all Radeon hardware initialisation is re-done without 1641119098Sanholt * affecting running applications. 1642119098Sanholt * 1643119098Sanholt * Charl P. Botha <http://cpbotha.net> 1644119098Sanholt */ 1645145132Sanholtstatic int radeon_do_resume_cp(drm_device_t * dev) 1646119098Sanholt{ 1647119098Sanholt drm_radeon_private_t *dev_priv = dev->dev_private; 1648119098Sanholt 1649145132Sanholt if (!dev_priv) { 1650145132Sanholt DRM_ERROR("Called with no initialization\n"); 1651145132Sanholt return DRM_ERR(EINVAL); 1652119098Sanholt } 1653119098Sanholt 1654119098Sanholt DRM_DEBUG("Starting radeon_do_resume_cp()\n"); 1655119098Sanholt 1656145132Sanholt#if __OS_HAS_AGP 1657145132Sanholt if (dev_priv->flags & CHIP_IS_AGP) { 1658119098Sanholt /* Turn off PCI GART */ 1659145132Sanholt radeon_set_pcigart(dev_priv, 0); 1660119098Sanholt } else 1661119098Sanholt#endif 1662119098Sanholt { 1663119098Sanholt /* Turn on PCI GART */ 1664145132Sanholt radeon_set_pcigart(dev_priv, 1); 1665119098Sanholt } 1666119098Sanholt 1667145132Sanholt radeon_cp_load_microcode(dev_priv); 1668145132Sanholt radeon_cp_init_ring_buffer(dev, dev_priv); 1669119098Sanholt 1670145132Sanholt radeon_do_engine_reset(dev); 1671119098Sanholt 1672119098Sanholt DRM_DEBUG("radeon_do_resume_cp() complete\n"); 1673119098Sanholt 1674119098Sanholt return 0; 1675119098Sanholt} 1676119098Sanholt 1677145132Sanholtint radeon_cp_init(DRM_IOCTL_ARGS) 167895584Sanholt{ 1679112015Sanholt DRM_DEVICE; 168095584Sanholt drm_radeon_init_t init; 168195584Sanholt 1682145132Sanholt LOCK_TEST_WITH_RETURN(dev, filp); 1683119098Sanholt 1684145132Sanholt DRM_COPY_FROM_USER_IOCTL(init, (drm_radeon_init_t __user *) data, 1685145132Sanholt sizeof(init)); 168695584Sanholt 1687148211Sanholt if(init.func == RADEON_INIT_R300_CP) 1688148211Sanholt r300_init_reg_flags(); 1689148211Sanholt 1690145132Sanholt switch (init.func) { 169195584Sanholt case RADEON_INIT_CP: 1692112015Sanholt case RADEON_INIT_R200_CP: 1693145132Sanholt case RADEON_INIT_R300_CP: 1694145132Sanholt return radeon_do_init_cp(dev, &init); 169595584Sanholt case RADEON_CLEANUP_CP: 1696145132Sanholt return radeon_do_cleanup_cp(dev); 169795584Sanholt } 169895584Sanholt 1699112015Sanholt return DRM_ERR(EINVAL); 170095584Sanholt} 170195584Sanholt 1702145132Sanholtint radeon_cp_start(DRM_IOCTL_ARGS) 170395584Sanholt{ 1704112015Sanholt DRM_DEVICE; 170595584Sanholt drm_radeon_private_t *dev_priv = dev->dev_private; 1706145132Sanholt DRM_DEBUG("\n"); 170795584Sanholt 1708145132Sanholt LOCK_TEST_WITH_RETURN(dev, filp); 170995584Sanholt 1710145132Sanholt if (dev_priv->cp_running) { 1711145132Sanholt DRM_DEBUG("%s while CP running\n", __FUNCTION__); 171295584Sanholt return 0; 171395584Sanholt } 1714145132Sanholt if (dev_priv->cp_mode == RADEON_CSQ_PRIDIS_INDDIS) { 1715145132Sanholt DRM_DEBUG("%s called with bogus CP mode (%d)\n", 1716145132Sanholt __FUNCTION__, dev_priv->cp_mode); 171795584Sanholt return 0; 171895584Sanholt } 171995584Sanholt 1720145132Sanholt radeon_do_cp_start(dev_priv); 172195584Sanholt 172295584Sanholt return 0; 172395584Sanholt} 172495584Sanholt 172595584Sanholt/* Stop the CP. The engine must have been idled before calling this 172695584Sanholt * routine. 172795584Sanholt */ 1728145132Sanholtint radeon_cp_stop(DRM_IOCTL_ARGS) 172995584Sanholt{ 1730112015Sanholt DRM_DEVICE; 173195584Sanholt drm_radeon_private_t *dev_priv = dev->dev_private; 173295584Sanholt drm_radeon_cp_stop_t stop; 173395584Sanholt int ret; 1734145132Sanholt DRM_DEBUG("\n"); 173595584Sanholt 1736145132Sanholt LOCK_TEST_WITH_RETURN(dev, filp); 173795584Sanholt 1738145132Sanholt DRM_COPY_FROM_USER_IOCTL(stop, (drm_radeon_cp_stop_t __user *) data, 1739145132Sanholt sizeof(stop)); 174095584Sanholt 1741112015Sanholt if (!dev_priv->cp_running) 1742112015Sanholt return 0; 1743112015Sanholt 174495584Sanholt /* Flush any pending CP commands. This ensures any outstanding 174595584Sanholt * commands are exectuted by the engine before we turn it off. 174695584Sanholt */ 1747145132Sanholt if (stop.flush) { 1748145132Sanholt radeon_do_cp_flush(dev_priv); 174995584Sanholt } 175095584Sanholt 175195584Sanholt /* If we fail to make the engine go idle, we return an error 175295584Sanholt * code so that the DRM ioctl wrapper can try again. 175395584Sanholt */ 1754145132Sanholt if (stop.idle) { 1755145132Sanholt ret = radeon_do_cp_idle(dev_priv); 1756145132Sanholt if (ret) 1757145132Sanholt return ret; 175895584Sanholt } 175995584Sanholt 176095584Sanholt /* Finally, we can turn off the CP. If the engine isn't idle, 176195584Sanholt * we will get some dropped triangles as they won't be fully 176295584Sanholt * rendered before the CP is shut down. 176395584Sanholt */ 1764145132Sanholt radeon_do_cp_stop(dev_priv); 176595584Sanholt 176695584Sanholt /* Reset the engine */ 1767145132Sanholt radeon_do_engine_reset(dev); 176895584Sanholt 176995584Sanholt return 0; 177095584Sanholt} 177195584Sanholt 1772145132Sanholtvoid radeon_do_release(drm_device_t * dev) 1773112015Sanholt{ 1774112015Sanholt drm_radeon_private_t *dev_priv = dev->dev_private; 1775145132Sanholt int i, ret; 1776112015Sanholt 1777112015Sanholt if (dev_priv) { 1778145132Sanholt 1779112015Sanholt if (dev_priv->cp_running) { 1780112015Sanholt /* Stop the cp */ 1781145132Sanholt while ((ret = radeon_do_cp_idle(dev_priv)) != 0) { 1782112015Sanholt DRM_DEBUG("radeon_do_cp_idle %d\n", ret); 1783112015Sanholt#ifdef __linux__ 1784112015Sanholt schedule(); 1785112015Sanholt#else 1786152909Sanholt#if defined(__FreeBSD__) && __FreeBSD_version > 500000 1787152909Sanholt msleep(&ret, &dev->dev_lock, PZERO, "rdnrel", 1788152909Sanholt 1); 1789152909Sanholt#else 1790112015Sanholt tsleep(&ret, PZERO, "rdnrel", 1); 1791112015Sanholt#endif 1792152909Sanholt#endif 1793112015Sanholt } 1794145132Sanholt radeon_do_cp_stop(dev_priv); 1795145132Sanholt radeon_do_engine_reset(dev); 1796112015Sanholt } 1797112015Sanholt 1798112015Sanholt /* Disable *all* interrupts */ 1799145132Sanholt if (dev_priv->mmio) /* remove this after permanent addmaps */ 1800145132Sanholt RADEON_WRITE(RADEON_GEN_INT_CNTL, 0); 1801112015Sanholt 1802145132Sanholt if (dev_priv->mmio) {/* remove all surfaces */ 1803145132Sanholt for (i = 0; i < RADEON_MAX_SURFACES; i++) { 1804145132Sanholt RADEON_WRITE(RADEON_SURFACE0_INFO + 16*i, 0); 1805145132Sanholt RADEON_WRITE(RADEON_SURFACE0_LOWER_BOUND + 16*i, 0); 1806145132Sanholt RADEON_WRITE(RADEON_SURFACE0_UPPER_BOUND + 16*i, 0); 1807145132Sanholt } 1808145132Sanholt } 1809145132Sanholt 1810112015Sanholt /* Free memory heap structures */ 1811145132Sanholt radeon_mem_takedown(&(dev_priv->gart_heap)); 1812145132Sanholt radeon_mem_takedown(&(dev_priv->fb_heap)); 1813112015Sanholt 1814112015Sanholt /* deallocate kernel resources */ 1815145132Sanholt radeon_do_cleanup_cp(dev); 1816112015Sanholt } 1817112015Sanholt} 1818112015Sanholt 181995584Sanholt/* Just reset the CP ring. Called as part of an X Server engine reset. 182095584Sanholt */ 1821145132Sanholtint radeon_cp_reset(DRM_IOCTL_ARGS) 182295584Sanholt{ 1823112015Sanholt DRM_DEVICE; 182495584Sanholt drm_radeon_private_t *dev_priv = dev->dev_private; 1825145132Sanholt DRM_DEBUG("\n"); 182695584Sanholt 1827145132Sanholt LOCK_TEST_WITH_RETURN(dev, filp); 182895584Sanholt 1829145132Sanholt if (!dev_priv) { 1830145132Sanholt DRM_DEBUG("%s called before init done\n", __FUNCTION__); 1831112015Sanholt return DRM_ERR(EINVAL); 183295584Sanholt } 183395584Sanholt 1834145132Sanholt radeon_do_cp_reset(dev_priv); 183595584Sanholt 183695584Sanholt /* The CP is no longer running after an engine reset */ 183795584Sanholt dev_priv->cp_running = 0; 183895584Sanholt 183995584Sanholt return 0; 184095584Sanholt} 184195584Sanholt 1842145132Sanholtint radeon_cp_idle(DRM_IOCTL_ARGS) 184395584Sanholt{ 1844112015Sanholt DRM_DEVICE; 184595584Sanholt drm_radeon_private_t *dev_priv = dev->dev_private; 1846145132Sanholt DRM_DEBUG("\n"); 184795584Sanholt 1848145132Sanholt LOCK_TEST_WITH_RETURN(dev, filp); 184995584Sanholt 1850145132Sanholt return radeon_do_cp_idle(dev_priv); 185195584Sanholt} 185295584Sanholt 1853119098Sanholt/* Added by Charl P. Botha to call radeon_do_resume_cp(). 1854119098Sanholt */ 1855145132Sanholtint radeon_cp_resume(DRM_IOCTL_ARGS) 1856119098Sanholt{ 1857119098Sanholt DRM_DEVICE; 1858119098Sanholt 1859119098Sanholt return radeon_do_resume_cp(dev); 1860119098Sanholt} 1861119098Sanholt 1862145132Sanholtint radeon_engine_reset(DRM_IOCTL_ARGS) 186395584Sanholt{ 1864112015Sanholt DRM_DEVICE; 1865145132Sanholt DRM_DEBUG("\n"); 186695584Sanholt 1867145132Sanholt LOCK_TEST_WITH_RETURN(dev, filp); 186895584Sanholt 1869145132Sanholt return radeon_do_engine_reset(dev); 187095584Sanholt} 187195584Sanholt 187295584Sanholt/* ================================================================ 187395584Sanholt * Fullscreen mode 187495584Sanholt */ 187595584Sanholt 1876112015Sanholt/* KW: Deprecated to say the least: 1877112015Sanholt */ 1878145132Sanholtint radeon_fullscreen(DRM_IOCTL_ARGS) 187995584Sanholt{ 188095584Sanholt return 0; 188195584Sanholt} 188295584Sanholt 188395584Sanholt/* ================================================================ 188495584Sanholt * Freelist management 188595584Sanholt */ 188695584Sanholt 1887112015Sanholt/* Original comment: FIXME: ROTATE_BUFS is a hack to cycle through 1888112015Sanholt * bufs until freelist code is used. Note this hides a problem with 1889112015Sanholt * the scratch register * (used to keep track of last buffer 1890112015Sanholt * completed) being written to before * the last buffer has actually 1891145132Sanholt * completed rendering. 1892112015Sanholt * 1893112015Sanholt * KW: It's also a good way to find free buffers quickly. 1894112015Sanholt * 1895112015Sanholt * KW: Ideally this loop wouldn't exist, and freelist_get wouldn't 1896112015Sanholt * sleep. However, bugs in older versions of radeon_accel.c mean that 1897112015Sanholt * we essentially have to do this, else old clients will break. 1898145132Sanholt * 1899112015Sanholt * However, it does leave open a potential deadlock where all the 1900112015Sanholt * buffers are held by other clients, which can't release them because 1901145132Sanholt * they can't get the lock. 1902112015Sanholt */ 1903112015Sanholt 1904145132Sanholtdrm_buf_t *radeon_freelist_get(drm_device_t * dev) 190595584Sanholt{ 190695584Sanholt drm_device_dma_t *dma = dev->dma; 190795584Sanholt drm_radeon_private_t *dev_priv = dev->dev_private; 1908112015Sanholt drm_radeon_buf_priv_t *buf_priv; 190995584Sanholt drm_buf_t *buf; 1910112015Sanholt int i, t; 1911112015Sanholt int start; 191295584Sanholt 1913145132Sanholt if (++dev_priv->last_buf >= dma->buf_count) 1914112015Sanholt dev_priv->last_buf = 0; 191595584Sanholt 1916112015Sanholt start = dev_priv->last_buf; 191795584Sanholt 1918145132Sanholt for (t = 0; t < dev_priv->usec_timeout; t++) { 1919145132Sanholt u32 done_age = GET_SCRATCH(1); 1920145132Sanholt DRM_DEBUG("done_age = %d\n", done_age); 1921145132Sanholt for (i = start; i < dma->buf_count; i++) { 1922112015Sanholt buf = dma->buflist[i]; 1923112015Sanholt buf_priv = buf->dev_private; 1924145132Sanholt if (buf->filp == 0 || (buf->pending && 1925145132Sanholt buf_priv->age <= done_age)) { 1926112015Sanholt dev_priv->stats.requested_bufs++; 1927112015Sanholt buf->pending = 0; 1928112015Sanholt return buf; 1929112015Sanholt } 1930112015Sanholt start = 0; 1931112015Sanholt } 193295584Sanholt 1933112015Sanholt if (t) { 1934145132Sanholt DRM_UDELAY(1); 1935112015Sanholt dev_priv->stats.freelist_loops++; 1936112015Sanholt } 193795584Sanholt } 193895584Sanholt 1939145132Sanholt DRM_DEBUG("returning NULL!\n"); 1940112015Sanholt return NULL; 194195584Sanholt} 1942145132Sanholt 1943112015Sanholt#if 0 1944145132Sanholtdrm_buf_t *radeon_freelist_get(drm_device_t * dev) 194595584Sanholt{ 194695584Sanholt drm_device_dma_t *dma = dev->dma; 194795584Sanholt drm_radeon_private_t *dev_priv = dev->dev_private; 194895584Sanholt drm_radeon_buf_priv_t *buf_priv; 194995584Sanholt drm_buf_t *buf; 195095584Sanholt int i, t; 195195584Sanholt int start; 1952112015Sanholt u32 done_age = DRM_READ32(dev_priv->ring_rptr, RADEON_SCRATCHOFF(1)); 195395584Sanholt 1954145132Sanholt if (++dev_priv->last_buf >= dma->buf_count) 195595584Sanholt dev_priv->last_buf = 0; 1956112015Sanholt 195795584Sanholt start = dev_priv->last_buf; 1958112015Sanholt dev_priv->stats.freelist_loops++; 1959145132Sanholt 1960145132Sanholt for (t = 0; t < 2; t++) { 1961145132Sanholt for (i = start; i < dma->buf_count; i++) { 196295584Sanholt buf = dma->buflist[i]; 196395584Sanholt buf_priv = buf->dev_private; 1964145132Sanholt if (buf->filp == 0 || (buf->pending && 1965145132Sanholt buf_priv->age <= done_age)) { 1966112015Sanholt dev_priv->stats.requested_bufs++; 196795584Sanholt buf->pending = 0; 196895584Sanholt return buf; 196995584Sanholt } 197095584Sanholt } 1971112015Sanholt start = 0; 197295584Sanholt } 197395584Sanholt 197495584Sanholt return NULL; 197595584Sanholt} 1976112015Sanholt#endif 197795584Sanholt 1978145132Sanholtvoid radeon_freelist_reset(drm_device_t * dev) 197995584Sanholt{ 198095584Sanholt drm_device_dma_t *dma = dev->dma; 198195584Sanholt drm_radeon_private_t *dev_priv = dev->dev_private; 198295584Sanholt int i; 198395584Sanholt 198495584Sanholt dev_priv->last_buf = 0; 1985145132Sanholt for (i = 0; i < dma->buf_count; i++) { 198695584Sanholt drm_buf_t *buf = dma->buflist[i]; 198795584Sanholt drm_radeon_buf_priv_t *buf_priv = buf->dev_private; 198895584Sanholt buf_priv->age = 0; 198995584Sanholt } 199095584Sanholt} 199195584Sanholt 199295584Sanholt/* ================================================================ 199395584Sanholt * CP command submission 199495584Sanholt */ 199595584Sanholt 1996145132Sanholtint radeon_wait_ring(drm_radeon_private_t * dev_priv, int n) 199795584Sanholt{ 199895584Sanholt drm_radeon_ring_buffer_t *ring = &dev_priv->ring; 199995584Sanholt int i; 2000145132Sanholt u32 last_head = GET_RING_HEAD(dev_priv); 200195584Sanholt 2002145132Sanholt for (i = 0; i < dev_priv->usec_timeout; i++) { 2003145132Sanholt u32 head = GET_RING_HEAD(dev_priv); 2004112015Sanholt 2005112015Sanholt ring->space = (head - ring->tail) * sizeof(u32); 2006145132Sanholt if (ring->space <= 0) 2007112015Sanholt ring->space += ring->size; 2008145132Sanholt if (ring->space > n) 200995584Sanholt return 0; 2010145132Sanholt 2011112015Sanholt dev_priv->stats.boxes |= RADEON_BOX_WAIT_IDLE; 2012112015Sanholt 2013112015Sanholt if (head != last_head) 2014112015Sanholt i = 0; 2015112015Sanholt last_head = head; 2016112015Sanholt 2017145132Sanholt DRM_UDELAY(1); 201895584Sanholt } 201995584Sanholt 202095584Sanholt /* FIXME: This return value is ignored in the BEGIN_RING macro! */ 202195584Sanholt#if RADEON_FIFO_DEBUG 2022145132Sanholt radeon_status(dev_priv); 2023145132Sanholt DRM_ERROR("failed!\n"); 202495584Sanholt#endif 2025112015Sanholt return DRM_ERR(EBUSY); 202695584Sanholt} 202795584Sanholt 2028145132Sanholtstatic int radeon_cp_get_buffers(DRMFILE filp, drm_device_t * dev, 2029145132Sanholt drm_dma_t * d) 203095584Sanholt{ 203195584Sanholt int i; 203295584Sanholt drm_buf_t *buf; 203395584Sanholt 2034145132Sanholt for (i = d->granted_count; i < d->request_count; i++) { 2035145132Sanholt buf = radeon_freelist_get(dev); 2036145132Sanholt if (!buf) 2037145132Sanholt return DRM_ERR(EBUSY); /* NOTE: broken client */ 203895584Sanholt 2039113995Sanholt buf->filp = filp; 204095584Sanholt 2041145132Sanholt if (DRM_COPY_TO_USER(&d->request_indices[i], &buf->idx, 2042145132Sanholt sizeof(buf->idx))) 2043112015Sanholt return DRM_ERR(EFAULT); 2044145132Sanholt if (DRM_COPY_TO_USER(&d->request_sizes[i], &buf->total, 2045145132Sanholt sizeof(buf->total))) 2046112015Sanholt return DRM_ERR(EFAULT); 204795584Sanholt 204895584Sanholt d->granted_count++; 204995584Sanholt } 205095584Sanholt return 0; 205195584Sanholt} 205295584Sanholt 2053145132Sanholtint radeon_cp_buffers(DRM_IOCTL_ARGS) 205495584Sanholt{ 2055112015Sanholt DRM_DEVICE; 205695584Sanholt drm_device_dma_t *dma = dev->dma; 205795584Sanholt int ret = 0; 2058145132Sanholt drm_dma_t __user *argp = (void __user *)data; 205995584Sanholt drm_dma_t d; 206095584Sanholt 2061145132Sanholt LOCK_TEST_WITH_RETURN(dev, filp); 206295584Sanholt 2063145132Sanholt DRM_COPY_FROM_USER_IOCTL(d, argp, sizeof(d)); 206495584Sanholt 206595584Sanholt /* Please don't send us buffers. 206695584Sanholt */ 2067145132Sanholt if (d.send_count != 0) { 2068145132Sanholt DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n", 2069145132Sanholt DRM_CURRENTPID, d.send_count); 2070112015Sanholt return DRM_ERR(EINVAL); 207195584Sanholt } 207295584Sanholt 207395584Sanholt /* We'll send you buffers. 207495584Sanholt */ 2075145132Sanholt if (d.request_count < 0 || d.request_count > dma->buf_count) { 2076145132Sanholt DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n", 2077145132Sanholt DRM_CURRENTPID, d.request_count, dma->buf_count); 2078112015Sanholt return DRM_ERR(EINVAL); 207995584Sanholt } 208095584Sanholt 208195584Sanholt d.granted_count = 0; 208295584Sanholt 2083145132Sanholt if (d.request_count) { 2084145132Sanholt ret = radeon_cp_get_buffers(filp, dev, &d); 208595584Sanholt } 208695584Sanholt 2087145132Sanholt DRM_COPY_TO_USER_IOCTL(argp, d, sizeof(d)); 208895584Sanholt 208995584Sanholt return ret; 209095584Sanholt} 2091145132Sanholt 2092152909Sanholtint radeon_driver_load(struct drm_device *dev, unsigned long flags) 2093145132Sanholt{ 2094145132Sanholt drm_radeon_private_t *dev_priv; 2095145132Sanholt int ret = 0; 2096145132Sanholt 2097145132Sanholt dev_priv = drm_alloc(sizeof(drm_radeon_private_t), DRM_MEM_DRIVER); 2098145132Sanholt if (dev_priv == NULL) 2099145132Sanholt return DRM_ERR(ENOMEM); 2100145132Sanholt 2101145132Sanholt memset(dev_priv, 0, sizeof(drm_radeon_private_t)); 2102145132Sanholt dev->dev_private = (void *)dev_priv; 2103145132Sanholt dev_priv->flags = flags; 2104145132Sanholt 2105145132Sanholt switch (flags & CHIP_FAMILY_MASK) { 2106145132Sanholt case CHIP_R100: 2107145132Sanholt case CHIP_RV200: 2108145132Sanholt case CHIP_R200: 2109145132Sanholt case CHIP_R300: 2110148211Sanholt case CHIP_R420: 2111145132Sanholt dev_priv->flags |= CHIP_HAS_HIERZ; 2112145132Sanholt break; 2113145132Sanholt default: 2114145132Sanholt /* all other chips have no hierarchical z buffer */ 2115145132Sanholt break; 2116145132Sanholt } 2117145132Sanholt 2118145132Sanholt if (drm_device_is_agp(dev)) 2119145132Sanholt dev_priv->flags |= CHIP_IS_AGP; 2120145132Sanholt 2121148211Sanholt if (drm_device_is_pcie(dev)) 2122148211Sanholt dev_priv->flags |= CHIP_IS_PCIE; 2123148211Sanholt 2124145132Sanholt DRM_DEBUG("%s card detected\n", 2125148211Sanholt ((dev_priv->flags & CHIP_IS_AGP) ? "AGP" : (((dev_priv->flags & CHIP_IS_PCIE) ? "PCIE" : "PCI")))); 2126145132Sanholt 2127145132Sanholt return ret; 2128145132Sanholt} 2129145132Sanholt 2130152909Sanholt/* Create mappings for registers and framebuffer so userland doesn't necessarily 2131152909Sanholt * have to find them. 2132152909Sanholt */ 2133152909Sanholtint radeon_driver_firstopen(struct drm_device *dev) 2134145132Sanholt{ 2135152909Sanholt int ret; 2136152909Sanholt drm_local_map_t *map; 2137145132Sanholt drm_radeon_private_t *dev_priv = dev->dev_private; 2138145132Sanholt 2139152909Sanholt ret = drm_addmap(dev, drm_get_resource_start(dev, 2), 2140152909Sanholt drm_get_resource_len(dev, 2), _DRM_REGISTERS, 2141152909Sanholt _DRM_READ_ONLY, &dev_priv->mmio); 2142152909Sanholt if (ret != 0) 2143152909Sanholt return ret; 2144152909Sanholt 2145152909Sanholt ret = drm_addmap(dev, drm_get_resource_start(dev, 0), 2146152909Sanholt drm_get_resource_len(dev, 0), _DRM_FRAME_BUFFER, 2147152909Sanholt _DRM_WRITE_COMBINING, &map); 2148152909Sanholt if (ret != 0) 2149152909Sanholt return ret; 2150152909Sanholt 2151152909Sanholt return 0; 2152152909Sanholt} 2153152909Sanholt 2154152909Sanholtint radeon_driver_unload(struct drm_device *dev) 2155152909Sanholt{ 2156152909Sanholt drm_radeon_private_t *dev_priv = dev->dev_private; 2157152909Sanholt 2158145132Sanholt DRM_DEBUG("\n"); 2159145132Sanholt drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER); 2160145132Sanholt 2161145132Sanholt dev->dev_private = NULL; 2162145132Sanholt return 0; 2163145132Sanholt} 2164