From patchwork Thu Jun 21 22:41:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10480905 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 38EBE604D3 for ; Thu, 21 Jun 2018 22:47:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2506F28DD2 for ; Thu, 21 Jun 2018 22:47:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15F3D28F8B; Thu, 21 Jun 2018 22:47:18 +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 8F66C28DD2 for ; Thu, 21 Jun 2018 22:47:17 +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=KfVMVgrxr5K4UoR37y1YzkEO89Ao/Iz1dh4Vwk2MvDM=; b=AF5IMlDdohdzdrDXL/HcbNUuBI CRcKkd+9ogvKTk2bvbuDGYxuXEexVtTenMZ0GNv8AF878+Eu0Bol+CWbFNdMvNzqsELrrKQzPhlDM bIY8iacWWRlDEBu7pv/hl1HmIAExP1f4w58PyOhN+MyOZZREMh6R5NHPu/VdaD1QeT3eaAKbzst5f OBnuuAtfUnzzeMB70Y+junS6WVbo36RTiy/mntRYAVZDVCRpsXRKKW7m+zD7DeCKsf2e1+HJ+vyxh 4Bvrl+v1j1dK2PrVKWm2DS0saK+HuZ/8Q3PDLnamJpJS9/pxnssDtvj//+yT2gAbRXIbzG7cQiuJN yACkXuXA==; 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 1fW8MF-0006pN-9D; Thu, 21 Jun 2018 22:47:15 +0000 Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fW8Hx-0003Xb-3Y for linux-arm-kernel@lists.infradead.org; Thu, 21 Jun 2018 22:43:00 +0000 Received: by mail-lf0-x242.google.com with SMTP id y20-v6so6638482lfy.0 for ; Thu, 21 Jun 2018 15:42:43 -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=ClkxPgg2cZgY5jCJ9+fXxslN8qhP3411BKdrQnTPFLI=; b=tbc08Y/SwwnQKy+mKjzaY0q36BanLdn1ECZ1umiMI/5409ZVjs9UXYG/FOEjgTg8/j BqMpXaY9Qd0Wf9TQoksSPC8tHjHjvm+Ubskci8o7dtDom0qdkpHqZUxzq4C4AK9ysp7a XrInV5lOI1WLkUrk4ehLquw7wSeeRWbGLJkbpFkOUdGoYflG2EhOJG//U7QWN2xG8y85 RagMzvB4Tl2dchsJgwvtTNpxPVc6HRoR9z7p8oeBIAKGqwZ8uskuR31fmycqsDP5hGWP /pG15G7mi7lyo5F9BpiedDkzV8HGVqM+rbo8gLXHE/z4zBTL5QeW3YgTrz1DG+AZvfMm BFaA== 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=ClkxPgg2cZgY5jCJ9+fXxslN8qhP3411BKdrQnTPFLI=; b=lDW9GmpOLo5OV8CmR1amhpdBccKcCmf3C+/CwJ08lv7v/2+ggk5RjjckTimA5UIyaU AKRT7p1A/uOGdLahWtY+dEI+LS85Fxj0awAUPkAj9AsGvzWJNTSO50rC1arlM7cJVJ8m x1aXS0dlOBRZBsd7d3S5FLFfFGSy4sG6rzByjLo5hVqaxXUIFwk45hbU/PCOPW1yI6fM GfmBNWeZnVLDGvSVL7FL38WAHdFVHOZc48Y41wVvN5GekfEn2G6qj1TZHdhSG4WwKX+8 YlvAbjLvDQwLGzpyH1IwiQuQU8H6kj9tbEY2ubYMsV90T5YIhEtWp5f9PfeMQDApL56C N6hQ== X-Gm-Message-State: APt69E34n2/2x5QZAUc7jFpe3vC8LIEjeayY2++bHhaKeEihSdPcT1WK Qgb4BN8dVq1T6KNMm1Qe6aA= X-Google-Smtp-Source: ADUXVKLgscNsqMifD8NGKcZ+xFWQJTEmmUTU1p0Axc0K7lsYYVVatdmn7uJOMDcQkp6hKRcMwkOjIg== X-Received: by 2002:a2e:9516:: with SMTP id f22-v6mr17867717ljh.9.1529620962097; Thu, 21 Jun 2018 15:42:42 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id t6-v6sm1046153lje.18.2018.06.21.15.42.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jun 2018 15:42:41 -0700 (PDT) From: Janusz Krzysztofik To: Dmitry Torokhov , Tony Lindgren , Aaro Koskinen Subject: [PATCH v2 09/10] Input: ams_delta_serio: use IRQ resource Date: Fri, 22 Jun 2018 00:41:27 +0200 Message-Id: <20180621224128.17623-9-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180621224128.17623-1-jmkrzyszt@gmail.com> References: <20180609140224.32606-1-jmkrzyszt@gmail.com> <20180621224128.17623-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180621_154249_170515_3384D101 X-CRM114-Status: GOOD ( 22.89 ) 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 "keybrd_clk" GPIO pin from FIQ initialization routine. As a benefit, the driver no longer needs to include . Signed-off-by: Janusz Krzysztofik Acked-by: Dmitry Torokhov --- Changelog: v2: - obsolete assignment of handle_simple_irq() removed from the driver and replaced with a comment in the FIQ init file, - rebased on v4.18-rc1, no conflicts. arch/arm/mach-omap1/ams-delta-fiq.c | 20 +++++++++++++++++++- 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 | 32 +++++++++----------------------- 4 files changed, 46 insertions(+), 26 deletions(-) diff --git a/arch/arm/mach-omap1/ams-delta-fiq.c b/arch/arm/mach-omap1/ams-delta-fiq.c index e72935034d42..82ca4246a5e4 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,22 @@ 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; + + /* + * Since FIQ handler performs handling of GPIO registers for + * "keybrd_clk" IRQ pin, ams_delta_serio driver used to set + * handle_simple_irq() as active IRQ handler for that pin to avoid + * bad interaction with gpio-omap driver. This is no longer needed + * as handle_simple_irq() is now the default handler for OMAP GPIO + * edge interrupts. + * This comment replaces the obsolete code which has been removed + * from the ams_delta_serio driver and stands here only as a reminder + * of that dependency on gpio-omap driver behavior. + */ + 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 2602f7cff5ae..c1f8226f172e 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) @@ -139,26 +136,20 @@ 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; } - /* - * Since GPIO register handling for keyboard clock pin is performed - * 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); serio = kzalloc(sizeof(*serio), GFP_KERNEL); - if (!serio) { - err = -ENOMEM; - goto irq; - } + if (!serio) + return -ENOMEM; priv->serio = serio; @@ -177,10 +168,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) @@ -188,7 +175,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; }