2 * This file is part of the coreboot project.
4 * Copyright (C) 2007 Advanced Micro Devices, Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #define FILECODE 0xCCCC
27 u8 getNumOfNodeNb(void);
28 u8 translateNodeIdToDeviceIdNb(u8 nodeId);
31 * Return the minimum possible NbCOF (in 100MHz) for the system.
33 * This function can be run on any core and is used by the HT & Memory init
36 * @return minNbCOF (in multiple of half of CLKIN, 100MHz).
40 u8 numOfNode, i, j, deviceId, nbDid, nbFid, nextNbFid;
46 /* get number of node in the system */
47 numOfNode = getNumOfNodeNb();
49 /* go through each node for the minimum NbCOF (in multiple of CLKIN/2) */
50 for(i=0; i < numOfNode; i++)
52 /* stub function for APIC ID virtualization for large MP system later */
53 deviceId = translateNodeIdToDeviceIdNb(i);
55 /* read all P-state spec registers for NbDid=1 */
58 AmdPCIRead(MAKE_SBDFO(0,0,deviceId,FN_4,PS_SPEC_REG+(j*PCI_REG_LEN)), &dtemp); /*F4x1E0 + j*4 */
60 if(dtemp & NB_DID_MASK)
63 /* if F3x1FC[NbCofVidUpdate]=0, NbFid = default value */
64 AmdPCIRead(MAKE_SBDFO(0,0,deviceId,FN_3,PRCT_INFO), &dtemp); /*F3x1FC*/
65 if(!(dtemp & NB_CV_UPDATE)) /* F3x1FC[NbCofVidUpdated]=0, use default VID */
67 AmdPCIRead(MAKE_SBDFO(0,0,deviceId,FN_3,CPTC0), &dtemp); /*F3xD4*/
68 nextNbFid = (u8) (dtemp & BIT_MASK_5);
70 nextNbFid = (u8) (nextNbFid >> 1);
75 AmdPCIRead(MAKE_SBDFO(0,0,deviceId,FN_3,PW_CTL_MISC), &dtemp); /*F3xA0*/
76 if(dtemp & PVI_MODE) /* PVI */
78 AmdPCIRead(MAKE_SBDFO(0,0,deviceId,FN_3,PRCT_INFO), &dtemp); /*F3x1FC*/
79 nextNbFid = (u8) (dtemp >> UNI_NB_FID_BIT);
80 nextNbFid &= BIT_MASK_5;
82 nextNbFid = nextNbFid >> 1; */
86 AmdPCIRead(MAKE_SBDFO(0,0,deviceId,FN_3,PRCT_INFO), &dtemp); /*F3x1FC*/
87 nextNbFid = (u8) ((dtemp >> UNI_NB_FID_BIT) & BIT_MASK_5);
88 nextNbFid = (u8) (nextNbFid + ((dtemp >> SPLT_NB_FID_OFFSET) & BIT_MASK_3));
90 nextNbFid = nextNbFid >> 1; */
95 else if( nbFid > nextNbFid )
99 /* add the base and convert to 100MHz divide by 2 if DID=1 */
101 nbFid = (u8) (nbFid + 4);
103 nbFid = (u8) ((nbFid + 4) << 1);
107 u8 getNumOfNodeNb(void)
111 AmdPCIRead(MAKE_SBDFO(0,0,24,0,0x60), &dtemp);
112 dtemp = (dtemp >> 4) & BIT_MASK_3;
118 * Return the PCI device ID for PCI access using node ID.
120 * This function may need to change node ID to device ID in big MP systems.
122 * @param nodeId Node ID of the node.
123 * @return PCI device ID of the node.
125 u8 translateNodeIdToDeviceIdNb(u8 nodeId)
127 return (u8) (nodeId+PCI_DEV_BASE);