Lines Matching refs:svc

28 	struct gb_svc *svc = to_gb_svc(dev);
30 return sprintf(buf, "0x%04x\n", svc->endo_id);
37 struct gb_svc *svc = to_gb_svc(dev);
39 return sprintf(buf, "%u\n", svc->ap_intf_id);
52 struct gb_svc *svc = to_gb_svc(dev);
62 ret = gb_svc_intf_eject(svc, intf_id);
73 struct gb_svc *svc = to_gb_svc(dev);
76 gb_svc_watchdog_enabled(svc) ? "enabled" : "disabled");
83 struct gb_svc *svc = to_gb_svc(dev);
92 retval = gb_svc_watchdog_enable(svc);
94 retval = gb_svc_watchdog_disable(svc);
104 struct gb_svc *svc = to_gb_svc(dev);
106 if (svc->action == GB_SVC_WATCHDOG_BITE_PANIC_KERNEL)
108 else if (svc->action == GB_SVC_WATCHDOG_BITE_RESET_UNIPRO)
118 struct gb_svc *svc = to_gb_svc(dev);
121 svc->action = GB_SVC_WATCHDOG_BITE_PANIC_KERNEL;
123 svc->action = GB_SVC_WATCHDOG_BITE_RESET_UNIPRO;
131 static int gb_svc_pwrmon_rail_count_get(struct gb_svc *svc, u8 *value)
136 ret = gb_operation_sync(svc->connection,
140 dev_err(&svc->dev, "failed to get rail count: %d\n", ret);
149 static int gb_svc_pwrmon_rail_names_get(struct gb_svc *svc,
155 ret = gb_operation_sync(svc->connection,
159 dev_err(&svc->dev, "failed to get rail names: %d\n", ret);
164 dev_err(&svc->dev,
173 static int gb_svc_pwrmon_sample_get(struct gb_svc *svc, u8 rail_id,
183 ret = gb_operation_sync(svc->connection, GB_SVC_TYPE_PWRMON_SAMPLE_GET,
187 dev_err(&svc->dev, "failed to get rail sample: %d\n", ret);
192 dev_err(&svc->dev,
210 int gb_svc_pwrmon_intf_sample_get(struct gb_svc *svc, u8 intf_id,
220 ret = gb_operation_sync(svc->connection,
225 dev_err(&svc->dev, "failed to get intf sample: %d\n", ret);
230 dev_err(&svc->dev,
256 ATTRIBUTE_GROUPS(svc);
258 int gb_svc_intf_device_id(struct gb_svc *svc, u8 intf_id, u8 device_id)
265 return gb_operation_sync(svc->connection, GB_SVC_TYPE_INTF_DEVICE_ID,
269 int gb_svc_intf_eject(struct gb_svc *svc, u8 intf_id)
277 * The pulse width for module release in svc is long so we need to
280 ret = gb_operation_sync_timeout(svc->connection,
285 dev_err(&svc->dev, "failed to eject interface %u\n", intf_id);
292 int gb_svc_intf_vsys_set(struct gb_svc *svc, u8 intf_id, bool enable)
305 ret = gb_operation_sync(svc->connection, type,
315 int gb_svc_intf_refclk_set(struct gb_svc *svc, u8 intf_id, bool enable)
328 ret = gb_operation_sync(svc->connection, type,
338 int gb_svc_intf_unipro_set(struct gb_svc *svc, u8 intf_id, bool enable)
351 ret = gb_operation_sync(svc->connection, type,
361 int gb_svc_intf_activate(struct gb_svc *svc, u8 intf_id, u8 *intf_type)
369 ret = gb_operation_sync_timeout(svc->connection,
377 dev_err(&svc->dev, "failed to activate interface %u: %u\n",
387 int gb_svc_intf_resume(struct gb_svc *svc, u8 intf_id)
395 ret = gb_operation_sync_timeout(svc->connection,
401 dev_err(&svc->dev, "failed to send interface resume %u: %d\n",
407 dev_err(&svc->dev, "failed to resume interface %u: %u\n",
415 int gb_svc_dme_peer_get(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector,
427 ret = gb_operation_sync(svc->connection, GB_SVC_TYPE_DME_PEER_GET,
431 dev_err(&svc->dev, "failed to get DME attribute (%u 0x%04x %u): %d\n",
438 dev_err(&svc->dev, "UniPro error while getting DME attribute (%u 0x%04x %u): %u\n",
449 int gb_svc_dme_peer_set(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector,
462 ret = gb_operation_sync(svc->connection, GB_SVC_TYPE_DME_PEER_SET,
466 dev_err(&svc->dev, "failed to set DME attribute (%u 0x%04x %u %u): %d\n",
473 dev_err(&svc->dev, "UniPro error while setting DME attribute (%u 0x%04x %u %u): %u\n",
481 int gb_svc_connection_create(struct gb_svc *svc,
495 return gb_operation_sync(svc->connection, GB_SVC_TYPE_CONN_CREATE,
499 void gb_svc_connection_destroy(struct gb_svc *svc, u8 intf1_id, u16 cport1_id,
503 struct gb_connection *connection = svc->connection;
514 dev_err(&svc->dev, "failed to destroy connection (%u:%u %u:%u): %d\n",
520 int gb_svc_route_create(struct gb_svc *svc, u8 intf1_id, u8 dev1_id,
530 return gb_operation_sync(svc->connection, GB_SVC_TYPE_ROUTE_CREATE,
535 void gb_svc_route_destroy(struct gb_svc *svc, u8 intf1_id, u8 intf2_id)
543 ret = gb_operation_sync(svc->connection, GB_SVC_TYPE_ROUTE_DESTROY,
546 dev_err(&svc->dev, "failed to destroy route (%u %u): %d\n",
551 int gb_svc_intf_set_power_mode(struct gb_svc *svc, u8 intf_id, u8 hs_series,
583 ret = gb_operation_sync(svc->connection, GB_SVC_TYPE_INTF_SET_PWRM,
591 dev_err(&svc->dev, "set power mode = %d\n", result_code);
599 int gb_svc_intf_set_power_mode_hibernate(struct gb_svc *svc, u8 intf_id)
613 ret = gb_operation_sync(svc->connection, GB_SVC_TYPE_INTF_SET_PWRM,
617 dev_err(&svc->dev,
625 dev_err(&svc->dev,
634 int gb_svc_ping(struct gb_svc *svc)
636 return gb_operation_sync_timeout(svc->connection, GB_SVC_TYPE_PING,
644 struct gb_svc *svc = gb_connection_get_data(connection);
649 dev_err(&svc->dev, "short version request (%zu < %zu)\n",
658 dev_warn(&svc->dev, "unsupported major version (%u > %u)\n",
663 svc->protocol_major = request->major;
664 svc->protocol_minor = request->minor;
670 response->major = svc->protocol_major;
671 response->minor = svc->protocol_minor;
681 struct gb_svc *svc = pwrmon_rails->svc;
686 ret = gb_svc_pwrmon_sample_get(svc, pwrmon_rails->id,
689 dev_err(&svc->dev,
705 struct gb_svc *svc = pwrmon_rails->svc;
710 ret = gb_svc_pwrmon_sample_get(svc, pwrmon_rails->id,
713 dev_err(&svc->dev,
729 struct gb_svc *svc = pwrmon_rails->svc;
734 ret = gb_svc_pwrmon_sample_get(svc, pwrmon_rails->id,
737 dev_err(&svc->dev, "failed to get power sample %u: %d\n",
759 static void gb_svc_pwrmon_debugfs_init(struct gb_svc *svc)
767 dent = debugfs_create_dir("pwrmon", svc->debugfs_dentry);
771 if (gb_svc_pwrmon_rail_count_get(svc, &rail_count))
784 svc->pwrmon_rails = kcalloc(rail_count, sizeof(*svc->pwrmon_rails),
786 if (!svc->pwrmon_rails)
789 if (gb_svc_pwrmon_rail_names_get(svc, rail_names, bufsize))
794 struct svc_debugfs_pwrmon_rail *rail = &svc->pwrmon_rails[i];
801 rail->svc = svc;
817 kfree(svc->pwrmon_rails);
818 svc->pwrmon_rails = NULL;
824 static void gb_svc_debugfs_init(struct gb_svc *svc)
826 svc->debugfs_dentry = debugfs_create_dir(dev_name(&svc->dev),
828 gb_svc_pwrmon_debugfs_init(svc);
831 static void gb_svc_debugfs_exit(struct gb_svc *svc)
833 debugfs_remove_recursive(svc->debugfs_dentry);
834 kfree(svc->pwrmon_rails);
835 svc->pwrmon_rails = NULL;
841 struct gb_svc *svc = gb_connection_get_data(connection);
846 dev_warn(&svc->dev, "short hello request (%zu < %zu)\n",
853 svc->endo_id = le16_to_cpu(hello_request->endo_id);
854 svc->ap_intf_id = hello_request->interface_id;
856 ret = device_add(&svc->dev);
858 dev_err(&svc->dev, "failed to register svc device: %d\n", ret);
862 ret = gb_svc_watchdog_create(svc);
864 dev_err(&svc->dev, "failed to create watchdog: %d\n", ret);
876 gb_svc_debugfs_init(svc);
881 gb_svc_watchdog_destroy(svc);
883 device_del(&svc->dev);
888 static struct gb_interface *gb_svc_interface_lookup(struct gb_svc *svc,
891 struct gb_host_device *hd = svc->hd;
909 static struct gb_module *gb_svc_module_lookup(struct gb_svc *svc, u8 module_id)
911 struct gb_host_device *hd = svc->hd;
925 struct gb_svc *svc = gb_connection_get_data(connection);
937 ret = gb_svc_intf_set_power_mode(svc, svc->ap_intf_id,
949 dev_warn(&svc->dev,
958 struct gb_svc *svc = gb_connection_get_data(connection);
959 struct gb_host_device *hd = svc->hd;
972 dev_dbg(&svc->dev, "%s - id = %u, num_interfaces = %zu, flags = 0x%04x\n",
976 dev_warn(&svc->dev, "no primary interface detected on module %u\n",
980 module = gb_svc_module_lookup(svc, module_id);
982 dev_warn(&svc->dev, "unexpected module-inserted event %u\n",
989 dev_err(&svc->dev, "failed to create module\n");
1006 struct gb_svc *svc = gb_connection_get_data(connection);
1014 dev_dbg(&svc->dev, "%s - id = %u\n", __func__, module_id);
1016 module = gb_svc_module_lookup(svc, module_id);
1018 dev_warn(&svc->dev, "unexpected module-removed event %u\n",
1034 struct gb_svc *svc = gb_connection_get_data(connection);
1044 intf = gb_svc_interface_lookup(svc, intf_id);
1046 dev_warn(&svc->dev, "unexpected interface-oops event %u\n",
1051 dev_info(&svc->dev, "Deactivating interface %u, interface oops reason = %u\n",
1065 struct gb_svc *svc = gb_connection_get_data(connection);
1077 dev_dbg(&svc->dev, "%s - id = %u, result = 0x%04x, mailbox = 0x%08x\n",
1080 intf = gb_svc_interface_lookup(svc, intf_id);
1082 dev_warn(&svc->dev, "unexpected mailbox event %u\n", intf_id);
1093 struct gb_svc *svc;
1098 svc = gb_connection_get_data(operation->connection);
1118 dev_err(&svc->dev, "bad deferred request type: 0x%02x\n", type);
1127 struct gb_svc *svc = gb_connection_get_data(operation->connection);
1139 queue_work(svc->wq, &dr->work);
1146 struct gb_svc *svc = gb_connection_get_data(op->connection);
1151 dev_warn(&svc->dev, "short reset request received (%zu < %zu)\n",
1164 struct gb_svc *svc = gb_connection_get_data(op->connection);
1168 dev_warn(&svc->dev, "short module-inserted request received (%zu < %zu)\n",
1175 dev_dbg(&svc->dev, "%s - id = %u\n", __func__,
1183 struct gb_svc *svc = gb_connection_get_data(op->connection);
1187 dev_warn(&svc->dev, "short module-removed request received (%zu < %zu)\n",
1194 dev_dbg(&svc->dev, "%s - id = %u\n", __func__,
1202 struct gb_svc *svc = gb_connection_get_data(op->connection);
1206 dev_warn(&svc->dev, "short intf-oops request received (%zu < %zu)\n",
1216 struct gb_svc *svc = gb_connection_get_data(op->connection);
1220 dev_warn(&svc->dev, "short mailbox request received (%zu < %zu)\n",
1227 dev_dbg(&svc->dev, "%s - id = %u\n", __func__, request->intf_id);
1235 struct gb_svc *svc = gb_connection_get_data(connection);
1251 if (svc->state != GB_SVC_STATE_RESET)
1255 if (svc->state != GB_SVC_STATE_PROTOCOL_VERSION)
1259 if (svc->state != GB_SVC_STATE_SVC_HELLO)
1265 dev_warn(&svc->dev, "unexpected request 0x%02x received (state %u)\n",
1266 type, svc->state);
1274 svc->state = GB_SVC_STATE_PROTOCOL_VERSION;
1279 svc->state = GB_SVC_STATE_SVC_HELLO;
1292 dev_warn(&svc->dev, "unsupported request 0x%02x\n", type);
1299 struct gb_svc *svc = to_gb_svc(dev);
1301 if (svc->connection)
1302 gb_connection_destroy(svc->connection);
1303 ida_destroy(&svc->device_id_map);
1304 destroy_workqueue(svc->wq);
1305 kfree(svc);
1315 struct gb_svc *svc;
1317 svc = kzalloc(sizeof(*svc), GFP_KERNEL);
1318 if (!svc)
1321 svc->wq = alloc_ordered_workqueue("%s:svc", 0, dev_name(&hd->dev));
1322 if (!svc->wq) {
1323 kfree(svc);
1327 svc->dev.parent = &hd->dev;
1328 svc->dev.bus = &greybus_bus_type;
1329 svc->dev.type = &greybus_svc_type;
1330 svc->dev.groups = svc_groups;
1331 svc->dev.dma_mask = svc->dev.parent->dma_mask;
1332 device_initialize(&svc->dev);
1334 dev_set_name(&svc->dev, "%d-svc", hd->bus_id);
1336 ida_init(&svc->device_id_map);
1337 svc->state = GB_SVC_STATE_RESET;
1338 svc->hd = hd;
1340 svc->connection = gb_connection_create_static(hd, GB_SVC_CPORT_ID,
1342 if (IS_ERR(svc->connection)) {
1343 dev_err(&svc->dev, "failed to create connection: %ld\n",
1344 PTR_ERR(svc->connection));
1348 gb_connection_set_data(svc->connection, svc);
1350 return svc;
1353 put_device(&svc->dev);
1357 int gb_svc_add(struct gb_svc *svc)
1366 ret = gb_connection_enable(svc->connection);
1373 static void gb_svc_remove_modules(struct gb_svc *svc)
1375 struct gb_host_device *hd = svc->hd;
1385 void gb_svc_del(struct gb_svc *svc)
1387 gb_connection_disable_rx(svc->connection);
1392 if (device_is_registered(&svc->dev)) {
1393 gb_svc_debugfs_exit(svc);
1394 gb_svc_watchdog_destroy(svc);
1395 device_del(&svc->dev);
1398 flush_workqueue(svc->wq);
1400 gb_svc_remove_modules(svc);
1402 gb_connection_disable(svc->connection);
1405 void gb_svc_put(struct gb_svc *svc)
1407 put_device(&svc->dev);