blob: 78b5b14be4468b878664b861391a574ee24486ce [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
47static void set_subsystem(device_t dev, unsigned vendor, unsigned device)
48{
49 if (!vendor || !device) {
50 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
51 pci_read_config32(dev, PCI_VENDOR_ID));
52 } else {
53 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
54 ((device & 0xffff) << 16) | (vendor &
55 0xffff));
56 }
57}
58
59static struct pci_operations pci_ops = {
60 .set_subsystem = set_subsystem,
61};
62
63static struct device_operations thermal_ops = {
64 .read_resources = pci_dev_read_resources,
65 .set_resources = pci_dev_set_resources,
66 .enable_resources = pci_dev_enable_resources,
67 .init = thermal_init,
68 .scan_bus = 0,
69 .ops_pci = &pci_ops,
70};
71
72static const unsigned short pci_device_ids[] = { 0x3b32, 0 };
73
74static const struct pci_driver pch_thermal __pci_driver = {
75 .ops = &thermal_ops,
76 .vendor = PCI_VENDOR_ID_INTEL,
77 .devices = pci_device_ids,
78};