blob: 83a15830aba72aacc7fb1c34d3d583aedf99f95d [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Patrick Georgie72a8a32012-11-06 11:05:09 +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>
Patrick Georgie72a8a32012-11-06 11:05:09 +01005#include <device/device.h>
6#include <device/pci.h>
7#include <device/pci_ids.h>
8
9#include "i82801ix.h"
10
11static void thermal_init(struct device *dev)
12{
Kyösti Mälkkic70eed12018-05-22 02:18:00 +030013 if (LPC_IS_MOBILE(pcidev_on_root(0x1f, 0)))
Patrick Georgie72a8a32012-11-06 11:05:09 +010014 return;
15
16 u8 reg8;
17 u32 reg32;
18
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080019 pci_write_config32(dev, 0x10, (uintptr_t)DEFAULT_TBAR);
Patrick Georgie72a8a32012-11-06 11:05:09 +010020 reg32 = pci_read_config32(dev, 0x04);
21 pci_write_config32(dev, 0x04, reg32 | (1 << 1));
22
23 write32(DEFAULT_TBAR + 0x04, 0); /* Clear thermal trip points. */
24 write32(DEFAULT_TBAR + 0x44, 0);
25
26 write8(DEFAULT_TBAR + 0x01, 0xba); /* Enable sensor 0 + 1. */
27 write8(DEFAULT_TBAR + 0x41, 0xba);
28
29 reg8 = read8(DEFAULT_TBAR + 0x08); /* Lock thermal registers. */
30 write8(DEFAULT_TBAR + 0x08, reg8 | (1 << 7));
31 reg8 = read8(DEFAULT_TBAR + 0x48);
32 write8(DEFAULT_TBAR + 0x48, reg8 | (1 << 7));
33
34 reg32 = pci_read_config32(dev, 0x04);
35 pci_write_config32(dev, 0x04, reg32 & ~(1 << 1));
36 pci_write_config32(dev, 0x10, 0);
37}
38
Patrick Georgie72a8a32012-11-06 11:05:09 +010039static struct pci_operations thermal_pci_ops = {
Subrata Banik4a0f0712019-03-20 14:29:47 +053040 .set_subsystem = pci_dev_set_subsystem,
Patrick Georgie72a8a32012-11-06 11:05:09 +010041};
42
43static struct device_operations device_ops = {
44 .read_resources = pci_dev_read_resources,
45 .set_resources = pci_dev_set_resources,
46 .enable_resources = pci_dev_enable_resources,
47 .init = thermal_init,
Patrick Georgie72a8a32012-11-06 11:05:09 +010048 .ops_pci = &thermal_pci_ops,
49};
50
51static const struct pci_driver ich9_thermal __pci_driver = {
52 .ops = &device_ops,
53 .vendor = PCI_VENDOR_ID_INTEL,
Felix Singer7f8b0cd82019-11-10 11:04:08 +010054 .device = PCI_DEVICE_ID_INTEL_82801IB_THERMAL,
Patrick Georgie72a8a32012-11-06 11:05:09 +010055};