From patchwork Sat Jun 9 14:02:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10455969 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5ED3C601F7 for ; Sat, 9 Jun 2018 14:20:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 498E0223A5 for ; Sat, 9 Jun 2018 14:20:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 399D5223B2; Sat, 9 Jun 2018 14:20:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B2073223A5 for ; Sat, 9 Jun 2018 14:20:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=v9v691sxIRqhHQlazPkVohtj+umiVbWE8vSSNMZmZOE=; b=tniJ/MKczbhtcnhyV2nmJFHw3U g2oH7zhxgkt2OxxpEx6kKy2WH6gFJkvPvdZmakrCIIttiFeaVUjVrdXyQEv8BOGShqd4O3av3TpqH vh7ZPH4i86Ap6rNJOpfMPHok52JYT4l8ujzFibNtpbdebeME8rFVz5pGP7jPqtHaYmzg2Rs+qE9BS eSTQpJCWFmyLXBmY5uyz5iiESYdbYR+2xVRoUDTxMDGFTwuAw95fLtSl8MAWDhHmmyDQHM/XWUQOG 3vLBdE8Uqyaaxw3EHjFjabjQTlfPsO5bAmcU8VoCXa6UL+hvzcc2qBQQU+0Ii6MYfsSLPoVI7431V 5DXOf97Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fReid-0001jc-8a; Sat, 09 Jun 2018 14:19:51 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fReiX-0001Hw-GW for linux-arm-kernel@bombadil.infradead.org; Sat, 09 Jun 2018 14:19:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=+QPyrYS4WwtnWSitmH1oh1ZsjI4BS+MGw3iyHI7mubc=; b=avdtAiv3t5+U9WcdYBGi1fcbY esydoGsflRMQ0/6SwG94ca3yzrPWVfvT2ztzw7io0NNScd6BiLUyd1Exz3UyeLLXVJVjN7txSJvIy owlxdVOQBN0yb0dbg7eBfonnR46U+y6OQpd+iT2z2YehOwV/zpRh8uXV3YoW/eKFl9EjcF4yNux4F IJvuOTdtjkg+MT4qr8qWb+F5QZ8x8VCaSPipoQKfjwLcZPjCtKuUGmVU8fYgEm5QTqWghAfDpij5Y e48Z9SowJljxG65QAH6Yyj7WOW23XGT9/t8ShZ1lU2g1f0kW432rtyLi2FK6wyPTBW0r/VWXKAf4e 7zIdseERw==; Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fReSk-0007Wy-BI for linux-arm-kernel@lists.infradead.org; Sat, 09 Jun 2018 14:03:28 +0000 Received: by mail-lf0-x244.google.com with SMTP id y20-v6so24232231lfy.0 for ; Sat, 09 Jun 2018 07:03:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+QPyrYS4WwtnWSitmH1oh1ZsjI4BS+MGw3iyHI7mubc=; b=PCDkJURhMh7lxQrUlpcUWQLc3zgH9D+8bIDJ/b/LX5HiG9nkV6PiuWUZcz5sceqacH jMs8b+P3Zk7ozrAFmVnGePR9c8NZ0OIEgxERW8jl7ZDPPr+nkRt9RRVI8GIkD2rQsIw4 oMVHCvwsMtbzdYo2O15ASgLlLxrOuTfuTUnX+teBE11mVvRsrn0mYKcYijp38vbEXDOf lP2LiVb/lfvxAoYZVK3lw72fJqyZieGY1J2Duo1FHsxItQwTxjl/Tptr7Hqm54zCareC dHAYi7PWJnQ78y/mCXzBNuRLm+NBqaVz0VGAYO20aQTUWHySCrFVBmvm/Pi2NoKCksae cByA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+QPyrYS4WwtnWSitmH1oh1ZsjI4BS+MGw3iyHI7mubc=; b=l9lVsD7Wk9QGUbNavRVlwZg7TVKetGqpZnTo5vZ2QJLZRYmXJecrlHf5mDp+u0pShz 7EQPZNyXzAsDmaxzHxcYQof7m0g+Bf9Tg+cHl41LjSo5ugGVtuNAsgaEe+rqHOIVg4ec o94mHEyUBuPsTmqjynmDJ57GwmRGXXy3ZPiGXqNv9iiEIMka8JkRkHxVYsr+k65dzJGh WDGBn7bf/DCdZDBs4FtuzaneZPDugDRmihI2salhFI62HHESjZsPveUGO1yWVucm2L8T tFkVXQIMND4n+m8IgdWYdel1U3ZMa+nOugjHHxaYi9ZABimvbLCoP5eYzuEiWJKYowiK d0zg== X-Gm-Message-State: APt69E2cfNjMpdPaMgZTTMLAa0QhFjz7W1oTEgt6UdKk+refgoqaxZYl gPt/eEsYjZmXgjs9gitbZSU= X-Google-Smtp-Source: ADUXVKJd/7+MMEInWPMeQgAKEkv2DQ+OewK+CjeSMVYWgZqgKMJH7hJQymCMN9KtzXPsHxhp37RdvA== X-Received: by 2002:a19:1c5:: with SMTP id 188-v6mr6705941lfb.67.1528553000773; Sat, 09 Jun 2018 07:03:20 -0700 (PDT) Received: from localhost.localdomain (apn-31-0-40-98.dynamic.gprs.plus.pl. [31.0.40.98]) by smtp.gmail.com with ESMTPSA id n84-v6sm4477727lfi.19.2018.06.09.07.03.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Jun 2018 07:03:20 -0700 (PDT) From: Janusz Krzysztofik To: Dmitry Torokhov , Tony Lindgren , Aaro Koskinen Subject: [PATCH 09/10] Input: ams_delta_serio: use IRQ resource Date: Sat, 9 Jun 2018 16:02:23 +0200 Message-Id: <20180609140224.32606-9-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180609140224.32606-1-jmkrzyszt@gmail.com> References: <20180609140224.32606-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180609_150326_542393_9A43D7BC X-CRM114-Status: GOOD ( 27.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kroah-Hartman , Linus Walleij , Randy Dunlap , Janusz Krzysztofik , Liam Girdwood , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Mark Brown , linux-input@vger.kernel.org, Mauro Carvalho Chehab , Andrew Morton , linux-omap@vger.kernel.org, "David S . Miller" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The driver still obtains IRQ number from a hardcoded GPIO. Use IRQ resource instead. For this to work on Amstrad Delta, add the IRQ resource to ams-delta-serio platform device structure. Obtain the IRQ number assigned to "keyboard_clk" GPIO pin from FIQ initialization routine. As a benefit, the driver no longer needs to include . Signed-off-by: Janusz Krzysztofik --- arch/arm/mach-omap1/ams-delta-fiq.c | 8 +++++++- arch/arm/mach-omap1/ams-delta-fiq.h | 3 ++- arch/arm/mach-omap1/board-ams-delta.c | 17 ++++++++++++++++- drivers/input/serio/ams_delta_serio.c | 28 ++++++++++------------------ 4 files changed, 35 insertions(+), 21 deletions(-) diff --git a/arch/arm/mach-omap1/ams-delta-fiq.c b/arch/arm/mach-omap1/ams-delta-fiq.c index e72935034d42..e9d350117240 100644 --- a/arch/arm/mach-omap1/ams-delta-fiq.c +++ b/arch/arm/mach-omap1/ams-delta-fiq.c @@ -20,6 +20,7 @@ #include #include #include +#include #include @@ -84,7 +85,8 @@ static irqreturn_t deferred_fiq(int irq, void *dev_id) return IRQ_HANDLED; } -void __init ams_delta_init_fiq(struct gpio_chip *chip) +void __init ams_delta_init_fiq(struct gpio_chip *chip, + struct platform_device *serio) { struct gpio_desc *gpiod, *data = NULL, *clk = NULL; void *fiqhandler_start; @@ -201,6 +203,10 @@ void __init ams_delta_init_fiq(struct gpio_chip *chip) val = omap_readl(OMAP_IH1_BASE + offset) | 1; omap_writel(val, OMAP_IH1_BASE + offset); + /* Initialize serio device IRQ resource */ + serio->resource[0].start = gpiod_to_irq(clk); + serio->resource[0].end = serio->resource[0].start; + return; out_gpio: diff --git a/arch/arm/mach-omap1/ams-delta-fiq.h b/arch/arm/mach-omap1/ams-delta-fiq.h index 3f691d68aa62..fd76df3cce37 100644 --- a/arch/arm/mach-omap1/ams-delta-fiq.h +++ b/arch/arm/mach-omap1/ams-delta-fiq.h @@ -35,7 +35,8 @@ #ifndef __ASSEMBLER__ extern unsigned char qwerty_fiqin_start, qwerty_fiqin_end; -extern void __init ams_delta_init_fiq(struct gpio_chip *chip); +extern void __init ams_delta_init_fiq(struct gpio_chip *chip, + struct platform_device *pdev); #endif #endif diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index fe9a3e7cbfeb..84177ba3e39a 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c @@ -504,9 +504,24 @@ static struct platform_device cx20442_codec_device = { .id = -1, }; +static struct resource ams_delta_serio_resources[] = { + { + .flags = IORESOURCE_IRQ, + /* + * Initialize IRQ resource with invalid IRQ number. + * It will be replaced with dynamically allocated GPIO IRQ + * obtained from GPIO chip as soon as the chip is available. + */ + .start = -EINVAL, + .end = -EINVAL, + }, +}; + static struct platform_device ams_delta_serio_device = { .name = "ams-delta-serio", .id = PLATFORM_DEVID_NONE, + .num_resources = ARRAY_SIZE(ams_delta_serio_resources), + .resource = ams_delta_serio_resources, }; static struct regulator_consumer_supply keybrd_pwr_consumers[] = { @@ -615,7 +630,7 @@ static void __init omap_gpio_deps_init(void) return; } - ams_delta_init_fiq(chip); + ams_delta_init_fiq(chip, &ams_delta_serio_device); } static void __init ams_delta_init(void) diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c index 5d0bd2005648..03640b171516 100644 --- a/drivers/input/serio/ams_delta_serio.c +++ b/drivers/input/serio/ams_delta_serio.c @@ -20,7 +20,6 @@ * However, when used with the E3 mailboard that producecs non-standard * scancodes, a custom key table must be prepared and loaded from userspace. */ -#include #include #include #include @@ -29,8 +28,6 @@ #include #include -#include - #define DRIVER_NAME "ams-delta-serio" MODULE_AUTHOR("Matt Callow"); @@ -113,7 +110,7 @@ static int ams_delta_serio_init(struct platform_device *pdev) { struct ams_delta_serio *priv; struct serio *serio; - int err; + int irq, err; priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) @@ -129,9 +126,12 @@ static int ams_delta_serio_init(struct platform_device *pdev) return err; } - err = request_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), - ams_delta_serio_interrupt, IRQ_TYPE_EDGE_RISING, - DRIVER_NAME, priv); + irq = platform_get_irq(pdev, 0); + if (irq < 0) + return -ENXIO; + + err = devm_request_irq(&pdev->dev, irq, ams_delta_serio_interrupt, + IRQ_TYPE_EDGE_RISING, DRIVER_NAME, priv); if (err < 0) { dev_err(&pdev->dev, "IRQ request failed (%d)\n", err); return err; @@ -141,14 +141,11 @@ static int ams_delta_serio_init(struct platform_device *pdev) * at FIQ level, switch back from edge to simple interrupt handler * to avoid bad interaction. */ - irq_set_handler(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), - handle_simple_irq); + irq_set_handler(irq, handle_simple_irq); serio = kzalloc(sizeof(*serio), GFP_KERNEL); - if (!serio) { - err = -ENOMEM; - goto irq; - } + if (!serio) + return -ENOMEM; priv->serio = serio; @@ -167,10 +164,6 @@ static int ams_delta_serio_init(struct platform_device *pdev) dev_info(&serio->dev, "%s\n", serio->name); return 0; - -irq: - free_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), priv); - return err; } static int ams_delta_serio_exit(struct platform_device *pdev) @@ -178,7 +171,6 @@ static int ams_delta_serio_exit(struct platform_device *pdev) struct ams_delta_serio *priv = platform_get_drvdata(pdev); serio_unregister_port(priv->serio); - free_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0); return 0; }