Lines Matching +full:rpmsg +full:- +full:name
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2021 STMicroelectronics - All Rights Reserved
5 * The rpmsg tty driver implements serial communication on the RPMsg bus to makes
6 * possible for user-space programs to send and receive rpmsg messages as a standard
9 * The remote processor can instantiate a new tty by requesting a "rpmsg-tty" RPMsg service.
10 * The "rpmsg-tty" service is directly used for data exchange. No flow control is implemented yet.
16 #include <linux/rpmsg.h>
31 int id; /* TTY rpmsg index */
32 struct rpmsg_device *rpdev; /* rpmsg device */
37 struct rpmsg_tty_port *cport = dev_get_drvdata(&rpdev->dev); in rpmsg_tty_cb()
41 return -EINVAL; in rpmsg_tty_cb()
42 copied = tty_insert_flip_string(&cport->port, data, len); in rpmsg_tty_cb()
44 dev_err_ratelimited(&rpdev->dev, "Trunc buffer: available space is %d\n", copied); in rpmsg_tty_cb()
45 tty_flip_buffer_push(&cport->port); in rpmsg_tty_cb()
52 struct rpmsg_tty_port *cport = idr_find(&tty_idr, tty->index); in rpmsg_tty_install()
55 tty->driver_data = cport; in rpmsg_tty_install()
57 port = tty_port_get(&cport->port); in rpmsg_tty_install()
63 tty_port_put(tty->port); in rpmsg_tty_cleanup()
68 return tty_port_open(tty->port, tty, filp); in rpmsg_tty_open()
73 return tty_port_close(tty->port, tty, filp); in rpmsg_tty_close()
79 struct rpmsg_tty_port *cport = tty->driver_data; in rpmsg_tty_write()
84 rpdev = cport->rpdev; in rpmsg_tty_write()
86 msg_max_size = rpmsg_get_mtu(rpdev->ept); in rpmsg_tty_write()
94 * hung until a rpmsg buffer is available. In such case rpmsg_trysend returns -ENOMEM. in rpmsg_tty_write()
96 ret = rpmsg_trysend(rpdev->ept, (void *)buf, msg_size); in rpmsg_tty_write()
98 dev_dbg_ratelimited(&rpdev->dev, "rpmsg_send failed: %d\n", ret); in rpmsg_tty_write()
107 struct rpmsg_tty_port *cport = tty->driver_data; in rpmsg_tty_write_room()
110 size = rpmsg_get_mtu(cport->rpdev->ept); in rpmsg_tty_write_room()
119 tty_port_hangup(tty->port); in rpmsg_tty_hangup()
139 return ERR_PTR(-ENOMEM); in rpmsg_tty_alloc_cport()
150 cport->id = ret; in rpmsg_tty_alloc_cport()
160 idr_remove(&tty_idr, cport->id); in rpmsg_tty_destruct_port()
174 struct device *dev = &rpdev->dev; in rpmsg_tty_probe()
182 tty_port_init(&cport->port); in rpmsg_tty_probe()
183 cport->port.ops = &rpmsg_tty_port_ops; in rpmsg_tty_probe()
185 tty_dev = tty_port_register_device(&cport->port, rpmsg_tty_driver, in rpmsg_tty_probe()
186 cport->id, dev); in rpmsg_tty_probe()
189 tty_port_put(&cport->port); in rpmsg_tty_probe()
193 cport->rpdev = rpdev; in rpmsg_tty_probe()
197 dev_dbg(dev, "New channel: 0x%x -> 0x%x: " RPMSG_TTY_NAME "%d\n", in rpmsg_tty_probe()
198 rpdev->src, rpdev->dst, cport->id); in rpmsg_tty_probe()
205 struct rpmsg_tty_port *cport = dev_get_drvdata(&rpdev->dev); in rpmsg_tty_remove()
207 dev_dbg(&rpdev->dev, "Removing rpmsg tty device %d\n", cport->id); in rpmsg_tty_remove()
210 tty_port_tty_hangup(&cport->port, false); in rpmsg_tty_remove()
212 tty_unregister_device(rpmsg_tty_driver, cport->id); in rpmsg_tty_remove()
214 tty_port_put(&cport->port); in rpmsg_tty_remove()
218 { .name = "rpmsg-tty" },
221 MODULE_DEVICE_TABLE(rpmsg, rpmsg_driver_tty_id_table);
224 .drv.name = KBUILD_MODNAME,
240 rpmsg_tty_driver->driver_name = "rpmsg_tty"; in rpmsg_tty_init()
241 rpmsg_tty_driver->name = RPMSG_TTY_NAME; in rpmsg_tty_init()
242 rpmsg_tty_driver->major = 0; in rpmsg_tty_init()
243 rpmsg_tty_driver->type = TTY_DRIVER_TYPE_CONSOLE; in rpmsg_tty_init()
246 rpmsg_tty_driver->init_termios = tty_std_termios; in rpmsg_tty_init()
247 rpmsg_tty_driver->init_termios.c_lflag &= ~(ECHO | ICANON); in rpmsg_tty_init()
248 rpmsg_tty_driver->init_termios.c_oflag &= ~(OPOST | ONLCR); in rpmsg_tty_init()