···11+What: /sys/class/intel_pmt/22+Date: October 202033+KernelVersion: 5.1044+Contact: David Box <david.e.box@linux.intel.com>55+Description:66+ The intel_pmt/ class directory contains information for77+ devices that expose hardware telemetry using Intel Platform88+ Monitoring Technology (PMT)99+1010+What: /sys/class/intel_pmt/telem<x>1111+Date: October 20201212+KernelVersion: 5.101313+Contact: David Box <david.e.box@linux.intel.com>1414+Description:1515+ The telem<x> directory contains files describing an instance of1616+ a PMT telemetry device that exposes hardware telemetry. Each1717+ telem<x> directory has an associated telem file. This file1818+ may be opened and mapped or read to access the telemetry space1919+ of the device. The register layout of the telemetry space is2020+ determined from an XML file that matches the PCI device id and2121+ GUID for the device.2222+2323+What: /sys/class/intel_pmt/telem<x>/telem2424+Date: October 20202525+KernelVersion: 5.102626+Contact: David Box <david.e.box@linux.intel.com>2727+Description:2828+ (RO) The telemetry data for this telemetry device. This file2929+ may be mapped or read to obtain the data.3030+3131+What: /sys/class/intel_pmt/telem<x>/guid3232+Date: October 20203333+KernelVersion: 5.103434+Contact: David Box <david.e.box@linux.intel.com>3535+Description:3636+ (RO) The GUID for this telemetry device. The GUID identifies3737+ the version of the XML file for the parent device that is to3838+ be used to get the register layout.3939+4040+What: /sys/class/intel_pmt/telem<x>/size4141+Date: October 20204242+KernelVersion: 5.104343+Contact: David Box <david.e.box@linux.intel.com>4444+Description:4545+ (RO) The size of telemetry region in bytes that corresponds to4646+ the mapping size for the telem file.4747+4848+What: /sys/class/intel_pmt/telem<x>/offset4949+Date: October 20205050+KernelVersion: 5.105151+Contact: David Box <david.e.box@linux.intel.com>5252+Description:5353+ (RO) The offset of telemetry region in bytes that corresponds to5454+ the mapping for the telem file.5555+5656+What: /sys/class/intel_pmt/crashlog<x>5757+Date: October 20205858+KernelVersion: 5.105959+Contact: Alexander Duyck <alexander.h.duyck@linux.intel.com>6060+Description:6161+ The crashlog<x> directory contains files for configuring an6262+ instance of a PMT crashlog device that can perform crash data6363+ recording. Each crashlog<x> device has an associated crashlog6464+ file. This file can be opened and mapped or read to access the6565+ resulting crashlog buffer. The register layout for the buffer6666+ can be determined from an XML file of specified GUID for the6767+ parent device.6868+6969+What: /sys/class/intel_pmt/crashlog<x>/crashlog7070+Date: October 20207171+KernelVersion: 5.107272+Contact: David Box <david.e.box@linux.intel.com>7373+Description:7474+ (RO) The crashlog buffer for this crashlog device. This file7575+ may be mapped or read to obtain the data.7676+7777+What: /sys/class/intel_pmt/crashlog<x>/guid7878+Date: October 20207979+KernelVersion: 5.108080+Contact: Alexander Duyck <alexander.h.duyck@linux.intel.com>8181+Description:8282+ (RO) The GUID for this crashlog device. The GUID identifies the8383+ version of the XML file for the parent device that should be8484+ used to determine the register layout.8585+8686+What: /sys/class/intel_pmt/crashlog<x>/size8787+Date: October 20208888+KernelVersion: 5.108989+Contact: Alexander Duyck <alexander.h.duyck@linux.intel.com>9090+Description:9191+ (RO) The length of the result buffer in bytes that corresponds9292+ to the size for the crashlog buffer.9393+9494+What: /sys/class/intel_pmt/crashlog<x>/offset9595+Date: October 20209696+KernelVersion: 5.109797+Contact: Alexander Duyck <alexander.h.duyck@linux.intel.com>9898+Description:9999+ (RO) The offset of the buffer in bytes that corresponds100100+ to the mapping for the crashlog device.101101+102102+What: /sys/class/intel_pmt/crashlog<x>/enable103103+Date: October 2020104104+KernelVersion: 5.10105105+Contact: Alexander Duyck <alexander.h.duyck@linux.intel.com>106106+Description:107107+ (RW) Boolean value controlling if the crashlog functionality108108+ is enabled for the crashlog device.109109+110110+What: /sys/class/intel_pmt/crashlog<x>/trigger111111+Date: October 2020112112+KernelVersion: 5.10113113+Contact: Alexander Duyck <alexander.h.duyck@linux.intel.com>114114+Description:115115+ (RW) Boolean value controlling the triggering of the crashlog116116+ device node. When read it provides data on if the crashlog has117117+ been triggered. When written to it can be used to either clear118118+ the current trigger by writing false, or to trigger a new119119+ event if the trigger is not currently set.
···682682 Register and P-unit access. In addition this creates devices683683 for iTCO watchdog and telemetry that are part of the PMC.684684685685+config MFD_INTEL_PMT686686+ tristate "Intel Platform Monitoring Technology (PMT) support"687687+ depends on PCI688688+ select MFD_CORE689689+ help690690+ The Intel Platform Monitoring Technology (PMT) is an interface that691691+ provides access to hardware monitor registers. This driver supports692692+ Telemetry, Watcher, and Crashlog PMT capabilities/devices for693693+ platforms starting from Tiger Lake.694694+685695config MFD_IPAQ_MICRO686696 bool "Atmel Micro ASIC (iPAQ h3100/h3600/h3700) Support"687697 depends on SA1100_H3100 || SA1100_H3600
···11+// SPDX-License-Identifier: GPL-2.022+/*33+ * Intel Platform Monitoring Technology PMT driver44+ *55+ * Copyright (c) 2020, Intel Corporation.66+ * All Rights Reserved.77+ *88+ * Author: David E. Box <david.e.box@linux.intel.com>99+ */1010+1111+#include <linux/bits.h>1212+#include <linux/kernel.h>1313+#include <linux/mfd/core.h>1414+#include <linux/module.h>1515+#include <linux/pci.h>1616+#include <linux/platform_device.h>1717+#include <linux/pm.h>1818+#include <linux/pm_runtime.h>1919+#include <linux/types.h>2020+2121+/* Intel DVSEC capability vendor space offsets */2222+#define INTEL_DVSEC_ENTRIES 0xA2323+#define INTEL_DVSEC_SIZE 0xB2424+#define INTEL_DVSEC_TABLE 0xC2525+#define INTEL_DVSEC_TABLE_BAR(x) ((x) & GENMASK(2, 0))2626+#define INTEL_DVSEC_TABLE_OFFSET(x) ((x) & GENMASK(31, 3))2727+#define INTEL_DVSEC_ENTRY_SIZE 42828+2929+/* PMT capabilities */3030+#define DVSEC_INTEL_ID_TELEMETRY 23131+#define DVSEC_INTEL_ID_WATCHER 33232+#define DVSEC_INTEL_ID_CRASHLOG 43333+3434+struct intel_dvsec_header {3535+ u16 length;3636+ u16 id;3737+ u8 num_entries;3838+ u8 entry_size;3939+ u8 tbir;4040+ u32 offset;4141+};4242+4343+enum pmt_quirks {4444+ /* Watcher capability not supported */4545+ PMT_QUIRK_NO_WATCHER = BIT(0),4646+4747+ /* Crashlog capability not supported */4848+ PMT_QUIRK_NO_CRASHLOG = BIT(1),4949+5050+ /* Use shift instead of mask to read discovery table offset */5151+ PMT_QUIRK_TABLE_SHIFT = BIT(2),5252+};5353+5454+struct pmt_platform_info {5555+ unsigned long quirks;5656+};5757+5858+static const struct pmt_platform_info tgl_info = {5959+ .quirks = PMT_QUIRK_NO_WATCHER | PMT_QUIRK_NO_CRASHLOG |6060+ PMT_QUIRK_TABLE_SHIFT,6161+};6262+6363+static int pmt_add_dev(struct pci_dev *pdev, struct intel_dvsec_header *header,6464+ unsigned long quirks)6565+{6666+ struct device *dev = &pdev->dev;6767+ struct resource *res, *tmp;6868+ struct mfd_cell *cell;6969+ const char *name;7070+ int count = header->num_entries;7171+ int size = header->entry_size;7272+ int id = header->id;7373+ int i;7474+7575+ switch (id) {7676+ case DVSEC_INTEL_ID_TELEMETRY:7777+ name = "pmt_telemetry";7878+ break;7979+ case DVSEC_INTEL_ID_WATCHER:8080+ if (quirks & PMT_QUIRK_NO_WATCHER) {8181+ dev_info(dev, "Watcher not supported\n");8282+ return 0;8383+ }8484+ name = "pmt_watcher";8585+ break;8686+ case DVSEC_INTEL_ID_CRASHLOG:8787+ if (quirks & PMT_QUIRK_NO_CRASHLOG) {8888+ dev_info(dev, "Crashlog not supported\n");8989+ return 0;9090+ }9191+ name = "pmt_crashlog";9292+ break;9393+ default:9494+ dev_err(dev, "Unrecognized PMT capability: %d\n", id);9595+ return -EINVAL;9696+ }9797+9898+ if (!header->num_entries || !header->entry_size) {9999+ dev_err(dev, "Invalid count or size for %s header\n", name);100100+ return -EINVAL;101101+ }102102+103103+ cell = devm_kzalloc(dev, sizeof(*cell), GFP_KERNEL);104104+ if (!cell)105105+ return -ENOMEM;106106+107107+ res = devm_kcalloc(dev, count, sizeof(*res), GFP_KERNEL);108108+ if (!res)109109+ return -ENOMEM;110110+111111+ if (quirks & PMT_QUIRK_TABLE_SHIFT)112112+ header->offset >>= 3;113113+114114+ /*115115+ * The PMT DVSEC contains the starting offset and count for a block of116116+ * discovery tables, each providing access to monitoring facilities for117117+ * a section of the device. Create a resource list of these tables to118118+ * provide to the driver.119119+ */120120+ for (i = 0, tmp = res; i < count; i++, tmp++) {121121+ tmp->start = pdev->resource[header->tbir].start +122122+ header->offset + i * (size << 2);123123+ tmp->end = tmp->start + (size << 2) - 1;124124+ tmp->flags = IORESOURCE_MEM;125125+ }126126+127127+ cell->resources = res;128128+ cell->num_resources = count;129129+ cell->name = name;130130+131131+ return devm_mfd_add_devices(dev, PLATFORM_DEVID_AUTO, cell, 1, NULL, 0,132132+ NULL);133133+}134134+135135+static int pmt_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)136136+{137137+ struct pmt_platform_info *info;138138+ unsigned long quirks = 0;139139+ bool found_devices = false;140140+ int ret, pos = 0;141141+142142+ ret = pcim_enable_device(pdev);143143+ if (ret)144144+ return ret;145145+146146+ info = (struct pmt_platform_info *)id->driver_data;147147+148148+ if (info)149149+ quirks = info->quirks;150150+151151+ do {152152+ struct intel_dvsec_header header;153153+ u32 table;154154+ u16 vid;155155+156156+ pos = pci_find_next_ext_capability(pdev, pos, PCI_EXT_CAP_ID_DVSEC);157157+ if (!pos)158158+ break;159159+160160+ pci_read_config_word(pdev, pos + PCI_DVSEC_HEADER1, &vid);161161+ if (vid != PCI_VENDOR_ID_INTEL)162162+ continue;163163+164164+ pci_read_config_word(pdev, pos + PCI_DVSEC_HEADER2,165165+ &header.id);166166+ pci_read_config_byte(pdev, pos + INTEL_DVSEC_ENTRIES,167167+ &header.num_entries);168168+ pci_read_config_byte(pdev, pos + INTEL_DVSEC_SIZE,169169+ &header.entry_size);170170+ pci_read_config_dword(pdev, pos + INTEL_DVSEC_TABLE,171171+ &table);172172+173173+ header.tbir = INTEL_DVSEC_TABLE_BAR(table);174174+ header.offset = INTEL_DVSEC_TABLE_OFFSET(table);175175+176176+ ret = pmt_add_dev(pdev, &header, quirks);177177+ if (ret) {178178+ dev_warn(&pdev->dev,179179+ "Failed to add device for DVSEC id %d\n",180180+ header.id);181181+ continue;182182+ }183183+184184+ found_devices = true;185185+ } while (true);186186+187187+ if (!found_devices)188188+ return -ENODEV;189189+190190+ pm_runtime_put(&pdev->dev);191191+ pm_runtime_allow(&pdev->dev);192192+193193+ return 0;194194+}195195+196196+static void pmt_pci_remove(struct pci_dev *pdev)197197+{198198+ pm_runtime_forbid(&pdev->dev);199199+ pm_runtime_get_sync(&pdev->dev);200200+}201201+202202+#define PCI_DEVICE_ID_INTEL_PMT_ADL 0x467d203203+#define PCI_DEVICE_ID_INTEL_PMT_OOBMSM 0x09a7204204+#define PCI_DEVICE_ID_INTEL_PMT_TGL 0x9a0d205205+static const struct pci_device_id pmt_pci_ids[] = {206206+ { PCI_DEVICE_DATA(INTEL, PMT_ADL, &tgl_info) },207207+ { PCI_DEVICE_DATA(INTEL, PMT_OOBMSM, NULL) },208208+ { PCI_DEVICE_DATA(INTEL, PMT_TGL, &tgl_info) },209209+ { }210210+};211211+MODULE_DEVICE_TABLE(pci, pmt_pci_ids);212212+213213+static struct pci_driver pmt_pci_driver = {214214+ .name = "intel-pmt",215215+ .id_table = pmt_pci_ids,216216+ .probe = pmt_pci_probe,217217+ .remove = pmt_pci_remove,218218+};219219+module_pci_driver(pmt_pci_driver);220220+221221+MODULE_AUTHOR("David E. Box <david.e.box@linux.intel.com>");222222+MODULE_DESCRIPTION("Intel Platform Monitoring Technology PMT driver");223223+MODULE_LICENSE("GPL v2");
+34
drivers/platform/x86/Kconfig
···13431343 - LTR Ignore13441344 - MPHY/PLL gating status (Sunrisepoint PCH only)1345134513461346+config INTEL_PMT_CLASS13471347+ tristate "Intel Platform Monitoring Technology (PMT) Class driver"13481348+ help13491349+ The Intel Platform Monitoring Technology (PMT) class driver provides13501350+ the basic sysfs interface and file hierarchy uses by PMT devices.13511351+13521352+ For more information, see:13531353+ <file:Documentation/ABI/testing/sysfs-class-intel_pmt>13541354+13551355+ To compile this driver as a module, choose M here: the module13561356+ will be called intel_pmt_class.13571357+13581358+config INTEL_PMT_TELEMETRY13591359+ tristate "Intel Platform Monitoring Technology (PMT) Telemetry driver"13601360+ select INTEL_PMT_CLASS13611361+ help13621362+ The Intel Platform Monitory Technology (PMT) Telemetry driver provides13631363+ access to hardware telemetry metrics on devices that support the13641364+ feature.13651365+13661366+ To compile this driver as a module, choose M here: the module13671367+ will be called intel_pmt_telemetry.13681368+13691369+config INTEL_PMT_CRASHLOG13701370+ tristate "Intel Platform Monitoring Technology (PMT) Crashlog driver"13711371+ select INTEL_PMT_CLASS13721372+ help13731373+ The Intel Platform Monitoring Technology (PMT) crashlog driver provides13741374+ access to hardware crashlog capabilities on devices that support the13751375+ feature.13761376+13771377+ To compile this driver as a module, choose M here: the module13781378+ will be called intel_pmt_crashlog.13791379+13461380config INTEL_PUNIT_IPC13471381 tristate "Intel P-Unit IPC Driver"13481382 help