* [PATCHv2 0/3] ARM:sunxi:ps2 Added support for A10/A20 ps2 controller.
@ 2014-12-06 23:15 vishnupatekar
[not found] ` <1417907719-26775-1-git-send-email-VishnuPatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 12+ messages in thread
From: vishnupatekar @ 2014-12-06 23:15 UTC (permalink / raw)
To: linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
linux-lFZ/pmaqli7XmaaqVzeoHQ
Cc: leafy.myeh-Q9AEpCAkrSgqDJ6do+/SaQ, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
pawel.moll-5wv7dgnIgG8, mark.rutland-5wv7dgnIgG8,
ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
galak-sgV2jX0FEOL9JmXXK+q4OQ, devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, vishnupatekar
Here is v2 of SUNXI PS2 controller support patch-set as with v1.
Changes in v2:
1. added default n depends on ARCH_SUNXI || COMPILE_TEST in Kconfig.
2. handled errors and free resources on errors.
3. used BIT(x), DIV_ROUND_UP macros.
4. corrected style errors.
5. added support for A10 also, A10 and A2 have same properties of PS2 controller.
6. by default commented ps20 and ps21 nodes,as ps20 pins conflict with HDMI
connector on Lime2 Board.
7. added compatible as allwinner,sun4i-a10-ps2.
8. corrected the possible race condition.
Patch 0 Summary: Allwinner A10/A20 PS2 controller. These modifications are
for PS2 host controller. IBM compliant IBM PS2 and AT-compatible
keyboard and mouse can be connected.
Patch 1 device tree bindings.
Patch 2 adds support for sun7i ps2 driver.
Patch 3 device tree support for PS2 controller.
1) Added A10/A20 ps2 nodes to the dtsi
2) Added A10/A20 ps2 pinmux to the dtsi
3) Added ps2 nodes to the lime2 dts file
vishnupatekar (3):
sunxi:dts-bindings:input:ps2 bindings for A10/A20 ps2.
sunxi:drivers:input:ps2 Added sunxi A10/A20 ps2 driver
ARM:dts:sunxi:ps2 dt nodes for A10/A20 PS2 controller.
.../bindings/input/allwinner,sunxi-ps2.txt | 23 ++
arch/arm/boot/dts/sun4i-a10.dtsi | 27 ++
arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts | 13 +
arch/arm/boot/dts/sun7i-a20.dtsi | 29 ++
drivers/input/serio/Kconfig | 10 +
drivers/input/serio/Makefile | 1 +
drivers/input/serio/sunxi-ps2.c | 364 ++++++++++++++++++++
7 files changed, 467 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/allwinner,sunxi-ps2.txt
create mode 100644 drivers/input/serio/sunxi-ps2.c
--
1.7.9.5
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCHv2 1/3] sunxi:dts-bindings:input:ps2 bindings for A10/A20 ps2.
[not found] ` <1417907719-26775-1-git-send-email-VishnuPatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2014-12-06 23:15 ` vishnupatekar
2014-12-08 22:15 ` Maxime Ripard
2014-12-06 23:15 ` [PATCHv2 2/3] sunxi:drivers:input:ps2 Added sunxi A10/A20 ps2 driver vishnupatekar
` (2 subsequent siblings)
3 siblings, 1 reply; 12+ messages in thread
From: vishnupatekar @ 2014-12-06 23:15 UTC (permalink / raw)
To: linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
linux-lFZ/pmaqli7XmaaqVzeoHQ
Cc: leafy.myeh-Q9AEpCAkrSgqDJ6do+/SaQ, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
pawel.moll-5wv7dgnIgG8, mark.rutland-5wv7dgnIgG8,
ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
galak-sgV2jX0FEOL9JmXXK+q4OQ, devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, vishnupatekar
A10 and A20 have same PS2 addresses, clocks, interrupts.
added compatible as allwinner,sun4i-a10-ps2.
Signed-off-by: vishnupatekar <VishnuPatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
.../bindings/input/allwinner,sunxi-ps2.txt | 23 ++++++++++++++++++++
1 file changed, 23 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/allwinner,sunxi-ps2.txt
diff --git a/Documentation/devicetree/bindings/input/allwinner,sunxi-ps2.txt b/Documentation/devicetree/bindings/input/allwinner,sunxi-ps2.txt
new file mode 100644
index 0000000..3a8919a
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/allwinner,sunxi-ps2.txt
@@ -0,0 +1,23 @@
+* Device tree bindings for Allwinner A10, A20 PS2 host controller
+
+A20 PS2 is dual role controller(PS2 host and PS2 device). These bindings are for PS2 host controller.
+IBM compliant IBM PS2 and AT-compatible keyboard and mouse can be connected.
+
+Required properties:
+
+ - reg : Offset and length of the register set for the device.
+ - compatible : Should one of the following:
+ - "allwinner,sun7i-a20-ps2"
+ - "allwinner,sun4i-a10-ps2"
+ - interrupts : The interrupt line connected to the PS2.
+ - clocks : The gate clk connected to the PS2.
+
+
+Example:
+ ps20: ps2@0x01c2a000 {
+ compatible = "allwinner,sun7i-a20-ps2";
+ reg = <0x01c2a000 0x400>;
+ interrupts = <0 62 4>;
+ clocks = <&apb1_gates 6>;
+ status = "disabled";
+ };
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCHv2 2/3] sunxi:drivers:input:ps2 Added sunxi A10/A20 ps2 driver
[not found] ` <1417907719-26775-1-git-send-email-VishnuPatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-12-06 23:15 ` [PATCHv2 1/3] sunxi:dts-bindings:input:ps2 bindings for A10/A20 ps2 vishnupatekar
@ 2014-12-06 23:15 ` vishnupatekar
[not found] ` <1417907719-26775-3-git-send-email-VishnuPatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-12-06 23:15 ` [PATCHv2 3/3] ARM:dts:sunxi:ps2 dt nodes for A10/A20 PS2 controller vishnupatekar
2014-12-12 13:15 ` [PATCHv2 0/3] ARM:sunxi:ps2 Added support for A10/A20 ps2 controller Hans de Goede
3 siblings, 1 reply; 12+ messages in thread
From: vishnupatekar @ 2014-12-06 23:15 UTC (permalink / raw)
To: linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
linux-lFZ/pmaqli7XmaaqVzeoHQ
Cc: leafy.myeh-Q9AEpCAkrSgqDJ6do+/SaQ, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
pawel.moll-5wv7dgnIgG8, mark.rutland-5wv7dgnIgG8,
ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
galak-sgV2jX0FEOL9JmXXK+q4OQ, devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, vishnupatekar
-added compatible as allwinner,sun4i-a10-ps2 and allwinner,sun7i-a20-ps2.
- added default n depends on ARCH_SUNXI || COMPILE_TEST
in Kconfig.
-handled errors and free resources on errors.
-used BIT(x), DIV_ROUND_UP macros.
-corrected style errors.
Signed-off-by: vishnupatekar <VishnuPatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
drivers/input/serio/Kconfig | 10 ++
drivers/input/serio/Makefile | 1 +
drivers/input/serio/sunxi-ps2.c | 364 +++++++++++++++++++++++++++++++++++++++
3 files changed, 375 insertions(+)
create mode 100644 drivers/input/serio/sunxi-ps2.c
diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig
index bc2d474..3a7599c 100644
--- a/drivers/input/serio/Kconfig
+++ b/drivers/input/serio/Kconfig
@@ -281,4 +281,14 @@ config HYPERV_KEYBOARD
To compile this driver as a module, choose M here: the module will
be called hyperv_keyboard.
+config SERIO_SUNXI_PS2
+ tristate "Allwinner Sun4i-A10/Sun7i-A20 PS/2 controller"
+ default n
+ depends on ARCH_SUNXI || COMPILE_TEST
+ help
+ Say Y here if you have Sun4i-A10/Sun7i-A20 Allwinner PS/2 ports.
+
+ To compile this driver as a module, choose M here: the
+ module will be called sunxi-ps2.
+
endif
diff --git a/drivers/input/serio/Makefile b/drivers/input/serio/Makefile
index 815d874..0fa0f78 100644
--- a/drivers/input/serio/Makefile
+++ b/drivers/input/serio/Makefile
@@ -29,3 +29,4 @@ obj-$(CONFIG_SERIO_ARC_PS2) += arc_ps2.o
obj-$(CONFIG_SERIO_APBPS2) += apbps2.o
obj-$(CONFIG_SERIO_OLPC_APSP) += olpc_apsp.o
obj-$(CONFIG_HYPERV_KEYBOARD) += hyperv-keyboard.o
+obj-$(CONFIG_SERIO_SUNXI_PS2) += sunxi-ps2.o
diff --git a/drivers/input/serio/sunxi-ps2.c b/drivers/input/serio/sunxi-ps2.c
new file mode 100644
index 0000000..4cd89ae
--- /dev/null
+++ b/drivers/input/serio/sunxi-ps2.c
@@ -0,0 +1,364 @@
+/*
+ * Driver for Allwinner A20 PS2 host controller
+ *
+ * Author: Vishnu Patekar <vishnupatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
+ * Aaron.maoye <leafy.myeh-Q9AEpCAkrSgqDJ6do+/SaQ@public.gmane.org>
+ *
+ * Based on 3.0 kernel
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/serio.h>
+#include <linux/interrupt.h>
+#include <linux/errno.h>
+#include <linux/slab.h>
+#include <linux/list.h>
+#include <linux/io.h>
+#include <linux/of_address.h>
+#include <linux/of_device.h>
+#include <linux/of_irq.h>
+#include <linux/of_platform.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+
+#define DRIVER_NAME "sunxi-ps2"
+
+/* register offset definitions */
+#define PS2_REG_GCTL (0x00) /* PS2 Module Global Control Reg */
+#define PS2_REG_DATA (0x04) /* PS2 Module Data Reg */
+#define PS2_REG_LCTL (0x08) /* PS2 Module Line Control Reg */
+#define PS2_REG_LSTS (0x0C) /* PS2 Module Line Status Reg */
+#define PS2_REG_FCTL (0x10) /* PS2 Module FIFO Control Reg */
+#define PS2_REG_FSTS (0x14) /* PS2 Module FIFO Status Reg */
+#define PS2_REG_CLKDR (0x18) /* PS2 Module Clock Divider Reg*/
+
+/* PS2 GLOBAL CONTROL REGISTER PS2_GCTL */
+#define PS2_GCTL_INTFLAG BIT(4)
+#define PS2_GCTL_INTEN BIT(3)
+#define PS2_GCTL_RESET BIT(2)
+#define PS2_GCTL_MASTER BIT(1)
+#define PS2_GCTL_BUSEN BIT(0)
+
+/* PS2 LINE CONTROL REGISTER */
+#define PS2_LCTL_NOACK BIT(18)
+#define PS2_LCTL_TXDTOEN BIT(8)
+#define PS2_LCTL_STOPERREN BIT(3)
+#define PS2_LCTL_ACKERREN BIT(2)
+#define PS2_LCTL_PARERREN BIT(1)
+#define PS2_LCTL_RXDTOEN BIT(0)
+
+/* PS2 LINE STATUS REGISTER */
+#define PS2_LSTS_TXTDO BIT(8)
+#define PS2_LSTS_STOPERR BIT(3)
+#define PS2_LSTS_ACKERR BIT(2)
+#define PS2_LSTS_PARERR BIT(1)
+#define PS2_LSTS_RXTDO BIT(0)
+
+/* PS2 FIFO CONTROL REGISTER */
+#define PS2_FCTL_TXRST BIT(17)
+#define PS2_FCTL_RXRST BIT(16)
+#define PS2_FCTL_TXUFIEN BIT(10)
+#define PS2_FCTL_TXOFIEN BIT(9)
+#define PS2_FCTL_TXRDYIEN BIT(8)
+#define PS2_FCTL_RXUFIEN BIT(2)
+#define PS2_FCTL_RXOFIEN BIT(1)
+#define PS2_FCTL_RXRDYIEN BIT(0)
+
+/* PS2 FIFO STATUS REGISTER */
+#define PS2_FSTS_TXUF BIT(10)
+#define PS2_FSTS_TXOF BIT(9)
+#define PS2_FSTS_TXRDY BIT(8)
+#define PS2_FSTS_RXUF BIT(2)
+#define PS2_FSTS_RXOF BIT(1)
+#define PS2_FSTS_RXRDY BIT(0)
+
+
+#define PS2_LINE_ERROR_BIT \
+ (PS2_LSTS_TXTDO|PS2_LSTS_STOPERR|PS2_LSTS_ACKERR| \
+ PS2_LSTS_PARERR|PS2_LSTS_RXTDO)
+
+#define PS2_FIFO_ERROR_BIT \
+ (PS2_FSTS_TXUF|PS2_FSTS_TXOF|PS2_FSTS_TXRDY|PS2_FSTS_RXUF| \
+ PS2_FSTS_RXOF|PS2_FSTS_RXRDY)
+
+#define PS2_SAMPLE_CLK (1000000)
+#define PS2_SCLK (125000)
+
+struct sunxips2data {
+ struct serio *serio;
+ struct device *dev;
+
+ /* IO mapping base */
+ void __iomem *reg_base;
+
+ /* clock management */
+ struct clk *clk;
+
+ /* irq */
+ spinlock_t lock;
+ int irq;
+};
+
+/*********************/
+/* Interrupt handler */
+/*********************/
+static irqreturn_t sunxips2_interrupt(int irq, void *dev_id)
+{
+ struct sunxips2data *drvdata = dev_id;
+ u32 intr_status;
+ u32 fifo_status;
+ unsigned char byte;
+ u32 rval;
+ u32 error = 0;
+
+ spin_lock(&drvdata->lock);
+
+ /* Get the PS/2 interrupts and clear them */
+ intr_status = readl(drvdata->reg_base + PS2_REG_LSTS);
+ fifo_status = readl(drvdata->reg_base + PS2_REG_FSTS);
+
+ /*Check Line Status Register*/
+ if (intr_status & 0x10f) {
+ if (intr_status & PS2_LSTS_STOPERR)
+ dev_info(drvdata->dev, "PS/2 Stop Bit Error!");
+ if (intr_status & PS2_LSTS_ACKERR)
+ dev_info(drvdata->dev, "PS/2 Acknowledge Error!\n");
+ if (intr_status & PS2_LSTS_PARERR)
+ dev_info(drvdata->dev, "PS/2 Parity Error!\n");
+ if (intr_status & PS2_LSTS_TXTDO)
+ dev_info(drvdata->dev, "PS/2 Transmit Data Timeout!\n");
+ if (intr_status & PS2_LSTS_RXTDO)
+ dev_info(drvdata->dev, "PS/2 Receive Data Timeout!\n");
+
+ /*reset PS/2 controller*/
+ writel(readl(drvdata->reg_base + PS2_REG_GCTL) | PS2_GCTL_RESET,
+ drvdata->reg_base + PS2_REG_GCTL);
+
+ rval = PS2_LSTS_TXTDO | PS2_LSTS_STOPERR | PS2_LSTS_ACKERR |
+ PS2_LSTS_PARERR | PS2_LSTS_RXTDO;
+ writel(rval, drvdata->reg_base + PS2_REG_LSTS);
+ error = 1;
+ }
+
+ /*Check FIFO Status Register*/
+ if (fifo_status & 0x0606) {
+ if (fifo_status & PS2_FSTS_TXUF)
+ dev_info(drvdata->dev, "PS/2 Tx FIFO Underflow!\n");
+ if (fifo_status & PS2_FSTS_TXOF)
+ dev_info(drvdata->dev, "PS/2 Tx FIFO Overflow!\n");
+ if (fifo_status & PS2_FSTS_RXUF)
+ dev_info(drvdata->dev, "PS/2 Rx FIFO Underflow!\n");
+ if (fifo_status & PS2_FSTS_RXOF)
+ dev_info(drvdata->dev, "PS/2 Rx FIFO Overflow!\n");
+ /*reset PS/2 controller*/
+ writel(readl(drvdata->reg_base + PS2_REG_GCTL) | PS2_GCTL_RESET,
+ drvdata->reg_base + PS2_REG_GCTL);
+
+ rval = PS2_FSTS_TXUF | PS2_FSTS_TXOF | PS2_FSTS_TXRDY |
+ PS2_FSTS_RXUF | PS2_FSTS_RXOF | PS2_FSTS_RXRDY;
+ writel(rval, drvdata->reg_base + PS2_REG_FSTS);
+ error = 1;
+ }
+
+ rval = (fifo_status >> 16) & 0x3;
+ while (!error && rval--) {
+ byte = readl(drvdata->reg_base + PS2_REG_DATA) & 0xff;
+ /* dev_info(drvdata->dev, "PS/2 Receive %02x\n", byte); */
+ serio_interrupt(drvdata->serio, byte, 0);
+ }
+
+ writel(intr_status, drvdata->reg_base + PS2_REG_LSTS);
+ writel(fifo_status, drvdata->reg_base + PS2_REG_FSTS);
+
+ spin_unlock(&drvdata->lock);
+
+ return IRQ_HANDLED;
+}
+
+
+static int sunxips2_open(struct serio *pserio)
+{
+ struct sunxips2data *drvdata = pserio->port_data;
+ u32 src_clk = 0;
+ u32 clk_scdf;
+ u32 clk_pcdf;
+ u32 rval;
+
+ /*Set Line Control And Enable Interrupt*/
+ rval = PS2_LCTL_TXDTOEN | PS2_LCTL_STOPERREN | PS2_LCTL_ACKERREN
+ | PS2_LCTL_PARERREN | PS2_LCTL_RXDTOEN;
+ writel(rval, drvdata->reg_base + PS2_REG_LCTL);
+
+ /*Reset FIFO*/
+ rval = PS2_FCTL_TXRST|PS2_FCTL_RXRST|PS2_FCTL_TXUFIEN|PS2_FCTL_TXOFIEN
+ |PS2_FCTL_RXUFIEN|PS2_FCTL_RXOFIEN|PS2_FCTL_RXRDYIEN;
+ writel(rval, drvdata->reg_base + PS2_REG_FCTL);
+
+ src_clk = clk_get_rate(drvdata->clk);
+
+ if (!src_clk) {
+ dev_info(drvdata->dev, "w_ps2c_set_sclk error, source clock is 0.");
+ return -1;
+ }
+
+ /*Set Clock Divider Register*/
+ clk_scdf = DIV_ROUND_UP(src_clk, PS2_SAMPLE_CLK) - 1;
+ clk_pcdf = DIV_ROUND_UP(PS2_SAMPLE_CLK, PS2_SCLK) - 1;
+ rval = (clk_scdf<<8) | clk_pcdf;
+ writel(rval, drvdata->reg_base + PS2_REG_CLKDR);
+
+ /*Set Global Control Register*/
+ rval = PS2_GCTL_RESET | PS2_GCTL_INTEN | PS2_GCTL_MASTER
+ | PS2_GCTL_BUSEN;
+ writel(rval, drvdata->reg_base + PS2_REG_GCTL);
+
+ return 0;
+}
+
+static void sunxips2_close(struct serio *pserio)
+{
+ struct sunxips2data *drvdata = pserio->port_data;
+ unsigned long flags;
+
+ spin_lock_irqsave(&drvdata->lock, flags);
+ /* Disable the PS2 interrupts */
+ writel(0, drvdata->reg_base + PS2_REG_GCTL);
+ spin_unlock_irqrestore(&drvdata->lock, flags);
+}
+
+static int sunxips2_write(struct serio *pserio, unsigned char val)
+{
+ unsigned long expire = jiffies + msecs_to_jiffies(10000);
+ struct sunxips2data *drvdata = (struct sunxips2data *)pserio->port_data;
+
+ do {
+ if (readl(drvdata->reg_base + PS2_REG_FSTS) & PS2_FSTS_TXRDY) {
+ writel(val, drvdata->reg_base + PS2_REG_DATA);
+ return 0;
+ }
+ } while (time_before(jiffies, expire));
+
+ return 0;
+}
+
+static int sunxips2_probe(struct platform_device *pdev)
+{
+ struct resource *res; /* IO mem resources */
+ struct sunxips2data *drvdata;
+ struct serio *serio;
+ struct device *dev = &pdev->dev;
+ unsigned int irq;
+ int error;
+
+ drvdata = devm_kzalloc(dev, sizeof(struct sunxips2data), GFP_KERNEL);
+ serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
+ if (!drvdata || !serio) {
+ error = -ENOMEM;
+ goto err_free_mem;
+ }
+
+ spin_lock_init(&drvdata->lock);
+
+ /* IO */
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ drvdata->reg_base = devm_ioremap_resource(dev, res);
+ if (IS_ERR(drvdata->reg_base)) {
+ dev_err(dev, "failed to map registers\n");
+ error = PTR_ERR(drvdata->reg_base);
+ goto err_free_mem;
+ }
+
+ drvdata->clk = devm_clk_get(dev, NULL);
+ if (!IS_ERR(drvdata->clk)) {
+ error = clk_prepare_enable(drvdata->clk);
+ if (error < 0) {
+ dev_err(dev, "failed to enable clock %d\n", error);
+ goto err_free_mem;
+ }
+ } else {
+ error = PTR_ERR(drvdata->clk);
+ dev_err(dev, "couldn't get clock %d\n", error);
+ goto err_free_mem;
+ }
+
+ serio->id.type = SERIO_8042;
+ serio->write = sunxips2_write;
+ serio->open = sunxips2_open;
+ serio->close = sunxips2_close;
+ serio->port_data = drvdata;
+ serio->dev.parent = dev;
+ strlcpy(serio->name, dev_name(dev), sizeof(serio->name));
+ strlcpy(serio->phys, dev_name(dev), sizeof(serio->phys));
+
+ /* Get IRQ for the device */
+ irq = platform_get_irq(pdev, 0);
+ if (!irq) {
+ dev_err(dev, "no IRQ found\n");
+ error = -ENXIO;
+ goto error_disable_clk;
+ }
+
+ drvdata->irq = irq;
+ drvdata->serio = serio;
+ drvdata->dev = dev;
+ error = devm_request_threaded_irq(dev, drvdata->irq,
+ sunxips2_interrupt, NULL, 0, DRIVER_NAME, drvdata);
+
+ if (error) {
+ dev_err(drvdata->dev, "Interrupt alloc failed %d:error:%d\n",
+ drvdata->irq, error);
+ goto error_disable_clk;
+ }
+
+ serio_register_port(serio);
+ platform_set_drvdata(pdev, drvdata);
+
+ return 0; /* success */
+
+error_disable_clk:
+ clk_disable_unprepare(drvdata->clk);
+
+err_free_mem:
+ kfree(serio);
+ return error;
+}
+
+static int sunxips2_remove(struct platform_device *pdev)
+{
+ struct sunxips2data *drvdata = platform_get_drvdata(pdev);
+
+ serio_unregister_port(drvdata->serio);
+ disable_irq(drvdata->irq);
+
+ if (!IS_ERR(drvdata->clk))
+ clk_disable_unprepare(drvdata->clk);
+ kfree(drvdata->serio);
+
+ return 0;
+}
+
+/* Match table for of_platform binding */
+static const struct of_device_id sunxips2_of_match[] = {
+ { .compatible = "allwinner,sun7i-a20-ps2", },
+ { .compatible = "allwinner,sun4i-a10-ps2", },
+ { },
+};
+
+MODULE_DEVICE_TABLE(of, sunxips2_of_match);
+
+/*platform driver structure*/
+static struct platform_driver sunxips2_of_driver = {
+ .probe = sunxips2_probe,
+ .remove = sunxips2_remove,
+ .driver = {
+ .name = DRIVER_NAME,
+ .of_match_table = sunxips2_of_match,
+ },
+};
+module_platform_driver(sunxips2_of_driver);
+
+MODULE_AUTHOR("Vishnu Patekar <vishnupatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>");
+MODULE_AUTHOR("Aaron.maoye <leafy.myeh-Q9AEpCAkrSgqDJ6do+/SaQ@public.gmane.org>");
+MODULE_DESCRIPTION("Sunxi PS/2 driver");
+MODULE_LICENSE("GPL");
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCHv2 3/3] ARM:dts:sunxi:ps2 dt nodes for A10/A20 PS2 controller.
[not found] ` <1417907719-26775-1-git-send-email-VishnuPatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-12-06 23:15 ` [PATCHv2 1/3] sunxi:dts-bindings:input:ps2 bindings for A10/A20 ps2 vishnupatekar
2014-12-06 23:15 ` [PATCHv2 2/3] sunxi:drivers:input:ps2 Added sunxi A10/A20 ps2 driver vishnupatekar
@ 2014-12-06 23:15 ` vishnupatekar
[not found] ` <1417907719-26775-4-git-send-email-VishnuPatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-12-12 13:15 ` [PATCHv2 0/3] ARM:sunxi:ps2 Added support for A10/A20 ps2 controller Hans de Goede
3 siblings, 1 reply; 12+ messages in thread
From: vishnupatekar @ 2014-12-06 23:15 UTC (permalink / raw)
To: linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
linux-lFZ/pmaqli7XmaaqVzeoHQ
Cc: leafy.myeh-Q9AEpCAkrSgqDJ6do+/SaQ, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
pawel.moll-5wv7dgnIgG8, mark.rutland-5wv7dgnIgG8,
ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
galak-sgV2jX0FEOL9JmXXK+q4OQ, devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, vishnupatekar
Added ps2 nodes in lime2 board dts. By default ps20 and ps21 nodes are
commented as ps20 pins conflict with HDMI connector
on Lime2 Board.
Signed-off-by: vishnupatekar <VishnuPatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
arch/arm/boot/dts/sun4i-a10.dtsi | 27 +++++++++++++++++++++
arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts | 13 ++++++++++
arch/arm/boot/dts/sun7i-a20.dtsi | 29 +++++++++++++++++++++++
3 files changed, 69 insertions(+)
diff --git a/arch/arm/boot/dts/sun4i-a10.dtsi b/arch/arm/boot/dts/sun4i-a10.dtsi
index 5e2ec2d..4726e8d 100644
--- a/arch/arm/boot/dts/sun4i-a10.dtsi
+++ b/arch/arm/boot/dts/sun4i-a10.dtsi
@@ -615,6 +615,19 @@
allwinner,drive = <0>;
allwinner,pull = <0>;
};
+ ps2_0_pins: ps2_0@0 {
+ allwinner,pins = "PI20","PI21";
+ allwinner,function = "ps2";
+ allwinner,drive = <0>;
+ allwinner,pull = <0>;
+ };
+ ps2_1_pins: ps2_1@0 {
+ allwinner,pins = "PH12","PH13";
+ allwinner,function = "ps2";
+ allwinner,drive = <0>;
+ allwinner,pull = <0>;
+ };
+
};
timer@01c20c00 {
@@ -781,5 +794,19 @@
#address-cells = <1>;
#size-cells = <0>;
};
+ ps20: ps2@0x01c2a000 {
+ compatible = "allwinner,sun4i-a10-ps2";
+ reg = <0x01c2a000 0x400>;
+ interrupts = <0 62 4>;
+ clocks = <&apb1_gates 6>;
+ status = "disabled";
+ };
+ ps21: ps2@0x01c2a400 {
+ compatible = "allwinner,sun4i-a10-ps2";
+ reg = <0x01c2a400 0x400>;
+ interrupts = <0 63 4>;
+ clocks = <&apb1_gates 7>;
+ status = "disabled";
+ };
};
};
diff --git a/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts b/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts
index ed364d5..5624e63 100644
--- a/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts
+++ b/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts
@@ -112,6 +112,19 @@
pinctrl-0 = <&uart0_pins_a>;
status = "okay";
};
+ /* PS2 0 and PS2 1 are disabled by default
+ To enable PS2 0 and PS2 1 uncomment below ps20 and ps21 nodes
+ Please note that ps20 pins conflict with HDMI on Lime2 Board*/
+ /*ps20: ps2@0x01c2a000 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&ps2_0_pins>;
+ status = "okay";
+ };
+ ps21: ps2@0x01c2a400 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&ps2_1_pins>;
+ status = "okay";
+ };*/
i2c0: i2c@01c2ac00 {
pinctrl-names = "default";
diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi b/arch/arm/boot/dts/sun7i-a20.dtsi
index 8605f2b..96fe37d 100644
--- a/arch/arm/boot/dts/sun7i-a20.dtsi
+++ b/arch/arm/boot/dts/sun7i-a20.dtsi
@@ -852,6 +852,19 @@
allwinner,drive = <0>;
allwinner,pull = <0>;
};
+ ps2_0_pins: ps2_0@0 {
+ allwinner,pins = "PI20","PI21";
+ allwinner,function = "ps2";
+ allwinner,drive = <0>;
+ allwinner,pull = <0>;
+ };
+ ps2_1_pins: ps2_1@0 {
+ allwinner,pins = "PH12","PH13";
+ allwinner,function = "ps2";
+ allwinner,drive = <0>;
+ allwinner,pull = <0>;
+ };
+
};
timer@01c20c00 {
@@ -1079,5 +1092,21 @@
#interrupt-cells = <3>;
interrupts = <1 9 0xf04>;
};
+ ps20: ps2@0x01c2a000 {
+ compatible = "allwinner,sun7i-a20-ps2";
+ reg = <0x01c2a000 0x400>;
+ interrupts = <0 62 4>;
+ clocks = <&apb1_gates 6>;
+ status = "disabled";
+ };
+ ps21: ps2@0x01c2a400 {
+ compatible = "allwinner,sun7i-a20-ps2";
+ reg = <0x01c2a400 0x400>;
+ interrupts = <0 63 4>;
+ clocks = <&apb1_gates 7>;
+ status = "disabled";
+ };
+
+
};
};
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCHv2 2/3] sunxi:drivers:input:ps2 Added sunxi A10/A20 ps2 driver
[not found] ` <1417907719-26775-3-git-send-email-VishnuPatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2014-12-08 4:43 ` Vishnu Patekar
2014-12-08 22:41 ` Maxime Ripard
1 sibling, 0 replies; 12+ messages in thread
From: Vishnu Patekar @ 2014-12-08 4:43 UTC (permalink / raw)
To: linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org,
dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org,
linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org
Cc: leafy.myeh-Q9AEpCAkrSgqDJ6do+/SaQ@public.gmane.org,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
pawel.moll-5wv7dgnIgG8@public.gmane.org,
mark.rutland-5wv7dgnIgG8@public.gmane.org,
ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org,
galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
vishnupatekar
[-- Attachment #1: Type: text/plain, Size: 15878 bytes --]
On Sunday, December 7, 2014, vishnupatekar <vishnupatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> -added compatible as allwinner,sun4i-a10-ps2 and allwinner,sun7i-a20-ps2.
> - added default n depends on ARCH_SUNXI || COMPILE_TEST
> in Kconfig.
> -handled errors and free resources on errors.
> -used BIT(x), DIV_ROUND_UP macros.
> -corrected style errors.
>
> Signed-off-by: vishnupatekar <VishnuPatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:;>>
> ---
> drivers/input/serio/Kconfig | 10 ++
> drivers/input/serio/Makefile | 1 +
> drivers/input/serio/sunxi-ps2.c | 364
> +++++++++++++++++++++++++++++++++++++++
> 3 files changed, 375 insertions(+)
> create mode 100644 drivers/input/serio/sunxi-ps2.c
>
> diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig
> index bc2d474..3a7599c 100644
> --- a/drivers/input/serio/Kconfig
> +++ b/drivers/input/serio/Kconfig
> @@ -281,4 +281,14 @@ config HYPERV_KEYBOARD
> To compile this driver as a module, choose M here: the module
> will
> be called hyperv_keyboard.
>
> +config SERIO_SUNXI_PS2
> + tristate "Allwinner Sun4i-A10/Sun7i-A20 PS/2 controller"
> + default n
> + depends on ARCH_SUNXI || COMPILE_TEST
> + help
> + Say Y here if you have Sun4i-A10/Sun7i-A20 Allwinner PS/2 ports.
> +
> + To compile this driver as a module, choose M here: the
> + module will be called sunxi-ps2.
> +
> endif
> diff --git a/drivers/input/serio/Makefile b/drivers/input/serio/Makefile
> index 815d874..0fa0f78 100644
> --- a/drivers/input/serio/Makefile
> +++ b/drivers/input/serio/Makefile
> @@ -29,3 +29,4 @@ obj-$(CONFIG_SERIO_ARC_PS2) += arc_ps2.o
> obj-$(CONFIG_SERIO_APBPS2) += apbps2.o
> obj-$(CONFIG_SERIO_OLPC_APSP) += olpc_apsp.o
> obj-$(CONFIG_HYPERV_KEYBOARD) += hyperv-keyboard.o
> +obj-$(CONFIG_SERIO_SUNXI_PS2) += sunxi-ps2.o
> diff --git a/drivers/input/serio/sunxi-ps2.c
> b/drivers/input/serio/sunxi-ps2.c
> new file mode 100644
> index 0000000..4cd89ae
> --- /dev/null
> +++ b/drivers/input/serio/sunxi-ps2.c
> @@ -0,0 +1,364 @@
> +/*
> + * Driver for Allwinner A20 PS2 host controller
> + *
> + * Author: Vishnu Patekar <vishnupatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:;>
> >
> + * Aaron.maoye <leafy.myeh-Q9AEpCAkrSgqDJ6do+/SaQ@public.gmane.org <javascript:;>>
> + *
> + * Based on 3.0 kernel
> + *
> + */
> +
> +#include <linux/module.h>
> +#include <linux/serio.h>
> +#include <linux/interrupt.h>
> +#include <linux/errno.h>
> +#include <linux/slab.h>
> +#include <linux/list.h>
> +#include <linux/io.h>
> +#include <linux/of_address.h>
> +#include <linux/of_device.h>
> +#include <linux/of_irq.h>
> +#include <linux/of_platform.h>
> +#include <linux/clk.h>
> +#include <linux/delay.h>
> +
> +#define DRIVER_NAME "sunxi-ps2"
> +
> +/* register offset definitions */
> +#define PS2_REG_GCTL (0x00) /* PS2 Module Global Control Reg
> */
> +#define PS2_REG_DATA (0x04) /* PS2 Module Data Reg */
> +#define PS2_REG_LCTL (0x08) /* PS2 Module Line Control Reg */
> +#define PS2_REG_LSTS (0x0C) /* PS2 Module Line Status Reg */
> +#define PS2_REG_FCTL (0x10) /* PS2 Module FIFO Control Reg */
> +#define PS2_REG_FSTS (0x14) /* PS2 Module FIFO Status Reg */
> +#define PS2_REG_CLKDR (0x18) /* PS2 Module Clock Divider Reg*/
> +
> +/* PS2 GLOBAL CONTROL REGISTER PS2_GCTL */
> +#define PS2_GCTL_INTFLAG BIT(4)
> +#define PS2_GCTL_INTEN BIT(3)
> +#define PS2_GCTL_RESET BIT(2)
> +#define PS2_GCTL_MASTER BIT(1)
> +#define PS2_GCTL_BUSEN BIT(0)
> +
> +/* PS2 LINE CONTROL REGISTER */
> +#define PS2_LCTL_NOACK BIT(18)
> +#define PS2_LCTL_TXDTOEN BIT(8)
> +#define PS2_LCTL_STOPERREN BIT(3)
> +#define PS2_LCTL_ACKERREN BIT(2)
> +#define PS2_LCTL_PARERREN BIT(1)
> +#define PS2_LCTL_RXDTOEN BIT(0)
> +
> +/* PS2 LINE STATUS REGISTER */
> +#define PS2_LSTS_TXTDO BIT(8)
> +#define PS2_LSTS_STOPERR BIT(3)
> +#define PS2_LSTS_ACKERR BIT(2)
> +#define PS2_LSTS_PARERR BIT(1)
> +#define PS2_LSTS_RXTDO BIT(0)
> +
> +/* PS2 FIFO CONTROL REGISTER */
> +#define PS2_FCTL_TXRST BIT(17)
> +#define PS2_FCTL_RXRST BIT(16)
> +#define PS2_FCTL_TXUFIEN BIT(10)
> +#define PS2_FCTL_TXOFIEN BIT(9)
> +#define PS2_FCTL_TXRDYIEN BIT(8)
> +#define PS2_FCTL_RXUFIEN BIT(2)
> +#define PS2_FCTL_RXOFIEN BIT(1)
> +#define PS2_FCTL_RXRDYIEN BIT(0)
> +
> +/* PS2 FIFO STATUS REGISTER */
> +#define PS2_FSTS_TXUF BIT(10)
> +#define PS2_FSTS_TXOF BIT(9)
> +#define PS2_FSTS_TXRDY BIT(8)
> +#define PS2_FSTS_RXUF BIT(2)
> +#define PS2_FSTS_RXOF BIT(1)
> +#define PS2_FSTS_RXRDY BIT(0)
> +
> +
> +#define PS2_LINE_ERROR_BIT \
> + (PS2_LSTS_TXTDO|PS2_LSTS_STOPERR|PS2_LSTS_ACKERR| \
> + PS2_LSTS_PARERR|PS2_LSTS_RXTDO)
> +
> +#define PS2_FIFO_ERROR_BIT \
> + (PS2_FSTS_TXUF|PS2_FSTS_TXOF|PS2_FSTS_TXRDY|PS2_FSTS_RXUF| \
> + PS2_FSTS_RXOF|PS2_FSTS_RXRDY)
> +
> +#define PS2_SAMPLE_CLK (1000000)
> +#define PS2_SCLK (125000)
> +
> +struct sunxips2data {
> + struct serio *serio;
> + struct device *dev;
> +
> + /* IO mapping base */
> + void __iomem *reg_base;
> +
> + /* clock management */
> + struct clk *clk;
> +
> + /* irq */
> + spinlock_t lock;
> + int irq;
> +};
> +
> +/*********************/
> +/* Interrupt handler */
> +/*********************/
> +static irqreturn_t sunxips2_interrupt(int irq, void *dev_id)
> +{
> + struct sunxips2data *drvdata = dev_id;
> + u32 intr_status;
> + u32 fifo_status;
> + unsigned char byte;
> + u32 rval;
> + u32 error = 0;
> +
> + spin_lock(&drvdata->lock);
> +
> + /* Get the PS/2 interrupts and clear them */
> + intr_status = readl(drvdata->reg_base + PS2_REG_LSTS);
> + fifo_status = readl(drvdata->reg_base + PS2_REG_FSTS);
> +
> + /*Check Line Status Register*/
> + if (intr_status & 0x10f) {
> + if (intr_status & PS2_LSTS_STOPERR)
> + dev_info(drvdata->dev, "PS/2 Stop Bit Error!");
> + if (intr_status & PS2_LSTS_ACKERR)
> + dev_info(drvdata->dev, "PS/2 Acknowledge
> Error!\n");
> + if (intr_status & PS2_LSTS_PARERR)
> + dev_info(drvdata->dev, "PS/2 Parity Error!\n");
> + if (intr_status & PS2_LSTS_TXTDO)
> + dev_info(drvdata->dev, "PS/2 Transmit Data
> Timeout!\n");
> + if (intr_status & PS2_LSTS_RXTDO)
> + dev_info(drvdata->dev, "PS/2 Receive Data
> Timeout!\n");
> +
> + /*reset PS/2 controller*/
> + writel(readl(drvdata->reg_base + PS2_REG_GCTL) |
> PS2_GCTL_RESET,
> + drvdata->reg_base + PS2_REG_GCTL);
> +
> + rval = PS2_LSTS_TXTDO | PS2_LSTS_STOPERR | PS2_LSTS_ACKERR
> |
> + PS2_LSTS_PARERR | PS2_LSTS_RXTDO;
> + writel(rval, drvdata->reg_base + PS2_REG_LSTS);
> + error = 1;
> + }
> +
> + /*Check FIFO Status Register*/
> + if (fifo_status & 0x0606) {
> + if (fifo_status & PS2_FSTS_TXUF)
> + dev_info(drvdata->dev, "PS/2 Tx FIFO
> Underflow!\n");
> + if (fifo_status & PS2_FSTS_TXOF)
> + dev_info(drvdata->dev, "PS/2 Tx FIFO Overflow!\n");
> + if (fifo_status & PS2_FSTS_RXUF)
> + dev_info(drvdata->dev, "PS/2 Rx FIFO
> Underflow!\n");
> + if (fifo_status & PS2_FSTS_RXOF)
> + dev_info(drvdata->dev, "PS/2 Rx FIFO Overflow!\n");
> + /*reset PS/2 controller*/
> + writel(readl(drvdata->reg_base + PS2_REG_GCTL) |
> PS2_GCTL_RESET,
> + drvdata->reg_base + PS2_REG_GCTL);
> +
> + rval = PS2_FSTS_TXUF | PS2_FSTS_TXOF | PS2_FSTS_TXRDY |
> + PS2_FSTS_RXUF | PS2_FSTS_RXOF | PS2_FSTS_RXRDY;
> + writel(rval, drvdata->reg_base + PS2_REG_FSTS);
> + error = 1;
> + }
> +
> + rval = (fifo_status >> 16) & 0x3;
> + while (!error && rval--) {
> + byte = readl(drvdata->reg_base + PS2_REG_DATA) & 0xff;
> + /* dev_info(drvdata->dev, "PS/2 Receive %02x\n", byte); */
> + serio_interrupt(drvdata->serio, byte, 0);
> + }
> +
> + writel(intr_status, drvdata->reg_base + PS2_REG_LSTS);
> + writel(fifo_status, drvdata->reg_base + PS2_REG_FSTS);
> +
> + spin_unlock(&drvdata->lock);
> +
> + return IRQ_HANDLED;
> +}
> +
> +
> +static int sunxips2_open(struct serio *pserio)
> +{
> + struct sunxips2data *drvdata = pserio->port_data;
> + u32 src_clk = 0;
> + u32 clk_scdf;
> + u32 clk_pcdf;
> + u32 rval;
> +
> + /*Set Line Control And Enable Interrupt*/
> + rval = PS2_LCTL_TXDTOEN | PS2_LCTL_STOPERREN | PS2_LCTL_ACKERREN
> + | PS2_LCTL_PARERREN | PS2_LCTL_RXDTOEN;
> + writel(rval, drvdata->reg_base + PS2_REG_LCTL);
> +
> + /*Reset FIFO*/
> + rval =
> PS2_FCTL_TXRST|PS2_FCTL_RXRST|PS2_FCTL_TXUFIEN|PS2_FCTL_TXOFIEN
> + |PS2_FCTL_RXUFIEN|PS2_FCTL_RXOFIEN|PS2_FCTL_RXRDYIEN;
> + writel(rval, drvdata->reg_base + PS2_REG_FCTL);
> +
> + src_clk = clk_get_rate(drvdata->clk);
> +
> + if (!src_clk) {
> + dev_info(drvdata->dev, "w_ps2c_set_sclk error, source
> clock is 0.");
> + return -1;
> + }
Ohh, I missed this!!. I'll modify to return proper error code here.
> +
> + /*Set Clock Divider Register*/
> + clk_scdf = DIV_ROUND_UP(src_clk, PS2_SAMPLE_CLK) - 1;
> + clk_pcdf = DIV_ROUND_UP(PS2_SAMPLE_CLK, PS2_SCLK) - 1;
> + rval = (clk_scdf<<8) | clk_pcdf;
> + writel(rval, drvdata->reg_base + PS2_REG_CLKDR);
> +
> + /*Set Global Control Register*/
> + rval = PS2_GCTL_RESET | PS2_GCTL_INTEN | PS2_GCTL_MASTER
> + | PS2_GCTL_BUSEN;
> + writel(rval, drvdata->reg_base + PS2_REG_GCTL);
> +
> + return 0;
> +}
> +
> +static void sunxips2_close(struct serio *pserio)
> +{
> + struct sunxips2data *drvdata = pserio->port_data;
> + unsigned long flags;
> +
> + spin_lock_irqsave(&drvdata->lock, flags);
> + /* Disable the PS2 interrupts */
> + writel(0, drvdata->reg_base + PS2_REG_GCTL);
> + spin_unlock_irqrestore(&drvdata->lock, flags);
> +}
> +
> +static int sunxips2_write(struct serio *pserio, unsigned char val)
> +{
> + unsigned long expire = jiffies + msecs_to_jiffies(10000);
> + struct sunxips2data *drvdata = (struct sunxips2data
> *)pserio->port_data;
> +
> + do {
> + if (readl(drvdata->reg_base + PS2_REG_FSTS) &
> PS2_FSTS_TXRDY) {
> + writel(val, drvdata->reg_base + PS2_REG_DATA);
> + return 0;
> + }
> + } while (time_before(jiffies, expire));
> +
> + return 0;
> +}
> +
> +static int sunxips2_probe(struct platform_device *pdev)
> +{
> + struct resource *res; /* IO mem resources */
> + struct sunxips2data *drvdata;
> + struct serio *serio;
> + struct device *dev = &pdev->dev;
> + unsigned int irq;
> + int error;
> +
> + drvdata = devm_kzalloc(dev, sizeof(struct sunxips2data),
> GFP_KERNEL);
> + serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
> + if (!drvdata || !serio) {
> + error = -ENOMEM;
> + goto err_free_mem;
> + }
> +
> + spin_lock_init(&drvdata->lock);
> +
> + /* IO */
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + drvdata->reg_base = devm_ioremap_resource(dev, res);
> + if (IS_ERR(drvdata->reg_base)) {
> + dev_err(dev, "failed to map registers\n");
> + error = PTR_ERR(drvdata->reg_base);
> + goto err_free_mem;
> + }
> +
> + drvdata->clk = devm_clk_get(dev, NULL);
> + if (!IS_ERR(drvdata->clk)) {
> + error = clk_prepare_enable(drvdata->clk);
> + if (error < 0) {
> + dev_err(dev, "failed to enable clock %d\n", error);
> + goto err_free_mem;
> + }
> + } else {
> + error = PTR_ERR(drvdata->clk);
> + dev_err(dev, "couldn't get clock %d\n", error);
> + goto err_free_mem;
> + }
> +
> + serio->id.type = SERIO_8042;
> + serio->write = sunxips2_write;
> + serio->open = sunxips2_open;
> + serio->close = sunxips2_close;
> + serio->port_data = drvdata;
> + serio->dev.parent = dev;
> + strlcpy(serio->name, dev_name(dev), sizeof(serio->name));
> + strlcpy(serio->phys, dev_name(dev), sizeof(serio->phys));
> +
> + /* Get IRQ for the device */
> + irq = platform_get_irq(pdev, 0);
> + if (!irq) {
> + dev_err(dev, "no IRQ found\n");
> + error = -ENXIO;
> + goto error_disable_clk;
> + }
> +
> + drvdata->irq = irq;
> + drvdata->serio = serio;
> + drvdata->dev = dev;
> + error = devm_request_threaded_irq(dev, drvdata->irq,
> + sunxips2_interrupt, NULL, 0, DRIVER_NAME, drvdata);
> +
> + if (error) {
> + dev_err(drvdata->dev, "Interrupt alloc failed
> %d:error:%d\n",
> + drvdata->irq, error);
> + goto error_disable_clk;
> + }
> +
> + serio_register_port(serio);
> + platform_set_drvdata(pdev, drvdata);
> +
> + return 0; /* success */
> +
> +error_disable_clk:
> + clk_disable_unprepare(drvdata->clk);
> +
> +err_free_mem:
> + kfree(serio);
> + return error;
> +}
> +
> +static int sunxips2_remove(struct platform_device *pdev)
> +{
> + struct sunxips2data *drvdata = platform_get_drvdata(pdev);
> +
> + serio_unregister_port(drvdata->serio);
> + disable_irq(drvdata->irq);
> +
> + if (!IS_ERR(drvdata->clk))
> + clk_disable_unprepare(drvdata->clk);
> + kfree(drvdata->serio);
> +
> + return 0;
> +}
> +
> +/* Match table for of_platform binding */
> +static const struct of_device_id sunxips2_of_match[] = {
> + { .compatible = "allwinner,sun7i-a20-ps2", },
> + { .compatible = "allwinner,sun4i-a10-ps2", },
> + { },
> +};
> +
> +MODULE_DEVICE_TABLE(of, sunxips2_of_match);
> +
> +/*platform driver structure*/
> +static struct platform_driver sunxips2_of_driver = {
> + .probe = sunxips2_probe,
> + .remove = sunxips2_remove,
> + .driver = {
> + .name = DRIVER_NAME,
> + .of_match_table = sunxips2_of_match,
> + },
> +};
> +module_platform_driver(sunxips2_of_driver);
> +
> +MODULE_AUTHOR("Vishnu Patekar <vishnupatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:;>
> >");
> +MODULE_AUTHOR("Aaron.maoye <leafy.myeh-Q9AEpCAkrSgqDJ6do+/SaQ@public.gmane.org <javascript:;>>");
> +MODULE_DESCRIPTION("Sunxi PS/2 driver");
> +MODULE_LICENSE("GPL");
> --
> 1.7.9.5
>
>
--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.
[-- Attachment #2: Type: text/html, Size: 20244 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv2 1/3] sunxi:dts-bindings:input:ps2 bindings for A10/A20 ps2.
2014-12-06 23:15 ` [PATCHv2 1/3] sunxi:dts-bindings:input:ps2 bindings for A10/A20 ps2 vishnupatekar
@ 2014-12-08 22:15 ` Maxime Ripard
2014-12-09 10:21 ` Vishnu Patekar
0 siblings, 1 reply; 12+ messages in thread
From: Maxime Ripard @ 2014-12-08 22:15 UTC (permalink / raw)
To: vishnupatekar
Cc: linux-sunxi, dmitry.torokhov, linux, leafy.myeh, robh+dt,
pawel.moll, mark.rutland, ijc+devicetree, galak, devicetree,
linux-arm-kernel, linux-kernel, linux-input
[-- Attachment #1: Type: text/plain, Size: 1869 bytes --]
Hi,
On Sun, Dec 07, 2014 at 04:45:17AM +0530, vishnupatekar wrote:
> A10 and A20 have same PS2 addresses, clocks, interrupts.
> added compatible as allwinner,sun4i-a10-ps2.
>
> Signed-off-by: vishnupatekar <VishnuPatekar0510@gmail.com>
You should have your real name here.
> ---
> .../bindings/input/allwinner,sunxi-ps2.txt | 23 ++++++++++++++++++++
> 1 file changed, 23 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/input/allwinner,sunxi-ps2.txt
>
> diff --git a/Documentation/devicetree/bindings/input/allwinner,sunxi-ps2.txt b/Documentation/devicetree/bindings/input/allwinner,sunxi-ps2.txt
> new file mode 100644
> index 0000000..3a8919a
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/allwinner,sunxi-ps2.txt
> @@ -0,0 +1,23 @@
> +* Device tree bindings for Allwinner A10, A20 PS2 host controller
> +A20 PS2 is dual role controller(PS2 host and PS2 device). These
> +bindings are for PS2 host controller. IBM compliant IBM PS2 and
> AT-compatible keyboard and mouse can be connected.
This should be wrapped to 80 chars.
> +Required properties:
> +
> + - reg : Offset and length of the register set for the device.
> + - compatible : Should one of the following:
> + - "allwinner,sun7i-a20-ps2"
> + - "allwinner,sun4i-a10-ps2"
> + - interrupts : The interrupt line connected to the PS2.
> + - clocks : The gate clk connected to the PS2.
> +
> +
> +Example:
> + ps20: ps2@0x01c2a000 {
> + compatible = "allwinner,sun7i-a20-ps2";
> + reg = <0x01c2a000 0x400>;
> + interrupts = <0 62 4>;
> + clocks = <&apb1_gates 6>;
> + status = "disabled";
> + };
> --
> 1.7.9.5
>
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv2 3/3] ARM:dts:sunxi:ps2 dt nodes for A10/A20 PS2 controller.
[not found] ` <1417907719-26775-4-git-send-email-VishnuPatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2014-12-08 22:22 ` Maxime Ripard
0 siblings, 0 replies; 12+ messages in thread
From: Maxime Ripard @ 2014-12-08 22:22 UTC (permalink / raw)
To: vishnupatekar
Cc: linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
linux-lFZ/pmaqli7XmaaqVzeoHQ, leafy.myeh-Q9AEpCAkrSgqDJ6do+/SaQ,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A, pawel.moll-5wv7dgnIgG8,
mark.rutland-5wv7dgnIgG8, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
galak-sgV2jX0FEOL9JmXXK+q4OQ, devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA
[-- Attachment #1: Type: text/plain, Size: 3421 bytes --]
Hi,
Your commit title should be less that 80 chars.
It should also be formatted using "ARM: sunxi: dts:" as a prefix (More
specific to less specific).
On Sun, Dec 07, 2014 at 04:45:19AM +0530, vishnupatekar wrote:
> Added ps2 nodes in lime2 board dts. By default ps20 and ps21 nodes are
> commented as ps20 pins conflict with HDMI connector
> on Lime2 Board.
>
> Signed-off-by: vishnupatekar <VishnuPatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
> arch/arm/boot/dts/sun4i-a10.dtsi | 27 +++++++++++++++++++++
> arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts | 13 ++++++++++
> arch/arm/boot/dts/sun7i-a20.dtsi | 29 +++++++++++++++++++++++
> 3 files changed, 69 insertions(+)
This patch should also be split into three different patches:
- The one adding the nodes for the controller to the DTSI
- The one adding the pinctrl nodes
- The one enabling the controller on the board.
>
> diff --git a/arch/arm/boot/dts/sun4i-a10.dtsi b/arch/arm/boot/dts/sun4i-a10.dtsi
> index 5e2ec2d..4726e8d 100644
> --- a/arch/arm/boot/dts/sun4i-a10.dtsi
> +++ b/arch/arm/boot/dts/sun4i-a10.dtsi
> @@ -615,6 +615,19 @@
> allwinner,drive = <0>;
> allwinner,pull = <0>;
> };
A newline here please.
> + ps2_0_pins: ps2_0@0 {
You called the node ps20, you probably want to call it the same way
here. And we usually have a suffix like pins_a whenever we have
several muxing options (as it's probably the case).
> + allwinner,pins = "PI20","PI21";
A whitespace after the comma please.
> + allwinner,function = "ps2";
> + allwinner,drive = <0>;
> + allwinner,pull = <0>;
> + };
Newline.
> + ps2_1_pins: ps2_1@0 {
> + allwinner,pins = "PH12","PH13";
> + allwinner,function = "ps2";
> + allwinner,drive = <0>;
> + allwinner,pull = <0>;
> + };
> +
> };
>
> timer@01c20c00 {
> @@ -781,5 +794,19 @@
> #address-cells = <1>;
> #size-cells = <0>;
> };
Newline.
> + ps20: ps2@0x01c2a000 {
Drop the 0x
> + compatible = "allwinner,sun4i-a10-ps2";
> + reg = <0x01c2a000 0x400>;
> + interrupts = <0 62 4>;
> + clocks = <&apb1_gates 6>;
> + status = "disabled";
> + };
Newline
> + ps21: ps2@0x01c2a400 {
> + compatible = "allwinner,sun4i-a10-ps2";
> + reg = <0x01c2a400 0x400>;
> + interrupts = <0 63 4>;
> + clocks = <&apb1_gates 7>;
> + status = "disabled";
> + };
> };
> };
> diff --git a/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts b/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts
> index ed364d5..5624e63 100644
> --- a/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts
> +++ b/arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts
> @@ -112,6 +112,19 @@
> pinctrl-0 = <&uart0_pins_a>;
> status = "okay";
> };
> + /* PS2 0 and PS2 1 are disabled by default
> + To enable PS2 0 and PS2 1 uncomment below ps20 and ps21 nodes
> + Please note that ps20 pins conflict with HDMI on Lime2 Board*/
> + /*ps20: ps2@0x01c2a000 {
> + pinctrl-names = "default";
> + pinctrl-0 = <&ps2_0_pins>;
> + status = "okay";
> + };
> + ps21: ps2@0x01c2a400 {
> + pinctrl-names = "default";
> + pinctrl-0 = <&ps2_1_pins>;
> + status = "okay";
> + };*/
Hmmm, no, no comments in the DTS.
Especially when it's that trivial to enable.
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv2 2/3] sunxi:drivers:input:ps2 Added sunxi A10/A20 ps2 driver
[not found] ` <1417907719-26775-3-git-send-email-VishnuPatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-12-08 4:43 ` Vishnu Patekar
@ 2014-12-08 22:41 ` Maxime Ripard
[not found] ` <CAEzqOZu9TWmYyBOP8t+b7mepqdbKjhf-3P-uNJS_Od05XiBLZw@mail.gmail.com>
1 sibling, 1 reply; 12+ messages in thread
From: Maxime Ripard @ 2014-12-08 22:41 UTC (permalink / raw)
To: vishnupatekar
Cc: linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
linux-lFZ/pmaqli7XmaaqVzeoHQ, leafy.myeh-Q9AEpCAkrSgqDJ6do+/SaQ,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A, pawel.moll-5wv7dgnIgG8,
mark.rutland-5wv7dgnIgG8, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
galak-sgV2jX0FEOL9JmXXK+q4OQ, devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA
[-- Attachment #1: Type: text/plain, Size: 14667 bytes --]
Hi,
On Sun, Dec 07, 2014 at 04:45:18AM +0530, vishnupatekar wrote:
> -added compatible as allwinner,sun4i-a10-ps2 and allwinner,sun7i-a20-ps2.
> - added default n depends on ARCH_SUNXI || COMPILE_TEST
> in Kconfig.
> -handled errors and free resources on errors.
> -used BIT(x), DIV_ROUND_UP macros.
> -corrected style errors.
The changelog should be either in your cover letter or just above the
diffstat, but not in your commitlog.
This should have a real commit log, telling what you're doing, why,
and how.
> Signed-off-by: vishnupatekar <VishnuPatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
> drivers/input/serio/Kconfig | 10 ++
> drivers/input/serio/Makefile | 1 +
> drivers/input/serio/sunxi-ps2.c | 364 +++++++++++++++++++++++++++++++++++++++
> 3 files changed, 375 insertions(+)
> create mode 100644 drivers/input/serio/sunxi-ps2.c
>
> diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig
> index bc2d474..3a7599c 100644
> --- a/drivers/input/serio/Kconfig
> +++ b/drivers/input/serio/Kconfig
> @@ -281,4 +281,14 @@ config HYPERV_KEYBOARD
> To compile this driver as a module, choose M here: the module will
> be called hyperv_keyboard.
>
> +config SERIO_SUNXI_PS2
> + tristate "Allwinner Sun4i-A10/Sun7i-A20 PS/2 controller"
Allwinner A10 is enough
> + default n
This is the default.
> + depends on ARCH_SUNXI || COMPILE_TEST
> + help
> + Say Y here if you have Sun4i-A10/Sun7i-A20 Allwinner PS/2 ports.
You can just mention Allwinne A10 here, on sun4i, at your convenience.
> +
> + To compile this driver as a module, choose M here: the
> + module will be called sunxi-ps2.
> +
> endif
> diff --git a/drivers/input/serio/Makefile b/drivers/input/serio/Makefile
> index 815d874..0fa0f78 100644
> --- a/drivers/input/serio/Makefile
> +++ b/drivers/input/serio/Makefile
> @@ -29,3 +29,4 @@ obj-$(CONFIG_SERIO_ARC_PS2) += arc_ps2.o
> obj-$(CONFIG_SERIO_APBPS2) += apbps2.o
> obj-$(CONFIG_SERIO_OLPC_APSP) += olpc_apsp.o
> obj-$(CONFIG_HYPERV_KEYBOARD) += hyperv-keyboard.o
> +obj-$(CONFIG_SERIO_SUNXI_PS2) += sunxi-ps2.o
> diff --git a/drivers/input/serio/sunxi-ps2.c b/drivers/input/serio/sunxi-ps2.c
> new file mode 100644
> index 0000000..4cd89ae
> --- /dev/null
> +++ b/drivers/input/serio/sunxi-ps2.c
Please call it sun4i-ps2, just in case we have another one coming at
some point.
> @@ -0,0 +1,364 @@
> +/*
> + * Driver for Allwinner A20 PS2 host controller
s/A20/A10/ ?
> + * Author: Vishnu Patekar <vishnupatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> + * Aaron.maoye <leafy.myeh-Q9AEpCAkrSgqDJ6do+/SaQ@public.gmane.org>
> + *
> + * Based on 3.0 kernel
Please mention that it is Allwinner's kernel driver you're talking
about.
> + *
> + */
> +
> +#include <linux/module.h>
> +#include <linux/serio.h>
> +#include <linux/interrupt.h>
> +#include <linux/errno.h>
> +#include <linux/slab.h>
> +#include <linux/list.h>
> +#include <linux/io.h>
> +#include <linux/of_address.h>
> +#include <linux/of_device.h>
> +#include <linux/of_irq.h>
> +#include <linux/of_platform.h>
> +#include <linux/clk.h>
> +#include <linux/delay.h>
> +
> +#define DRIVER_NAME "sunxi-ps2"
> +
> +/* register offset definitions */
> +#define PS2_REG_GCTL (0x00) /* PS2 Module Global Control Reg */
> +#define PS2_REG_DATA (0x04) /* PS2 Module Data Reg */
> +#define PS2_REG_LCTL (0x08) /* PS2 Module Line Control Reg */
> +#define PS2_REG_LSTS (0x0C) /* PS2 Module Line Status Reg */
> +#define PS2_REG_FCTL (0x10) /* PS2 Module FIFO Control Reg */
> +#define PS2_REG_FSTS (0x14) /* PS2 Module FIFO Status Reg */
> +#define PS2_REG_CLKDR (0x18) /* PS2 Module Clock Divider Reg*/
> +
> +/* PS2 GLOBAL CONTROL REGISTER PS2_GCTL */
> +#define PS2_GCTL_INTFLAG BIT(4)
> +#define PS2_GCTL_INTEN BIT(3)
> +#define PS2_GCTL_RESET BIT(2)
> +#define PS2_GCTL_MASTER BIT(1)
> +#define PS2_GCTL_BUSEN BIT(0)
> +
> +/* PS2 LINE CONTROL REGISTER */
> +#define PS2_LCTL_NOACK BIT(18)
> +#define PS2_LCTL_TXDTOEN BIT(8)
> +#define PS2_LCTL_STOPERREN BIT(3)
> +#define PS2_LCTL_ACKERREN BIT(2)
> +#define PS2_LCTL_PARERREN BIT(1)
> +#define PS2_LCTL_RXDTOEN BIT(0)
> +
> +/* PS2 LINE STATUS REGISTER */
> +#define PS2_LSTS_TXTDO BIT(8)
> +#define PS2_LSTS_STOPERR BIT(3)
> +#define PS2_LSTS_ACKERR BIT(2)
> +#define PS2_LSTS_PARERR BIT(1)
> +#define PS2_LSTS_RXTDO BIT(0)
> +
> +/* PS2 FIFO CONTROL REGISTER */
> +#define PS2_FCTL_TXRST BIT(17)
> +#define PS2_FCTL_RXRST BIT(16)
> +#define PS2_FCTL_TXUFIEN BIT(10)
> +#define PS2_FCTL_TXOFIEN BIT(9)
> +#define PS2_FCTL_TXRDYIEN BIT(8)
> +#define PS2_FCTL_RXUFIEN BIT(2)
> +#define PS2_FCTL_RXOFIEN BIT(1)
> +#define PS2_FCTL_RXRDYIEN BIT(0)
> +
> +/* PS2 FIFO STATUS REGISTER */
> +#define PS2_FSTS_TXUF BIT(10)
> +#define PS2_FSTS_TXOF BIT(9)
> +#define PS2_FSTS_TXRDY BIT(8)
> +#define PS2_FSTS_RXUF BIT(2)
> +#define PS2_FSTS_RXOF BIT(1)
> +#define PS2_FSTS_RXRDY BIT(0)
Please define the bits right below the register they belong too, not
separated.
> +#define PS2_LINE_ERROR_BIT \
> + (PS2_LSTS_TXTDO|PS2_LSTS_STOPERR|PS2_LSTS_ACKERR| \
> + PS2_LSTS_PARERR|PS2_LSTS_RXTDO)
> +
> +#define PS2_FIFO_ERROR_BIT \
> + (PS2_FSTS_TXUF|PS2_FSTS_TXOF|PS2_FSTS_TXRDY|PS2_FSTS_RXUF| \
> + PS2_FSTS_RXOF|PS2_FSTS_RXRDY)
Spaces around the operators.
> +
> +#define PS2_SAMPLE_CLK (1000000)
> +#define PS2_SCLK (125000)
> +
> +struct sunxips2data {
> + struct serio *serio;
> + struct device *dev;
> +
> + /* IO mapping base */
> + void __iomem *reg_base;
> +
> + /* clock management */
> + struct clk *clk;
> +
> + /* irq */
> + spinlock_t lock;
> + int irq;
> +};
> +
> +/*********************/
> +/* Interrupt handler */
> +/*********************/
> +static irqreturn_t sunxips2_interrupt(int irq, void *dev_id)
s/sunxips2/sun4i_ps2/ please.
> +{
> + struct sunxips2data *drvdata = dev_id;
> + u32 intr_status;
> + u32 fifo_status;
> + unsigned char byte;
> + u32 rval;
> + u32 error = 0;
> +
> + spin_lock(&drvdata->lock);
> +
> + /* Get the PS/2 interrupts and clear them */
> + intr_status = readl(drvdata->reg_base + PS2_REG_LSTS);
> + fifo_status = readl(drvdata->reg_base + PS2_REG_FSTS);
> +
> + /*Check Line Status Register*/
> + if (intr_status & 0x10f) {
> + if (intr_status & PS2_LSTS_STOPERR)
> + dev_info(drvdata->dev, "PS/2 Stop Bit Error!");
> + if (intr_status & PS2_LSTS_ACKERR)
> + dev_info(drvdata->dev, "PS/2 Acknowledge Error!\n");
> + if (intr_status & PS2_LSTS_PARERR)
> + dev_info(drvdata->dev, "PS/2 Parity Error!\n");
> + if (intr_status & PS2_LSTS_TXTDO)
> + dev_info(drvdata->dev, "PS/2 Transmit Data Timeout!\n");
> + if (intr_status & PS2_LSTS_RXTDO)
> + dev_info(drvdata->dev, "PS/2 Receive Data Timeout!\n");
> +
> + /*reset PS/2 controller*/
> + writel(readl(drvdata->reg_base + PS2_REG_GCTL) | PS2_GCTL_RESET,
> + drvdata->reg_base + PS2_REG_GCTL);
It's usually better to have it as two lines: one for the read, one for
the write.
> +
> + rval = PS2_LSTS_TXTDO | PS2_LSTS_STOPERR | PS2_LSTS_ACKERR |
> + PS2_LSTS_PARERR | PS2_LSTS_RXTDO;
> + writel(rval, drvdata->reg_base + PS2_REG_LSTS);
> + error = 1;
> + }
> +
> + /*Check FIFO Status Register*/
> + if (fifo_status & 0x0606) {
> + if (fifo_status & PS2_FSTS_TXUF)
> + dev_info(drvdata->dev, "PS/2 Tx FIFO Underflow!\n");
> + if (fifo_status & PS2_FSTS_TXOF)
> + dev_info(drvdata->dev, "PS/2 Tx FIFO Overflow!\n");
> + if (fifo_status & PS2_FSTS_RXUF)
> + dev_info(drvdata->dev, "PS/2 Rx FIFO Underflow!\n");
> + if (fifo_status & PS2_FSTS_RXOF)
> + dev_info(drvdata->dev, "PS/2 Rx FIFO Overflow!\n");
> + /*reset PS/2 controller*/
> + writel(readl(drvdata->reg_base + PS2_REG_GCTL) | PS2_GCTL_RESET,
> + drvdata->reg_base + PS2_REG_GCTL);
Ditto.
> + rval = PS2_FSTS_TXUF | PS2_FSTS_TXOF | PS2_FSTS_TXRDY |
> + PS2_FSTS_RXUF | PS2_FSTS_RXOF | PS2_FSTS_RXRDY;
> + writel(rval, drvdata->reg_base + PS2_REG_FSTS);
> + error = 1;
> + }
> +
> + rval = (fifo_status >> 16) & 0x3;
> + while (!error && rval--) {
> + byte = readl(drvdata->reg_base + PS2_REG_DATA) & 0xff;
> + /* dev_info(drvdata->dev, "PS/2 Receive %02x\n", byte); */
Remove that line.
> + serio_interrupt(drvdata->serio, byte, 0);
> + }
> +
> + writel(intr_status, drvdata->reg_base + PS2_REG_LSTS);
> + writel(fifo_status, drvdata->reg_base + PS2_REG_FSTS);
> +
> + spin_unlock(&drvdata->lock);
> +
> + return IRQ_HANDLED;
> +}
> +
> +
> +static int sunxips2_open(struct serio *pserio)
> +{
> + struct sunxips2data *drvdata = pserio->port_data;
> + u32 src_clk = 0;
> + u32 clk_scdf;
> + u32 clk_pcdf;
> + u32 rval;
> +
> + /*Set Line Control And Enable Interrupt*/
> + rval = PS2_LCTL_TXDTOEN | PS2_LCTL_STOPERREN | PS2_LCTL_ACKERREN
> + | PS2_LCTL_PARERREN | PS2_LCTL_RXDTOEN;
> + writel(rval, drvdata->reg_base + PS2_REG_LCTL);
> +
> + /*Reset FIFO*/
> + rval = PS2_FCTL_TXRST|PS2_FCTL_RXRST|PS2_FCTL_TXUFIEN|PS2_FCTL_TXOFIEN
> + |PS2_FCTL_RXUFIEN|PS2_FCTL_RXOFIEN|PS2_FCTL_RXRDYIEN;
> + writel(rval, drvdata->reg_base + PS2_REG_FCTL);
> +
> + src_clk = clk_get_rate(drvdata->clk);
> +
> + if (!src_clk) {
> + dev_info(drvdata->dev, "w_ps2c_set_sclk error, source clock is 0.");
> + return -1;
> + }
> +
> + /*Set Clock Divider Register*/
> + clk_scdf = DIV_ROUND_UP(src_clk, PS2_SAMPLE_CLK) - 1;
> + clk_pcdf = DIV_ROUND_UP(PS2_SAMPLE_CLK, PS2_SCLK) - 1;
So this is actually a rounding down?
Why not just using src_clk / PS2_SAMPLE_CLK directly?
> + rval = (clk_scdf<<8) | clk_pcdf;
Spaces between the operators. Remember, run checkpatch.
> + writel(rval, drvdata->reg_base + PS2_REG_CLKDR);
> +
> + /*Set Global Control Register*/
> + rval = PS2_GCTL_RESET | PS2_GCTL_INTEN | PS2_GCTL_MASTER
> + | PS2_GCTL_BUSEN;
> + writel(rval, drvdata->reg_base + PS2_REG_GCTL);
You seem to be reading/writing from the same registers than in your
interrupt handler, don't you need some locking in here?
> +
> + return 0;
> +}
> +
> +static void sunxips2_close(struct serio *pserio)
> +{
> + struct sunxips2data *drvdata = pserio->port_data;
> + unsigned long flags;
> +
> + spin_lock_irqsave(&drvdata->lock, flags);
> + /* Disable the PS2 interrupts */
> + writel(0, drvdata->reg_base + PS2_REG_GCTL);
> + spin_unlock_irqrestore(&drvdata->lock, flags);
> +}
> +
> +static int sunxips2_write(struct serio *pserio, unsigned char val)
> +{
> + unsigned long expire = jiffies + msecs_to_jiffies(10000);
> + struct sunxips2data *drvdata = (struct sunxips2data *)pserio->port_data;
> +
> + do {
> + if (readl(drvdata->reg_base + PS2_REG_FSTS) & PS2_FSTS_TXRDY) {
> + writel(val, drvdata->reg_base + PS2_REG_DATA);
> + return 0;
> + }
> + } while (time_before(jiffies, expire));
> +
> + return 0;
> +}
> +
> +static int sunxips2_probe(struct platform_device *pdev)
> +{
> + struct resource *res; /* IO mem resources */
> + struct sunxips2data *drvdata;
> + struct serio *serio;
> + struct device *dev = &pdev->dev;
> + unsigned int irq;
> + int error;
> +
> + drvdata = devm_kzalloc(dev, sizeof(struct sunxips2data), GFP_KERNEL);
> + serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
> + if (!drvdata || !serio) {
> + error = -ENOMEM;
> + goto err_free_mem;
> + }
> +
> + spin_lock_init(&drvdata->lock);
> +
> + /* IO */
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + drvdata->reg_base = devm_ioremap_resource(dev, res);
> + if (IS_ERR(drvdata->reg_base)) {
> + dev_err(dev, "failed to map registers\n");
> + error = PTR_ERR(drvdata->reg_base);
> + goto err_free_mem;
> + }
> +
> + drvdata->clk = devm_clk_get(dev, NULL);
> + if (!IS_ERR(drvdata->clk)) {
> + error = clk_prepare_enable(drvdata->clk);
> + if (error < 0) {
> + dev_err(dev, "failed to enable clock %d\n", error);
> + goto err_free_mem;
> + }
> + } else {
> + error = PTR_ERR(drvdata->clk);
> + dev_err(dev, "couldn't get clock %d\n", error);
> + goto err_free_mem;
> + }
That would be better if you had something like
clk_get()
if (IS_ERR())
goto
clk_prepare_enable()
if (IS_ERR())
Especially since you're using that kind of construct in the rest of
your function.
> + serio->id.type = SERIO_8042;
> + serio->write = sunxips2_write;
> + serio->open = sunxips2_open;
> + serio->close = sunxips2_close;
> + serio->port_data = drvdata;
> + serio->dev.parent = dev;
> + strlcpy(serio->name, dev_name(dev), sizeof(serio->name));
> + strlcpy(serio->phys, dev_name(dev), sizeof(serio->phys));
> +
> + /* Get IRQ for the device */
> + irq = platform_get_irq(pdev, 0);
> + if (!irq) {
> + dev_err(dev, "no IRQ found\n");
> + error = -ENXIO;
> + goto error_disable_clk;
> + }
> +
> + drvdata->irq = irq;
> + drvdata->serio = serio;
> + drvdata->dev = dev;
> + error = devm_request_threaded_irq(dev, drvdata->irq,
> + sunxips2_interrupt, NULL, 0, DRIVER_NAME, drvdata);
This really looks like a case for a regular request_irq.
> + if (error) {
> + dev_err(drvdata->dev, "Interrupt alloc failed %d:error:%d\n",
> + drvdata->irq, error);
> + goto error_disable_clk;
> + }
> +
> + serio_register_port(serio);
> + platform_set_drvdata(pdev, drvdata);
> +
> + return 0; /* success */
> +
> +error_disable_clk:
> + clk_disable_unprepare(drvdata->clk);
> +
> +err_free_mem:
> + kfree(serio);
> + return error;
> +}
> +
> +static int sunxips2_remove(struct platform_device *pdev)
> +{
> + struct sunxips2data *drvdata = platform_get_drvdata(pdev);
> +
> + serio_unregister_port(drvdata->serio);
> + disable_irq(drvdata->irq);
> +
> + if (!IS_ERR(drvdata->clk))
> + clk_disable_unprepare(drvdata->clk);
And you can drop that if.
> + kfree(drvdata->serio);
> +
> + return 0;
> +}
> +
> +/* Match table for of_platform binding */
> +static const struct of_device_id sunxips2_of_match[] = {
> + { .compatible = "allwinner,sun7i-a20-ps2", },
> + { .compatible = "allwinner,sun4i-a10-ps2", },
If the two really are compatible, you just need one of them, the A10
one in that case, since that's the earlier SoCs.
> + { },
> +};
> +
> +MODULE_DEVICE_TABLE(of, sunxips2_of_match);
> +
> +/*platform driver structure*/
> +static struct platform_driver sunxips2_of_driver = {
> + .probe = sunxips2_probe,
> + .remove = sunxips2_remove,
> + .driver = {
> + .name = DRIVER_NAME,
> + .of_match_table = sunxips2_of_match,
> + },
> +};
> +module_platform_driver(sunxips2_of_driver);
> +
> +MODULE_AUTHOR("Vishnu Patekar <vishnupatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>");
> +MODULE_AUTHOR("Aaron.maoye <leafy.myeh-Q9AEpCAkrSgqDJ6do+/SaQ@public.gmane.org>");
> +MODULE_DESCRIPTION("Sunxi PS/2 driver");
> +MODULE_LICENSE("GPL");
> --
> 1.7.9.5
>
It's looking great otherwise.
Thanks!
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv2 1/3] sunxi:dts-bindings:input:ps2 bindings for A10/A20 ps2.
2014-12-08 22:15 ` Maxime Ripard
@ 2014-12-09 10:21 ` Vishnu Patekar
0 siblings, 0 replies; 12+ messages in thread
From: Vishnu Patekar @ 2014-12-09 10:21 UTC (permalink / raw)
To: linux-sunxi-/JYPxA39Uh5TLH3MbocFFw
Cc: vishnupatekar0510-Re5JQEeQqe8AvxtiuMwx3w,
dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
linux-lFZ/pmaqli7XmaaqVzeoHQ, leafy.myeh-Q9AEpCAkrSgqDJ6do+/SaQ,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A, pawel.moll-5wv7dgnIgG8,
mark.rutland-5wv7dgnIgG8, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
galak-sgV2jX0FEOL9JmXXK+q4OQ, devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA
[-- Attachment #1.1: Type: text/plain, Size: 2552 bytes --]
Hello,
On Tuesday, December 9, 2014 3:50:05 AM UTC+5:30, Maxime Ripard wrote:
>
> Hi,
>
> On Sun, Dec 07, 2014 at 04:45:17AM +0530, vishnupatekar wrote:
> > A10 and A20 have same PS2 addresses, clocks, interrupts.
> > added compatible as allwinner,sun4i-a10-ps2.
> >
> > Signed-off-by: vishnupatekar <VishnuPa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>>
>
> You should have your real name here.
>
This is my real Name. Vishnu Patekar :)
>
> > ---
> > .../bindings/input/allwinner,sunxi-ps2.txt | 23
> ++++++++++++++++++++
> > 1 file changed, 23 insertions(+)
> > create mode 100644
> Documentation/devicetree/bindings/input/allwinner,sunxi-ps2.txt
> >
> > diff --git
> a/Documentation/devicetree/bindings/input/allwinner,sunxi-ps2.txt
> b/Documentation/devicetree/bindings/input/allwinner,sunxi-ps2.txt
> > new file mode 100644
> > index 0000000..3a8919a
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/input/allwinner,sunxi-ps2.txt
> > @@ -0,0 +1,23 @@
> > +* Device tree bindings for Allwinner A10, A20 PS2 host controller
>
> > +A20 PS2 is dual role controller(PS2 host and PS2 device). These
> > +bindings are for PS2 host controller. IBM compliant IBM PS2 and
> > AT-compatible keyboard and mouse can be connected.
>
> This should be wrapped to 80 chars.
>
> Okie.
> > +Required properties:
> > +
> > + - reg : Offset and length of the register set for the
> device.
> > + - compatible : Should one of the following:
> > + - "allwinner,sun7i-a20-ps2"
> > + - "allwinner,sun4i-a10-ps2"
> > + - interrupts : The interrupt line connected to the PS2.
> > + - clocks : The gate clk connected to the PS2.
> > +
> > +
> > +Example:
> > + ps20: ps2@0x01c2a000 {
> > + compatible = "allwinner,sun7i-a20-ps2";
> > + reg = <0x01c2a000 0x400>;
> > + interrupts = <0 62 4>;
> > + clocks = <&apb1_gates 6>;
> > + status = "disabled";
> > + };
> > --
> > 1.7.9.5
> >
>
> --
> Maxime Ripard, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com
>
--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.
[-- Attachment #1.2: Type: text/html, Size: 4729 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv2 2/3] sunxi:drivers:input:ps2 Added sunxi A10/A20 ps2 driver
[not found] ` <CAEzqOZu9TWmYyBOP8t+b7mepqdbKjhf-3P-uNJS_Od05XiBLZw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2014-12-11 21:09 ` Maxime Ripard
0 siblings, 0 replies; 12+ messages in thread
From: Maxime Ripard @ 2014-12-11 21:09 UTC (permalink / raw)
To: Vishnu Patekar
Cc: linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
linux-lFZ/pmaqli7XmaaqVzeoHQ, leafy.myeh-Q9AEpCAkrSgqDJ6do+/SaQ,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A, pawel.moll-5wv7dgnIgG8,
mark.rutland-5wv7dgnIgG8, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
galak-sgV2jX0FEOL9JmXXK+q4OQ, devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA
[-- Attachment #1: Type: text/plain, Size: 2525 bytes --]
Hi,
Remember to reply to all the recipients.
On Tue, Dec 09, 2014 at 04:40:36PM +0530, Vishnu Patekar wrote:
> > > Signed-off-by: vishnupatekar <VishnuPatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> > > ---
> > > drivers/input/serio/Kconfig | 10 ++
> > > drivers/input/serio/Makefile | 1 +
> > > drivers/input/serio/sunxi-ps2.c | 364
> > +++++++++++++++++++++++++++++++++++++++
> > > 3 files changed, 375 insertions(+)
> > > create mode 100644 drivers/input/serio/sunxi-ps2.c
> > >
> > > diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig
> > > index bc2d474..3a7599c 100644
> > > --- a/drivers/input/serio/Kconfig
> > > +++ b/drivers/input/serio/Kconfig
> > > @@ -281,4 +281,14 @@ config HYPERV_KEYBOARD
> > > To compile this driver as a module, choose M here: the module
> > will
> > > be called hyperv_keyboard.
> > >
> > > +config SERIO_SUNXI_PS2
> > > + tristate "Allwinner Sun4i-A10/Sun7i-A20 PS/2 controller"
> >
> > Allwinner A10 is enough
> >
> Okie, Should I change the config option as well, like SERIO_SUN4I_PS2 ?
Yep.
> > > + /*Set Clock Divider Register*/
> > > + clk_scdf = DIV_ROUND_UP(src_clk, PS2_SAMPLE_CLK) - 1;
> > > + clk_pcdf = DIV_ROUND_UP(PS2_SAMPLE_CLK, PS2_SCLK) - 1;
> >
> > So this is actually a rounding down?
> >
> > Why not just using src_clk / PS2_SAMPLE_CLK directly?
> >
> > > + rval = (clk_scdf<<8) | clk_pcdf;
> >
> > Spaces between the operators. Remember, run checkpatch.
> >
> Okie.
>
> checkpatch could not catch this!!
Well, then it should have :)
> > > + writel(rval, drvdata->reg_base + PS2_REG_CLKDR);
> > > +
> > > + /*Set Global Control Register*/
> > > + rval = PS2_GCTL_RESET | PS2_GCTL_INTEN | PS2_GCTL_MASTER
> > > + | PS2_GCTL_BUSEN;
> > > + writel(rval, drvdata->reg_base + PS2_REG_GCTL);
> >
> > You seem to be reading/writing from the same registers than in your
> > interrupt handler, don't you need some locking in here?
> >
>
> Interrupt is getting enabled only after writing to GCTL register.
>
> do you think still we need to locking mechanism here?
Not really, you don't know the state of the device before your driver
is probed, and the interrupts are enabled as soon as request_irq. So
you can very well have the device running with the interrupts running
before this function is called.
Plus you might get spurious interrupts.
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv2 0/3] ARM:sunxi:ps2 Added support for A10/A20 ps2 controller.
[not found] ` <1417907719-26775-1-git-send-email-VishnuPatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
` (2 preceding siblings ...)
2014-12-06 23:15 ` [PATCHv2 3/3] ARM:dts:sunxi:ps2 dt nodes for A10/A20 PS2 controller vishnupatekar
@ 2014-12-12 13:15 ` Hans de Goede
[not found] ` <548AEA8E.6040100-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
3 siblings, 1 reply; 12+ messages in thread
From: Hans de Goede @ 2014-12-12 13:15 UTC (permalink / raw)
To: linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
linux-lFZ/pmaqli7XmaaqVzeoHQ
Cc: leafy.myeh-Q9AEpCAkrSgqDJ6do+/SaQ, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
pawel.moll-5wv7dgnIgG8, mark.rutland-5wv7dgnIgG8,
ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
galak-sgV2jX0FEOL9JmXXK+q4OQ, devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA, vishnupatekar
[-- Attachment #1: Type: text/plain, Size: 2718 bytes --]
Hi,
On 07-12-14 00:15, vishnupatekar wrote:
> Here is v2 of SUNXI PS2 controller support patch-set as with v1.
So as promised I've run this on an A10 board, with a small fix to
the interrupt property in the sun4i.dtsi file this works as is.
This means that the sun7i compat should be dropped, and the sun4i
compat used everywhere.
I've created 3 fixup patches to do this, note one also renames / moves
the bindings file as it is in the wrong place.
I've attached the 3 fixup patches, pleasesquash these into your
existing patches before posting the next version.
Thanks & Regards,
Hans
>
> Changes in v2:
> 1. added default n depends on ARCH_SUNXI || COMPILE_TEST in Kconfig.
> 2. handled errors and free resources on errors.
> 3. used BIT(x), DIV_ROUND_UP macros.
> 4. corrected style errors.
> 5. added support for A10 also, A10 and A2 have same properties of PS2 controller.
> 6. by default commented ps20 and ps21 nodes,as ps20 pins conflict with HDMI
> connector on Lime2 Board.
> 7. added compatible as allwinner,sun4i-a10-ps2.
> 8. corrected the possible race condition.
>
> Patch 0 Summary: Allwinner A10/A20 PS2 controller. These modifications are
> for PS2 host controller. IBM compliant IBM PS2 and AT-compatible
> keyboard and mouse can be connected.
>
> Patch 1 device tree bindings.
>
> Patch 2 adds support for sun7i ps2 driver.
>
> Patch 3 device tree support for PS2 controller.
> 1) Added A10/A20 ps2 nodes to the dtsi
> 2) Added A10/A20 ps2 pinmux to the dtsi
> 3) Added ps2 nodes to the lime2 dts file
>
> vishnupatekar (3):
> sunxi:dts-bindings:input:ps2 bindings for A10/A20 ps2.
> sunxi:drivers:input:ps2 Added sunxi A10/A20 ps2 driver
> ARM:dts:sunxi:ps2 dt nodes for A10/A20 PS2 controller.
>
> .../bindings/input/allwinner,sunxi-ps2.txt | 23 ++
> arch/arm/boot/dts/sun4i-a10.dtsi | 27 ++
> arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts | 13 +
> arch/arm/boot/dts/sun7i-a20.dtsi | 29 ++
> drivers/input/serio/Kconfig | 10 +
> drivers/input/serio/Makefile | 1 +
> drivers/input/serio/sunxi-ps2.c | 364 ++++++++++++++++++++
> 7 files changed, 467 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/input/allwinner,sunxi-ps2.txt
> create mode 100644 drivers/input/serio/sunxi-ps2.c
>
--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.
[-- Attachment #2: 0001-FIXUP-sunxi-dts-bindings-input-ps2-bindings-for-A10-.patch --]
[-- Type: text/x-patch, Size: 3292 bytes --]
>From 85105ec25cfb0dcff102e579e00a0a6c38ac34e9 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Date: Fri, 12 Dec 2014 14:05:56 +0100
Subject: [PATCH v2 1/4] FIXUP: "sunxi:dts-bindings:input:ps2 bindings for
A10/A20 ps2."
2 fixups for: "sunxi:dts-bindings:input:ps2 bindings for A10/A20 ps2."
1) dt bindings should use the compat string for the earliest version of the
hardware which has the relevant hardware block, unless there are differences,
the A10 and A20 ps2 controllers are identical, so for both sun4i-a10-ps2
should be used as compat string.
2) ps2 / serio bindings belong under Documentation/devicetree/bindings/serio
Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
.../bindings/input/allwinner,sunxi-ps2.txt | 23 ----------------------
.../bindings/serio/allwinner,sun4i-a10-ps2.txt | 22 +++++++++++++++++++++
2 files changed, 22 insertions(+), 23 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/input/allwinner,sunxi-ps2.txt
create mode 100644 Documentation/devicetree/bindings/serio/allwinner,sun4i-a10-ps2.txt
diff --git a/Documentation/devicetree/bindings/input/allwinner,sunxi-ps2.txt b/Documentation/devicetree/bindings/input/allwinner,sunxi-ps2.txt
deleted file mode 100644
index 3a8919a..0000000
--- a/Documentation/devicetree/bindings/input/allwinner,sunxi-ps2.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-* Device tree bindings for Allwinner A10, A20 PS2 host controller
-
-A20 PS2 is dual role controller(PS2 host and PS2 device). These bindings are for PS2 host controller.
-IBM compliant IBM PS2 and AT-compatible keyboard and mouse can be connected.
-
-Required properties:
-
- - reg : Offset and length of the register set for the device.
- - compatible : Should one of the following:
- - "allwinner,sun7i-a20-ps2"
- - "allwinner,sun4i-a10-ps2"
- - interrupts : The interrupt line connected to the PS2.
- - clocks : The gate clk connected to the PS2.
-
-
-Example:
- ps20: ps2@0x01c2a000 {
- compatible = "allwinner,sun7i-a20-ps2";
- reg = <0x01c2a000 0x400>;
- interrupts = <0 62 4>;
- clocks = <&apb1_gates 6>;
- status = "disabled";
- };
diff --git a/Documentation/devicetree/bindings/serio/allwinner,sun4i-a10-ps2.txt b/Documentation/devicetree/bindings/serio/allwinner,sun4i-a10-ps2.txt
new file mode 100644
index 0000000..c93ca90
--- /dev/null
+++ b/Documentation/devicetree/bindings/serio/allwinner,sun4i-a10-ps2.txt
@@ -0,0 +1,22 @@
+* Device tree bindings for Allwinner A10, A20 PS2 host controller
+
+A10 PS2 is dual role controller (PS2 host and PS2 device). These bindings are
+for the PS2 host controller.
+IBM compliant IBM PS2 and AT-compatible keyboard and mouse can be connected.
+
+Required properties:
+
+ - reg : Offset and length of the register set for the device.
+ - compatible : "allwinner,sun4i-a10-ps2"
+ - interrupts : The interrupt line connected to the PS2.
+ - clocks : The gate clk connected to the PS2.
+
+
+Example:
+ ps20: ps2@0x01c2a000 {
+ compatible = "allwinner,sun4i-a10-ps2";
+ reg = <0x01c2a000 0x400>;
+ interrupts = <0 62 4>;
+ clocks = <&apb1_gates 6>;
+ status = "disabled";
+ };
--
2.1.0
[-- Attachment #3: 0002-FIXUP-sunxi-drivers-input-ps2-Added-sunxi-A10-A20-ps.patch --]
[-- Type: text/x-patch, Size: 1205 bytes --]
>From 0eecd5e763278a59c4533e576ac1c9616310c21e Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Date: Fri, 12 Dec 2014 14:11:56 +0100
Subject: [PATCH v2 2/4] FIXUP: "sunxi:drivers:input:ps2 Added sunxi A10/A20
ps2 driver"
dt bindings should use the compat string for the earliest version of the
hardware which has the relevant hardware block, unless there are differences,
the A10 and A20 ps2 controllers are identical, so for both sun4i-a10-ps2
should be used as compat string, drop the sun7i-a20-ps2 compat string.
Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
drivers/input/serio/sunxi-ps2.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/input/serio/sunxi-ps2.c b/drivers/input/serio/sunxi-ps2.c
index 4cd89ae..cb89d80 100644
--- a/drivers/input/serio/sunxi-ps2.c
+++ b/drivers/input/serio/sunxi-ps2.c
@@ -340,7 +340,6 @@ static int sunxips2_remove(struct platform_device *pdev)
/* Match table for of_platform binding */
static const struct of_device_id sunxips2_of_match[] = {
- { .compatible = "allwinner,sun7i-a20-ps2", },
{ .compatible = "allwinner,sun4i-a10-ps2", },
{ },
};
--
2.1.0
[-- Attachment #4: 0003-FIXUP-ARM-dts-sunxi-ps2-dt-nodes-for-A10-A20-PS2-con.patch --]
[-- Type: text/x-patch, Size: 2304 bytes --]
>From 45985183f3e96adf1c846c7bbde32647367024dc Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Date: Fri, 12 Dec 2014 14:01:43 +0100
Subject: [PATCH v2 3/4] FIXUP: "ARM:dts:sunxi:ps2 dt nodes for A10/A20 PS2
controller."
2 fixups for: "ARM:dts:sunxi:ps2 dt nodes for A10/A20 PS2 controller."
1) Fixup the sun4i ps/2 nodes interrupt property, sun4i interrupts take
only 1 specifier
2) dt bindings should use the compat string for the earliest version of the
hardware which has the relevant hardware block, unless there are differences,
the A10 and A20 ps2 controllers are identical, so for both sun4i-a10-ps2
should be used as compat string, update the sun7i.dtsi ps2 entries to
use the sun4i-a10-ps2 compat string.
Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
arch/arm/boot/dts/sun4i-a10.dtsi | 4 ++--
arch/arm/boot/dts/sun7i-a20.dtsi | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/arm/boot/dts/sun4i-a10.dtsi b/arch/arm/boot/dts/sun4i-a10.dtsi
index c04c117..e8cd6db 100644
--- a/arch/arm/boot/dts/sun4i-a10.dtsi
+++ b/arch/arm/boot/dts/sun4i-a10.dtsi
@@ -818,14 +818,14 @@
ps20: ps2@0x01c2a000 {
compatible = "allwinner,sun4i-a10-ps2";
reg = <0x01c2a000 0x400>;
- interrupts = <0 62 4>;
+ interrupts = <62>;
clocks = <&apb1_gates 6>;
status = "disabled";
};
ps21: ps2@0x01c2a400 {
compatible = "allwinner,sun4i-a10-ps2";
reg = <0x01c2a400 0x400>;
- interrupts = <0 63 4>;
+ interrupts = <63>;
clocks = <&apb1_gates 7>;
status = "disabled";
};
diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi b/arch/arm/boot/dts/sun7i-a20.dtsi
index 4417c8c3..d54d684 100644
--- a/arch/arm/boot/dts/sun7i-a20.dtsi
+++ b/arch/arm/boot/dts/sun7i-a20.dtsi
@@ -1114,14 +1114,14 @@
interrupts = <1 9 0xf04>;
};
ps20: ps2@0x01c2a000 {
- compatible = "allwinner,sun7i-a20-ps2";
+ compatible = "allwinner,sun4i-a10-ps2";
reg = <0x01c2a000 0x400>;
interrupts = <0 62 4>;
clocks = <&apb1_gates 6>;
status = "disabled";
};
ps21: ps2@0x01c2a400 {
- compatible = "allwinner,sun7i-a20-ps2";
+ compatible = "allwinner,sun4i-a10-ps2";
reg = <0x01c2a400 0x400>;
interrupts = <0 63 4>;
clocks = <&apb1_gates 7>;
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCHv2 0/3] ARM:sunxi:ps2 Added support for A10/A20 ps2 controller.
[not found] ` <548AEA8E.6040100-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2014-12-12 13:55 ` Vishnu Patekar
0 siblings, 0 replies; 12+ messages in thread
From: Vishnu Patekar @ 2014-12-12 13:55 UTC (permalink / raw)
To: linux-sunxi-/JYPxA39Uh5TLH3MbocFFw
Cc: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
linux-lFZ/pmaqli7XmaaqVzeoHQ, leafy.myeh-Q9AEpCAkrSgqDJ6do+/SaQ,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A, pawel.moll-5wv7dgnIgG8,
mark.rutland-5wv7dgnIgG8, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
galak-sgV2jX0FEOL9JmXXK+q4OQ, devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-input-u79uwXL29TY76Z2rM5mHXA,
VishnuPatekar0510-Re5JQEeQqe8AvxtiuMwx3w,
hdegoede-H+wXaHxf7aLQT0dZR+AlfA
[-- Attachment #1.1: Type: text/plain, Size: 3156 bytes --]
Hello Hans,
Thank you for testing it on A10 board. now we have PS2 working on A10 as
well. :)
I'll include these in next version which I'm was about to send.
On Friday, December 12, 2014 6:46:25 PM UTC+5:30, Hans de Goede wrote:
>
> Hi,
>
> On 07-12-14 00:15, vishnupatekar wrote:
> > Here is v2 of SUNXI PS2 controller support patch-set as with v1.
>
> So as promised I've run this on an A10 board, with a small fix to
> the interrupt property in the sun4i.dtsi file this works as is.
>
> This means that the sun7i compat should be dropped, and the sun4i
> compat used everywhere.
>
> I've created 3 fixup patches to do this, note one also renames / moves
> the bindings file as it is in the wrong place.
>
> I've attached the 3 fixup patches, pleasesquash these into your
> existing patches before posting the next version.
>
> Thanks & Regards,
>
> Hans
>
>
> >
> > Changes in v2:
> > 1. added default n depends on ARCH_SUNXI || COMPILE_TEST in Kconfig.
> > 2. handled errors and free resources on errors.
> > 3. used BIT(x), DIV_ROUND_UP macros.
> > 4. corrected style errors.
> > 5. added support for A10 also, A10 and A2 have same properties of PS2
> controller.
> > 6. by default commented ps20 and ps21 nodes,as ps20 pins conflict with
> HDMI
> > connector on Lime2 Board.
> > 7. added compatible as allwinner,sun4i-a10-ps2.
> > 8. corrected the possible race condition.
> >
> > Patch 0 Summary: Allwinner A10/A20 PS2 controller. These modifications
> are
> > for PS2 host controller. IBM compliant IBM PS2 and AT-compatible
> > keyboard and mouse can be connected.
> >
> > Patch 1 device tree bindings.
> >
> > Patch 2 adds support for sun7i ps2 driver.
> >
> > Patch 3 device tree support for PS2 controller.
> > 1) Added A10/A20 ps2 nodes to the dtsi
> > 2) Added A10/A20 ps2 pinmux to the dtsi
> > 3) Added ps2 nodes to the lime2 dts file
> >
> > vishnupatekar (3):
> > sunxi:dts-bindings:input:ps2 bindings for A10/A20 ps2.
> > sunxi:drivers:input:ps2 Added sunxi A10/A20 ps2 driver
> > ARM:dts:sunxi:ps2 dt nodes for A10/A20 PS2 controller.
> >
> > .../bindings/input/allwinner,sunxi-ps2.txt | 23 ++
> > arch/arm/boot/dts/sun4i-a10.dtsi | 27 ++
> > arch/arm/boot/dts/sun7i-a20-olinuxino-lime2.dts | 13 +
> > arch/arm/boot/dts/sun7i-a20.dtsi | 29 ++
> > drivers/input/serio/Kconfig | 10 +
> > drivers/input/serio/Makefile | 1 +
> > drivers/input/serio/sunxi-ps2.c | 364
> ++++++++++++++++++++
> > 7 files changed, 467 insertions(+)
> > create mode 100644
> Documentation/devicetree/bindings/input/allwinner,sunxi-ps2.txt
> > create mode 100644 drivers/input/serio/sunxi-ps2.c
> >
>
--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.
[-- Attachment #1.2: Type: text/html, Size: 4352 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2014-12-12 13:55 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-06 23:15 [PATCHv2 0/3] ARM:sunxi:ps2 Added support for A10/A20 ps2 controller vishnupatekar
[not found] ` <1417907719-26775-1-git-send-email-VishnuPatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-12-06 23:15 ` [PATCHv2 1/3] sunxi:dts-bindings:input:ps2 bindings for A10/A20 ps2 vishnupatekar
2014-12-08 22:15 ` Maxime Ripard
2014-12-09 10:21 ` Vishnu Patekar
2014-12-06 23:15 ` [PATCHv2 2/3] sunxi:drivers:input:ps2 Added sunxi A10/A20 ps2 driver vishnupatekar
[not found] ` <1417907719-26775-3-git-send-email-VishnuPatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-12-08 4:43 ` Vishnu Patekar
2014-12-08 22:41 ` Maxime Ripard
[not found] ` <CAEzqOZu9TWmYyBOP8t+b7mepqdbKjhf-3P-uNJS_Od05XiBLZw@mail.gmail.com>
[not found] ` <CAEzqOZu9TWmYyBOP8t+b7mepqdbKjhf-3P-uNJS_Od05XiBLZw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-12-11 21:09 ` Maxime Ripard
2014-12-06 23:15 ` [PATCHv2 3/3] ARM:dts:sunxi:ps2 dt nodes for A10/A20 PS2 controller vishnupatekar
[not found] ` <1417907719-26775-4-git-send-email-VishnuPatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-12-08 22:22 ` Maxime Ripard
2014-12-12 13:15 ` [PATCHv2 0/3] ARM:sunxi:ps2 Added support for A10/A20 ps2 controller Hans de Goede
[not found] ` <548AEA8E.6040100-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-12-12 13:55 ` Vishnu Patekar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).