Angel Pons | a019524 | 2020-04-01 13:34:54 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Vladimir Serbinenko | 7686a56 | 2014-05-18 11:05:56 +0200 | [diff] [blame] | 2 | |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 3 | #include <device/mmio.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 4 | #include <device/pci_ops.h> |
Vladimir Serbinenko | 7686a56 | 2014-05-18 11:05:56 +0200 | [diff] [blame] | 5 | #include "pch.h" |
| 6 | #include "cpu/intel/model_206ax/model_206ax.h" |
| 7 | #include <cpu/x86/msr.h> |
| 8 | |
Angel Pons | 1efa7d9 | 2020-05-07 00:59:32 +0200 | [diff] [blame] | 9 | /* Temporary address for the thermal BAR */ |
| 10 | #define TBARB_TEMP 0x40000000 |
| 11 | |
Vladimir Serbinenko | 7686a56 | 2014-05-18 11:05:56 +0200 | [diff] [blame] | 12 | /* Early thermal init, must be done prior to giving ME its memory |
Angel Pons | ec99cd9 | 2021-01-28 14:20:36 +0100 | [diff] [blame] | 13 | which is done at the end of raminit */ |
Vladimir Serbinenko | 7686a56 | 2014-05-18 11:05:56 +0200 | [diff] [blame] | 14 | void early_thermal_init(void) |
| 15 | { |
Angel Pons | ec99cd9 | 2021-01-28 14:20:36 +0100 | [diff] [blame] | 16 | const pci_devfn_t dev = PCH_THERMAL_DEV; |
Vladimir Serbinenko | 7686a56 | 2014-05-18 11:05:56 +0200 | [diff] [blame] | 17 | |
Angel Pons | ec99cd9 | 2021-01-28 14:20:36 +0100 | [diff] [blame] | 18 | /* Program address for temporary BAR */ |
Angel Pons | 1efa7d9 | 2020-05-07 00:59:32 +0200 | [diff] [blame] | 19 | pci_write_config32(dev, 0x40, TBARB_TEMP); |
Vladimir Serbinenko | 7686a56 | 2014-05-18 11:05:56 +0200 | [diff] [blame] | 20 | pci_write_config32(dev, 0x44, 0x0); |
| 21 | |
Angel Pons | ec99cd9 | 2021-01-28 14:20:36 +0100 | [diff] [blame] | 22 | /* Activate temporary BAR */ |
Angel Pons | c803f65 | 2020-06-07 22:09:01 +0200 | [diff] [blame] | 23 | pci_or_config32(dev, 0x40, 5); |
Vladimir Serbinenko | 7686a56 | 2014-05-18 11:05:56 +0200 | [diff] [blame] | 24 | |
Angel Pons | 1efa7d9 | 2020-05-07 00:59:32 +0200 | [diff] [blame] | 25 | write16p(TBARB_TEMP + 0x04, 0x3a2b); |
Vladimir Serbinenko | 7686a56 | 2014-05-18 11:05:56 +0200 | [diff] [blame] | 26 | |
Angel Pons | 1efa7d9 | 2020-05-07 00:59:32 +0200 | [diff] [blame] | 27 | 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 Serbinenko | 7686a56 | 2014-05-18 11:05:56 +0200 | [diff] [blame] | 32 | |
Angel Pons | ec99cd9 | 2021-01-28 14:20:36 +0100 | [diff] [blame] | 33 | /* Perform init */ |
| 34 | /* Configure TJmax */ |
| 35 | const msr_t msr = rdmsr(MSR_TEMPERATURE_TARGET); |
Angel Pons | 1efa7d9 | 2020-05-07 00:59:32 +0200 | [diff] [blame] | 36 | write16p(TBARB_TEMP + 0x12, ((msr.lo >> 16) & 0xff) << 6); |
Angel Pons | 6cd6e71 | 2020-05-07 00:54:42 +0200 | [diff] [blame] | 37 | /* Northbridge temperature slope and offset */ |
Angel Pons | 1efa7d9 | 2020-05-07 00:59:32 +0200 | [diff] [blame] | 38 | write16p(TBARB_TEMP + 0x16, 0x808c); |
Vladimir Serbinenko | 7686a56 | 2014-05-18 11:05:56 +0200 | [diff] [blame] | 39 | |
Angel Pons | 1efa7d9 | 2020-05-07 00:59:32 +0200 | [diff] [blame] | 40 | write16p(TBARB_TEMP + 0x14, 0xde87); |
Vladimir Serbinenko | 7686a56 | 2014-05-18 11:05:56 +0200 | [diff] [blame] | 41 | |
Angel Pons | 6cd6e71 | 2020-05-07 00:54:42 +0200 | [diff] [blame] | 42 | /* Enable thermal data reporting, processor, PCH and northbridge */ |
Angel Pons | 1efa7d9 | 2020-05-07 00:59:32 +0200 | [diff] [blame] | 43 | write16p(TBARB_TEMP + 0x1a, (read16p(TBARB_TEMP + 0x1a) & ~0xf) | 0x10f0); |
Vladimir Serbinenko | 7686a56 | 2014-05-18 11:05:56 +0200 | [diff] [blame] | 44 | |
Angel Pons | 6cd6e71 | 2020-05-07 00:54:42 +0200 | [diff] [blame] | 45 | /* Disable temporary BAR */ |
Angel Pons | c803f65 | 2020-06-07 22:09:01 +0200 | [diff] [blame] | 46 | pci_and_config32(dev, 0x40, ~1); |
| 47 | |
Vladimir Serbinenko | 7686a56 | 2014-05-18 11:05:56 +0200 | [diff] [blame] | 48 | pci_write_config32(dev, 0x40, 0); |
| 49 | |
Angel Pons | ec99cd9 | 2021-01-28 14:20:36 +0100 | [diff] [blame] | 50 | RCBA32_AND_OR(0x38b0, 0xffff8003, 0x403c); |
Vladimir Serbinenko | 7686a56 | 2014-05-18 11:05:56 +0200 | [diff] [blame] | 51 | } |