linux/drivers/hwmon/xgene-hwmon.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * APM X-Gene SoC Hardware Monitoring Driver
 *
 * Copyright (c) 2016, Applied Micro Circuits Corporation
 * Author: Loc Ho <[email protected]>
 *         Hoan Tran <[email protected]>
 *
 * This driver provides the following features:
 *  - Retrieve CPU total power (uW)
 *  - Retrieve IO total power (uW)
 *  - Retrieve SoC temperature (milli-degree C) and alarm
 */
#include <linux/acpi.h>
#include <linux/dma-mapping.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/io.h>
#include <linux/interrupt.h>
#include <linux/kfifo.h>
#include <linux/mailbox_controller.h>
#include <linux/mailbox_client.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>

#include <acpi/pcc.h>

/* SLIMpro message defines */
#define MSG_TYPE_DBG
#define MSG_TYPE_ERR
#define MSG_TYPE_PWRMGMT

#define MSG_TYPE(v)
#define MSG_TYPE_SET(v)
#define MSG_SUBTYPE(v)
#define MSG_SUBTYPE_SET(v)

#define DBG_SUBTYPE_SENSOR_READ
#define SENSOR_RD_MSG
#define SENSOR_RD_EN_ADDR(a)
#define PMD_PWR_REG
#define PMD_PWR_MW_REG
#define SOC_PWR_REG
#define SOC_PWR_MW_REG
#define SOC_TEMP_REG

#define TEMP_NEGATIVE_BIT
#define SENSOR_INVALID_DATA

#define PWRMGMT_SUBTYPE_TPC
#define TPC_ALARM
#define TPC_GET_ALARM
#define TPC_CMD(v)
#define TPC_CMD_SET(v)
#define TPC_EN_MSG(hndl, cmd, type)

/*
 * Arbitrary retries in case the remote processor is slow to respond
 * to PCC commands
 */
#define PCC_NUM_RETRIES

#define ASYNC_MSG_FIFO_SIZE
#define MBOX_OP_TIMEOUTMS

#define WATT_TO_mWATT(x)
#define mWATT_TO_uWATT(x)
#define CELSIUS_TO_mCELSIUS(x)

#define to_xgene_hwmon_dev(cl)

enum xgene_hwmon_version {};

struct slimpro_resp_msg {} __packed;

struct xgene_hwmon_dev {};

/*
 * This function tests and clears a bitmask then returns its old value
 */
static u16 xgene_word_tst_and_clr(u16 *addr, u16 mask)
{}

static int xgene_hwmon_pcc_rd(struct xgene_hwmon_dev *ctx, u32 *msg)
{}

static int xgene_hwmon_rd(struct xgene_hwmon_dev *ctx, u32 *msg)
{}

static int xgene_hwmon_reg_map_rd(struct xgene_hwmon_dev *ctx, u32 addr,
				  u32 *data)
{}

static int xgene_hwmon_get_notification_msg(struct xgene_hwmon_dev *ctx,
					    u32 *amsg)
{}

static int xgene_hwmon_get_cpu_pwr(struct xgene_hwmon_dev *ctx, u32 *val)
{}

static int xgene_hwmon_get_io_pwr(struct xgene_hwmon_dev *ctx, u32 *val)
{}

static int xgene_hwmon_get_temp(struct xgene_hwmon_dev *ctx, u32 *val)
{}

/*
 * Sensor temperature/power functions
 */
static ssize_t temp1_input_show(struct device *dev,
				struct device_attribute *attr,
				char *buf)
{}

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

static ssize_t temp1_critical_alarm_show(struct device *dev,
					 struct device_attribute *devattr,
					 char *buf)
{}

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

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

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

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

static DEVICE_ATTR_RO(temp1_label);
static DEVICE_ATTR_RO(temp1_input);
static DEVICE_ATTR_RO(temp1_critical_alarm);
static DEVICE_ATTR_RO(power1_label);
static DEVICE_ATTR_RO(power1_input);
static DEVICE_ATTR_RO(power2_label);
static DEVICE_ATTR_RO(power2_input);

static struct attribute *xgene_hwmon_attrs[] =;

ATTRIBUTE_GROUPS();

static int xgene_hwmon_tpc_alarm(struct xgene_hwmon_dev *ctx,
				 struct slimpro_resp_msg *amsg)
{}

static void xgene_hwmon_process_pwrmsg(struct xgene_hwmon_dev *ctx,
				       struct slimpro_resp_msg *amsg)
{}

/*
 * This function is called to process async work queue
 */
static void xgene_hwmon_evt_work(struct work_struct *work)
{}

static int xgene_hwmon_rx_ready(struct xgene_hwmon_dev *ctx, void *msg)
{}

/*
 * This function is called when the SLIMpro Mailbox received a message
 */
static void xgene_hwmon_rx_cb(struct mbox_client *cl, void *msg)
{}

/*
 * This function is called when the PCC Mailbox received a message
 */
static void xgene_hwmon_pcc_rx_cb(struct mbox_client *cl, void *msg)
{}

static void xgene_hwmon_tx_done(struct mbox_client *cl, void *msg, int ret)
{}

#ifdef CONFIG_ACPI
static const struct acpi_device_id xgene_hwmon_acpi_match[] =;
MODULE_DEVICE_TABLE(acpi, xgene_hwmon_acpi_match);
#endif

static int xgene_hwmon_probe(struct platform_device *pdev)
{}

static void xgene_hwmon_remove(struct platform_device *pdev)
{}

static const struct of_device_id xgene_hwmon_of_match[] =;
MODULE_DEVICE_TABLE(of, xgene_hwmon_of_match);

static struct platform_driver xgene_hwmon_driver =;
module_platform_driver();

MODULE_DESCRIPTION();
MODULE_LICENSE();