blob: 216af67d5b5c49496dcb2611d5f39f41fa7ffcda [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Vladimir Serbinenko888d5592013-11-13 17:53:38 +01002
3#include <console/console.h>
4#include <device/device.h>
5#include <device/pci.h>
Elyes HAOUASa4dd33c2020-08-11 09:39:43 +02006#include <device/pci_def.h>
Vladimir Serbinenko888d5592013-11-13 17:53:38 +01007#include <device/pci_ids.h>
8#include "pch.h"
Kyösti Mälkki13f66502019-03-03 08:01:05 +02009#include <device/mmio.h>
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010010
11static void thermal_init(struct device *dev)
12{
13 struct resource *res;
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080014 u8 *base;
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010015 printk(BIOS_DEBUG, "Thermal init start.\n");
16
Angel Ponsf32ae102021-11-03 13:07:14 +010017 res = probe_resource(dev, PCI_BASE_ADDRESS_0);
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010018 if (!res)
19 return;
20
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080021 base = res2mmio(res, 0, 0);
22 write32(base + 4, 0x3a2b);
23 write8(base + 0xe, 0x40);
24 write16(base + 0x56, 0xffff);
25 write16(base + 0x64, 0xffff);
26 write16(base + 0x66, 0xffff);
27 write16(base + 0x68, 0xfa);
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010028
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080029 write8(base + 1, 0xb8);
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010030
31 printk(BIOS_DEBUG, "Thermal init done.\n");
32}
33
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010034static struct device_operations thermal_ops = {
35 .read_resources = pci_dev_read_resources,
36 .set_resources = pci_dev_set_resources,
37 .enable_resources = pci_dev_enable_resources,
38 .init = thermal_init,
Angel Pons1fc0edd2020-05-31 00:03:28 +020039 .ops_pci = &pci_dev_ops_pci,
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010040};
41
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010042static const struct pci_driver pch_thermal __pci_driver = {
43 .ops = &thermal_ops,
Felix Singer43b7f412022-03-07 04:34:52 +010044 .vendor = PCI_VID_INTEL,
Felix Singeref6ecee2020-03-06 02:11:53 +010045 .device = PCI_DID_INTEL_IBEXPEAK_THERMAL,
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010046};