171d7fec4Smrg/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nsc/gfx/gfx_msr.c,v 1.1 2002/12/10 15:12:25 alanh Exp $ */
271d7fec4Smrg/*
371d7fec4Smrg * $Workfile: gfx_msr.c $
471d7fec4Smrg *
571d7fec4Smrg * This file contains routines to read machine-specific registers (MSRs)
671d7fec4Smrg *
771d7fec4Smrg * Routines:
871d7fec4Smrg *
971d7fec4Smrg *       gfx_msr_init
1071d7fec4Smrg *       gfx_id_msr_device
1171d7fec4Smrg *       gfx_get_msr_dev_address
1271d7fec4Smrg *       gfx_get_glink_id_at_address
1371d7fec4Smrg *       gfx_msr_read
1471d7fec4Smrg *       gfx_msr_write
1571d7fec4Smrg *
1671d7fec4Smrg * NSC_LIC_ALTERNATIVE_PREAMBLE
1771d7fec4Smrg *
1871d7fec4Smrg * Revision 1.0
1971d7fec4Smrg *
2071d7fec4Smrg * National Semiconductor Alternative GPL-BSD License
2171d7fec4Smrg *
2271d7fec4Smrg * National Semiconductor Corporation licenses this software
2371d7fec4Smrg * ("Software"):
2471d7fec4Smrg *
2571d7fec4Smrg *      Durango
2671d7fec4Smrg *
2771d7fec4Smrg * under one of the two following licenses, depending on how the
2871d7fec4Smrg * Software is received by the Licensee.
2971d7fec4Smrg *
3071d7fec4Smrg * If this Software is received as part of the Linux Framebuffer or
3171d7fec4Smrg * other GPL licensed software, then the GPL license designated
3271d7fec4Smrg * NSC_LIC_GPL applies to this Software; in all other circumstances
3371d7fec4Smrg * then the BSD-style license designated NSC_LIC_BSD shall apply.
3471d7fec4Smrg *
3571d7fec4Smrg * END_NSC_LIC_ALTERNATIVE_PREAMBLE */
3671d7fec4Smrg
3771d7fec4Smrg/* NSC_LIC_BSD
3871d7fec4Smrg *
3971d7fec4Smrg * National Semiconductor Corporation Open Source License for Durango
4071d7fec4Smrg *
4171d7fec4Smrg * (BSD License with Export Notice)
4271d7fec4Smrg *
4371d7fec4Smrg * Copyright (c) 1999-2001
4471d7fec4Smrg * National Semiconductor Corporation.
4571d7fec4Smrg * All rights reserved.
4671d7fec4Smrg *
4771d7fec4Smrg * Redistribution and use in source and binary forms, with or without
4871d7fec4Smrg * modification, are permitted provided that the following conditions
4971d7fec4Smrg * are met:
5071d7fec4Smrg *
5171d7fec4Smrg *   * Redistributions of source code must retain the above copyright
5271d7fec4Smrg *     notice, this list of conditions and the following disclaimer.
5371d7fec4Smrg *
5471d7fec4Smrg *   * Redistributions in binary form must reproduce the above
5571d7fec4Smrg *     copyright notice, this list of conditions and the following
5671d7fec4Smrg *     disclaimer in the documentation and/or other materials provided
5771d7fec4Smrg *     with the distribution.
5871d7fec4Smrg *
5971d7fec4Smrg *   * Neither the name of the National Semiconductor Corporation nor
6071d7fec4Smrg *     the names of its contributors may be used to endorse or promote
6171d7fec4Smrg *     products derived from this software without specific prior
6271d7fec4Smrg *     written permission.
6371d7fec4Smrg *
6471d7fec4Smrg * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6571d7fec4Smrg * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
6671d7fec4Smrg * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
6771d7fec4Smrg * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
6871d7fec4Smrg * NATIONAL SEMICONDUCTOR CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY
6971d7fec4Smrg * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
7071d7fec4Smrg * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
7171d7fec4Smrg * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
7271d7fec4Smrg * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
7371d7fec4Smrg * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE,
7471d7fec4Smrg * INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY
7571d7fec4Smrg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
7671d7fec4Smrg * OF SUCH DAMAGE.
7771d7fec4Smrg *
7871d7fec4Smrg * EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF
7971d7fec4Smrg * YOUR JURISDICTION. It is licensee's responsibility to comply with
8071d7fec4Smrg * any export regulations applicable in licensee's jurisdiction. Under
8171d7fec4Smrg * CURRENT (2001) U.S. export regulations this software
8271d7fec4Smrg * is eligible for export from the U.S. and can be downloaded by or
8371d7fec4Smrg * otherwise exported or reexported worldwide EXCEPT to U.S. embargoed
8471d7fec4Smrg * destinations which include Cuba, Iraq, Libya, North Korea, Iran,
8571d7fec4Smrg * Syria, Sudan, Afghanistan and any other country to which the U.S.
8671d7fec4Smrg * has embargoed goods and services.
8771d7fec4Smrg *
8871d7fec4Smrg * END_NSC_LIC_BSD */
8971d7fec4Smrg
9071d7fec4Smrg/* NSC_LIC_GPL
9171d7fec4Smrg *
9271d7fec4Smrg * National Semiconductor Corporation Gnu General Public License for Durango
9371d7fec4Smrg *
9471d7fec4Smrg * (GPL License with Export Notice)
9571d7fec4Smrg *
9671d7fec4Smrg * Copyright (c) 1999-2001
9771d7fec4Smrg * National Semiconductor Corporation.
9871d7fec4Smrg * All rights reserved.
9971d7fec4Smrg *
10071d7fec4Smrg * Redistribution and use in source and binary forms, with or without
10171d7fec4Smrg * modification, are permitted under the terms of the GNU General
10271d7fec4Smrg * Public License as published by the Free Software Foundation; either
10371d7fec4Smrg * version 2 of the License, or (at your option) any later version
10471d7fec4Smrg *
10571d7fec4Smrg * In addition to the terms of the GNU General Public License, neither
10671d7fec4Smrg * the name of the National Semiconductor Corporation nor the names of
10771d7fec4Smrg * its contributors may be used to endorse or promote products derived
10871d7fec4Smrg * from this software without specific prior written permission.
10971d7fec4Smrg *
11071d7fec4Smrg * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
11171d7fec4Smrg * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
11271d7fec4Smrg * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
11371d7fec4Smrg * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
11471d7fec4Smrg * NATIONAL SEMICONDUCTOR CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY
11571d7fec4Smrg * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
11671d7fec4Smrg * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
11771d7fec4Smrg * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
11871d7fec4Smrg * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
11971d7fec4Smrg * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE,
12071d7fec4Smrg * INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY
12171d7fec4Smrg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
12271d7fec4Smrg * OF SUCH DAMAGE. See the GNU General Public License for more details.
12371d7fec4Smrg *
12471d7fec4Smrg * EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF
12571d7fec4Smrg * YOUR JURISDICTION. It is licensee's responsibility to comply with
12671d7fec4Smrg * any export regulations applicable in licensee's jurisdiction. Under
12771d7fec4Smrg * CURRENT (2001) U.S. export regulations this software
12871d7fec4Smrg * is eligible for export from the U.S. and can be downloaded by or
12971d7fec4Smrg * otherwise exported or reexported worldwide EXCEPT to U.S. embargoed
13071d7fec4Smrg * destinations which include Cuba, Iraq, Libya, North Korea, Iran,
13171d7fec4Smrg * Syria, Sudan, Afghanistan and any other country to which the U.S.
13271d7fec4Smrg * has embargoed goods and services.
13371d7fec4Smrg *
13471d7fec4Smrg * You should have received a copy of the GNU General Public License
13571d7fec4Smrg * along with this file; if not, write to the Free Software Foundation,
13671d7fec4Smrg * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
13771d7fec4Smrg *
13871d7fec4Smrg * END_NSC_LIC_GPL */
13971d7fec4Smrg
14071d7fec4Smrg/* INCLUDE SUPPORT FOR REDCLOUD, IF SPECIFIED */
14171d7fec4Smrg
14271d7fec4Smrg#if GFX_MSR_REDCLOUD
14371d7fec4Smrg#include "msr_rdcl.c"
14471d7fec4Smrg#endif
14571d7fec4Smrg
14671d7fec4Smrg/* EXTRA WRAPPERS FOR DYNAMIC SELECTION */
14771d7fec4Smrg
14871d7fec4Smrg#if GFX_MSR_DYNAMIC
14971d7fec4Smrg
15071d7fec4Smrg/*-----------------------------------------------------------------------------
15171d7fec4Smrg * gfx_msr_init
15271d7fec4Smrg *-----------------------------------------------------------------------------
15371d7fec4Smrg */
15471d7fec4Smrgint
15571d7fec4Smrggfx_msr_init()
15671d7fec4Smrg{
15771d7fec4Smrg   int ret_value = 0;
15871d7fec4Smrg
15971d7fec4Smrg#	if GFX_MSR_REDCLOUD
16071d7fec4Smrg   if (gfx_msr_type & GFX_MSR_TYPE_REDCLOUD)
16171d7fec4Smrg      ret_value = redcloud_msr_init();
16271d7fec4Smrg#	endif
16371d7fec4Smrg
16471d7fec4Smrg   return ret_value;
16571d7fec4Smrg}
16671d7fec4Smrg
16771d7fec4Smrg/*-----------------------------------------------------------------------------
16871d7fec4Smrg * gfx_id_msr_device
16971d7fec4Smrg *-----------------------------------------------------------------------------
17071d7fec4Smrg */
17171d7fec4SmrgDEV_STATUS
17271d7fec4Smrggfx_id_msr_device(MSR * pDev, unsigned long address)
17371d7fec4Smrg{
17471d7fec4Smrg   DEV_STATUS ret_value = NOT_KNOWN;
17571d7fec4Smrg
17671d7fec4Smrg#	if GFX_MSR_REDCLOUD
17771d7fec4Smrg   if (gfx_msr_type & GFX_MSR_TYPE_REDCLOUD)
17871d7fec4Smrg      ret_value = redcloud_id_msr_device(pDev, address);
17971d7fec4Smrg#	endif
18071d7fec4Smrg
18171d7fec4Smrg   return ret_value;
18271d7fec4Smrg}
18371d7fec4Smrg
18471d7fec4Smrg/*-----------------------------------------------------------------------------
18571d7fec4Smrg * gfx_get_msr_dev_address
18671d7fec4Smrg *-----------------------------------------------------------------------------
18771d7fec4Smrg */
18871d7fec4SmrgDEV_STATUS
18971d7fec4Smrggfx_get_msr_dev_address(unsigned int device, unsigned long *address)
19071d7fec4Smrg{
19171d7fec4Smrg   DEV_STATUS ret_value = NOT_KNOWN;
19271d7fec4Smrg
19371d7fec4Smrg#	if GFX_MSR_REDCLOUD
19471d7fec4Smrg   if (gfx_msr_type & GFX_MSR_TYPE_REDCLOUD)
19571d7fec4Smrg      ret_value = redcloud_get_msr_dev_address(device, address);
19671d7fec4Smrg#	endif
19771d7fec4Smrg
19871d7fec4Smrg   return ret_value;
19971d7fec4Smrg}
20071d7fec4Smrg
20171d7fec4Smrg/*-----------------------------------------------------------------------------
20271d7fec4Smrg * gfx_get_glink_id_at_address
20371d7fec4Smrg *-----------------------------------------------------------------------------
20471d7fec4Smrg */
20571d7fec4SmrgDEV_STATUS
20671d7fec4Smrggfx_get_glink_id_at_address(unsigned int *device, unsigned long address)
20771d7fec4Smrg{
20871d7fec4Smrg   DEV_STATUS ret_value = NOT_KNOWN;
20971d7fec4Smrg
21071d7fec4Smrg#	if GFX_MSR_REDCLOUD
21171d7fec4Smrg   if (gfx_msr_type & GFX_MSR_TYPE_REDCLOUD)
21271d7fec4Smrg      ret_value = redcloud_get_glink_id_at_address(device, address);
21371d7fec4Smrg#	endif
21471d7fec4Smrg
21571d7fec4Smrg   return ret_value;
21671d7fec4Smrg}
21771d7fec4Smrg
21871d7fec4Smrg/*-----------------------------------------------------------------------------
21971d7fec4Smrg * gfx_msr_read
22071d7fec4Smrg *-----------------------------------------------------------------------------
22171d7fec4Smrg */
22271d7fec4SmrgDEV_STATUS
22371d7fec4Smrggfx_msr_read(unsigned int device, unsigned int msrRegister, Q_WORD * msrValue)
22471d7fec4Smrg{
22571d7fec4Smrg   DEV_STATUS ret_value = NOT_KNOWN;
22671d7fec4Smrg
22771d7fec4Smrg#	if GFX_MSR_REDCLOUD
22871d7fec4Smrg   if (gfx_msr_type & GFX_MSR_TYPE_REDCLOUD)
22971d7fec4Smrg      ret_value = redcloud_msr_read(device, msrRegister, msrValue);
23071d7fec4Smrg#	endif
23171d7fec4Smrg
23271d7fec4Smrg   return ret_value;
23371d7fec4Smrg}
23471d7fec4Smrg
23571d7fec4Smrg/*-----------------------------------------------------------------------------
23671d7fec4Smrg * gfx_msr_write
23771d7fec4Smrg *-----------------------------------------------------------------------------
23871d7fec4Smrg */
23971d7fec4SmrgDEV_STATUS
24071d7fec4Smrggfx_msr_write(unsigned int device, unsigned int msrRegister,
24171d7fec4Smrg	      Q_WORD * msrValue)
24271d7fec4Smrg{
24371d7fec4Smrg   DEV_STATUS ret_value = NOT_KNOWN;
24471d7fec4Smrg
24571d7fec4Smrg#	if GFX_MSR_REDCLOUD
24671d7fec4Smrg   if (gfx_msr_type & GFX_MSR_TYPE_REDCLOUD)
24771d7fec4Smrg      ret_value = redcloud_msr_write(device, msrRegister, msrValue);
24871d7fec4Smrg#	endif
24971d7fec4Smrg
25071d7fec4Smrg   return ret_value;
25171d7fec4Smrg}
25271d7fec4Smrg
25371d7fec4Smrg#endif
254