68 lines · c
1/* SPDX-License-Identifier: GPL-2.0+ */2/*3 * Serial core related functions, serial port device drivers do not need this.4 *5 * Copyright (C) 2023 Texas Instruments Incorporated - https://www.ti.com/6 * Author: Tony Lindgren <tony@atomide.com>7 */8 9#define to_serial_base_ctrl_device(d) container_of((d), struct serial_ctrl_device, dev)10#define to_serial_base_port_device(d) container_of((d), struct serial_port_device, dev)11 12struct uart_driver;13struct uart_port;14struct device_driver;15struct device;16 17struct serial_ctrl_device {18 struct device dev;19 struct ida port_ida;20};21 22struct serial_port_device {23 struct device dev;24 struct uart_port *port;25 unsigned int tx_enabled:1;26};27 28int serial_base_ctrl_init(void);29void serial_base_ctrl_exit(void);30 31int serial_base_port_init(void);32void serial_base_port_exit(void);33 34void serial_base_port_startup(struct uart_port *port);35void serial_base_port_shutdown(struct uart_port *port);36 37int serial_base_driver_register(struct device_driver *driver);38void serial_base_driver_unregister(struct device_driver *driver);39 40struct serial_ctrl_device *serial_base_ctrl_add(struct uart_port *port,41 struct device *parent);42struct serial_port_device *serial_base_port_add(struct uart_port *port,43 struct serial_ctrl_device *parent);44void serial_base_ctrl_device_remove(struct serial_ctrl_device *ctrl_dev);45void serial_base_port_device_remove(struct serial_port_device *port_dev);46 47int serial_ctrl_register_port(struct uart_driver *drv, struct uart_port *port);48void serial_ctrl_unregister_port(struct uart_driver *drv, struct uart_port *port);49 50int serial_core_register_port(struct uart_driver *drv, struct uart_port *port);51void serial_core_unregister_port(struct uart_driver *drv, struct uart_port *port);52 53#ifdef CONFIG_SERIAL_CORE_CONSOLE54 55int serial_base_match_and_update_preferred_console(struct uart_driver *drv,56 struct uart_port *port);57 58#else59 60static inline61int serial_base_match_and_update_preferred_console(struct uart_driver *drv,62 struct uart_port *port)63{64 return 0;65}66 67#endif68