xref: /linux/drivers/input/serio/xilinx_ps2.c (revision 61c7a080a5a061c976988fd4b844dfb468dda255)
11191828fSJohn Linn /*
21191828fSJohn Linn  * Xilinx XPS PS/2 device driver
31191828fSJohn Linn  *
41191828fSJohn Linn  * (c) 2005 MontaVista Software, Inc.
51191828fSJohn Linn  * (c) 2008 Xilinx, Inc.
61191828fSJohn Linn  *
71191828fSJohn Linn  * This program is free software; you can redistribute it and/or modify it
81191828fSJohn Linn  * under the terms of the GNU General Public License as published by the
91191828fSJohn Linn  * Free Software Foundation; either version 2 of the License, or (at your
101191828fSJohn Linn  * option) any later version.
111191828fSJohn Linn  *
121191828fSJohn Linn  * You should have received a copy of the GNU General Public License along
131191828fSJohn Linn  * with this program; if not, write to the Free Software Foundation, Inc.,
141191828fSJohn Linn  * 675 Mass Ave, Cambridge, MA 02139, USA.
151191828fSJohn Linn  */
161191828fSJohn Linn 
171191828fSJohn Linn 
181191828fSJohn Linn #include <linux/module.h>
191191828fSJohn Linn #include <linux/serio.h>
201191828fSJohn Linn #include <linux/interrupt.h>
211191828fSJohn Linn #include <linux/errno.h>
225a0e3ad6STejun Heo #include <linux/slab.h>
231191828fSJohn Linn #include <linux/init.h>
241191828fSJohn Linn #include <linux/list.h>
251191828fSJohn Linn #include <linux/io.h>
261191828fSJohn Linn 
271191828fSJohn Linn #include <linux/of_device.h>
281191828fSJohn Linn #include <linux/of_platform.h>
291191828fSJohn Linn 
301191828fSJohn Linn #define DRIVER_NAME		"xilinx_ps2"
311191828fSJohn Linn 
321191828fSJohn Linn /* Register offsets for the xps2 device */
331191828fSJohn Linn #define XPS2_SRST_OFFSET	0x00000000 /* Software Reset register */
341191828fSJohn Linn #define XPS2_STATUS_OFFSET	0x00000004 /* Status register */
351191828fSJohn Linn #define XPS2_RX_DATA_OFFSET	0x00000008 /* Receive Data register */
361191828fSJohn Linn #define XPS2_TX_DATA_OFFSET	0x0000000C /* Transmit Data register */
371191828fSJohn Linn #define XPS2_GIER_OFFSET	0x0000002C /* Global Interrupt Enable reg */
381191828fSJohn Linn #define XPS2_IPISR_OFFSET	0x00000030 /* Interrupt Status register */
391191828fSJohn Linn #define XPS2_IPIER_OFFSET	0x00000038 /* Interrupt Enable register */
401191828fSJohn Linn 
411191828fSJohn Linn /* Reset Register Bit Definitions */
421191828fSJohn Linn #define XPS2_SRST_RESET		0x0000000A /* Software Reset  */
431191828fSJohn Linn 
441191828fSJohn Linn /* Status Register Bit Positions */
451191828fSJohn Linn #define XPS2_STATUS_RX_FULL	0x00000001 /* Receive Full  */
461191828fSJohn Linn #define XPS2_STATUS_TX_FULL	0x00000002 /* Transmit Full  */
471191828fSJohn Linn 
481191828fSJohn Linn /* Bit definitions for ISR/IER registers. Both the registers have the same bit
491191828fSJohn Linn  * definitions and are only defined once. */
501191828fSJohn Linn #define XPS2_IPIXR_WDT_TOUT	0x00000001 /* Watchdog Timeout Interrupt */
511191828fSJohn Linn #define XPS2_IPIXR_TX_NOACK	0x00000002 /* Transmit No ACK Interrupt */
521191828fSJohn Linn #define XPS2_IPIXR_TX_ACK	0x00000004 /* Transmit ACK (Data) Interrupt */
531191828fSJohn Linn #define XPS2_IPIXR_RX_OVF	0x00000008 /* Receive Overflow Interrupt */
541191828fSJohn Linn #define XPS2_IPIXR_RX_ERR	0x00000010 /* Receive Error Interrupt */
551191828fSJohn Linn #define XPS2_IPIXR_RX_FULL	0x00000020 /* Receive Data Interrupt */
561191828fSJohn Linn 
571191828fSJohn Linn /* Mask for all the Transmit Interrupts */
581191828fSJohn Linn #define XPS2_IPIXR_TX_ALL	(XPS2_IPIXR_TX_NOACK | XPS2_IPIXR_TX_ACK)
591191828fSJohn Linn 
601191828fSJohn Linn /* Mask for all the Receive Interrupts */
611191828fSJohn Linn #define XPS2_IPIXR_RX_ALL	(XPS2_IPIXR_RX_OVF | XPS2_IPIXR_RX_ERR |  \
621191828fSJohn Linn 				 XPS2_IPIXR_RX_FULL)
631191828fSJohn Linn 
641191828fSJohn Linn /* Mask for all the Interrupts */
651191828fSJohn Linn #define XPS2_IPIXR_ALL		(XPS2_IPIXR_TX_ALL | XPS2_IPIXR_RX_ALL |  \
661191828fSJohn Linn 				 XPS2_IPIXR_WDT_TOUT)
671191828fSJohn Linn 
681191828fSJohn Linn /* Global Interrupt Enable mask */
691191828fSJohn Linn #define XPS2_GIER_GIE_MASK	0x80000000
701191828fSJohn Linn 
711191828fSJohn Linn struct xps2data {
721191828fSJohn Linn 	int irq;
731191828fSJohn Linn 	spinlock_t lock;
741191828fSJohn Linn 	void __iomem *base_address;	/* virt. address of control registers */
75b4a3ac9aSJohn Linn 	unsigned int flags;
761191828fSJohn Linn 	struct serio serio;		/* serio */
771191828fSJohn Linn };
781191828fSJohn Linn 
791191828fSJohn Linn /************************************/
801191828fSJohn Linn /* XPS PS/2 data transmission calls */
811191828fSJohn Linn /************************************/
821191828fSJohn Linn 
83b4a3ac9aSJohn Linn /**
84b4a3ac9aSJohn Linn  * xps2_recv() - attempts to receive a byte from the PS/2 port.
85b4a3ac9aSJohn Linn  * @drvdata:	pointer to ps2 device private data structure
86b4a3ac9aSJohn Linn  * @byte:	address where the read data will be copied
87b4a3ac9aSJohn Linn  *
88b4a3ac9aSJohn Linn  * If there is any data available in the PS/2 receiver, this functions reads
89b4a3ac9aSJohn Linn  * the data, otherwise it returns error.
901191828fSJohn Linn  */
911191828fSJohn Linn static int xps2_recv(struct xps2data *drvdata, u8 *byte)
921191828fSJohn Linn {
931191828fSJohn Linn 	u32 sr;
941191828fSJohn Linn 	int status = -1;
951191828fSJohn Linn 
961191828fSJohn Linn 	/* If there is data available in the PS/2 receiver, read it */
971191828fSJohn Linn 	sr = in_be32(drvdata->base_address + XPS2_STATUS_OFFSET);
981191828fSJohn Linn 	if (sr & XPS2_STATUS_RX_FULL) {
991191828fSJohn Linn 		*byte = in_be32(drvdata->base_address + XPS2_RX_DATA_OFFSET);
1001191828fSJohn Linn 		status = 0;
1011191828fSJohn Linn 	}
1021191828fSJohn Linn 
1031191828fSJohn Linn 	return status;
1041191828fSJohn Linn }
1051191828fSJohn Linn 
1061191828fSJohn Linn /*********************/
1071191828fSJohn Linn /* Interrupt handler */
1081191828fSJohn Linn /*********************/
1091191828fSJohn Linn static irqreturn_t xps2_interrupt(int irq, void *dev_id)
1101191828fSJohn Linn {
1111191828fSJohn Linn 	struct xps2data *drvdata = dev_id;
1121191828fSJohn Linn 	u32 intr_sr;
1131191828fSJohn Linn 	u8 c;
1141191828fSJohn Linn 	int status;
1151191828fSJohn Linn 
1161191828fSJohn Linn 	/* Get the PS/2 interrupts and clear them */
1171191828fSJohn Linn 	intr_sr = in_be32(drvdata->base_address + XPS2_IPISR_OFFSET);
1181191828fSJohn Linn 	out_be32(drvdata->base_address + XPS2_IPISR_OFFSET, intr_sr);
1191191828fSJohn Linn 
1201191828fSJohn Linn 	/* Check which interrupt is active */
1211191828fSJohn Linn 	if (intr_sr & XPS2_IPIXR_RX_OVF)
122b4a3ac9aSJohn Linn 		dev_warn(drvdata->serio.dev.parent, "receive overrun error\n");
1231191828fSJohn Linn 
1241191828fSJohn Linn 	if (intr_sr & XPS2_IPIXR_RX_ERR)
125b4a3ac9aSJohn Linn 		drvdata->flags |= SERIO_PARITY;
1261191828fSJohn Linn 
1271191828fSJohn Linn 	if (intr_sr & (XPS2_IPIXR_TX_NOACK | XPS2_IPIXR_WDT_TOUT))
128b4a3ac9aSJohn Linn 		drvdata->flags |= SERIO_TIMEOUT;
1291191828fSJohn Linn 
1301191828fSJohn Linn 	if (intr_sr & XPS2_IPIXR_RX_FULL) {
131b4a3ac9aSJohn Linn 		status = xps2_recv(drvdata, &c);
1321191828fSJohn Linn 
1331191828fSJohn Linn 		/* Error, if a byte is not received */
1341191828fSJohn Linn 		if (status) {
135b4a3ac9aSJohn Linn 			dev_err(drvdata->serio.dev.parent,
136b4a3ac9aSJohn Linn 				"wrong rcvd byte count (%d)\n", status);
1371191828fSJohn Linn 		} else {
138b4a3ac9aSJohn Linn 			serio_interrupt(&drvdata->serio, c, drvdata->flags);
139b4a3ac9aSJohn Linn 			drvdata->flags = 0;
1401191828fSJohn Linn 		}
1411191828fSJohn Linn 	}
1421191828fSJohn Linn 
1431191828fSJohn Linn 	return IRQ_HANDLED;
1441191828fSJohn Linn }
1451191828fSJohn Linn 
1461191828fSJohn Linn /*******************/
1471191828fSJohn Linn /* serio callbacks */
1481191828fSJohn Linn /*******************/
1491191828fSJohn Linn 
150b4a3ac9aSJohn Linn /**
151b4a3ac9aSJohn Linn  * sxps2_write() - sends a byte out through the PS/2 port.
152b4a3ac9aSJohn Linn  * @pserio:	pointer to the serio structure of the PS/2 port
153b4a3ac9aSJohn Linn  * @c:		data that needs to be written to the PS/2 port
154b4a3ac9aSJohn Linn  *
155b4a3ac9aSJohn Linn  * This function checks if the PS/2 transmitter is empty and sends a byte.
156b4a3ac9aSJohn Linn  * Otherwise it returns error. Transmission fails only when nothing is connected
157b4a3ac9aSJohn Linn  * to the PS/2 port. Thats why, we do not try to resend the data in case of a
158b4a3ac9aSJohn Linn  * failure.
1591191828fSJohn Linn  */
1601191828fSJohn Linn static int sxps2_write(struct serio *pserio, unsigned char c)
1611191828fSJohn Linn {
1621191828fSJohn Linn 	struct xps2data *drvdata = pserio->port_data;
1631191828fSJohn Linn 	unsigned long flags;
1641191828fSJohn Linn 	u32 sr;
1651191828fSJohn Linn 	int status = -1;
1661191828fSJohn Linn 
1671191828fSJohn Linn 	spin_lock_irqsave(&drvdata->lock, flags);
1681191828fSJohn Linn 
1691191828fSJohn Linn 	/* If the PS/2 transmitter is empty send a byte of data */
1701191828fSJohn Linn 	sr = in_be32(drvdata->base_address + XPS2_STATUS_OFFSET);
1711191828fSJohn Linn 	if (!(sr & XPS2_STATUS_TX_FULL)) {
1721191828fSJohn Linn 		out_be32(drvdata->base_address + XPS2_TX_DATA_OFFSET, c);
1731191828fSJohn Linn 		status = 0;
1741191828fSJohn Linn 	}
1751191828fSJohn Linn 
1761191828fSJohn Linn 	spin_unlock_irqrestore(&drvdata->lock, flags);
1771191828fSJohn Linn 
1781191828fSJohn Linn 	return status;
1791191828fSJohn Linn }
1801191828fSJohn Linn 
181b4a3ac9aSJohn Linn /**
182b4a3ac9aSJohn Linn  * sxps2_open() - called when a port is opened by the higher layer.
183b4a3ac9aSJohn Linn  * @pserio:	pointer to the serio structure of the PS/2 device
184b4a3ac9aSJohn Linn  *
185b4a3ac9aSJohn Linn  * This function requests irq and enables interrupts for the PS/2 device.
1861191828fSJohn Linn  */
1871191828fSJohn Linn static int sxps2_open(struct serio *pserio)
1881191828fSJohn Linn {
1891191828fSJohn Linn 	struct xps2data *drvdata = pserio->port_data;
190b4a3ac9aSJohn Linn 	int error;
191b4a3ac9aSJohn Linn 	u8 c;
1921191828fSJohn Linn 
193b4a3ac9aSJohn Linn 	error = request_irq(drvdata->irq, &xps2_interrupt, 0,
1941191828fSJohn Linn 				DRIVER_NAME, drvdata);
195b4a3ac9aSJohn Linn 	if (error) {
196b4a3ac9aSJohn Linn 		dev_err(drvdata->serio.dev.parent,
197b4a3ac9aSJohn Linn 			"Couldn't allocate interrupt %d\n", drvdata->irq);
198b4a3ac9aSJohn Linn 		return error;
1991191828fSJohn Linn 	}
2001191828fSJohn Linn 
2011191828fSJohn Linn 	/* start reception by enabling the interrupts */
2021191828fSJohn Linn 	out_be32(drvdata->base_address + XPS2_GIER_OFFSET, XPS2_GIER_GIE_MASK);
2031191828fSJohn Linn 	out_be32(drvdata->base_address + XPS2_IPIER_OFFSET, XPS2_IPIXR_RX_ALL);
204b4a3ac9aSJohn Linn 	(void)xps2_recv(drvdata, &c);
2051191828fSJohn Linn 
2061191828fSJohn Linn 	return 0;		/* success */
2071191828fSJohn Linn }
2081191828fSJohn Linn 
209b4a3ac9aSJohn Linn /**
210b4a3ac9aSJohn Linn  * sxps2_close() - frees the interrupt.
211b4a3ac9aSJohn Linn  * @pserio:	pointer to the serio structure of the PS/2 device
212b4a3ac9aSJohn Linn  *
213b4a3ac9aSJohn Linn  * This function frees the irq and disables interrupts for the PS/2 device.
2141191828fSJohn Linn  */
2151191828fSJohn Linn static void sxps2_close(struct serio *pserio)
2161191828fSJohn Linn {
2171191828fSJohn Linn 	struct xps2data *drvdata = pserio->port_data;
2181191828fSJohn Linn 
2191191828fSJohn Linn 	/* Disable the PS2 interrupts */
2201191828fSJohn Linn 	out_be32(drvdata->base_address + XPS2_GIER_OFFSET, 0x00);
2211191828fSJohn Linn 	out_be32(drvdata->base_address + XPS2_IPIER_OFFSET, 0x00);
2221191828fSJohn Linn 	free_irq(drvdata->irq, drvdata);
2231191828fSJohn Linn }
2241191828fSJohn Linn 
225b4a3ac9aSJohn Linn /**
226b4a3ac9aSJohn Linn  * xps2_of_probe - probe method for the PS/2 device.
227b4a3ac9aSJohn Linn  * @of_dev:	pointer to OF device structure
228b4a3ac9aSJohn Linn  * @match:	pointer to the stucture used for matching a device
229b4a3ac9aSJohn Linn  *
230b4a3ac9aSJohn Linn  * This function probes the PS/2 device in the device tree.
231b4a3ac9aSJohn Linn  * It initializes the driver data structure and the hardware.
232b4a3ac9aSJohn Linn  * It returns 0, if the driver is bound to the PS/2 device, or a negative
233b4a3ac9aSJohn Linn  * value if there is an error.
234b4a3ac9aSJohn Linn  */
235b4a3ac9aSJohn Linn static int __devinit xps2_of_probe(struct of_device *ofdev,
236b4a3ac9aSJohn Linn 				   const struct of_device_id *match)
2371191828fSJohn Linn {
238b4a3ac9aSJohn Linn 	struct resource r_irq; /* Interrupt resources */
239b4a3ac9aSJohn Linn 	struct resource r_mem; /* IO mem resources */
2401191828fSJohn Linn 	struct xps2data *drvdata;
2411191828fSJohn Linn 	struct serio *serio;
242b4a3ac9aSJohn Linn 	struct device *dev = &ofdev->dev;
243b4a3ac9aSJohn Linn 	resource_size_t remap_size, phys_addr;
244b4a3ac9aSJohn Linn 	int error;
2451191828fSJohn Linn 
246b4a3ac9aSJohn Linn 	dev_info(dev, "Device Tree Probing \'%s\'\n",
247*61c7a080SGrant Likely 			ofdev->dev.of_node->name);
2481191828fSJohn Linn 
249b4a3ac9aSJohn Linn 	/* Get iospace for the device */
250*61c7a080SGrant Likely 	error = of_address_to_resource(ofdev->dev.of_node, 0, &r_mem);
251b4a3ac9aSJohn Linn 	if (error) {
252b4a3ac9aSJohn Linn 		dev_err(dev, "invalid address\n");
253b4a3ac9aSJohn Linn 		return error;
254b4a3ac9aSJohn Linn 	}
255b4a3ac9aSJohn Linn 
256b4a3ac9aSJohn Linn 	/* Get IRQ for the device */
257*61c7a080SGrant Likely 	if (of_irq_to_resource(ofdev->dev.of_node, 0, &r_irq) == NO_IRQ) {
258b4a3ac9aSJohn Linn 		dev_err(dev, "no IRQ found\n");
259b4a3ac9aSJohn Linn 		return -ENODEV;
2601191828fSJohn Linn 	}
2611191828fSJohn Linn 
2621191828fSJohn Linn 	drvdata = kzalloc(sizeof(struct xps2data), GFP_KERNEL);
2631191828fSJohn Linn 	if (!drvdata) {
2641191828fSJohn Linn 		dev_err(dev, "Couldn't allocate device private record\n");
2651191828fSJohn Linn 		return -ENOMEM;
2661191828fSJohn Linn 	}
2671191828fSJohn Linn 
2681191828fSJohn Linn 	dev_set_drvdata(dev, drvdata);
2691191828fSJohn Linn 
2701191828fSJohn Linn 	spin_lock_init(&drvdata->lock);
271b4a3ac9aSJohn Linn 	drvdata->irq = r_irq.start;
2721191828fSJohn Linn 
273b4a3ac9aSJohn Linn 	phys_addr = r_mem.start;
274ce841b94STobias Klauser 	remap_size = resource_size(&r_mem);
275b4a3ac9aSJohn Linn 	if (!request_mem_region(phys_addr, remap_size, DRIVER_NAME)) {
276b4a3ac9aSJohn Linn 		dev_err(dev, "Couldn't lock memory region at 0x%08llX\n",
277b4a3ac9aSJohn Linn 			(unsigned long long)phys_addr);
278b4a3ac9aSJohn Linn 		error = -EBUSY;
2791191828fSJohn Linn 		goto failed1;
2801191828fSJohn Linn 	}
2811191828fSJohn Linn 
2821191828fSJohn Linn 	/* Fill in configuration data and add them to the list */
283b4a3ac9aSJohn Linn 	drvdata->base_address = ioremap(phys_addr, remap_size);
2841191828fSJohn Linn 	if (drvdata->base_address == NULL) {
285b4a3ac9aSJohn Linn 		dev_err(dev, "Couldn't ioremap memory at 0x%08llX\n",
286b4a3ac9aSJohn Linn 			(unsigned long long)phys_addr);
287b4a3ac9aSJohn Linn 		error = -EFAULT;
2881191828fSJohn Linn 		goto failed2;
2891191828fSJohn Linn 	}
2901191828fSJohn Linn 
2911191828fSJohn Linn 	/* Disable all the interrupts, just in case */
2921191828fSJohn Linn 	out_be32(drvdata->base_address + XPS2_IPIER_OFFSET, 0);
2931191828fSJohn Linn 
2941191828fSJohn Linn 	/* Reset the PS2 device and abort any current transaction, to make sure
2951191828fSJohn Linn 	 * we have the PS2 in a good state */
2961191828fSJohn Linn 	out_be32(drvdata->base_address + XPS2_SRST_OFFSET, XPS2_SRST_RESET);
2971191828fSJohn Linn 
298b4a3ac9aSJohn Linn 	dev_info(dev, "Xilinx PS2 at 0x%08llX mapped to 0x%p, irq=%d\n",
299b4a3ac9aSJohn Linn 		 (unsigned long long)phys_addr, drvdata->base_address,
300b4a3ac9aSJohn Linn 		 drvdata->irq);
3011191828fSJohn Linn 
3021191828fSJohn Linn 	serio = &drvdata->serio;
3031191828fSJohn Linn 	serio->id.type = SERIO_8042;
3041191828fSJohn Linn 	serio->write = sxps2_write;
3051191828fSJohn Linn 	serio->open = sxps2_open;
3061191828fSJohn Linn 	serio->close = sxps2_close;
3071191828fSJohn Linn 	serio->port_data = drvdata;
3081191828fSJohn Linn 	serio->dev.parent = dev;
3091191828fSJohn Linn 	snprintf(serio->name, sizeof(serio->name),
310b4a3ac9aSJohn Linn 		 "Xilinx XPS PS/2 at %08llX", (unsigned long long)phys_addr);
3111191828fSJohn Linn 	snprintf(serio->phys, sizeof(serio->phys),
312b4a3ac9aSJohn Linn 		 "xilinxps2/serio at %08llX", (unsigned long long)phys_addr);
313b4a3ac9aSJohn Linn 
3141191828fSJohn Linn 	serio_register_port(serio);
3151191828fSJohn Linn 
3161191828fSJohn Linn 	return 0;		/* success */
3171191828fSJohn Linn 
3181191828fSJohn Linn failed2:
319b4a3ac9aSJohn Linn 	release_mem_region(phys_addr, remap_size);
3201191828fSJohn Linn failed1:
3211191828fSJohn Linn 	kfree(drvdata);
3221191828fSJohn Linn 	dev_set_drvdata(dev, NULL);
3231191828fSJohn Linn 
324b4a3ac9aSJohn Linn 	return error;
3251191828fSJohn Linn }
3261191828fSJohn Linn 
327b4a3ac9aSJohn Linn /**
328b4a3ac9aSJohn Linn  * xps2_of_remove - unbinds the driver from the PS/2 device.
329b4a3ac9aSJohn Linn  * @of_dev:	pointer to OF device structure
330b4a3ac9aSJohn Linn  *
331b4a3ac9aSJohn Linn  * This function is called if a device is physically removed from the system or
332b4a3ac9aSJohn Linn  * if the driver module is being unloaded. It frees any resources allocated to
333b4a3ac9aSJohn Linn  * the device.
334b4a3ac9aSJohn Linn  */
3351191828fSJohn Linn static int __devexit xps2_of_remove(struct of_device *of_dev)
3361191828fSJohn Linn {
3371191828fSJohn Linn 	struct device *dev = &of_dev->dev;
338b4a3ac9aSJohn Linn 	struct xps2data *drvdata = dev_get_drvdata(dev);
339b4a3ac9aSJohn Linn 	struct resource r_mem; /* IO mem resources */
3401191828fSJohn Linn 
3411191828fSJohn Linn 	serio_unregister_port(&drvdata->serio);
3421191828fSJohn Linn 	iounmap(drvdata->base_address);
343b4a3ac9aSJohn Linn 
344b4a3ac9aSJohn Linn 	/* Get iospace of the device */
345*61c7a080SGrant Likely 	if (of_address_to_resource(of_dev->dev.of_node, 0, &r_mem))
346b4a3ac9aSJohn Linn 		dev_err(dev, "invalid address\n");
347b4a3ac9aSJohn Linn 	else
348ce841b94STobias Klauser 		release_mem_region(r_mem.start, resource_size(&r_mem));
349b4a3ac9aSJohn Linn 
3501191828fSJohn Linn 	kfree(drvdata);
3511191828fSJohn Linn 
3521191828fSJohn Linn 	dev_set_drvdata(dev, NULL);
3531191828fSJohn Linn 
354b4a3ac9aSJohn Linn 	return 0;
3551191828fSJohn Linn }
3561191828fSJohn Linn 
3571191828fSJohn Linn /* Match table for of_platform binding */
358ef9a16f1SMárton Németh static const struct of_device_id xps2_of_match[] __devinitconst = {
3591191828fSJohn Linn 	{ .compatible = "xlnx,xps-ps2-1.00.a", },
3601191828fSJohn Linn 	{ /* end of list */ },
3611191828fSJohn Linn };
3621191828fSJohn Linn MODULE_DEVICE_TABLE(of, xps2_of_match);
3631191828fSJohn Linn 
3641191828fSJohn Linn static struct of_platform_driver xps2_of_driver = {
3651191828fSJohn Linn 	.name		= DRIVER_NAME,
3661191828fSJohn Linn 	.match_table	= xps2_of_match,
3671191828fSJohn Linn 	.probe		= xps2_of_probe,
3681191828fSJohn Linn 	.remove		= __devexit_p(xps2_of_remove),
3691191828fSJohn Linn };
3701191828fSJohn Linn 
3711191828fSJohn Linn static int __init xps2_init(void)
3721191828fSJohn Linn {
3731191828fSJohn Linn 	return of_register_platform_driver(&xps2_of_driver);
3741191828fSJohn Linn }
3751191828fSJohn Linn 
3761191828fSJohn Linn static void __exit xps2_cleanup(void)
3771191828fSJohn Linn {
3781191828fSJohn Linn 	of_unregister_platform_driver(&xps2_of_driver);
3791191828fSJohn Linn }
3801191828fSJohn Linn 
3811191828fSJohn Linn module_init(xps2_init);
3821191828fSJohn Linn module_exit(xps2_cleanup);
3831191828fSJohn Linn 
3841191828fSJohn Linn MODULE_AUTHOR("Xilinx, Inc.");
3851191828fSJohn Linn MODULE_DESCRIPTION("Xilinx XPS PS/2 driver");
3861191828fSJohn Linn MODULE_LICENSE("GPL");
3871191828fSJohn Linn 
388