Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp151751imm; Thu, 21 Jun 2018 15:43:58 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIrYKkbx6+i5pJp55OLykCR1ngEE/EKEXeh2k6nMd8sCclHnDhgPeUB877deLMQ/Smol4Ie X-Received: by 2002:a17:902:6b86:: with SMTP id p6-v6mr30589450plk.75.1529621038197; Thu, 21 Jun 2018 15:43:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529621038; cv=none; d=google.com; s=arc-20160816; b=CfqRvp6lJfx255c6gOpcgg3/CQFbq32S8sGn2Uojl3dfIa/8/iea0YH5jLEEjfC7aB /X0ztY2MUqZA8J1gWYIKSsxvIN/fVJaLI/jgPEi3Nn0s4/EyDcsarbA3nBnWn/ns1/4K EHMU0joAoITVh7Du/5kKkT4dCM7hHy8j7lj3Y0BkBaimv2TTOpI2JvNjdQfB2vXPvn+y HS6E92ZOTrC+AD31minhzqu5N7vpcJ3VvaxUe2xf0vu3oXbGcL/kWlCR1ovLgVhOFj36 Vy3V6mR5Mvb5+daP1W7L4HHf+chkEb0imhwddrXqYVJEfzSqG5gxvJwCQj9YSvHxy98f 152Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=ClkxPgg2cZgY5jCJ9+fXxslN8qhP3411BKdrQnTPFLI=; b=T7BNt0iXiDHdIVnD4WZeTjaKzrXQWTvlp+QswX0nPP3YOsGdjY+VvSbevYPd2ZYL6m Ixjl1LzvKMduv+wkvybiYVjOT+97KqZZIx8O97LPx5yBcPT24Ul7XMhvDV80uqmnzgas 53cSghQ7H7POjHk52/Sghy131ycd+warzdXzJHcw6qvjsrXGUp0Z7EjtEyTMA3MG66Nf s1aZmrgZgji4LesdnbzoiM6SGEWf+tZ88d/hq6NF95DUG2Xp5MU3bgss3RVUbmvDcHb5 w2wdkfezQ0RL5hlen4qLtYezlwxYkA+HX1LGuVIhKXHQb7F3tJ/MrFlUKPCJon9UosN6 hp0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="tbc08Y/S"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 89-v6si5785130plf.224.2018.06.21.15.43.43; Thu, 21 Jun 2018 15:43:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="tbc08Y/S"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934166AbeFUWmt (ORCPT + 99 others); Thu, 21 Jun 2018 18:42:49 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:37533 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933714AbeFUWmo (ORCPT ); Thu, 21 Jun 2018 18:42:44 -0400 Received: by mail-lj1-f195.google.com with SMTP id h16-v6so578732ljg.4; Thu, 21 Jun 2018 15:42:42 -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=tG0Dv+SruyDwCdDEtw9WDybC51syNSAK+e0/b/nlNNgvYJAx0IZuDr68VKExd0eyCt af9k+eZT/SIybkA3BirbUtIPGTDH1a1Ko+SZbcKnnd7rw0DiQB/zR6cqFwTo9Alg0QJc V/zLOE3GybEaNoE4E1tCHzuHaLKFJomey+1NjGpOuOm96XXtT74gEDHp8uMrbHQH0QsW C/PuSVgo7fk40ak54e06Vy3NUpkqt4FknTUK2D9gLBdbgGeiVEoS0JxtRPYp0glUl4yx Ja+9Th2MeiHVxtnpGjwuKpBe0h5DyuPrdz/g1pqKZ64ycviBGfj22bpaGATZLriiYizM lpnQ== X-Gm-Message-State: APt69E0izwGCvg79oyn7FDf9BKr9F31G4zpx04ONbR8zRf2of5Q6iN6h sNEtlvmG91XaZ7++5p05GiA= 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 Cc: "David S . Miller " , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Randy Dunlap , Linus Walleij , Mark Brown , Liam Girdwood , linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-input@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; } -- 2.16.4