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 #include <northbridge/amd/amdht/AsPsDefs.h>
23 static inline void print_debug_fv(const char *str, u32 val)
25 #if CONFIG_SET_FIDVID_DEBUG
26 printk(BIOS_DEBUG, "%s%x\n", str, val);
30 static inline void print_debug_fv_8(const char *str, u8 val)
32 #if CONFIG_SET_FIDVID_DEBUG
33 printk(BIOS_DEBUG, "%s%02x\n", str, val);
37 static inline void print_debug_fv_64(const char *str, u32 val, u32 val2)
39 #if CONFIG_SET_FIDVID_DEBUG
40 printk(BIOS_DEBUG, "%s%x%x\n", str, val, val2);
48 static void enable_fid_change(u8 fid)
57 for (i = 0; i < nodes; i++) {
59 dword = pci_read_config32(dev, 0xd4);
61 dword |= (u32) fid & 0x1F;
62 dword |= 1 << 5; // enable
63 pci_write_config32(dev, 0xd4, dword);
64 printk(BIOS_DEBUG, "FID Change Node:%02x, F3xD4: %08x \n", i,
69 static void setVSRamp(device_t dev) {
70 /* BKDG r31116 2010-04-22 2.4.1.7 step b F3xD8[VSRampTime]
71 * If this field accepts 8 values between 10 and 500 us why
72 * does page 324 say "BIOS should set this field to 001b."
74 * Shouldn't it depend on the voltage regulators, mainboard
78 dword = pci_read_config32(dev, 0xd8);
80 dword |= VSRAMP_VALUE;
81 pci_write_config32(dev, 0xd8, dword);
84 static void recalculateVsSlamTimeSettingOnCorePre(device_t dev)
87 u8 highVoltageVid, lowVoltageVid, bValue;
89 u16 vSlamTimes[7] = { 1000, 2000, 3000, 4000, 6000, 10000, 20000 }; /* Reg settings scaled by 100 */
93 /* This function calculates the VsSlamTime using the range of possible
94 * voltages instead of a hardcoded 200us.
95 * Note:This function is called from setFidVidRegs and setUserPs after
96 * programming a custom Pstate.
99 /* Calculate Slam Time
100 * Vslam = 0.4us/mV * Vp0 - (lowest out of Vpmin or Valt)
101 * In our case, we will scale the values by 100 to avoid
105 /* Determine if this is a PVI or SVI system */
106 dtemp = pci_read_config32(dev, 0xA0);
108 if (dtemp & PVI_MODE)
113 /* Get P0's voltage */
114 msr = rdmsr(0xC0010064);
115 highVoltageVid = (u8) ((msr.lo >> PS_CPU_VID_SHFT) & 0x7F);
117 /* If SVI, we only care about CPU VID.
118 * If PVI, determine the higher voltage b/t NB and CPU
121 bValue = (u8) ((msr.lo >> PS_NB_VID_SHFT) & 0x7F);
122 if (highVoltageVid > bValue)
123 highVoltageVid = bValue;
126 /* Get Pmin's index */
127 msr = rdmsr(0xC0010061);
128 bValue = (u8) ((msr.lo >> PS_CUR_LIM_SHFT) & BIT_MASK_3);
131 msr = rdmsr(0xC0010064 + bValue);
132 lowVoltageVid = (u8) ((msr.lo >> PS_CPU_VID_SHFT) & 0x7F);
134 /* If SVI, we only care about CPU VID.
135 * If PVI, determine the higher voltage b/t NB and CPU
138 bValue = (u8) ((msr.lo >> PS_NB_VID_SHFT) & 0x7F);
139 if (lowVoltageVid > bValue)
140 lowVoltageVid = bValue;
144 dtemp = pci_read_config32(dev, 0xDC);
145 bValue = (u8) (dtemp & BIT_MASK_7);
147 /* Use the VID with the lowest voltage (higher VID) */
148 if (lowVoltageVid < bValue)
149 lowVoltageVid = bValue;
151 /* If Vids are 7Dh - 7Fh, force 7Ch to keep calculations linear */
152 if (lowVoltageVid > 0x7C) {
153 lowVoltageVid = 0x7C;
154 if (highVoltageVid > 0x7C)
155 highVoltageVid = 0x7C;
158 bValue = (u8) (lowVoltageVid - highVoltageVid);
160 /* Each Vid increment is 12.5 mV. The minimum slam time is:
161 * vidCodeDelta * 12.5mV * 0.4us/mV
162 * Scale by 100 to avoid decimals.
164 minimumSlamTime = bValue * (125 * 4);
166 /* Now round up to nearest register setting.
167 * Note that if we don't find a value, we
168 * will fall through to a value of 7
170 for (bValue = 0; bValue < 7; bValue++) {
171 if (minimumSlamTime <= vSlamTimes[bValue])
175 /* Apply the value */
176 dtemp = pci_read_config32(dev, 0xD8);
177 dtemp &= VSSLAM_MASK;
179 pci_write_config32(dev, 0xd8, dtemp);
182 static u32 power_up_down(int node) {
184 /* check platform type */
185 if (!(get_platform_type() & AMD_PTYPE_SVR)) {
186 /* For non-server platform
187 * PowerStepUp=01000b - 50nS
188 * PowerStepDown=01000b - 50ns
190 dword |= PW_STP_UP50 | PW_STP_DN50 ;
192 /* get number of cores for PowerStepUp & PowerStepDown in server
193 1 core - 400nS - 0000b
194 2 cores - 200nS - 0010b
195 3 cores - 133nS -> 100nS - 0011b
196 4 cores - 100nS - 0011b
198 switch (get_core_num_in_bsp(node)) {
200 dword |= PW_STP_UP400 | PW_STP_DN400;
204 dword |= PW_STP_UP200 | PW_STP_DN200;
207 dword |= PW_STP_UP100 | PW_STP_DN100;
210 dword |= PW_STP_UP100 | PW_STP_DN100;
217 static void config_clk_power_ctrl_reg0(int node) {
218 device_t dev = NODE_PCI(node, 3);
221 /* Program fields in Clock Power/Control register0 (F3xD4) */
223 /* set F3xD4 Clock Power/Timing Control 0 Register
224 * NbClkDidApplyAll=1b
226 * PowerStepUp= "platform dependent"
227 * PowerStepDown= "platform dependent"
229 * ClkRampHystSel=HW default
231 u32 dword= pci_read_config32(dev, 0xd4);
233 dword |= NB_CLKDID_ALL | NB_CLKDID | LNK_PLL_LOCK; /* per BKDG */
234 dword |= power_up_down(node);
236 pci_write_config32(dev, 0xd4, dword);
240 static void config_power_ctrl_misc_reg(device_t dev) {
242 u32 dword = pci_read_config32(dev, 0xA0);
243 if (dword & PVI_MODE) { /* PVI */
244 /* set slamVidMode to 0 for PVI */
245 dword &= VID_SLAM_OFF | PLLLOCK_OFF;
246 dword |= PLLLOCK_DFT_L;
247 pci_write_config32(dev, 0xA0, dword);
249 /* set slamVidMode to 1 for SVI */
250 dword &= PLLLOCK_OFF;
251 dword |= PLLLOCK_DFT_L | VID_SLAM_ON;
252 pci_write_config32(dev, 0xA0, dword);
256 /* Program F3xD8[PwrPlanes] according F3xA0[DulaVdd] */
257 dword = pci_read_config32(dev, 0xD8);
259 if (dtemp & DUAL_VDD_BIT)
262 dword &= PWR_PLN_OFF;
263 pci_write_config32(dev, 0xD8, dword);
267 static void config_nb_syn_ptr_adj(device_t dev) {
268 /* Note the following settings are additional from the ported
269 * function setFidVidRegs()
271 u32 dword = pci_read_config32(dev, 0xDc);
272 dword |= 0x5 << 12; /* NbsynPtrAdj set to 0x5 per BKDG (needs reset) */
273 pci_write_config32(dev, 0xdc, dword);
277 static void config_acpi_pwr_state_ctrl_regs(device_t dev) {
278 /* Rev B settings - FIXME: support other revs. */
279 u32 dword = 0xA0E641E6;
280 pci_write_config32(dev, 0x84, dword);
282 pci_write_config32(dev, 0x80, dword);
286 static void prep_fid_change(void)
293 /* This needs to be run before any Pstate changes are requested */
297 for (i = 0; i < nodes; i++) {
298 printk(BIOS_DEBUG, "Prep FID/VID Node:%02x \n", i);
299 dev = NODE_PCI(i, 3);
302 /* BKDG r31116 2010-04-22 2.4.1.7 step b F3xD8[VSSlamTime] */
303 /* Figure out the value for VsSlamTime and program it */
304 recalculateVsSlamTimeSettingOnCorePre(dev);
306 config_clk_power_ctrl_reg0(i);
308 config_power_ctrl_misc_reg(dev);
310 config_nb_syn_ptr_adj(dev);
312 config_acpi_pwr_state_ctrl_regs(dev);
314 dword = pci_read_config32(dev, 0x80);
315 printk(BIOS_DEBUG, " F3x80: %08x \n", dword);
316 dword = pci_read_config32(dev, 0x84);
317 printk(BIOS_DEBUG, " F3x84: %08x \n", dword);
318 dword = pci_read_config32(dev, 0xD4);
319 printk(BIOS_DEBUG, " F3xD4: %08x \n", dword);
320 dword = pci_read_config32(dev, 0xD8);
321 printk(BIOS_DEBUG, " F3xD8: %08x \n", dword);
322 dword = pci_read_config32(dev, 0xDC);
323 printk(BIOS_DEBUG, " F3xDC: %08x \n", dword);
330 static void UpdateSinglePlaneNbVid(void)
336 /* copy higher voltage (lower VID) of NBVID & CPUVID to both */
337 for (i = 0; i < 5; i++) {
338 msr = rdmsr(PS_REG_BASE + i);
339 nbVid = (msr.lo & PS_CPU_VID_M_ON) >> PS_CPU_VID_SHFT;
340 cpuVid = (msr.lo & PS_NB_VID_M_ON) >> PS_NB_VID_SHFT;
342 if (nbVid != cpuVid) {
346 msr.lo = msr.lo & PS_BOTH_VID_OFF;
347 msr.lo = msr.lo | (u32) ((nbVid) << PS_NB_VID_SHFT);
348 msr.lo = msr.lo | (u32) ((nbVid) << PS_CPU_VID_SHFT);
349 wrmsr(PS_REG_BASE + i, msr);
354 static void fixPsNbVidBeforeWR(u32 newNbVid, u32 coreid)
359 /* This function sets NbVid before the warm reset.
360 * Get StartupPstate from MSRC001_0071.
361 * Read Pstate register pionted by [StartupPstate].
362 * and copy its content to P0 and P1 registers.
363 * Copy newNbVid to P0[NbVid].
364 * transition to P1 on all cores,
365 * then transition to P0 on core 0.
366 * Wait for MSRC001_0063[CurPstate] = 000b on core 0.
369 msr = rdmsr(0xc0010071);
370 startup_pstate = (msr.hi >> (32 - 32)) & 0x07;
372 /* Copy startup pstate to P1 and P0 MSRs. Set the maxvid for this node in P0.
373 * Then transition to P1 for corex and P0 for core0.
374 * These setting will be cleared by the warm reset
376 msr = rdmsr(0xC0010064 + startup_pstate);
377 wrmsr(0xC0010065, msr);
378 wrmsr(0xC0010064, msr);
380 msr.lo &= ~0xFE000000; // clear nbvid
381 msr.lo |= newNbVid << 25;
382 wrmsr(0xC0010064, msr);
384 UpdateSinglePlaneNbVid();
386 // Transition to P1 for all APs and P0 for core0.
387 msr = rdmsr(0xC0010062);
388 msr.lo = (msr.lo & ~0x07) | 1;
389 wrmsr(0xC0010062, msr);
391 // Wait for P1 to set.
393 msr = rdmsr(0xC0010063);
394 } while (msr.lo != 1);
397 msr.lo = msr.lo & ~0x07;
398 wrmsr(0xC0010062, msr);
399 // Wait for P0 to set.
401 msr = rdmsr(0xC0010063);
402 } while (msr.lo != 0);
406 static void coreDelay(void)
413 This seems like a hack to me...
414 It would be nice to have a central delay function. */
416 cycles = 8000 << 3; /* x8 (number of 1.25ns ticks) */
418 msr = 0x10; /* TSC */
419 _RDMSR(msr, &lo, &hi);
422 _RDMSR(msr, &lo, &hi);
423 } while (lo - saved < cycles);
426 static void transitionVid(u32 targetVid, u8 dev, u8 isNb)
428 u32 currentVid, dtemp;
431 u16 timeTable[8] = { 10, 20, 30, 40, 60, 100, 200, 500 };
434 /* This function steps or slam the Nb VID to the target VID.
435 * It uses VSRampTime for [SlamVidMode]=0 ([PviMode]=1)
436 * or VSSlamTime for [SlamVidMode]=1 ([PviMode]=0)to time period.
439 /* get the current VID */
440 msr = rdmsr(0xC0010071);
442 currentVid = (msr.lo >> NB_VID_POS) & BIT_MASK_7;
444 currentVid = (msr.lo >> CPU_VID_POS) & BIT_MASK_7;
446 /* Read MSRC001_0070 COFVID Control Register */
447 msr = rdmsr(0xC0010070);
450 dtemp = pci_read_config32(dev, 0xA0);
451 if (dtemp & PVI_MODE) { /* PVI, step VID */
452 if (currentVid < targetVid) {
453 while (currentVid < targetVid) {
456 msr.lo = (msr.lo & NB_VID_MASK_OFF) | (currentVid << NB_VID_POS);
458 msr.lo = (msr.lo & CPU_VID_MASK_OFF) | (currentVid << CPU_VID_POS);
459 wrmsr(0xC0010070, msr);
461 /* read F3xD8[VSRampTime] */
462 dtemp = pci_read_config32(dev, 0xD8);
463 vsTimecode = (u8) ((dtemp >> VS_RAMP_T) & 0x7);
464 vsTime = (int)timeTable[vsTimecode];
468 } while (vsTime > 0);
470 } else if (currentVid > targetVid) {
471 while (currentVid > targetVid) {
474 msr.lo = (msr.lo & NB_VID_MASK_OFF) | (currentVid << NB_VID_POS);
476 msr.lo = (msr.lo & CPU_VID_MASK_OFF) | (currentVid << CPU_VID_POS);
477 wrmsr(0xC0010070, msr);
479 /* read F3xD8[VSRampTime] */
480 dtemp = pci_read_config32(dev, 0xD8);
481 vsTimecode = (u8) ((dtemp >> VS_RAMP_T) & 0x7);
482 vsTime = (int)timeTable[vsTimecode];
486 } while (vsTime > 0);
489 } else { /* SVI, slam VID */
491 msr.lo = (msr.lo & NB_VID_MASK_OFF) | (targetVid << NB_VID_POS);
493 msr.lo = (msr.lo & CPU_VID_MASK_OFF) | (targetVid << CPU_VID_POS);
494 wrmsr(0xC0010070, msr);
496 /* read F3xD8[VSRampTime] */
497 dtemp = pci_read_config32(dev, 0xD8);
498 vsTimecode = (u8) ((dtemp >> VS_RAMP_T) & 0x7);
499 vsTime = (int)timeTable[vsTimecode];
503 } while (vsTime > 0);
507 static u32 needs_NB_COF_VID_update(void)
509 u8 nb_cof_vid_update;
513 /* If any node has nb_cof_vid_update set all nodes need an update. */
515 nb_cof_vid_update = 0;
516 for (i = 0; i < nodes; i++) {
517 if (pci_read_config32(NODE_PCI(i, 3), 0x1FC) & 1) {
518 nb_cof_vid_update = 1;
522 return nb_cof_vid_update;
525 static void init_fidvid_ap(u32 bsp_apicid, u32 apicid, u32 nodeid, u32 coreid)
530 u8 nb_cof_vid_update = needs_NB_COF_VID_update();
535 printk(BIOS_DEBUG, "FIDVID on AP: %02x\n", apicid);
537 /* Steps 1-6 of BIOS NB COF and VID Configuration
538 * for SVI and Single-Plane PVI Systems.
543 dev = NODE_PCI(nodeid, 3);
544 pvimode = (pci_read_config32(dev, 0xA0) >> 8) & 1;
545 reg1fc = pci_read_config32(dev, 0x1FC);
547 if (nb_cof_vid_update) {
549 vid_max = (reg1fc >> 7) & 0x7F;
550 fid_max = (reg1fc >> 2) & 0x1F;
552 /* write newNbVid to P-state Reg's NbVid always if NbVidUpdatedAll=1 */
553 fixPsNbVidBeforeWR(vid_max, coreid);
555 vid_max = ((reg1fc >> 7) & 0x7F) - ((reg1fc >> 17) & 0x1F);
556 fid_max = ((reg1fc >> 2) & 0x1F) + ((reg1fc >> 14) & 0x7);
557 transitionVid(vid_max, dev, IS_NB);
560 /* fid setup is handled by the BSP at the end. */
562 } else { /* ! nb_cof_vid_update */
565 UpdateSinglePlaneNbVid();
568 send = (nb_cof_vid_update << 16) | (fid_max << 8);
569 send |= (apicid << 24); // ap apicid
571 // Send signal to BSP about this AP max fid
572 // This also indicates this AP is ready for warm reset (if required).
573 lapic_write(LAPIC_MSG_REG, send | F10_APSTATE_RESET);
576 static u32 calc_common_fid(u32 fid_packed, u32 fid_packed_new)
581 fidmax = (fid_packed >> 8) & 0xFF;
583 fidmax_new = (fid_packed_new >> 8) & 0xFF;
585 if (fidmax > fidmax_new) {
589 fid_packed &= 0xFF << 16;
590 fid_packed |= (fidmax << 8);
591 fid_packed |= fid_packed_new & (0xFF << 16); // set nb_cof_vid_update
596 static void init_fidvid_bsp_stage1(u32 ap_apicid, void *gp)
601 struct fidvid_st *fvp = gp;
604 print_debug_fv("Wait for AP stage 1: ap_apicid = ", ap_apicid);
608 if (lapic_remote_read(ap_apicid, LAPIC_MSG_REG, &readback) != 0)
610 if ((readback & 0x3f) == 1) {
612 break; /* target ap is in stage 1 */
617 printk(BIOS_DEBUG, "%s: timed out reading from ap %02x\n",
618 __func__, ap_apicid);
622 print_debug_fv("\treadback = ", readback);
624 fvp->common_fid = calc_common_fid(fvp->common_fid, readback);
626 print_debug_fv("\tcommon_fid(packed) = ", fvp->common_fid);
630 static void updateSviPsNbVidAfterWR(u32 newNbVid)
635 /* This function copies newNbVid to NbVid bits in P-state Registers[4:0]
639 for (i = 0; i < 5; i++) {
640 msr = rdmsr(0xC0010064 + i);
641 if ((msr.hi >> 31) & 1) { /* PstateEn? */
642 msr.lo &= ~(0x7F << 25);
643 msr.lo |= (newNbVid & 0x7F) << 25;
644 wrmsr(0xC0010064 + i, msr);
650 static void fixPsNbVidAfterWR(u32 newNbVid, u8 NbVidUpdatedAll)
656 /* This function copies newNbVid to NbVid bits in P-state
657 * Registers[4:0] if its NbDid bit=0 and PstateEn bit =1 in case of
658 * NbVidUpdatedAll =0 or copies copies newNbVid to NbVid bits in
659 * P-state Registers[4:0] if its and PstateEn bit =1 in case of
660 * NbVidUpdatedAll=1. Then transition to StartPstate.
663 /* write newNbVid to P-state Reg's NbVid if its NbDid=0 */
664 for (i = 0; i < 5; i++) {
665 msr = rdmsr(0xC0010064 + i);
666 /* NbDid (bit 22 of P-state Reg) == 0 or NbVidUpdatedAll = 1 */
667 if ((((msr.lo >> 22) & 1) == 0) || NbVidUpdatedAll) {
668 msr.lo &= ~(0x7F << 25);
669 msr.lo |= (newNbVid & 0x7F) << 25;
670 wrmsr(0xC0010064 + i, msr);
674 UpdateSinglePlaneNbVid();
676 /* For each core in the system, transition all cores to StartupPstate */
677 msr = rdmsr(0xC0010071);
678 StartupPstate = msr.hi & 0x07;
679 msr = rdmsr(0xC0010062);
680 msr.lo = StartupPstate;
681 wrmsr(0xC0010062, msr);
683 /* Wait for StartupPstate to set. */
685 msr = rdmsr(0xC0010063);
686 } while (msr.lo != StartupPstate);
689 static void set_p0(void)
693 // Transition P0 for calling core.
694 msr = rdmsr(0xC0010062);
695 msr.lo = (msr.lo & ~0x07);
696 wrmsr(0xC0010062, msr);
698 /* Wait for P0 to set. */
700 msr = rdmsr(0xC0010063);
701 } while (msr.lo != 0);
704 static void finalPstateChange(void)
706 /* Enble P0 on all cores for best performance.
707 * Linux can slow them down later if need be.
708 * It is safe since they will be in C1 halt
709 * most of the time anyway.
714 static void init_fidvid_stage2(u32 apicid, u32 nodeid)
721 u8 nb_cof_vid_update = needs_NB_COF_VID_update();
725 /* After warm reset finish the fid/vid setup for all cores. */
727 /* If any node has nb_cof_vid_update set all nodes need an update. */
729 dev = NODE_PCI(nodeid, 3);
730 pvimode = (pci_read_config32(dev, 0xA0) >> 8) & 1;
731 reg1fc = pci_read_config32(dev, 0x1FC);
732 nbvid = (reg1fc >> 7) & 0x7F;
733 NbVidUpdateAll = (reg1fc >> 1) & 1;
735 if (nb_cof_vid_update) {
737 nbvid = (reg1fc >> 7) & 0x7F;
738 /* write newNbVid to P-state Reg's NbVid if its NbDid=0 */
739 fixPsNbVidAfterWR(nbvid, NbVidUpdateAll);
741 nbvid = ((reg1fc >> 7) & 0x7F) - ((reg1fc >> 17) & 0x1F);
742 updateSviPsNbVidAfterWR(nbvid);
744 } else { /* !nb_cof_vid_update */
746 UpdateSinglePlaneNbVid();
748 dtemp = pci_read_config32(dev, 0xA0);
749 dtemp &= PLLLOCK_OFF;
750 dtemp |= PLLLOCK_DFT_L;
751 pci_write_config32(dev, 0xA0, dtemp);
755 /* Set TSC to tick at the P0 ndfid rate */
762 #if CONFIG_SET_FIDVID_STORE_AP_APICID_AT_FIRST
763 struct ap_apicid_st {
765 // it could use 256 bytes for 64 node quad core system
766 u8 apicid[NODE_NUMS * 4];
769 static void store_ap_apicid(unsigned ap_apicid, void *gp)
771 struct ap_apicid_st *p = gp;
773 p->apicid[p->num++] = ap_apicid;
779 static int init_fidvid_bsp(u32 bsp_apicid, u32 nodes)
781 #if CONFIG_SET_FIDVID_STORE_AP_APICID_AT_FIRST
782 struct ap_apicid_st ap_apicidx;
789 u8 nb_cof_vid_update = needs_NB_COF_VID_update();
793 printk(BIOS_DEBUG, "FIDVID on BSP, APIC_id: %02x\n", bsp_apicid);
794 /* FIXME: The first half of this function is nearly the same as
795 * init_fidvid_bsp() and the code could be combined.
798 /* Steps 1-6 of BIOS NB COF and VID Configuration
799 * for SVI and Single-Plane PVI Systems.
802 dev = NODE_PCI(0, 3);
803 pvimode = (pci_read_config32(dev, 0xA0) >> 8) & 1;
804 reg1fc = pci_read_config32(dev, 0x1FC);
806 if (nb_cof_vid_update) {
808 vid_max = (reg1fc >> 7) & 0x7F;
809 fid_max = (reg1fc >> 2) & 0x1F;
811 /* write newNbVid to P-state Reg's NbVid always if NbVidUpdatedAll=1 */
812 fixPsNbVidBeforeWR(vid_max, 0);
814 vid_max = ((reg1fc >> 7) & 0x7F) - ((reg1fc >> 17) & 0x1F);
815 fid_max = ((reg1fc >> 2) & 0x1F) + ((reg1fc >> 14) & 0x7);
816 transitionVid(vid_max, dev, IS_NB);
819 /* fid setup is handled by the BSP at the end. */
821 } else { /* ! nb_cof_vid_update */
824 UpdateSinglePlaneNbVid();
827 fv.common_fid = (nb_cof_vid_update << 16) | (fid_max << 8);
828 print_debug_fv("BSP fid = ", fv.common_fid);
830 #if CONFIG_SET_FIDVID_STORE_AP_APICID_AT_FIRST && !CONFIG_SET_FIDVID_CORE0_ONLY
831 /* For all APs (We know the APIC ID of all APs even when the APIC ID
832 is lifted) remote read from AP LAPIC_MSG_REG about max fid.
833 Then calculate the common max fid that can be used for all
837 for_each_ap(bsp_apicid, CONFIG_SET_FIDVID_CORE_RANGE, store_ap_apicid, &ap_apicidx);
839 for (i = 0; i < ap_apicidx.num; i++) {
840 init_fidvid_bsp_stage1(ap_apicidx.apicid[i], &fv);
843 for_each_ap(bsp_apicid, CONFIG_SET_FIDVID_CORE0_ONLY, init_fidvid_bsp_stage1, &fv);
846 print_debug_fv("common_fid = ", fv.common_fid);
848 if (fv.common_fid & (1 << 16)) { /* check nb_cof_vid_update */
850 // Enable the common fid and other settings.
851 enable_fid_change((fv.common_fid >> 8) & 0x1F);
853 // nbfid change need warm reset, so reset at first
857 return 0; // No FID/VID changes. Don't reset