#ifndef _LINUX_SERDEV_H
#define _LINUX_SERDEV_H
#include <linux/types.h>
#include <linux/device.h>
#include <linux/iopoll.h>
#include <linux/uaccess.h>
#include <linux/termios.h>
#include <linux/delay.h>
struct serdev_controller;
struct serdev_device;
struct serdev_device_ops { … };
struct serdev_device { … };
static inline struct serdev_device *to_serdev_device(struct device *d)
{ … }
struct serdev_device_driver { … };
static inline struct serdev_device_driver *to_serdev_device_driver(struct device_driver *d)
{ … }
enum serdev_parity { … };
struct serdev_controller_ops { … };
struct serdev_controller { … };
static inline struct serdev_controller *to_serdev_controller(struct device *d)
{ … }
static inline void *serdev_device_get_drvdata(const struct serdev_device *serdev)
{ … }
static inline void serdev_device_set_drvdata(struct serdev_device *serdev, void *data)
{ … }
static inline void serdev_device_put(struct serdev_device *serdev)
{ … }
static inline void serdev_device_set_client_ops(struct serdev_device *serdev,
const struct serdev_device_ops *ops)
{ … }
static inline
void *serdev_controller_get_drvdata(const struct serdev_controller *ctrl)
{ … }
static inline void serdev_controller_set_drvdata(struct serdev_controller *ctrl,
void *data)
{ … }
static inline void serdev_controller_put(struct serdev_controller *ctrl)
{ … }
struct serdev_device *serdev_device_alloc(struct serdev_controller *);
int serdev_device_add(struct serdev_device *);
void serdev_device_remove(struct serdev_device *);
struct serdev_controller *serdev_controller_alloc(struct device *host,
struct device *parent,
size_t size);
int serdev_controller_add(struct serdev_controller *);
void serdev_controller_remove(struct serdev_controller *);
static inline void serdev_controller_write_wakeup(struct serdev_controller *ctrl)
{ … }
static inline size_t serdev_controller_receive_buf(struct serdev_controller *ctrl,
const u8 *data,
size_t count)
{ … }
#if IS_ENABLED(CONFIG_SERIAL_DEV_BUS)
int serdev_device_open(struct serdev_device *);
void serdev_device_close(struct serdev_device *);
int devm_serdev_device_open(struct device *, struct serdev_device *);
unsigned int serdev_device_set_baudrate(struct serdev_device *, unsigned int);
void serdev_device_set_flow_control(struct serdev_device *, bool);
int serdev_device_write_buf(struct serdev_device *, const u8 *, size_t);
void serdev_device_wait_until_sent(struct serdev_device *, long);
int serdev_device_get_tiocm(struct serdev_device *);
int serdev_device_set_tiocm(struct serdev_device *, int, int);
int serdev_device_break_ctl(struct serdev_device *serdev, int break_state);
void serdev_device_write_wakeup(struct serdev_device *);
ssize_t serdev_device_write(struct serdev_device *, const u8 *, size_t, long);
void serdev_device_write_flush(struct serdev_device *);
int serdev_device_write_room(struct serdev_device *);
int __serdev_device_driver_register(struct serdev_device_driver *, struct module *);
#define serdev_device_driver_register(sdrv) …
static inline void serdev_device_driver_unregister(struct serdev_device_driver *sdrv)
{ … }
#define module_serdev_device_driver(__serdev_device_driver) …
#else
static inline int serdev_device_open(struct serdev_device *sdev)
{
return -ENODEV;
}
static inline void serdev_device_close(struct serdev_device *sdev) {}
static inline unsigned int serdev_device_set_baudrate(struct serdev_device *sdev, unsigned int baudrate)
{
return 0;
}
static inline void serdev_device_set_flow_control(struct serdev_device *sdev, bool enable) {}
static inline int serdev_device_write_buf(struct serdev_device *serdev,
const u8 *buf,
size_t count)
{
return -ENODEV;
}
static inline void serdev_device_wait_until_sent(struct serdev_device *sdev, long timeout) {}
static inline int serdev_device_get_tiocm(struct serdev_device *serdev)
{
return -EOPNOTSUPP;
}
static inline int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear)
{
return -EOPNOTSUPP;
}
static inline int serdev_device_break_ctl(struct serdev_device *serdev, int break_state)
{
return -EOPNOTSUPP;
}
static inline ssize_t serdev_device_write(struct serdev_device *sdev,
const u8 *buf, size_t count,
unsigned long timeout)
{
return -ENODEV;
}
static inline void serdev_device_write_flush(struct serdev_device *sdev) {}
static inline int serdev_device_write_room(struct serdev_device *sdev)
{
return 0;
}
#define serdev_device_driver_register …
#define serdev_device_driver_unregister …
#endif
static inline bool serdev_device_get_cts(struct serdev_device *serdev)
{ … }
static inline int serdev_device_wait_for_cts(struct serdev_device *serdev, bool state, int timeout_ms)
{ … }
static inline int serdev_device_set_rts(struct serdev_device *serdev, bool enable)
{ … }
int serdev_device_set_parity(struct serdev_device *serdev,
enum serdev_parity parity);
struct tty_port;
struct tty_driver;
#ifdef CONFIG_SERIAL_DEV_CTRL_TTYPORT
struct device *serdev_tty_port_register(struct tty_port *port,
struct device *host,
struct device *parent,
struct tty_driver *drv, int idx);
int serdev_tty_port_unregister(struct tty_port *port);
#else
static inline struct device *serdev_tty_port_register(struct tty_port *port,
struct device *host,
struct device *parent,
struct tty_driver *drv, int idx)
{
return ERR_PTR(-ENODEV);
}
static inline int serdev_tty_port_unregister(struct tty_port *port)
{
return -ENODEV;
}
#endif
struct acpi_resource;
struct acpi_resource_uart_serialbus;
#ifdef CONFIG_ACPI
bool serdev_acpi_get_uart_resource(struct acpi_resource *ares,
struct acpi_resource_uart_serialbus **uart);
#else
static inline bool serdev_acpi_get_uart_resource(struct acpi_resource *ares,
struct acpi_resource_uart_serialbus **uart)
{
return false;
}
#endif
#endif