blob: ca8492b7b3f05594aeac06ea431b80a349882de1 [file] [log] [blame]
Vladimir Serbinenko888d5592013-11-13 17:53:38 +01001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2013 Vladimir Serbinenko
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; version 2 of
9 * the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010015 */
16
17#include <console/console.h>
18#include <device/device.h>
19#include <device/pci.h>
20#include <device/pci_ids.h>
21#include "pch.h"
Kyösti Mälkki13f66502019-03-03 08:01:05 +020022#include <device/mmio.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020023#include <device/pci_ops.h>
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010024
25static void thermal_init(struct device *dev)
26{
27 struct resource *res;
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080028 u8 *base;
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010029 printk(BIOS_DEBUG, "Thermal init start.\n");
30
31 res = find_resource(dev, 0x10);
32 if (!res)
33 return;
34
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080035 base = res2mmio(res, 0, 0);
36 write32(base + 4, 0x3a2b);
37 write8(base + 0xe, 0x40);
38 write16(base + 0x56, 0xffff);
39 write16(base + 0x64, 0xffff);
40 write16(base + 0x66, 0xffff);
41 write16(base + 0x68, 0xfa);
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010042
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080043 write8(base + 1, 0xb8);
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010044
45 printk(BIOS_DEBUG, "Thermal init done.\n");
46}
47
Elyes HAOUASbe841402018-05-13 13:40:39 +020048static void set_subsystem(struct device *dev, unsigned vendor,
49 unsigned device)
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010050{
51 if (!vendor || !device) {
52 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
53 pci_read_config32(dev, PCI_VENDOR_ID));
54 } else {
55 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
56 ((device & 0xffff) << 16) | (vendor &
57 0xffff));
58 }
59}
60
61static struct pci_operations pci_ops = {
62 .set_subsystem = set_subsystem,
63};
64
65static struct device_operations thermal_ops = {
66 .read_resources = pci_dev_read_resources,
67 .set_resources = pci_dev_set_resources,
68 .enable_resources = pci_dev_enable_resources,
69 .init = thermal_init,
70 .scan_bus = 0,
71 .ops_pci = &pci_ops,
72};
73
74static const unsigned short pci_device_ids[] = { 0x3b32, 0 };
75
76static const struct pci_driver pch_thermal __pci_driver = {
77 .ops = &thermal_ops,
78 .vendor = PCI_VENDOR_ID_INTEL,
79 .devices = pci_device_ids,
80};