platform/x86/intel/vsec.h: Move to include/linux
authorDavid E. Box <david.e.box@linux.intel.com>
Thu, 25 Jul 2024 12:23:40 +0000 (08:23 -0400)
committerHans de Goede <hdegoede@redhat.com>
Mon, 12 Aug 2024 14:21:31 +0000 (16:21 +0200)
Some drivers outside of PDX86 need access to the vsec header. Move it to
include/linux to make it easier to include.

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: David E. Box <david.e.box@linux.intel.com>
Link: https://lore.kernel.org/r/20240725122346.4063913-2-michael.j.ruhl@intel.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
MAINTAINERS
drivers/platform/x86/intel/pmc/core_ssram.c
drivers/platform/x86/intel/pmt/class.c
drivers/platform/x86/intel/pmt/class.h
drivers/platform/x86/intel/pmt/crashlog.c
drivers/platform/x86/intel/pmt/telemetry.c
drivers/platform/x86/intel/sdsi.c
drivers/platform/x86/intel/tpmi.c
drivers/platform/x86/intel/vsec.c
drivers/platform/x86/intel/vsec.h [deleted file]
include/linux/intel_vsec.h [new file with mode: 0644]

index 42decde..894608f 100644 (file)
@@ -11599,7 +11599,8 @@ F:      drivers/platform/x86/intel/uncore-frequency/
 INTEL VENDOR SPECIFIC EXTENDED CAPABILITIES DRIVER
 M:     David E. Box <david.e.box@linux.intel.com>
 S:     Supported
-F:     drivers/platform/x86/intel/vsec.*
+F:     drivers/platform/x86/intel/vsec.c
+F:     include/linux/intel_vsec.h
 
 INTEL VIRTUAL BUTTON DRIVER
 M:     AceLan Kao <acelan.kao@canonical.com>
index 1bde86c..baddaae 100644 (file)
@@ -9,11 +9,11 @@
  */
 
 #include <linux/cleanup.h>
+#include <linux/intel_vsec.h>
 #include <linux/pci.h>
 #include <linux/io-64-nonatomic-lo-hi.h>
 
 #include "core.h"
-#include "../vsec.h"
 #include "../pmt/telemetry.h"
 
 #define SSRAM_HDR_SIZE         0x100
index 4b53940..d7939b2 100644 (file)
@@ -9,12 +9,12 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/intel_vsec.h>
 #include <linux/io-64-nonatomic-lo-hi.h>
 #include <linux/module.h>
 #include <linux/mm.h>
 #include <linux/pci.h>
 
-#include "../vsec.h"
 #include "class.h"
 
 #define PMT_XA_START           1
index d23c63b..d6f9cca 100644 (file)
@@ -2,13 +2,13 @@
 #ifndef _INTEL_PMT_CLASS_H
 #define _INTEL_PMT_CLASS_H
 
+#include <linux/intel_vsec.h>
 #include <linux/xarray.h>
 #include <linux/types.h>
 #include <linux/bits.h>
 #include <linux/err.h>
 #include <linux/io.h>
 
-#include "../vsec.h"
 #include "telemetry.h"
 
 /* PMT access types */
index 4014c02..9079d5d 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include <linux/auxiliary_bus.h>
+#include <linux/intel_vsec.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
@@ -16,7 +17,6 @@
 #include <linux/uaccess.h>
 #include <linux/overflow.h>
 
-#include "../vsec.h"
 #include "class.h"
 
 /* Crashlog discovery header types */
index 0925856..3478f89 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include <linux/auxiliary_bus.h>
+#include <linux/intel_vsec.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
@@ -16,7 +17,6 @@
 #include <linux/uaccess.h>
 #include <linux/overflow.h>
 
-#include "../vsec.h"
 #include "class.h"
 
 #define TELEM_SIZE_OFFSET      0x0
index 277e4f4..9d13762 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/bits.h>
 #include <linux/bitfield.h>
 #include <linux/device.h>
+#include <linux/intel_vsec.h>
 #include <linux/iopoll.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -22,8 +23,6 @@
 #include <linux/types.h>
 #include <linux/uaccess.h>
 
-#include "vsec.h"
-
 #define ACCESS_TYPE_BARID              2
 #define ACCESS_TYPE_LOCAL              3
 
index 83e8b1f..486ddc9 100644 (file)
@@ -51,6 +51,7 @@
 #include <linux/debugfs.h>
 #include <linux/delay.h>
 #include <linux/intel_tpmi.h>
+#include <linux/intel_vsec.h>
 #include <linux/io.h>
 #include <linux/iopoll.h>
 #include <linux/module.h>
@@ -59,8 +60,6 @@
 #include <linux/sizes.h>
 #include <linux/string_helpers.h>
 
