Lines Matching +full:ipmi +full:- +full:ipmb

1 // SPDX-License-Identifier: GPL-2.0+
5 * The interface to the IPMI driver for SMBus access to a SMBus
6 * compliant device. Called SSIF by the IPMI spec.
12 * non-blocking I2C interface, add support for multi-part
63 /* ssif_debug is a bit-field
64 * SSIF_DEBUG_MSG - commands and their responses
65 * SSIF_DEBUG_STATES - message states
66 * SSIF_DEBUG_TIMING - Measure times between events in the driver
100 /* FIXME - add watchdog stuff. */
103 #define SSIF_IDLE(ssif) ((ssif)->ssif_state == SSIF_NORMAL \
104 && (ssif)->curr_msg == NULL)
245 * Used to perform timer operations when run-to-completion
293 atomic_inc(&(ssif)->stats[SSIF_STAT_ ## stat])
295 ((unsigned int) atomic_read(&(ssif)->stats[SSIF_STAT_ ## stat]))
309 __acquires(&ssif_info->lock) in ipmi_ssif_lock_cond()
311 spin_lock_irqsave(&ssif_info->lock, *flags); in ipmi_ssif_lock_cond()
317 __releases(&ssif_info->lock) in ipmi_ssif_unlock_cond()
319 spin_unlock_irqrestore(&ssif_info->lock, *flags); in ipmi_ssif_unlock_cond()
325 if (msg->rsp_size < 0) { in deliver_recv_msg()
327 dev_err(&ssif_info->client->dev, in deliver_recv_msg()
329 __func__, msg->rsp_size); in deliver_recv_msg()
331 ipmi_smi_msg_received(ssif_info->intf, msg); in deliver_recv_msg()
341 msg->rsp[0] = msg->data[0] | 4; in return_hosed_msg()
342 msg->rsp[1] = msg->data[1]; in return_hosed_msg()
343 msg->rsp[2] = 0xFF; /* Unknown error. */ in return_hosed_msg()
344 msg->rsp_size = 3; in return_hosed_msg()
359 ssif_info->msg_flags &= ~WDT_PRE_TIMEOUT_INT; in start_clear_flags()
360 ssif_info->ssif_state = SSIF_CLEARING_FLAGS; in start_clear_flags()
363 /* Make sure the watchdog pre-timeout flag is not set at startup. */ in start_clear_flags()
370 ssif_info->ssif_state = SSIF_NORMAL; in start_clear_flags()
378 ssif_info->req_flags = false; in start_flag_fetch()
379 ssif_info->ssif_state = SSIF_GETTING_FLAGS; in start_flag_fetch()
385 ssif_info->ssif_state = SSIF_NORMAL; in start_flag_fetch()
391 if (start_send(ssif_info, msg->data, msg->data_size) != 0) { in check_start_send()
395 ssif_info->curr_msg = NULL; in check_start_send()
396 ssif_info->ssif_state = SSIF_NORMAL; in check_start_send()
406 ssif_info->req_events = false; in start_event_fetch()
410 ssif_info->ssif_state = SSIF_NORMAL; in start_event_fetch()
415 ssif_info->curr_msg = msg; in start_event_fetch()
416 ssif_info->ssif_state = SSIF_GETTING_EVENTS; in start_event_fetch()
419 msg->data[0] = (IPMI_NETFN_APP_REQUEST << 2); in start_event_fetch()
420 msg->data[1] = IPMI_READ_EVENT_MSG_BUFFER_CMD; in start_event_fetch()
421 msg->data_size = 2; in start_event_fetch()
433 ssif_info->ssif_state = SSIF_NORMAL; in start_recv_msg_fetch()
438 ssif_info->curr_msg = msg; in start_recv_msg_fetch()
439 ssif_info->ssif_state = SSIF_GETTING_MESSAGES; in start_recv_msg_fetch()
442 msg->data[0] = (IPMI_NETFN_APP_REQUEST << 2); in start_recv_msg_fetch()
443 msg->data[1] = IPMI_GET_MSG_CMD; in start_recv_msg_fetch()
444 msg->data_size = 2; in start_recv_msg_fetch()
457 if (ssif_info->msg_flags & WDT_PRE_TIMEOUT_INT) { in handle_flags()
458 /* Watchdog pre-timeout */ in handle_flags()
461 ipmi_smi_watchdog_pretimeout(ssif_info->intf); in handle_flags()
462 } else if (ssif_info->msg_flags & RECEIVE_MSG_AVAIL) in handle_flags()
465 else if (ssif_info->msg_flags & EVENT_MSG_BUFFER_FULL) in handle_flags()
469 ssif_info->ssif_state = SSIF_NORMAL; in handle_flags()
483 &ssif_info->wake_thread); in ipmi_ssif_thread()
484 if (ssif_info->stopping) in ipmi_ssif_thread()
486 if (result == -ERESTARTSYS) in ipmi_ssif_thread()
488 init_completion(&ssif_info->wake_thread); in ipmi_ssif_thread()
490 if (ssif_info->i2c_read_write == I2C_SMBUS_WRITE) { in ipmi_ssif_thread()
492 ssif_info->client, ssif_info->i2c_command, in ipmi_ssif_thread()
493 ssif_info->i2c_data[0], in ipmi_ssif_thread()
494 ssif_info->i2c_data + 1); in ipmi_ssif_thread()
495 ssif_info->done_handler(ssif_info, result, NULL, 0); in ipmi_ssif_thread()
498 ssif_info->client, ssif_info->i2c_command, in ipmi_ssif_thread()
499 ssif_info->i2c_data); in ipmi_ssif_thread()
501 ssif_info->done_handler(ssif_info, result, in ipmi_ssif_thread()
504 ssif_info->done_handler(ssif_info, 0, in ipmi_ssif_thread()
505 ssif_info->i2c_data, in ipmi_ssif_thread()
518 ssif_info->done_handler = handler; in ssif_i2c_send()
520 ssif_info->i2c_read_write = read_write; in ssif_i2c_send()
521 ssif_info->i2c_command = command; in ssif_i2c_send()
522 ssif_info->i2c_data = data; in ssif_i2c_send()
523 ssif_info->i2c_size = size; in ssif_i2c_send()
524 complete(&ssif_info->wake_thread); in ssif_i2c_send()
533 ssif_info->rtc_us_timer = 0; in start_get()
534 ssif_info->multi_pos = 0; in start_get()
538 ssif_info->recv, I2C_SMBUS_BLOCK_DATA); in start_get()
547 if (ssif_info->stopping) in retry_timeout()
551 waiting = ssif_info->waiting_alert; in retry_timeout()
552 ssif_info->waiting_alert = false; in retry_timeout()
564 if (ssif_info->stopping) in watch_timeout()
568 if (ssif_info->watch_timeout) { in watch_timeout()
569 mod_timer(&ssif_info->watch_timer, in watch_timeout()
570 jiffies + ssif_info->watch_timeout); in watch_timeout()
575 ssif_info->req_flags = true; in watch_timeout()
593 if (ssif_info->waiting_alert) { in ssif_alert()
594 ssif_info->waiting_alert = false; in ssif_alert()
595 del_timer(&ssif_info->retry_timer); in ssif_alert()
597 } else if (ssif_info->curr_msg) { in ssif_alert()
598 ssif_info->got_alert = true; in ssif_alert()
614 * We are single-threaded here, so no need for a lock until we in msg_done_handler()
619 ssif_info->retries_left--; in msg_done_handler()
620 if (ssif_info->retries_left > 0) { in msg_done_handler()
624 ssif_info->waiting_alert = true; in msg_done_handler()
625 ssif_info->rtc_us_timer = SSIF_MSG_USEC; in msg_done_handler()
626 if (!ssif_info->stopping) in msg_done_handler()
627 mod_timer(&ssif_info->retry_timer, in msg_done_handler()
635 if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) in msg_done_handler()
636 dev_dbg(&ssif_info->client->dev, in msg_done_handler()
642 if ((len > 1) && (ssif_info->multi_pos == 0) in msg_done_handler()
644 /* Start of multi-part read. Start the next transaction. */ in msg_done_handler()
649 /* Remove the multi-part read marker. */ in msg_done_handler()
650 len -= 2; in msg_done_handler()
653 ssif_info->data[i] = data[i]; in msg_done_handler()
654 ssif_info->multi_len = len; in msg_done_handler()
655 ssif_info->multi_pos = 1; in msg_done_handler()
659 ssif_info->recv, I2C_SMBUS_BLOCK_DATA); in msg_done_handler()
661 } else if (ssif_info->multi_pos) { in msg_done_handler()
662 /* Middle of multi-part read. Start the next transaction. */ in msg_done_handler()
667 result = -EIO; in msg_done_handler()
668 if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) in msg_done_handler()
669 dev_dbg(&ssif_info->client->dev, in msg_done_handler()
676 len--; in msg_done_handler()
681 result = -EIO; in msg_done_handler()
682 if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) in msg_done_handler()
683 dev_dbg(&ssif_info->client->dev, in msg_done_handler()
689 if (ssif_info->multi_len + len > IPMI_MAX_MSG_LENGTH) { in msg_done_handler()
691 result = -E2BIG; in msg_done_handler()
692 if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) in msg_done_handler()
693 dev_dbg(&ssif_info->client->dev, in msg_done_handler()
700 ssif_info->data[i + ssif_info->multi_len] = data[i]; in msg_done_handler()
701 ssif_info->multi_len += len; in msg_done_handler()
704 len = ssif_info->multi_len; in msg_done_handler()
705 data = ssif_info->data; in msg_done_handler()
706 } else if (blocknum + 1 != ssif_info->multi_pos) { in msg_done_handler()
712 if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) in msg_done_handler()
713 dev_dbg(&ssif_info->client->dev, in msg_done_handler()
715 ssif_info->multi_pos - 1, blocknum); in msg_done_handler()
716 result = -EIO; in msg_done_handler()
720 ssif_info->multi_pos++; in msg_done_handler()
725 ssif_info->recv, in msg_done_handler()
739 if (ssif_info->ssif_debug & SSIF_DEBUG_STATE) in msg_done_handler()
740 dev_dbg(&ssif_info->client->dev, in msg_done_handler()
742 ssif_info->ssif_state, result); in msg_done_handler()
745 msg = ssif_info->curr_msg; in msg_done_handler()
750 memcpy(msg->rsp, data, len); in msg_done_handler()
754 msg->rsp_size = len; in msg_done_handler()
755 ssif_info->curr_msg = NULL; in msg_done_handler()
758 switch (ssif_info->ssif_state) { in msg_done_handler()
777 ssif_info->ssif_state = SSIF_NORMAL; in msg_done_handler()
779 dev_warn(&ssif_info->client->dev, in msg_done_handler()
789 dev_warn(&ssif_info->client->dev, in msg_done_handler()
794 ssif_info->msg_flags = data[3]; in msg_done_handler()
803 dev_warn(&ssif_info->client->dev, in msg_done_handler()
808 dev_warn(&ssif_info->client->dev, in msg_done_handler()
812 ssif_info->ssif_state = SSIF_NORMAL; in msg_done_handler()
819 dev_warn(&ssif_info->client->dev, in msg_done_handler()
825 if ((result < 0) || (len < 3) || (msg->rsp[2] != 0)) { in msg_done_handler()
827 msg->done(msg); in msg_done_handler()
830 ssif_info->msg_flags &= ~EVENT_MSG_BUFFER_FULL; in msg_done_handler()
832 } else if (msg->rsp[0] != (IPMI_NETFN_APP_REQUEST | 1) << 2 in msg_done_handler()
833 || msg->rsp[1] != IPMI_READ_EVENT_MSG_BUFFER_CMD) { in msg_done_handler()
834 dev_warn(&ssif_info->client->dev, in msg_done_handler()
836 msg->rsp[0], msg->rsp[1]); in msg_done_handler()
837 msg->done(msg); in msg_done_handler()
839 ssif_info->msg_flags &= ~EVENT_MSG_BUFFER_FULL; in msg_done_handler()
851 dev_warn(&ssif_info->client->dev, in msg_done_handler()
857 if ((result < 0) || (len < 3) || (msg->rsp[2] != 0)) { in msg_done_handler()
859 msg->done(msg); in msg_done_handler()
862 ssif_info->msg_flags &= ~RECEIVE_MSG_AVAIL; in msg_done_handler()
864 } else if (msg->rsp[0] != (IPMI_NETFN_APP_REQUEST | 1) << 2 in msg_done_handler()
865 || msg->rsp[1] != IPMI_GET_MSG_CMD) { in msg_done_handler()
866 dev_warn(&ssif_info->client->dev, in msg_done_handler()
868 msg->rsp[0], msg->rsp[1]); in msg_done_handler()
869 msg->done(msg); in msg_done_handler()
872 ssif_info->msg_flags &= ~RECEIVE_MSG_AVAIL; in msg_done_handler()
883 dev_warn(&ssif_info->client->dev, in msg_done_handler()
885 ssif_info->ssif_state); in msg_done_handler()
890 if (SSIF_IDLE(ssif_info) && !ssif_info->stopping) { in msg_done_handler()
891 if (ssif_info->req_events) in msg_done_handler()
893 else if (ssif_info->req_flags) in msg_done_handler()
900 if (ssif_info->ssif_debug & SSIF_DEBUG_STATE) in msg_done_handler()
901 dev_dbg(&ssif_info->client->dev, in msg_done_handler()
902 "DONE 2: state = %d.\n", ssif_info->ssif_state); in msg_done_handler()
908 /* We are single-threaded here, so no need for a lock. */ in msg_written_handler()
910 ssif_info->retries_left--; in msg_written_handler()
911 if (ssif_info->retries_left > 0) { in msg_written_handler()
919 if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) in msg_written_handler()
920 dev_dbg(&ssif_info->client->dev, in msg_written_handler()
922 msg_done_handler(ssif_info, -EIO, NULL, 0); in msg_written_handler()
932 if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) in msg_written_handler()
933 dev_dbg(&ssif_info->client->dev, in msg_written_handler()
940 if (ssif_info->multi_data) { in msg_written_handler()
942 * In the middle of a multi-data write. See the comment in msg_written_handler()
952 left = ssif_info->multi_len - ssif_info->multi_pos; in msg_written_handler()
957 ssif_info->multi_data[ssif_info->multi_pos] = to_write; in msg_written_handler()
958 data_to_send = ssif_info->multi_data + ssif_info->multi_pos; in msg_written_handler()
959 ssif_info->multi_pos += to_write; in msg_written_handler()
961 if (ssif_info->cmd8_works) { in msg_written_handler()
964 ssif_info->multi_data = NULL; in msg_written_handler()
967 ssif_info->multi_data = NULL; in msg_written_handler()
981 if (ssif_info->got_alert) { in msg_written_handler()
983 ssif_info->got_alert = false; in msg_written_handler()
988 ssif_info->waiting_alert = true; in msg_written_handler()
989 ssif_info->retries_left = SSIF_RECV_RETRIES; in msg_written_handler()
990 ssif_info->rtc_us_timer = SSIF_MSG_PART_USEC; in msg_written_handler()
991 if (!ssif_info->stopping) in msg_written_handler()
992 mod_timer(&ssif_info->retry_timer, in msg_written_handler()
1003 ssif_info->got_alert = false; in start_resend()
1005 if (ssif_info->data_len > 32) { in start_resend()
1007 ssif_info->multi_data = ssif_info->data; in start_resend()
1008 ssif_info->multi_len = ssif_info->data_len; in start_resend()
1014 ssif_info->multi_pos = 32; in start_resend()
1015 ssif_info->data[0] = 32; in start_resend()
1017 ssif_info->multi_data = NULL; in start_resend()
1019 ssif_info->data[0] = ssif_info->data_len; in start_resend()
1023 command, ssif_info->data, I2C_SMBUS_BLOCK_DATA); in start_resend()
1032 return -E2BIG; in start_send()
1033 if (len > ssif_info->max_xmit_msg_size) in start_send()
1034 return -E2BIG; in start_send()
1036 ssif_info->retries_left = SSIF_SEND_RETRIES; in start_send()
1037 memcpy(ssif_info->data + 1, data, len); in start_send()
1038 ssif_info->data_len = len; in start_send()
1054 if (!ssif_info->waiting_msg) { in start_next_msg()
1055 ssif_info->curr_msg = NULL; in start_next_msg()
1060 ssif_info->curr_msg = ssif_info->waiting_msg; in start_next_msg()
1061 ssif_info->waiting_msg = NULL; in start_next_msg()
1064 ssif_info->curr_msg->data, in start_next_msg()
1065 ssif_info->curr_msg->data_size); in start_next_msg()
1067 msg = ssif_info->curr_msg; in start_next_msg()
1068 ssif_info->curr_msg = NULL; in start_next_msg()
1082 BUG_ON(ssif_info->waiting_msg); in sender()
1083 ssif_info->waiting_msg = msg; in sender()
1088 if (ssif_info->ssif_debug & SSIF_DEBUG_TIMING) { in sender()
1092 dev_dbg(&ssif_info->client->dev, in sender()
1094 msg->data[0], msg->data[1], in sender()
1103 data->addr_src = ssif_info->addr_source; in get_smi_info()
1104 data->dev = &ssif_info->client->dev; in get_smi_info()
1105 data->addr_info = ssif_info->addr_info; in get_smi_info()
1106 get_device(data->dev); in get_smi_info()
1119 if (!ssif_info->has_event_buffer) in request_events()
1123 ssif_info->req_events = true; in request_events()
1143 if (timeout != ssif_info->watch_timeout) { in ssif_set_need_watch()
1144 ssif_info->watch_timeout = timeout; in ssif_set_need_watch()
1145 if (ssif_info->watch_timeout) in ssif_set_need_watch()
1146 mod_timer(&ssif_info->watch_timer, in ssif_set_need_watch()
1147 jiffies + ssif_info->watch_timeout); in ssif_set_need_watch()
1157 ssif_info->intf = intf; in ssif_start_processing()
1167 MODULE_PARM_DESC(addr, "The addresses to scan for IPMI BMCs on the SSIFs.");
1178 "The default IPMB slave address for the controller.");
1268 device_remove_group(&ssif_info->client->dev, &ipmi_ssif_dev_attr_group); in shutdown_ssif()
1269 dev_set_drvdata(&ssif_info->client->dev, NULL); in shutdown_ssif()
1272 while (ssif_info->ssif_state != SSIF_NORMAL) in shutdown_ssif()
1275 ssif_info->stopping = true; in shutdown_ssif()
1276 del_timer_sync(&ssif_info->watch_timer); in shutdown_ssif()
1277 del_timer_sync(&ssif_info->retry_timer); in shutdown_ssif()
1278 if (ssif_info->thread) { in shutdown_ssif()
1279 complete(&ssif_info->wake_thread); in shutdown_ssif()
1280 kthread_stop(ssif_info->thread); in shutdown_ssif()
1296 ipmi_unregister_smi(ssif_info->intf); in ssif_remove()
1299 if (addr_info->client == client) { in ssif_remove()
1300 addr_info->client = NULL; in ssif_remove()
1310 int ret = -ENODEV, retry_cnt = SSIF_RECV_RETRIES; in read_response()
1318 retry_cnt--; in read_response()
1336 retry_cnt--; in do_cmd()
1339 return -ENODEV; in do_cmd()
1348 ret = -EINVAL; in do_cmd()
1350 ret = -E2BIG; in do_cmd()
1369 return -ENOMEM; in ssif_detect()
1376 rv = -ENODEV; in ssif_detect()
1378 strscpy(info->type, DEVICE_NAME, I2C_NAME_SIZE); in ssif_detect()
1393 return -1; in strcmp_nospace()
1408 if (info->binfo.addr == addr) { in ssif_info_find()
1409 if (info->addr_src == SI_SMBIOS) in ssif_info_find()
1410 info->adapter_name = kstrdup(adapter_name, in ssif_info_find()
1413 if (info->adapter_name || adapter_name) { in ssif_info_find()
1414 if (!info->adapter_name != !adapter_name) { in ssif_info_find()
1419 strcmp_nospace(info->adapter_name, in ssif_info_find()
1446 ssif_info->addr_source = SI_ACPI; in check_acpi()
1447 ssif_info->addr_info.acpi_info.acpi_handle = acpi_handle; in check_acpi()
1461 i2c_adapter_id(client->adapter), in find_slave_address()
1462 client->addr); in find_slave_address()
1478 retry_cnt--; in start_multipart_test()
1481 …dev_err(&client->dev, "Could not write multi-part start, though the BMC said it could handle it. … in start_multipart_test()
1492 …dev_err(&client->dev, "Could not write multi-part middle, though the BMC said it could handle it. … in start_multipart_test()
1507 if (ssif_info->max_xmit_msg_size <= 32) in test_multipart_messages()
1510 do_middle = ssif_info->max_xmit_msg_size > 63; in test_multipart_messages()
1518 * multi-part messages. Per what the specification says, it in test_multipart_messages()
1532 * implement cmd=8, they use a zero-length end transaction, in test_multipart_messages()
1536 * If it does, then we use that. If not, it tests zero- in test_multipart_messages()
1538 * we only allow 63-byte transactions max. in test_multipart_messages()
1554 ssif_info->cmd8_works = true; in test_multipart_messages()
1560 dev_err(&client->dev, "Second multipart test failed.\n"); in test_multipart_messages()
1570 /* Zero-size end parts work, use those. */ in test_multipart_messages()
1574 if (ssif_info->max_xmit_msg_size > 63) in test_multipart_messages()
1575 ssif_info->max_xmit_msg_size = 63; in test_multipart_messages()
1579 ssif_info->max_xmit_msg_size = 32; in test_multipart_messages()
1593 ipmi_unregister_smi(ssif_info->intf); in ssif_remove_dup()
1603 return -ENOMEM; in ssif_add_infos()
1604 info->addr_src = SI_ACPI; in ssif_add_infos()
1605 info->client = client; in ssif_add_infos()
1606 info->adapter_name = kstrdup(client->adapter->name, GFP_KERNEL); in ssif_add_infos()
1607 info->binfo.addr = client->addr; in ssif_add_infos()
1608 list_add_tail(&info->link, &ssif_infos); in ssif_add_infos()
1623 if (!info->client) in ssif_check_and_remove()
1625 if (!strcmp(info->adapter_name, client->adapter->name) && in ssif_check_and_remove()
1626 info->binfo.addr == client->addr) { in ssif_check_and_remove()
1627 if (info->addr_src == SI_ACPI) in ssif_check_and_remove()
1628 return -EEXIST; in ssif_check_and_remove()
1630 if (ssif_info->addr_source == SI_ACPI && in ssif_check_and_remove()
1631 info->addr_src == SI_SMBIOS) { in ssif_check_and_remove()
1632 dev_info(&client->dev, in ssif_check_and_remove()
1633 "Removing %s-specified SSIF interface in favor of ACPI\n", in ssif_check_and_remove()
1634 ipmi_addr_src_to_str(info->addr_src)); in ssif_check_and_remove()
1635 ssif_remove_dup(info->client); in ssif_check_and_remove()
1658 return -ENOMEM; in ssif_probe()
1665 return -ENOMEM; in ssif_probe()
1668 if (!check_acpi(ssif_info, &client->dev)) { in ssif_probe()
1669 addr_info = ssif_info_find(client->addr, client->adapter->name, in ssif_probe()
1673 ssif_info->addr_source = SI_HOTMOD; in ssif_probe()
1675 ssif_info->addr_source = addr_info->addr_src; in ssif_probe()
1676 ssif_info->ssif_debug = addr_info->debug; in ssif_probe()
1677 ssif_info->addr_info = addr_info->addr_info; in ssif_probe()
1678 addr_info->client = client; in ssif_probe()
1679 slave_addr = addr_info->slave_addr; in ssif_probe()
1683 ssif_info->client = client; in ssif_probe()
1688 if (!rv && ssif_info->addr_source == SI_ACPI) { in ssif_probe()
1691 dev_err(&client->dev, "Out of memory!, exiting ..\n"); in ssif_probe()
1695 dev_err(&client->dev, "Not probing, Interface already present\n"); in ssif_probe()
1701 dev_info(&client->dev, in ssif_probe()
1702 "Trying %s-specified SSIF interface at i2c address 0x%x, adapter %s, slave address 0x%x\n", in ssif_probe()
1703 ipmi_addr_src_to_str(ssif_info->addr_source), in ssif_probe()
1704 client->addr, client->adapter->name, slave_addr); in ssif_probe()
1714 dev_dbg(&ssif_info->client->dev, in ssif_probe()
1720 ssif_info->max_xmit_msg_size = resp[5]; in ssif_probe()
1721 ssif_info->max_recv_msg_size = resp[6]; in ssif_probe()
1722 ssif_info->multi_support = (resp[4] >> 6) & 0x3; in ssif_probe()
1723 ssif_info->supports_pec = (resp[4] >> 3) & 0x1; in ssif_probe()
1726 switch (ssif_info->multi_support) { in ssif_probe()
1728 if (ssif_info->max_xmit_msg_size > 32) in ssif_probe()
1729 ssif_info->max_xmit_msg_size = 32; in ssif_probe()
1730 if (ssif_info->max_recv_msg_size > 32) in ssif_probe()
1731 ssif_info->max_recv_msg_size = 32; in ssif_probe()
1735 if (ssif_info->max_xmit_msg_size > 63) in ssif_probe()
1736 ssif_info->max_xmit_msg_size = 63; in ssif_probe()
1737 if (ssif_info->max_recv_msg_size > 62) in ssif_probe()
1738 ssif_info->max_recv_msg_size = 62; in ssif_probe()
1751 /* Assume no multi-part or PEC support */ in ssif_probe()
1752 dev_info(&ssif_info->client->dev, in ssif_probe()
1756 ssif_info->max_xmit_msg_size = 32; in ssif_probe()
1757 ssif_info->max_recv_msg_size = 32; in ssif_probe()
1758 ssif_info->multi_support = SSIF_NO_MULTI; in ssif_probe()
1759 ssif_info->supports_pec = 0; in ssif_probe()
1770 dev_warn(&ssif_info->client->dev, in ssif_probe()
1779 dev_warn(&ssif_info->client->dev, in ssif_probe()
1786 ssif_info->global_enables = resp[3]; in ssif_probe()
1789 ssif_info->has_event_buffer = true; in ssif_probe()
1796 msg[2] = ssif_info->global_enables | IPMI_BMC_EVT_MSG_BUFF; in ssif_probe()
1799 dev_warn(&ssif_info->client->dev, in ssif_probe()
1808 ssif_info->has_event_buffer = true; in ssif_probe()
1809 ssif_info->global_enables |= IPMI_BMC_EVT_MSG_BUFF; in ssif_probe()
1818 msg[2] = ssif_info->global_enables | IPMI_BMC_RCV_MSG_INTR; in ssif_probe()
1821 dev_warn(&ssif_info->client->dev, in ssif_probe()
1830 ssif_info->supports_alert = true; in ssif_probe()
1831 ssif_info->global_enables |= IPMI_BMC_RCV_MSG_INTR; in ssif_probe()
1836 dev_dbg(&ssif_info->client->dev, in ssif_probe()
1838 __func__, client->addr); in ssif_probe()
1841 spin_lock_init(&ssif_info->lock); in ssif_probe()
1842 ssif_info->ssif_state = SSIF_NORMAL; in ssif_probe()
1843 timer_setup(&ssif_info->retry_timer, retry_timeout, 0); in ssif_probe()
1844 timer_setup(&ssif_info->watch_timer, watch_timeout, 0); in ssif_probe()
1847 atomic_set(&ssif_info->stats[i], 0); in ssif_probe()
1849 if (ssif_info->supports_pec) in ssif_probe()
1850 ssif_info->client->flags |= I2C_CLIENT_PEC; in ssif_probe()
1852 ssif_info->handlers.owner = THIS_MODULE; in ssif_probe()
1853 ssif_info->handlers.start_processing = ssif_start_processing; in ssif_probe()
1854 ssif_info->handlers.shutdown = shutdown_ssif; in ssif_probe()
1855 ssif_info->handlers.get_smi_info = get_smi_info; in ssif_probe()
1856 ssif_info->handlers.sender = sender; in ssif_probe()
1857 ssif_info->handlers.request_events = request_events; in ssif_probe()
1858 ssif_info->handlers.set_need_watch = ssif_set_need_watch; in ssif_probe()
1863 thread_num = ((i2c_adapter_id(ssif_info->client->adapter) in ssif_probe()
1865 ssif_info->client->addr); in ssif_probe()
1866 init_completion(&ssif_info->wake_thread); in ssif_probe()
1867 ssif_info->thread = kthread_run(ipmi_ssif_thread, ssif_info, in ssif_probe()
1869 if (IS_ERR(ssif_info->thread)) { in ssif_probe()
1870 rv = PTR_ERR(ssif_info->thread); in ssif_probe()
1871 dev_notice(&ssif_info->client->dev, in ssif_probe()
1878 dev_set_drvdata(&ssif_info->client->dev, ssif_info); in ssif_probe()
1879 rv = device_add_group(&ssif_info->client->dev, in ssif_probe()
1882 dev_err(&ssif_info->client->dev, in ssif_probe()
1888 rv = ipmi_register_smi(&ssif_info->handlers, in ssif_probe()
1890 &ssif_info->client->dev, in ssif_probe()
1893 dev_err(&ssif_info->client->dev, in ssif_probe()
1901 addr_info->client = NULL; in ssif_probe()
1903 dev_err(&ssif_info->client->dev, in ssif_probe()
1904 "Unable to start IPMI SSIF: %d\n", rv); in ssif_probe()
1913 device_remove_group(&ssif_info->client->dev, &ipmi_ssif_dev_attr_group); in ssif_probe()
1914 dev_set_drvdata(&ssif_info->client->dev, NULL); in ssif_probe()
1928 rv = -EEXIST; in new_ssif_client()
1934 rv = -ENOMEM; in new_ssif_client()
1939 addr_info->adapter_name = kstrdup(adapter_name, GFP_KERNEL); in new_ssif_client()
1940 if (!addr_info->adapter_name) { in new_ssif_client()
1942 rv = -ENOMEM; in new_ssif_client()
1947 strncpy(addr_info->binfo.type, DEVICE_NAME, in new_ssif_client()
1948 sizeof(addr_info->binfo.type)); in new_ssif_client()
1949 addr_info->binfo.addr = addr; in new_ssif_client()
1950 addr_info->binfo.platform_data = addr_info; in new_ssif_client()
1951 addr_info->debug = debug; in new_ssif_client()
1952 addr_info->slave_addr = slave_addr; in new_ssif_client()
1953 addr_info->addr_src = addr_src; in new_ssif_client()
1954 addr_info->dev = dev; in new_ssif_client()
1959 list_add_tail(&addr_info->link, &ssif_infos); in new_ssif_client()
1974 list_del(&info->link); in free_ssif_clients()
1975 kfree(info->adapter_name); in free_ssif_clients()
1996 unsigned short addr = info->binfo.addr; in ssif_address_list()
2028 return -ENODEV; in dmi_ipmi_probe()
2030 rv = device_property_read_u16(&pdev->dev, "i2c-addr", &i2c_addr); in dmi_ipmi_probe()
2032 dev_warn(&pdev->dev, "No i2c-addr property\n"); in dmi_ipmi_probe()
2033 return -ENODEV; in dmi_ipmi_probe()
2036 rv = device_property_read_u8(&pdev->dev, "slave-addr", &slave_addr); in dmi_ipmi_probe()
2041 slave_addr, SI_SMBIOS, &pdev->dev); in dmi_ipmi_probe()
2046 return -ENODEV; in dmi_ipmi_probe()
2075 struct ssif_addr_info *addr_info = dev_get_drvdata(&dev->dev); in ssif_platform_remove()
2081 list_del(&addr_info->link); in ssif_platform_remove()
2088 { "dmi-ipmi-ssif", 0 },
2109 pr_info("IPMI SSIF Interface driver\n"); in init_ipmi_ssif()
2161 MODULE_ALIAS("platform:dmi-ipmi-ssif");
2163 MODULE_DESCRIPTION("IPMI driver for management controllers on a SMBus");