Lines Matching +full:bi +full:- +full:directional
1 // SPDX-License-Identifier: GPL-2.0
30 return sprintf(buf, "0x%04x\n", svc->endo_id); in endo_id_show()
39 return sprintf(buf, "%u\n", svc->ap_intf_id); in ap_intf_id_show()
106 if (svc->action == GB_SVC_WATCHDOG_BITE_PANIC_KERNEL) in watchdog_action_show()
108 else if (svc->action == GB_SVC_WATCHDOG_BITE_RESET_UNIPRO) in watchdog_action_show()
111 return -EINVAL; in watchdog_action_show()
121 svc->action = GB_SVC_WATCHDOG_BITE_PANIC_KERNEL; in watchdog_action_store()
123 svc->action = GB_SVC_WATCHDOG_BITE_RESET_UNIPRO; in watchdog_action_store()
125 return -EINVAL; in watchdog_action_store()
136 ret = gb_operation_sync(svc->connection, in gb_svc_pwrmon_rail_count_get()
140 dev_err(&svc->dev, "failed to get rail count: %d\n", ret); in gb_svc_pwrmon_rail_count_get()
155 ret = gb_operation_sync(svc->connection, in gb_svc_pwrmon_rail_names_get()
159 dev_err(&svc->dev, "failed to get rail names: %d\n", ret); in gb_svc_pwrmon_rail_names_get()
163 if (response->status != GB_SVC_OP_SUCCESS) { in gb_svc_pwrmon_rail_names_get()
164 dev_err(&svc->dev, in gb_svc_pwrmon_rail_names_get()
166 response->status); in gb_svc_pwrmon_rail_names_get()
167 return -EREMOTEIO; in gb_svc_pwrmon_rail_names_get()
183 ret = gb_operation_sync(svc->connection, GB_SVC_TYPE_PWRMON_SAMPLE_GET, in gb_svc_pwrmon_sample_get()
187 dev_err(&svc->dev, "failed to get rail sample: %d\n", ret); in gb_svc_pwrmon_sample_get()
192 dev_err(&svc->dev, in gb_svc_pwrmon_sample_get()
197 return -EINVAL; in gb_svc_pwrmon_sample_get()
199 return -ENOMSG; in gb_svc_pwrmon_sample_get()
201 return -EREMOTEIO; in gb_svc_pwrmon_sample_get()
220 ret = gb_operation_sync(svc->connection, in gb_svc_pwrmon_intf_sample_get()
225 dev_err(&svc->dev, "failed to get intf sample: %d\n", ret); in gb_svc_pwrmon_intf_sample_get()
230 dev_err(&svc->dev, in gb_svc_pwrmon_intf_sample_get()
235 return -EINVAL; in gb_svc_pwrmon_intf_sample_get()
237 return -ENOMSG; in gb_svc_pwrmon_intf_sample_get()
239 return -EREMOTEIO; in gb_svc_pwrmon_intf_sample_get()
265 return gb_operation_sync(svc->connection, GB_SVC_TYPE_INTF_DEVICE_ID, in gb_svc_intf_device_id()
280 ret = gb_operation_sync_timeout(svc->connection, in gb_svc_intf_eject()
285 dev_err(&svc->dev, "failed to eject interface %u\n", intf_id); in gb_svc_intf_eject()
305 ret = gb_operation_sync(svc->connection, type, in gb_svc_intf_vsys_set()
311 return -EREMOTEIO; in gb_svc_intf_vsys_set()
328 ret = gb_operation_sync(svc->connection, type, in gb_svc_intf_refclk_set()
334 return -EREMOTEIO; in gb_svc_intf_refclk_set()
351 ret = gb_operation_sync(svc->connection, type, in gb_svc_intf_unipro_set()
357 return -EREMOTEIO; in gb_svc_intf_unipro_set()
369 ret = gb_operation_sync_timeout(svc->connection, in gb_svc_intf_activate()
377 dev_err(&svc->dev, "failed to activate interface %u: %u\n", in gb_svc_intf_activate()
379 return -EREMOTEIO; in gb_svc_intf_activate()
395 ret = gb_operation_sync_timeout(svc->connection, in gb_svc_intf_resume()
401 dev_err(&svc->dev, "failed to send interface resume %u: %d\n", in gb_svc_intf_resume()
407 dev_err(&svc->dev, "failed to resume interface %u: %u\n", in gb_svc_intf_resume()
409 return -EREMOTEIO; in gb_svc_intf_resume()
427 ret = gb_operation_sync(svc->connection, GB_SVC_TYPE_DME_PEER_GET, in gb_svc_dme_peer_get()
431 dev_err(&svc->dev, "failed to get DME attribute (%u 0x%04x %u): %d\n", in gb_svc_dme_peer_get()
438 dev_err(&svc->dev, "UniPro error while getting DME attribute (%u 0x%04x %u): %u\n", in gb_svc_dme_peer_get()
440 return -EREMOTEIO; in gb_svc_dme_peer_get()
462 ret = gb_operation_sync(svc->connection, GB_SVC_TYPE_DME_PEER_SET, in gb_svc_dme_peer_set()
466 dev_err(&svc->dev, "failed to set DME attribute (%u 0x%04x %u %u): %d\n", in gb_svc_dme_peer_set()
473 dev_err(&svc->dev, "UniPro error while setting DME attribute (%u 0x%04x %u %u): %u\n", in gb_svc_dme_peer_set()
475 return -EREMOTEIO; in gb_svc_dme_peer_set()
495 return gb_operation_sync(svc->connection, GB_SVC_TYPE_CONN_CREATE, in gb_svc_connection_create()
503 struct gb_connection *connection = svc->connection; in gb_svc_connection_destroy()
514 dev_err(&svc->dev, "failed to destroy connection (%u:%u %u:%u): %d\n", in gb_svc_connection_destroy()
519 /* Creates bi-directional routes between the devices */
530 return gb_operation_sync(svc->connection, GB_SVC_TYPE_ROUTE_CREATE, in gb_svc_route_create()
534 /* Destroys bi-directional routes between the devices */
543 ret = gb_operation_sync(svc->connection, GB_SVC_TYPE_ROUTE_DESTROY, in gb_svc_route_destroy()
546 dev_err(&svc->dev, "failed to destroy route (%u %u): %d\n", in gb_svc_route_destroy()
583 ret = gb_operation_sync(svc->connection, GB_SVC_TYPE_INTF_SET_PWRM, in gb_svc_intf_set_power_mode()
591 dev_err(&svc->dev, "set power mode = %d\n", result_code); in gb_svc_intf_set_power_mode()
592 return -EIO; in gb_svc_intf_set_power_mode()
613 ret = gb_operation_sync(svc->connection, GB_SVC_TYPE_INTF_SET_PWRM, in gb_svc_intf_set_power_mode_hibernate()
617 dev_err(&svc->dev, in gb_svc_intf_set_power_mode_hibernate()
625 dev_err(&svc->dev, in gb_svc_intf_set_power_mode_hibernate()
628 return -EIO; in gb_svc_intf_set_power_mode_hibernate()
636 return gb_operation_sync_timeout(svc->connection, GB_SVC_TYPE_PING, in gb_svc_ping()
643 struct gb_connection *connection = op->connection; in gb_svc_version_request()
648 if (op->request->payload_size < sizeof(*request)) { in gb_svc_version_request()
649 dev_err(&svc->dev, "short version request (%zu < %zu)\n", in gb_svc_version_request()
650 op->request->payload_size, in gb_svc_version_request()
652 return -EINVAL; in gb_svc_version_request()
655 request = op->request->payload; in gb_svc_version_request()
657 if (request->major > GB_SVC_VERSION_MAJOR) { in gb_svc_version_request()
658 dev_warn(&svc->dev, "unsupported major version (%u > %u)\n", in gb_svc_version_request()
659 request->major, GB_SVC_VERSION_MAJOR); in gb_svc_version_request()
660 return -ENOTSUPP; in gb_svc_version_request()
663 svc->protocol_major = request->major; in gb_svc_version_request()
664 svc->protocol_minor = request->minor; in gb_svc_version_request()
667 return -ENOMEM; in gb_svc_version_request()
669 response = op->response->payload; in gb_svc_version_request()
670 response->major = svc->protocol_major; in gb_svc_version_request()
671 response->minor = svc->protocol_minor; in gb_svc_version_request()
680 file_inode(file)->i_private; in pwr_debugfs_voltage_read()
681 struct gb_svc *svc = pwrmon_rails->svc; in pwr_debugfs_voltage_read()
686 ret = gb_svc_pwrmon_sample_get(svc, pwrmon_rails->id, in pwr_debugfs_voltage_read()
689 dev_err(&svc->dev, in pwr_debugfs_voltage_read()
691 pwrmon_rails->id, ret); in pwr_debugfs_voltage_read()
704 file_inode(file)->i_private; in pwr_debugfs_current_read()
705 struct gb_svc *svc = pwrmon_rails->svc; in pwr_debugfs_current_read()
710 ret = gb_svc_pwrmon_sample_get(svc, pwrmon_rails->id, in pwr_debugfs_current_read()
713 dev_err(&svc->dev, in pwr_debugfs_current_read()
715 pwrmon_rails->id, ret); in pwr_debugfs_current_read()
728 file_inode(file)->i_private; in pwr_debugfs_power_read()
729 struct gb_svc *svc = pwrmon_rails->svc; in pwr_debugfs_power_read()
734 ret = gb_svc_pwrmon_sample_get(svc, pwrmon_rails->id, in pwr_debugfs_power_read()
737 dev_err(&svc->dev, "failed to get power sample %u: %d\n", in pwr_debugfs_power_read()
738 pwrmon_rails->id, ret); in pwr_debugfs_power_read()
767 dent = debugfs_create_dir("pwrmon", svc->debugfs_dentry); in gb_svc_pwrmon_debugfs_init()
784 svc->pwrmon_rails = kcalloc(rail_count, sizeof(*svc->pwrmon_rails), in gb_svc_pwrmon_debugfs_init()
786 if (!svc->pwrmon_rails) in gb_svc_pwrmon_debugfs_init()
794 struct svc_debugfs_pwrmon_rail *rail = &svc->pwrmon_rails[i]; in gb_svc_pwrmon_debugfs_init()
798 (char *)&rail_names->name[i]); in gb_svc_pwrmon_debugfs_init()
800 rail->id = i; in gb_svc_pwrmon_debugfs_init()
801 rail->svc = svc; in gb_svc_pwrmon_debugfs_init()
817 kfree(svc->pwrmon_rails); in gb_svc_pwrmon_debugfs_init()
818 svc->pwrmon_rails = NULL; in gb_svc_pwrmon_debugfs_init()
826 svc->debugfs_dentry = debugfs_create_dir(dev_name(&svc->dev), in gb_svc_debugfs_init()
833 debugfs_remove_recursive(svc->debugfs_dentry); in gb_svc_debugfs_exit()
834 kfree(svc->pwrmon_rails); in gb_svc_debugfs_exit()
835 svc->pwrmon_rails = NULL; in gb_svc_debugfs_exit()
840 struct gb_connection *connection = op->connection; in gb_svc_hello()
845 if (op->request->payload_size < sizeof(*hello_request)) { in gb_svc_hello()
846 dev_warn(&svc->dev, "short hello request (%zu < %zu)\n", in gb_svc_hello()
847 op->request->payload_size, in gb_svc_hello()
849 return -EINVAL; in gb_svc_hello()
852 hello_request = op->request->payload; in gb_svc_hello()
853 svc->endo_id = le16_to_cpu(hello_request->endo_id); in gb_svc_hello()
854 svc->ap_intf_id = hello_request->interface_id; in gb_svc_hello()
856 ret = device_add(&svc->dev); in gb_svc_hello()
858 dev_err(&svc->dev, "failed to register svc device: %d\n", ret); in gb_svc_hello()
864 dev_err(&svc->dev, "failed to create watchdog: %d\n", ret); in gb_svc_hello()
883 device_del(&svc->dev); in gb_svc_hello()
891 struct gb_host_device *hd = svc->hd; in gb_svc_interface_lookup()
896 list_for_each_entry(module, &hd->modules, hd_node) { in gb_svc_interface_lookup()
897 module_id = module->module_id; in gb_svc_interface_lookup()
898 num_interfaces = module->num_interfaces; in gb_svc_interface_lookup()
902 return module->interfaces[intf_id - module_id]; in gb_svc_interface_lookup()
911 struct gb_host_device *hd = svc->hd; in gb_svc_module_lookup()
914 list_for_each_entry(module, &hd->modules, hd_node) { in gb_svc_module_lookup()
915 if (module->module_id == module_id) in gb_svc_module_lookup()
924 struct gb_connection *connection = operation->connection; in gb_svc_process_hello_deferred()
929 * XXX This is a hack/work-around to reconfigure the APBridgeA-Switch in gb_svc_process_hello_deferred()
931 * bandwidth for 3 audio streams plus boot-over-UniPro of a hot-plugged in gb_svc_process_hello_deferred()
934 * The code should be removed once SW-2217, Heuristic for UniPro in gb_svc_process_hello_deferred()
937 ret = gb_svc_intf_set_power_mode(svc, svc->ap_intf_id, in gb_svc_process_hello_deferred()
949 dev_warn(&svc->dev, in gb_svc_process_hello_deferred()
957 struct gb_connection *connection = operation->connection; in gb_svc_process_module_inserted()
959 struct gb_host_device *hd = svc->hd; in gb_svc_process_module_inserted()
967 request = operation->request->payload; in gb_svc_process_module_inserted()
968 module_id = request->primary_intf_id; in gb_svc_process_module_inserted()
969 num_interfaces = request->intf_count; in gb_svc_process_module_inserted()
970 flags = le16_to_cpu(request->flags); in gb_svc_process_module_inserted()
972 dev_dbg(&svc->dev, "%s - id = %u, num_interfaces = %zu, flags = 0x%04x\n", in gb_svc_process_module_inserted()
976 dev_warn(&svc->dev, "no primary interface detected on module %u\n", in gb_svc_process_module_inserted()
982 dev_warn(&svc->dev, "unexpected module-inserted event %u\n", in gb_svc_process_module_inserted()
989 dev_err(&svc->dev, "failed to create module\n"); in gb_svc_process_module_inserted()
999 list_add(&module->hd_node, &hd->modules); in gb_svc_process_module_inserted()
1005 struct gb_connection *connection = operation->connection; in gb_svc_process_module_removed()
1011 request = operation->request->payload; in gb_svc_process_module_removed()
1012 module_id = request->primary_intf_id; in gb_svc_process_module_removed()
1014 dev_dbg(&svc->dev, "%s - id = %u\n", __func__, module_id); in gb_svc_process_module_removed()
1018 dev_warn(&svc->dev, "unexpected module-removed event %u\n", in gb_svc_process_module_removed()
1023 module->disconnected = true; in gb_svc_process_module_removed()
1026 list_del(&module->hd_node); in gb_svc_process_module_removed()
1033 struct gb_connection *connection = operation->connection; in gb_svc_process_intf_oops()
1040 request = operation->request->payload; in gb_svc_process_intf_oops()
1041 intf_id = request->intf_id; in gb_svc_process_intf_oops()
1042 reason = request->reason; in gb_svc_process_intf_oops()
1046 dev_warn(&svc->dev, "unexpected interface-oops event %u\n", in gb_svc_process_intf_oops()
1051 dev_info(&svc->dev, "Deactivating interface %u, interface oops reason = %u\n", in gb_svc_process_intf_oops()
1054 mutex_lock(&intf->mutex); in gb_svc_process_intf_oops()
1055 intf->disconnected = true; in gb_svc_process_intf_oops()
1058 mutex_unlock(&intf->mutex); in gb_svc_process_intf_oops()
1064 struct gb_connection *connection = operation->connection; in gb_svc_process_intf_mailbox_event()
1072 request = operation->request->payload; in gb_svc_process_intf_mailbox_event()
1073 intf_id = request->intf_id; in gb_svc_process_intf_mailbox_event()
1074 result_code = le16_to_cpu(request->result_code); in gb_svc_process_intf_mailbox_event()
1075 mailbox = le32_to_cpu(request->mailbox); in gb_svc_process_intf_mailbox_event()
1077 dev_dbg(&svc->dev, "%s - id = %u, result = 0x%04x, mailbox = 0x%08x\n", in gb_svc_process_intf_mailbox_event()
1082 dev_warn(&svc->dev, "unexpected mailbox event %u\n", intf_id); in gb_svc_process_intf_mailbox_event()
1097 operation = dr->operation; in gb_svc_process_deferred_request()
1098 svc = gb_connection_get_data(operation->connection); in gb_svc_process_deferred_request()
1099 type = operation->request->header->type; in gb_svc_process_deferred_request()
1118 dev_err(&svc->dev, "bad deferred request type: 0x%02x\n", type); in gb_svc_process_deferred_request()
1127 struct gb_svc *svc = gb_connection_get_data(operation->connection); in gb_svc_queue_deferred_request()
1132 return -ENOMEM; in gb_svc_queue_deferred_request()
1136 dr->operation = operation; in gb_svc_queue_deferred_request()
1137 INIT_WORK(&dr->work, gb_svc_process_deferred_request); in gb_svc_queue_deferred_request()
1139 queue_work(svc->wq, &dr->work); in gb_svc_queue_deferred_request()
1146 struct gb_svc *svc = gb_connection_get_data(op->connection); in gb_svc_intf_reset_recv()
1147 struct gb_message *request = op->request; in gb_svc_intf_reset_recv()
1150 if (request->payload_size < sizeof(*reset)) { in gb_svc_intf_reset_recv()
1151 dev_warn(&svc->dev, "short reset request received (%zu < %zu)\n", in gb_svc_intf_reset_recv()
1152 request->payload_size, sizeof(*reset)); in gb_svc_intf_reset_recv()
1153 return -EINVAL; in gb_svc_intf_reset_recv()
1155 reset = request->payload; in gb_svc_intf_reset_recv()
1164 struct gb_svc *svc = gb_connection_get_data(op->connection); in gb_svc_module_inserted_recv()
1167 if (op->request->payload_size < sizeof(*request)) { in gb_svc_module_inserted_recv()
1168 dev_warn(&svc->dev, "short module-inserted request received (%zu < %zu)\n", in gb_svc_module_inserted_recv()
1169 op->request->payload_size, sizeof(*request)); in gb_svc_module_inserted_recv()
1170 return -EINVAL; in gb_svc_module_inserted_recv()
1173 request = op->request->payload; in gb_svc_module_inserted_recv()
1175 dev_dbg(&svc->dev, "%s - id = %u\n", __func__, in gb_svc_module_inserted_recv()
1176 request->primary_intf_id); in gb_svc_module_inserted_recv()
1183 struct gb_svc *svc = gb_connection_get_data(op->connection); in gb_svc_module_removed_recv()
1186 if (op->request->payload_size < sizeof(*request)) { in gb_svc_module_removed_recv()
1187 dev_warn(&svc->dev, "short module-removed request received (%zu < %zu)\n", in gb_svc_module_removed_recv()
1188 op->request->payload_size, sizeof(*request)); in gb_svc_module_removed_recv()
1189 return -EINVAL; in gb_svc_module_removed_recv()
1192 request = op->request->payload; in gb_svc_module_removed_recv()
1194 dev_dbg(&svc->dev, "%s - id = %u\n", __func__, in gb_svc_module_removed_recv()
1195 request->primary_intf_id); in gb_svc_module_removed_recv()
1202 struct gb_svc *svc = gb_connection_get_data(op->connection); in gb_svc_intf_oops_recv()
1205 if (op->request->payload_size < sizeof(*request)) { in gb_svc_intf_oops_recv()
1206 dev_warn(&svc->dev, "short intf-oops request received (%zu < %zu)\n", in gb_svc_intf_oops_recv()
1207 op->request->payload_size, sizeof(*request)); in gb_svc_intf_oops_recv()
1208 return -EINVAL; in gb_svc_intf_oops_recv()
1216 struct gb_svc *svc = gb_connection_get_data(op->connection); in gb_svc_intf_mailbox_event_recv()
1219 if (op->request->payload_size < sizeof(*request)) { in gb_svc_intf_mailbox_event_recv()
1220 dev_warn(&svc->dev, "short mailbox request received (%zu < %zu)\n", in gb_svc_intf_mailbox_event_recv()
1221 op->request->payload_size, sizeof(*request)); in gb_svc_intf_mailbox_event_recv()
1222 return -EINVAL; in gb_svc_intf_mailbox_event_recv()
1225 request = op->request->payload; in gb_svc_intf_mailbox_event_recv()
1227 dev_dbg(&svc->dev, "%s - id = %u\n", __func__, request->intf_id); in gb_svc_intf_mailbox_event_recv()
1234 struct gb_connection *connection = op->connection; in gb_svc_request_handler()
1236 u8 type = op->type; in gb_svc_request_handler()
1242 * - PROTOCOL_VERSION in gb_svc_request_handler()
1243 * - SVC_HELLO in gb_svc_request_handler()
1244 * - Any other request, but the earlier two. in gb_svc_request_handler()
1251 if (svc->state != GB_SVC_STATE_RESET) in gb_svc_request_handler()
1252 ret = -EINVAL; in gb_svc_request_handler()
1255 if (svc->state != GB_SVC_STATE_PROTOCOL_VERSION) in gb_svc_request_handler()
1256 ret = -EINVAL; in gb_svc_request_handler()
1259 if (svc->state != GB_SVC_STATE_SVC_HELLO) in gb_svc_request_handler()
1260 ret = -EINVAL; in gb_svc_request_handler()
1265 dev_warn(&svc->dev, "unexpected request 0x%02x received (state %u)\n", in gb_svc_request_handler()
1266 type, svc->state); in gb_svc_request_handler()
1274 svc->state = GB_SVC_STATE_PROTOCOL_VERSION; in gb_svc_request_handler()
1279 svc->state = GB_SVC_STATE_SVC_HELLO; in gb_svc_request_handler()
1292 dev_warn(&svc->dev, "unsupported request 0x%02x\n", type); in gb_svc_request_handler()
1293 return -EINVAL; in gb_svc_request_handler()
1301 if (svc->connection) in gb_svc_release()
1302 gb_connection_destroy(svc->connection); in gb_svc_release()
1303 ida_destroy(&svc->device_id_map); in gb_svc_release()
1304 destroy_workqueue(svc->wq); in gb_svc_release()
1321 svc->wq = alloc_ordered_workqueue("%s:svc", 0, dev_name(&hd->dev)); in gb_svc_create()
1322 if (!svc->wq) { in gb_svc_create()
1327 svc->dev.parent = &hd->dev; in gb_svc_create()
1328 svc->dev.bus = &greybus_bus_type; in gb_svc_create()
1329 svc->dev.type = &greybus_svc_type; in gb_svc_create()
1330 svc->dev.groups = svc_groups; in gb_svc_create()
1331 svc->dev.dma_mask = svc->dev.parent->dma_mask; in gb_svc_create()
1332 device_initialize(&svc->dev); in gb_svc_create()
1334 dev_set_name(&svc->dev, "%d-svc", hd->bus_id); in gb_svc_create()
1336 ida_init(&svc->device_id_map); in gb_svc_create()
1337 svc->state = GB_SVC_STATE_RESET; in gb_svc_create()
1338 svc->hd = hd; in gb_svc_create()
1340 svc->connection = gb_connection_create_static(hd, GB_SVC_CPORT_ID, in gb_svc_create()
1342 if (IS_ERR(svc->connection)) { in gb_svc_create()
1343 dev_err(&svc->dev, "failed to create connection: %ld\n", in gb_svc_create()
1344 PTR_ERR(svc->connection)); in gb_svc_create()
1348 gb_connection_set_data(svc->connection, svc); in gb_svc_create()
1353 put_device(&svc->dev); in gb_svc_create()
1366 ret = gb_connection_enable(svc->connection); in gb_svc_add()
1375 struct gb_host_device *hd = svc->hd; in gb_svc_remove_modules()
1378 list_for_each_entry_safe(module, tmp, &hd->modules, hd_node) { in gb_svc_remove_modules()
1380 list_del(&module->hd_node); in gb_svc_remove_modules()
1387 gb_connection_disable_rx(svc->connection); in gb_svc_del()
1392 if (device_is_registered(&svc->dev)) { in gb_svc_del()
1395 device_del(&svc->dev); in gb_svc_del()
1398 flush_workqueue(svc->wq); in gb_svc_del()
1402 gb_connection_disable(svc->connection); in gb_svc_del()
1407 put_device(&svc->dev); in gb_svc_put()