drivers/auxdisplay/img-ascii-lcd.c

Source file repositories/reference/linux-study-clean/drivers/auxdisplay/img-ascii-lcd.c

File Facts

System
Linux kernel
Corpus path
drivers/auxdisplay/img-ascii-lcd.c
Extension
.c
Size
6936 bytes
Lines
300
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct img_ascii_lcd_config {
	unsigned int num_chars;
	bool external_regmap;
	const struct linedisp_ops ops;
};

/**
 * struct img_ascii_lcd_ctx - Private data structure
 * @linedisp: line display structure
 * @base: the base address of the LCD registers
 * @regmap: the regmap through which LCD registers are accessed
 * @offset: the offset within regmap to the start of the LCD registers
 */
struct img_ascii_lcd_ctx {
	struct linedisp linedisp;
	union {
		void __iomem *base;
		struct regmap *regmap;
	};
	u32 offset;
};

/*
 * MIPS Boston development board
 */

static void boston_update(struct linedisp *linedisp)
{
	struct img_ascii_lcd_ctx *ctx =
		container_of(linedisp, struct img_ascii_lcd_ctx, linedisp);
	ulong val;

#if BITS_PER_LONG == 64
	val = *((u64 *)&linedisp->buf[0]);
	__raw_writeq(val, ctx->base);
#elif BITS_PER_LONG == 32
	val = *((u32 *)&linedisp->buf[0]);
	__raw_writel(val, ctx->base);
	val = *((u32 *)&linedisp->buf[4]);
	__raw_writel(val, ctx->base + 4);
#else
# error Not 32 or 64 bit
#endif
}

static const struct img_ascii_lcd_config boston_config = {
	.num_chars = 8,
	.ops = {
		.update = boston_update,
	},
};

/*
 * MIPS Malta development board
 */

static void malta_update(struct linedisp *linedisp)
{
	struct img_ascii_lcd_ctx *ctx =
		container_of(linedisp, struct img_ascii_lcd_ctx, linedisp);
	unsigned int i;
	int err = 0;

	for (i = 0; i < linedisp->num_chars; i++) {
		err = regmap_write(ctx->regmap,
				   ctx->offset + (i * 8), linedisp->buf[i]);
		if (err)
			break;
	}

	if (unlikely(err))
		pr_err_ratelimited("Failed to update LCD display: %d\n", err);
}

static const struct img_ascii_lcd_config malta_config = {
	.num_chars = 8,
	.external_regmap = true,
	.ops = {
		.update = malta_update,
	},
};

/*
 * MIPS SEAD3 development board
 */

enum {
	SEAD3_REG_LCD_CTRL		= 0x00,
#define SEAD3_REG_LCD_CTRL_SETDRAM	BIT(7)
	SEAD3_REG_LCD_DATA		= 0x08,

Annotation

Implementation Notes