-#include "vsec.h"
-
 /**
  * struct intel_tpmi_pfs_entry - TPMI PM Feature Structure (PFS) entry
  * @tpmi_id:   TPMI feature identifier (what the feature is and its data format).
index 0fdfaf3..2b46807 100644 (file)
 #include <linux/bits.h>
 #include <linux/cleanup.h>
 #include <linux/delay.h>
-#include <linux/kernel.h>
 #include <linux/idr.h>
+#include <linux/intel_vsec.h>
+#include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/types.h>
 
-#include "vsec.h"
-
 #define PMT_XA_START                   0
 #define PMT_XA_MAX                     INT_MAX
 #define PMT_XA_LIMIT                   XA_LIMIT(PMT_XA_START, PMT_XA_MAX)
@@ -341,7 +340,7 @@ static bool intel_vsec_walk_vsec(struct pci_dev *pdev,
 void intel_vsec_register(struct pci_dev *pdev,
                         struct intel_vsec_platform_info *info)
 {
-       if (!pdev || !info)
+       if (!pdev || !info || !info->headers)
                return;
 
        intel_vsec_walk_header(pdev, info);
diff --git a/drivers/platform/x86/intel/vsec.h b/drivers/platform/x86/intel/vsec.h
deleted file mode 100644 (file)
index e23e761..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _VSEC_H
-#define _VSEC_H
-
-#include <linux/auxiliary_bus.h>
-#include <linux/bits.h>
-
-#define VSEC_CAP_TELEMETRY     BIT(0)
-#define VSEC_CAP_WATCHER       BIT(1)
-#define VSEC_CAP_CRASHLOG      BIT(2)
-#define VSEC_CAP_SDSI          BIT(3)
-#define VSEC_CAP_TPMI          BIT(4)
-
-/* Intel DVSEC offsets */
-#define INTEL_DVSEC_ENTRIES            0xA
-#define INTEL_DVSEC_SIZE               0xB
-#define INTEL_DVSEC_TABLE              0xC
-#define INTEL_DVSEC_TABLE_BAR(x)       ((x) & GENMASK(2, 0))
-#define INTEL_DVSEC_TABLE_OFFSET(x)    ((x) & GENMASK(31, 3))
-#define TABLE_OFFSET_SHIFT             3
-
-struct pci_dev;
-struct resource;
-
-enum intel_vsec_id {
-       VSEC_ID_TELEMETRY       = 2,
-       VSEC_ID_WATCHER         = 3,
-       VSEC_ID_CRASHLOG        = 4,
-       VSEC_ID_SDSI            = 65,
-       VSEC_ID_TPMI            = 66,
-};
-
-/**
- * struct intel_vsec_header - Common fields of Intel VSEC and DVSEC registers.
- * @rev:         Revision ID of the VSEC/DVSEC register space
- * @length:      Length of the VSEC/DVSEC register space
- * @id:          ID of the feature
- * @num_entries: Number of instances of the feature
- * @entry_size:  Size of the discovery table for each feature
- * @tbir:        BAR containing the discovery tables
- * @offset:      BAR offset of start of the first discovery table
- */
-struct intel_vsec_header {
-       u8      rev;
-       u16     length;
-       u16     id;
-       u8      num_entries;
-       u8      entry_size;
-       u8      tbir;
-       u32     offset;
-};
-
-enum intel_vsec_quirks {
-       /* Watcher feature not supported */
-       VSEC_QUIRK_NO_WATCHER   = BIT(0),
-
-       /* Crashlog feature not supported */
-       VSEC_QUIRK_NO_CRASHLOG  = BIT(1),
-
-       /* Use shift instead of mask to read discovery table offset */
-       VSEC_QUIRK_TABLE_SHIFT  = BIT(2),
-
-       /* DVSEC not present (provided in driver data) */
-       VSEC_QUIRK_NO_DVSEC     = BIT(3),
-
-       /* Platforms requiring quirk in the auxiliary driver */
-       VSEC_QUIRK_EARLY_HW     = BIT(4),
-};
-
-/* Platform specific data */
-struct intel_vsec_platform_info {
-       struct device *parent;
-       struct intel_vsec_header **headers;
-       unsigned long caps;
-       unsigned long quirks;
-       u64 base_addr;
-};
-
-struct intel_vsec_device {
-       struct auxiliary_device auxdev;
-       struct pci_dev *pcidev;
-       struct resource *resource;
-       struct ida *ida;
-       int num_resources;
-       int id; /* xa */
-       void *priv_data;
-       size_t priv_data_size;
-       unsigned long quirks;
-       u64 base_addr;
-};
-
-int intel_vsec_add_aux(struct pci_dev *pdev, struct device *parent,
-                      struct intel_vsec_device *intel_vsec_dev,
-                      const char *name);
-
-static inline struct intel_vsec_device *dev_to_ivdev(struct device *dev)
-{
-       return container_of(dev, struct intel_vsec_device, auxdev.dev);
-}
-
-static inline struct intel_vsec_device *auxdev_to_ivdev(struct auxiliary_device *auxdev)
-{
-       return container_of(auxdev, struct intel_vsec_device, auxdev);
-}
-
-void intel_vsec_register(struct pci_dev *pdev,
-                        struct intel_vsec_platform_info *info);
-#endif
diff --git a/include/linux/intel_vsec.h b/include/linux/intel_vsec.h
new file mode 100644 (file)
index 0000000..6495e37
--- /dev/null
@@ -0,0 +1,134 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _INTEL_VSEC_H
+#define _INTEL_VSEC_H
+
+#include <linux/auxiliary_bus.h>
+#include <linux/bits.h>
+
+#define VSEC_CAP_TELEMETRY     BIT(0)
+#define VSEC_CAP_WATCHER       BIT(1)
+#define VSEC_CAP_CRASHLOG      BIT(2)
+#define VSEC_CAP_SDSI          BIT(3)
+#define VSEC_CAP_TPMI          BIT(4)
+
+/* Intel DVSEC offsets */
+#define INTEL_DVSEC_ENTRIES            0xA
+#define INTEL_DVSEC_SIZE               0xB
+#define INTEL_DVSEC_TABLE              0xC
+#define INTEL_DVSEC_TABLE_BAR(x)       ((x) & GENMASK(2, 0))
+#define INTEL_DVSEC_TABLE_OFFSET(x)    ((x) & GENMASK(31, 3))
+#define TABLE_OFFSET_SHIFT             3
+
+struct pci_dev;
+struct resource;
+
+enum intel_vsec_id {
+       VSEC_ID_TELEMETRY       = 2,
+       VSEC_ID_WATCHER         = 3,
+       VSEC_ID_CRASHLOG        = 4,
+       VSEC_ID_SDSI            = 65,
+       VSEC_ID_TPMI            = 66,
+};
+
+/**
+ * struct intel_vsec_header - Common fields of Intel VSEC and DVSEC registers.
+ * @rev:         Revision ID of the VSEC/DVSEC register space
+ * @length:      Length of the VSEC/DVSEC register space
+ * @id:          ID of the feature
+ * @num_entries: Number of instances of the feature
+ * @entry_size:  Size of the discovery table for each feature
+ * @tbir:        BAR containing the discovery tables
+ * @offset:      BAR offset of start of the first discovery table
+ */
+struct intel_vsec_header {
+       u8      rev;
+       u16     length;
+       u16     id;
+       u8      num_entries;
+       u8      entry_size;
+       u8      tbir;
+       u32     offset;
+};
+
+enum intel_vsec_quirks {
+       /* Watcher feature not supported */
+       VSEC_QUIRK_NO_WATCHER   = BIT(0),
+
+       /* Crashlog feature not supported */
+       VSEC_QUIRK_NO_CRASHLOG  = BIT(1),
+
+       /* Use shift instead of mask to read discovery table offset */
+       VSEC_QUIRK_TABLE_SHIFT  = BIT(2),
+
+       /* DVSEC not present (provided in driver data) */
+       VSEC_QUIRK_NO_DVSEC     = BIT(3),
+
+       /* Platforms requiring quirk in the auxiliary driver */
+       VSEC_QUIRK_EARLY_HW     = BIT(4),
+};
+
+/**
+ * struct intel_vsec_platform_info - Platform specific data
+ * @parent:    parent device in the auxbus chain
+ * @headers:   list of headers to define the PMT client devices to create
+ * @caps:      bitmask of PMT capabilities for the given headers
+ * @quirks:    bitmask of VSEC device quirks
+ * @base_addr: allow a base address to be specified (rather than derived)
+ */
+struct intel_vsec_platform_info {
+       struct device *parent;
+       struct intel_vsec_header **headers;
+       unsigned long caps;
+       unsigned long quirks;
+       u64 base_addr;
+};
+
+/**
+ * struct intel_sec_device - Auxbus specific device information
+ * @auxdev:        auxbus device struct for auxbus access
+ * @pcidev:        pci device associated with the device
+ * @resource:      any resources shared by the parent
+ * @ida:           id reference
+ * @num_resources: number of resources
+ * @id:            xarray id
+ * @priv_data:     any private data needed
+ * @quirks:        specified quirks
+ * @base_addr:     base address of entries (if specified)
+ */
+struct intel_vsec_device {
+       struct auxiliary_device auxdev;
+       struct pci_dev *pcidev;
+       struct resource *resource;
+       struct ida *ida;
+       int num_resources;
+       int id; /* xa */
+       void *priv_data;
+       size_t priv_data_size;
+       unsigned long quirks;
+       u64 base_addr;
+};
+
+int intel_vsec_add_aux(struct pci_dev *pdev, struct device *parent,
+                      struct intel_vsec_device *intel_vsec_dev,
+                      const char *name);
+
+static inline struct intel_vsec_device *dev_to_ivdev(struct device *dev)
+{
+       return container_of(dev, struct intel_vsec_device, auxdev.dev);
+}
+
+static inline struct intel_vsec_device *auxdev_to_ivdev(struct auxiliary_device *auxdev)
+{
+       return container_of(auxdev, struct intel_vsec_device, auxdev);
+}
+
+#if IS_ENABLED(CONFIG_INTEL_VSEC)
+void intel_vsec_register(struct pci_dev *pdev,
+                        struct intel_vsec_platform_info *info);
+#else
+static inline void intel_vsec_register(struct pci_dev *pdev,
+                                      struct intel_vsec_platform_info *info)
+{
+}
+#endif
+#endif