Lines Matching full:ctrl
79 struct serdev_controller *ctrl = to_serdev_controller(dev); in serdev_ctrl_release() local
80 ida_free(&ctrl_ida, ctrl->nr); in serdev_ctrl_release()
81 kfree(ctrl); in serdev_ctrl_release()
106 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_add() local
113 if (ctrl->serdev) { in serdev_device_add()
117 ctrl->serdev = serdev; in serdev_device_add()
131 ctrl->serdev = NULL; in serdev_device_add()
142 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_remove() local
145 ctrl->serdev = NULL; in serdev_device_remove()
151 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_open() local
154 if (!ctrl || !ctrl->ops->open) in serdev_device_open()
157 ret = ctrl->ops->open(ctrl); in serdev_device_open()
161 ret = pm_runtime_get_sync(&ctrl->dev); in serdev_device_open()
163 pm_runtime_put_noidle(&ctrl->dev); in serdev_device_open()
170 if (ctrl->ops->close) in serdev_device_open()
171 ctrl->ops->close(ctrl); in serdev_device_open()
179 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_close() local
181 if (!ctrl || !ctrl->ops->close) in serdev_device_close()
184 pm_runtime_put(&ctrl->dev); in serdev_device_close()
186 ctrl->ops->close(ctrl); in serdev_device_close()
230 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_write_buf() local
232 if (!ctrl || !ctrl->ops->write_buf) in serdev_device_write_buf()
235 return ctrl->ops->write_buf(ctrl, buf, count); in serdev_device_write_buf()
264 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_write() local
268 if (!ctrl || !ctrl->ops->write_buf || !serdev->ops->write_wakeup) in serdev_device_write()
278 ret = ctrl->ops->write_buf(ctrl, buf, count); in serdev_device_write()
310 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_write_flush() local
312 if (!ctrl || !ctrl->ops->write_flush) in serdev_device_write_flush()
315 ctrl->ops->write_flush(ctrl); in serdev_device_write_flush()
321 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_write_room() local
323 if (!ctrl || !ctrl->ops->write_room) in serdev_device_write_room()
326 return serdev->ctrl->ops->write_room(ctrl); in serdev_device_write_room()
332 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_set_baudrate() local
334 if (!ctrl || !ctrl->ops->set_baudrate) in serdev_device_set_baudrate()
337 return ctrl->ops->set_baudrate(ctrl, speed); in serdev_device_set_baudrate()
344 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_set_flow_control() local
346 if (!ctrl || !ctrl->ops->set_flow_control) in serdev_device_set_flow_control()
349 ctrl->ops->set_flow_control(ctrl, enable); in serdev_device_set_flow_control()
356 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_set_parity() local
358 if (!ctrl || !ctrl->ops->set_parity) in serdev_device_set_parity()
361 return ctrl->ops->set_parity(ctrl, parity); in serdev_device_set_parity()
367 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_wait_until_sent() local
369 if (!ctrl || !ctrl->ops->wait_until_sent) in serdev_device_wait_until_sent()
372 ctrl->ops->wait_until_sent(ctrl, timeout); in serdev_device_wait_until_sent()
378 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_get_tiocm() local
380 if (!ctrl || !ctrl->ops->get_tiocm) in serdev_device_get_tiocm()
383 return ctrl->ops->get_tiocm(ctrl); in serdev_device_get_tiocm()
389 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_set_tiocm() local
391 if (!ctrl || !ctrl->ops->set_tiocm) in serdev_device_set_tiocm()
394 return ctrl->ops->set_tiocm(ctrl, set, clear); in serdev_device_set_tiocm()
400 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_break_ctl() local
402 if (!ctrl || !ctrl->ops->break_ctl) in serdev_device_break_ctl()
405 return ctrl->ops->break_ctl(ctrl, break_state); in serdev_device_break_ctl()
443 * @ctrl: associated controller
448 struct serdev_device *serdev_device_alloc(struct serdev_controller *ctrl) in serdev_device_alloc() argument
456 serdev->ctrl = ctrl; in serdev_device_alloc()
458 serdev->dev.parent = &ctrl->dev; in serdev_device_alloc()
482 struct serdev_controller *ctrl; in serdev_controller_alloc() local
488 ctrl = kzalloc(sizeof(*ctrl) + size, GFP_KERNEL); in serdev_controller_alloc()
489 if (!ctrl) in serdev_controller_alloc()
499 ctrl->nr = id; in serdev_controller_alloc()
501 device_initialize(&ctrl->dev); in serdev_controller_alloc()
502 ctrl->dev.type = &serdev_ctrl_type; in serdev_controller_alloc()
503 ctrl->dev.bus = &serdev_bus_type; in serdev_controller_alloc()
504 ctrl->dev.parent = parent; in serdev_controller_alloc()
505 ctrl->host = host; in serdev_controller_alloc()
506 device_set_node(&ctrl->dev, dev_fwnode(host)); in serdev_controller_alloc()
507 serdev_controller_set_drvdata(ctrl, &ctrl[1]); in serdev_controller_alloc()
509 dev_set_name(&ctrl->dev, "serial%d", id); in serdev_controller_alloc()
511 pm_runtime_no_callbacks(&ctrl->dev); in serdev_controller_alloc()
512 pm_suspend_ignore_children(&ctrl->dev, true); in serdev_controller_alloc()
514 dev_dbg(&ctrl->dev, "allocated controller 0x%p id %d\n", ctrl, id); in serdev_controller_alloc()
515 return ctrl; in serdev_controller_alloc()
518 kfree(ctrl); in serdev_controller_alloc()
524 static int of_serdev_register_devices(struct serdev_controller *ctrl) in of_serdev_register_devices() argument
531 for_each_available_child_of_node(ctrl->dev.of_node, node) { in of_serdev_register_devices()
535 dev_dbg(&ctrl->dev, "adding child %pOF\n", node); in of_serdev_register_devices()
537 serdev = serdev_device_alloc(ctrl); in of_serdev_register_devices()
643 static int acpi_serdev_check_resources(struct serdev_controller *ctrl, in acpi_serdev_check_resources() argument
669 if (!device_match_acpi_handle(ctrl->host, lookup.controller_handle)) in acpi_serdev_check_resources()
675 static acpi_status acpi_serdev_register_device(struct serdev_controller *ctrl, in acpi_serdev_register_device() argument
681 serdev = serdev_device_alloc(ctrl); in acpi_serdev_register_device()
683 dev_err(&ctrl->dev, "failed to allocate serdev device for %s\n", in acpi_serdev_register_device()
712 struct serdev_controller *ctrl = data; in acpi_serdev_add_device() local
721 if (acpi_serdev_check_resources(ctrl, adev)) in acpi_serdev_add_device()
724 return acpi_serdev_register_device(ctrl, adev); in acpi_serdev_add_device()
728 static int acpi_serdev_register_devices(struct serdev_controller *ctrl) in acpi_serdev_register_devices() argument
734 if (!has_acpi_companion(ctrl->host)) in acpi_serdev_register_devices()
743 ret = acpi_quirk_skip_serdev_enumeration(ctrl->host, &skip); in acpi_serdev_register_devices()
751 acpi_serdev_add_device, NULL, ctrl, NULL); in acpi_serdev_register_devices()
753 dev_warn(&ctrl->dev, "failed to enumerate serdev slaves\n"); in acpi_serdev_register_devices()
755 if (!ctrl->serdev) in acpi_serdev_register_devices()
761 static inline int acpi_serdev_register_devices(struct serdev_controller *ctrl) in acpi_serdev_register_devices() argument
769 * @ctrl: controller to be registered.
774 int serdev_controller_add(struct serdev_controller *ctrl) in serdev_controller_add() argument
782 ret = device_add(&ctrl->dev); in serdev_controller_add()
786 pm_runtime_enable(&ctrl->dev); in serdev_controller_add()
788 ret_of = of_serdev_register_devices(ctrl); in serdev_controller_add()
789 ret_acpi = acpi_serdev_register_devices(ctrl); in serdev_controller_add()
791 dev_dbg(&ctrl->dev, "no devices registered: of:%pe acpi:%pe\n", in serdev_controller_add()
797 dev_dbg(&ctrl->dev, "serdev%d registered: dev:%p\n", in serdev_controller_add()
798 ctrl->nr, &ctrl->dev); in serdev_controller_add()
802 pm_runtime_disable(&ctrl->dev); in serdev_controller_add()
803 device_del(&ctrl->dev); in serdev_controller_add()
819 * @ctrl: controller to remove
824 void serdev_controller_remove(struct serdev_controller *ctrl) in serdev_controller_remove() argument
826 if (!ctrl) in serdev_controller_remove()
829 device_for_each_child(&ctrl->dev, NULL, serdev_remove_device); in serdev_controller_remove()
830 pm_runtime_disable(&ctrl->dev); in serdev_controller_remove()
831 device_del(&ctrl->dev); in serdev_controller_remove()