Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2057467imm; Sat, 9 Jun 2018 07:04:51 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKH7iDohXcf594hewngceU7+N+ebqBTLLZpekqBdDFLgvxOsjG1kwukmUNcJ0rqzfmPzbeB X-Received: by 2002:a17:902:650c:: with SMTP id b12-v6mr11229675plk.31.1528553091786; Sat, 09 Jun 2018 07:04:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528553091; cv=none; d=google.com; s=arc-20160816; b=SsYCBhkEwnKbSpwM9pcKA/vhAYTDTKby7UfiL36LfC2aq21fnpCfhJld7FUxPQZpTk wAA+qbgxipH/4cwMOrKXAwqQkF/HQZ17jwHxZmp5rbHqBgNghspXnbhLzyMuZC2gjCd6 G7KAncwn0/hbHWA7Z6ICJGRQSYuOKpwiJxic6z7ksU25VC2/LPM4U83CvJcYTCx00U5p dGdwDe4Lrm1yOFYtUY18zo5i3EpLL9Uk5XLj99HueBj94tWzppq65usAjtAj4B28auCr 5UbJk4qJ86pwjS2WNyvDn2ysVdP1/mOa06qrOY12cdvEE0xrEmf3CW3kDv4VQ+cQAHt5 eITw== 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=+QPyrYS4WwtnWSitmH1oh1ZsjI4BS+MGw3iyHI7mubc=; b=TgYZo4LKL3TOpktSjN2r2cEBfhPBt9RMxW8l7d381WivvGnQDLozNw4tqcTDLVFc2b E+LJ9ix3HthMgg0TEoO67OboHapCB1qTiAKf01PUlBDZDd6bQT9SJUwnUyv6Y0yQ46sb ysoVLUk5+m0WBvX1qmhqlYOMrMZV2sKqVLWBQ38PZhj40/8Hps7q7FD0pwktcGyyFLdC +I0nJ/zEFmYh70cqV43cxIn1nP+8WA0xeZyvnhlZ6NjtvOkC9JDd/mc3wtpyqYpl3ulP RYOf1aFkHJU7/AnIVrZT400DAn1+7lnMWlDjAOv8kQD5QxSs3YyWTQZl3ie0/RrUDukK 5GKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PCDkJURh; 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 90-v6si30148216plf.56.2018.06.09.07.04.37; Sat, 09 Jun 2018 07:04:51 -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=PCDkJURh; 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 S1753496AbeFIOD1 (ORCPT + 99 others); Sat, 9 Jun 2018 10:03:27 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:45833 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753478AbeFIODX (ORCPT ); Sat, 9 Jun 2018 10:03:23 -0400 Received: by mail-lf0-f66.google.com with SMTP id n3-v6so24169283lfe.12; Sat, 09 Jun 2018 07:03:21 -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=dgmMekNJsAaTloSMqYIX21lVo1l7JujG+z6x2xg1oCweiw3OfJmxHwmJK1pb+pxE8C p3PHYdMkjOdojzY7JdMzbqv9jq5r1oUN8SNb4hf42nAy226yrSFpUGA409kEKFSFZbHm IUl7ojEChDFap/9GF8lsO79LJC4pQPtWEgg2Hqs9400VdwbgrDfsJFboUgTuVWVRm1nF m8ZOmdY+o8BxaLDj9li4y7qDBVmnD9nOhNIDkevP2GgrOuDRvMAz976xph2gyawahc9T VGF754BfYI5XTl1zt50U1756TjZrEStMNJIY4Nuh7wPvp50JcjxfyP8BnUK/cwSJLc4P 2Azg== X-Gm-Message-State: APt69E0qt31oTp30M/vNzlxBjMjSz53oBr8ybPac7H9XN/fUtKhoIRXP q2xDJ9VEp+WA6J9NfB37CIk= 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 Cc: "David S . Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Andrew Morton , Randy Dunlap , Liam Girdwood , Mark Brown , Linus Walleij , linux-arm-kernel@lists.infradead.org, linux-input@vger.kernel.org, linux-omap@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik 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> 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 "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; } -- 2.16.1