22 #include <linux/ipmi.h>
23 #include <linux/module.h>
28 #include <linux/slab.h>
31 #define REFRESH_INTERVAL (2 * HZ)
32 #define DRVNAME "ibmpex"
34 #define PEX_GET_VERSION 1
35 #define PEX_GET_SENSOR_COUNT 2
36 #define PEX_GET_SENSOR_NAME 3
37 #define PEX_RESET_HIGH_LOW 4
38 #define PEX_GET_SENSOR_DATA 6
40 #define PEX_NET_FUNCTION 0x3A
41 #define PEX_COMMAND 0x3C
49 #define POWER_SENSOR 2
51 #define PEX_SENSOR_TYPE_LEN 3
52 static u8 const power_sensor_sig[] = {0x70, 0x77, 0x72};
53 static u8 const temp_sensor_sig[] = {0x74, 0x65, 0x6D};
55 #define PEX_MULT_LEN 2
56 static u8 const watt_sensor_sig[] = {0x41, 0x43};
58 #define PEX_NUM_SENSOR_FUNCS 3
59 static char const *
const power_sensor_name_templates[] = {
61 "%s%d_average_lowest",
62 "%s%d_average_highest"
64 static char const *
const temp_sensor_name_templates[] = {
70 static void ibmpex_msg_handler(
struct ipmi_recv_msg *
msg,
void *user_msg_data);
71 static void ibmpex_register_bmc(
int iface,
struct device *
dev);
72 static void ibmpex_bmc_gone(
int iface);
121 .new_smi = ibmpex_register_bmc,
122 .smi_gone = ibmpex_bmc_gone,
125 .ipmi_recv_hndl = ibmpex_msg_handler,
156 ibmpex_send_message(data);
167 "v%d.%d %d-%02d-%02d on interface %d\n",
182 ibmpex_send_message(data);
192 static int ibmpex_query_sensor_name(
struct ibmpex_bmc_data *data,
int sensor)
197 ibmpex_send_message(data);
207 static int ibmpex_query_sensor_data(
struct ibmpex_bmc_data *data,
int sensor)
212 ibmpex_send_message(data);
229 ibmpex_send_message(data);
248 err = ibmpex_query_sensor_data(data, i);
291 ibmpex_update_device(data);
304 ibmpex_reset_high_low_data(data);
310 ibmpex_reset_high_low, 0);
312 static int is_power_sensor(
const char *sensor_id,
int len)
322 static int is_temp_sensor(
const char *sensor_id,
int len)
333 const char *sensor_id,
int len)
358 sprintf(n, temp_sensor_name_templates[func],
"temp", counter);
360 sprintf(n, power_sensor_name_templates[func],
"power", counter);
363 data->
sensors[sensor].attr[
func].dev_attr.attr.name =
n;
365 data->
sensors[sensor].attr[
func].dev_attr.show = ibmpex_show_sensor;
370 &data->
sensors[sensor].attr[func].dev_attr);
388 err = ibmpex_query_sensor_count(data);
399 err = ibmpex_query_sensor_name(data, i);
406 sensor_counter = num_power;
408 power_sensor_multiplier(data,
415 sensor_counter = num_temp;
424 err = create_sensor(data, sensor_type, sensor_counter,
432 &sensor_dev_attr_reset_high_low.dev_attr);
437 &sensor_dev_attr_name.dev_attr);
445 &sensor_dev_attr_reset_high_low.dev_attr);
449 if (!data->
sensors[i].attr[j].dev_attr.attr.name)
452 &data->
sensors[i].attr[j].dev_attr);
460 static void ibmpex_register_bmc(
int iface,
struct device *
dev)
467 dev_err(dev,
"Insufficient memory for BMC interface.\n");
481 dev_err(dev,
"Unable to register user with IPMI "
496 err = ibmpex_ver_check(data);
505 "device for IPMI interface %d\n",
515 err = ibmpex_find_sensors(data);
536 &sensor_dev_attr_reset_high_low.dev_attr);
540 if (!data->
sensors[i].attr[j].dev_attr.attr.name)
543 &data->
sensors[i].attr[j].dev_attr);
555 static void ibmpex_bmc_gone(
int iface)
562 ibmpex_bmc_delete(data);
565 static void ibmpex_msg_handler(
struct ipmi_recv_msg *
msg,
void *user_msg_data)
571 "(%02x) and transmitted msgid (%02x)!\n",
579 if (msg->
msg.data_len > 0)
584 if (msg->
msg.data_len > 1) {
594 static int __init ibmpex_init(
void)
599 static void __exit ibmpex_exit(
void)
605 ibmpex_bmc_delete(p);