Skip to contentSkip to conversation

powerpc: Xilinx: PS2: Added new XPS PS2 driver

PATCH Superseded John Linn 3 participants 5 messages Jun 30, 2008

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

John Linn

author
#0 lore raw

PATCH v2 1/1 powerpc: Xilinx: PS2: Added new XPS PS2 driver

Added a new driver for Xilinx XPS PS2 IP. This driver is a flat driver to better match the Linux driver pattern.

---

V2

Changes from v1:

Ran the scripts/checkpatch.pl on the patch as I should have done before sending it (thanks to Stephen).

 drivers/input/serio/Kconfig      |    5 +
 drivers/input/serio/Makefile     |    1 +
 drivers/input/serio/xilinx_ps2.c |  460 ++++++++++++++++++++++++++++++++++++++
 drivers/input/serio/xilinx_ps2.h |   97 ++++++++
 4 files changed, 563 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/serio/xilinx_ps2.c
 create mode 100644 drivers/input/serio/xilinx_ps2.h
drivers/input/serio/Kconfig +5 -0
index ec4b661..0e62b39 100644
@@ -190,4 +190,9 @@ config SERIO_RAW
 	  To compile this driver as a module, choose M here: the
 	  module will be called serio_raw.
 
+config SERIO_XILINX_XPS_PS2
+	tristate "Xilinx XPS PS/2 Controller Support"
+	help
+	  This driver supports XPS PS/2 IP from Xilinx EDK.
+
 endif
drivers/input/serio/Makefile +1 -0
index 38b8868..9b6c813 100644
@@ -21,3 +21,4 @@ obj-$(CONFIG_SERIO_PCIPS2)	+= pcips2.o
 obj-$(CONFIG_SERIO_MACEPS2)	+= maceps2.o
 obj-$(CONFIG_SERIO_LIBPS2)	+= libps2.o
 obj-$(CONFIG_SERIO_RAW)		+= serio_raw.o
+obj-$(CONFIG_SERIO_XILINX_XPS_PS2)	+= xilinx_ps2.o
drivers/input/serio/xilinx_ps2.c new file +460 -0

460 lines not on this page · raw message

drivers/input/serio/xilinx_ps2.h new file +97 -0

97 lines not on this page · raw message

Signature · 5 lines
1.5.2.1



This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
#1 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"John" == John Linn <[email protected]> writes:

John> Added a new driver for Xilinx XPS PS2 IP. This driver is John> a flat driver to better match the Linux driver pattern.

John> Signed-off-by: Sadanand <[email protected]> John> Signed-off-by: John Linn <[email protected]> John> ---

John> V2

John> Changes from v1:

John> Ran the scripts/checkpatch.pl on the patch as I should have done John> before sending it (thanks to Stephen).

What about my comments?

Signature · 1 line
Bye, Peter Korsgaard
author
#2 lore raw

Ahh... sorry about that Peter, didn't ignore your comments on purpose.

Just got on a tangent about sending it to the other mailing list and forgot to look on down.

I'll review them.

-- John

-----Original Message-----
From: Peter Korsgaard [mailto:[email protected]] On Behalf Of Peter Korsgaard
Sent: Monday, June 30, 2008 11:56 AM
To: John Linn
Cc: [email protected]; [email protected]; Sadanand Mutyala
Subject: Re: [PATCH] [V2] powerpc: Xilinx: PS2: Added new XPS PS2 driver

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"John" == John Linn <[email protected]> writes:

John> Added a new driver for Xilinx XPS PS2 IP. This driver is John> a flat driver to better match the Linux driver pattern.

John> Signed-off-by: Sadanand <[email protected]> John> Signed-off-by: John Linn <[email protected]> John> ---

John> V2

John> Changes from v1:

John> Ran the scripts/checkpatch.pl on the patch as I should have done John> before sending it (thanks to Stephen).

What about my comments?

Signature · 4 lines
Bye, Peter Korsgaard


This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
maintainer
#3 lore raw
In reply to John Linn

drivers/input/serio/xilinx_ps2.c line 284

Quoted 2 lines · John Linn
drivers/input/serio/xilinx_ps2.c new file +2 -0
+	spin_lock_init(&drvdata->lock);
+	dev_set_drvdata(dev, (void *)drvdata);

No need to cast to void *.

Quoted 28 lines
drivers/input/serio/xilinx_ps2.c new file +28 -0
+
+	if (!regs_res || !irq_res) {
+		dev_err(dev, "IO resource(s) not found\n");
+		retval = -EFAULT;
+		goto failed1;
+	}
+
+	drvdata->irq = irq_res->start;
+	remap_size = regs_res->end - regs_res->start + 1;
+	if (!request_mem_region(regs_res->start, remap_size, DRIVER_NAME)) {
+
+		dev_err(dev, "Couldn't lock memory region at 0x%08X\n",
+			(unsigned int)regs_res->start);
+		retval = -EBUSY;
+		goto failed1;
+	}
+
+	/* Fill in configuration data and add them to the list */
+	drvdata->phys_addr = regs_res->start;
+	drvdata->remap_size = remap_size;
+	drvdata->base_address = ioremap(regs_res->start, remap_size);
+	if (drvdata->base_address == NULL) {
+
+		dev_err(dev, "Couldn't ioremap memory at 0x%08X\n",
+			(unsigned int)regs_res->start);
+		retval = -EFAULT;
+		goto failed2;
+	}

