blob: 32ad3c204203ab49917b17f6d9498891631ee912 [file] [log] [blame]
Angel Ponsa0195242020-04-01 13:34:54 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Vladimir Serbinenko7686a562014-05-18 11:05:56 +02002
Kyösti Mälkki13f66502019-03-03 08:01:05 +02003#include <device/mmio.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02004#include <device/pci_ops.h>
Vladimir Serbinenko7686a562014-05-18 11:05:56 +02005#include "pch.h"
6#include "cpu/intel/model_206ax/model_206ax.h"
7#include <cpu/x86/msr.h>
8
Angel Pons1efa7d92020-05-07 00:59:32 +02009/* Temporary address for the thermal BAR */
10#define TBARB_TEMP 0x40000000
11
Vladimir Serbinenko7686a562014-05-18 11:05:56 +020012/* Early thermal init, must be done prior to giving ME its memory
Angel Ponsec99cd92021-01-28 14:20:36 +010013 which is done at the end of raminit */
Vladimir Serbinenko7686a562014-05-18 11:05:56 +020014void early_thermal_init(void)
15{
Angel Ponsec99cd92021-01-28 14:20:36 +010016 const pci_devfn_t dev = PCH_THERMAL_DEV;
Vladimir Serbinenko7686a562014-05-18 11:05:56 +020017
Angel Ponsec99cd92021-01-28 14:20:36 +010018 /* Program address for temporary BAR */
Angel Pons1efa7d92020-05-07 00:59:32 +020019 pci_write_config32(dev, 0x40, TBARB_TEMP);
Vladimir Serbinenko7686a562014-05-18 11:05:56 +020020 pci_write_config32(dev, 0x44, 0x0);
21
Angel Ponsec99cd92021-01-28 14:20:36 +010022 /* Activate temporary BAR */
Angel Ponsc803f652020-06-07 22:09:01 +020023 pci_or_config32(dev, 0x40, 5);
Vladimir Serbinenko7686a562014-05-18 11:05:56 +020024
Angel Pons1efa7d92020-05-07 00:59:32 +020025 write16p(TBARB_TEMP + 0x04, 0x3a2b);
Vladimir Serbinenko7686a562014-05-18 11:05:56 +020026
Angel Pons1efa7d92020-05-07 00:59:32 +020027 write8p(TBARB_TEMP + 0x0c, 0xff);
28 write8p(TBARB_TEMP + 0x0d, 0x00);
29 write8p(TBARB_TEMP + 0x0e, 0x40);
30 write8p(TBARB_TEMP + 0x82, 0x00);
31 write8p(TBARB_TEMP + 0x01, 0xba);
Vladimir Serbinenko7686a562014-05-18 11:05:56 +020032
Angel Ponsec99cd92021-01-28 14:20:36 +010033 /* Perform init */
34 /* Configure TJmax */
35 const msr_t msr = rdmsr(MSR_TEMPERATURE_TARGET);
Angel Pons1efa7d92020-05-07 00:59:32 +020036 write16p(TBARB_TEMP + 0x12, ((msr.lo >> 16) & 0xff) << 6);
Angel Pons6cd6e712020-05-07 00:54:42 +020037 /* Northbridge temperature slope and offset */
Angel Pons1efa7d92020-05-07 00:59:32 +020038 write16p(TBARB_TEMP + 0x16, 0x808c);
Vladimir Serbinenko7686a562014-05-18 11:05:56 +020039
Angel Pons1efa7d92020-05-07 00:59:32 +020040 write16p(TBARB_TEMP + 0x14, 0xde87);
Vladimir Serbinenko7686a562014-05-18 11:05:56 +020041
Angel Pons6cd6e712020-05-07 00:54:42 +020042 /* Enable thermal data reporting, processor, PCH and northbridge */
Angel Pons1efa7d92020-05-07 00:59:32 +020043 write16p(TBARB_TEMP + 0x1a, (read16p(TBARB_TEMP + 0x1a) & ~0xf) | 0x10f0);
Vladimir Serbinenko7686a562014-05-18 11:05:56 +020044
Angel Pons6cd6e712020-05-07 00:54:42 +020045 /* Disable temporary BAR */
Angel Ponsc803f652020-06-07 22:09:01 +020046 pci_and_config32(dev, 0x40, ~1);
47
Vladimir Serbinenko7686a562014-05-18 11:05:56 +020048 pci_write_config32(dev, 0x40, 0);
49
Angel Ponsec99cd92021-01-28 14:20:36 +010050 RCBA32_AND_OR(0x38b0, 0xffff8003, 0x403c);
Vladimir Serbinenko7686a562014-05-18 11:05:56 +020051}