drivers/auxdisplay/arm-charlcd.c
Source file repositories/reference/linux-study-clean/drivers/auxdisplay/arm-charlcd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/auxdisplay/arm-charlcd.c- Extension
.c- Size
- 8319 bytes
- Lines
- 329
- Domain
- Driver Families
- Bucket
- drivers/auxdisplay
- 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 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/completion.hlinux/container_of.hlinux/delay.hlinux/err.hlinux/init.hlinux/interrupt.hlinux/iopoll.hlinux/mod_devicetable.hlinux/platform_device.hlinux/string.hlinux/types.hlinux/workqueue.hgenerated/utsrelease.h
Detected Declarations
struct charlcdfunction charlcd_interruptfunction charlcd_wait_complete_irqfunction charlcd_4bit_read_charfunction charlcd_4bit_read_bffunction charlcd_4bit_wait_busyfunction charlcd_4bit_commandfunction charlcd_4bit_charfunction charlcd_4bit_printfunction charlcd_4bit_initfunction charlcd_init_workfunction charlcd_probefunction charlcd_suspendfunction charlcd_resume
Annotated Snippet
struct charlcd {
struct device *dev;
void __iomem *virtbase;
int irq;
struct completion complete;
struct delayed_work init_work;
};
static irqreturn_t charlcd_interrupt(int irq, void *data)
{
struct charlcd *lcd = data;
u8 status;
status = readl(lcd->virtbase + CHAR_STAT) & 0x01;
/* Clear IRQ */
writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW);
if (status)
complete(&lcd->complete);
else
dev_info(lcd->dev, "Spurious IRQ (%02x)\n", status);
return IRQ_HANDLED;
}
static void charlcd_wait_complete_irq(struct charlcd *lcd)
{
int ret;
ret = wait_for_completion_interruptible_timeout(&lcd->complete,
CHARLCD_TIMEOUT);
/* Disable IRQ after completion */
writel(0x00, lcd->virtbase + CHAR_MASK);
if (ret < 0) {
dev_err(lcd->dev,
"wait_for_completion_interruptible_timeout() returned %d waiting for ready\n",
ret);
return;
}
if (ret == 0) {
dev_err(lcd->dev, "charlcd controller timed out waiting for ready\n");
return;
}
}
static u8 charlcd_4bit_read_char(struct charlcd *lcd)
{
u8 data;
u32 val;
/* If we can, use an IRQ to wait for the data, else poll */
if (lcd->irq >= 0)
charlcd_wait_complete_irq(lcd);
else {
udelay(100);
readl_poll_timeout_atomic(lcd->virtbase + CHAR_RAW, val,
val & CHAR_RAW_VALID, 100, 1000);
writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW);
}
msleep(1);
/* Read the 4 high bits of the data */
data = readl(lcd->virtbase + CHAR_RD) & 0xf0;
/*
* The second read for the low bits does not trigger an IRQ
* so in this case we have to poll for the 4 lower bits
*/
udelay(100);
readl_poll_timeout_atomic(lcd->virtbase + CHAR_RAW, val,
val & CHAR_RAW_VALID, 100, 1000);
writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW);
msleep(1);
/* Read the 4 low bits of the data */
data |= (readl(lcd->virtbase + CHAR_RD) >> 4) & 0x0f;
return data;
}
static bool charlcd_4bit_read_bf(struct charlcd *lcd)
{
if (lcd->irq >= 0) {
/*
* If we'll use IRQs to wait for the busyflag, clear any
* pending flag and enable IRQ
*/
writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW);
init_completion(&lcd->complete);
Annotation
- Immediate include surface: `linux/completion.h`, `linux/container_of.h`, `linux/delay.h`, `linux/err.h`, `linux/init.h`, `linux/interrupt.h`, `linux/iopoll.h`, `linux/mod_devicetable.h`.
- Detected declarations: `struct charlcd`, `function charlcd_interrupt`, `function charlcd_wait_complete_irq`, `function charlcd_4bit_read_char`, `function charlcd_4bit_read_bf`, `function charlcd_4bit_wait_busy`, `function charlcd_4bit_command`, `function charlcd_4bit_char`, `function charlcd_4bit_print`, `function charlcd_4bit_init`.
- Atlas domain: Driver Families / drivers/auxdisplay.
- Implementation status: source implementation candidate.
- 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.