drivers/input/serio/xilinx_ps2.c line 322

Quoted 10 lines
drivers/input/serio/xilinx_ps2.c new file +10 -0
+
+	/* Initialize the PS/2 interface */
+	down(&cfg_sem);
+	if (xps2_initialize(drvdata)) {
+		up(&cfg_sem);
+		dev_err(dev, "Could not initialize device\n");
+		retval = -ENODEV;
+		goto failed3;
+	}
+	up(&cfg_sem);

Do you need a counting semaphore here?

Quoted 4 lines
drivers/input/serio/xilinx_ps2.c new file +4 -0
+
+	dev_info(dev, "Xilinx PS2 at 0x%08X mapped to 0x%08X, irq=%d\n",
+		drvdata->phys_addr, (u32)drvdata->base_address, drvdata->irq);
+

drivers/input/serio/xilinx_ps2.c line 336

Quoted 10 lines
drivers/input/serio/xilinx_ps2.c new file +10 -0
+	drvdata->serio.id.type = SERIO_8042;
+	drvdata->serio.write = sxps2_write;
+	drvdata->serio.open = sxps2_open;
+	drvdata->serio.close = sxps2_close;
+	drvdata->serio.port_data = drvdata;
+	drvdata->serio.dev.parent = dev;
+	snprintf(drvdata->serio.name, sizeof(drvdata->serio.name),
+		 XPS2_NAME_DESC, id);
+	snprintf(drvdata->serio.phys, sizeof(drvdata->serio.phys),
+		 XPS2_PHYS_DESC, id);

I bet if you make a temp variable for drvdata->serio the code size wil shrink a tiny bit.

Signature · 1 line
Dmitry
author
#4 lore raw

Thanks Dmitry, see my comments inline.

-- John

Quoted 5 lines · John Linn

drivers/input/serio/xilinx_ps2.c line 284

Quoted 2 lines
drivers/input/serio/xilinx_ps2.c new file +2 -0
+	spin_lock_init(&drvdata->lock);
+	dev_set_drvdata(dev, (void *)drvdata);

No need to cast to void *.

OK.

Quoted 11 lines

drivers/input/serio/xilinx_ps2.c

Quoted 11 lines
drivers/input/serio/xilinx_ps2.c new file +10 -0
+
+	if (!regs_res || !irq_res) {
+		dev_err(dev, "IO resource(s) not found\n");
+		retval = -EFAULT;
+		goto failed1;
+	}
+
+	drvdata->irq = irq_res->start;
+	remap_size = regs_res->end - regs_res->start + 1;
+	if (!request_mem_region(regs_res->start, remap_size,

DRIVER_NAME)) {

Quoted 22 lines
Quoted 22 lines
drivers/input/serio/xilinx_ps2.c new file +22 -0
+
+		dev_err(dev, "Couldn't lock memory region at 0x%08X\n",
+			(unsigned int)regs_res->start);
+		retval = -EBUSY;
+		goto failed1;
+	}
+
+	/* Fill in configuration data and add them to the list */
+	drvdata->phys_addr = regs_res->start;
+	drvdata->remap_size = remap_size;
+	drvdata->base_address = ioremap(regs_res->start, remap_size);
+	if (drvdata->base_address == NULL) {
+
+		dev_err(dev, "Couldn't ioremap memory at 0x%08X\n",
+			(unsigned int)regs_res->start);
+		retval = -EFAULT;
+		goto failed2;
+	}
+
+	/* Initialize the PS/2 interface */
+	down(&cfg_sem);
+	if (xps2_initialize(drvdata)) {
Quoted 9 lines

drivers/input/serio/xilinx_ps2.c line 322

Quoted 6 lines
drivers/input/serio/xilinx_ps2.c new file +6 -0
+		up(&cfg_sem);
+		dev_err(dev, "Could not initialize device\n");
+		retval = -ENODEV;
+		goto failed3;
+	}
+	up(&cfg_sem);

Do you need a counting semaphore here?

Seems like a simpler kind of mutal exclusion would do the job, like a spinlock.
Looks like mutual exclusion is needed as the device contains 2 ps2 controllers.

Quoted 3 lines

drivers/input/serio/xilinx_ps2.c

Quoted 3 lines
drivers/input/serio/xilinx_ps2.c new file +3 -0
+
+	dev_info(dev, "Xilinx PS2 at 0x%08X mapped to 0x%08X, irq=%d\n",
+		drvdata->phys_addr, (u32)drvdata->base_address,

drvdata->irq);

