#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
#include <linux/module.h>
#include <linux/usb.h>
#include <linux/usb/serial.h>
#include <linux/gpio/driver.h>
#include <linux/bitops.h>
#include <linux/mutex.h>
#define DRIVER_DESC …
static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *);
static void cp210x_close(struct usb_serial_port *);
static void cp210x_change_speed(struct tty_struct *, struct usb_serial_port *,
const struct ktermios *);
static void cp210x_set_termios(struct tty_struct *, struct usb_serial_port *,
const struct ktermios *);
static bool cp210x_tx_empty(struct usb_serial_port *port);
static int cp210x_tiocmget(struct tty_struct *);
static int cp210x_tiocmset(struct tty_struct *, unsigned int, unsigned int);
static int cp210x_tiocmset_port(struct usb_serial_port *port,
unsigned int, unsigned int);
static int cp210x_break_ctl(struct tty_struct *, int);
static int cp210x_attach(struct usb_serial *);
static void cp210x_disconnect(struct usb_serial *);
static void cp210x_release(struct usb_serial *);
static int cp210x_port_probe(struct usb_serial_port *);
static void cp210x_port_remove(struct usb_serial_port *);
static void cp210x_dtr_rts(struct usb_serial_port *port, int on);
static void cp210x_process_read_urb(struct urb *urb);
static void cp210x_enable_event_mode(struct usb_serial_port *port);
static void cp210x_disable_event_mode(struct usb_serial_port *port);
static const struct usb_device_id id_table[] = …;
MODULE_DEVICE_TABLE(usb, id_table);
struct cp210x_serial_private { … };
enum cp210x_event_state { … };
struct cp210x_port_private { … };
static struct usb_serial_driver cp210x_device = …;
static struct usb_serial_driver * const serial_drivers[] = …;
#define REQTYPE_HOST_TO_INTERFACE …
#define REQTYPE_INTERFACE_TO_HOST …
#define REQTYPE_HOST_TO_DEVICE …
#define REQTYPE_DEVICE_TO_HOST …
#define CP210X_IFC_ENABLE …
#define CP210X_SET_BAUDDIV …
#define CP210X_GET_BAUDDIV …
#define CP210X_SET_LINE_CTL …
#define CP210X_GET_LINE_CTL …
#define CP210X_SET_BREAK …
#define CP210X_IMM_CHAR …
#define CP210X_SET_MHS …
#define CP210X_GET_MDMSTS …
#define CP210X_SET_XON …
#define CP210X_SET_XOFF …
#define CP210X_SET_EVENTMASK …
#define CP210X_GET_EVENTMASK …
#define CP210X_SET_CHAR …
#define CP210X_GET_CHARS …
#define CP210X_GET_PROPS …
#define CP210X_GET_COMM_STATUS …
#define CP210X_RESET …
#define CP210X_PURGE …
#define CP210X_SET_FLOW …
#define CP210X_GET_FLOW …
#define CP210X_EMBED_EVENTS …
#define CP210X_GET_EVENTSTATE …
#define CP210X_SET_CHARS …
#define CP210X_GET_BAUDRATE …
#define CP210X_SET_BAUDRATE …
#define CP210X_VENDOR_SPECIFIC …
#define UART_ENABLE …
#define UART_DISABLE …
#define BAUD_RATE_GEN_FREQ …
#define BITS_DATA_MASK …
#define BITS_DATA_5 …
#define BITS_DATA_6 …
#define BITS_DATA_7 …
#define BITS_DATA_8 …
#define BITS_DATA_9 …
#define BITS_PARITY_MASK …
#define BITS_PARITY_NONE …
#define BITS_PARITY_ODD …
#define BITS_PARITY_EVEN …
#define BITS_PARITY_MARK …
#define BITS_PARITY_SPACE …
#define BITS_STOP_MASK …
#define BITS_STOP_1 …
#define BITS_STOP_1_5 …
#define BITS_STOP_2 …
#define BREAK_ON …
#define BREAK_OFF …
#define CONTROL_DTR …
#define CONTROL_RTS …
#define CONTROL_CTS …
#define CONTROL_DSR …
#define CONTROL_RING …
#define CONTROL_DCD …
#define CONTROL_WRITE_DTR …
#define CONTROL_WRITE_RTS …
struct cp210x_special_chars { … };
#define CP210X_GET_FW_VER …
#define CP210X_READ_2NCONFIG …
#define CP210X_GET_FW_VER_2N …
#define CP210X_READ_LATCH …
#define CP210X_GET_PARTNUM …
#define CP210X_GET_PORTCONFIG …
#define CP210X_GET_DEVICEMODE …
#define CP210X_WRITE_LATCH …
#define CP210X_PARTNUM_CP2101 …
#define CP210X_PARTNUM_CP2102 …
#define CP210X_PARTNUM_CP2103 …
#define CP210X_PARTNUM_CP2104 …
#define CP210X_PARTNUM_CP2105 …
#define CP210X_PARTNUM_CP2108 …
#define CP210X_PARTNUM_CP2102N_QFN28 …
#define CP210X_PARTNUM_CP2102N_QFN24 …
#define CP210X_PARTNUM_CP2102N_QFN20 …
#define CP210X_PARTNUM_UNKNOWN …
struct cp210x_comm_status { … } __packed;
#define PURGE_ALL …
#define CP210X_ESCCHAR …
#define CP210X_LSR_OVERRUN …
#define CP210X_LSR_PARITY …
#define CP210X_LSR_FRAME …
#define CP210X_LSR_BREAK …
struct cp210x_flow_ctl { … };
#define CP210X_SERIAL_DTR_MASK …
#define CP210X_SERIAL_DTR_INACTIVE …
#define CP210X_SERIAL_DTR_ACTIVE …
#define CP210X_SERIAL_DTR_FLOW_CTL …
#define CP210X_SERIAL_CTS_HANDSHAKE …
#define CP210X_SERIAL_DSR_HANDSHAKE …
#define CP210X_SERIAL_DCD_HANDSHAKE …
#define CP210X_SERIAL_DSR_SENSITIVITY …
#define CP210X_SERIAL_AUTO_TRANSMIT …
#define CP210X_SERIAL_AUTO_RECEIVE …
#define CP210X_SERIAL_ERROR_CHAR …
#define CP210X_SERIAL_NULL_STRIPPING …
#define CP210X_SERIAL_BREAK_CHAR …
#define CP210X_SERIAL_RTS_MASK …
#define CP210X_SERIAL_RTS_INACTIVE …
#define CP210X_SERIAL_RTS_ACTIVE …
#define CP210X_SERIAL_RTS_FLOW_CTL …
#define CP210X_SERIAL_XOFF_CONTINUE …
struct cp210x_pin_mode { … };
#define CP210X_PIN_MODE_MODEM …
#define CP210X_PIN_MODE_GPIO …
struct cp210x_dual_port_config { … } __packed;
struct cp210x_single_port_config { … } __packed;
#define CP210X_SCI_GPIO_MODE_OFFSET …
#define CP210X_SCI_GPIO_MODE_MASK …
#define CP210X_ECI_GPIO_MODE_OFFSET …
#define CP210X_ECI_GPIO_MODE_MASK …
#define CP210X_GPIO_MODE_OFFSET …
#define CP210X_GPIO_MODE_MASK …
#define CP2105_GPIO0_TXLED_MODE …
#define CP2105_GPIO1_RXLED_MODE …
#define CP2105_GPIO1_RS485_MODE …
#define CP2104_GPIO0_TXLED_MODE …
#define CP2104_GPIO1_RXLED_MODE …
#define CP2104_GPIO2_RS485_MODE …
struct cp210x_quad_port_state { … };
struct cp210x_quad_port_config { … } __packed;
#define CP2108_EF_IFC_GPIO_TXLED …
#define CP2108_EF_IFC_GPIO_RXLED …
#define CP2108_EF_IFC_GPIO_RS485 …
#define CP2108_EF_IFC_GPIO_RS485_LOGIC …
#define CP2108_EF_IFC_GPIO_CLOCK …
#define CP2108_EF_IFC_DYNAMIC_SUSPEND …
#define CP210X_2NCONFIG_CONFIG_VERSION_IDX …
#define CP210X_2NCONFIG_GPIO_MODE_IDX …
#define CP210X_2NCONFIG_GPIO_RSTLATCH_IDX …
#define CP210X_2NCONFIG_GPIO_CONTROL_IDX …
#define CP2102N_QFN20_GPIO2_TXLED_MODE …
#define CP2102N_QFN20_GPIO3_RXLED_MODE …
#define CP2102N_QFN20_GPIO1_RS485_MODE …
#define CP2102N_QFN20_GPIO0_CLK_MODE …
struct cp210x_gpio_write { … };
struct cp210x_gpio_write16 { … };
static u8 cp210x_interface_num(struct usb_serial *serial)
{ … }
static int cp210x_read_reg_block(struct usb_serial_port *port, u8 req,
void *buf, int bufsize)
{ … }
static int cp210x_read_u8_reg(struct usb_serial_port *port, u8 req, u8 *val)
{ … }
static int cp210x_read_vendor_block(struct usb_serial *serial, u8 type, u16 val,
void *buf, int bufsize)
{ … }
static int cp210x_write_u16_reg(struct usb_serial_port *port, u8 req, u16 val)
{ … }
static int cp210x_write_reg_block(struct usb_serial_port *port, u8 req,
void *buf, int bufsize)
{ … }
static int cp210x_write_u32_reg(struct usb_serial_port *port, u8 req, u32 val)
{ … }
#ifdef CONFIG_GPIOLIB
static int cp210x_write_vendor_block(struct usb_serial *serial, u8 type,
u16 val, void *buf, int bufsize)
{ … }
#endif
static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *port)
{ … }
static void cp210x_close(struct usb_serial_port *port)
{ … }
static void cp210x_process_lsr(struct usb_serial_port *port, unsigned char lsr, char *flag)
{ … }
static bool cp210x_process_char(struct usb_serial_port *port, unsigned char *ch, char *flag)
{ … }
static void cp210x_process_read_urb(struct urb *urb)
{ … }
static int cp210x_get_tx_queue_byte_count(struct usb_serial_port *port,
u32 *count)
{ … }
static bool cp210x_tx_empty(struct usb_serial_port *port)
{ … }
struct cp210x_rate { … };
static const struct cp210x_rate cp210x_an205_table1[] = …;
static speed_t cp210x_get_an205_rate(speed_t baud)
{ … }
static speed_t cp210x_get_actual_rate(speed_t baud)
{ … }
static void cp210x_change_speed(struct tty_struct *tty,
struct usb_serial_port *port,
const struct ktermios *old_termios)
{ … }
static void cp210x_enable_event_mode(struct usb_serial_port *port)
{ … }
static void cp210x_disable_event_mode(struct usb_serial_port *port)
{ … }
static bool cp210x_termios_change(const struct ktermios *a, const struct ktermios *b)
{ … }
static void cp210x_set_flow_control(struct tty_struct *tty,
struct usb_serial_port *port,
const struct ktermios *old_termios)
{ … }
static void cp210x_set_termios(struct tty_struct *tty,
struct usb_serial_port *port,
const struct ktermios *old_termios)
{ … }
static int cp210x_tiocmset(struct tty_struct *tty,
unsigned int set, unsigned int clear)
{ … }
static int cp210x_tiocmset_port(struct usb_serial_port *port,
unsigned int set, unsigned int clear)
{ … }
static void cp210x_dtr_rts(struct usb_serial_port *port, int on)
{ … }
static int cp210x_tiocmget(struct tty_struct *tty)
{ … }
static int cp210x_break_ctl(struct tty_struct *tty, int break_state)
{ … }
#ifdef CONFIG_GPIOLIB
static int cp210x_gpio_get(struct gpio_chip *gc, unsigned int gpio)
{ … }
static void cp210x_gpio_set(struct gpio_chip *gc, unsigned int gpio, int value)
{ … }
static int cp210x_gpio_direction_get(struct gpio_chip *gc, unsigned int gpio)
{ … }
static int cp210x_gpio_direction_input(struct gpio_chip *gc, unsigned int gpio)
{ … }
static int cp210x_gpio_direction_output(struct gpio_chip *gc, unsigned int gpio,
int value)
{ … }
static int cp210x_gpio_set_config(struct gpio_chip *gc, unsigned int gpio,
unsigned long config)
{ … }
static int cp210x_gpio_init_valid_mask(struct gpio_chip *gc,
unsigned long *valid_mask, unsigned int ngpios)
{ … }
static int cp2105_gpioconf_init(struct usb_serial *serial)
{ … }
static int cp2104_gpioconf_init(struct usb_serial *serial)
{ … }
static int cp2108_gpio_init(struct usb_serial *serial)
{ … }
static int cp2102n_gpioconf_init(struct usb_serial *serial)
{ … }
static int cp210x_gpio_init(struct usb_serial *serial)
{ … }
static void cp210x_gpio_remove(struct usb_serial *serial)
{ … }
#else
static int cp210x_gpio_init(struct usb_serial *serial)
{
return 0;
}
static void cp210x_gpio_remove(struct usb_serial *serial)
{
}
#endif
static int cp210x_port_probe(struct usb_serial_port *port)
{ … }
static void cp210x_port_remove(struct usb_serial_port *port)
{ … }
static void cp210x_init_max_speed(struct usb_serial *serial)
{ … }
static void cp2102_determine_quirks(struct usb_serial *serial)
{ … }
static int cp210x_get_fw_version(struct usb_serial *serial, u16 value)
{ … }
static void cp210x_determine_type(struct usb_serial *serial)
{ … }
static int cp210x_attach(struct usb_serial *serial)
{ … }
static void cp210x_disconnect(struct usb_serial *serial)
{ … }
static void cp210x_release(struct usb_serial *serial)
{ … }
module_usb_serial_driver(…);
MODULE_DESCRIPTION(…);
MODULE_LICENSE(…) …;