Release 4.7 drivers/input/serio/maceps2.c
  
  
/*
 * SGI O2 MACE PS2 controller driver for linux
 *
 * Copyright (C) 2002 Vivien Chappelier
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation
 */
#include <linux/module.h>
#include <linux/init.h>
#include <linux/serio.h>
#include <linux/errno.h>
#include <linux/interrupt.h>
#include <linux/ioport.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/err.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/ip32/mace.h>
#include <asm/ip32/ip32_ints.h>
MODULE_AUTHOR("Vivien Chappelier <vivien.chappelier@linux-mips.org");
MODULE_DESCRIPTION("SGI O2 MACE PS2 controller driver");
MODULE_LICENSE("GPL");
#define MACE_PS2_TIMEOUT 10000 
/* in 50us unit */
#define PS2_STATUS_CLOCK_SIGNAL  BIT(0) 
/* external clock signal */
#define PS2_STATUS_CLOCK_INHIBIT BIT(1) 
/* clken output signal */
#define PS2_STATUS_TX_INPROGRESS BIT(2) 
/* transmission in progress */
#define PS2_STATUS_TX_EMPTY      BIT(3) 
/* empty transmit buffer */
#define PS2_STATUS_RX_FULL       BIT(4) 
/* full receive buffer */
#define PS2_STATUS_RX_INPROGRESS BIT(5) 
/* reception in progress */
#define PS2_STATUS_ERROR_PARITY  BIT(6) 
/* parity error */
#define PS2_STATUS_ERROR_FRAMING BIT(7) 
/* framing error */
#define PS2_CONTROL_TX_CLOCK_DISABLE BIT(0) 
/* inhibit clock signal after TX */
#define PS2_CONTROL_TX_ENABLE        BIT(1) 
/* transmit enable */
#define PS2_CONTROL_TX_INT_ENABLE    BIT(2) 
/* enable transmit interrupt */
#define PS2_CONTROL_RX_INT_ENABLE    BIT(3) 
/* enable receive interrupt */
#define PS2_CONTROL_RX_CLOCK_ENABLE  BIT(4) 
/* pause reception if set to 0 */
#define PS2_CONTROL_RESET            BIT(5) 
/* reset */
struct maceps2_data {
	
struct mace_ps2port *port;
	
int irq;
};
static struct maceps2_data port_data[2];
static struct serio *maceps2_port[2];
static struct platform_device *maceps2_device;
static int maceps2_write(struct serio *dev, unsigned char val)
{
	struct mace_ps2port *port = ((struct maceps2_data *)dev->port_data)->port;
	unsigned int timeout = MACE_PS2_TIMEOUT;
	do {
		if (port->status & PS2_STATUS_TX_EMPTY) {
			port->tx = val;
			return 0;
		}
		udelay(50);
	} while (timeout--);
	return -1;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| andrew morton | andrew morton | 73 | 96.05% | 1 | 33.33% | 
| ralf baechle | ralf baechle | 2 | 2.63% | 1 | 33.33% | 
| dmitry torokhov | dmitry torokhov | 1 | 1.32% | 1 | 33.33% | 
 | Total | 76 | 100.00% | 3 | 100.00% | 
static irqreturn_t maceps2_interrupt(int irq, void *dev_id)
{
	struct serio *dev = dev_id;
	struct mace_ps2port *port = ((struct maceps2_data *)dev->port_data)->port;
	unsigned long byte;
	if (port->status & PS2_STATUS_RX_FULL) {
		byte = port->rx;
		serio_interrupt(dev, byte & 0xff, 0);
        }
	return IRQ_HANDLED;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| andrew morton | andrew morton | 70 | 97.22% | 1 | 33.33% | 
| dmitry torokhov | dmitry torokhov | 1 | 1.39% | 1 | 33.33% | 
| ralf baechle | ralf baechle | 1 | 1.39% | 1 | 33.33% | 
 | Total | 72 | 100.00% | 3 | 100.00% | 
static int maceps2_open(struct serio *dev)
{
	struct maceps2_data *data = (struct maceps2_data *)dev->port_data;
	if (request_irq(data->irq, maceps2_interrupt, 0, "PS2 port", dev)) {
		printk(KERN_ERR "Could not allocate PS/2 IRQ\n");
		return -EBUSY;
	}
	/* Reset port */
	data->port->control = PS2_CONTROL_TX_CLOCK_DISABLE | PS2_CONTROL_RESET;
	udelay(100);
        /* Enable interrupts */
	data->port->control = PS2_CONTROL_RX_CLOCK_ENABLE |
			      PS2_CONTROL_TX_ENABLE |
			      PS2_CONTROL_RX_INT_ENABLE;
	return 0;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| andrew morton | andrew morton | 74 | 86.05% | 1 | 25.00% | 
| ralf baechle | ralf baechle | 10 | 11.63% | 1 | 25.00% | 
| dmitry torokhov | dmitry torokhov | 1 | 1.16% | 1 | 25.00% | 
| olaf hering | olaf hering | 1 | 1.16% | 1 | 25.00% | 
 | Total | 86 | 100.00% | 4 | 100.00% | 
static void maceps2_close(struct serio *dev)
{
	struct maceps2_data *data = (struct maceps2_data *)dev->port_data;
	data->port->control = PS2_CONTROL_TX_CLOCK_DISABLE | PS2_CONTROL_RESET;
	udelay(100);
	free_irq(data->irq, dev);
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| andrew morton | andrew morton | 44 | 89.80% | 1 | 33.33% | 
| ralf baechle | ralf baechle | 4 | 8.16% | 1 | 33.33% | 
| dmitry torokhov | dmitry torokhov | 1 | 2.04% | 1 | 33.33% | 
 | Total | 49 | 100.00% | 3 | 100.00% | 
static struct serio *maceps2_allocate_port(int idx)
{
	struct serio *serio;
	serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
	if (serio) {
		serio->id.type		= SERIO_8042;
		serio->write		= maceps2_write;
		serio->open		= maceps2_open;
		serio->close		= maceps2_close;
		snprintf(serio->name, sizeof(serio->name), "MACE PS/2 port%d", idx);
		snprintf(serio->phys, sizeof(serio->phys), "mace/serio%d", idx);
		serio->port_data	= &port_data[idx];
		serio->dev.parent	= &maceps2_device->dev;
	}
	return serio;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| dmitry torokhov | dmitry torokhov | 99 | 81.82% | 5 | 83.33% | 
| andrew morton | andrew morton | 22 | 18.18% | 1 | 16.67% | 
 | Total | 121 | 100.00% | 6 | 100.00% | 
static int maceps2_probe(struct platform_device *dev)
{
	maceps2_port[0] = maceps2_allocate_port(0);
	maceps2_port[1] = maceps2_allocate_port(1);
	if (!maceps2_port[0] || !maceps2_port[1]) {
		kfree(maceps2_port[0]);
		kfree(maceps2_port[1]);
		return -ENOMEM;
	}
	serio_register_port(maceps2_port[0]);
	serio_register_port(maceps2_port[1]);
	return 0;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| dmitry torokhov | dmitry torokhov | 69 | 80.23% | 2 | 66.67% | 
| andrew morton | andrew morton | 17 | 19.77% | 1 | 33.33% | 
 | Total | 86 | 100.00% | 3 | 100.00% | 
static int maceps2_remove(struct platform_device *dev)
{
	serio_unregister_port(maceps2_port[0]);
	serio_unregister_port(maceps2_port[1]);
	return 0;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| dmitry torokhov | dmitry torokhov | 18 | 60.00% | 2 | 66.67% | 
| andrew morton | andrew morton | 12 | 40.00% | 1 | 33.33% | 
 | Total | 30 | 100.00% | 3 | 100.00% | 
static struct platform_driver maceps2_driver = {
	.driver		= {
		.name	= "maceps2",
        },
	.probe		= maceps2_probe,
	.remove		= maceps2_remove,
};
static int __init maceps2_init(void)
{
	int error;
	error = platform_driver_register(&maceps2_driver);
	if (error)
		return error;
	maceps2_device = platform_device_alloc("maceps2", -1);
	if (!maceps2_device) {
		error = -ENOMEM;
		goto err_unregister_driver;
	}
	port_data[0].port = &mace->perif.ps2.keyb;
	port_data[0].irq  = MACEISA_KEYB_IRQ;
	port_data[1].port = &mace->perif.ps2.mouse;
	port_data[1].irq  = MACEISA_MOUSE_IRQ;
	error = platform_device_add(maceps2_device);
	if (error)
		goto err_free_device;
	return 0;
 err_free_device:
	platform_device_put(maceps2_device);
 err_unregister_driver:
	platform_driver_unregister(&maceps2_driver);
	return error;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| dmitry torokhov | dmitry torokhov | 137 | 100.00% | 1 | 100.00% | 
 | Total | 137 | 100.00% | 1 | 100.00% | 
static void __exit maceps2_exit(void)
{
	platform_device_unregister(maceps2_device);
	platform_driver_unregister(&maceps2_driver);
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| dmitry torokhov | dmitry torokhov | 19 | 95.00% | 2 | 66.67% | 
| andrew morton | andrew morton | 1 | 5.00% | 1 | 33.33% | 
 | Total | 20 | 100.00% | 3 | 100.00% | 
module_init(maceps2_init);
module_exit(maceps2_exit);
Overall Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| andrew morton | andrew morton | 468 | 52.82% | 1 | 11.11% | 
| dmitry torokhov | dmitry torokhov | 399 | 45.03% | 5 | 55.56% | 
| ralf baechle | ralf baechle | 17 | 1.92% | 1 | 11.11% | 
| olaf hering | olaf hering | 1 | 0.11% | 1 | 11.11% | 
| russell king | russell king | 1 | 0.11% | 1 | 11.11% | 
 | Total | 886 | 100.00% | 9 | 100.00% | 
  
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.