Lines Matching refs:svc

28 	struct gb_svc *svc = to_gb_svc(dev);  in endo_id_show()  local
30 return sprintf(buf, "0x%04x\n", svc->endo_id); in endo_id_show()
37 struct gb_svc *svc = to_gb_svc(dev); in ap_intf_id_show() local
39 return sprintf(buf, "%u\n", svc->ap_intf_id); in ap_intf_id_show()
52 struct gb_svc *svc = to_gb_svc(dev); in intf_eject_store() local
62 ret = gb_svc_intf_eject(svc, intf_id); in intf_eject_store()
73 struct gb_svc *svc = to_gb_svc(dev); in watchdog_show() local
76 gb_svc_watchdog_enabled(svc) ? "enabled" : "disabled"); in watchdog_show()
83 struct gb_svc *svc = to_gb_svc(dev); in watchdog_store() local
92 retval = gb_svc_watchdog_enable(svc); in watchdog_store()
94 retval = gb_svc_watchdog_disable(svc); in watchdog_store()
104 struct gb_svc *svc = to_gb_svc(dev); in watchdog_action_show() local
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()
118 struct gb_svc *svc = to_gb_svc(dev); in watchdog_action_store() local
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()
131 static int gb_svc_pwrmon_rail_count_get(struct gb_svc *svc, u8 *value) in gb_svc_pwrmon_rail_count_get() argument
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()
149 static int gb_svc_pwrmon_rail_names_get(struct gb_svc *svc, in gb_svc_pwrmon_rail_names_get() argument
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()
164 dev_err(&svc->dev, in gb_svc_pwrmon_rail_names_get()
173 static int gb_svc_pwrmon_sample_get(struct gb_svc *svc, u8 rail_id, in gb_svc_pwrmon_sample_get() argument
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()
210 int gb_svc_pwrmon_intf_sample_get(struct gb_svc *svc, u8 intf_id, in gb_svc_pwrmon_intf_sample_get() argument
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()
256 ATTRIBUTE_GROUPS(svc);
258 int gb_svc_intf_device_id(struct gb_svc *svc, u8 intf_id, u8 device_id) in gb_svc_intf_device_id() argument
265 return gb_operation_sync(svc->connection, GB_SVC_TYPE_INTF_DEVICE_ID, in gb_svc_intf_device_id()
269 int gb_svc_intf_eject(struct gb_svc *svc, u8 intf_id) in gb_svc_intf_eject() argument
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()
292 int gb_svc_intf_vsys_set(struct gb_svc *svc, u8 intf_id, bool enable) in gb_svc_intf_vsys_set() argument
305 ret = gb_operation_sync(svc->connection, type, in gb_svc_intf_vsys_set()
315 int gb_svc_intf_refclk_set(struct gb_svc *svc, u8 intf_id, bool enable) in gb_svc_intf_refclk_set() argument
328 ret = gb_operation_sync(svc->connection, type, in gb_svc_intf_refclk_set()
338 int gb_svc_intf_unipro_set(struct gb_svc *svc, u8 intf_id, bool enable) in gb_svc_intf_unipro_set() argument
351 ret = gb_operation_sync(svc->connection, type, in gb_svc_intf_unipro_set()
361 int gb_svc_intf_activate(struct gb_svc *svc, u8 intf_id, u8 *intf_type) in gb_svc_intf_activate() argument
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()
387 int gb_svc_intf_resume(struct gb_svc *svc, u8 intf_id) in gb_svc_intf_resume() argument
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()
415 int gb_svc_dme_peer_get(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector, in gb_svc_dme_peer_get() argument
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()
449 int gb_svc_dme_peer_set(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector, in gb_svc_dme_peer_set() argument
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()
481 int gb_svc_connection_create(struct gb_svc *svc, in gb_svc_connection_create() argument
495 return gb_operation_sync(svc->connection, GB_SVC_TYPE_CONN_CREATE, in gb_svc_connection_create()
499 void gb_svc_connection_destroy(struct gb_svc *svc, u8 intf1_id, u16 cport1_id, in gb_svc_connection_destroy() argument
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()
520 int gb_svc_route_create(struct gb_svc *svc, u8 intf1_id, u8 dev1_id, in gb_svc_route_create() argument
530 return gb_operation_sync(svc->connection, GB_SVC_TYPE_ROUTE_CREATE, in gb_svc_route_create()
535 void gb_svc_route_destroy(struct gb_svc *svc, u8 intf1_id, u8 intf2_id) in gb_svc_route_destroy() argument
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()
551 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
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()
599 int gb_svc_intf_set_power_mode_hibernate(struct gb_svc *svc, u8 intf_id) in gb_svc_intf_set_power_mode_hibernate() argument
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()
634 int gb_svc_ping(struct gb_svc *svc) in gb_svc_ping() argument
636 return gb_operation_sync_timeout(svc->connection, GB_SVC_TYPE_PING, in gb_svc_ping()
644 struct gb_svc *svc = gb_connection_get_data(connection); in gb_svc_version_request() local
649 dev_err(&svc->dev, "short version request (%zu < %zu)\n", in gb_svc_version_request()
658 dev_warn(&svc->dev, "unsupported major version (%u > %u)\n", 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()
670 response->major = svc->protocol_major; in gb_svc_version_request()
671 response->minor = svc->protocol_minor; in gb_svc_version_request()
681 struct gb_svc *svc = pwrmon_rails->svc; in pwr_debugfs_voltage_read() local
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()
705 struct gb_svc *svc = pwrmon_rails->svc; in pwr_debugfs_current_read() local
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()
729 struct gb_svc *svc = pwrmon_rails->svc; in pwr_debugfs_power_read() local
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()
759 static void gb_svc_pwrmon_debugfs_init(struct gb_svc *svc) in gb_svc_pwrmon_debugfs_init() argument
767 dent = debugfs_create_dir("pwrmon", svc->debugfs_dentry); in gb_svc_pwrmon_debugfs_init()
771 if (gb_svc_pwrmon_rail_count_get(svc, &rail_count)) 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()
789 if (gb_svc_pwrmon_rail_names_get(svc, rail_names, bufsize)) in gb_svc_pwrmon_debugfs_init()
794 struct svc_debugfs_pwrmon_rail *rail = &svc->pwrmon_rails[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()
824 static void gb_svc_debugfs_init(struct gb_svc *svc) in gb_svc_debugfs_init() argument
826 svc->debugfs_dentry = debugfs_create_dir(dev_name(&svc->dev), in gb_svc_debugfs_init()
828 gb_svc_pwrmon_debugfs_init(svc); in gb_svc_debugfs_init()
831 static void gb_svc_debugfs_exit(struct gb_svc *svc) in gb_svc_debugfs_exit() argument
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()
841 struct gb_svc *svc = gb_connection_get_data(connection); in gb_svc_hello() local
846 dev_warn(&svc->dev, "short hello request (%zu < %zu)\n", 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()
862 ret = gb_svc_watchdog_create(svc); in gb_svc_hello()
864 dev_err(&svc->dev, "failed to create watchdog: %d\n", ret); in gb_svc_hello()
876 gb_svc_debugfs_init(svc); in gb_svc_hello()
881 gb_svc_watchdog_destroy(svc); in gb_svc_hello()
883 device_del(&svc->dev); in gb_svc_hello()
888 static struct gb_interface *gb_svc_interface_lookup(struct gb_svc *svc, in gb_svc_interface_lookup() argument
891 struct gb_host_device *hd = svc->hd; in gb_svc_interface_lookup()
909 static struct gb_module *gb_svc_module_lookup(struct gb_svc *svc, u8 module_id) in gb_svc_module_lookup() argument
911 struct gb_host_device *hd = svc->hd; in gb_svc_module_lookup()
925 struct gb_svc *svc = gb_connection_get_data(connection); in gb_svc_process_hello_deferred() local
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()
958 struct gb_svc *svc = gb_connection_get_data(connection); in gb_svc_process_module_inserted() local
959 struct gb_host_device *hd = svc->hd; 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()
980 module = gb_svc_module_lookup(svc, module_id); 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()
1006 struct gb_svc *svc = gb_connection_get_data(connection); in gb_svc_process_module_removed() local
1014 dev_dbg(&svc->dev, "%s - id = %u\n", __func__, module_id); in gb_svc_process_module_removed()
1016 module = gb_svc_module_lookup(svc, 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()
1034 struct gb_svc *svc = gb_connection_get_data(connection); in gb_svc_process_intf_oops() local
1044 intf = gb_svc_interface_lookup(svc, intf_id); 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()
1065 struct gb_svc *svc = gb_connection_get_data(connection); in gb_svc_process_intf_mailbox_event() local
1077 dev_dbg(&svc->dev, "%s - id = %u, result = 0x%04x, mailbox = 0x%08x\n", in gb_svc_process_intf_mailbox_event()
1080 intf = gb_svc_interface_lookup(svc, intf_id); 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()
1093 struct gb_svc *svc; in gb_svc_process_deferred_request() local
1098 svc = gb_connection_get_data(operation->connection); 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() local
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() local
1151 dev_warn(&svc->dev, "short reset request received (%zu < %zu)\n", in gb_svc_intf_reset_recv()
1164 struct gb_svc *svc = gb_connection_get_data(op->connection); in gb_svc_module_inserted_recv() local
1168 dev_warn(&svc->dev, "short module-inserted request received (%zu < %zu)\n", in gb_svc_module_inserted_recv()
1175 dev_dbg(&svc->dev, "%s - id = %u\n", __func__, in gb_svc_module_inserted_recv()
1183 struct gb_svc *svc = gb_connection_get_data(op->connection); in gb_svc_module_removed_recv() local
1187 dev_warn(&svc->dev, "short module-removed request received (%zu < %zu)\n", in gb_svc_module_removed_recv()
1194 dev_dbg(&svc->dev, "%s - id = %u\n", __func__, in gb_svc_module_removed_recv()
1202 struct gb_svc *svc = gb_connection_get_data(op->connection); in gb_svc_intf_oops_recv() local
1206 dev_warn(&svc->dev, "short intf-oops request received (%zu < %zu)\n", in gb_svc_intf_oops_recv()
1216 struct gb_svc *svc = gb_connection_get_data(op->connection); in gb_svc_intf_mailbox_event_recv() local
1220 dev_warn(&svc->dev, "short mailbox request received (%zu < %zu)\n", 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()
1235 struct gb_svc *svc = gb_connection_get_data(connection); in gb_svc_request_handler() local
1251 if (svc->state != GB_SVC_STATE_RESET) in gb_svc_request_handler()
1255 if (svc->state != GB_SVC_STATE_PROTOCOL_VERSION) in gb_svc_request_handler()
1259 if (svc->state != GB_SVC_STATE_SVC_HELLO) 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()
1299 struct gb_svc *svc = to_gb_svc(dev); in gb_svc_release() local
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()
1305 kfree(svc); in gb_svc_release()
1315 struct gb_svc *svc; in gb_svc_create() local
1317 svc = kzalloc(sizeof(*svc), GFP_KERNEL); in gb_svc_create()
1318 if (!svc) in gb_svc_create()
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()
1323 kfree(svc); 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()
1350 return svc; in gb_svc_create()
1353 put_device(&svc->dev); in gb_svc_create()
1357 int gb_svc_add(struct gb_svc *svc) in gb_svc_add() argument
1366 ret = gb_connection_enable(svc->connection); in gb_svc_add()
1373 static void gb_svc_remove_modules(struct gb_svc *svc) in gb_svc_remove_modules() argument
1375 struct gb_host_device *hd = svc->hd; in gb_svc_remove_modules()
1385 void gb_svc_del(struct gb_svc *svc) in gb_svc_del() argument
1387 gb_connection_disable_rx(svc->connection); in gb_svc_del()
1392 if (device_is_registered(&svc->dev)) { in gb_svc_del()
1393 gb_svc_debugfs_exit(svc); in gb_svc_del()
1394 gb_svc_watchdog_destroy(svc); in gb_svc_del()
1395 device_del(&svc->dev); in gb_svc_del()
1398 flush_workqueue(svc->wq); in gb_svc_del()
1400 gb_svc_remove_modules(svc); in gb_svc_del()
1402 gb_connection_disable(svc->connection); in gb_svc_del()
1405 void gb_svc_put(struct gb_svc *svc) in gb_svc_put() argument
1407 put_device(&svc->dev); in gb_svc_put()