drivers/macintosh/ans-lcd.c

Source file repositories/reference/linux-study-clean/drivers/macintosh/ans-lcd.c

File Facts

System
Linux kernel
Corpus path
drivers/macintosh/ans-lcd.c
Extension
.c
Size
4108 bytes
Lines
206
Domain
Driver Families
Bucket
drivers/macintosh
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern 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

const struct file_operations anslcd_fops = {
	.write		= anslcd_write,
	.unlocked_ioctl	= anslcd_ioctl,
	.open		= anslcd_open,
	.llseek		= default_llseek,
};

static struct miscdevice anslcd_dev = {
	LCD_MINOR,
	"anslcd",
	&anslcd_fops
};

static const char anslcd_logo[] __initconst =
				"********************"  /* Line #1 */
				"*      LINUX!      *"  /* Line #3 */
				"*    Welcome to    *"  /* Line #2 */
				"********************"; /* Line #4 */

static int __init
anslcd_init(void)
{
	int a;
	int retval;
	struct device_node* node;

	node = of_find_node_by_name(NULL, "lcd");
	if (!node || !of_node_name_eq(node->parent, "gc")) {
		of_node_put(node);
		return -ENODEV;
	}
	of_node_put(node);

	anslcd_ptr = ioremap(ANSLCD_ADDR, 0x20);
	
	retval = misc_register(&anslcd_dev);
	if(retval < 0){
		printk(KERN_INFO "LCD: misc_register failed\n");
		iounmap(anslcd_ptr);
		return retval;
	}

#ifdef DEBUG
	printk(KERN_DEBUG "LCD: init\n");
#endif

	mutex_lock(&anslcd_mutex);
	anslcd_write_byte_ctrl ( 0x38 );
	anslcd_write_byte_ctrl ( 0x0c );
	anslcd_write_byte_ctrl ( 0x06 );
	anslcd_write_byte_ctrl ( 0x01 );
	anslcd_write_byte_ctrl ( 0x02 );
	for(a=0;a<80;a++) {
		anslcd_write_byte_data(anslcd_logo[a]);
	}
	mutex_unlock(&anslcd_mutex);
	return 0;
}

static void __exit
anslcd_exit(void)
{
	misc_deregister(&anslcd_dev);
	iounmap(anslcd_ptr);
}

module_init(anslcd_init);
module_exit(anslcd_exit);
MODULE_LICENSE("GPL v2");

Annotation

Implementation Notes