1
/* Copyright (c) 2003-2006 Advanced Micro Devices, Inc.
3
* Permission is hereby granted, free of charge, to any person obtaining a copy
4
* of this software and associated documentation files (the "Software"), to
5
* deal in the Software without restriction, including without limitation the
6
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
* sell copies of the Software, and to permit persons to whom the Software is
8
* furnished to do so, subject to the following conditions:
10
* The above copyright notice and this permission notice shall be included in
11
* all copies or substantial portions of the Software.
13
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21
* Neither the name of the Advanced Micro Devices, Inc. nor the names of its
22
* contributors may be used to endorse or promote products derived from this
23
* software without specific prior written permission.
26
/* The previous version of this file was way more complex then it should have
27
been - remove the unnessesary #defines and routines, and concentrate on
38
#include <os.h> /* ErrorF() */
40
/* Compiler options */
42
#define GFX_DISPLAY_GU1 0 /* 1st generation display controller */
43
#define GFX_DISPLAY_GU2 1 /* 2nd generation display controller */
45
#define GFX_INIT_DYNAMIC 0 /* runtime selection */
46
#define GFX_INIT_GU1 0 /* SC1200/GX1 */
47
#define GFX_INIT_GU2 1 /* GX */
49
#define GFX_MSR_DYNAMIC 0 /* runtime selection */
50
#define GFX_MSR_REDCLOUD 1 /* GX */
52
#define GFX_2DACCEL_DYNAMIC 0 /* runtime selection */
53
#define GFX_2DACCEL_GU1 0 /* 1st generation 2D accelerator */
54
#define GFX_2DACCEL_GU2 1 /* 2nd generation 2D accelerator */
56
#define GFX_VIDEO_DYNAMIC 0 /* runtime selection */
57
#define GFX_VIDEO_CS5530 0 /* support for CS5530 */
58
#define GFX_VIDEO_SC1200 0 /* support for SC1200 */
59
#define GFX_VIDEO_REDCLOUD 1 /* support for GX */
61
#define GFX_VIP_DYNAMIC 0 /* runtime selection */
62
#define GFX_VIP_SC1200 0 /* support for SC1200 */
64
#define GFX_DECODER_DYNAMIC 0 /* runtime selection */
65
#define GFX_DECODER_SAA7114 0 /* Philips SAA7114 decoder */
67
#define GFX_TV_DYNAMIC 0 /* runtime selection */
68
#define GFX_TV_FS451 0 /* Focus Enhancements FS450 */
69
#define GFX_TV_SC1200 0 /* SC1200 integrated TV encoder */
71
#define GFX_I2C_DYNAMIC 0 /* runtime selection */
72
#define GFX_I2C_ACCESS 0 /* support for ACCESS.BUS */
73
#define GFX_I2C_GPIO 0 /* support for CS5530 GPIOs */
75
#define GFX_VGA_DYNAMIC 0 /* runtime selection */
76
#define GFX_VGA_GU1 0 /* 1st generation graphics unit */
78
#define FB4MB 1 /* Set to use 4Mb vid ram for Pyramid */
80
#define GFX_NO_IO_IN_WAIT_MACROS 1 /* Set to remove I/O accesses in GP */
81
#define GFX_READ_ROUTINES 1
88
unsigned char *gfx_virt_regptr = (unsigned char *) 0x40000000;
89
unsigned char *gfx_virt_fbptr = (unsigned char *) 0x40800000;
90
unsigned char *gfx_virt_vidptr = (unsigned char *) 0x40010000;
91
unsigned char *gfx_virt_vipptr = (unsigned char *) 0x40015000;
92
unsigned char *gfx_virt_spptr = (unsigned char *) 0x40000000;
93
unsigned char *gfx_virt_gpptr = (unsigned char *) 0x40000000;
95
unsigned char *gfx_phys_regptr = (unsigned char *) 0x40000000;
96
unsigned char *gfx_phys_fbptr = (unsigned char *) 0x40800000;
97
unsigned char *gfx_phys_vidptr = (unsigned char *) 0x40010000;
98
unsigned char *gfx_phys_vipptr = (unsigned char *) 0x40015000;
100
#define INB(port) inb(port)
101
#define INW(port) inw(port)
102
#define IND(port) inl(port)
103
#define OUTB(port,data) outb(port, data)
104
#define OUTW(port,data) outw(port, data)
105
#define OUTD(port,data) outl(port, data)
107
/* Squash warnings */
108
unsigned char gfx_inb(unsigned short);
109
unsigned short gfx_inw(unsigned short);
110
unsigned long gfx_ind(unsigned short);
112
void gfx_outb(unsigned short, unsigned char);
113
void gfx_outw(unsigned short, unsigned short);
114
void gfx_outd(unsigned short, unsigned long);
117
gfx_inb(unsigned short port)
122
inline unsigned short
123
gfx_inw(unsigned short port)
129
gfx_ind(unsigned short port)
135
gfx_outb(unsigned short port, unsigned char data)
141
gfx_outw(unsigned short port, unsigned short data)
147
gfx_outd(unsigned short port, unsigned long data)
152
/* These routines use VSA to read the MSRs - these are a second resort to the Linux MSR method */
154
#define vsa_msr_read(msr,adr,high,low) \
155
__asm__ __volatile__( \
156
" mov $0x0AC1C, %%edx\n" \
157
" mov $0xFC530007, %%eax\n" \
158
" out %%eax,%%dx\n" \
161
: "=a" (*(low)), "=d" (*(high)) \
164
#define vsa_msr_write(msr,adr,high,low) \
165
{ int d0, d1, d2, d3, d4; \
166
__asm__ __volatile__( \
168
" mov $0x0AC1C, %%edx\n" \
169
" mov $0xFC530007, %%eax\n" \
170
" out %%eax,%%dx\n" \
177
" out %%ax, %%dx\n" \
179
: "=a"(d0),"=&D"(d1),"=&S"(d2), \
181
: "1"(msr | adr),"2"(*(high)),"3"(*(low))); \
184
extern int GeodeWriteMSR(unsigned long, unsigned long, unsigned long);
185
extern int GeodeReadMSR(unsigned long, unsigned long *, unsigned long *);
188
gfx_msr_asm_write(unsigned short reg, unsigned long addr,
189
unsigned long *hi, unsigned long *lo)
191
static int msr_method = 0;
193
if (msr_method == 0) {
194
if (!GeodeWriteMSR(addr | reg, *lo, *hi))
200
/* This is the fallback VSA method - not preferred */
201
vsa_msr_write(reg, addr, hi, lo);
205
gfx_msr_asm_read(unsigned short reg, unsigned long addr,
206
unsigned long *hi, unsigned long *lo)
208
static int msr_method = 0;
210
if (msr_method == 0) {
211
if (!GeodeReadMSR(addr | reg, lo, hi))
214
ErrorF("Unable to read the MSR - reverting to the VSA method.\n");
218
/* This is the fallback VSA method - not preferred */
219
vsa_msr_read(reg, addr, hi, lo);
222
#include "gfx_init.c"
224
#include "gfx_rndr.c"
225
#include "gfx_mode.h"
226
#include "gfx_disp.c"
229
#include "gfx_dcdr.c"