linux/drivers/hwmon/ibmaem.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * A hwmon driver for the IBM System Director Active Energy Manager (AEM)
 * temperature/power/energy sensors and capping functionality.
 * Copyright (C) 2008 IBM
 *
 * Author: Darrick J. Wong <[email protected]>
 */

#define pr_fmt(fmt)

#include <linux/ipmi.h>
#include <linux/module.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/jiffies.h>
#include <linux/mutex.h>
#include <linux/kdev_t.h>
#include <linux/spinlock.h>
#include <linux/idr.h>
#include <linux/slab.h>
#include <linux/sched.h>
#include <linux/platform_device.h>
#include <linux/math64.h>
#include <linux/time.h>
#include <linux/err.h>

#define REFRESH_INTERVAL
#define IPMI_TIMEOUT
#define DRVNAME

#define AEM_NETFN

#define AEM_FIND_FW_CMD
#define AEM_ELEMENT_CMD
#define AEM_FW_INSTANCE_CMD

#define AEM_READ_ELEMENT_CFG
#define AEM_READ_BUFFER
#define AEM_READ_REGISTER
#define AEM_WRITE_REGISTER
#define AEM_SET_REG_MASK
#define AEM_CLEAR_REG_MASK
#define AEM_READ_ELEMENT_CFG2

#define AEM_CONTROL_ELEMENT
#define AEM_ENERGY_ELEMENT
#define AEM_CLOCK_ELEMENT
#define AEM_POWER_CAP_ELEMENT
#define AEM_EXHAUST_ELEMENT
#define AEM_POWER_ELEMENT

#define AEM_MODULE_TYPE_ID

#define AEM2_NUM_ENERGY_REGS
#define AEM2_NUM_PCAP_REGS
#define AEM2_NUM_TEMP_REGS
#define AEM2_NUM_SENSORS

#define AEM1_NUM_ENERGY_REGS
#define AEM1_NUM_SENSORS

/* AEM 2.x has more energy registers */
#define AEM_NUM_ENERGY_REGS
/* AEM 2.x needs more sensor files */
#define AEM_NUM_SENSORS

#define POWER_CAP
#define POWER_CAP_MAX_HOTPLUG
#define POWER_CAP_MAX
#define POWER_CAP_MIN_WARNING
#define POWER_CAP_MIN
#define POWER_AUX

#define AEM_DEFAULT_POWER_INTERVAL
#define AEM_MIN_POWER_INTERVAL
#define UJ_PER_MJ

static DEFINE_IDA(aem_ida);

static struct platform_driver aem_driver =;

struct aem_ipmi_data {};

struct aem_ro_sensor_template {};

struct aem_rw_sensor_template {};

struct aem_data {};

/* Data structures returned by the AEM firmware */
struct aem_iana_id {};
static struct aem_iana_id system_x_id =;

/* These are used to find AEM1 instances */
struct aem_find_firmware_req {} __packed;

struct aem_find_firmware_resp {} __packed;

/* These are used to find AEM2 instances */
struct aem_find_instance_req {} __packed;

struct aem_find_instance_resp {} __packed;

/* These are used to query sensors */
struct aem_read_sensor_req {} __packed;

struct aem_read_sensor_resp {} __packed;

/* Data structures to talk to the IPMI layer */
struct aem_driver_data {};

static void aem_register_bmc(int iface, struct device *dev);
static void aem_bmc_gone(int iface);
static void aem_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data);

static void aem_remove_sensors(struct aem_data *data);
static int aem1_find_sensors(struct aem_data *data);
static int aem2_find_sensors(struct aem_data *data);
static void update_aem1_sensors(struct aem_data *data);
static void update_aem2_sensors(struct aem_data *data);

static struct aem_driver_data driver_data =;

/* Functions to talk to the IPMI layer */

/* Initialize IPMI address, message buffers and user data */
static int aem_init_ipmi_data(struct aem_ipmi_data *data, int iface,
			      struct device *bmc)
{}

/* Send an IPMI command */
static int aem_send_message(struct aem_ipmi_data *data)
{}

/* Dispatch IPMI messages to callers */
static void aem_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data)
{}

/* Sensor support functions */

