Пример #1
0
static void __exit hil_exit(void)
{
	if (HIL_IRQ) {
		disable_irq(HIL_IRQ);
		free_irq(HIL_IRQ, hil_dev.dev_id);
	}

	/* Turn off interrupts */
	hil_do(HIL_INTOFF, NULL, 0);

	input_unregister_device(&hil_dev.dev);

#if defined(CONFIG_PARISC)
	unregister_parisc_driver(&hil_driver);
#else
	release_region(HILBASE+HIL_DATA, 2);
#endif
}
Пример #2
0
static int __init
hil_keyb_init(void)
{
	unsigned char c;
	unsigned int i, kbid;
	wait_queue_head_t hil_wait;

	if (hil_dev.dev.id.bustype) {
		return -ENODEV; /* already initialized */
	}
	
#if defined(CONFIG_HP300)
	if (!hwreg_present((void *)(HILBASE + HIL_DATA)))
		return -ENODEV;
	
	request_region(HILBASE+HIL_DATA, 2, "hil");
#endif
	
	request_irq(HIL_IRQ, hil_interrupt, 0, "hil", hil_dev.dev_id);

	/* Turn on interrupts */
	hil_do(HIL_INTON, NULL, 0);

	/* Look for keyboards */
	hil_dev.valid = 0;	/* clear any pending data */
	hil_do(HIL_READKBDSADR, NULL, 0);

	init_waitqueue_head(&hil_wait);
	wait_event_interruptible_timeout(hil_wait, hil_dev.valid, 3*HZ);
	if (!hil_dev.valid) {
		printk(KERN_WARNING "HIL: timed out, assuming no keyboard present.\n");
	}

	c = hil_dev.c; 
	hil_dev.valid = 0;
	if (c == 0) {
		kbid = -1;
		printk(KERN_WARNING "HIL: no keyboard present.\n");
	} else {
		kbid = ffz(~c);
		/* printk(KERN_INFO "HIL: keyboard found at id %d\n", kbid); */
	}

	/* set it to raw mode */
	c = 0;
	hil_do(HIL_WRITEKBDSADR, &c, 1);
	
	init_input_dev(&hil_dev.dev);

	for (i = 0; i < HIL_KEYCODES_SET1_TBLSIZE; i++)
		if (hphilkeyb_keycode[i] != KEY_RESERVED)
			set_bit(hphilkeyb_keycode[i], hil_dev.dev.keybit);

	hil_dev.dev.evbit[0]    = BIT(EV_KEY) | BIT(EV_REP);
	hil_dev.dev.ledbit[0]   = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL);
	hil_dev.dev.keycodemax  = HIL_KEYCODES_SET1_TBLSIZE;
        hil_dev.dev.keycodesize = sizeof(hphilkeyb_keycode[0]);
	hil_dev.dev.keycode     = hphilkeyb_keycode;
	hil_dev.dev.name 	= "HIL keyboard";
	hil_dev.dev.phys 	= "hpkbd/input0";

	hil_dev.dev.id.bustype	= BUS_HIL;
	hil_dev.dev.id.vendor	= PCI_VENDOR_ID_HP;
	hil_dev.dev.id.product	= 0x0001;
	hil_dev.dev.id.version	= 0x0010;

	input_register_device(&hil_dev.dev);
	printk(KERN_INFO "input: %s, ID %d at 0x%08lx (irq %d) found and attached\n",
		hil_dev.dev.name, kbid, HILBASE, HIL_IRQ);

	return 0;
}
Пример #3
0
/* initialise HIL */
static int __init
hil_keyb_init(void)
{
	unsigned char c;
	unsigned int i, kbid;
	wait_queue_head_t hil_wait;
	int err;

	if (hil_dev.dev) {
		return -ENODEV; /* already initialized */
	}

	spin_lock_init(&hil_dev.lock);
	hil_dev.dev = input_allocate_device();
	if (!hil_dev.dev)
		return -ENOMEM;

#if defined(CONFIG_HP300)
	if (!hwreg_present((void *)(HILBASE + HIL_DATA))) {
		printk(KERN_ERR "HIL: hardware register was not found\n");
		err = -ENODEV;
		goto err1;
	}
	if (!request_region(HILBASE + HIL_DATA, 2, "hil")) {
		printk(KERN_ERR "HIL: IOPORT region already used\n");
		err = -EIO;
		goto err1;
	}
#endif

	err = request_irq(HIL_IRQ, hil_interrupt, 0, "hil", hil_dev.dev_id);
	if (err) {
		printk(KERN_ERR "HIL: Can't get IRQ\n");
		goto err2;
	}

	/* Turn on interrupts */
	hil_do(HIL_INTON, NULL, 0);

	/* Look for keyboards */
	hil_dev.valid = 0;	/* clear any pending data */
	hil_do(HIL_READKBDSADR, NULL, 0);

	init_waitqueue_head(&hil_wait);
	wait_event_interruptible_timeout(hil_wait, hil_dev.valid, 3*HZ);
	if (!hil_dev.valid) {
		printk(KERN_WARNING "HIL: timed out, assuming no keyboard present\n");
	}

	c = hil_dev.c;
	hil_dev.valid = 0;
	if (c == 0) {
		kbid = -1;
		printk(KERN_WARNING "HIL: no keyboard present\n");
	} else {
		kbid = ffz(~c);
		printk(KERN_INFO "HIL: keyboard found at id %d\n", kbid);
	}

	/* set it to raw mode */
	c = 0;
	hil_do(HIL_WRITEKBDSADR, &c, 1);

	for (i = 0; i < HIL_KEYCODES_SET1_TBLSIZE; i++)
		if (hphilkeyb_keycode[i] != KEY_RESERVED)
			set_bit(hphilkeyb_keycode[i], hil_dev.dev->keybit);

	hil_dev.dev->evbit[0]	= BIT(EV_KEY) | BIT(EV_REP);
	hil_dev.dev->ledbit[0]	= BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL);
	hil_dev.dev->keycodemax	= HIL_KEYCODES_SET1_TBLSIZE;
	hil_dev.dev->keycodesize= sizeof(hphilkeyb_keycode[0]);
	hil_dev.dev->keycode	= hphilkeyb_keycode;
	hil_dev.dev->name	= "HIL keyboard";
	hil_dev.dev->phys	= "hpkbd/input0";

	hil_dev.dev->id.bustype	= BUS_HIL;
	hil_dev.dev->id.vendor	= PCI_VENDOR_ID_HP;
	hil_dev.dev->id.product	= 0x0001;
	hil_dev.dev->id.version	= 0x0010;

	err = input_register_device(hil_dev.dev);
	if (err) {
		printk(KERN_ERR "HIL: Can't register device\n");
		goto err3;
	}
	printk(KERN_INFO "input: %s, ID %d at 0x%08lx (irq %d) found and attached\n",
	       hil_dev.dev->name, kbid, HILBASE, HIL_IRQ);

	return 0;

err3:
	hil_do(HIL_INTOFF, NULL, 0);
	disable_irq(HIL_IRQ);
	free_irq(HIL_IRQ, hil_dev.dev_id);
err2:
#if defined(CONFIG_HP300)
	release_region(HILBASE + HIL_DATA, 2);
err1:
#endif
	input_free_device(hil_dev.dev);
	hil_dev.dev = NULL;
	return err;
}