Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 1 | /* |
| 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 Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 15 | */ |
| 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älkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame^] | 22 | #include <device/mmio.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 23 | #include <device/pci_ops.h> |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 24 | |
| 25 | static void thermal_init(struct device *dev) |
| 26 | { |
| 27 | struct resource *res; |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 28 | u8 *base; |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 29 | printk(BIOS_DEBUG, "Thermal init start.\n"); |
| 30 | |
| 31 | res = find_resource(dev, 0x10); |
| 32 | if (!res) |
| 33 | return; |
| 34 | |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 35 | 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 Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 42 | |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 43 | write8(base + 1, 0xb8); |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 44 | |
| 45 | printk(BIOS_DEBUG, "Thermal init done.\n"); |
| 46 | } |
| 47 | |
Elyes HAOUAS | be84140 | 2018-05-13 13:40:39 +0200 | [diff] [blame] | 48 | static void set_subsystem(struct device *dev, unsigned vendor, |
| 49 | unsigned device) |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 50 | { |
| 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 | |
| 61 | static struct pci_operations pci_ops = { |
| 62 | .set_subsystem = set_subsystem, |
| 63 | }; |
| 64 | |
| 65 | static 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 | |
| 74 | static const unsigned short pci_device_ids[] = { 0x3b32, 0 }; |
| 75 | |
| 76 | static const struct pci_driver pch_thermal __pci_driver = { |
| 77 | .ops = &thermal_ops, |
| 78 | .vendor = PCI_VENDOR_ID_INTEL, |
| 79 | .devices = pci_device_ids, |
| 80 | }; |