drivers/tty/mips_ejtag_fdc.c
Source file repositories/reference/linux-study-clean/drivers/tty/mips_ejtag_fdc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tty/mips_ejtag_fdc.c- Extension
.c- Size
- 36016 bytes
- Lines
- 1272
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/atomic.hlinux/bitops.hlinux/completion.hlinux/console.hlinux/delay.hlinux/export.hlinux/init.hlinux/interrupt.hlinux/kernel.hlinux/kgdb.hlinux/kthread.hlinux/sched.hlinux/serial.hlinux/serial_core.hlinux/slab.hlinux/spinlock.hlinux/string.hlinux/timer.hlinux/tty.hlinux/tty_driver.hlinux/tty_flip.hlinux/uaccess.hasm/cdmm.hasm/irq.h
Detected Declarations
struct mips_ejtag_fdc_ttystruct mips_ejtag_fdc_tty_portstruct mips_ejtag_fdc_ttystruct fdc_wordstruct mips_ejtag_fdc_consolefunction mips_ejtag_fdc_writefunction mips_ejtag_fdc_readfunction sequencesfunction mips_ejtag_fdc_decodefunction mips_ejtag_fdc_console_writefunction mips_ejtag_fdc_console_initfunction mips_ejtag_fdc_put_chanfunction mips_ejtag_fdc_putfunction mips_ejtag_fdc_handlefunction mips_ejtag_fdc_isrfunction mips_ejtag_fdc_tty_timerfunction mips_ejtag_fdc_tty_port_activatefunction mips_ejtag_fdc_tty_port_shutdownfunction mips_ejtag_fdc_tty_installfunction mips_ejtag_fdc_tty_openfunction mips_ejtag_fdc_tty_closefunction mips_ejtag_fdc_tty_hangupfunction mips_ejtag_fdc_tty_writefunction mips_ejtag_fdc_tty_write_roomfunction mips_ejtag_fdc_tty_chars_in_bufferfunction get_c0_fdc_intfunction mips_ejtag_fdc_tty_probefunction mips_ejtag_fdc_tty_cpu_downfunction mips_ejtag_fdc_tty_cpu_upfunction mips_ejtag_fdc_init_consolefunction setup_early_fdc_consolefunction kgdbfdc_read_charfunction kgdbfdc_push_onefunction kgdbfdc_flushfunction kgdbfdc_write_charfunction kgdbfdc_init
Annotated Snippet
struct mips_ejtag_fdc_tty_port {
struct tty_port port;
struct mips_ejtag_fdc_tty *driver;
raw_spinlock_t rx_lock;
void *rx_buf;
spinlock_t xmit_lock;
unsigned int xmit_cnt;
unsigned int xmit_head;
unsigned int xmit_tail;
struct completion xmit_empty;
};
/**
* struct mips_ejtag_fdc_tty - Driver data for FDC as a whole.
* @dev: FDC device (for dev_*() logging).
* @driver: TTY driver.
* @cpu: CPU number for this FDC.
* @fdc_name: FDC name (not for base of channel names).
* @driver_name: Base of driver name.
* @ports: Per-channel data.
* @waitqueue: Wait queue for waiting for TX data, or for space in TX
* FIFO.
* @lock: Lock to protect FDCFG (interrupt enable).
* @thread: KThread for writing out data to FDC.
* @reg: FDC registers.
* @tx_fifo: TX FIFO size.
* @xmit_size: Size of each port's xmit buffer.
* @xmit_total: Total number of bytes (from all ports) to transmit.
* @xmit_next: Next port number to transmit from (round robin).
* @xmit_full: Indicates TX FIFO is full, we're waiting for space.
* @irq: IRQ number (negative if no IRQ).
* @removing: Indicates the device is being removed and @poll_timer
* should not be restarted.
* @poll_timer: Timer for polling for interrupt events when @irq < 0.
* @sysrq_pressed: Whether the magic sysrq key combination has been
* detected. See mips_ejtag_fdc_handle().
*/
struct mips_ejtag_fdc_tty {
struct device *dev;
struct tty_driver *driver;
unsigned int cpu;
char fdc_name[16];
char driver_name[16];
struct mips_ejtag_fdc_tty_port ports[NUM_TTY_CHANNELS];
wait_queue_head_t waitqueue;
raw_spinlock_t lock;
struct task_struct *thread;
void __iomem *reg;
u8 tx_fifo;
unsigned int xmit_size;
atomic_t xmit_total;
unsigned int xmit_next;
bool xmit_full;
int irq;
bool removing;
struct timer_list poll_timer;
#ifdef CONFIG_MAGIC_SYSRQ
bool sysrq_pressed;
#endif
};
/* Hardware access */
static inline void mips_ejtag_fdc_write(struct mips_ejtag_fdc_tty *priv,
unsigned int offs, unsigned int data)
{
__raw_writel(data, priv->reg + offs);
}
static inline unsigned int mips_ejtag_fdc_read(struct mips_ejtag_fdc_tty *priv,
unsigned int offs)
{
return __raw_readl(priv->reg + offs);
}
/* Encoding of byte stream in FDC words */
/**
* struct fdc_word - FDC word encoding some number of bytes of data.
* @word: Raw FDC word.
* @bytes: Number of bytes encoded by @word.
*/
struct fdc_word {
u32 word;
unsigned int bytes;
};
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/bitops.h`, `linux/completion.h`, `linux/console.h`, `linux/delay.h`, `linux/export.h`, `linux/init.h`, `linux/interrupt.h`.
- Detected declarations: `struct mips_ejtag_fdc_tty`, `struct mips_ejtag_fdc_tty_port`, `struct mips_ejtag_fdc_tty`, `struct fdc_word`, `struct mips_ejtag_fdc_console`, `function mips_ejtag_fdc_write`, `function mips_ejtag_fdc_read`, `function sequences`, `function mips_ejtag_fdc_decode`, `function mips_ejtag_fdc_console_write`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.