/* Read a sensor value; must be called with data->lock held */
static int aem_read_sensor(struct aem_data *data, u8 elt, u8 reg,
			   void *buf, size_t size)
{}

/* Update AEM energy registers */
static void update_aem_energy_one(struct aem_data *data, int which)
{}

static void update_aem_energy(struct aem_data *data)
{}

/* Update all AEM1 sensors */
static void update_aem1_sensors(struct aem_data *data)
{}

/* Update all AEM2 sensors */
static void update_aem2_sensors(struct aem_data *data)
{}

/* Delete an AEM instance */
static void aem_delete(struct aem_data *data)
{}

/* Probe functions for AEM1 devices */

/* Retrieve version and module handle for an AEM1 instance */
static int aem_find_aem1_count(struct aem_ipmi_data *data)
{}

/* Find and initialize one AEM1 instance */
static int aem_init_aem1_inst(struct aem_ipmi_data *probe, u8 module_handle)
{}

/* Find and initialize all AEM1 instances */
static void aem_init_aem1(struct aem_ipmi_data *probe)
{}

/* Probe functions for AEM2 devices */

/* Retrieve version and module handle for an AEM2 instance */
static int aem_find_aem2(struct aem_ipmi_data *data,
			    struct aem_find_instance_resp *fi_resp,
			    int instance_num)
{}

/* Find and initialize one AEM2 instance */
static int aem_init_aem2_inst(struct aem_ipmi_data *probe,
			      struct aem_find_instance_resp *fi_resp)
{}

/* Find and initialize all AEM2 instances */
static void aem_init_aem2(struct aem_ipmi_data *probe)
{}

/* Probe a BMC for AEM firmware instances */
static void aem_register_bmc(int iface, struct device *dev)
{}

/* Handle BMC deletion */
static void aem_bmc_gone(int iface)
{}

/* sysfs support functions */

/* AEM device name */
static ssize_t name_show(struct device *dev, struct device_attribute *devattr,
			 char *buf)
{}
static SENSOR_DEVICE_ATTR_RO(name, name, 0);

/* AEM device version */
static ssize_t version_show(struct device *dev,
			    struct device_attribute *devattr, char *buf)
{}
static SENSOR_DEVICE_ATTR_RO(version, version, 0);

/* Display power use */
static ssize_t aem_show_power(struct device *dev,
			      struct device_attribute *devattr,
			      char *buf)
{}

/* Display energy use */
static ssize_t aem_show_energy(struct device *dev,
			       struct device_attribute *devattr,
			       char *buf)
{}

/* Display power interval registers */
static ssize_t aem_show_power_period(struct device *dev,
				     struct device_attribute *devattr,
				     char *buf)
{}

/* Set power interval registers */
static ssize_t aem_set_power_period(struct device *dev,
				    struct device_attribute *devattr,
				    const char *buf, size_t count)
{}

/* Discover sensors on an AEM device */
static int aem_register_sensors(struct aem_data *data,
				const struct aem_ro_sensor_template *ro,
				const struct aem_rw_sensor_template *rw)
{}

/* sysfs support functions for AEM2 sensors */

/* Display temperature use */
static ssize_t aem2_show_temp(struct device *dev,
			      struct device_attribute *devattr,
			      char *buf)
{}

/* Display power-capping registers */
static ssize_t aem2_show_pcap_value(struct device *dev,
				    struct device_attribute *devattr,
				    char *buf)
{}

/* Remove sensors attached to an AEM device */
static void aem_remove_sensors(struct aem_data *data)
{}

/* Sensor probe functions */

/* Description of AEM1 sensors */
static const struct aem_ro_sensor_template aem1_ro_sensors[] =;

static const struct aem_rw_sensor_template aem1_rw_sensors[] =;

/* Description of AEM2 sensors */
static const struct aem_ro_sensor_template aem2_ro_sensors[] =;

static const struct aem_rw_sensor_template aem2_rw_sensors[] =;

/* Set up AEM1 sensor attrs */
static int aem1_find_sensors(struct aem_data *data)
{}

/* Set up AEM2 sensor attrs */
static int aem2_find_sensors(struct aem_data *data)
{}

/* Module init/exit routines */

static int __init aem_init(void)
{}

static void __exit aem_exit(void)
{}

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();

module_init();
module_exit(aem_exit);

MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();