Lines Matching refs:svc
27 struct gb_svc *svc = to_gb_svc(dev); in endo_id_show() local
29 return sprintf(buf, "0x%04x\n", svc->endo_id); in endo_id_show()
36 struct gb_svc *svc = to_gb_svc(dev); in ap_intf_id_show() local
38 return sprintf(buf, "%u\n", svc->ap_intf_id); in ap_intf_id_show()
51 struct gb_svc *svc = to_gb_svc(dev); in intf_eject_store() local
61 ret = gb_svc_intf_eject(svc, intf_id); in intf_eject_store()
72 struct gb_svc *svc = to_gb_svc(dev); in watchdog_show() local
75 gb_svc_watchdog_enabled(svc) ? "enabled" : "disabled"); in watchdog_show()
82 struct gb_svc *svc = to_gb_svc(dev); in watchdog_store() local
91 retval = gb_svc_watchdog_enable(svc); in watchdog_store()
93 retval = gb_svc_watchdog_disable(svc); in watchdog_store()
103 struct gb_svc *svc = to_gb_svc(dev); in watchdog_action_show() local
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()
117 struct gb_svc *svc = to_gb_svc(dev); in watchdog_action_store() local
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()
130 static int gb_svc_pwrmon_rail_count_get(struct gb_svc *svc, u8 *value) in gb_svc_pwrmon_rail_count_get() argument
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()
148 static int gb_svc_pwrmon_rail_names_get(struct gb_svc *svc, in gb_svc_pwrmon_rail_names_get() argument
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()
163 dev_err(&svc->dev, in gb_svc_pwrmon_rail_names_get()
172 static int gb_svc_pwrmon_sample_get(struct gb_svc *svc, u8 rail_id, in gb_svc_pwrmon_sample_get() argument
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()
209 int gb_svc_pwrmon_intf_sample_get(struct gb_svc *svc, u8 intf_id, in gb_svc_pwrmon_intf_sample_get() argument
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()
255 ATTRIBUTE_GROUPS(svc);
257 int gb_svc_intf_device_id(struct gb_svc *svc, u8 intf_id, u8 device_id) in gb_svc_intf_device_id() argument
264 return gb_operation_sync(svc->connection, GB_SVC_TYPE_INTF_DEVICE_ID, in gb_svc_intf_device_id()
268 int gb_svc_intf_eject(struct gb_svc *svc, u8 intf_id) in gb_svc_intf_eject() argument
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()
291 int gb_svc_intf_vsys_set(struct gb_svc *svc, u8 intf_id, bool enable) in gb_svc_intf_vsys_set() argument
304 ret = gb_operation_sync(svc->connection, type, in gb_svc_intf_vsys_set()
314 int gb_svc_intf_refclk_set(struct gb_svc *svc, u8 intf_id, bool enable) in gb_svc_intf_refclk_set() argument
327 ret = gb_operation_sync(svc->connection, type, in gb_svc_intf_refclk_set()
337 int gb_svc_intf_unipro_set(struct gb_svc *svc, u8 intf_id, bool enable) in gb_svc_intf_unipro_set() argument
350 ret = gb_operation_sync(svc->connection, type, in gb_svc_intf_unipro_set()
360 int gb_svc_intf_activate(struct gb_svc *svc, u8 intf_id, u8 *intf_type) in gb_svc_intf_activate() argument
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()
386 int gb_svc_intf_resume(struct gb_svc *svc, u8 intf_id) in gb_svc_intf_resume() argument
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()
414 int gb_svc_dme_peer_get(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector, in gb_svc_dme_peer_get() argument
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()
448 int gb_svc_dme_peer_set(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector, in gb_svc_dme_peer_set() argument
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()
480 int gb_svc_connection_create(struct gb_svc *svc, in gb_svc_connection_create() argument
494 return gb_operation_sync(svc->connection, GB_SVC_TYPE_CONN_CREATE, in gb_svc_connection_create()
498 void gb_svc_connection_destroy(struct gb_svc *svc, u8 intf1_id, u16 cport1_id, in gb_svc_connection_destroy() argument
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()
519 int gb_svc_route_create(struct gb_svc *svc, u8 intf1_id, u8 dev1_id, in gb_svc_route_create() argument
529 return gb_operation_sync(svc->connection, GB_SVC_TYPE_ROUTE_CREATE, in gb_svc_route_create()
534 void gb_svc_route_destroy(struct gb_svc *svc, u8 intf1_id, u8 intf2_id) in gb_svc_route_destroy() argument
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()
550 int gb_svc_intf_set_power_mode(struct gb_svc *svc, u8 intf_id, u8 hs_series, in gb_svc_intf_set_power_mode() argument
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()
598 int gb_svc_intf_set_power_mode_hibernate(struct gb_svc *svc, u8 intf_id) in gb_svc_intf_set_power_mode_hibernate() argument
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()
633 int gb_svc_ping(struct gb_svc *svc) in gb_svc_ping() argument
635 return gb_operation_sync_timeout(svc->connection, GB_SVC_TYPE_PING, in gb_svc_ping()
643 struct gb_svc *svc = gb_connection_get_data(connection); in gb_svc_version_request() local
648 dev_err(&svc->dev, "short version request (%zu < %zu)\n", in gb_svc_version_request()
657 dev_warn(&svc->dev, "unsupported major version (%u > %u)\n", 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()
669 response->major = svc->protocol_major; in gb_svc_version_request()
670 response->minor = svc->protocol_minor; in gb_svc_version_request()
680 struct gb_svc *svc = pwrmon_rails->svc; in pwr_debugfs_voltage_read() local
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()
704 struct gb_svc *svc = pwrmon_rails->svc; in pwr_debugfs_current_read() local
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()
728 struct gb_svc *svc = pwrmon_rails->svc; in pwr_debugfs_power_read() local
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()
758 static void gb_svc_pwrmon_debugfs_init(struct gb_svc *svc) in gb_svc_pwrmon_debugfs_init() argument
766 dent = debugfs_create_dir("pwrmon", svc->debugfs_dentry); in gb_svc_pwrmon_debugfs_init()
770 if (gb_svc_pwrmon_rail_count_get(svc, &rail_count)) 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()
788 if (gb_svc_pwrmon_rail_names_get(svc, rail_names, bufsize)) in gb_svc_pwrmon_debugfs_init()
793 struct svc_debugfs_pwrmon_rail *rail = &svc->pwrmon_rails[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()
823 static void gb_svc_debugfs_init(struct gb_svc *svc) in gb_svc_debugfs_init() argument
825 svc->debugfs_dentry = debugfs_create_dir(dev_name(&svc->dev), in gb_svc_debugfs_init()
827 gb_svc_pwrmon_debugfs_init(svc); in gb_svc_debugfs_init()
830 static void gb_svc_debugfs_exit(struct gb_svc *svc) in gb_svc_debugfs_exit() argument
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()
840 struct gb_svc *svc = gb_connection_get_data(connection); in gb_svc_hello() local
845 dev_warn(&svc->dev, "short hello request (%zu < %zu)\n", 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()
861 ret = gb_svc_watchdog_create(svc); in gb_svc_hello()
863 dev_err(&svc->dev, "failed to create watchdog: %d\n", ret); in gb_svc_hello()
867 gb_svc_debugfs_init(svc); in gb_svc_hello()
876 gb_svc_debugfs_exit(svc); in gb_svc_hello()
878 gb_svc_watchdog_destroy(svc); in gb_svc_hello()
879 device_del(&svc->dev); in gb_svc_hello()
883 static struct gb_interface *gb_svc_interface_lookup(struct gb_svc *svc, in gb_svc_interface_lookup() argument
886 struct gb_host_device *hd = svc->hd; in gb_svc_interface_lookup()
904 static struct gb_module *gb_svc_module_lookup(struct gb_svc *svc, u8 module_id) in gb_svc_module_lookup() argument
906 struct gb_host_device *hd = svc->hd; in gb_svc_module_lookup()
920 struct gb_svc *svc = gb_connection_get_data(connection); in gb_svc_process_hello_deferred() local
932 ret = gb_svc_intf_set_power_mode(svc, svc->ap_intf_id, in gb_svc_process_hello_deferred()
944 dev_warn(&svc->dev, in gb_svc_process_hello_deferred()
953 struct gb_svc *svc = gb_connection_get_data(connection); in gb_svc_process_module_inserted() local
954 struct gb_host_device *hd = svc->hd; in gb_svc_process_module_inserted()
967 dev_dbg(&svc->dev, "%s - id = %u, num_interfaces = %zu, flags = 0x%04x\n", in gb_svc_process_module_inserted()
971 dev_warn(&svc->dev, "no primary interface detected on module %u\n", in gb_svc_process_module_inserted()
975 module = gb_svc_module_lookup(svc, module_id); in gb_svc_process_module_inserted()
977 dev_warn(&svc->dev, "unexpected module-inserted event %u\n", in gb_svc_process_module_inserted()
984 dev_err(&svc->dev, "failed to create module\n"); in gb_svc_process_module_inserted()
1001 struct gb_svc *svc = gb_connection_get_data(connection); in gb_svc_process_module_removed() local
1009 dev_dbg(&svc->dev, "%s - id = %u\n", __func__, module_id); in gb_svc_process_module_removed()
1011 module = gb_svc_module_lookup(svc, module_id); in gb_svc_process_module_removed()
1013 dev_warn(&svc->dev, "unexpected module-removed event %u\n", in gb_svc_process_module_removed()
1029 struct gb_svc *svc = gb_connection_get_data(connection); in gb_svc_process_intf_oops() local
1039 intf = gb_svc_interface_lookup(svc, intf_id); in gb_svc_process_intf_oops()
1041 dev_warn(&svc->dev, "unexpected interface-oops event %u\n", in gb_svc_process_intf_oops()
1046 dev_info(&svc->dev, "Deactivating interface %u, interface oops reason = %u\n", in gb_svc_process_intf_oops()
1060 struct gb_svc *svc = gb_connection_get_data(connection); in gb_svc_process_intf_mailbox_event() local
1072 dev_dbg(&svc->dev, "%s - id = %u, result = 0x%04x, mailbox = 0x%08x\n", in gb_svc_process_intf_mailbox_event()
1075 intf = gb_svc_interface_lookup(svc, intf_id); in gb_svc_process_intf_mailbox_event()
1077 dev_warn(&svc->dev, "unexpected mailbox event %u\n", intf_id); in gb_svc_process_intf_mailbox_event()
1088 struct gb_svc *svc; in gb_svc_process_deferred_request() local
1093 svc = gb_connection_get_data(operation->connection); in gb_svc_process_deferred_request()
1113 dev_err(&svc->dev, "bad deferred request type: 0x%02x\n", type); in gb_svc_process_deferred_request()
1122 struct gb_svc *svc = gb_connection_get_data(operation->connection); in gb_svc_queue_deferred_request() local
1134 queue_work(svc->wq, &dr->work); in gb_svc_queue_deferred_request()
1141 struct gb_svc *svc = gb_connection_get_data(op->connection); in gb_svc_intf_reset_recv() local
1146 dev_warn(&svc->dev, "short reset request received (%zu < %zu)\n", in gb_svc_intf_reset_recv()
1159 struct gb_svc *svc = gb_connection_get_data(op->connection); in gb_svc_module_inserted_recv() local
1163 dev_warn(&svc->dev, "short module-inserted request received (%zu < %zu)\n", in gb_svc_module_inserted_recv()
1170 dev_dbg(&svc->dev, "%s - id = %u\n", __func__, in gb_svc_module_inserted_recv()
1178 struct gb_svc *svc = gb_connection_get_data(op->connection); in gb_svc_module_removed_recv() local
1182 dev_warn(&svc->dev, "short module-removed request received (%zu < %zu)\n", in gb_svc_module_removed_recv()
1189 dev_dbg(&svc->dev, "%s - id = %u\n", __func__, in gb_svc_module_removed_recv()
1197 struct gb_svc *svc = gb_connection_get_data(op->connection); in gb_svc_intf_oops_recv() local
1201 dev_warn(&svc->dev, "short intf-oops request received (%zu < %zu)\n", in gb_svc_intf_oops_recv()
1211 struct gb_svc *svc = gb_connection_get_data(op->connection); in gb_svc_intf_mailbox_event_recv() local
1215 dev_warn(&svc->dev, "short mailbox request received (%zu < %zu)\n", in gb_svc_intf_mailbox_event_recv()
1222 dev_dbg(&svc->dev, "%s - id = %u\n", __func__, request->intf_id); in gb_svc_intf_mailbox_event_recv()
1230 struct gb_svc *svc = gb_connection_get_data(connection); in gb_svc_request_handler() local
1246 if (svc->state != GB_SVC_STATE_RESET) in gb_svc_request_handler()
1250 if (svc->state != GB_SVC_STATE_PROTOCOL_VERSION) in gb_svc_request_handler()
1254 if (svc->state != GB_SVC_STATE_SVC_HELLO) in gb_svc_request_handler()
1260 dev_warn(&svc->dev, "unexpected request 0x%02x received (state %u)\n", in gb_svc_request_handler()
1261 type, svc->state); in gb_svc_request_handler()
1269 svc->state = GB_SVC_STATE_PROTOCOL_VERSION; in gb_svc_request_handler()
1274 svc->state = GB_SVC_STATE_SVC_HELLO; in gb_svc_request_handler()
1287 dev_warn(&svc->dev, "unsupported request 0x%02x\n", type); in gb_svc_request_handler()
1294 struct gb_svc *svc = to_gb_svc(dev); in gb_svc_release() local
1296 if (svc->connection) in gb_svc_release()
1297 gb_connection_destroy(svc->connection); in gb_svc_release()
1298 ida_destroy(&svc->device_id_map); in gb_svc_release()
1299 destroy_workqueue(svc->wq); in gb_svc_release()
1300 kfree(svc); in gb_svc_release()
1310 struct gb_svc *svc; in gb_svc_create() local
1312 svc = kzalloc(sizeof(*svc), GFP_KERNEL); in gb_svc_create()
1313 if (!svc) in gb_svc_create()
1316 svc->wq = alloc_workqueue("%s:svc", WQ_UNBOUND, 1, dev_name(&hd->dev)); in gb_svc_create()
1317 if (!svc->wq) { in gb_svc_create()
1318 kfree(svc); in gb_svc_create()
1322 svc->dev.parent = &hd->dev; in gb_svc_create()
1323 svc->dev.bus = &greybus_bus_type; in gb_svc_create()
1324 svc->dev.type = &greybus_svc_type; in gb_svc_create()
1325 svc->dev.groups = svc_groups; in gb_svc_create()
1326 svc->dev.dma_mask = svc->dev.parent->dma_mask; in gb_svc_create()
1327 device_initialize(&svc->dev); in gb_svc_create()
1329 dev_set_name(&svc->dev, "%d-svc", hd->bus_id); in gb_svc_create()
1331 ida_init(&svc->device_id_map); in gb_svc_create()
1332 svc->state = GB_SVC_STATE_RESET; in gb_svc_create()
1333 svc->hd = hd; in gb_svc_create()
1335 svc->connection = gb_connection_create_static(hd, GB_SVC_CPORT_ID, in gb_svc_create()
1337 if (IS_ERR(svc->connection)) { in gb_svc_create()
1338 dev_err(&svc->dev, "failed to create connection: %ld\n", in gb_svc_create()
1339 PTR_ERR(svc->connection)); in gb_svc_create()
1343 gb_connection_set_data(svc->connection, svc); in gb_svc_create()
1345 return svc; in gb_svc_create()
1348 put_device(&svc->dev); in gb_svc_create()
1352 int gb_svc_add(struct gb_svc *svc) in gb_svc_add() argument
1361 ret = gb_connection_enable(svc->connection); in gb_svc_add()
1368 static void gb_svc_remove_modules(struct gb_svc *svc) in gb_svc_remove_modules() argument
1370 struct gb_host_device *hd = svc->hd; in gb_svc_remove_modules()
1380 void gb_svc_del(struct gb_svc *svc) in gb_svc_del() argument
1382 gb_connection_disable_rx(svc->connection); in gb_svc_del()
1387 if (device_is_registered(&svc->dev)) { in gb_svc_del()
1388 gb_svc_debugfs_exit(svc); in gb_svc_del()
1389 gb_svc_watchdog_destroy(svc); in gb_svc_del()
1390 device_del(&svc->dev); in gb_svc_del()
1393 flush_workqueue(svc->wq); in gb_svc_del()
1395 gb_svc_remove_modules(svc); in gb_svc_del()
1397 gb_connection_disable(svc->connection); in gb_svc_del()
1400 void gb_svc_put(struct gb_svc *svc) in gb_svc_put() argument
1402 put_device(&svc->dev); in gb_svc_put()