blob: 374cbf11dc724de18e4e803df4a8719a6dc4ac04 [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"
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010022#include <arch/io.h>
23
24static void thermal_init(struct device *dev)
25{
26 struct resource *res;
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080027 u8 *base;
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010028 printk(BIOS_DEBUG, "Thermal init start.\n");
29
30 res = find_resource(dev, 0x10);
31 if (!res)
32 return;
33
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080034 base = res2mmio(res, 0, 0);
35 write32(base + 4, 0x3a2b);
36 write8(base + 0xe, 0x40);
37 write16(base + 0x56, 0xffff);
38 write16(base + 0x64, 0xffff);
39 write16(base + 0x66, 0xffff);
40 write16(base + 0x68, 0xfa);
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010041
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080042 write8(base + 1, 0xb8);
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010043
44 printk(BIOS_DEBUG, "Thermal init done.\n");
45}
46
Elyes HAOUASbe841402018-05-13 13:40:39 +020047static void set_subsystem(struct device *dev, unsigned vendor,
48 unsigned device)
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010049{
50 if (!vendor || !device) {
51 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
52 pci_read_config32(dev, PCI_VENDOR_ID));
53 } else {
54 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
55 ((device & 0xffff) << 16) | (vendor &
56 0xffff));
57 }
58}
59
60static struct pci_operations pci_ops = {
61 .set_subsystem = set_subsystem,
62};
63
64static struct device_operations thermal_ops = {
65 .read_resources = pci_dev_read_resources,
66 .set_resources = pci_dev_set_resources,
67 .enable_resources = pci_dev_enable_resources,
68 .init = thermal_init,
69 .scan_bus = 0,
70 .ops_pci = &pci_ops,
71};
72
73static const unsigned short pci_device_ids[] = { 0x3b32, 0 };
74
75static const struct pci_driver pch_thermal __pci_driver = {
76 .ops = &thermal_ops,
77 .vendor = PCI_VENDOR_ID_INTEL,
78 .devices = pci_device_ids,
79};