atyfb: Properly save PCI state before changing PCI PM level
[deliverable/linux.git] / drivers / video / aty / atyfb_base.c
CommitLineData
1da177e4
LT
1/*
2 * ATI Frame Buffer Device Driver Core
3 *
4 * Copyright (C) 2004 Alex Kern <alex.kern@gmx.de>
5 * Copyright (C) 1997-2001 Geert Uytterhoeven
6 * Copyright (C) 1998 Bernd Harries
7 * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
8 *
9 * This driver supports the following ATI graphics chips:
10 * - ATI Mach64
11 *
12 * To do: add support for
13 * - ATI Rage128 (from aty128fb.c)
14 * - ATI Radeon (from radeonfb.c)
15 *
16 * This driver is partly based on the PowerMac console driver:
17 *
18 * Copyright (C) 1996 Paul Mackerras
19 *
20 * and on the PowerMac ATI/mach64 display driver:
21 *
22 * Copyright (C) 1997 Michael AK Tesch
23 *
24 * with work by Jon Howell
25 * Harry AC Eaton
26 * Anthony Tong <atong@uiuc.edu>
27 *
28 * Generic LCD support written by Daniel Mantione, ported from 2.4.20 by Alex Kern
96de0e25 29 * Many Thanks to Ville Syrjälä for patches and fixing nasting 16 bit color bug.
1da177e4
LT
30 *
31 * This file is subject to the terms and conditions of the GNU General Public
32 * License. See the file COPYING in the main directory of this archive for
33 * more details.
34 *
35 * Many thanks to Nitya from ATI devrel for support and patience !
36 */
37
38/******************************************************************************
39
40 TODO:
41
42 - cursor support on all cards and all ramdacs.
43 - cursor parameters controlable via ioctl()s.
44 - guess PLL and MCLK based on the original PLL register values initialized
45 by Open Firmware (if they are initialized). BIOS is done
46
47 (Anyone with Mac to help with this?)
48
49******************************************************************************/
50
51
1da177e4
LT
52#include <linux/module.h>
53#include <linux/moduleparam.h>
54#include <linux/kernel.h>
55#include <linux/errno.h>
56#include <linux/string.h>
57#include <linux/mm.h>
58#include <linux/slab.h>
59#include <linux/vmalloc.h>
60#include <linux/delay.h>
61#include <linux/console.h>
62#include <linux/fb.h>
63#include <linux/init.h>
64#include <linux/pci.h>
65#include <linux/interrupt.h>
66#include <linux/spinlock.h>
67#include <linux/wait.h>
5474c120 68#include <linux/backlight.h>
1da177e4
LT
69
70#include <asm/io.h>
84902b7a 71#include <linux/uaccess.h>
1da177e4
LT
72
73#include <video/mach64.h>
74#include "atyfb.h"
75#include "ati_ids.h"
76
77#ifdef __powerpc__
e8222502 78#include <asm/machdep.h>
1da177e4
LT
79#include <asm/prom.h>
80#include "../macmodes.h"
81#endif
82#ifdef __sparc__
1da177e4 83#include <asm/fbio.h>
63c3f460
DM
84#include <asm/oplib.h>
85#include <asm/prom.h>
1da177e4
LT
86#endif
87
88#ifdef CONFIG_ADB_PMU
89#include <linux/adb.h>
90#include <linux/pmu.h>
91#endif
92#ifdef CONFIG_BOOTX_TEXT
93#include <asm/btext.h>
94#endif
95#ifdef CONFIG_PMAC_BACKLIGHT
96#include <asm/backlight.h>
97#endif
98#ifdef CONFIG_MTRR
99#include <asm/mtrr.h>
100#endif
101
102/*
103 * Debug flags.
104 */
105#undef DEBUG
106/*#define DEBUG*/
107
108/* Make sure n * PAGE_SIZE is protected at end of Aperture for GUI-regs */
109/* - must be large enough to catch all GUI-Regs */
110/* - must be aligned to a PAGE boundary */
111#define GUI_RESERVE (1 * PAGE_SIZE)
112
113/* FIXME: remove the FAIL definition */