powernow.h revision 1.13
11.13Sjruoho/* $NetBSD: powernow.h,v 1.13 2011/02/24 10:56:02 jruoho Exp $ */ 21.1Sxtraeme 31.1Sxtraeme/*- 41.1Sxtraeme * Copyright (c) 2004 Martin V�giard. 51.1Sxtraeme * All rights reserved. 61.1Sxtraeme * 71.1Sxtraeme * Redistribution and use in source and binary forms, with or without 81.1Sxtraeme * modification, are permitted provided that the following conditions 91.1Sxtraeme * are met: 101.1Sxtraeme * 1. Redistributions of source code must retain the above copyright 111.1Sxtraeme * notice, this list of conditions and the following disclaimer. 121.1Sxtraeme * 2. Redistributions in binary form must reproduce the above copyright 131.1Sxtraeme * notice, this list of conditions and the following disclaimer in the 141.1Sxtraeme * documentation and/or other materials provided with the distribution. 151.1Sxtraeme * 3. The name of the author may not be used to endorse or promote products 161.1Sxtraeme * derived from this software without specific prior written permission. 171.1Sxtraeme * 181.1Sxtraeme * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 191.1Sxtraeme * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 201.1Sxtraeme * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 211.1Sxtraeme * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 221.1Sxtraeme * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 231.1Sxtraeme * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 241.1Sxtraeme * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 251.1Sxtraeme * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 261.1Sxtraeme * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 271.1Sxtraeme * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 281.1Sxtraeme */ 291.1Sxtraeme 301.1Sxtraeme/*- 311.1Sxtraeme * Copyright (c) 2004-2005 Bruno Ducrot 321.1Sxtraeme * Copyright (c) 2004 FUKUDA Nobuhiko <nfukuda@spa.is.uec.ac.jp> 331.1Sxtraeme * 341.1Sxtraeme * Redistribution and use in source and binary forms, with or without 351.1Sxtraeme * modification, are permitted provided that the following conditions 361.1Sxtraeme * are met: 371.1Sxtraeme * 1. Redistributions of source code must retain the above copyright 381.1Sxtraeme * notice, this list of conditions and the following disclaimer. 391.1Sxtraeme * 2. Redistributions in binary form must reproduce the above copyright 401.1Sxtraeme * notice, this list of conditions and the following disclaimer in the 411.1Sxtraeme * documentation and/or other materials provided with the distribution. 421.1Sxtraeme * 431.1Sxtraeme * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 441.1Sxtraeme * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 451.1Sxtraeme * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 461.1Sxtraeme * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 471.1Sxtraeme * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 481.1Sxtraeme * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 491.1Sxtraeme * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 501.1Sxtraeme * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 511.1Sxtraeme * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 521.1Sxtraeme * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 531.1Sxtraeme */ 541.1Sxtraeme 551.13Sjruoho#ifndef _X86_POWERNOW_H 561.13Sjruoho#define _X86_POWERNOW_H 571.1Sxtraeme 581.1Sxtraeme#ifdef POWERNOW_DEBUG 591.1Sxtraeme#define DPRINTF(x) do { printf x; } while (0) 601.1Sxtraeme#else 611.1Sxtraeme#define DPRINTF(x) 621.1Sxtraeme#endif 631.1Sxtraeme 641.1Sxtraeme#define BIOS_START 0xe0000 651.1Sxtraeme#define BIOS_LEN 0x20000 661.1Sxtraeme#define BIOS_STEP 16 671.1Sxtraeme 681.1Sxtraeme/* 691.1Sxtraeme * MSRs and bits used by Powernow technology 701.1Sxtraeme */ 711.1Sxtraeme#define MSR_AMDK7_FIDVID_CTL 0xc0010041 721.1Sxtraeme#define MSR_AMDK7_FIDVID_STATUS 0xc0010042 731.1Sxtraeme#define AMD_PN_FID_VID 0x06 741.1Sxtraeme#define AMD_ERRATA_A0_CPUSIG 0x660 751.1Sxtraeme 761.1Sxtraeme#define PN7_FLAG_ERRATA_A0 0x01 771.1Sxtraeme#define PN7_FLAG_DESKTOP_VRM 0x02 781.1Sxtraeme 791.1Sxtraeme/* Bitfields used by K7 */ 801.1Sxtraeme#define PN7_PSB_VERSION 0x12 811.1Sxtraeme#define PN7_CTR_FID(x) ((x) & 0x1f) 821.1Sxtraeme#define PN7_CTR_VID(x) (((x) & 0x1f) << 8) 831.1Sxtraeme#define PN7_CTR_FIDC 0x00010000 841.1Sxtraeme#define PN7_CTR_VIDC 0x00020000 851.1Sxtraeme#define PN7_CTR_FIDCHRATIO 0x00100000 861.1Sxtraeme#define PN7_CTR_SGTC(x) (((uint64_t)(x) & 0x000fffff) << 32) 871.1Sxtraeme 881.1Sxtraeme#define PN7_STA_CFID(x) ((x) & 0x1f) 891.1Sxtraeme#define PN7_STA_SFID(x) (((x) >> 8) & 0x1f) 901.1Sxtraeme#define PN7_STA_MFID(x) (((x) >> 16) & 0x1f) 911.1Sxtraeme#define PN7_STA_CVID(x) (((x) >> 32) & 0x1f) 921.1Sxtraeme#define PN7_STA_SVID(x) (((x) >> 40) & 0x1f) 931.1Sxtraeme#define PN7_STA_MVID(x) (((x) >> 48) & 0x1f) 941.1Sxtraeme 951.1Sxtraeme/* Bitfields used by K8 */ 961.1Sxtraeme#define PN8_CTR_FID(x) ((x) & 0x3f) 971.1Sxtraeme#define PN8_CTR_VID(x) (((x) & 0x1f) << 8) 981.1Sxtraeme#define PN8_CTR_PENDING(x) (((x) & 1) << 32) 991.1Sxtraeme 1001.1Sxtraeme#define PN8_STA_CFID(x) ((x) & 0x3f) 1011.1Sxtraeme#define PN8_STA_SFID(x) (((x) >> 8) & 0x3f) 1021.1Sxtraeme#define PN8_STA_MFID(x) (((x) >> 16) & 0x3f) 1031.1Sxtraeme#define PN8_STA_PENDING(x) (((x) >> 31) & 0x01) 1041.1Sxtraeme#define PN8_STA_CVID(x) (((x) >> 32) & 0x1f) 1051.1Sxtraeme#define PN8_STA_SVID(x) (((x) >> 40) & 0x1f) 1061.1Sxtraeme#define PN8_STA_MVID(x) (((x) >> 48) & 0x1f) 1071.1Sxtraeme 1081.1Sxtraeme#define COUNT_OFF_IRT(irt) DELAY(10 * (1 << (irt))) 1091.1Sxtraeme#define COUNT_OFF_VST(vst) DELAY(20 * (vst)) 1101.1Sxtraeme 1111.1Sxtraeme#define FID_TO_VCO_FID(fid) \ 1121.1Sxtraeme (((fid) < 8) ? (8 + ((fid) << 1)) : (fid)) 1131.1Sxtraeme 1141.1Sxtraeme/* Reserved1 to powernow k8 configuration */ 1151.1Sxtraeme#define PN8_PSB_TO_RVO(x) ((x) & 0x03) 1161.1Sxtraeme#define PN8_PSB_TO_IRT(x) (((x) >> 2) & 0x03) 1171.1Sxtraeme#define PN8_PSB_TO_MVS(x) (((x) >> 4) & 0x03) 1181.1Sxtraeme#define PN8_PSB_TO_BATT(x) (((x) >> 6) & 0x03) 1191.1Sxtraeme 1201.1Sxtraeme#define POWERNOW_MAX_STATES 16 1211.1Sxtraeme 1221.1Sxtraemestruct powernow_state { 1231.2Sxtraeme int freq; 1241.1Sxtraeme uint8_t fid; 1251.1Sxtraeme uint8_t vid; 1261.1Sxtraeme}; 1271.1Sxtraeme 1281.1Sxtraemestruct powernow_cpu_state { 1291.13Sjruoho struct powernow_state state_table[POWERNOW_MAX_STATES]; 1301.1Sxtraeme unsigned int fsb; 1311.2Sxtraeme unsigned int n_states; 1321.2Sxtraeme unsigned int sgtc; 1331.2Sxtraeme unsigned int vst; 1341.1Sxtraeme unsigned int mvs; 1351.1Sxtraeme unsigned int pll; 1361.1Sxtraeme unsigned int rvo; 1371.2Sxtraeme unsigned int irt; 1381.1Sxtraeme int low; 1391.1Sxtraeme}; 1401.1Sxtraeme 1411.1Sxtraemestruct powernow_psb_s { 1421.1Sxtraeme char signature[10]; /* AMDK7PNOW! */ 1431.1Sxtraeme uint8_t version; 1441.1Sxtraeme uint8_t flags; 1451.1Sxtraeme uint16_t ttime; /* Min settling time */ 1461.1Sxtraeme uint8_t reserved; 1471.1Sxtraeme uint8_t n_pst; 1481.1Sxtraeme}; 1491.1Sxtraeme 1501.1Sxtraemestruct powernow_pst_s { 1511.1Sxtraeme uint32_t signature; 1521.1Sxtraeme uint8_t pll; 1531.1Sxtraeme uint8_t fid; 1541.1Sxtraeme uint8_t vid; 1551.1Sxtraeme uint8_t n_states; 1561.1Sxtraeme}; 1571.1Sxtraeme 1581.13Sjruoho#endif /* !_X86_POWERNOW_H */ 159