Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 2 | |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 3 | #include <device/mmio.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 4 | #include <device/pci_ops.h> |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 5 | #include <device/device.h> |
| 6 | #include <device/pci.h> |
| 7 | #include <device/pci_ids.h> |
| 8 | |
| 9 | #include "i82801ix.h" |
| 10 | |
| 11 | static void thermal_init(struct device *dev) |
| 12 | { |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame] | 13 | if (LPC_IS_MOBILE(pcidev_on_root(0x1f, 0))) |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 14 | return; |
| 15 | |
| 16 | u8 reg8; |
| 17 | u32 reg32; |
| 18 | |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 19 | pci_write_config32(dev, 0x10, (uintptr_t)DEFAULT_TBAR); |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 20 | 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 Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 39 | static struct pci_operations thermal_pci_ops = { |
Subrata Banik | 4a0f071 | 2019-03-20 14:29:47 +0530 | [diff] [blame] | 40 | .set_subsystem = pci_dev_set_subsystem, |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | static 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 Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 48 | .ops_pci = &thermal_pci_ops, |
| 49 | }; |
| 50 | |
| 51 | static const struct pci_driver ich9_thermal __pci_driver = { |
| 52 | .ops = &device_ops, |
| 53 | .vendor = PCI_VENDOR_ID_INTEL, |
Felix Singer | 7f8b0cd8 | 2019-11-10 11:04:08 +0100 | [diff] [blame] | 54 | .device = PCI_DEVICE_ID_INTEL_82801IB_THERMAL, |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 55 | }; |