All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] powerpc: Add i8042 keyboard and mouse irq parsing
@ 2010-05-24 16:25 ` Martyn Welch
  0 siblings, 0 replies; 6+ messages in thread
From: Martyn Welch @ 2010-05-24 16:25 UTC (permalink / raw)
  To: Grant Likely, benh; +Cc: Dmitry Torokhov, linuxppc-dev, linux-input

Currently the irqs for the i8042, which historically provides keyboard and
mouse (aux) support, is hardwired in the driver rather than parsing the
dts.  This patch modifies the powerpc legacy IO code to attempt to parse
the device tree for this information, failing back to the hardcoded values
if it fails.

Signed-off-by: Martyn Welch <martyn.welch@ge.com>
---

v2: This patch no longer requires the DTS files to be modified, reading the
interrupts from the current location as suggested by Grant.

 arch/powerpc/kernel/setup-common.c |   49 ++++++++++++++++++++++++++++++++++--
 drivers/input/serio/i8042-io.h     |    8 ++++++
 2 files changed, 54 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 48f0a00..7f1bb99 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -94,6 +94,10 @@ struct screen_info screen_info = {
 	.orig_video_points = 16
 };
 
+/* Variables required to store legacy IO irq routing */
+int of_i8042_kbd_irq;
+int of_i8042_aux_irq;
+
 #ifdef __DO_IRQ_CANON
 /* XXX should go elsewhere eventually */
 int ppc_do_canonicalize_irqs;
@@ -558,13 +562,52 @@ void probe_machine(void)
 /* Match a class of boards, not a specific device configuration. */
 int check_legacy_ioport(unsigned long base_port)
 {
-	struct device_node *parent, *np = NULL;
+	struct device_node *parent, *np = NULL, *np_aux = NULL;
 	int ret = -ENODEV;
 
 	switch(base_port) {
 	case I8042_DATA_REG:
-		if (!(np = of_find_compatible_node(NULL, NULL, "pnpPNP,303")))
-			np = of_find_compatible_node(NULL, NULL, "pnpPNP,f03");
+		np = of_find_compatible_node(NULL, NULL, "pnpPNP,303");
+		if (np) {
+			/* Interrupt routing in parent node */
+			parent = of_get_parent(np);
+			if (parent) {
+				/*
+				 * Attempt to parse DTS for keyboard irq,
+				 * fallback to standard.
+				 */
+				of_i8042_kbd_irq = irq_of_parse_and_map(parent,
+					0);
+				if (!of_i8042_kbd_irq)
+					of_i8042_kbd_irq = 1;
+
+				of_node_put(parent);
+			}
+		}
+
+		np_aux = of_find_compatible_node(NULL, NULL, "pnpPNP,f03");
+		if (np_aux) {
+			if (!np) {
+				of_node_put(np);
+				np = np_aux;
+			}
+
+			/* Interrupt routing in parent node */
+			parent = of_get_parent(np_aux);
+			if (parent) {
+				/*
+				 * Attempt to parse DTS for mouse (aux) irq,
+				 * fallback to standard.
+				 */
+				of_i8042_aux_irq = irq_of_parse_and_map(parent,
+					1);
+				if (!of_i8042_aux_irq)
+					of_i8042_aux_irq = 12;
+
+				of_node_put(parent);
+			}
+		}
+
 		if (np) {
 			parent = of_get_parent(np);
 			of_node_put(np);
diff --git a/drivers/input/serio/i8042-io.h b/drivers/input/serio/i8042-io.h
index 847f4aa..8fc8753 100644
--- a/drivers/input/serio/i8042-io.h
+++ b/drivers/input/serio/i8042-io.h
@@ -19,6 +19,11 @@
  * IRQs.
  */
 
+#if defined(CONFIG_PPC)
+extern int of_i8042_kbd_irq;
+extern int of_i8042_aux_irq;
+#endif
+
 #ifdef __alpha__
 # define I8042_KBD_IRQ	1
 # define I8042_AUX_IRQ	(RTC_PORT(0) == 0x170 ? 9 : 12)	/* Jensen is special */
@@ -27,6 +32,9 @@
 #include <asm/irq.h>
 #elif defined(CONFIG_SH_CAYMAN)
 #include <asm/irq.h>
+#elif defined(CONFIG_PPC)
+#define I8042_KBD_IRQ	of_i8042_kbd_irq
+#define I8042_AUX_IRQ	of_i8042_aux_irq
 #else
 # define I8042_KBD_IRQ	1
 # define I8042_AUX_IRQ	12


--
Martyn Welch (Principal Software Engineer)   |   Registered in England and
GE Intelligent Platforms                     |   Wales (3828642) at 100
T +44(0)127322748                            |   Barbirolli Square, Manchester,
E martyn.welch@ge.com                        |   M2 3AB  VAT:GB 927559189

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2] powerpc: Add i8042 keyboard and mouse irq parsing
@ 2010-05-24 16:25 ` Martyn Welch
  0 siblings, 0 replies; 6+ messages in thread