Quoted 6 lines
Quoted 6 lines
drivers/input/serio/xilinx_ps2.c new file +6 -0
+
+	drvdata->serio.id.type = SERIO_8042;
+	drvdata->serio.write = sxps2_write;
+	drvdata->serio.open = sxps2_open;
+	drvdata->serio.close = sxps2_close;
+	drvdata->serio.port_data = drvdata;
Quoted 8 lines

drivers/input/serio/xilinx_ps2.c line 336

Quoted 5 lines
drivers/input/serio/xilinx_ps2.c new file +5 -0
+	drvdata->serio.dev.parent = dev;
+	snprintf(drvdata->serio.name, sizeof(drvdata->serio.name),
+		 XPS2_NAME_DESC, id);
+	snprintf(drvdata->serio.phys, sizeof(drvdata->serio.phys),
+		 XPS2_PHYS_DESC, id);

I bet if you make a temp variable for drvdata->serio the code size wil shrink a tiny bit.

Ok, not sure the complexity of the temp is worth the tiny code shrinkage.
I would think the compiler should optimize it as well but your experience
must say otherwise.

Quoted 4 lines
Signature · 2 lines
-- 
Dmitry

-----Original Message-----
From: Dmitry Torokhov [mailto:[email protected]]
Sent: Monday, June 30, 2008 12:21 PM
To: John Linn
Cc: [email protected]; [email protected]; Sadanand Mutyala
Subject: Re: [PATCH] [V2] powerpc: Xilinx: PS2: Added new XPS PS2 driver

drivers/input/serio/xilinx_ps2.c line 284

Quoted 2 lines · John Linn
drivers/input/serio/xilinx_ps2.c new file +2 -0
+	spin_lock_init(&drvdata->lock);
+	dev_set_drvdata(dev, (void *)drvdata);

No need to cast to void *.

drivers/input/serio/xilinx_ps2.c

Quoted 10 lines
drivers/input/serio/xilinx_ps2.c new file +10 -0
+
+	if (!regs_res || !irq_res) {
+		dev_err(dev, "IO resource(s) not found\n");
+		retval = -EFAULT;
+		goto failed1;
+	}
+
+	drvdata->irq = irq_res->start;
+	remap_size = regs_res->end - regs_res->start + 1;
+	if (!request_mem_region(regs_res->start, remap_size,

DRIVER_NAME)) {

Quoted 18 lines
drivers/input/serio/xilinx_ps2.c new file +18 -0
+
+		dev_err(dev, "Couldn't lock memory region at 0x%08X\n",
+			(unsigned int)regs_res->start);
+		retval = -EBUSY;
+		goto failed1;
+	}
+
+	/* Fill in configuration data and add them to the list */
+	drvdata->phys_addr = regs_res->start;
+	drvdata->remap_size = remap_size;
+	drvdata->base_address = ioremap(regs_res->start, remap_size);
+	if (drvdata->base_address == NULL) {
+
+		dev_err(dev, "Couldn't ioremap memory at 0x%08X\n",
+			(unsigned int)regs_res->start);
+		retval = -EFAULT;
+		goto failed2;
+	}

drivers/input/serio/xilinx_ps2.c line 322

Quoted 10 lines
drivers/input/serio/xilinx_ps2.c new file +10 -0
+
+	/* Initialize the PS/2 interface */
+	down(&cfg_sem);
+	if (xps2_initialize(drvdata)) {
+		up(&cfg_sem);
+		dev_err(dev, "Could not initialize device\n");
+		retval = -ENODEV;
+		goto failed3;
+	}
+	up(&cfg_sem);

Do you need a counting semaphore here?

drivers/input/serio/xilinx_ps2.c

Quoted 3 lines
drivers/input/serio/xilinx_ps2.c new file +3 -0
+
+	dev_info(dev, "Xilinx PS2 at 0x%08X mapped to 0x%08X, irq=%d\n",
+		drvdata->phys_addr, (u32)drvdata->base_address,

drvdata->irq);

drivers/input/serio/xilinx_ps2.c line 336

Quoted 11 lines
drivers/input/serio/xilinx_ps2.c new file +11 -0
+
+	drvdata->serio.id.type = SERIO_8042;
+	drvdata->serio.write = sxps2_write;
+	drvdata->serio.open = sxps2_open;
+	drvdata->serio.close = sxps2_close;
+	drvdata->serio.port_data = drvdata;
+	drvdata->serio.dev.parent = dev;
+	snprintf(drvdata->serio.name, sizeof(drvdata->serio.name),
+		 XPS2_NAME_DESC, id);
+	snprintf(drvdata->serio.phys, sizeof(drvdata->serio.phys),
+		 XPS2_PHYS_DESC, id);

I bet if you make a temp variable for drvdata->serio the code size wil shrink a tiny bit.

Signature · 4 lines
Dmitry


This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.