blob: d8b91956c728720e1d1137ebfe91de71537595d9 [file] [log] [blame]
Patrick Georgiac959032020-05-05 22:49:26 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Vladimir Serbinenko1cd937b2014-01-09 23:41:48 +01002
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 Serbinenko1cd937b2014-01-09 23:41:48 +01005#include "pch.h"
Vladimir Serbinenko2bebc802014-02-19 22:02:51 +01006#include "cpu/intel/model_2065x/model_2065x.h"
7#include <cpu/x86/msr.h>
Vladimir Serbinenko1cd937b2014-01-09 23:41:48 +01008
9/* Early thermal init, must be done prior to giving ME its memory
10 which is done at the end of raminit. */
11void early_thermal_init(void)
12{
Antonello Dettori040117a2016-09-02 09:15:33 +020013 pci_devfn_t dev;
Vladimir Serbinenko2bebc802014-02-19 22:02:51 +010014 msr_t msr;
Vladimir Serbinenko1cd937b2014-01-09 23:41:48 +010015
16 dev = PCI_DEV(0x0, 0x1f, 0x6);
17
18 /* Program address for temporary BAR. */
19 pci_write_config32(dev, 0x40, 0x40000000);
20 pci_write_config32(dev, 0x44, 0x0);
21
22 /* Activate temporary BAR. */
23 pci_write_config32(dev, 0x40,
24 pci_read_config32(dev, 0x40) | 5);
25
26 /* Perform init. */
Vladimir Serbinenko2bebc802014-02-19 22:02:51 +010027 /* Configure TJmax. */
28 msr = rdmsr(MSR_TEMPERATURE_TARGET);
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080029 write16((u16 *)0x40000012, ((msr.lo >> 16) & 0xff) << 6);
Vladimir Serbinenko2bebc802014-02-19 22:02:51 +010030 /* Northbridge temperature slope and offset. */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080031 write16((u16 *)0x40000016, 0x7746);
Vladimir Serbinenko2bebc802014-02-19 22:02:51 +010032 /* Enable thermal data reporting, processor, PCH and northbridge. */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080033 write16((u16 *)0x4000001a,
34 (read16((u16 *)0x4000001a) & ~0xf) | 0x10f0);
Vladimir Serbinenko1cd937b2014-01-09 23:41:48 +010035
36 /* Disable temporary BAR. */
37 pci_write_config32(dev, 0x40,
38 pci_read_config32(dev, 0x40) & ~1);
39 pci_write_config32(dev, 0x40, 0);
40}