blob: 4d49af4f5bbf9496245a51571c7ee3c167efcc4e [file] [log] [blame]
Patrick Georgie72a8a32012-11-06 11:05:09 +01001/*
2 * This file is part of the coreboot project.
3 *
Patrick Georgie72a8a32012-11-06 11:05:09 +01004 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; version 2 of
8 * the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Patrick Georgie72a8a32012-11-06 11:05:09 +010014 */
15
Kyösti Mälkki13f66502019-03-03 08:01:05 +020016#include <device/mmio.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020017#include <device/pci_ops.h>
Patrick Georgie72a8a32012-11-06 11:05:09 +010018#include <device/device.h>
19#include <device/pci.h>
20#include <device/pci_ids.h>
21
22#include "i82801ix.h"
23
24static void thermal_init(struct device *dev)
25{
Kyösti Mälkkic70eed12018-05-22 02:18:00 +030026 if (LPC_IS_MOBILE(pcidev_on_root(0x1f, 0)))
Patrick Georgie72a8a32012-11-06 11:05:09 +010027 return;
28
29 u8 reg8;
30 u32 reg32;
31
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080032 pci_write_config32(dev, 0x10, (uintptr_t)DEFAULT_TBAR);
Patrick Georgie72a8a32012-11-06 11:05:09 +010033 reg32 = pci_read_config32(dev, 0x04);
34 pci_write_config32(dev, 0x04, reg32 | (1 << 1));
35
36 write32(DEFAULT_TBAR + 0x04, 0); /* Clear thermal trip points. */
37 write32(DEFAULT_TBAR + 0x44, 0);
38
39 write8(DEFAULT_TBAR + 0x01, 0xba); /* Enable sensor 0 + 1. */
40 write8(DEFAULT_TBAR + 0x41, 0xba);
41
42 reg8 = read8(DEFAULT_TBAR + 0x08); /* Lock thermal registers. */
43 write8(DEFAULT_TBAR + 0x08, reg8 | (1 << 7));
44 reg8 = read8(DEFAULT_TBAR + 0x48);
45 write8(DEFAULT_TBAR + 0x48, reg8 | (1 << 7));
46
47 reg32 = pci_read_config32(dev, 0x04);
48 pci_write_config32(dev, 0x04, reg32 & ~(1 << 1));
49 pci_write_config32(dev, 0x10, 0);
50}
51
Patrick Georgie72a8a32012-11-06 11:05:09 +010052static struct pci_operations thermal_pci_ops = {
Subrata Banik4a0f0712019-03-20 14:29:47 +053053 .set_subsystem = pci_dev_set_subsystem,
Patrick Georgie72a8a32012-11-06 11:05:09 +010054};
55
56static struct device_operations device_ops = {
57 .read_resources = pci_dev_read_resources,
58 .set_resources = pci_dev_set_resources,
59 .enable_resources = pci_dev_enable_resources,
60 .init = thermal_init,
61 .scan_bus = 0,
62 .ops_pci = &thermal_pci_ops,
63};
64
65static const struct pci_driver ich9_thermal __pci_driver = {
66 .ops = &device_ops,
67 .vendor = PCI_VENDOR_ID_INTEL,
Felix Singer7f8b0cd82019-11-10 11:04:08 +010068 .device = PCI_DEVICE_ID_INTEL_82801IB_THERMAL,
Patrick Georgie72a8a32012-11-06 11:05:09 +010069};