linux/drivers/thermal/intel/int340x_thermal/processor_thermal_wt_hint.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * processor thermal device interface for reading workload type hints
 * from the user space. The hints are provided by the firmware.
 *
 * Operation:
 * When user space enables workload type prediction:
 * - Use mailbox to:
 *	Configure notification delay
 *	Enable processor thermal device interrupt
 *
 * - The predicted workload type can be read from MMIO:
 *	Offset 0x5B18 shows if there was an interrupt
 *	active for change in workload type and also
 *	predicted workload type.
 *
 * Two interface functions are provided to call when there is a
 * thermal device interrupt:
 * - proc_thermal_check_wt_intr():
 *     Check if the interrupt is for change in workload type. Called from
 *     interrupt context.
 *
 * - proc_thermal_wt_intr_callback():
 *     Callback for interrupt processing in thread context. This involves
 *	sending notification to user space that there is a change in the
 *     workload type.
 *
 * Copyright (c) 2023, Intel Corporation.
 */

#include <linux/bitfield.h>
#include <linux/pci.h>
#include "processor_thermal_device.h"

#define SOC_WT

#define SOC_WT_PREDICTION_INT_ENABLE_BIT

#define SOC_WT_PREDICTION_INT_ACTIVE

/*
 * Closest possible to 1 Second is 1024 ms with programmed time delay
 * of 0x0A.
 */
static u8 notify_delay =;
static u16 notify_delay_ms =;

static DEFINE_MUTEX(wt_lock);
static u8 wt_enable;

/* Show current predicted workload type index */
static ssize_t workload_type_index_show(struct device *dev,
					struct device_attribute *attr,
					char *buf)
{}

static DEVICE_ATTR_RO(workload_type_index);

static ssize_t workload_hint_enable_show(struct device *dev,
					 struct device_attribute *attr,
					 char *buf)
{}

static ssize_t workload_hint_enable_store(struct device *dev,
					  struct device_attribute *attr,
					  const char *buf, size_t size)
{}

static DEVICE_ATTR_RW(workload_hint_enable);

static ssize_t notification_delay_ms_show(struct device *dev,
					  struct device_attribute *attr,
					  char *buf)
{}

static ssize_t notification_delay_ms_store(struct device *dev,
					   struct device_attribute *attr,
					   const char *buf, size_t size)
{}

static DEVICE_ATTR_RW(notification_delay_ms);

static struct attribute *workload_hint_attrs[] =;

static const struct attribute_group workload_hint_attribute_group =;

/*
 * Callback to check if the interrupt for prediction is active.
 * Caution: Called from the interrupt context.
 */
bool proc_thermal_check_wt_intr(struct proc_thermal_device *proc_priv)
{}
EXPORT_SYMBOL_NS_GPL();

/* Callback to notify user space */
void proc_thermal_wt_intr_callback(struct pci_dev *pdev, struct proc_thermal_device *proc_priv)
{}
EXPORT_SYMBOL_NS_GPL();

static bool workload_hint_created;

int proc_thermal_wt_hint_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv)
{}
EXPORT_SYMBOL_NS_GPL();

void proc_thermal_wt_hint_remove(struct pci_dev *pdev)
{}
EXPORT_SYMBOL_NS_GPL();

MODULE_IMPORT_NS();
MODULE_LICENSE();
MODULE_DESCRIPTION();