drivers/usb/serial/xr_serial.c
Source file repositories/reference/linux-study-clean/drivers/usb/serial/xr_serial.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/serial/xr_serial.c- Extension
.c- Size
- 26689 bytes
- Lines
- 1111
- Domain
- Driver Families
- Bucket
- drivers/usb
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/module.hlinux/slab.hlinux/tty.hlinux/usb.hlinux/usb/cdc.hlinux/usb/serial.h
Detected Declarations
struct xr_txrx_clk_maskstruct xr_typestruct xr_dataenum xr_type_idfunction xr_set_regfunction xr_get_regfunction xr_set_reg_uartfunction xr_get_reg_uartfunction xr_set_reg_umfunction __xr_uart_enablefunction __xr_uart_disablefunction xr21v141x_uart_enablefunction xr21v141x_uart_disablefunction xr_uart_enablefunction xr_uart_disablefunction xr21v141x_fifo_resetfunction xr_fifo_resetfunction xr_tiocmgetfunction xr_tiocmset_portfunction xr_tiocmsetfunction xr_dtr_rtsfunction xr_break_ctlfunction xr21v141x_set_baudratefunction xr_set_flow_modefunction xr21v141x_set_line_settingsfunction xr_cdc_set_line_codingfunction xr_sanitize_serial_rs485function xr_get_rs485_configfunction xr_set_rs485_configfunction xr_ioctlfunction xr_set_termiosfunction xr_openfunction xr_closefunction xr_probefunction xr_gpio_initfunction xr_port_probefunction xr_port_remove
Annotated Snippet
struct xr_txrx_clk_mask {
u16 tx;
u16 rx0;
u16 rx1;
};
#define XR_INT_OSC_HZ 48000000U
#define XR21V141X_MIN_SPEED 46U
#define XR21V141X_MAX_SPEED XR_INT_OSC_HZ
/* XR21V141X register blocks */
#define XR21V141X_UART_REG_BLOCK 0
#define XR21V141X_UM_REG_BLOCK 4
#define XR21V141X_UART_CUSTOM_BLOCK 0x66
/* XR21V141X UART registers */
#define XR21V141X_CLOCK_DIVISOR_0 0x04
#define XR21V141X_CLOCK_DIVISOR_1 0x05
#define XR21V141X_CLOCK_DIVISOR_2 0x06
#define XR21V141X_TX_CLOCK_MASK_0 0x07
#define XR21V141X_TX_CLOCK_MASK_1 0x08
#define XR21V141X_RX_CLOCK_MASK_0 0x09
#define XR21V141X_RX_CLOCK_MASK_1 0x0a
#define XR21V141X_REG_FORMAT 0x0b
/* XR21V141X UART Manager registers */
#define XR21V141X_UM_FIFO_ENABLE_REG 0x10
#define XR21V141X_UM_ENABLE_TX_FIFO 0x01
#define XR21V141X_UM_ENABLE_RX_FIFO 0x02
#define XR21V141X_UM_RX_FIFO_RESET 0x18
#define XR21V141X_UM_TX_FIFO_RESET 0x1c
#define XR_UART_ENABLE_TX 0x1
#define XR_UART_ENABLE_RX 0x2
#define XR_GPIO_RI BIT(0)
#define XR_GPIO_CD BIT(1)
#define XR_GPIO_DSR BIT(2)
#define XR_GPIO_DTR BIT(3)
#define XR_GPIO_CTS BIT(4)
#define XR_GPIO_RTS BIT(5)
#define XR_GPIO_CLK BIT(6)
#define XR_GPIO_XEN BIT(7)
#define XR_GPIO_TXT BIT(8)
#define XR_GPIO_RXT BIT(9)
#define XR_UART_DATA_MASK GENMASK(3, 0)
#define XR_UART_DATA_7 0x7
#define XR_UART_DATA_8 0x8
#define XR_UART_PARITY_MASK GENMASK(6, 4)
#define XR_UART_PARITY_SHIFT 4
#define XR_UART_PARITY_NONE (0x0 << XR_UART_PARITY_SHIFT)
#define XR_UART_PARITY_ODD (0x1 << XR_UART_PARITY_SHIFT)
#define XR_UART_PARITY_EVEN (0x2 << XR_UART_PARITY_SHIFT)
#define XR_UART_PARITY_MARK (0x3 << XR_UART_PARITY_SHIFT)
#define XR_UART_PARITY_SPACE (0x4 << XR_UART_PARITY_SHIFT)
#define XR_UART_STOP_MASK BIT(7)
#define XR_UART_STOP_SHIFT 7
#define XR_UART_STOP_1 (0x0 << XR_UART_STOP_SHIFT)
#define XR_UART_STOP_2 (0x1 << XR_UART_STOP_SHIFT)
#define XR_UART_FLOW_MODE_NONE 0x0
#define XR_UART_FLOW_MODE_HW 0x1
#define XR_UART_FLOW_MODE_SW 0x2
#define XR_GPIO_MODE_SEL_MASK GENMASK(2, 0)
#define XR_GPIO_MODE_SEL_RTS_CTS 0x1
#define XR_GPIO_MODE_SEL_DTR_DSR 0x2
#define XR_GPIO_MODE_SEL_RS485 0x3
#define XR_GPIO_MODE_SEL_RS485_ADDR 0x4
#define XR_GPIO_MODE_RS485_TX_H 0x8
#define XR_GPIO_MODE_TX_TOGGLE 0x100
#define XR_GPIO_MODE_RX_TOGGLE 0x200
#define XR_FIFO_RESET 0x1
#define XR_CUSTOM_DRIVER_ACTIVE 0x1
static int xr21v141x_uart_enable(struct usb_serial_port *port);
static int xr21v141x_uart_disable(struct usb_serial_port *port);
static int xr21v141x_fifo_reset(struct usb_serial_port *port);
static void xr21v141x_set_line_settings(struct tty_struct *tty,
struct usb_serial_port *port,
const struct ktermios *old_termios);
struct xr_type {
int reg_width;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/slab.h`, `linux/tty.h`, `linux/usb.h`, `linux/usb/cdc.h`, `linux/usb/serial.h`.
- Detected declarations: `struct xr_txrx_clk_mask`, `struct xr_type`, `struct xr_data`, `enum xr_type_id`, `function xr_set_reg`, `function xr_get_reg`, `function xr_set_reg_uart`, `function xr_get_reg_uart`, `function xr_set_reg_um`, `function __xr_uart_enable`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.