1/* Copyright (c) 2005 Advanced Micro Devices, Inc.
2 *
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:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
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
19 * IN THE SOFTWARE.
20 *
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.
24 * */
25
26/*
27 * This file contains routines used in Redcloud initialization.
28 * */
29
30/*----------------------------------------------------------------------------
31 * gfx_get_core_freq
32 *
33 * Returns the core clock frequency of a GX2.
34 *----------------------------------------------------------------------------
35 */
36#if GFX_INIT_DYNAMIC
37unsigned long
38gu2_get_core_freq(void)
39#else
40unsigned long
41gfx_get_core_freq(void)
42#endif
43{
44    unsigned long value;
45
46    /* CPU SPEED IS REPORTED BY A VSM IN VSA II */
47    /* Virtual Register Class = 0x12 (Sysinfo)  */
48    /* CPU Speed Register     = 0x01            */
49
50    OUTW(0xAC1C, 0xFC53);
51    OUTW(0xAC1C, 0x1201);
52
53    value = (unsigned long) (INW(0xAC1E));
54
55    return (value);
56}
57
58/*----------------------------------------------------------------------------
59 * gfx_get_cpu_register_base
60 *
61 * This routine returns the base address for display controller registers.
62 *----------------------------------------------------------------------------
63 */
64#if GFX_INIT_DYNAMIC
65unsigned long
66gu2_get_cpu_register_base(void)
67#else
68unsigned long
69gfx_get_cpu_register_base(void)
70#endif
71{
72    return gfx_pci_config_read(0x80000918);
73}
74
75/*----------------------------------------------------------------------------
76 * gfx_get_graphics_register_base
77 *
78 * This routine returns the base address for the graphics acceleration.
79 *----------------------------------------------------------------------------
80 */
81#if GFX_INIT_DYNAMIC
82unsigned long
83gu2_get_graphics_register_base(void)
84#else
85unsigned long
86gfx_get_graphics_register_base(void)
87#endif
88{
89    return gfx_pci_config_read(0x80000914);
90}
91
92/*----------------------------------------------------------------------------
93 * gfx_get_frame_buffer_base
94 *
95 * This routine returns the base address for graphics memory.
96 *----------------------------------------------------------------------------
97 */
98#if GFX_INIT_DYNAMIC
99unsigned long
100gu2_get_frame_buffer_base(void)
101#else
102unsigned long
103gfx_get_frame_buffer_base(void)
104#endif
105{
106    return gfx_pci_config_read(0x80000910);
107}
108
109/*----------------------------------------------------------------------------
110 * gfx_get_frame_buffer_size
111 *
112 * This routine returns the total size of graphics memory, in bytes.
113 *----------------------------------------------------------------------------
114 */
115#if GFX_INIT_DYNAMIC
116unsigned long
117gu2_get_frame_buffer_size(void)
118#else
119unsigned long
120gfx_get_frame_buffer_size(void)
121#endif
122{
123    unsigned long value;
124
125    /* FRAME BUFFER SIZE IS REPORTED BY A VSM IN VSA II */
126    /* Virtual Register Class     = 0x02                */
127    /* VG_MEM_SIZE (512KB units)  = 0x00                */
128
129    OUTW(0xAC1C, 0xFC53);
130    OUTW(0xAC1C, 0x0200);
131
132    value = (unsigned long) (INW(0xAC1E)) & 0xFFl;
133
134    return (value << 19);
135}
136
137/*----------------------------------------------------------------------------
138 * gfx_get_vid_register_base
139 *
140 * This routine returns the base address for the video hardware.
141 *----------------------------------------------------------------------------
142 */
143#if GFX_INIT_DYNAMIC
144unsigned long
145gu2_get_vid_register_base(void)
146#else
147unsigned long
148gfx_get_vid_register_base(void)
149#endif
150{
151    return gfx_pci_config_read(0x8000091C);
152}
153
154/* END OF FILE */
155