Vladimir Serbinenko | 1cd937b | 2014-01-09 23:41:48 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2014 Vladimir Serbinenko |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation; version 2 of |
| 9 | * the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | |
| 21 | #include <arch/io.h> |
| 22 | #include "pch.h" |
Vladimir Serbinenko | 2bebc80 | 2014-02-19 22:02:51 +0100 | [diff] [blame] | 23 | #include "cpu/intel/model_2065x/model_2065x.h" |
| 24 | #include <cpu/x86/msr.h> |
Vladimir Serbinenko | 1cd937b | 2014-01-09 23:41:48 +0100 | [diff] [blame] | 25 | |
| 26 | /* Early thermal init, must be done prior to giving ME its memory |
| 27 | which is done at the end of raminit. */ |
| 28 | void early_thermal_init(void) |
| 29 | { |
| 30 | device_t dev; |
Vladimir Serbinenko | 2bebc80 | 2014-02-19 22:02:51 +0100 | [diff] [blame] | 31 | msr_t msr; |
Vladimir Serbinenko | 1cd937b | 2014-01-09 23:41:48 +0100 | [diff] [blame] | 32 | |
| 33 | dev = PCI_DEV(0x0, 0x1f, 0x6); |
| 34 | |
| 35 | /* Program address for temporary BAR. */ |
| 36 | pci_write_config32(dev, 0x40, 0x40000000); |
| 37 | pci_write_config32(dev, 0x44, 0x0); |
| 38 | |
| 39 | /* Activate temporary BAR. */ |
| 40 | pci_write_config32(dev, 0x40, |
| 41 | pci_read_config32(dev, 0x40) | 5); |
| 42 | |
| 43 | /* Perform init. */ |
Vladimir Serbinenko | 2bebc80 | 2014-02-19 22:02:51 +0100 | [diff] [blame] | 44 | /* Configure TJmax. */ |
| 45 | msr = rdmsr(MSR_TEMPERATURE_TARGET); |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame^] | 46 | write16((u16 *)0x40000012, ((msr.lo >> 16) & 0xff) << 6); |
Vladimir Serbinenko | 2bebc80 | 2014-02-19 22:02:51 +0100 | [diff] [blame] | 47 | /* Northbridge temperature slope and offset. */ |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame^] | 48 | write16((u16 *)0x40000016, 0x7746); |
Vladimir Serbinenko | 2bebc80 | 2014-02-19 22:02:51 +0100 | [diff] [blame] | 49 | /* Enable thermal data reporting, processor, PCH and northbridge. */ |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame^] | 50 | write16((u16 *)0x4000001a, |
| 51 | (read16((u16 *)0x4000001a) & ~0xf) | 0x10f0); |
Vladimir Serbinenko | 1cd937b | 2014-01-09 23:41:48 +0100 | [diff] [blame] | 52 | |
| 53 | /* Disable temporary BAR. */ |
| 54 | pci_write_config32(dev, 0x40, |
| 55 | pci_read_config32(dev, 0x40) & ~1); |
| 56 | pci_write_config32(dev, 0x40, 0); |
| 57 | } |