mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
issei: add heci hardware module
Add support for the ISSEI (Intel Silicon Security Engine Interface) HECI PCI devices. Add the necessary PCI handling routines, hardware definitions, register mappings and hardware access routines. This enables the communication via HECI PCI device advertized by BIOS. Reviewed-by: Karol Wachowski <karol.wachowski@linux.intel.com> Co-developed-by: Vitaly Lubart <lubvital@gmail.com> Signed-off-by: Vitaly Lubart <lubvital@gmail.com> Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Link: https://patch.msgid.link/20260513-issei-for-upstream-v1-4-f590038678f9@intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
7bd4b9991d
commit
8bf5e84998
@@ -11,3 +11,19 @@ config INTEL_SSEI
|
||||
|
||||
If selected, the /dev/isseiX device will be created.
|
||||
If in doubt, select N.
|
||||
|
||||
if INTEL_SSEI
|
||||
|
||||
config INTEL_SSEI_HW_HECI
|
||||
tristate "Intel Silicon Security Engine Interface Hardware"
|
||||
depends on X86 && PCI
|
||||
help
|
||||
HECI interface of communication channel between
|
||||
the host and the Silicon Security Engine.
|
||||
|
||||
Implementation of ISSEI communication channel over
|
||||
the HECI hardware PCI device.
|
||||
This device is available on Intel client CPUs released in 2024
|
||||
(Lunar Lake) or later.
|
||||
|
||||
endif
|
||||
|
||||
@@ -9,3 +9,7 @@ issei-objs += fw_client.o
|
||||
issei-objs += host_client.o
|
||||
issei-objs += ham.o
|
||||
issei-objs += main.o
|
||||
|
||||
obj-$(CONFIG_INTEL_SSEI_HW_HECI) += issei-heci.o
|
||||
issei-heci-objs := pci_heci.o
|
||||
issei-heci-objs += hw_heci.o
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,47 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/* Copyright (C) 2023-2026 Intel Corporation */
|
||||
#ifndef _ISSEI_HW_HECI_H_
|
||||
#define _ISSEI_HW_HECI_H_
|
||||
#include <linux/irqreturn.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
#include "issei_dev.h"
|
||||
|
||||
/*
|
||||
* hw_heci_cfg - issei heci device configuration
|
||||
*
|
||||
* @dma_length: DMA area length
|
||||
*/
|
||||
struct hw_heci_cfg {
|
||||
const struct issei_dma_length dma_length;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct issei_heci_hw - issei heci hw specific data
|
||||
*
|
||||
* @cfg: per device generation config and ops
|
||||
* @mem_addr: io memory address
|
||||
* @irq: device irq number
|
||||
* @access_lock: spinlock to protect hw access
|
||||
* @hbuf_depth: depth of hardware host/write buffer in slots
|
||||
*/
|
||||
struct issei_heci_hw {
|
||||
const struct hw_heci_cfg *cfg;
|
||||
void __iomem *mem_addr;
|
||||
int irq;
|
||||
spinlock_t access_lock;
|
||||
u8 hbuf_depth;
|
||||
};
|
||||
|
||||
#define to_heci_hw(dev) ((struct issei_heci_hw *)(dev)->hw)
|
||||
|
||||
const struct hw_heci_cfg *issei_heci_get_cfg(kernel_ulong_t idx);
|
||||
const struct issei_hw_ops *issei_heci_get_ops(void);
|
||||
|
||||
void issei_heci_dev_init(struct issei_device *idev,
|
||||
void __iomem *mem_addr, const struct hw_heci_cfg *cfg);
|
||||
|
||||
irqreturn_t issei_heci_irq_quick_handler(int irq, void *dev_id);
|
||||
|
||||
#endif /* _ISSEI_HW_HECI_H_ */
|
||||
@@ -0,0 +1,35 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/* Copyright (C) 2023-2026 Intel Corporation */
|
||||
#ifndef _ISSEI_HW_HECI_REGS_H_
|
||||
#define _ISSEI_HW_HECI_REGS_H_
|
||||
|
||||
#include <linux/bits.h>
|
||||
|
||||
/* H_CB_WW - Host Circular Buffer (CB) Write Window register */
|
||||
#define H_CB_WW 0x0
|
||||
/* H_CSR - Host Control Status register */
|
||||
#define H_CSR 0x4
|
||||
#define H_CSR_CBD GENMASK(31, 24) /* Host Circular Buffer Depth */
|
||||
#define H_CSR_CBWP GENMASK(23, 16) /* Host Circular Buffer Write Pointer */
|
||||
#define H_CSR_CBRP GENMASK(15, 8) /* Host Circular Buffer Read Pointer */
|
||||
#define H_CSR_RST BIT(4) /* Host Reset */
|
||||
#define H_CSR_RDY BIT(3) /* Host Ready */
|
||||
#define H_CSR_IG BIT(2) /* Host Interrupt Generate */
|
||||
#define H_CSR_IS BIT(1) /* Host Interrupt Status */
|
||||
#define H_CSR_IE BIT(0) /* Host Interrupt Enable */
|
||||
/* FW_CB_RW - FW Circular Buffer Read Window register (read only) */
|
||||
#define FW_CB_RW 0x8
|
||||
/* FW_CSR_HA - FW Control Status Host Access register (read only) */
|
||||
#define FW_CSR_HA 0xC
|
||||
#define FW_CSR_CBD GENMASK(31, 24) /* FW CB (Circular Buffer) Depth */
|
||||
#define FW_CSR_CBWP GENMASK(23, 16) /* FW CB Write Pointer */
|
||||
#define FW_CSR_CBRP GENMASK(15, 8) /* FW CB Read Pointer */
|
||||
#define FW_CSR_RST BIT(4) /* FW Reset */
|
||||
#define FW_CSR_RDY BIT(3) /* FW Ready */
|
||||
#define FW_CSR_IG BIT(2) /* FW Interrupt Generate */
|
||||
#define FW_CSR_IS BIT(1) /* FW Interrupt Status */
|
||||
#define FW_CSR_IE BIT(0) /* FW Interrupt Enable */
|
||||
|
||||
#define CB_SLOT_SIZE sizeof(u32) /* Circular Buffer windows size */
|
||||
|
||||
#endif /* _ISSEI_HW_HECI_REGS_H_ */
|
||||
@@ -0,0 +1,151 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/* Copyright (C) 2023-2026 Intel Corporation */
|
||||
#include <linux/device.h>
|
||||
#include <linux/dev_printk.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/pm.h>
|
||||
|
||||
#include "cdev.h"
|
||||
#include "hw_heci.h"
|
||||
#include "hw_heci_regs.h"
|
||||
|
||||
static int issei_heci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
const struct hw_heci_cfg *cfg;
|
||||
struct issei_device *idev;
|
||||
struct issei_heci_hw *hw;
|
||||
char __iomem *registers;
|
||||
int err;
|
||||
|
||||
cfg = issei_heci_get_cfg(ent->driver_data);
|
||||
if (!cfg)
|
||||
return dev_err_probe(dev, -ENODEV, "no usable configuration.\n");
|
||||
|
||||
err = pcim_enable_device(pdev);
|
||||
if (err)
|
||||
return dev_err_probe(dev, err, "failed to enable pci device.\n");
|
||||
|
||||
pci_set_master(pdev);
|
||||
|
||||
registers = pcim_iomap_region(pdev, 0, KBUILD_MODNAME);
|
||||
if (IS_ERR(registers))
|
||||
return dev_err_probe(dev, PTR_ERR(registers), "failed to get pci region.\n");
|
||||
|
||||
err = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
|
||||
if (err)
|
||||
return dev_err_probe(dev, err, "no usable DMA configuration.\n");
|
||||
|
||||
idev = issei_register(sizeof(*hw), dev, &cfg->dma_length, issei_heci_get_ops());
|
||||
if (IS_ERR(idev))
|
||||
return dev_err_probe(dev, PTR_ERR(idev), "register failure.\n");
|
||||
|
||||
issei_heci_dev_init(idev, registers, cfg);
|
||||
|
||||
pci_set_drvdata(pdev, idev);
|
||||
|
||||
err = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSI);
|
||||
if (err < 0) {
|
||||
dev_err_probe(dev, err, "pci_alloc_irq_vectors failure.\n");
|
||||
goto deregister;
|
||||
}
|
||||
|
||||
hw = to_heci_hw(idev);
|
||||
hw->irq = pci_irq_vector(pdev, 0);
|
||||
|
||||
err = request_threaded_irq(hw->irq,
|
||||
issei_heci_irq_quick_handler,
|
||||
NULL,
|
||||
IRQF_SHARED, KBUILD_MODNAME, idev);
|
||||
if (err)
|
||||
goto release_irq;
|
||||
|
||||
err = issei_start(idev);
|
||||
if (err) {
|
||||
dev_err_probe(dev, err, "init hw failure.\n");
|
||||
goto free_irq;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
free_irq:
|
||||
idev->ops->irq_disable(idev);
|
||||
free_irq(hw->irq, idev);
|
||||
release_irq:
|
||||
pci_free_irq_vectors(pdev);
|
||||
deregister:
|
||||
issei_deregister(idev);
|
||||
return err;
|
||||
}
|
||||
|
||||
static void issei_heci_shutdown(struct pci_dev *pdev)
|
||||
{
|
||||
struct issei_device *idev = pci_get_drvdata(pdev);
|
||||
struct issei_heci_hw *hw = to_heci_hw(idev);
|
||||
|
||||
issei_stop(idev);
|
||||
|
||||
idev->ops->irq_disable(idev);
|
||||
free_irq(hw->irq, idev);
|
||||
pci_free_irq_vectors(pdev);
|
||||
}
|
||||
|
||||
static void issei_heci_remove(struct pci_dev *pdev)
|
||||
{
|
||||
issei_heci_shutdown(pdev);
|
||||
|
||||
issei_deregister(pci_get_drvdata(pdev));
|
||||
}
|
||||
|
||||
static int issei_heci_pm_suspend(struct device *device)
|
||||
{
|
||||
struct issei_device *idev = dev_get_drvdata(device);
|
||||
|
||||
issei_stop(idev);
|
||||
idev->ops->irq_disable(idev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int issei_heci_pm_resume(struct device *device)
|
||||
{
|
||||
struct issei_device *idev = dev_get_drvdata(device);
|
||||
|
||||
return issei_start(idev);
|
||||
}
|
||||
|
||||
static const struct dev_pm_ops issei_heci_pm_ops = {
|
||||
SYSTEM_SLEEP_PM_OPS(issei_heci_pm_suspend, issei_heci_pm_resume)
|
||||
};
|
||||
|
||||
static const struct pci_device_id heci_pci_tbl[] = {
|
||||
{PCI_VDEVICE(INTEL, 0xA85D)}, /* Lunar Lake M */
|
||||
{PCI_VDEVICE(INTEL, 0xE35D)}, /* Panther Lake H */
|
||||
{PCI_VDEVICE(INTEL, 0xE45D)}, /* Panther Lake P */
|
||||
{PCI_VDEVICE(INTEL, 0xD470)}, /* Nova Lake S */
|
||||
{PCI_VDEVICE(INTEL, 0xD358)}, /* Nova Lake H */
|
||||
{PCI_VDEVICE(INTEL, 0x4D5D)}, /* Wildcat Lake */
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(pci, heci_pci_tbl);
|
||||
|
||||
static struct pci_driver issei_heci_driver = {
|
||||
.name = KBUILD_MODNAME,
|
||||
.id_table = heci_pci_tbl,
|
||||
.probe = issei_heci_probe,
|
||||
.remove = issei_heci_remove,
|
||||
.shutdown = issei_heci_shutdown,
|
||||
.driver = {
|
||||
.pm = &issei_heci_pm_ops,
|
||||
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
|
||||
},
|
||||
};
|
||||
module_pci_driver(issei_heci_driver);
|
||||
|
||||
MODULE_DESCRIPTION("Intel(R) Silicon Security Engine Interface - HECI");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_IMPORT_NS("INTEL_SSEI");
|
||||
Reference in New Issue
Block a user