Lines Matching full:control

3  * Greybus CPort control protocol.
14 /* Highest control-protocol version supported */
18 static int gb_control_get_version(struct gb_control *control) in gb_control_get_version() argument
20 struct gb_interface *intf = control->connection->intf; in gb_control_get_version()
28 ret = gb_operation_sync(control->connection, in gb_control_get_version()
34 "failed to get control-protocol version: %d\n", in gb_control_get_version()
41 "unsupported major control-protocol version (%u > %u)\n", in gb_control_get_version()
46 control->protocol_major = response.major; in gb_control_get_version()
47 control->protocol_minor = response.minor; in gb_control_get_version()
55 static int gb_control_get_bundle_version(struct gb_control *control, in gb_control_get_bundle_version() argument
58 struct gb_interface *intf = control->connection->intf; in gb_control_get_bundle_version()
65 ret = gb_operation_sync(control->connection, in gb_control_get_bundle_version()
85 int gb_control_get_bundle_versions(struct gb_control *control) in gb_control_get_bundle_versions() argument
87 struct gb_interface *intf = control->connection->intf; in gb_control_get_bundle_versions()
91 if (!control->has_bundle_version) in gb_control_get_bundle_versions()
95 ret = gb_control_get_bundle_version(control, bundle); in gb_control_get_bundle_versions()
107 struct gb_connection *connection = intf->control->connection; in gb_control_get_manifest_size_operation()
125 struct gb_connection *connection = intf->control->connection; in gb_control_get_manifest_operation()
131 int gb_control_connected_operation(struct gb_control *control, u16 cport_id) in gb_control_connected_operation() argument
136 return gb_operation_sync(control->connection, GB_CONTROL_TYPE_CONNECTED, in gb_control_connected_operation()
140 int gb_control_disconnected_operation(struct gb_control *control, u16 cport_id) in gb_control_disconnected_operation() argument
145 return gb_operation_sync(control->connection, in gb_control_disconnected_operation()
150 int gb_control_disconnecting_operation(struct gb_control *control, in gb_control_disconnecting_operation() argument
157 operation = gb_operation_create_core(control->connection, in gb_control_disconnecting_operation()
169 dev_err(&control->dev, "failed to send disconnecting: %d\n", in gb_control_disconnecting_operation()
178 int gb_control_mode_switch_operation(struct gb_control *control) in gb_control_mode_switch_operation() argument
183 operation = gb_operation_create_core(control->connection, in gb_control_mode_switch_operation()
193 dev_err(&control->dev, "failed to send mode switch: %d\n", ret); in gb_control_mode_switch_operation()
215 int gb_control_bundle_suspend(struct gb_control *control, u8 bundle_id) in gb_control_bundle_suspend() argument
222 ret = gb_operation_sync(control->connection, in gb_control_bundle_suspend()
226 dev_err(&control->dev, "failed to send bundle %u suspend: %d\n", in gb_control_bundle_suspend()
232 dev_err(&control->dev, "failed to suspend bundle %u: %d\n", in gb_control_bundle_suspend()
240 int gb_control_bundle_resume(struct gb_control *control, u8 bundle_id) in gb_control_bundle_resume() argument
247 ret = gb_operation_sync(control->connection, in gb_control_bundle_resume()
251 dev_err(&control->dev, "failed to send bundle %u resume: %d\n", in gb_control_bundle_resume()
257 dev_err(&control->dev, "failed to resume bundle %u: %d\n", in gb_control_bundle_resume()
265 int gb_control_bundle_deactivate(struct gb_control *control, u8 bundle_id) in gb_control_bundle_deactivate() argument
272 ret = gb_operation_sync(control->connection, in gb_control_bundle_deactivate()
276 dev_err(&control->dev, in gb_control_bundle_deactivate()
283 dev_err(&control->dev, "failed to deactivate bundle %u: %d\n", in gb_control_bundle_deactivate()
291 int gb_control_bundle_activate(struct gb_control *control, u8 bundle_id) in gb_control_bundle_activate() argument
297 if (!control->has_bundle_activate) in gb_control_bundle_activate()
301 ret = gb_operation_sync(control->connection, in gb_control_bundle_activate()
305 dev_err(&control->dev, in gb_control_bundle_activate()
312 dev_err(&control->dev, "failed to activate bundle %u: %d\n", in gb_control_bundle_activate()
332 int gb_control_interface_suspend_prepare(struct gb_control *control) in gb_control_interface_suspend_prepare() argument
337 ret = gb_operation_sync(control->connection, in gb_control_interface_suspend_prepare()
341 dev_err(&control->dev, in gb_control_interface_suspend_prepare()
347 dev_err(&control->dev, "interface error while preparing suspend: %d\n", in gb_control_interface_suspend_prepare()
355 int gb_control_interface_deactivate_prepare(struct gb_control *control) in gb_control_interface_deactivate_prepare() argument
360 ret = gb_operation_sync(control->connection, in gb_control_interface_deactivate_prepare()
364 dev_err(&control->dev, "failed to send interface deactivate prepare: %d\n", in gb_control_interface_deactivate_prepare()
370 dev_err(&control->dev, "interface error while preparing deactivate: %d\n", in gb_control_interface_deactivate_prepare()
378 int gb_control_interface_hibernate_abort(struct gb_control *control) in gb_control_interface_hibernate_abort() argument
383 ret = gb_operation_sync(control->connection, in gb_control_interface_hibernate_abort()
387 dev_err(&control->dev, in gb_control_interface_hibernate_abort()
394 dev_err(&control->dev, "interface error while aborting hibernate: %d\n", in gb_control_interface_hibernate_abort()
405 struct gb_control *control = to_gb_control(dev); in vendor_string_show() local
407 return scnprintf(buf, PAGE_SIZE, "%s\n", control->vendor_string); in vendor_string_show()
414 struct gb_control *control = to_gb_control(dev); in product_string_show() local
416 return scnprintf(buf, PAGE_SIZE, "%s\n", control->product_string); in product_string_show()
425 ATTRIBUTE_GROUPS(control);
429 struct gb_control *control = to_gb_control(dev); in gb_control_release() local
431 gb_connection_destroy(control->connection); in gb_control_release()
433 kfree(control->vendor_string); in gb_control_release()
434 kfree(control->product_string); in gb_control_release()
436 kfree(control); in gb_control_release()
447 struct gb_control *control; in gb_control_create() local
449 control = kzalloc(sizeof(*control), GFP_KERNEL); in gb_control_create()
450 if (!control) in gb_control_create()
453 control->intf = intf; in gb_control_create()
458 "failed to create control connection: %ld\n", in gb_control_create()
460 kfree(control); in gb_control_create()
464 control->connection = connection; in gb_control_create()
466 control->dev.parent = &intf->dev; in gb_control_create()
467 control->dev.bus = &greybus_bus_type; in gb_control_create()
468 control->dev.type = &greybus_control_type; in gb_control_create()
469 control->dev.groups = control_groups; in gb_control_create()
470 control->dev.dma_mask = intf->dev.dma_mask; in gb_control_create()
471 device_initialize(&control->dev); in gb_control_create()
472 dev_set_name(&control->dev, "%s.ctrl", dev_name(&intf->dev)); in gb_control_create()
474 gb_connection_set_data(control->connection, control); in gb_control_create()
476 return control; in gb_control_create()
479 int gb_control_enable(struct gb_control *control) in gb_control_enable() argument
483 dev_dbg(&control->connection->intf->dev, "%s\n", __func__); in gb_control_enable()
485 ret = gb_connection_enable_tx(control->connection); in gb_control_enable()
487 dev_err(&control->connection->intf->dev, in gb_control_enable()
488 "failed to enable control connection: %d\n", in gb_control_enable()
493 ret = gb_control_get_version(control); in gb_control_enable()
497 if (control->protocol_major > 0 || control->protocol_minor > 1) in gb_control_enable()
498 control->has_bundle_version = true; in gb_control_enable()
501 if (!(control->intf->quirks & GB_INTERFACE_QUIRK_NO_BUNDLE_ACTIVATE)) in gb_control_enable()
502 control->has_bundle_activate = true; in gb_control_enable()
507 gb_connection_disable(control->connection); in gb_control_enable()
512 void gb_control_disable(struct gb_control *control) in gb_control_disable() argument
514 dev_dbg(&control->connection->intf->dev, "%s\n", __func__); in gb_control_disable()
516 if (control->intf->disconnected) in gb_control_disable()
517 gb_connection_disable_forced(control->connection); in gb_control_disable()
519 gb_connection_disable(control->connection); in gb_control_disable()
522 int gb_control_suspend(struct gb_control *control) in gb_control_suspend() argument
524 gb_connection_disable(control->connection); in gb_control_suspend()
529 int gb_control_resume(struct gb_control *control) in gb_control_resume() argument
533 ret = gb_connection_enable_tx(control->connection); in gb_control_resume()
535 dev_err(&control->connection->intf->dev, in gb_control_resume()
536 "failed to enable control connection: %d\n", ret); in gb_control_resume()
543 int gb_control_add(struct gb_control *control) in gb_control_add() argument
547 ret = device_add(&control->dev); in gb_control_add()
549 dev_err(&control->dev, in gb_control_add()
550 "failed to register control device: %d\n", in gb_control_add()
558 void gb_control_del(struct gb_control *control) in gb_control_del() argument
560 if (device_is_registered(&control->dev)) in gb_control_del()
561 device_del(&control->dev); in gb_control_del()
564 struct gb_control *gb_control_get(struct gb_control *control) in gb_control_get() argument
566 get_device(&control->dev); in gb_control_get()
568 return control; in gb_control_get()
571 void gb_control_put(struct gb_control *control) in gb_control_put() argument
573 put_device(&control->dev); in gb_control_put()
576 void gb_control_mode_switch_prepare(struct gb_control *control) in gb_control_mode_switch_prepare() argument
578 gb_connection_mode_switch_prepare(control->connection); in gb_control_mode_switch_prepare()
581 void gb_control_mode_switch_complete(struct gb_control *control) in gb_control_mode_switch_complete() argument
583 gb_connection_mode_switch_complete(control->connection); in gb_control_mode_switch_complete()