drivers/tty/serial/8250/8250_keba.c
Source file repositories/reference/linux-study-clean/drivers/tty/serial/8250/8250_keba.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tty/serial/8250/8250_keba.c- Extension
.c- Size
- 7841 bytes
- Lines
- 292
- Domain
- Driver Families
- Bucket
- drivers/tty
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/auxiliary_bus.hlinux/bits.hlinux/container_of.hlinux/dev_printk.hlinux/device/devres.hlinux/err.hlinux/io.hlinux/misc/keba.hlinux/mod_devicetable.hlinux/module.hlinux/serial_core.hlinux/spinlock.hlinux/types.h8250.h
Detected Declarations
struct kuartenum kuart_modefunction kuart_set_phy_modefunction kuart_enhanced_modefunction kuart_dtr_line_configfunction kuart_rs485_configfunction kuart_probefunction kuart_remove
Annotated Snippet
struct kuart {
struct keba_uart_auxdev *auxdev;
void __iomem *base;
unsigned int line;
unsigned int flags;
u8 capability;
enum kuart_mode mode;
};
static void kuart_set_phy_mode(struct kuart *kuart, enum kuart_mode mode)
{
iowrite8(mode, kuart->base + KUART_CONTROL);
}
static void kuart_enhanced_mode(struct uart_8250_port *up, bool enable)
{
u8 lcr, efr;
/* backup LCR register */
lcr = serial_in(up, UART_LCR);
/* enable 650 compatible register set (EFR, ...) */
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
/* enable/disable enhanced mode with indexed control registers */
efr = serial_in(up, UART_EFR);
if (enable)
efr |= UART_EFR_ECB;
else
efr &= ~UART_EFR_ECB;
serial_out(up, UART_EFR, efr);
/* disable 650 compatible register set, restore LCR */
serial_out(up, UART_LCR, lcr);
}
static void kuart_dtr_line_config(struct uart_8250_port *up, u8 dtrlc)
{
u8 acr;
/* set index register to 0 to access ACR register */
serial_out(up, KUART_EMODE_ICR_OFFSET, UART_ACR);
/* set value register to 0x10 writing DTR mode (1,0) */
acr = serial_in(up, KUART_EMODE_ICR_VALUE);
acr &= ~UART_ACR_DTRLC_MASK;
acr |= dtrlc;
serial_out(up, KUART_EMODE_ICR_VALUE, acr);
}
static int kuart_rs485_config(struct uart_port *port, struct ktermios *termios,
struct serial_rs485 *rs485)
{
struct uart_8250_port *up = up_to_u8250p(port);
struct kuart *kuart = port->private_data;
enum kuart_mode mode;
u8 dtrlc;
if (rs485->flags & SER_RS485_ENABLED) {
if (rs485->flags & SER_RS485_MODE_RS422)
mode = KUART_MODE_RS422;
else
mode = KUART_MODE_RS485;
} else {
mode = KUART_MODE_RS232;
}
if (mode == kuart->mode)
return 0;
if (kuart->flags & KUART_USE_CAPABILITY) {
/* deactivate physical interface, break before make */
kuart_set_phy_mode(kuart, KUART_MODE_NONE);
}
if (mode == KUART_MODE_RS485) {
/*
* Set DTR line configuration of 95x UART to DTR mode (1,0).
* In this mode the DTR pin drives the active-low enable pin of
* an external RS485 buffer. The DTR pin will be forced low
* whenever the transmitter is not empty, otherwise DTR pin is
* high.
*/
dtrlc = UART_ACR_DTRLC_ENABLE_LOW;
} else {
/*
* Set DTR line configuration of 95x UART to DTR mode (0,0).
* In this mode the DTR pin is compatible with 16C450, 16C550,
* 16C650 and 16c670 (i.e. normal).
Annotation
- Immediate include surface: `linux/auxiliary_bus.h`, `linux/bits.h`, `linux/container_of.h`, `linux/dev_printk.h`, `linux/device/devres.h`, `linux/err.h`, `linux/io.h`, `linux/misc/keba.h`.
- Detected declarations: `struct kuart`, `enum kuart_mode`, `function kuart_set_phy_mode`, `function kuart_enhanced_mode`, `function kuart_dtr_line_config`, `function kuart_rs485_config`, `function kuart_probe`, `function kuart_remove`.
- Atlas domain: Driver Families / drivers/tty.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.