Lines Matching refs:ctrl

77 	struct serdev_controller *ctrl = to_serdev_controller(dev);  in serdev_ctrl_release()  local
78 ida_simple_remove(&ctrl_ida, ctrl->nr); in serdev_ctrl_release()
79 kfree(ctrl); in serdev_ctrl_release()
104 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_add() local
111 if (ctrl->serdev) { in serdev_device_add()
115 ctrl->serdev = serdev; in serdev_device_add()
129 ctrl->serdev = NULL; in serdev_device_add()
140 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_remove() local
143 ctrl->serdev = NULL; in serdev_device_remove()
149 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_open() local
152 if (!ctrl || !ctrl->ops->open) in serdev_device_open()
155 ret = ctrl->ops->open(ctrl); in serdev_device_open()
159 ret = pm_runtime_get_sync(&ctrl->dev); in serdev_device_open()
161 pm_runtime_put_noidle(&ctrl->dev); in serdev_device_open()
168 if (ctrl->ops->close) in serdev_device_open()
169 ctrl->ops->close(ctrl); in serdev_device_open()
177 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_close() local
179 if (!ctrl || !ctrl->ops->close) in serdev_device_close()
182 pm_runtime_put(&ctrl->dev); in serdev_device_close()
184 ctrl->ops->close(ctrl); in serdev_device_close()
239 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_write_buf() local
241 if (!ctrl || !ctrl->ops->write_buf) in serdev_device_write_buf()
244 return ctrl->ops->write_buf(ctrl, buf, count); in serdev_device_write_buf()
274 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_write() local
278 if (!ctrl || !ctrl->ops->write_buf || !serdev->ops->write_wakeup) in serdev_device_write()
288 ret = ctrl->ops->write_buf(ctrl, buf, count); in serdev_device_write()
320 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_write_flush() local
322 if (!ctrl || !ctrl->ops->write_flush) in serdev_device_write_flush()
325 ctrl->ops->write_flush(ctrl); in serdev_device_write_flush()
331 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_write_room() local
333 if (!ctrl || !ctrl->ops->write_room) in serdev_device_write_room()
336 return serdev->ctrl->ops->write_room(ctrl); in serdev_device_write_room()
342 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_set_baudrate() local
344 if (!ctrl || !ctrl->ops->set_baudrate) in serdev_device_set_baudrate()
347 return ctrl->ops->set_baudrate(ctrl, speed); in serdev_device_set_baudrate()
354 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_set_flow_control() local
356 if (!ctrl || !ctrl->ops->set_flow_control) in serdev_device_set_flow_control()
359 ctrl->ops->set_flow_control(ctrl, enable); in serdev_device_set_flow_control()
366 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_set_parity() local
368 if (!ctrl || !ctrl->ops->set_parity) in serdev_device_set_parity()
371 return ctrl->ops->set_parity(ctrl, parity); in serdev_device_set_parity()
377 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_wait_until_sent() local
379 if (!ctrl || !ctrl->ops->wait_until_sent) in serdev_device_wait_until_sent()
382 ctrl->ops->wait_until_sent(ctrl, timeout); in serdev_device_wait_until_sent()
388 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_get_tiocm() local
390 if (!ctrl || !ctrl->ops->get_tiocm) in serdev_device_get_tiocm()
393 return ctrl->ops->get_tiocm(ctrl); in serdev_device_get_tiocm()
399 struct serdev_controller *ctrl = serdev->ctrl; in serdev_device_set_tiocm() local
401 if (!ctrl || !ctrl->ops->set_tiocm) in serdev_device_set_tiocm()
404 return ctrl->ops->set_tiocm(ctrl, set, clear); in serdev_device_set_tiocm()
447 struct serdev_device *serdev_device_alloc(struct serdev_controller *ctrl) in serdev_device_alloc() argument
455 serdev->ctrl = ctrl; in serdev_device_alloc()
457 serdev->dev.parent = &ctrl->dev; in serdev_device_alloc()
479 struct serdev_controller *ctrl; in serdev_controller_alloc() local
485 ctrl = kzalloc(sizeof(*ctrl) + size, GFP_KERNEL); in serdev_controller_alloc()
486 if (!ctrl) in serdev_controller_alloc()
496 ctrl->nr = id; in serdev_controller_alloc()
498 device_initialize(&ctrl->dev); in serdev_controller_alloc()
499 ctrl->dev.type = &serdev_ctrl_type; in serdev_controller_alloc()
500 ctrl->dev.bus = &serdev_bus_type; in serdev_controller_alloc()
501 ctrl->dev.parent = parent; in serdev_controller_alloc()
502 ctrl->dev.of_node = parent->of_node; in serdev_controller_alloc()
503 serdev_controller_set_drvdata(ctrl, &ctrl[1]); in serdev_controller_alloc()
505 dev_set_name(&ctrl->dev, "serial%d", id); in serdev_controller_alloc()
507 pm_runtime_no_callbacks(&ctrl->dev); in serdev_controller_alloc()
508 pm_suspend_ignore_children(&ctrl->dev, true); in serdev_controller_alloc()
510 dev_dbg(&ctrl->dev, "allocated controller 0x%p id %d\n", ctrl, id); in serdev_controller_alloc()
511 return ctrl; in serdev_controller_alloc()
514 kfree(ctrl); in serdev_controller_alloc()
520 static int of_serdev_register_devices(struct serdev_controller *ctrl) in of_serdev_register_devices() argument
527 for_each_available_child_of_node(ctrl->dev.of_node, node) { in of_serdev_register_devices()
531 dev_dbg(&ctrl->dev, "adding child %pOF\n", node); in of_serdev_register_devices()
533 serdev = serdev_device_alloc(ctrl); in of_serdev_register_devices()
639 static int acpi_serdev_check_resources(struct serdev_controller *ctrl, in acpi_serdev_check_resources() argument
665 if (ACPI_HANDLE(ctrl->dev.parent) != lookup.controller_handle) in acpi_serdev_check_resources()
671 static acpi_status acpi_serdev_register_device(struct serdev_controller *ctrl, in acpi_serdev_register_device() argument
677 serdev = serdev_device_alloc(ctrl); in acpi_serdev_register_device()
679 dev_err(&ctrl->dev, "failed to allocate serdev device for %s\n", in acpi_serdev_register_device()
707 struct serdev_controller *ctrl = data; in acpi_serdev_add_device() local
720 if (acpi_serdev_check_resources(ctrl, adev)) in acpi_serdev_add_device()
723 return acpi_serdev_register_device(ctrl, adev); in acpi_serdev_add_device()
727 static int acpi_serdev_register_devices(struct serdev_controller *ctrl) in acpi_serdev_register_devices() argument
731 if (!has_acpi_companion(ctrl->dev.parent)) in acpi_serdev_register_devices()
736 acpi_serdev_add_device, NULL, ctrl, NULL); in acpi_serdev_register_devices()
738 dev_warn(&ctrl->dev, "failed to enumerate serdev slaves\n"); in acpi_serdev_register_devices()
740 if (!ctrl->serdev) in acpi_serdev_register_devices()
746 static inline int acpi_serdev_register_devices(struct serdev_controller *ctrl) in acpi_serdev_register_devices() argument
759 int serdev_controller_add(struct serdev_controller *ctrl) in serdev_controller_add() argument
767 ret = device_add(&ctrl->dev); in serdev_controller_add()
771 pm_runtime_enable(&ctrl->dev); in serdev_controller_add()
773 ret_of = of_serdev_register_devices(ctrl); in serdev_controller_add()
774 ret_acpi = acpi_serdev_register_devices(ctrl); in serdev_controller_add()
776 dev_dbg(&ctrl->dev, "no devices registered: of:%pe acpi:%pe\n", in serdev_controller_add()
782 dev_dbg(&ctrl->dev, "serdev%d registered: dev:%p\n", in serdev_controller_add()
783 ctrl->nr, &ctrl->dev); in serdev_controller_add()
787 pm_runtime_disable(&ctrl->dev); in serdev_controller_add()
788 device_del(&ctrl->dev); in serdev_controller_add()
809 void serdev_controller_remove(struct serdev_controller *ctrl) in serdev_controller_remove() argument
811 if (!ctrl) in serdev_controller_remove()
814 device_for_each_child(&ctrl->dev, NULL, serdev_remove_device); in serdev_controller_remove()
815 pm_runtime_disable(&ctrl->dev); in serdev_controller_remove()
816 device_del(&ctrl->dev); in serdev_controller_remove()