26 #include <linux/kernel.h>
27 #include <linux/module.h>
29 #include <linux/types.h>
34 #include <linux/list.h>
39 #include <linux/ipmi.h>
40 #include <linux/device.h>
47 #define IPMI_FLAGS_HANDLER_INSTALL 0
49 #define ACPI_IPMI_OK 0
50 #define ACPI_IPMI_TIMEOUT 0x10
51 #define ACPI_IPMI_UNKNOWN 0x07
53 #define IPMI_TIMEOUT (5 * HZ)
107 static void ipmi_register_bmc(
int iface,
struct device *
dev);
108 static void ipmi_bmc_gone(
int iface);
109 static void ipmi_msg_handler(
struct ipmi_recv_msg *
msg,
void *user_msg_data);
117 .new_smi = ipmi_register_bmc,
118 .smi_gone = ipmi_bmc_gone,
121 .ipmi_recv_hndl = ipmi_msg_handler,
132 dev_warn(&pnp_dev->
dev,
"Can't allocate memory for ipmi_msg\n");
136 INIT_LIST_HEAD(&ipmi_msg->
head);
141 #define IPMI_OP_RGN_NETFN(offset) ((offset >> 8) & 0xff)
142 #define IPMI_OP_RGN_CMD(offset) (offset & 0xff)
176 tx_msg->
addr.data[0] = 0;
222 struct pnp_dev *pnp_dev = ipmi->
pnp_dev;
236 dev_warn(&pnp_dev->
dev,
"tx msg list is not NULL\n");
239 static void ipmi_msg_handler(
struct ipmi_recv_msg *msg,
void *user_msg_data)
244 struct pnp_dev *pnp_dev = ipmi_device->
pnp_dev;
247 dev_warn(&pnp_dev->
dev,
"Unexpected response is returned. "
248 "returned user %p, expected user %p\n",
263 dev_warn(&pnp_dev->
dev,
"Unexpected response (msg id %ld) is "
264 "returned.\n", msg->
msgid);
269 if (msg->
msg.data_len) {
279 static void ipmi_register_bmc(
int iface,
struct device *
dev)
282 struct pnp_dev *pnp_dev;
293 if (smi_data.addr_src !=
SI_ACPI) {
298 handle = smi_data.addr_info.acpi_info.acpi_handle;
306 if (temp->
handle == handle)
310 ipmi_device = kzalloc(
sizeof(*ipmi_device),
GFP_KERNEL);
317 ipmi_device->
pnp_dev = pnp_dev;
322 dev_warn(&pnp_dev->
dev,
"Can't create IPMI user interface\n");
326 acpi_add_ipmi_device(ipmi_device);
339 static void ipmi_bmc_gone(
int iface)
349 acpi_remove_ipmi_device(ipmi_device);
373 acpi_ipmi_space_handler(
u32 function, acpi_physical_address
address,
375 void *handler_context,
void *region_context)
393 tx_msg = acpi_alloc_ipmi_msg(ipmi_device);
397 acpi_format_ipmi_msg(tx_msg, address, value);
412 acpi_format_ipmi_response(tx_msg, value, rem_time);
443 &acpi_ipmi_space_handler,
446 struct pnp_dev *pnp_dev = ipmi->
pnp_dev;
447 dev_warn(&pnp_dev->
dev,
"Can't register IPMI opregion space "
458 INIT_LIST_HEAD(&ipmi_device->
head);
462 ipmi_install_space_handler(ipmi_device);
479 ipmi_flush_tx_msg(ipmi_device);
482 ipmi_remove_space_handler(ipmi_device);
485 static int __init acpi_ipmi_init(
void)
499 static void __exit acpi_ipmi_exit(
void)
517 acpi_remove_ipmi_device(ipmi_device);