coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
imc.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include "imc.h"
4 #include <amdblocks/acpimmio.h>
5 #include <device/mmio.h>
6 #include <Porting.h>
7 #include <AGESA.h>
8 #include <amdlib.h>
9 #include <Proc/Fch/Fch.h>
10 #include <Proc/Fch/Common/FchCommonCfg.h>
11 #include <Proc/Fch/FchPlatform.h>
12 
13 void imc_reg_init(void)
14 {
15  /* Init Power Management Block 2 (PM2) Registers.
16  * Check BKDG for AMD Family 16h for details. */
17  pm2_write8(0, 0x06);
18  pm2_write8(1, 0x06);
19  pm2_write8(2, 0xf7);
20  pm2_write8(3, 0xff);
21  pm2_write8(4, 0xff);
22 
23 #if !CONFIG(SOUTHBRIDGE_AMD_AGESA_YANGTZE)
24  pm2_write8(0x10, 0x06);
25  pm2_write8(0x11, 0x06);
26  pm2_write8(0x12, 0xf7);
27  pm2_write8(0x13, 0xff);
28  pm2_write8(0x14, 0xff);
29 #endif
30 
31 #if CONFIG(SOUTHBRIDGE_AMD_AGESA_YANGTZE)
32  UINT8 PciData;
33  PCI_ADDR PciAddress;
34  AMD_CONFIG_PARAMS StdHeader;
35  PciAddress.AddressValue = MAKE_SBDFO (0, 0, 0x18, 0x3, 0x1E4);
36  LibAmdPciRead(AccessWidth8, PciAddress, &PciData, &StdHeader);
37  PciData &= (UINT8)0x8F;
38  PciData |= 0x10;
39  LibAmdPciWrite(AccessWidth8, PciAddress, &PciData, &StdHeader);
40 #endif
41 }
42 
44 {
45  AMD_CONFIG_PARAMS StdHeader;
46  UINT8 FunNum;
47  UINT8 regs[10];
48  int i;
49 
50  regs[0] = 0;
51  regs[1] = 0;
52  FunNum = Fun_80;
53  for (i = 0; i <= 1; i++)
54  WriteECmsg(MSG_REG0 + i, AccessWidth8, &regs[i], &StdHeader);
55  WriteECmsg(MSG_SYS_TO_IMC, AccessWidth8, &FunNum, &StdHeader); // function number
56  WaitForEcLDN9MailboxCmdAck(&StdHeader);
57 
58  for (i = 2; i < ARRAY_SIZE(regs); i++)
59  ReadECmsg(MSG_REG0 + i, AccessWidth8, &regs[i], &StdHeader);
60 
61  /* enable thermal zone 0 */
62  regs[2] |= 1;
63  regs[0] = 0;
64  regs[1] = 0;
65  FunNum = Fun_81;
66  for (i = 0; i < ARRAY_SIZE(regs); i++)
67  WriteECmsg(MSG_REG0 + i, AccessWidth8, &regs[i], &StdHeader);
68  WriteECmsg(MSG_SYS_TO_IMC, AccessWidth8, &FunNum, &StdHeader); // function number
69  WaitForEcLDN9MailboxCmdAck(&StdHeader);
70 }
@ AccessWidth8
Access width is 8 bits.
Definition: Amd.h:60
static void pm2_write8(uint8_t reg, uint8_t value)
Definition: acpimmio.h:201
void imc_reg_init(void)
Definition: imc.c:13
void enable_imc_thermal_zone(void)
Definition: imc.c:43
#define ARRAY_SIZE(a)
Definition: helpers.h:12
The standard header for all AGESA services.
Definition: Amd.h:74