From: Martyn Welch @ 2010-05-24 16:25 UTC (permalink / raw)
  To: Grant Likely, benh; +Cc: linuxppc-dev, Dmitry Torokhov, linux-input

Currently the irqs for the i8042, which historically provides keyboard and
mouse (aux) support, is hardwired in the driver rather than parsing the
dts.  This patch modifies the powerpc legacy IO code to attempt to parse
the device tree for this information, failing back to the hardcoded values
if it fails.

Signed-off-by: Martyn Welch <martyn.welch@ge.com>
---

v2: This patch no longer requires the DTS files to be modified, reading the
interrupts from the current location as suggested by Grant.

 arch/powerpc/kernel/setup-common.c |   49 ++++++++++++++++++++++++++++++++++--
 drivers/input/serio/i8042-io.h     |    8 ++++++
 2 files changed, 54 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 48f0a00..7f1bb99 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -94,6 +94,10 @@ struct screen_info screen_info = {
 	.orig_video_points = 16
 };
 
+/* Variables required to store legacy IO irq routing */
+int of_i8042_kbd_irq;
+int of_i8042_aux_irq;
+
 #ifdef __DO_IRQ_CANON
 /* XXX should go elsewhere eventually */
 int ppc_do_canonicalize_irqs;
@@ -558,13 +562,52 @@ void probe_machine(void)
 /* Match a class of boards, not a specific device configuration. */
 int check_legacy_ioport(unsigned long base_port)
 {
-	struct device_node *parent, *np = NULL;
+	struct device_node *parent, *np = NULL, *np_aux = NULL;
 	int ret = -ENODEV;
 
 	switch(base_port) {
 	case I8042_DATA_REG:
-		if (!(np = of_find_compatible_node(NULL, NULL, "pnpPNP,303")))
-			np = of_find_compatible_node(NULL, NULL, "pnpPNP,f03");
+		np = of_find_compatible_node(NULL, NULL, "pnpPNP,303");
+		if (np) {
+			/* Interrupt routing in parent node */
+			parent = of_get_parent(np);
+			if (parent) {
+				/*
+				 * Attempt to parse DTS for keyboard irq,
+				 * fallback to standard.
+				 */
+				of_i8042_kbd_irq = irq_of_parse_and_map(parent,
+					0);
+				if (!of_i8042_kbd_irq)
+					of_i8042_kbd_irq = 1;
+
+				of_node_put(parent);
+			}
+		}
+
+		np_aux = of_find_compatible_node(NULL, NULL, "pnpPNP,f03");
+		if (np_aux) {
+			if (!np) {
+				of_node_put(np);
+				np = np_aux;
+			}
+
+			/* Interrupt routing in parent node */
+			parent = of_get_parent(np_aux);
+			if (parent) {
+				/*
+				 * Attempt to parse DTS for mouse (aux) irq,
+				 * fallback to standard.
+				 */
+				of_i8042_aux_irq = irq_of_parse_and_map(parent,
+					1);
+				if (!of_i8042_aux_irq)
+					of_i8042_aux_irq = 12;
+
+				of_node_put(parent);
+			}
+		}
+
 		if (np) {
 			parent = of_get_parent(np);
 			of_node_put(np);
diff --git a/drivers/input/serio/i8042-io.h b/drivers/input/serio/i8042-io.h
index 847f4aa..8fc8753 100644
--- a/drivers/input/serio/i8042-io.h
+++ b/drivers/input/serio/i8042-io.h
@@ -19,6 +19,11 @@
  * IRQs.
  */
 
+#if defined(CONFIG_PPC)
+extern int of_i8042_kbd_irq;
+extern int of_i8042_aux_irq;
+#endif
+
 #ifdef __alpha__
 # define I8042_KBD_IRQ	1
 # define I8042_AUX_IRQ	(RTC_PORT(0) == 0x170 ? 9 : 12)	/* Jensen is special */
@@ -27,6 +32,9 @@
 #include <asm/irq.h>
 #elif defined(CONFIG_SH_CAYMAN)
 #include <asm/irq.h>
+#elif defined(CONFIG_PPC)
+#define I8042_KBD_IRQ	of_i8042_kbd_irq
+#define I8042_AUX_IRQ	of_i8042_aux_irq
 #else
 # define I8042_KBD_IRQ	1
 # define I8042_AUX_IRQ	12


--
Martyn Welch (Principal Software Engineer)   |   Registered in England and
GE Intelligent Platforms                     |   Wales (3828642) at 100
T +44(0)127322748                            |   Barbirolli Square, Manchester,
E martyn.welch@ge.com                        |   M2 3AB  VAT:GB 927559189

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] powerpc: Add i8042 keyboard and mouse irq parsing
  2010-05-24 16:25 ` Martyn Welch
@ 2010-05-24 17:33   ` Grant Likely
  -1 siblings, 0 replies; 6+ messages in thread
From: Grant Likely @ 2010-05-24 17:33 UTC (permalink / raw)
  To: Martyn Welch; +Cc: benh, Dmitry Torokhov, linuxppc-dev, linux-input

On Mon, May 24, 2010 at 10:25 AM, Martyn Welch <martyn.welch@ge.com> wrote:
> Currently the irqs for the i8042, which historically provides keyboard and
> mouse (aux) support, is hardwired in the driver rather than parsing the
> dts.  This patch modifies the powerpc legacy IO code to attempt to parse
> the device tree for this information, failing back to the hardcoded values
> if it fails.
>
> Signed-off-by: Martyn Welch <martyn.welch@ge.com>
> ---
>
> v2: This patch no longer requires the DTS files to be modified, reading the
> interrupts from the current location as suggested by Grant.
>
>  arch/powerpc/kernel/setup-common.c |   49 ++++++++++++++++++++++++++++++++++--
>  drivers/input/serio/i8042-io.h     |    8 ++++++
>  2 files changed, 54 insertions(+), 3 deletions(-)
>
> diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
> index 48f0a00..7f1bb99 100644
> --- a/arch/powerpc/kernel/setup-common.c
> +++ b/arch/powerpc/kernel/setup-common.c
> @@ -94,6 +94,10 @@ struct screen_info screen_info = {
>        .orig_video_points = 16
>  };
>
> +/* Variables required to store legacy IO irq routing */
> +int of_i8042_kbd_irq;
> +int of_i8042_aux_irq;
> +
>  #ifdef __DO_IRQ_CANON
>  /* XXX should go elsewhere eventually */
>  int ppc_do_canonicalize_irqs;
> @@ -558,13 +562,52 @@ void probe_machine(void)
>  /* Match a class of boards, not a specific device configuration. */
>  int check_legacy_ioport(unsigned long base_port)
>  {
> -       struct device_node *parent, *np = NULL;
> +       struct device_node *parent, *np = NULL, *np_aux = NULL;
>        int ret = -ENODEV;
>
>        switch(base_port) {
>        case I8042_DATA_REG:
> -               if (!(np = of_find_compatible_node(NULL, NULL, "pnpPNP,303")))
> -                       np = of_find_compatible_node(NULL, NULL, "pnpPNP,f03");
> +               np = of_find_compatible_node(NULL, NULL, "pnpPNP,303");
> +               if (np) {
> +                       /* Interrupt routing in parent node */
> +                       parent = of_get_parent(np);
> +                       if (parent) {
> +                               /*
> +                                * Attempt to parse DTS for keyboard irq,
> +                                * fallback to standard.
> +                                */
> +                               of_i8042_kbd_irq = irq_of_parse_and_map(parent,
> +                                       0);
> +                               if (!of_i8042_kbd_irq)
> +                                       of_i8042_kbd_irq = 1;
> +
> +                               of_node_put(parent);
> +                       }
> +               }
> +
> +               np_aux = of_find_compatible_node(NULL, NULL, "pnpPNP,f03");
> +               if (np_aux) {
> +                       if (!np) {
> +                               of_node_put(np);
> +                               np = np_aux;
> +                       }
> +
> +                       /* Interrupt routing in parent node */
> +                       parent = of_get_parent(np_aux);
> +                       if (parent) {
> +                               /*
> +                                * Attempt to parse DTS for mouse (aux) irq,
> +                                * fallback to standard.
> +                                */
> +                               of_i8042_aux_irq = irq_of_parse_and_map(parent,
> +                                       1);
> +                               if (!of_i8042_aux_irq)
> +                                       of_i8042_aux_irq = 12;
> +
> +                               of_node_put(parent);
> +                       }
> +               }
> +

This seems to be a lot more code that you need.  The existing code
already obtains a pointer to the parent node for you.  All you really
should need to add is the two calls to irq_of_parse_and_map() for
obtaining the kbd and aux irq numbers.

>                if (np) {
>                        parent = of_get_parent(np);
>                        of_node_put(np);
> diff --git a/drivers/input/serio/i8042-io.h b/drivers/input/serio/i8042-io.h
> index 847f4aa..8fc8753 100644
> --- a/drivers/input/serio/i8042-io.h
> +++ b/drivers/input/serio/i8042-io.h
> @@ -19,6 +19,11 @@
>  * IRQs.
>  */
>
> +#if defined(CONFIG_PPC)
> +extern int of_i8042_kbd_irq;
> +extern int of_i8042_aux_irq;
> +#endif

Please fold these two extern definitions into the #elif
defined(CONFIG_PPC) block below.

> +
>  #ifdef __alpha__
>  # define I8042_KBD_IRQ 1
>  # define I8042_AUX_IRQ (RTC_PORT(0) == 0x170 ? 9 : 12) /* Jensen is special */
> @@ -27,6 +32,9 @@
>  #include <asm/irq.h>
>  #elif defined(CONFIG_SH_CAYMAN)
>  #include <asm/irq.h>
> +#elif defined(CONFIG_PPC)
> +#define I8042_KBD_IRQ  of_i8042_kbd_irq
> +#define I8042_AUX_IRQ  of_i8042_aux_irq
>  #else
>  # define I8042_KBD_IRQ 1
>  # define I8042_AUX_IRQ 12

Cheers,
g.
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] powerpc: Add i8042 keyboard and mouse irq parsing
@ 2010-05-24 17:33   ` Grant Likely
  0 siblings, 0 replies; 6+ messages in thread
From: Grant Likely @ 2010-05-24 17:33 UTC (permalink / raw)
  To: Martyn Welch; +Cc: Dmitry Torokhov, linux-input, linuxppc-dev

On Mon, May 24, 2010 at 10:25 AM, Martyn Welch <martyn.welch@ge.com> wrote:
> Currently the irqs for the i8042, which historically provides keyboard an=
d
> mouse (aux) support, is hardwired in the driver rather than parsing the
> dts. =A0This patch modifies the powerpc legacy IO code to attempt to pars=
e
> the device tree for this information, failing back to the hardcoded value=
s
> if it fails.
>
> Signed-off-by: Martyn Welch <martyn.welch@ge.com>
> ---
>
> v2: This patch no longer requires the DTS files to be modified, reading t=
he
> interrupts from the current location as suggested by Grant.
>
> =A0arch/powerpc/kernel/setup-common.c | =A0 49 ++++++++++++++++++++++++++=
++++++++--
> =A0drivers/input/serio/i8042-io.h =A0 =A0 | =A0 =A08 ++++++
> =A02 files changed, 54 insertions(+), 3 deletions(-)
>
> diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/set=
up-common.c
> index 48f0a00..7f1bb99 100644
> --- a/arch/powerpc/kernel/setup-common.c
> +++ b/arch/powerpc/kernel/setup-common.c
> @@ -94,6 +94,10 @@ struct screen_info screen_info =3D {
> =A0 =A0 =A0 =A0.orig_video_points =3D 16
> =A0};
>
> +/* Variables required to store legacy IO irq routing */
> +int of_i8042_kbd_irq;
> +int of_i8042_aux_irq;
> +
> =A0#ifdef __DO_IRQ_CANON
> =A0/* XXX should go elsewhere eventually */
> =A0int ppc_do_canonicalize_irqs;
> @@ -558,13 +562,52 @@ void probe_machine(void)
> =A0/* Match a class of boards, not a specific device configuration. */
> =A0int check_legacy_ioport(unsigned long base_port)
> =A0{
> - =A0 =A0 =A0 struct device_node *parent, *np =3D NULL;
> + =A0 =A0 =A0 struct device_node *parent, *np =3D NULL, *np_aux =3D NULL;
> =A0 =A0 =A0 =A0int ret =3D -ENODEV;
>
> =A0 =A0 =A0 =A0switch(base_port) {
> =A0 =A0 =A0 =A0case I8042_DATA_REG:
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!(np =3D of_find_compatible_node(NULL, =
NULL, "pnpPNP,303")))
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 np =3D of_find_compatible_n=
ode(NULL, NULL, "pnpPNP,f03");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 np =3D of_find_compatible_node(NULL, NULL, =
"pnpPNP,303");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (np) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Interrupt routing in par=
ent node */
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 parent =3D of_get_parent(np=
);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (parent) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /*
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* Attemp=
t to parse DTS for keyboard irq,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* fallba=
ck to standard.
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*/
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 of_i8042_kb=
d_irq =3D irq_of_parse_and_map(parent,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 0);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!of_i80=
42_kbd_irq)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 of_i8042_kbd_irq =3D 1;
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 of_node_put=
(parent);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 np_aux =3D of_find_compatible_node(NULL, NU=
LL, "pnpPNP,f03");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (np_aux) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!np) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 of_node_put=
(np);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 np =3D np_a=
ux;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Interrupt routing in par=
ent node */
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 parent =3D of_get_parent(np=
_aux);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (parent) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /*
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* Attemp=
t to parse DTS for mouse (aux) irq,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* fallba=
ck to standard.
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*/
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 of_i8042_au=
x_irq =3D irq_of_parse_and_map(parent,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 1);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!of_i80=
42_aux_irq)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 of_i8042_aux_irq =3D 12;
> +
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 of_node_put=
(parent);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> +

This seems to be a lot more code that you need.  The existing code
already obtains a pointer to the parent node for you.  All you really
should need to add is the two calls to irq_of_parse_and_map() for
obtaining the kbd and aux irq numbers.

> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (np) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0parent =3D of_get_parent(n=
p);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0of_node_put(np);
> diff --git a/drivers/input/serio/i8042-io.h b/drivers/input/serio/i8042-i=
o.h
> index 847f4aa..8fc8753 100644
> --- a/drivers/input/serio/i8042-io.h
> +++ b/drivers/input/serio/i8042-io.h
> @@ -19,6 +19,11 @@
> =A0* IRQs.
> =A0*/
>
> +#if defined(CONFIG_PPC)
> +extern int of_i8042_kbd_irq;
> +extern int of_i8042_aux_irq;
> +#endif

Please fold these two extern definitions into the #elif
defined(CONFIG_PPC) block below.

> +
> =A0#ifdef __alpha__
> =A0# define I8042_KBD_IRQ 1
> =A0# define I8042_AUX_IRQ (RTC_PORT(0) =3D=3D 0x170 ? 9 : 12) /* Jensen i=
s special */
> @@ -27,6 +32,9 @@
> =A0#include <asm/irq.h>
> =A0#elif defined(CONFIG_SH_CAYMAN)
> =A0#include <asm/irq.h>
> +#elif defined(CONFIG_PPC)
> +#define I8042_KBD_IRQ =A0of_i8042_kbd_irq
> +#define I8042_AUX_IRQ =A0of_i8042_aux_irq
> =A0#else
> =A0# define I8042_KBD_IRQ 1
> =A0# define I8042_AUX_IRQ 12

Cheers,
g.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] powerpc: Add i8042 keyboard and mouse irq parsing
  2010-05-24 17:33   ` Grant Likely
@ 2010-05-25  7:52     ` Martyn Welch
  -1 siblings, 0 replies; 6+ messages in thread
From: Martyn Welch @ 2010-05-25  7:52 UTC (permalink / raw)
  To: Grant Likely; +Cc: benh, Dmitry Torokhov, linuxppc-dev, linux-input

Grant Likely wrote:
> On Mon, May 24, 2010 at 10:25 AM, Martyn Welch <martyn.welch@ge.com> wrote:
>   
>> Currently the irqs for the i8042, which historically provides keyboard and
>> mouse (aux) support, is hardwired in the driver rather than parsing the
>> dts.  This patch modifies the powerpc legacy IO code to attempt to parse
>> the device tree for this information, failing back to the hardcoded values
>> if it fails.
>>
>> Signed-off-by: Martyn Welch <martyn.welch@ge.com>
>> ---
>>
>> v2: This patch no longer requires the DTS files to be modified, reading the
>> interrupts from the current location as suggested by Grant.
>>
>>  arch/powerpc/kernel/setup-common.c |   49 ++++++++++++++++++++++++++++++++++--
>>  drivers/input/serio/i8042-io.h     |    8 ++++++
>>  2 files changed, 54 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
>> index 48f0a00..7f1bb99 100644
>> --- a/arch/powerpc/kernel/setup-common.c
>> +++ b/arch/powerpc/kernel/setup-common.c
>> @@ -94,6 +94,10 @@ struct screen_info screen_info = {
>>        .orig_video_points = 16
>>  };
>>
>> +/* Variables required to store legacy IO irq routing */
>> +int of_i8042_kbd_irq;
>> +int of_i8042_aux_irq;
>> +
>>  #ifdef __DO_IRQ_CANON
>>  /* XXX should go elsewhere eventually */
>>  int ppc_do_canonicalize_irqs;
>> @@ -558,13 +562,52 @@ void probe_machine(void)
>>  /* Match a class of boards, not a specific device configuration. */
>>  int check_legacy_ioport(unsigned long base_port)
>>  {
>> -       struct device_node *parent, *np = NULL;
>> +       struct device_node *parent, *np = NULL, *np_aux = NULL;
>>        int ret = -ENODEV;
>>
>>        switch(base_port) {
>>        case I8042_DATA_REG:
>> -               if (!(np = of_find_compatible_node(NULL, NULL, "pnpPNP,303")))
>> -                       np = of_find_compatible_node(NULL, NULL, "pnpPNP,f03");
>> +               np = of_find_compatible_node(NULL, NULL, "pnpPNP,303");
>> +               if (np) {
>> +                       /* Interrupt routing in parent node */
>> +                       parent = of_get_parent(np);
>> +                       if (parent) {
>> +                               /*
>> +                                * Attempt to parse DTS for keyboard irq,
>> +                                * fallback to standard.
>> +                                */
>> +                               of_i8042_kbd_irq = irq_of_parse_and_map(parent,
>> +                                       0);
>> +                               if (!of_i8042_kbd_irq)
>> +                                       of_i8042_kbd_irq = 1;
>> +
>> +                               of_node_put(parent);
>> +                       }
>> +               }
>> +
>> +               np_aux = of_find_compatible_node(NULL, NULL, "pnpPNP,f03");
>> +               if (np_aux) {
>> +                       if (!np) {
>> +                               of_node_put(np);
>> +                               np = np_aux;
>> +                       }
>> +
>> +                       /* Interrupt routing in parent node */
>> +                       parent = of_get_parent(np_aux);
>> +                       if (parent) {
>> +                               /*
>> +                                * Attempt to parse DTS for mouse (aux) irq,
>> +                                * fallback to standard.
>> +                                */
>> +                               of_i8042_aux_irq = irq_of_parse_and_map(parent,
>> +                                       1);
>> +                               if (!of_i8042_aux_irq)
>> +                                       of_i8042_aux_irq = 12;
>> +
>> +                               of_node_put(parent);
>> +                       }
>> +               }
>> +
>>     
>
> This seems to be a lot more code that you need.  The existing code
> already obtains a pointer to the parent node for you.  All you really
> should need to add is the two calls to irq_of_parse_and_map() for
> obtaining the kbd and aux irq numbers.
>   

Your right - new patch on it's way.

>>                if (np) {
>>                        parent = of_get_parent(np);
>>                        of_node_put(np);
>> diff --git a/drivers/input/serio/i8042-io.h b/drivers/input/serio/i8042-io.h
>> index 847f4aa..8fc8753 100644
>> --- a/drivers/input/serio/i8042-io.h
>> +++ b/drivers/input/serio/i8042-io.h
>> @@ -19,6 +19,11 @@
>>  * IRQs.
>>  */
>>
>> +#if defined(CONFIG_PPC)
>> +extern int of_i8042_kbd_irq;
>> +extern int of_i8042_aux_irq;
>> +#endif
>>     
>
> Please fold these two extern definitions into the #elif
> defined(CONFIG_PPC) block below.
>   

Will do.

>> +
>>  #ifdef __alpha__
>>  # define I8042_KBD_IRQ 1
>>  # define I8042_AUX_IRQ (RTC_PORT(0) == 0x170 ? 9 : 12) /* Jensen is special */
>> @@ -27,6 +32,9 @@
>>  #include <asm/irq.h>
>>  #elif defined(CONFIG_SH_CAYMAN)
>>  #include <asm/irq.h>
>> +#elif defined(CONFIG_PPC)
>> +#define I8042_KBD_IRQ  of_i8042_kbd_irq
>> +#define I8042_AUX_IRQ  of_i8042_aux_irq
>>  #else
>>  # define I8042_KBD_IRQ 1
>>  # define I8042_AUX_IRQ 12
>>     
>
> Cheers,
> g.
>   


-- 
Martyn Welch (Principal Software Engineer)   |   Registered in England and
GE Intelligent Platforms                     |   Wales (3828642) at 100
T +44(0)127322748                            |   Barbirolli Square, Manchester,
E martyn.welch@ge.com                        |   M2 3AB  VAT:GB 927559189


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] powerpc: Add i8042 keyboard and mouse irq parsing
@ 2010-05-25  7:52     ` Martyn Welch
  0 siblings, 0 replies; 6+ messages in thread
From: Martyn Welch @ 2010-05-25  7:52 UTC (permalink / raw)
  To: Grant Likely; +Cc: Dmitry Torokhov, linux-input, linuxppc-dev

Grant Likely wrote:
> On Mon, May 24, 2010 at 10:25 AM, Martyn Welch <martyn.welch@ge.com> wrote:
>   
>> Currently the irqs for the i8042, which historically provides keyboard and
>> mouse (aux) support, is hardwired in the driver rather than parsing the
>> dts.  This patch modifies the powerpc legacy IO code to attempt to parse
>> the device tree for this information, failing back to the hardcoded values
>> if it fails.
>>
>> Signed-off-by: Martyn Welch <martyn.welch@ge.com>
>> ---
>>
>> v2: This patch no longer requires the DTS files to be modified, reading the
>> interrupts from the current location as suggested by Grant.
>>
>>  arch/powerpc/kernel/setup-common.c |   49 ++++++++++++++++++++++++++++++++++--
>>  drivers/input/serio/i8042-io.h     |    8 ++++++
>>  2 files changed, 54 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
>> index 48f0a00..7f1bb99 100644
>> --- a/arch/powerpc/kernel/setup-common.c
>> +++ b/arch/powerpc/kernel/setup-common.c
>> @@ -94,6 +94,10 @@ struct screen_info screen_info = {
>>        .orig_video_points = 16
>>  };
>>
>> +/* Variables required to store legacy IO irq routing */
>> +int of_i8042_kbd_irq;
>> +int of_i8042_aux_irq;
>> +
>>  #ifdef __DO_IRQ_CANON
>>  /* XXX should go elsewhere eventually */
>>  int ppc_do_canonicalize_irqs;
>> @@ -558,13 +562,52 @@ void probe_machine(void)
>>  /* Match a class of boards, not a specific device configuration. */
>>  int check_legacy_ioport(unsigned long base_port)
>>  {
>> -       struct device_node *parent, *np = NULL;
>> +       struct device_node *parent, *np = NULL, *np_aux = NULL;
>>        int ret = -ENODEV;
>>
>>        switch(base_port) {
>>        case I8042_DATA_REG:
>> -               if (!(np = of_find_compatible_node(NULL, NULL, "pnpPNP,303")))
>> -                       np = of_find_compatible_node(NULL, NULL, "pnpPNP,f03");
>> +               np = of_find_compatible_node(NULL, NULL, "pnpPNP,303");
>> +               if (np) {
>> +                       /* Interrupt routing in parent node */
>> +                       parent = of_get_parent(np);
>> +                       if (parent) {
>> +                               /*
>> +                                * Attempt to parse DTS for keyboard irq,
>> +                                * fallback to standard.
>> +                                */
>> +                               of_i8042_kbd_irq = irq_of_parse_and_map(parent,
>> +                                       0);
>> +                               if (!of_i8042_kbd_irq)
>> +                                       of_i8042_kbd_irq = 1;
>> +
>> +                               of_node_put(parent);
>> +                       }
>> +               }
>> +
>> +               np_aux = of_find_compatible_node(NULL, NULL, "pnpPNP,f03");
>> +               if (np_aux) {
>> +                       if (!np) {
>> +                               of_node_put(np);
>> +                               np = np_aux;
>> +                       }
>> +
>> +                       /* Interrupt routing in parent node */
>> +                       parent = of_get_parent(np_aux);
>> +                       if (parent) {
>> +                               /*
>> +                                * Attempt to parse DTS for mouse (aux) irq,
>> +                                * fallback to standard.
>> +                                */
>> +                               of_i8042_aux_irq = irq_of_parse_and_map(parent,
>> +                                       1);
>> +                               if (!of_i8042_aux_irq)
>> +                                       of_i8042_aux_irq = 12;
>> +
>> +                               of_node_put(parent);
>> +                       }
>> +               }
>> +
>>     
>
> This seems to be a lot more code that you need.  The existing code
> already obtains a pointer to the parent node for you.  All you really
> should need to add is the two calls to irq_of_parse_and_map() for
> obtaining the kbd and aux irq numbers.
>   

Your right - new patch on it's way.

>>                if (np) {
>>                        parent = of_get_parent(np);
>>                        of_node_put(np);
>> diff --git a/drivers/input/serio/i8042-io.h b/drivers/input/serio/i8042-io.h
>> index 847f4aa..8fc8753 100644
>> --- a/drivers/input/serio/i8042-io.h
>> +++ b/drivers/input/serio/i8042-io.h
>> @@ -19,6 +19,11 @@
>>  * IRQs.
>>  */
>>
>> +#if defined(CONFIG_PPC)
>> +extern int of_i8042_kbd_irq;
>> +extern int of_i8042_aux_irq;
>> +#endif
>>     
>
> Please fold these two extern definitions into the #elif
> defined(CONFIG_PPC) block below.
>   

Will do.

>> +
>>  #ifdef __alpha__
>>  # define I8042_KBD_IRQ 1
>>  # define I8042_AUX_IRQ (RTC_PORT(0) == 0x170 ? 9 : 12) /* Jensen is special */
>> @@ -27,6 +32,9 @@
>>  #include <asm/irq.h>
>>  #elif defined(CONFIG_SH_CAYMAN)
>>  #include <asm/irq.h>
>> +#elif defined(CONFIG_PPC)
>> +#define I8042_KBD_IRQ  of_i8042_kbd_irq
>> +#define I8042_AUX_IRQ  of_i8042_aux_irq
>>  #else
>>  # define I8042_KBD_IRQ 1
>>  # define I8042_AUX_IRQ 12
>>     
>
> Cheers,
> g.
>   


-- 
Martyn Welch (Principal Software Engineer)   |   Registered in England and
GE Intelligent Platforms                     |   Wales (3828642) at 100
T +44(0)127322748                            |   Barbirolli Square, Manchester,
E martyn.welch@ge.com                        |   M2 3AB  VAT:GB 927559189

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-05-25  7:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-24 16:25 [PATCH v2] powerpc: Add i8042 keyboard and mouse irq parsing Martyn Welch
2010-05-24 16:25 ` Martyn Welch
2010-05-24 17:33 ` Grant Likely
2010-05-24 17:33   ` Grant Likely
2010-05-25  7:52   ` Martyn Welch
2010-05-25  7:52     ` Martyn Welch

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.