blob: 543b2ffd3864be771e229cb7b84165102ffd0dae [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;
Patrick Georgie72a8a32012-11-06 11:05:09 +010017
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080018 pci_write_config32(dev, 0x10, (uintptr_t)DEFAULT_TBAR);
Angel Pons67406472020-06-08 11:13:42 +020019 pci_or_config32(dev, 0x04, 1 << 1);
Patrick Georgie72a8a32012-11-06 11:05:09 +010020
21 write32(DEFAULT_TBAR + 0x04, 0); /* Clear thermal trip points. */
22 write32(DEFAULT_TBAR + 0x44, 0);
23
24 write8(DEFAULT_TBAR + 0x01, 0xba); /* Enable sensor 0 + 1. */
25 write8(DEFAULT_TBAR + 0x41, 0xba);
26
27 reg8 = read8(DEFAULT_TBAR + 0x08); /* Lock thermal registers. */
28 write8(DEFAULT_TBAR + 0x08, reg8 | (1 << 7));
29 reg8 = read8(DEFAULT_TBAR + 0x48);
30 write8(DEFAULT_TBAR + 0x48, reg8 | (1 << 7));
31
Angel Pons67406472020-06-08 11:13:42 +020032 pci_and_config32(dev, 0x04, ~(1 << 1));
Patrick Georgie72a8a32012-11-06 11:05:09 +010033 pci_write_config32(dev, 0x10, 0);
34}
35
Patrick Georgie72a8a32012-11-06 11:05:09 +010036static struct device_operations device_ops = {
37 .read_resources = pci_dev_read_resources,
38 .set_resources = pci_dev_set_resources,
39 .enable_resources = pci_dev_enable_resources,
40 .init = thermal_init,
Angel Pons1fc0edd2020-05-31 00:03:28 +020041 .ops_pci = &pci_dev_ops_pci,
Patrick Georgie72a8a32012-11-06 11:05:09 +010042};
43
44static const struct pci_driver ich9_thermal __pci_driver = {
45 .ops = &device_ops,
Felix Singer43b7f412022-03-07 04:34:52 +010046 .vendor = PCI_VID_INTEL,
47 .device = PCI_DID_INTEL_82801IB_THERMAL,
Patrick Georgie72a8a32012-11-06 11:05:09 +010048};