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 to read machine-specific registers (MSRs) 28 * 29 * Routines: 30 * 31 * gfx_msr_init 32 * gfx_id_msr_device 33 * gfx_get_msr_dev_address 34 * gfx_get_glink_id_at_address 35 * gfx_msr_read 36 * gfx_msr_write 37 * */ 38 39#ifdef HAVE_CONFIG_H 40#include "config.h" 41#endif 42 43/* INCLUDE SUPPORT FOR REDCLOUD, IF SPECIFIED */ 44 45#if GFX_MSR_REDCLOUD 46#include "msr_rdcl.c" 47#endif 48 49/* EXTRA WRAPPERS FOR DYNAMIC SELECTION */ 50 51#if GFX_MSR_DYNAMIC 52 53/*---------------------------------------------------------------------------- 54 * gfx_msr_init 55 *---------------------------------------------------------------------------- 56 */ 57int 58gfx_msr_init() 59{ 60 int ret_value = 0; 61 62#if GFX_MSR_REDCLOUD 63 if (gfx_msr_type & GFX_MSR_TYPE_REDCLOUD) 64 ret_value = redcloud_msr_init(); 65#endif 66 67 return ret_value; 68} 69 70/*---------------------------------------------------------------------------- 71 * gfx_id_msr_device 72 *---------------------------------------------------------------------------- 73 */ 74DEV_STATUS 75gfx_id_msr_device(MSR * pDev, unsigned long address) 76{ 77 DEV_STATUS ret_value = NOT_KNOWN; 78 79#if GFX_MSR_REDCLOUD 80 if (gfx_msr_type & GFX_MSR_TYPE_REDCLOUD) 81 ret_value = redcloud_id_msr_device(pDev, address); 82#endif 83 84 return ret_value; 85} 86 87/*---------------------------------------------------------------------------- 88 * gfx_get_msr_dev_address 89 *---------------------------------------------------------------------------- 90 */ 91DEV_STATUS 92gfx_get_msr_dev_address(unsigned int device, unsigned long *address) 93{ 94 DEV_STATUS ret_value = NOT_KNOWN; 95 96#if GFX_MSR_REDCLOUD 97 if (gfx_msr_type & GFX_MSR_TYPE_REDCLOUD) 98 ret_value = redcloud_get_msr_dev_address(device, address); 99#endif 100 101 return ret_value; 102} 103 104/*---------------------------------------------------------------------------- 105 * gfx_get_glink_id_at_address 106 *---------------------------------------------------------------------------- 107 */ 108DEV_STATUS 109gfx_get_glink_id_at_address(unsigned int *device, unsigned long address) 110{ 111 DEV_STATUS ret_value = NOT_KNOWN; 112 113#if GFX_MSR_REDCLOUD 114 if (gfx_msr_type & GFX_MSR_TYPE_REDCLOUD) 115 ret_value = redcloud_get_glink_id_at_address(device, address); 116#endif 117 118 return ret_value; 119} 120 121/*---------------------------------------------------------------------------- 122 * gfx_msr_read 123 *---------------------------------------------------------------------------- 124 */ 125DEV_STATUS 126gfx_msr_read(unsigned int device, unsigned int msrRegister, Q_WORD * msrValue) 127{ 128 DEV_STATUS ret_value = NOT_KNOWN; 129 130#if GFX_MSR_REDCLOUD 131 if (gfx_msr_type & GFX_MSR_TYPE_REDCLOUD) 132 ret_value = redcloud_msr_read(device, msrRegister, msrValue); 133#endif 134 135 return ret_value; 136} 137 138/*---------------------------------------------------------------------------- 139 * gfx_msr_write 140 *---------------------------------------------------------------------------- 141 */ 142DEV_STATUS 143gfx_msr_write(unsigned int device, unsigned int msrRegister, Q_WORD * msrValue) 144{ 145 DEV_STATUS ret_value = NOT_KNOWN; 146 147#if GFX_MSR_REDCLOUD 148 if (gfx_msr_type & GFX_MSR_TYPE_REDCLOUD) 149 ret_value = redcloud_msr_write(device, msrRegister, msrValue); 150#endif 151 152 return ret_value; 153} 154 155#endif 156