From patchwork Fri May 14 10:35:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martyn Welch X-Patchwork-Id: 52603 X-Patchwork-Delegate: grant.likely@secretlab.ca Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id CCCECB7E1E for ; Fri, 14 May 2010 20:36:09 +1000 (EST) Received: by ozlabs.org (Postfix) id 72DCDB7E16; Fri, 14 May 2010 20:36:02 +1000 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from exprod5og113.obsmtp.com (exprod5og113.obsmtp.com [64.18.0.26]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6E657B7DF6 for ; Fri, 14 May 2010 20:36:00 +1000 (EST) Received: from source ([4.78.218.129]) (using TLSv1) by exprod5ob113.postini.com ([64.18.4.12]) with SMTP ID DSNKS+0njbtcfaX9+CcVrHbMPO8P5OpLXg+X@postini.com; Fri, 14 May 2010 03:36:01 PDT Received: from unknown (HELO alpmlip01.e2k.ad.ge.com) ([3.159.17.48]) by Cinmlip09.e2k.ad.ge.com with ESMTP; 14 May 2010 06:35:56 -0400 Received: from es-j7s4d2j.amer.consind.ge.com ([3.138.54.92]) by alpmlip01.e2k.ad.ge.com with ESMTP; 14 May 2010 06:35:56 -0400 From: Martyn Welch Subject: [PATCH] powerpc: Add i8042 keyboard and mouse irq parsing To: Dmitry Torokhov , benh@kernel.crashing.org Date: Fri, 14 May 2010 11:35:54 +0100 Message-ID: <20100514102905.7807.27638.stgit@ES-J7S4D2J.amer.consind.ge.com> User-Agent: StGIT/0.13 MIME-Version: 1.0 Cc: linuxppc-dev@ozlabs.org, linux-input@vger.kernel.org X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Currently the irqs for the i8042, which historically provides keyboard and mouse (aux) support, is hardwired in the driver rather than parsing the dts. In addition the interrupts are provided in the dts, but in a way that is not easily parsable using irq_of_parse_and_map(). 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. For this to succeed the interrupts for the keyboard and mouse ports need to be moved from the parent i8042 node to the individual port nodes. Signed-off-by: Martyn Welch --- To get irq_of_parse_and_map() to successfully parse the interrupts, I had to do this to my device tree: @@ -120,16 +120,17 @@ #address-cells = <1>; reg = <1 0x60 0x1 1 0x64 0x1>; - interrupts = <1 1 12 1>; interrupt-parent = <&lpc_pic>; keyboard@0 { reg = <0x0>; + interrupts = <1 1>; compatible = "pnpPNP,303"; }; mouse@1 { reg = <0x1>; + interrupts = <12 1>; compatible = "pnpPNP,f03"; }; }; I'm not sure how to parse for the correct interrupt if I don't do this. I this is incorrect and someone could advise me on how the existing device tree layout can be properly parsed, I'll happily modify this patch. arch/powerpc/kernel/setup-common.c | 34 +++++++++++++++++++++++++++++++--- drivers/input/serio/i8042-io.h | 8 ++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) -- 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 diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c index 03dd6a2..9c4dc4c 100644 --- a/arch/powerpc/kernel/setup-common.c +++ b/arch/powerpc/kernel/setup-common.c @@ -93,6 +93,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; @@ -555,13 +559,37 @@ 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) { + /* + * Attempt to parse DTS for keyboard irq, fallback to + * standard. + */ + of_i8042_kbd_irq = irq_of_parse_and_map(np, 0); + if (!of_i8042_kbd_irq) + of_i8042_kbd_irq = 1; + } + + np_aux = of_find_compatible_node(NULL, NULL, "pnpPNP,f03"); + if (np_aux) { + if (!np) { + of_node_put(np); + np = np_aux; + } + /* + * Attempt to parse DTS for mouse (aux) irq, fallback to + * standard. + */ + of_i8042_aux_irq = irq_of_parse_and_map(np_aux, 0); + if (!of_i8042_aux_irq) + of_i8042_aux_irq = 12; + } + 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 #elif defined(CONFIG_SH_CAYMAN) #include +#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