Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License as |
| 7 | * published by the Free Software Foundation; version 2 of |
| 8 | * the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <console/console.h> |
| 17 | #include <device/device.h> |
| 18 | #include <device/pci.h> |
| 19 | #include <device/pci_ids.h> |
| 20 | #include "pch.h" |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 21 | #include <device/mmio.h> |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 22 | |
| 23 | static void thermal_init(struct device *dev) |
| 24 | { |
| 25 | struct resource *res; |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 26 | u8 *base; |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 27 | printk(BIOS_DEBUG, "Thermal init start.\n"); |
| 28 | |
| 29 | res = find_resource(dev, 0x10); |
| 30 | if (!res) |
| 31 | return; |
| 32 | |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 33 | base = res2mmio(res, 0, 0); |
| 34 | write32(base + 4, 0x3a2b); |
| 35 | write8(base + 0xe, 0x40); |
| 36 | write16(base + 0x56, 0xffff); |
| 37 | write16(base + 0x64, 0xffff); |
| 38 | write16(base + 0x66, 0xffff); |
| 39 | write16(base + 0x68, 0xfa); |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 40 | |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 41 | write8(base + 1, 0xb8); |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 42 | |
| 43 | printk(BIOS_DEBUG, "Thermal init done.\n"); |
| 44 | } |
| 45 | |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 46 | static struct pci_operations pci_ops = { |
Subrata Banik | 4a0f071 | 2019-03-20 14:29:47 +0530 | [diff] [blame] | 47 | .set_subsystem = pci_dev_set_subsystem, |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | static struct device_operations thermal_ops = { |
| 51 | .read_resources = pci_dev_read_resources, |
| 52 | .set_resources = pci_dev_set_resources, |
| 53 | .enable_resources = pci_dev_enable_resources, |
| 54 | .init = thermal_init, |
| 55 | .scan_bus = 0, |
| 56 | .ops_pci = &pci_ops, |
| 57 | }; |
| 58 | |
Felix Singer | 838fbc7 | 2019-11-21 21:23:32 +0100 | [diff] [blame] | 59 | static const unsigned short pci_device_ids[] = { |
| 60 | PCI_DID_INTEL_IBEXPEAK_THERMAL, |
| 61 | 0 |
| 62 | }; |
Vladimir Serbinenko | 888d559 | 2013-11-13 17:53:38 +0100 | [diff] [blame] | 63 | |
| 64 | static const struct pci_driver pch_thermal __pci_driver = { |
| 65 | .ops = &thermal_ops, |
| 66 | .vendor = PCI_VENDOR_ID_INTEL, |
| 67 | .devices = pci_device_ids, |
| 68 | }; |