Lines Matching +full:bi +full:- +full:directional
1 // SPDX-License-Identifier: GPL-2.0
29 return sprintf(buf, "0x%04x\n", svc->endo_id); in endo_id_show()
38 return sprintf(buf, "%u\n", svc->ap_intf_id); in ap_intf_id_show()
105 if (svc->action == GB_SVC_WATCHDOG_BITE_PANIC_KERNEL) in watchdog_action_show()
107 else if (svc->action == GB_SVC_WATCHDOG_BITE_RESET_UNIPRO) in watchdog_action_show()
110 return -EINVAL; in watchdog_action_show()
120 svc->action = GB_SVC_WATCHDOG_BITE_PANIC_KERNEL; in watchdog_action_store()
122 svc->action = GB_SVC_WATCHDOG_BITE_RESET_UNIPRO; in watchdog_action_store()
124 return -EINVAL; in watchdog_action_store()
135 ret = gb_operation_sync(svc->connection, in gb_svc_pwrmon_rail_count_get()
139 dev_err(&svc->dev, "failed to get rail count: %d\n", ret); in gb_svc_pwrmon_rail_count_get()
154 ret = gb_operation_sync(svc->connection, in gb_svc_pwrmon_rail_names_get()
158 dev_err(&svc->dev, "failed to get rail names: %d\n", ret); in gb_svc_pwrmon_rail_names_get()
162 if (response->status != GB_SVC_OP_SUCCESS) { in gb_svc_pwrmon_rail_names_get()
163 dev_err(&svc->dev, in gb_svc_pwrmon_rail_names_get()
165 response->status); in gb_svc_pwrmon_rail_names_get()
166 return -EREMOTEIO; in gb_svc_pwrmon_rail_names_get()
182 ret = gb_operation_sync(svc->connection, GB_SVC_TYPE_PWRMON_SAMPLE_GET, in gb_svc_pwrmon_sample_get()
186 dev_err(&svc->dev, "failed to get rail sample: %d\n", ret); in gb_svc_pwrmon_sample_get()
191 dev_err(&svc->dev, in gb_svc_pwrmon_sample_get()
196 return -EINVAL; in gb_svc_pwrmon_sample_get()
198 return -ENOMSG; in gb_svc_pwrmon_sample_get()
200 return -EREMOTEIO; in gb_svc_pwrmon_sample_get()
219 ret = gb_operation_sync(svc->connection, in gb_svc_pwrmon_intf_sample_get()
224 dev_err(&svc->dev, "failed to get intf sample: %d\n", ret); in gb_svc_pwrmon_intf_sample_get()
229 dev_err(&svc->dev, in gb_svc_pwrmon_intf_sample_get()
234 return -EINVAL; in gb_svc_pwrmon_intf_sample_get()
236 return -ENOMSG; in gb_svc_pwrmon_intf_sample_get()
238 return -EREMOTEIO; in gb_svc_pwrmon_intf_sample_get()
264 return gb_operation_sync(svc->connection, GB_SVC_TYPE_INTF_DEVICE_ID, in gb_svc_intf_device_id()
279 ret = gb_operation_sync_timeout(svc->connection, in gb_svc_intf_eject()
284 dev_err(&svc->dev, "failed to eject interface %u\n", intf_id); in gb_svc_intf_eject()
304 ret = gb_operation_sync(svc->connection, type, in gb_svc_intf_vsys_set()
310 return -EREMOTEIO; in gb_svc_intf_vsys_set()
327 ret = gb_operation_sync(svc->connection, type, in gb_svc_intf_refclk_set()
333 return -EREMOTEIO; in gb_svc_intf_refclk_set()
350 ret = gb_operation_sync(svc->connection, type, in gb_svc_intf_unipro_set()
356 return -EREMOTEIO; in gb_svc_intf_unipro_set()
368 ret = gb_operation_sync_timeout(svc->connection, in gb_svc_intf_activate()
376 dev_err(&svc->dev, "failed to activate interface %u: %u\n", in gb_svc_intf_activate()
378 return -EREMOTEIO; in gb_svc_intf_activate()
394 ret = gb_operation_sync_timeout(svc->connection, in gb_svc_intf_resume()
400 dev_err(&svc->dev, "failed to send interface resume %u: %d\n", in gb_svc_intf_resume()
406 dev_err(&svc->dev, "failed to resume interface %u: %u\n", in gb_svc_intf_resume()
408 return -EREMOTEIO; in gb_svc_intf_resume()
426 ret = gb_operation_sync(svc->connection, GB_SVC_TYPE_DME_PEER_GET, in gb_svc_dme_peer_get()
430 dev_err(&svc->dev, "failed to get DME attribute (%u 0x%04x %u): %d\n", in gb_svc_dme_peer_get()
437 dev_err(&svc->dev, "UniPro error while getting DME attribute (%u 0x%04x %u): %u\n", in gb_svc_dme_peer_get()
439 return -EREMOTEIO; in gb_svc_dme_peer_get()
461 ret = gb_operation_sync(svc->connection, GB_SVC_TYPE_DME_PEER_SET, in gb_svc_dme_peer_set()
465 dev_err(&svc->dev, "failed to set DME attribute (%u 0x%04x %u %u): %d\n", in gb_svc_dme_peer_set()
472 dev_err(&svc->dev, "UniPro error while setting DME attribute (%u 0x%04x %u %u): %u\n", in gb_svc_dme_peer_set()
474 return -EREMOTEIO; in gb_svc_dme_peer_set()
494 return gb_operation_sync(svc->connection, GB_SVC_TYPE_CONN_CREATE, in gb_svc_connection_create()
502 struct gb_connection *connection = svc->connection; in gb_svc_connection_destroy()
513 dev_err(&svc->dev, "failed to destroy connection (%u:%u %u:%u): %d\n", in gb_svc_connection_destroy()
518 /* Creates bi-directional routes between the devices */
529 return gb_operation_sync(svc->connection, GB_SVC_TYPE_ROUTE_CREATE, in gb_svc_route_create()
533 /* Destroys bi-directional routes between the devices */
542 ret = gb_operation_sync(svc->connection, GB_SVC_TYPE_ROUTE_DESTROY, in gb_svc_route_destroy()
545 dev_err(&svc->dev, "failed to destroy route (%u %u): %d\n", in gb_svc_route_destroy()
582 ret = gb_operation_sync(svc->connection, GB_SVC_TYPE_INTF_SET_PWRM, in gb_svc_intf_set_power_mode()
590 dev_err(&svc->dev, "set power mode = %d\n", result_code); in gb_svc_intf_set_power_mode()
591 return -EIO; in gb_svc_intf_set_power_mode()
612 ret = gb_operation_sync(svc->connection, GB_SVC_TYPE_INTF_SET_PWRM, in gb_svc_intf_set_power_mode_hibernate()
616 dev_err(&svc->dev, in gb_svc_intf_set_power_mode_hibernate()
624 dev_err(&svc->dev, in gb_svc_intf_set_power_mode_hibernate()
627 return -EIO; in gb_svc_intf_set_power_mode_hibernate()
635 return gb_operation_sync_timeout(svc->connection, GB_SVC_TYPE_PING, in gb_svc_ping()
642 struct gb_connection *connection = op->connection; in gb_svc_version_request()
647 if (op->request->payload_size < sizeof(*request)) { in gb_svc_version_request()
648 dev_err(&svc->dev, "short version request (%zu < %zu)\n", in gb_svc_version_request()
649 op->request->payload_size, in gb_svc_version_request()
651 return -EINVAL; in gb_svc_version_request()
654 request = op->request->payload; in gb_svc_version_request()
656 if (request->major > GB_SVC_VERSION_MAJOR) { in gb_svc_version_request()
657 dev_warn(&svc->dev, "unsupported major version (%u > %u)\n", in gb_svc_version_request()
658 request->major, GB_SVC_VERSION_MAJOR); in gb_svc_version_request()
659 return -ENOTSUPP; in gb_svc_version_request()
662 svc->protocol_major = request->major; in gb_svc_version_request()
663 svc->protocol_minor = request->minor; in gb_svc_version_request()
666 return -ENOMEM; in gb_svc_version_request()
668 response = op->response->payload; in gb_svc_version_request()
669 response->major = svc->protocol_major; in gb_svc_version_request()
670 response->minor = svc->protocol_minor; in gb_svc_version_request()
679 file_inode(file)->i_private; in pwr_debugfs_voltage_read()
680 struct gb_svc *svc = pwrmon_rails->svc; in pwr_debugfs_voltage_read()
685 ret = gb_svc_pwrmon_sample_get(svc, pwrmon_rails->id, in pwr_debugfs_voltage_read()
688 dev_err(&svc->dev, in pwr_debugfs_voltage_read()
690 pwrmon_rails->id, ret); in pwr_debugfs_voltage_read()
703 file_inode(file)->i_private; in pwr_debugfs_current_read()
704 struct gb_svc *svc = pwrmon_rails->svc; in pwr_debugfs_current_read()
709 ret = gb_svc_pwrmon_sample_get(svc, pwrmon_rails->id, in pwr_debugfs_current_read()
712 dev_err(&svc->dev, in pwr_debugfs_current_read()
714 pwrmon_rails->id, ret); in pwr_debugfs_current_read()
727 file_inode(file)->i_private; in pwr_debugfs_power_read()
728 struct gb_svc *svc = pwrmon_rails->svc; in pwr_debugfs_power_read()
733 ret = gb_svc_pwrmon_sample_get(svc, pwrmon_rails->id, in pwr_debugfs_power_read()
736 dev_err(&svc->dev, "failed to get power sample %u: %d\n", in pwr_debugfs_power_read()
737 pwrmon_rails->id, ret); in pwr_debugfs_power_read()
766 dent = debugfs_create_dir("pwrmon", svc->debugfs_dentry); in gb_svc_pwrmon_debugfs_init()
783 svc->pwrmon_rails = kcalloc(rail_count, sizeof(*svc->pwrmon_rails), in gb_svc_pwrmon_debugfs_init()
785 if (!svc->pwrmon_rails) in gb_svc_pwrmon_debugfs_init()
793 struct svc_debugfs_pwrmon_rail *rail = &svc->pwrmon_rails[i]; in gb_svc_pwrmon_debugfs_init()
797 (char *)&rail_names->name[i]); in gb_svc_pwrmon_debugfs_init()
799 rail->id = i; in gb_svc_pwrmon_debugfs_init()
800 rail->svc = svc; in gb_svc_pwrmon_debugfs_init()
816 kfree(svc->pwrmon_rails); in gb_svc_pwrmon_debugfs_init()
817 svc->pwrmon_rails = NULL; in gb_svc_pwrmon_debugfs_init()
825 svc->debugfs_dentry = debugfs_create_dir(dev_name(&svc->dev), in gb_svc_debugfs_init()
832 debugfs_remove_recursive(svc->debugfs_dentry); in gb_svc_debugfs_exit()
833 kfree(svc->pwrmon_rails); in gb_svc_debugfs_exit()
834 svc->pwrmon_rails = NULL; in gb_svc_debugfs_exit()
839 struct gb_connection *connection = op->connection; in gb_svc_hello()
844 if (op->request->payload_size < sizeof(*hello_request)) { in gb_svc_hello()
845 dev_warn(&svc->dev, "short hello request (%zu < %zu)\n", in gb_svc_hello()
846 op->request->payload_size, in gb_svc_hello()
848 return -EINVAL; in gb_svc_hello()
851 hello_request = op->request->payload; in gb_svc_hello()
852 svc->endo_id = le16_to_cpu(hello_request->endo_id); in gb_svc_hello()
853 svc->ap_intf_id = hello_request->interface_id; in gb_svc_hello()
855 ret = device_add(&svc->dev); in gb_svc_hello()
857 dev_err(&svc->dev, "failed to register svc device: %d\n", ret); in gb_svc_hello()
863 dev_err(&svc->dev, "failed to create watchdog: %d\n", ret); in gb_svc_hello()
873 device_del(&svc->dev); in gb_svc_hello()
880 struct gb_host_device *hd = svc->hd; in gb_svc_interface_lookup()
885 list_for_each_entry(module, &hd->modules, hd_node) { in gb_svc_interface_lookup()
886 module_id = module->module_id; in gb_svc_interface_lookup()
887 num_interfaces = module->num_interfaces; in gb_svc_interface_lookup()
891 return module->interfaces[intf_id - module_id]; in gb_svc_interface_lookup()
900 struct gb_host_device *hd = svc->hd; in gb_svc_module_lookup()
903 list_for_each_entry(module, &hd->modules, hd_node) { in gb_svc_module_lookup()
904 if (module->module_id == module_id) in gb_svc_module_lookup()
913 struct gb_connection *connection = operation->connection; in gb_svc_process_hello_deferred()
918 * XXX This is a hack/work-around to reconfigure the APBridgeA-Switch in gb_svc_process_hello_deferred()
920 * bandwidth for 3 audio streams plus boot-over-UniPro of a hot-plugged in gb_svc_process_hello_deferred()
923 * The code should be removed once SW-2217, Heuristic for UniPro in gb_svc_process_hello_deferred()
926 ret = gb_svc_intf_set_power_mode(svc, svc->ap_intf_id, in gb_svc_process_hello_deferred()
938 dev_warn(&svc->dev, in gb_svc_process_hello_deferred()
946 struct gb_connection *connection = operation->connection; in gb_svc_process_module_inserted()
948 struct gb_host_device *hd = svc->hd; in gb_svc_process_module_inserted()
956 request = operation->request->payload; in gb_svc_process_module_inserted()
957 module_id = request->primary_intf_id; in gb_svc_process_module_inserted()
958 num_interfaces = request->intf_count; in gb_svc_process_module_inserted()
959 flags = le16_to_cpu(request->flags); in gb_svc_process_module_inserted()
961 dev_dbg(&svc->dev, "%s - id = %u, num_interfaces = %zu, flags = 0x%04x\n", in gb_svc_process_module_inserted()
965 dev_warn(&svc->dev, "no primary interface detected on module %u\n", in gb_svc_process_module_inserted()
971 dev_warn(&svc->dev, "unexpected module-inserted event %u\n", in gb_svc_process_module_inserted()
978 dev_err(&svc->dev, "failed to create module\n"); in gb_svc_process_module_inserted()
988 list_add(&module->hd_node, &hd->modules); in gb_svc_process_module_inserted()
994 struct gb_connection *connection = operation->connection; in gb_svc_process_module_removed()
1000 request = operation->request->payload; in gb_svc_process_module_removed()
1001 module_id = request->primary_intf_id; in gb_svc_process_module_removed()
1003 dev_dbg(&svc->dev, "%s - id = %u\n", __func__, module_id); in gb_svc_process_module_removed()
1007 dev_warn(&svc->dev, "unexpected module-removed event %u\n", in gb_svc_process_module_removed()
1012 module->disconnected = true; in gb_svc_process_module_removed()
1015 list_del(&module->hd_node); in gb_svc_process_module_removed()
1022 struct gb_connection *connection = operation->connection; in gb_svc_process_intf_oops()
1029 request = operation->request->payload; in gb_svc_process_intf_oops()
1030 intf_id = request->intf_id; in gb_svc_process_intf_oops()
1031 reason = request->reason; in gb_svc_process_intf_oops()
1035 dev_warn(&svc->dev, "unexpected interface-oops event %u\n", in gb_svc_process_intf_oops()
1040 dev_info(&svc->dev, "Deactivating interface %u, interface oops reason = %u\n", in gb_svc_process_intf_oops()
1043 mutex_lock(&intf->mutex); in gb_svc_process_intf_oops()
1044 intf->disconnected = true; in gb_svc_process_intf_oops()
1047 mutex_unlock(&intf->mutex); in gb_svc_process_intf_oops()
1053 struct gb_connection *connection = operation->connection; in gb_svc_process_intf_mailbox_event()
1061 request = operation->request->payload; in gb_svc_process_intf_mailbox_event()
1062 intf_id = request->intf_id; in gb_svc_process_intf_mailbox_event()
1063 result_code = le16_to_cpu(request->result_code); in gb_svc_process_intf_mailbox_event()
1064 mailbox = le32_to_cpu(request->mailbox); in gb_svc_process_intf_mailbox_event()
1066 dev_dbg(&svc->dev, "%s - id = %u, result = 0x%04x, mailbox = 0x%08x\n", in gb_svc_process_intf_mailbox_event()
1071 dev_warn(&svc->dev, "unexpected mailbox event %u\n", intf_id); in gb_svc_process_intf_mailbox_event()
1086 operation = dr->operation; in gb_svc_process_deferred_request()
1087 svc = gb_connection_get_data(operation->connection); in gb_svc_process_deferred_request()
1088 type = operation->request->header->type; in gb_svc_process_deferred_request()
1107 dev_err(&svc->dev, "bad deferred request type: 0x%02x\n", type); in gb_svc_process_deferred_request()
1116 struct gb_svc *svc = gb_connection_get_data(operation->connection); in gb_svc_queue_deferred_request()
1121 return -ENOMEM; in gb_svc_queue_deferred_request()
1125 dr->operation = operation; in gb_svc_queue_deferred_request()
1126 INIT_WORK(&dr->work, gb_svc_process_deferred_request); in gb_svc_queue_deferred_request()
1128 queue_work(svc->wq, &dr->work); in gb_svc_queue_deferred_request()
1135 struct gb_svc *svc = gb_connection_get_data(op->connection); in gb_svc_intf_reset_recv()
1136 struct gb_message *request = op->request; in gb_svc_intf_reset_recv()
1139 if (request->payload_size < sizeof(*reset)) { in gb_svc_intf_reset_recv()
1140 dev_warn(&svc->dev, "short reset request received (%zu < %zu)\n", in gb_svc_intf_reset_recv()
1141 request->payload_size, sizeof(*reset)); in gb_svc_intf_reset_recv()
1142 return -EINVAL; in gb_svc_intf_reset_recv()
1144 reset = request->payload; in gb_svc_intf_reset_recv()
1153 struct gb_svc *svc = gb_connection_get_data(op->connection); in gb_svc_module_inserted_recv()
1156 if (op->request->payload_size < sizeof(*request)) { in gb_svc_module_inserted_recv()
1157 dev_warn(&svc->dev, "short module-inserted request received (%zu < %zu)\n", in gb_svc_module_inserted_recv()
1158 op->request->payload_size, sizeof(*request)); in gb_svc_module_inserted_recv()
1159 return -EINVAL; in gb_svc_module_inserted_recv()
1162 request = op->request->payload; in gb_svc_module_inserted_recv()
1164 dev_dbg(&svc->dev, "%s - id = %u\n", __func__, in gb_svc_module_inserted_recv()
1165 request->primary_intf_id); in gb_svc_module_inserted_recv()
1172 struct gb_svc *svc = gb_connection_get_data(op->connection); in gb_svc_module_removed_recv()
1175 if (op->request->payload_size < sizeof(*request)) { in gb_svc_module_removed_recv()
1176 dev_warn(&svc->dev, "short module-removed request received (%zu < %zu)\n", in gb_svc_module_removed_recv()
1177 op->request->payload_size, sizeof(*request)); in gb_svc_module_removed_recv()
1178 return -EINVAL; in gb_svc_module_removed_recv()
1181 request = op->request->payload; in gb_svc_module_removed_recv()
1183 dev_dbg(&svc->dev, "%s - id = %u\n", __func__, in gb_svc_module_removed_recv()
1184 request->primary_intf_id); in gb_svc_module_removed_recv()
1191 struct gb_svc *svc = gb_connection_get_data(op->connection); in gb_svc_intf_oops_recv()
1194 if (op->request->payload_size < sizeof(*request)) { in gb_svc_intf_oops_recv()
1195 dev_warn(&svc->dev, "short intf-oops request received (%zu < %zu)\n", in gb_svc_intf_oops_recv()
1196 op->request->payload_size, sizeof(*request)); in gb_svc_intf_oops_recv()
1197 return -EINVAL; in gb_svc_intf_oops_recv()
1205 struct gb_svc *svc = gb_connection_get_data(op->connection); in gb_svc_intf_mailbox_event_recv()
1208 if (op->request->payload_size < sizeof(*request)) { in gb_svc_intf_mailbox_event_recv()
1209 dev_warn(&svc->dev, "short mailbox request received (%zu < %zu)\n", in gb_svc_intf_mailbox_event_recv()
1210 op->request->payload_size, sizeof(*request)); in gb_svc_intf_mailbox_event_recv()
1211 return -EINVAL; in gb_svc_intf_mailbox_event_recv()
1214 request = op->request->payload; in gb_svc_intf_mailbox_event_recv()
1216 dev_dbg(&svc->dev, "%s - id = %u\n", __func__, request->intf_id); in gb_svc_intf_mailbox_event_recv()
1223 struct gb_connection *connection = op->connection; in gb_svc_request_handler()
1225 u8 type = op->type; in gb_svc_request_handler()
1231 * - PROTOCOL_VERSION in gb_svc_request_handler()
1232 * - SVC_HELLO in gb_svc_request_handler()
1233 * - Any other request, but the earlier two. in gb_svc_request_handler()
1240 if (svc->state != GB_SVC_STATE_RESET) in gb_svc_request_handler()
1241 ret = -EINVAL; in gb_svc_request_handler()
1244 if (svc->state != GB_SVC_STATE_PROTOCOL_VERSION) in gb_svc_request_handler()
1245 ret = -EINVAL; in gb_svc_request_handler()
1248 if (svc->state != GB_SVC_STATE_SVC_HELLO) in gb_svc_request_handler()
1249 ret = -EINVAL; in gb_svc_request_handler()
1254 dev_warn(&svc->dev, "unexpected request 0x%02x received (state %u)\n", in gb_svc_request_handler()
1255 type, svc->state); in gb_svc_request_handler()
1263 svc->state = GB_SVC_STATE_PROTOCOL_VERSION; in gb_svc_request_handler()
1268 svc->state = GB_SVC_STATE_SVC_HELLO; in gb_svc_request_handler()
1281 dev_warn(&svc->dev, "unsupported request 0x%02x\n", type); in gb_svc_request_handler()
1282 return -EINVAL; in gb_svc_request_handler()
1290 if (svc->connection) in gb_svc_release()
1291 gb_connection_destroy(svc->connection); in gb_svc_release()
1292 ida_destroy(&svc->device_id_map); in gb_svc_release()
1293 destroy_workqueue(svc->wq); in gb_svc_release()
1310 svc->wq = alloc_workqueue("%s:svc", WQ_UNBOUND, 1, dev_name(&hd->dev)); in gb_svc_create()
1311 if (!svc->wq) { in gb_svc_create()
1316 svc->dev.parent = &hd->dev; in gb_svc_create()
1317 svc->dev.bus = &greybus_bus_type; in gb_svc_create()
1318 svc->dev.type = &greybus_svc_type; in gb_svc_create()
1319 svc->dev.groups = svc_groups; in gb_svc_create()
1320 svc->dev.dma_mask = svc->dev.parent->dma_mask; in gb_svc_create()
1321 device_initialize(&svc->dev); in gb_svc_create()
1323 dev_set_name(&svc->dev, "%d-svc", hd->bus_id); in gb_svc_create()
1325 ida_init(&svc->device_id_map); in gb_svc_create()
1326 svc->state = GB_SVC_STATE_RESET; in gb_svc_create()
1327 svc->hd = hd; in gb_svc_create()
1329 svc->connection = gb_connection_create_static(hd, GB_SVC_CPORT_ID, in gb_svc_create()
1331 if (IS_ERR(svc->connection)) { in gb_svc_create()
1332 dev_err(&svc->dev, "failed to create connection: %ld\n", in gb_svc_create()
1333 PTR_ERR(svc->connection)); in gb_svc_create()
1337 gb_connection_set_data(svc->connection, svc); in gb_svc_create()
1342 put_device(&svc->dev); in gb_svc_create()
1355 ret = gb_connection_enable(svc->connection); in gb_svc_add()
1364 struct gb_host_device *hd = svc->hd; in gb_svc_remove_modules()
1367 list_for_each_entry_safe(module, tmp, &hd->modules, hd_node) { in gb_svc_remove_modules()
1369 list_del(&module->hd_node); in gb_svc_remove_modules()
1376 gb_connection_disable_rx(svc->connection); in gb_svc_del()
1381 if (device_is_registered(&svc->dev)) { in gb_svc_del()
1384 device_del(&svc->dev); in gb_svc_del()
1387 flush_workqueue(svc->wq); in gb_svc_del()
1391 gb_connection_disable(svc->connection); in gb_svc_del()
1396 put_device(&svc->dev); in gb_svc_put()