blob: e765943b2471c6e194997c51d5cd3168b1062440 [file] [log] [blame]
Vladimir Serbinenko1cd937b2014-01-09 23:41:48 +01001/*
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 Serbinenko2bebc802014-02-19 22:02:51 +010023#include "cpu/intel/model_2065x/model_2065x.h"
24#include <cpu/x86/msr.h>
Vladimir Serbinenko1cd937b2014-01-09 23:41:48 +010025
26/* Early thermal init, must be done prior to giving ME its memory
27 which is done at the end of raminit. */
28void early_thermal_init(void)
29{
30 device_t dev;
Vladimir Serbinenko2bebc802014-02-19 22:02:51 +010031 msr_t msr;
Vladimir Serbinenko1cd937b2014-01-09 23:41:48 +010032
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 Serbinenko2bebc802014-02-19 22:02:51 +010044 /* Configure TJmax. */
45 msr = rdmsr(MSR_TEMPERATURE_TARGET);
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080046 write16((u16 *)0x40000012, ((msr.lo >> 16) & 0xff) << 6);
Vladimir Serbinenko2bebc802014-02-19 22:02:51 +010047 /* Northbridge temperature slope and offset. */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080048 write16((u16 *)0x40000016, 0x7746);
Vladimir Serbinenko2bebc802014-02-19 22:02:51 +010049 /* Enable thermal data reporting, processor, PCH and northbridge. */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080050 write16((u16 *)0x4000001a,
51 (read16((u16 *)0x4000001a) & ~0xf) | 0x10f0);
Vladimir Serbinenko1cd937b2014-01-09 23:41:48 +010052
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}