Lines Matching +full:ssif +full:- +full:bmc

1 // SPDX-License-Identifier: GPL-2.0+
6 * compliant device. Called SSIF by the IPMI spec.
12 * non-blocking I2C interface, add support for multi-part
20 * This file holds the "policy" for the interface to the SSIF state
22 * and drives the real SSIF state machine.
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
103 /* FIXME - add watchdog stuff. */
106 #define IS_SSIF_IDLE(ssif) ((ssif)->ssif_state == SSIF_IDLE \ argument
107 && (ssif)->curr_msg == NULL)
275 /* Info from SSIF cmd */
292 #define ssif_inc_stat(ssif, stat) \ argument
293 atomic_inc(&(ssif)->stats[SSIF_STAT_ ## stat])
294 #define ssif_get_stat(ssif, stat) \ argument
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_IDLE; 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_IDLE; 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_IDLE; in check_start_send()
406 ssif_info->req_events = false; in start_event_fetch()
410 ssif_info->ssif_state = SSIF_IDLE; 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_IDLE; 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_IDLE; 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->multi_pos = 0; in start_get()
537 ssif_info->recv, I2C_SMBUS_BLOCK_DATA); in start_get()
548 if (ssif_info->stopping) in retry_timeout()
552 resend = ssif_info->do_resend; in retry_timeout()
553 ssif_info->do_resend = false; in retry_timeout()
554 waiting = ssif_info->waiting_alert; in retry_timeout()
555 ssif_info->waiting_alert = false; in retry_timeout()
571 if (ssif_info->stopping) in watch_timeout()
575 if (ssif_info->watch_timeout) { in watch_timeout()
576 mod_timer(&ssif_info->watch_timer, in watch_timeout()
577 jiffies + ssif_info->watch_timeout); in watch_timeout()
582 ssif_info->req_flags = true; in watch_timeout()
600 if (ssif_info->waiting_alert) { in ssif_alert()
601 ssif_info->waiting_alert = false; in ssif_alert()
602 del_timer(&ssif_info->retry_timer); in ssif_alert()
604 } else if (ssif_info->curr_msg) { in ssif_alert()
605 ssif_info->got_alert = true; in ssif_alert()
619 * We are single-threaded here, so no need for a lock until we in msg_done_handler()
624 ssif_info->retries_left--; in msg_done_handler()
625 if (ssif_info->retries_left > 0) { in msg_done_handler()
629 ssif_info->waiting_alert = true; in msg_done_handler()
630 if (!ssif_info->stopping) in msg_done_handler()
631 mod_timer(&ssif_info->retry_timer, in msg_done_handler()
639 if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) in msg_done_handler()
640 dev_dbg(&ssif_info->client->dev, in msg_done_handler()
646 if ((len > 1) && (ssif_info->multi_pos == 0) in msg_done_handler()
648 /* Start of multi-part read. Start the next transaction. */ in msg_done_handler()
653 /* Remove the multi-part read marker. */ in msg_done_handler()
654 len -= 2; in msg_done_handler()
657 ssif_info->data[i] = data[i]; in msg_done_handler()
658 ssif_info->multi_len = len; in msg_done_handler()
659 ssif_info->multi_pos = 1; in msg_done_handler()
663 ssif_info->recv, I2C_SMBUS_BLOCK_DATA); in msg_done_handler()
665 } else if (ssif_info->multi_pos) { in msg_done_handler()
666 /* Middle of multi-part read. Start the next transaction. */ in msg_done_handler()
671 result = -EIO; in msg_done_handler()
672 if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) in msg_done_handler()
673 dev_dbg(&ssif_info->client->dev, in msg_done_handler()
680 len--; in msg_done_handler()
685 result = -EIO; in msg_done_handler()
686 if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) in msg_done_handler()
687 dev_dbg(&ssif_info->client->dev, in msg_done_handler()
693 if (ssif_info->multi_len + len > IPMI_MAX_MSG_LENGTH) { in msg_done_handler()
695 result = -E2BIG; in msg_done_handler()
696 if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) in msg_done_handler()
697 dev_dbg(&ssif_info->client->dev, in msg_done_handler()
704 ssif_info->data[i + ssif_info->multi_len] = data[i]; in msg_done_handler()
705 ssif_info->multi_len += len; in msg_done_handler()
708 len = ssif_info->multi_len; in msg_done_handler()
709 data = ssif_info->data; in msg_done_handler()
710 } else if (blocknum + 1 != ssif_info->multi_pos) { in msg_done_handler()
716 if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) in msg_done_handler()
717 dev_dbg(&ssif_info->client->dev, in msg_done_handler()
719 ssif_info->multi_pos - 1, blocknum); in msg_done_handler()
720 result = -EIO; in msg_done_handler()
724 ssif_info->multi_pos++; in msg_done_handler()
729 ssif_info->recv, in msg_done_handler()
743 if (ssif_info->ssif_debug & SSIF_DEBUG_STATE) in msg_done_handler()
744 dev_dbg(&ssif_info->client->dev, in msg_done_handler()
746 ssif_info->ssif_state, result); in msg_done_handler()
749 msg = ssif_info->curr_msg; in msg_done_handler()
754 memcpy(msg->rsp, data, len); in msg_done_handler()
758 msg->rsp_size = len; in msg_done_handler()
759 ssif_info->curr_msg = NULL; in msg_done_handler()
762 switch (ssif_info->ssif_state) { in msg_done_handler()
775 /* We got the flags from the SSIF, now handle them. */ in msg_done_handler()
781 ssif_info->ssif_state = SSIF_IDLE; in msg_done_handler()
783 dev_warn(&ssif_info->client->dev, in msg_done_handler()
791 ssif_info->ssif_state = SSIF_IDLE; in msg_done_handler()
793 dev_warn(&ssif_info->client->dev, in msg_done_handler()
798 ssif_info->msg_flags = data[3]; in msg_done_handler()
807 dev_warn(&ssif_info->client->dev, in msg_done_handler()
812 dev_warn(&ssif_info->client->dev, in msg_done_handler()
816 ssif_info->ssif_state = SSIF_IDLE; in msg_done_handler()
823 dev_warn(&ssif_info->client->dev, in msg_done_handler()
829 if ((result < 0) || (len < 3) || (msg->rsp[2] != 0)) { in msg_done_handler()
831 msg->done(msg); in msg_done_handler()
834 ssif_info->msg_flags &= ~EVENT_MSG_BUFFER_FULL; in msg_done_handler()
836 } else if (msg->rsp[0] != (IPMI_NETFN_APP_REQUEST | 1) << 2 in msg_done_handler()
837 || msg->rsp[1] != IPMI_READ_EVENT_MSG_BUFFER_CMD) { in msg_done_handler()
838 dev_warn(&ssif_info->client->dev, in msg_done_handler()
840 msg->rsp[0], msg->rsp[1]); in msg_done_handler()
841 msg->done(msg); in msg_done_handler()
843 ssif_info->msg_flags &= ~EVENT_MSG_BUFFER_FULL; in msg_done_handler()
855 dev_warn(&ssif_info->client->dev, in msg_done_handler()
861 if ((result < 0) || (len < 3) || (msg->rsp[2] != 0)) { in msg_done_handler()
863 msg->done(msg); in msg_done_handler()
866 ssif_info->msg_flags &= ~RECEIVE_MSG_AVAIL; in msg_done_handler()
868 } else if (msg->rsp[0] != (IPMI_NETFN_APP_REQUEST | 1) << 2 in msg_done_handler()
869 || msg->rsp[1] != IPMI_GET_MSG_CMD) { in msg_done_handler()
870 dev_warn(&ssif_info->client->dev, in msg_done_handler()
872 msg->rsp[0], msg->rsp[1]); in msg_done_handler()
873 msg->done(msg); in msg_done_handler()
876 ssif_info->msg_flags &= ~RECEIVE_MSG_AVAIL; in msg_done_handler()
887 dev_warn(&ssif_info->client->dev, in msg_done_handler()
889 ssif_info->ssif_state); in msg_done_handler()
894 if (IS_SSIF_IDLE(ssif_info) && !ssif_info->stopping) { in msg_done_handler()
895 if (ssif_info->req_events) in msg_done_handler()
897 else if (ssif_info->req_flags) in msg_done_handler()
904 if (ssif_info->ssif_debug & SSIF_DEBUG_STATE) in msg_done_handler()
905 dev_dbg(&ssif_info->client->dev, in msg_done_handler()
906 "DONE 2: state = %d.\n", ssif_info->ssif_state); in msg_done_handler()
912 /* We are single-threaded here, so no need for a lock. */ in msg_written_handler()
914 ssif_info->retries_left--; in msg_written_handler()
915 if (ssif_info->retries_left > 0) { in msg_written_handler()
920 ssif_info->do_resend = true; in msg_written_handler()
921 mod_timer(&ssif_info->retry_timer, in msg_written_handler()
928 if (ssif_info->ssif_debug & SSIF_DEBUG_MSG) in msg_written_handler()
929 dev_dbg(&ssif_info->client->dev, in msg_written_handler()
932 msg_done_handler(ssif_info, -EIO, NULL, 0); in msg_written_handler()
936 if (ssif_info->multi_data) { in msg_written_handler()
938 * In the middle of a multi-data write. See the comment in msg_written_handler()
948 left = ssif_info->multi_len - ssif_info->multi_pos; in msg_written_handler()
953 ssif_info->multi_data[ssif_info->multi_pos] = to_write; in msg_written_handler()
954 data_to_send = ssif_info->multi_data + ssif_info->multi_pos; in msg_written_handler()
955 ssif_info->multi_pos += to_write; in msg_written_handler()
957 if (ssif_info->cmd8_works) { in msg_written_handler()
960 ssif_info->multi_data = NULL; in msg_written_handler()
963 ssif_info->multi_data = NULL; in msg_written_handler()
977 if (ssif_info->got_alert) { in msg_written_handler()
979 ssif_info->got_alert = false; in msg_written_handler()
984 ssif_info->waiting_alert = true; in msg_written_handler()
985 ssif_info->retries_left = SSIF_RECV_RETRIES; in msg_written_handler()
986 if (!ssif_info->stopping) in msg_written_handler()
987 mod_timer(&ssif_info->retry_timer, in msg_written_handler()
998 ssif_info->got_alert = false; in start_resend()
1000 if (ssif_info->data_len > 32) { in start_resend()
1002 ssif_info->multi_data = ssif_info->data; in start_resend()
1003 ssif_info->multi_len = ssif_info->data_len; in start_resend()
1009 ssif_info->multi_pos = 32; in start_resend()
1010 ssif_info->data[0] = 32; in start_resend()
1012 ssif_info->multi_data = NULL; in start_resend()
1014 ssif_info->data[0] = ssif_info->data_len; in start_resend()
1018 command, ssif_info->data, I2C_SMBUS_BLOCK_DATA); in start_resend()
1026 return -E2BIG; in start_send()
1027 if (len > ssif_info->max_xmit_msg_size) in start_send()
1028 return -E2BIG; in start_send()
1030 ssif_info->retries_left = SSIF_SEND_RETRIES; in start_send()
1031 memcpy(ssif_info->data + 1, data, len); in start_send()
1032 ssif_info->data_len = len; in start_send()
1049 if (!ssif_info->waiting_msg) { in start_next_msg()
1050 ssif_info->curr_msg = NULL; in start_next_msg()
1055 ssif_info->curr_msg = ssif_info->waiting_msg; in start_next_msg()
1056 ssif_info->waiting_msg = NULL; in start_next_msg()
1059 ssif_info->curr_msg->data, in start_next_msg()
1060 ssif_info->curr_msg->data_size); in start_next_msg()
1062 msg = ssif_info->curr_msg; in start_next_msg()
1063 ssif_info->curr_msg = NULL; in start_next_msg()
1077 BUG_ON(ssif_info->waiting_msg); in sender()
1078 ssif_info->waiting_msg = msg; in sender()
1083 if (ssif_info->ssif_debug & SSIF_DEBUG_TIMING) { in sender()
1087 dev_dbg(&ssif_info->client->dev, in sender()
1089 msg->data[0], msg->data[1], in sender()
1098 data->addr_src = ssif_info->addr_source; in get_smi_info()
1099 data->dev = &ssif_info->client->dev; in get_smi_info()
1100 data->addr_info = ssif_info->addr_info; in get_smi_info()
1101 get_device(data->dev); in get_smi_info()
1114 if (!ssif_info->has_event_buffer) in request_events()
1118 ssif_info->req_events = true; in request_events()
1138 if (timeout != ssif_info->watch_timeout) { in ssif_set_need_watch()
1139 ssif_info->watch_timeout = timeout; in ssif_set_need_watch()
1140 if (ssif_info->watch_timeout) in ssif_set_need_watch()
1141 mod_timer(&ssif_info->watch_timer, in ssif_set_need_watch()
1142 jiffies + ssif_info->watch_timeout); in ssif_set_need_watch()
1152 ssif_info->intf = intf; in ssif_start_processing()
1167 MODULE_PARM_DESC(adapter_name, "The string name of the I2C device that has the BMC. By default all…
1219 return sysfs_emit(buf, "ssif\n"); in ipmi_type_show()
1263 device_remove_group(&ssif_info->client->dev, &ipmi_ssif_dev_attr_group); in shutdown_ssif()
1264 dev_set_drvdata(&ssif_info->client->dev, NULL); in shutdown_ssif()
1267 while (ssif_info->ssif_state != SSIF_IDLE) in shutdown_ssif()
1270 ssif_info->stopping = true; in shutdown_ssif()
1271 del_timer_sync(&ssif_info->watch_timer); in shutdown_ssif()
1272 del_timer_sync(&ssif_info->retry_timer); in shutdown_ssif()
1273 if (ssif_info->thread) { in shutdown_ssif()
1274 complete(&ssif_info->wake_thread); in shutdown_ssif()
1275 kthread_stop(ssif_info->thread); in shutdown_ssif()
1288 ipmi_unregister_smi(ssif_info->intf); in ssif_remove()
1291 if (addr_info->client == client) { in ssif_remove()
1292 addr_info->client = NULL; in ssif_remove()
1302 int ret = -ENODEV, retry_cnt = SSIF_RECV_RETRIES; in read_response()
1310 retry_cnt--; in read_response()
1328 retry_cnt--; in do_cmd()
1333 return -ENODEV; in do_cmd()
1342 ret = -EINVAL; in do_cmd()
1344 ret = -E2BIG; in do_cmd()
1363 return -ENOMEM; in ssif_detect()
1370 rv = -ENODEV; in ssif_detect()
1373 rv = -ENODEV; in ssif_detect()
1378 resp + 2, len - 2, &id); in ssif_detect()
1380 rv = -ENODEV; /* Error means a BMC probably isn't there. */ in ssif_detect()
1383 strscpy(info->type, DEVICE_NAME, I2C_NAME_SIZE); in ssif_detect()
1399 return -1; in strcmp_nospace()
1414 if (info->binfo.addr == addr) { in ssif_info_find()
1415 if (info->addr_src == SI_SMBIOS && !info->adapter_name) in ssif_info_find()
1416 info->adapter_name = kstrdup(adapter_name, in ssif_info_find()
1419 if (info->adapter_name || adapter_name) { in ssif_info_find()
1420 if (!info->adapter_name != !adapter_name) { in ssif_info_find()
1425 strcmp_nospace(info->adapter_name, in ssif_info_find()
1452 ssif_info->addr_source = SI_ACPI; in check_acpi()
1453 ssif_info->addr_info.acpi_info.acpi_handle = acpi_handle; in check_acpi()
1467 i2c_adapter_id(client->adapter), in find_slave_address()
1468 client->addr); in find_slave_address()
1484 retry_cnt--; in start_multipart_test()
1489 …dev_err(&client->dev, "Could not write multi-part start, though the BMC said it could handle it. … in start_multipart_test()
1500 …dev_err(&client->dev, "Could not write multi-part middle, though the BMC said it could handle it. … in start_multipart_test()
1515 if (ssif_info->max_xmit_msg_size <= 32) in test_multipart_messages()
1518 do_middle = ssif_info->max_xmit_msg_size > 63; in test_multipart_messages()
1526 * multi-part messages. Per what the specification says, it in test_multipart_messages()
1540 * implement cmd=8, they use a zero-length end transaction, in test_multipart_messages()
1544 * If it does, then we use that. If not, it tests zero- in test_multipart_messages()
1546 * we only allow 63-byte transactions max. in test_multipart_messages()
1562 ssif_info->cmd8_works = true; in test_multipart_messages()
1568 dev_err(&client->dev, "Second multipart test failed.\n"); in test_multipart_messages()
1578 /* Zero-size end parts work, use those. */ in test_multipart_messages()
1582 if (ssif_info->max_xmit_msg_size > 63) in test_multipart_messages()
1583 ssif_info->max_xmit_msg_size = 63; in test_multipart_messages()
1587 ssif_info->max_xmit_msg_size = 32; in test_multipart_messages()
1601 ipmi_unregister_smi(ssif_info->intf); in ssif_remove_dup()
1611 return -ENOMEM; in ssif_add_infos()
1612 info->addr_src = SI_ACPI; in ssif_add_infos()
1613 info->client = client; in ssif_add_infos()
1614 info->adapter_name = kstrdup(client->adapter->name, GFP_KERNEL); in ssif_add_infos()
1615 if (!info->adapter_name) { in ssif_add_infos()
1617 return -ENOMEM; in ssif_add_infos()
1620 info->binfo.addr = client->addr; in ssif_add_infos()
1621 list_add_tail(&info->link, &ssif_infos); in ssif_add_infos()
1636 if (!info->client) in ssif_check_and_remove()
1638 if (!strcmp(info->adapter_name, client->adapter->name) && in ssif_check_and_remove()
1639 info->binfo.addr == client->addr) { in ssif_check_and_remove()
1640 if (info->addr_src == SI_ACPI) in ssif_check_and_remove()
1641 return -EEXIST; in ssif_check_and_remove()
1643 if (ssif_info->addr_source == SI_ACPI && in ssif_check_and_remove()
1644 info->addr_src == SI_SMBIOS) { in ssif_check_and_remove()
1645 dev_info(&client->dev, in ssif_check_and_remove()
1646 "Removing %s-specified SSIF interface in favor of ACPI\n", in ssif_check_and_remove()
1647 ipmi_addr_src_to_str(info->addr_src)); in ssif_check_and_remove()
1648 ssif_remove_dup(info->client); in ssif_check_and_remove()
1671 return -ENOMEM; in ssif_probe()
1678 return -ENOMEM; in ssif_probe()
1681 if (!check_acpi(ssif_info, &client->dev)) { in ssif_probe()
1682 addr_info = ssif_info_find(client->addr, client->adapter->name, in ssif_probe()
1686 ssif_info->addr_source = SI_HOTMOD; in ssif_probe()
1688 ssif_info->addr_source = addr_info->addr_src; in ssif_probe()
1689 ssif_info->ssif_debug = addr_info->debug; in ssif_probe()
1690 ssif_info->addr_info = addr_info->addr_info; in ssif_probe()
1691 addr_info->client = client; in ssif_probe()
1692 slave_addr = addr_info->slave_addr; in ssif_probe()
1696 ssif_info->client = client; in ssif_probe()
1701 if (!rv && ssif_info->addr_source == SI_ACPI) { in ssif_probe()
1704 dev_err(&client->dev, "Out of memory!, exiting ..\n"); in ssif_probe()
1708 dev_err(&client->dev, "Not probing, Interface already present\n"); in ssif_probe()
1714 dev_info(&client->dev, in ssif_probe()
1715 "Trying %s-specified SSIF interface at i2c address 0x%x, adapter %s, slave address 0x%x\n", in ssif_probe()
1716 ipmi_addr_src_to_str(ssif_info->addr_source), in ssif_probe()
1717 client->addr, client->adapter->name, slave_addr); in ssif_probe()
1721 * make sure a valid BMC is there. in ssif_probe()
1725 dev_err(&client->dev, "Not present\n"); in ssif_probe()
1732 msg[2] = 0; /* SSIF */ in ssif_probe()
1737 dev_dbg(&ssif_info->client->dev, in ssif_probe()
1738 "SSIF info too short: %d\n", len); in ssif_probe()
1742 /* Got a good SSIF response, handle it. */ in ssif_probe()
1743 ssif_info->max_xmit_msg_size = resp[5]; in ssif_probe()
1744 ssif_info->max_recv_msg_size = resp[6]; in ssif_probe()
1745 ssif_info->multi_support = (resp[4] >> 6) & 0x3; in ssif_probe()
1746 ssif_info->supports_pec = (resp[4] >> 3) & 0x1; in ssif_probe()
1749 switch (ssif_info->multi_support) { in ssif_probe()
1751 if (ssif_info->max_xmit_msg_size > 32) in ssif_probe()
1752 ssif_info->max_xmit_msg_size = 32; in ssif_probe()
1753 if (ssif_info->max_recv_msg_size > 32) in ssif_probe()
1754 ssif_info->max_recv_msg_size = 32; in ssif_probe()
1758 if (ssif_info->max_xmit_msg_size > 63) in ssif_probe()
1759 ssif_info->max_xmit_msg_size = 63; in ssif_probe()
1760 if (ssif_info->max_recv_msg_size > 62) in ssif_probe()
1761 ssif_info->max_recv_msg_size = 62; in ssif_probe()
1774 /* Assume no multi-part or PEC support */ in ssif_probe()
1775 dev_info(&ssif_info->client->dev, in ssif_probe()
1776 …"Error fetching SSIF: %d %d %2.2x, your system probably doesn't support this command so using defa… in ssif_probe()
1779 ssif_info->max_xmit_msg_size = 32; in ssif_probe()
1780 ssif_info->max_recv_msg_size = 32; in ssif_probe()
1781 ssif_info->multi_support = SSIF_NO_MULTI; in ssif_probe()
1782 ssif_info->supports_pec = 0; in ssif_probe()
1793 dev_warn(&ssif_info->client->dev, in ssif_probe()
1802 dev_warn(&ssif_info->client->dev, in ssif_probe()
1809 ssif_info->global_enables = resp[3]; in ssif_probe()
1812 ssif_info->has_event_buffer = true; in ssif_probe()
1819 msg[2] = ssif_info->global_enables | IPMI_BMC_EVT_MSG_BUFF; in ssif_probe()
1822 dev_warn(&ssif_info->client->dev, in ssif_probe()
1831 ssif_info->has_event_buffer = true; in ssif_probe()
1832 ssif_info->global_enables |= IPMI_BMC_EVT_MSG_BUFF; in ssif_probe()
1841 msg[2] = ssif_info->global_enables | IPMI_BMC_RCV_MSG_INTR; in ssif_probe()
1844 dev_warn(&ssif_info->client->dev, in ssif_probe()
1853 ssif_info->supports_alert = true; in ssif_probe()
1854 ssif_info->global_enables |= IPMI_BMC_RCV_MSG_INTR; in ssif_probe()
1859 dev_dbg(&ssif_info->client->dev, in ssif_probe()
1861 __func__, client->addr); in ssif_probe()
1864 spin_lock_init(&ssif_info->lock); in ssif_probe()
1865 ssif_info->ssif_state = SSIF_IDLE; in ssif_probe()
1866 timer_setup(&ssif_info->retry_timer, retry_timeout, 0); in ssif_probe()
1867 timer_setup(&ssif_info->watch_timer, watch_timeout, 0); in ssif_probe()
1870 atomic_set(&ssif_info->stats[i], 0); in ssif_probe()
1872 if (ssif_info->supports_pec) in ssif_probe()
1873 ssif_info->client->flags |= I2C_CLIENT_PEC; in ssif_probe()
1875 ssif_info->handlers.owner = THIS_MODULE; in ssif_probe()
1876 ssif_info->handlers.start_processing = ssif_start_processing; in ssif_probe()
1877 ssif_info->handlers.shutdown = shutdown_ssif; in ssif_probe()
1878 ssif_info->handlers.get_smi_info = get_smi_info; in ssif_probe()
1879 ssif_info->handlers.sender = sender; in ssif_probe()
1880 ssif_info->handlers.request_events = request_events; in ssif_probe()
1881 ssif_info->handlers.set_need_watch = ssif_set_need_watch; in ssif_probe()
1886 thread_num = ((i2c_adapter_id(ssif_info->client->adapter) in ssif_probe()
1888 ssif_info->client->addr); in ssif_probe()
1889 init_completion(&ssif_info->wake_thread); in ssif_probe()
1890 ssif_info->thread = kthread_run(ipmi_ssif_thread, ssif_info, in ssif_probe()
1892 if (IS_ERR(ssif_info->thread)) { in ssif_probe()
1893 rv = PTR_ERR(ssif_info->thread); in ssif_probe()
1894 dev_notice(&ssif_info->client->dev, in ssif_probe()
1901 dev_set_drvdata(&ssif_info->client->dev, ssif_info); in ssif_probe()
1902 rv = device_add_group(&ssif_info->client->dev, in ssif_probe()
1905 dev_err(&ssif_info->client->dev, in ssif_probe()
1911 rv = ipmi_register_smi(&ssif_info->handlers, in ssif_probe()
1913 &ssif_info->client->dev, in ssif_probe()
1916 dev_err(&ssif_info->client->dev, in ssif_probe()
1924 addr_info->client = NULL; in ssif_probe()
1926 dev_err(&ssif_info->client->dev, in ssif_probe()
1927 "Unable to start IPMI SSIF: %d\n", rv); in ssif_probe()
1936 device_remove_group(&ssif_info->client->dev, &ipmi_ssif_dev_attr_group); in ssif_probe()
1937 dev_set_drvdata(&ssif_info->client->dev, NULL); in ssif_probe()
1951 rv = -EEXIST; in new_ssif_client()
1957 rv = -ENOMEM; in new_ssif_client()
1962 addr_info->adapter_name = kstrdup(adapter_name, GFP_KERNEL); in new_ssif_client()
1963 if (!addr_info->adapter_name) { in new_ssif_client()
1965 rv = -ENOMEM; in new_ssif_client()
1970 strscpy(addr_info->binfo.type, DEVICE_NAME, in new_ssif_client()
1971 sizeof(addr_info->binfo.type)); in new_ssif_client()
1972 addr_info->binfo.addr = addr; in new_ssif_client()
1973 addr_info->binfo.platform_data = addr_info; in new_ssif_client()
1974 addr_info->debug = debug; in new_ssif_client()
1975 addr_info->slave_addr = slave_addr; in new_ssif_client()
1976 addr_info->addr_src = addr_src; in new_ssif_client()
1977 addr_info->dev = dev; in new_ssif_client()
1982 list_add_tail(&addr_info->link, &ssif_infos); in new_ssif_client()
1997 list_del(&info->link); in free_ssif_clients()
1998 kfree(info->adapter_name); in free_ssif_clients()
2019 unsigned short addr = info->binfo.addr; in ssif_address_list()
2051 return -ENODEV; in dmi_ipmi_probe()
2053 rv = device_property_read_u16(&pdev->dev, "i2c-addr", &i2c_addr); in dmi_ipmi_probe()
2055 dev_warn(&pdev->dev, "No i2c-addr property\n"); in dmi_ipmi_probe()
2056 return -ENODEV; in dmi_ipmi_probe()
2059 rv = device_property_read_u8(&pdev->dev, "slave-addr", &slave_addr); in dmi_ipmi_probe()
2064 slave_addr, SI_SMBIOS, &pdev->dev); in dmi_ipmi_probe()
2069 return -ENODEV; in dmi_ipmi_probe()
2098 struct ssif_addr_info *addr_info = dev_get_drvdata(&dev->dev); in ssif_platform_remove()
2101 list_del(&addr_info->link); in ssif_platform_remove()
2107 { "dmi-ipmi-ssif", 0 },
2129 pr_info("IPMI SSIF Interface driver\n"); in init_ipmi_ssif()
2181 MODULE_ALIAS("platform:dmi-ipmi-ssif");