Lines Matching refs:svc
27 struct gb_svc *svc = to_gb_svc(dev);
29 return sprintf(buf, "0x%04x\n", svc->endo_id);
36 struct gb_svc *svc = to_gb_svc(dev);
38 return sprintf(buf, "%u\n", svc->ap_intf_id);
51 struct gb_svc *svc = to_gb_svc(dev);
61 ret = gb_svc_intf_eject(svc, intf_id);
72 struct gb_svc *svc = to_gb_svc(dev);
75 gb_svc_watchdog_enabled(svc) ? "enabled" : "disabled");
82 struct gb_svc *svc = to_gb_svc(dev);
91 retval = gb_svc_watchdog_enable(svc);
93 retval = gb_svc_watchdog_disable(svc);
103 struct gb_svc *svc = to_gb_svc(dev);
105 if (svc->action == GB_SVC_WATCHDOG_BITE_PANIC_KERNEL)
107 else if (svc->action == GB_SVC_WATCHDOG_BITE_RESET_UNIPRO)
117 struct gb_svc *svc = to_gb_svc(dev);
120 svc->action = GB_SVC_WATCHDOG_BITE_PANIC_KERNEL;
122 svc->action = GB_SVC_WATCHDOG_BITE_RESET_UNIPRO;
130 static int gb_svc_pwrmon_rail_count_get(struct gb_svc *svc, u8 *value)
135 ret = gb_operation_sync(svc->connection,
139 dev_err(&svc->dev, "failed to get rail count: %d\n", ret);
148 static int gb_svc_pwrmon_rail_names_get(struct gb_svc *svc,
154 ret = gb_operation_sync(svc->connection,
158 dev_err(&svc->dev, "failed to get rail names: %d\n", ret);
163 dev_err(&svc->dev,
172 static int gb_svc_pwrmon_sample_get(struct gb_svc *svc, u8 rail_id,
182 ret = gb_operation_sync(svc->connection, GB_SVC_TYPE_PWRMON_SAMPLE_GET,
186 dev_err(&svc->dev, "failed to get rail sample: %d\n", ret);
191 dev_err(&svc->dev,
209 int gb_svc_pwrmon_intf_sample_get(struct gb_svc *svc, u8 intf_id,
219 ret = gb_operation_sync(svc->connection,
224 dev_err(&svc->dev, "failed to get intf sample: %d\n", ret);
229 dev_err(&svc->dev,
255 ATTRIBUTE_GROUPS(svc);
257 int gb_svc_intf_device_id(struct gb_svc *svc, u8 intf_id, u8 device_id)
264 return gb_operation_sync(svc->connection, GB_SVC_TYPE_INTF_DEVICE_ID,
268 int gb_svc_intf_eject(struct gb_svc *svc, u8 intf_id)
276 * The pulse width for module release in svc is long so we need to
279 ret = gb_operation_sync_timeout(svc->connection,
284 dev_err(&svc->dev, "failed to eject interface %u\n", intf_id);
291 int gb_svc_intf_vsys_set(struct gb_svc *svc, u8 intf_id, bool enable)
304 ret = gb_operation_sync(svc->connection, type,
314 int gb_svc_intf_refclk_set(struct gb_svc *svc, u8 intf_id, bool enable)
327 ret = gb_operation_sync(svc->connection, type,
337 int gb_svc_intf_unipro_set(struct gb_svc *svc, u8 intf_id, bool enable)
350 ret = gb_operation_sync(svc->connection, type,
360 int gb_svc_intf_activate(struct gb_svc *svc, u8 intf_id, u8 *intf_type)
368 ret = gb_operation_sync_timeout(svc->connection,
376 dev_err(&svc->dev, "failed to activate interface %u: %u\n",
386 int gb_svc_intf_resume(struct gb_svc *svc, u8 intf_id)
394 ret = gb_operation_sync_timeout(svc->connection,
400 dev_err(&svc->dev, "failed to send interface resume %u: %d\n",
406 dev_err(&svc->dev, "failed to resume interface %u: %u\n",
414 int gb_svc_dme_peer_get(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector,
426 ret = gb_operation_sync(svc->connection, GB_SVC_TYPE_DME_PEER_GET,
430 dev_err(&svc->dev, "failed to get DME attribute (%u 0x%04x %u): %d\n",
437 dev_err(&svc->dev, "UniPro error while getting DME attribute (%u 0x%04x %u): %u\n",
448 int gb_svc_dme_peer_set(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector,
461 ret = gb_operation_sync(svc->connection, GB_SVC_TYPE_DME_PEER_SET,
465 dev_err(&svc->dev, "failed to set DME attribute (%u 0x%04x %u %u): %d\n",
472 dev_err(&svc->dev, "UniPro error while setting DME attribute (%u 0x%04x %u %u): %u\n",
480 int gb_svc_connection_create(struct gb_svc *svc,
494 return gb_operation_sync(svc->connection, GB_SVC_TYPE_CONN_CREATE,
498 void gb_svc_connection_destroy(struct gb_svc *svc, u8 intf1_id, u16 cport1_id,
502 struct gb_connection *connection = svc->connection;
513 dev_err(&svc->dev, "failed to destroy connection (%u:%u %u:%u): %d\n",
519 int gb_svc_route_create(struct gb_svc *svc, u8 intf1_id, u8 dev1_id,
529 return gb_operation_sync(svc->connection, GB_SVC_TYPE_ROUTE_CREATE,
534 void gb_svc_route_destroy(struct gb_svc *svc, u8 intf1_id, u8 intf2_id)
542 ret = gb_operation_sync(svc->connection, GB_SVC_TYPE_ROUTE_DESTROY,
545 dev_err(&svc->dev, "failed to destroy route (%u %u): %d\n",
550 int gb_svc_intf_set_power_mode(struct gb_svc *svc, u8 intf_id, u8 hs_series,
582 ret = gb_operation_sync(svc->connection, GB_SVC_TYPE_INTF_SET_PWRM,
590 dev_err(&svc->dev, "set power mode = %d\n", result_code);
598 int gb_svc_intf_set_power_mode_hibernate(struct gb_svc *svc, u8 intf_id)
612 ret = gb_operation_sync(svc->connection, GB_SVC_TYPE_INTF_SET_PWRM,
616 dev_err(&svc->dev,
624 dev_err(&svc->dev,
633 int gb_svc_ping(struct gb_svc *svc)
635 return gb_operation_sync_timeout(svc->connection, GB_SVC_TYPE_PING,
643 struct gb_svc *svc = gb_connection_get_data(connection);
648 dev_err(&svc->dev, "short version request (%zu < %zu)\n",
657 dev_warn(&svc->dev, "unsupported major version (%u > %u)\n",
662 svc->protocol_major = request->major;
663 svc->protocol_minor = request->minor;
669 response->major = svc->protocol_major;
670 response->minor = svc->protocol_minor;
680 struct gb_svc *svc = pwrmon_rails->svc;
685 ret = gb_svc_pwrmon_sample_get(svc, pwrmon_rails->id,
688 dev_err(&svc->dev,
704 struct gb_svc *svc = pwrmon_rails->svc;
709 ret = gb_svc_pwrmon_sample_get(svc, pwrmon_rails->id,
712 dev_err(&svc->dev,
728 struct gb_svc *svc = pwrmon_rails->svc;
733 ret = gb_svc_pwrmon_sample_get(svc, pwrmon_rails->id,
736 dev_err(&svc->dev, "failed to get power sample %u: %d\n",
758 static void gb_svc_pwrmon_debugfs_init(struct gb_svc *svc)
766 dent = debugfs_create_dir("pwrmon", svc->debugfs_dentry);
770 if (gb_svc_pwrmon_rail_count_get(svc, &rail_count))
783 svc->pwrmon_rails = kcalloc(rail_count, sizeof(*svc->pwrmon_rails),
785 if (!svc->pwrmon_rails)
788 if (gb_svc_pwrmon_rail_names_get(svc, rail_names, bufsize))
793 struct svc_debugfs_pwrmon_rail *rail = &svc->pwrmon_rails[i];
800 rail->svc = svc;
816 kfree(svc->pwrmon_rails);
817 svc->pwrmon_rails = NULL;
823 static void gb_svc_debugfs_init(struct gb_svc *svc)
825 svc->debugfs_dentry = debugfs_create_dir(dev_name(&svc->dev),
827 gb_svc_pwrmon_debugfs_init(svc);
830 static void gb_svc_debugfs_exit(struct gb_svc *svc)
832 debugfs_remove_recursive(svc->debugfs_dentry);
833 kfree(svc->pwrmon_rails);
834 svc->pwrmon_rails = NULL;
840 struct gb_svc *svc = gb_connection_get_data(connection);
845 dev_warn(&svc->dev, "short hello request (%zu < %zu)\n",
852 svc->endo_id = le16_to_cpu(hello_request->endo_id);
853 svc->ap_intf_id = hello_request->interface_id;
855 ret = device_add(&svc->dev);
857 dev_err(&svc->dev, "failed to register svc device: %d\n", ret);
861 ret = gb_svc_watchdog_create(svc);
863 dev_err(&svc->dev, "failed to create watchdog: %d\n", ret);
867 gb_svc_debugfs_init(svc);
876 gb_svc_debugfs_exit(svc);
878 gb_svc_watchdog_destroy(svc);
879 device_del(&svc->dev);
883 static struct gb_interface *gb_svc_interface_lookup(struct gb_svc *svc,
886 struct gb_host_device *hd = svc->hd;
904 static struct gb_module *gb_svc_module_lookup(struct gb_svc *svc, u8 module_id)
906 struct gb_host_device *hd = svc->hd;
920 struct gb_svc *svc = gb_connection_get_data(connection);
932 ret = gb_svc_intf_set_power_mode(svc, svc->ap_intf_id,
944 dev_warn(&svc->dev,
953 struct gb_svc *svc = gb_connection_get_data(connection);
954 struct gb_host_device *hd = svc->hd;
967 dev_dbg(&svc->dev, "%s - id = %u, num_interfaces = %zu, flags = 0x%04x\n",
971 dev_warn(&svc->dev, "no primary interface detected on module %u\n",
975 module = gb_svc_module_lookup(svc, module_id);
977 dev_warn(&svc->dev, "unexpected module-inserted event %u\n",
984 dev_err(&svc->dev, "failed to create module\n");
1001 struct gb_svc *svc = gb_connection_get_data(connection);
1009 dev_dbg(&svc->dev, "%s - id = %u\n", __func__, module_id);
1011 module = gb_svc_module_lookup(svc, module_id);
1013 dev_warn(&svc->dev, "unexpected module-removed event %u\n",
1029 struct gb_svc *svc = gb_connection_get_data(connection);
1039 intf = gb_svc_interface_lookup(svc, intf_id);
1041 dev_warn(&svc->dev, "unexpected interface-oops event %u\n",
1046 dev_info(&svc->dev, "Deactivating interface %u, interface oops reason = %u\n",
1060 struct gb_svc *svc = gb_connection_get_data(connection);
1072 dev_dbg(&svc->dev, "%s - id = %u, result = 0x%04x, mailbox = 0x%08x\n",
1075 intf = gb_svc_interface_lookup(svc, intf_id);
1077 dev_warn(&svc->dev, "unexpected mailbox event %u\n", intf_id);
1088 struct gb_svc *svc;
1093 svc = gb_connection_get_data(operation->connection);
1113 dev_err(&svc->dev, "bad deferred request type: 0x%02x\n", type);
1122 struct gb_svc *svc = gb_connection_get_data(operation->connection);
1134 queue_work(svc->wq, &dr->work);
1141 struct gb_svc *svc = gb_connection_get_data(op->connection);
1146 dev_warn(&svc->dev, "short reset request received (%zu < %zu)\n",
1159 struct gb_svc *svc = gb_connection_get_data(op->connection);
1163 dev_warn(&svc->dev, "short module-inserted request received (%zu < %zu)\n",
1170 dev_dbg(&svc->dev, "%s - id = %u\n", __func__,
1178 struct gb_svc *svc = gb_connection_get_data(op->connection);
1182 dev_warn(&svc->dev, "short module-removed request received (%zu < %zu)\n",
1189 dev_dbg(&svc->dev, "%s - id = %u\n", __func__,
1197 struct gb_svc *svc = gb_connection_get_data(op->connection);
1201 dev_warn(&svc->dev, "short intf-oops request received (%zu < %zu)\n",
1211 struct gb_svc *svc = gb_connection_get_data(op->connection);
1215 dev_warn(&svc->dev, "short mailbox request received (%zu < %zu)\n",
1222 dev_dbg(&svc->dev, "%s - id = %u\n", __func__, request->intf_id);
1230 struct gb_svc *svc = gb_connection_get_data(connection);
1246 if (svc->state != GB_SVC_STATE_RESET)
1250 if (svc->state != GB_SVC_STATE_PROTOCOL_VERSION)
1254 if (svc->state != GB_SVC_STATE_SVC_HELLO)
1260 dev_warn(&svc->dev, "unexpected request 0x%02x received (state %u)\n",
1261 type, svc->state);
1269 svc->state = GB_SVC_STATE_PROTOCOL_VERSION;
1274 svc->state = GB_SVC_STATE_SVC_HELLO;
1287 dev_warn(&svc->dev, "unsupported request 0x%02x\n", type);
1294 struct gb_svc *svc = to_gb_svc(dev);
1296 if (svc->connection)
1297 gb_connection_destroy(svc->connection);
1298 ida_destroy(&svc->device_id_map);
1299 destroy_workqueue(svc->wq);
1300 kfree(svc);
1310 struct gb_svc *svc;
1312 svc = kzalloc(sizeof(*svc), GFP_KERNEL);
1313 if (!svc)
1316 svc->wq = alloc_workqueue("%s:svc", WQ_UNBOUND, 1, dev_name(&hd->dev));
1317 if (!svc->wq) {
1318 kfree(svc);
1322 svc->dev.parent = &hd->dev;
1323 svc->dev.bus = &greybus_bus_type;
1324 svc->dev.type = &greybus_svc_type;
1325 svc->dev.groups = svc_groups;
1326 svc->dev.dma_mask = svc->dev.parent->dma_mask;
1327 device_initialize(&svc->dev);
1329 dev_set_name(&svc->dev, "%d-svc", hd->bus_id);
1331 ida_init(&svc->device_id_map);
1332 svc->state = GB_SVC_STATE_RESET;
1333 svc->hd = hd;
1335 svc->connection = gb_connection_create_static(hd, GB_SVC_CPORT_ID,
1337 if (IS_ERR(svc->connection)) {
1338 dev_err(&svc->dev, "failed to create connection: %ld\n",
1339 PTR_ERR(svc->connection));
1343 gb_connection_set_data(svc->connection, svc);
1345 return svc;
1348 put_device(&svc->dev);
1352 int gb_svc_add(struct gb_svc *svc)
1361 ret = gb_connection_enable(svc->connection);
1368 static void gb_svc_remove_modules(struct gb_svc *svc)
1370 struct gb_host_device *hd = svc->hd;
1380 void gb_svc_del(struct gb_svc *svc)
1382 gb_connection_disable_rx(svc->connection);
1387 if (device_is_registered(&svc->dev)) {
1388 gb_svc_debugfs_exit(svc);
1389 gb_svc_watchdog_destroy(svc);
1390 device_del(&svc->dev);
1393 flush_workqueue(svc->wq);
1395 gb_svc_remove_modules(svc);
1397 gb_connection_disable(svc->connection);
1400 void gb_svc_put(struct gb_svc *svc)
1402 put_device(&svc->dev);