summaryrefslogtreecommitdiff
path: root/ReferenceCode/Chipset/SystemAgent/MemoryInit/Pei/Source/McConfiguration/MrcSchedulerParameters.c
blob: 58d5e77801f1059a47120a6c83d85edf23d75137 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/** @file
  This module configures the memory controller scheduler.

@copyright
  Copyright (c) 1999 - 2013 Intel Corporation. All rights reserved.

  This software and associated documentation (if any) is furnished
  under a license and may only be used or copied in accordance
  with the terms of the license. Except as permitted by such
  license, no part of this software or documentation may be
  reproduced, stored in a retrieval system, or transmitted in any
  form or by any means without the express written consent of
  Intel Corporation.

  This file contains an 'Intel Peripheral Driver' and uniquely
  identified as "Intel Reference Module" and is
  licensed for Intel CPUs and chipsets under the terms of your
  license agreement with Intel or your vendor.  This file may
  be modified by the user, subject to additional terms of the
  license agreement.
**/

//
// Include files
//
#include "MrcSchedulerParameters.h"

/**
@brief
  This function configures the memory controller scheduler.

  @param[in] MrcData - Include all MRC global data.

  @retval Nothing.
**/
void
MrcSchedulerParametersConfig (
  IN MrcParameters *const MrcData
  )
{
  const MrcInput                       *Inputs;
  MrcOutput                            *Outputs;
  MCSCHEDS_CR_SCHED_CBIT_STRUCT        SchedCbit;
  MCSCHEDS_CR_SCHED_SECOND_CBIT_STRUCT SchedSecondCbit;
  U8                                   Channel;
  U32                                  Offset;
#ifdef ULT_FLAG
  MCHBAR_CH0_CR_CMD_RATE_STRUCT        CmdRate;
#endif // ULT_FLAG

  Inputs  = &MrcData->SysIn.Inputs;
  Outputs = &MrcData->SysOut.Outputs;
  Channel = 0;
  Offset  = 0;
  if ((Inputs->CpuModel == cmHSW) && (Inputs->CpuStepping == csHswA0)) {
    SchedCbit.Data = SCHED_CBIT_DEFAULT;
  } else {
    SchedCbit.Data = SCHED_CBIT_DEFAULT_B0;
  }
#ifdef ULT_FLAG
  if (Inputs->CpuModel == cmHSW_ULT) {
    SchedCbit.Bits.dis_odt = 1;
    if (Outputs->DdrType == MRC_DDR_TYPE_LPDDR3) {
      //
      // LPDDR3 DDP and QDP (multi-die) packages share the same ZQ pin,
      // so we need to serialize the ZQ calibration for different ranks.
      //
      SchedCbit.Bits.Serialize_ZQ = 1;

      if (Inputs->LpddrDramOdt) {
        //
        // DRAM ODT is used
        //
        SchedCbit.Bits.dis_odt = 0;
      }
    }
  }
#endif

  MrcWriteCrMulticast (MrcData, MCSCHEDS_CR_SCHED_CBIT_REG, SchedCbit.Data);

  MrcWriteCrMulticast (MrcData, MCMNTS_CR_SC_WDBWM_REG, SC_WDBWM_DEFAULT);

  if (Outputs->AsyncOdtDis) {
    SchedSecondCbit.Data                = 0;
    SchedSecondCbit.Bits.dis_async_odt  = 1;
    MrcWriteCR8 (MrcData, MCSCHEDS_CR_SCHED_SECOND_CBIT_REG + 1, SchedSecondCbit.Data8[1]);
  }

#ifdef ULT_FLAG
  //
  // For LPDDR3, set Command Rate Limit to 3
  //
  if (Outputs->DdrType == MRC_DDR_TYPE_LPDDR3) {
    for (Channel = 0; Channel < MAX_CHANNEL; Channel++) {
      if (MrcChannelExist (Outputs, Channel)) {
        Offset = MCHBAR_CH0_CR_CMD_RATE_REG + ((MCHBAR_CH1_CR_CMD_RATE_REG - MCHBAR_CH0_CR_CMD_RATE_REG) * Channel);
        CmdRate.Data = MrcReadCR (MrcData, Offset);
        CmdRate.Bits.enable_cmd_rate_limit  = 1;
        CmdRate.Bits.cmd_rate_limit         = 3;
        MrcWriteCR (MrcData, Offset, CmdRate.Data);
      }
    }
  }
#endif


  return;
}