init_gu2.c revision 71d7fec4
1/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nsc/gfx/init_gu2.c,v 1.1 2002/12/10 15:12:27 alanh Exp $ */
2/*
3 * $Workfile: init_gu2.c $
4 *
5 * This file contains routines used in Redcloud initialization.
6 *
7 * NSC_LIC_ALTERNATIVE_PREAMBLE
8 *
9 * Revision 1.0
10 *
11 * National Semiconductor Alternative GPL-BSD License
12 *
13 * National Semiconductor Corporation licenses this software
14 * ("Software"):
15 *
16 *      Durango
17 *
18 * under one of the two following licenses, depending on how the
19 * Software is received by the Licensee.
20 *
21 * If this Software is received as part of the Linux Framebuffer or
22 * other GPL licensed software, then the GPL license designated
23 * NSC_LIC_GPL applies to this Software; in all other circumstances
24 * then the BSD-style license designated NSC_LIC_BSD shall apply.
25 *
26 * END_NSC_LIC_ALTERNATIVE_PREAMBLE */
27
28/* NSC_LIC_BSD
29 *
30 * National Semiconductor Corporation Open Source License for Durango
31 *
32 * (BSD License with Export Notice)
33 *
34 * Copyright (c) 1999-2001
35 * National Semiconductor Corporation.
36 * All rights reserved.
37 *
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
40 * are met:
41 *
42 *   * Redistributions of source code must retain the above copyright
43 *     notice, this list of conditions and the following disclaimer.
44 *
45 *   * Redistributions in binary form must reproduce the above
46 *     copyright notice, this list of conditions and the following
47 *     disclaimer in the documentation and/or other materials provided
48 *     with the distribution.
49 *
50 *   * Neither the name of the National Semiconductor Corporation nor
51 *     the names of its contributors may be used to endorse or promote
52 *     products derived from this software without specific prior
53 *     written permission.
54 *
55 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
56 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
57 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
58 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
59 * NATIONAL SEMICONDUCTOR CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY
60 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
61 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
62 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
63 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
64 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE,
65 * INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY
66 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
67 * OF SUCH DAMAGE.
68 *
69 * EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF
70 * YOUR JURISDICTION. It is licensee's responsibility to comply with
71 * any export regulations applicable in licensee's jurisdiction. Under
72 * CURRENT (2001) U.S. export regulations this software
73 * is eligible for export from the U.S. and can be downloaded by or
74 * otherwise exported or reexported worldwide EXCEPT to U.S. embargoed
75 * destinations which include Cuba, Iraq, Libya, North Korea, Iran,
76 * Syria, Sudan, Afghanistan and any other country to which the U.S.
77 * has embargoed goods and services.
78 *
79 * END_NSC_LIC_BSD */
80
81/* NSC_LIC_GPL
82 *
83 * National Semiconductor Corporation Gnu General Public License for Durango
84 *
85 * (GPL License with Export Notice)
86 *
87 * Copyright (c) 1999-2001
88 * National Semiconductor Corporation.
89 * All rights reserved.
90 *
91 * Redistribution and use in source and binary forms, with or without
92 * modification, are permitted under the terms of the GNU General
93 * Public License as published by the Free Software Foundation; either
94 * version 2 of the License, or (at your option) any later version
95 *
96 * In addition to the terms of the GNU General Public License, neither
97 * the name of the National Semiconductor Corporation nor the names of
98 * its contributors may be used to endorse or promote products derived
99 * from this software without specific prior written permission.
100 *
101 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
102 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
103 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
104 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
105 * NATIONAL SEMICONDUCTOR CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY
106 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
107 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
108 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
109 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
110 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE,
111 * INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY
112 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
113 * OF SUCH DAMAGE. See the GNU General Public License for more details.
114 *
115 * EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF
116 * YOUR JURISDICTION. It is licensee's responsibility to comply with
117 * any export regulations applicable in licensee's jurisdiction. Under
118 * CURRENT (2001) U.S. export regulations this software
119 * is eligible for export from the U.S. and can be downloaded by or
120 * otherwise exported or reexported worldwide EXCEPT to U.S. embargoed
121 * destinations which include Cuba, Iraq, Libya, North Korea, Iran,
122 * Syria, Sudan, Afghanistan and any other country to which the U.S.
123 * has embargoed goods and services.
124 *
125 * You should have received a copy of the GNU General Public License
126 * along with this file; if not, write to the Free Software Foundation,
127 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
128 *
129 * END_NSC_LIC_GPL */
130
131unsigned long gu2_pci_config_read(unsigned long address);
132void gu2_pci_config_write(unsigned long address, unsigned long data);
133unsigned long gu2_get_core_freq(void);
134unsigned long gu2_detect_cpu(void);
135unsigned long gu2_detect_video(void);
136unsigned long gu2_get_cpu_register_base(void);
137unsigned long gu2_get_graphics_register_base(void);
138unsigned long gu2_get_frame_buffer_base(void);
139unsigned long gu2_get_frame_buffer_size(void);
140unsigned long gu2_get_vid_register_base(void);
141unsigned long gu2_get_vip_register_base(void);
142
143/*-----------------------------------------------------------------------------
144 * gfx_get_core_freq
145 *
146 * Returns the core clock frequency of a GX2.
147 *-----------------------------------------------------------------------------
148 */
149#if GFX_INIT_DYNAMIC
150unsigned long
151gu2_get_core_freq(void)
152#else
153unsigned long
154gfx_get_core_freq(void)
155#endif
156{
157   unsigned long value;
158
159   /* CPU SPEED IS REPORTED BY A VSM IN VSA II */
160   /* Virtual Register Class = 0x12 (Sysinfo)  */
161   /* CPU Speed Register     = 0x01            */
162
163   OUTW(0xAC1C, 0xFC53);
164   OUTW(0xAC1C, 0x1201);
165
166   value = (unsigned long)(INW(0xAC1E));
167
168   return (value);
169}
170
171/*-----------------------------------------------------------------------------
172 * gfx_get_cpu_register_base
173 *
174 * This routine returns the base address for display controller registers.
175 *-----------------------------------------------------------------------------
176 */
177#if GFX_INIT_DYNAMIC
178unsigned long
179gu2_get_cpu_register_base(void)
180#else
181unsigned long
182gfx_get_cpu_register_base(void)
183#endif
184{
185   return gfx_pci_config_read(0x80000918);
186}
187
188/*-----------------------------------------------------------------------------
189 * gfx_get_graphics_register_base
190 *
191 * This routine returns the base address for the graphics acceleration.
192 *-----------------------------------------------------------------------------
193 */
194#if GFX_INIT_DYNAMIC
195unsigned long
196gu2_get_graphics_register_base(void)
197#else
198unsigned long
199gfx_get_graphics_register_base(void)
200#endif
201{
202   return gfx_pci_config_read(0x80000914);
203}
204
205/*-----------------------------------------------------------------------------
206 * gfx_get_frame_buffer_base
207 *
208 * This routine returns the base address for graphics memory.
209 *-----------------------------------------------------------------------------
210 */
211#if GFX_INIT_DYNAMIC
212unsigned long
213gu2_get_frame_buffer_base(void)
214#else
215unsigned long
216gfx_get_frame_buffer_base(void)
217#endif
218{
219   return gfx_pci_config_read(0x80000910);
220}
221
222/*-----------------------------------------------------------------------------
223 * gfx_get_frame_buffer_size
224 *
225 * This routine returns the total size of graphics memory, in bytes.
226 *-----------------------------------------------------------------------------
227 */
228#if GFX_INIT_DYNAMIC
229unsigned long
230gu2_get_frame_buffer_size(void)
231#else
232unsigned long
233gfx_get_frame_buffer_size(void)
234#endif
235{
236   unsigned long value;
237
238   /* FRAME BUFFER SIZE IS REPORTED BY A VSM IN VSA II */
239   /* Virtual Register Class     = 0x02                */
240   /* VG_MEM_SIZE (512KB units)  = 0x00                */
241
242   OUTW(0xAC1C, 0xFC53);
243   OUTW(0xAC1C, 0x0200);
244
245   value = (unsigned long)(INW(0xAC1E)) & 0xFFl;
246
247   return (value << 19);
248}
249
250/*-----------------------------------------------------------------------------
251 * gfx_get_vid_register_base
252 *
253 * This routine returns the base address for the video hardware.
254 *-----------------------------------------------------------------------------
255 */
256#if GFX_INIT_DYNAMIC
257unsigned long
258gu2_get_vid_register_base(void)
259#else
260unsigned long
261gfx_get_vid_register_base(void)
262#endif
263{
264   return gfx_pci_config_read(0x8000091C);
265}
266
267/* END OF FILE */
268