From patchwork Sat Jun 9 14:02:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 927137 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="c8rRgTOQ"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4131FD3Zf9z9s01 for ; Sun, 10 Jun 2018 00:02:40 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753263AbeFIOCj (ORCPT ); Sat, 9 Jun 2018 10:02:39 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:38169 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753062AbeFIOCh (ORCPT ); Sat, 9 Jun 2018 10:02:37 -0400 Received: by mail-lf0-f65.google.com with SMTP id i83-v6so24177401lfh.5; Sat, 09 Jun 2018 07:02:36 -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; bh=KqMR5MOiwe8rDPnpmEXsY4mPzCR9+MDFfmVGp35l1fk=; b=c8rRgTOQR3h0EK3AeiRK/DuGd6y3FmRNLhkFeBHyuI7diXXpvGNxI+idLx24zfLvmu YMoumiSLbV4JPj+I3JbZkPsfykU9+SpcYRv6BoJkoQ3EIOcAG2cNuFjvna9QFBa/FQIk mWRM1Uxa2oiCcAX7FOZcX2HZQ1edbPvwtG2z0zAmDrUhYcwc8Ml8zxZ8FkBZlVFNNi5h MHvhFC201fQDhsOnD5TzuPJ/pBAbI6+GpCjT32v7Fs12o8spuSSBM4gSZdNUZcLGrZS1 5TulQFxQJ7aWkMZRq9dByEOt59aiJg6XTW0VyOIx/FxiY4i0H0MYKI3p1t4bifUkxdzx UNgw== 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; bh=KqMR5MOiwe8rDPnpmEXsY4mPzCR9+MDFfmVGp35l1fk=; b=miCz/7NRfStfXPmtWu7pDHAcg3+BdHxnm5Okkwh0/gKEv+ftKHhxkwZazTN06bHgwI 4aEedZAb9xI4BHOhUxYIi3vH9fCctLB7ZUA+6KgN53Z0pp4UG8OrlY1mzxtc/nspz/Um /y3kXbsqEZgm3KwRbLK2N326/ADt96hrvqregNo3ZRicNg7hHDctMusOcFZD80RqKIxW cNfsYovnGj6MiU22yQBcAQCb3/mOtvIGOJxE9urWQLcATXknXviUA7iqoERCRa6pK0Dy bLlEHTyqVOwhEWhYH3QkdA+rJEMLII8Pj26vjzfvQwu4mLXzdy66gAgUzfBSLBog3oEP a9YA== X-Gm-Message-State: APt69E3lRkonxuTSW4kgwBWWtMEn80eR8xtmlSiyq9fSIQ1/OW0s1sog p2JDhFkUw6DZcb8RZl2t8wQ= X-Google-Smtp-Source: ADUXVKJtTVVAWwhgWd0C15mEp86/PWpbpAgiLwVfjt6AzUOJGmSmF+YB5dhDsp0+1PvYxHWVEsLxmA== X-Received: by 2002:a19:7:: with SMTP id 7-v6mr6644480lfa.62.1528552955633; Sat, 09 Jun 2018 07:02:35 -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.02.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Jun 2018 07:02:34 -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 01/10] ARM: OMAP1: ams-delta: drop GPIO lookup table for serio device Date: Sat, 9 Jun 2018 16:02:15 +0200 Message-Id: <20180609140224.32606-1-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.1 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org GPIO lookup table for ams-delta-serio device was introduced by commit 0486738928bf ("ARM: OMAP1: ams-delta: add GPIO lookup tables"). Unfortunately, a follow up patch "Input: ams_delta_serio: use GPIO lookup table" was not accepted by subystem maintainer who requested conversion of the driver to a platform driver, replacepemnt of IRQ GPIO pin with IRQ resource, replacement of GPIO pin providing keyboard power with a regulator and removal of remaining GPIO pins from the driver as not handled by it. Let's start with removal of no the longer needed GPIO lookup table from the board init file. Series created and tested on top of next-20180608 tag from linux-next tree. Signed-off-by: Janusz Krzysztofik --- arch/arm/mach-omap1/board-ams-delta.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index 80f54cb54276..18e0ff437b27 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c @@ -504,20 +504,6 @@ static struct platform_device cx20442_codec_device = { .id = -1, }; -static struct gpiod_lookup_table ams_delta_serio_gpio_table = { - .table = { - GPIO_LOOKUP(OMAP_GPIO_LABEL, AMS_DELTA_GPIO_PIN_KEYBRD_DATA, - "data", 0), - GPIO_LOOKUP(OMAP_GPIO_LABEL, AMS_DELTA_GPIO_PIN_KEYBRD_CLK, - "clock", 0), - GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_KEYBRD_PWR, - "power", 0), - GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_KEYBRD_DATAOUT, - "dataout", 0), - { }, - }, -}; - static struct platform_device *ams_delta_devices[] __initdata = { &latch1_gpio_device, &latch2_gpio_device, @@ -534,7 +520,6 @@ static struct platform_device *late_devices[] __initdata = { static struct gpiod_lookup_table *ams_delta_gpio_tables[] __initdata = { &ams_delta_audio_gpio_table, - &ams_delta_serio_gpio_table, }; static struct gpiod_lookup_table *late_gpio_tables[] __initdata = { @@ -580,10 +565,6 @@ static void __init ams_delta_init(void) */ ams_delta_audio_gpio_table.dev_id = dev_name(&ams_delta_audio_device.dev); - /* - * No device name is assigned to GPIO lookup table for serio device - * as long as serio driver is not converted to platform device driver. - */ gpiod_add_lookup_tables(ams_delta_gpio_tables, ARRAY_SIZE(ams_delta_gpio_tables)); From patchwork Sat Jun 9 14:02:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 927146 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DpC8CwSU"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4131J1395bz9s01 for ; Sun, 10 Jun 2018 00:05:05 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753323AbeFIOCs (ORCPT ); Sat, 9 Jun 2018 10:02:48 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:42628 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753062AbeFIOCq (ORCPT ); Sat, 9 Jun 2018 10:02:46 -0400 Received: by mail-lf0-f67.google.com with SMTP id v135-v6so24168436lfa.9; Sat, 09 Jun 2018 07:02:44 -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=mOjLsJfnKdGMrPPfSAYY48IQW/M2iyitMXHZcPfc+Bc=; b=DpC8CwSUS27YBAwqW1vSudxGoz7qmAyZVRlDW/MsOO639ld5s8YSbRfb0uzIGU31A0 fRijTPxPeiItH196pEdxaVfpFFvQMPrsbVmT/0tfRfzz9+S6i7pVt7t1/J6YGKiBRz8o efodSyuwLLfKauC9/85w5V175rokr+cmkDEh3QlFbXlW3AXILFcns3IS2ZQyhLAP38cW J9d4rWJ+IMSDaWtrIonno+l9OPXdJo9q66HtDvc7PNRoBW081Yw+MM85UA2D5CdBzHVi VhEh3CCCOyR0m/sN+PHheXCZgJHIqt2Q5hivVunDFVcV44l1afyqrb6SCPNStoBP53Cu V9Pw== 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=mOjLsJfnKdGMrPPfSAYY48IQW/M2iyitMXHZcPfc+Bc=; b=kIBa+iHgqjlYikXW9+yCPqC2vkO3b13AvAwos3voPC0xlH0yJcbVOO3kRXibnFxhhy YowX+3ZzEql7aiMU4CJ7rEAWcd/2BL3Mgd+CvDX6X4eFK3CzpvzgjrmiG2fzQScEWKcG UgJ3pOcLj/jEH0XjG9XaIQ2Yzxpj+cQfD3ARfn6QA7O0JmCZmHEZ7aQifZQlpBCNKI7P 9Oq2fczB6ydjtCRP8qL7wGRAQLviVePlSU5d7dYLi1xxdc/Y0BlTnKJ1vGuxes6hjkz2 hBfqaxPLnBK0y697uABcAZl6iPHvI49YpXGA5ZFW0+XddwoWNIaTd8+Hn403PpcVYBPN 67Hw== X-Gm-Message-State: APt69E2+4dZNj660du1VZLO07CutwYBMCe3hoNKZQkh7oROiJct5b8PO wbHb9UKGbgEW6oamlG59V/o= X-Google-Smtp-Source: ADUXVKKgdijZdWPTDV0itN7GLvBHpgCGKWt8sjcomNosd+E1zwWYYwvwv2ZkdRQ79MYGybG3In175g== X-Received: by 2002:a19:cc4b:: with SMTP id c72-v6mr6676158lfg.30.1528552963947; Sat, 09 Jun 2018 07:02:43 -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.02.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Jun 2018 07:02:43 -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 02/10] Input: ams_delta_serio: convert to platform driver Date: Sat, 9 Jun 2018 16:02:16 +0200 Message-Id: <20180609140224.32606-2-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-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Convert the driver to an "ams-delta-serio" platform driver. For it to be used with Amstrad Delta, register an "ams-delta-serio" platform device from the board init file. Signed-off-by: Janusz Krzysztofik --- arch/arm/mach-omap1/board-ams-delta.c | 6 ++++++ drivers/input/serio/ams_delta_serio.c | 34 +++++++++++++++++++++------------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index 18e0ff437b27..2119d2d3ba84 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c @@ -504,12 +504,18 @@ static struct platform_device cx20442_codec_device = { .id = -1, }; +static struct platform_device ams_delta_serio_device = { + .name = "ams-delta-serio", + .id = PLATFORM_DEVID_NONE, +}; + static struct platform_device *ams_delta_devices[] __initdata = { &latch1_gpio_device, &latch2_gpio_device, &ams_delta_kp_device, &ams_delta_camera_device, &ams_delta_audio_device, + &ams_delta_serio_device, }; static struct platform_device *late_devices[] __initdata = { diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c index 3df501c3421b..a2a7fa19bf49 100644 --- a/drivers/input/serio/ams_delta_serio.c +++ b/drivers/input/serio/ams_delta_serio.c @@ -22,15 +22,17 @@ */ #include #include +#include #include #include #include -#include #include #include +#define DRIVER_NAME "ams-delta-serio" + MODULE_AUTHOR("Matt Callow"); MODULE_DESCRIPTION("AMS Delta (E3) keyboard port driver"); MODULE_LICENSE("GPL"); @@ -126,13 +128,10 @@ static const struct gpio ams_delta_gpios[] __initconst_or_module = { }, }; -static int __init ams_delta_serio_init(void) +static int ams_delta_serio_init(struct platform_device *pdev) { int err; - if (!machine_is_ams_delta()) - return -ENODEV; - ams_delta_serio = kzalloc(sizeof(struct serio), GFP_KERNEL); if (!ams_delta_serio) return -ENOMEM; @@ -142,22 +141,22 @@ static int __init ams_delta_serio_init(void) ams_delta_serio->close = ams_delta_serio_close; strlcpy(ams_delta_serio->name, "AMS DELTA keyboard adapter", sizeof(ams_delta_serio->name)); - strlcpy(ams_delta_serio->phys, "GPIO/serio0", + strlcpy(ams_delta_serio->phys, dev_name(&pdev->dev), sizeof(ams_delta_serio->phys)); + ams_delta_serio->dev.parent = &pdev->dev; err = gpio_request_array(ams_delta_gpios, ARRAY_SIZE(ams_delta_gpios)); if (err) { - pr_err("ams_delta_serio: Couldn't request gpio pins\n"); + dev_err(&pdev->dev, "Couldn't request gpio pins\n"); goto serio; } err = request_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), ams_delta_serio_interrupt, IRQ_TYPE_EDGE_RISING, - "ams-delta-serio", 0); + DRIVER_NAME, 0); if (err < 0) { - pr_err("ams_delta_serio: couldn't request gpio interrupt %d\n", - gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK)); + dev_err(&pdev->dev, "IRQ request failed (%d)\n", err); goto gpio; } /* @@ -179,13 +178,22 @@ static int __init ams_delta_serio_init(void) kfree(ams_delta_serio); return err; } -module_init(ams_delta_serio_init); -static void __exit ams_delta_serio_exit(void) +static int ams_delta_serio_exit(struct platform_device *pdev) { serio_unregister_port(ams_delta_serio); free_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0); gpio_free_array(ams_delta_gpios, ARRAY_SIZE(ams_delta_gpios)); + + return 0; } -module_exit(ams_delta_serio_exit); + +static struct platform_driver ams_delta_serio_driver = { + .probe = ams_delta_serio_init, + .remove = ams_delta_serio_exit, + .driver = { + .name = DRIVER_NAME + }, +}; +module_platform_driver(ams_delta_serio_driver); From patchwork Sat Jun 9 14:02:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 927145 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="T9goHlsB"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4131Hs0jHtz9s01 for ; Sun, 10 Jun 2018 00:04:57 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753062AbeFIOCx (ORCPT ); Sat, 9 Jun 2018 10:02:53 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:33436 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753336AbeFIOCv (ORCPT ); Sat, 9 Jun 2018 10:02:51 -0400 Received: by mail-lf0-f66.google.com with SMTP id y20-v6so24230674lfy.0; Sat, 09 Jun 2018 07:02:49 -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=cSGIAu+yPFYzl2tKjFSyAudgSsSy/f+rBZug1MC7D5Q=; b=T9goHlsBUeUCIQ18jmiyntUOufRm1V89//DWJ8YL/0Ymgsn8+au42NOpf7VJ7d09rw 9WcBhKnh5UohEGNtwDsHdr5oLejleFNOxo7eKG6E6xf8UN1O0X66BJOMS39PfTvJRGtt BmDiEuaiWX26x6ZYZJB06Jh3zTdajH5foG2fIMsONllX9vx3WIDMXxhvXdBITSU6nsQc cNDL+0RxG4PF6z0ba6CpaBzSzrxpXXKYdCJhlSh9jGKMGvo5c+I7ct+AIlG08q7cz8Up RYDSsW1Kr7XwDHWmxZQjr6IbYY1Yj4zqjW3ft780aanBJKDknmHEjxFozZ/Iz8Hhs9IN BVQw== 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=cSGIAu+yPFYzl2tKjFSyAudgSsSy/f+rBZug1MC7D5Q=; b=aoO1bKLwe87ZUH3YPSqe6+Y1rxScXp1SDDDQScbuwAKbxLiwGK2fe1HbF8GNu/wCqV M0duIya61PKJLiPyw5xdXn0Xrmujpv+otxOnumnNGLWgAs7Ttbmbctv6XLkAZL1XeWJr t9qCbZ9zCrfJZEWY8TBNdKk9NqE/17Qs0n87LLDp57wtgQw4vdZtXve9mShgWzgmL3n0 KLnQugdF8CRSxt44M3V0ururrlKHVa3nY40j+1NB3ILJFF/plvVjU6JSIBs2QtkGObcD 4TsB1aRKwqU7ADlzO9PlStdWNsk+//wP8m0i6dWb2ISnYhF5UHru804tYdN+Fw2xV07R /waw== X-Gm-Message-State: APt69E0t2QsbnRQjx3YNwKqKdeuhQy2tr9dbk6OmYU3UBmxfQ65BX0r5 wYJxxj5eTwb4Hutt0hJIVlc= X-Google-Smtp-Source: ADUXVKJOqhM2HSjTlmi7MYQGcF6IufBrpEuFLt3JGN2PX+zOdZW8y2PxIxzUTbRiYYIJfVuM0qtw6A== X-Received: by 2002:a2e:7c02:: with SMTP id x2-v6mr7290347ljc.71.1528552968999; Sat, 09 Jun 2018 07:02:48 -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.02.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Jun 2018 07:02:48 -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 03/10] Input: ams_delta_serio: use private structure Date: Sat, 9 Jun 2018 16:02:17 +0200 Message-Id: <20180609140224.32606-3-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-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Introduce a driver private structure and allocate it on device probe. For now, use it instead of a static variable for storing a pointer to serio structure. Subsequent patches will populate it with more members as needed. Signed-off-by: Janusz Krzysztofik # Conflicts: # drivers/input/serio/ams_delta_serio.c --- drivers/input/serio/ams_delta_serio.c | 69 ++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 26 deletions(-) diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c index a2a7fa19bf49..551a4fa73fe4 100644 --- a/drivers/input/serio/ams_delta_serio.c +++ b/drivers/input/serio/ams_delta_serio.c @@ -37,17 +37,17 @@ MODULE_AUTHOR("Matt Callow"); MODULE_DESCRIPTION("AMS Delta (E3) keyboard port driver"); MODULE_LICENSE("GPL"); -static struct serio *ams_delta_serio; +struct ams_delta_serio { + struct serio *serio; +}; -static int check_data(int data) +static int check_data(struct serio *serio, int data) { int i, parity = 0; /* check valid stop bit */ if (!(data & 0x400)) { - dev_warn(&ams_delta_serio->dev, - "invalid stop bit, data=0x%X\n", - data); + dev_warn(&serio->dev, "invalid stop bit, data=0x%X\n", data); return SERIO_FRAME; } /* calculate the parity */ @@ -57,9 +57,9 @@ static int check_data(int data) } /* it should be odd */ if (!(parity & 0x01)) { - dev_warn(&ams_delta_serio->dev, - "parity check failed, data=0x%X parity=0x%X\n", - data, parity); + dev_warn(&serio->dev, + "parity check failed, data=0x%X parity=0x%X\n", data, + parity); return SERIO_PARITY; } return 0; @@ -67,6 +67,7 @@ static int check_data(int data) static irqreturn_t ams_delta_serio_interrupt(int irq, void *dev_id) { + struct ams_delta_serio *priv = dev_id; int *circ_buff = &fiq_buffer[FIQ_CIRC_BUFF]; int data, dfl; u8 scancode; @@ -84,9 +85,9 @@ static irqreturn_t ams_delta_serio_interrupt(int irq, void *dev_id) if (fiq_buffer[FIQ_HEAD_OFFSET] == fiq_buffer[FIQ_BUF_LEN]) fiq_buffer[FIQ_HEAD_OFFSET] = 0; - dfl = check_data(data); + dfl = check_data(priv->serio, data); scancode = (u8) (data >> 1) & 0xFF; - serio_interrupt(ams_delta_serio, scancode, dfl); + serio_interrupt(priv->serio, scancode, dfl); } return IRQ_HANDLED; } @@ -130,21 +131,14 @@ static const struct gpio ams_delta_gpios[] __initconst_or_module = { static int ams_delta_serio_init(struct platform_device *pdev) { + struct ams_delta_serio *priv; + struct serio *serio; int err; - ams_delta_serio = kzalloc(sizeof(struct serio), GFP_KERNEL); - if (!ams_delta_serio) + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) return -ENOMEM; - ams_delta_serio->id.type = SERIO_8042; - ams_delta_serio->open = ams_delta_serio_open; - ams_delta_serio->close = ams_delta_serio_close; - strlcpy(ams_delta_serio->name, "AMS DELTA keyboard adapter", - sizeof(ams_delta_serio->name)); - strlcpy(ams_delta_serio->phys, dev_name(&pdev->dev), - sizeof(ams_delta_serio->phys)); - ams_delta_serio->dev.parent = &pdev->dev; - err = gpio_request_array(ams_delta_gpios, ARRAY_SIZE(ams_delta_gpios)); if (err) { @@ -154,7 +148,7 @@ static int ams_delta_serio_init(struct platform_device *pdev) err = request_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), ams_delta_serio_interrupt, IRQ_TYPE_EDGE_RISING, - DRIVER_NAME, 0); + DRIVER_NAME, priv); if (err < 0) { dev_err(&pdev->dev, "IRQ request failed (%d)\n", err); goto gpio; @@ -167,21 +161,44 @@ static int ams_delta_serio_init(struct platform_device *pdev) irq_set_handler(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), handle_simple_irq); - serio_register_port(ams_delta_serio); - dev_info(&ams_delta_serio->dev, "%s\n", ams_delta_serio->name); + serio = kzalloc(sizeof(*serio), GFP_KERNEL); + if (!serio) { + err = -ENOMEM; + goto irq; + } + + priv->serio = serio; + + serio->id.type = SERIO_8042; + serio->open = ams_delta_serio_open; + serio->close = ams_delta_serio_close; + strlcpy(serio->name, "AMS DELTA keyboard adapter", sizeof(serio->name)); + strlcpy(serio->phys, dev_name(&pdev->dev), sizeof(serio->phys)); + serio->dev.parent = &pdev->dev; + serio->port_data = priv; + + serio_register_port(serio); + + platform_set_drvdata(pdev, priv); + + dev_info(&serio->dev, "%s\n", serio->name); return 0; + +irq: + free_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), priv); gpio: gpio_free_array(ams_delta_gpios, ARRAY_SIZE(ams_delta_gpios)); serio: - kfree(ams_delta_serio); return err; } static int ams_delta_serio_exit(struct platform_device *pdev) { - serio_unregister_port(ams_delta_serio); + 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); gpio_free_array(ams_delta_gpios, ARRAY_SIZE(ams_delta_gpios)); From patchwork Sat Jun 9 14:02:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 927143 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FhnWWQnG"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4131HM2qpvz9s3C for ; Sun, 10 Jun 2018 00:04:31 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753383AbeFIODC (ORCPT ); Sat, 9 Jun 2018 10:03:02 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:43530 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753336AbeFIOC5 (ORCPT ); Sat, 9 Jun 2018 10:02:57 -0400 Received: by mail-lf0-f65.google.com with SMTP id n15-v6so24166368lfn.10; Sat, 09 Jun 2018 07:02:55 -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=vK4z529eQgjlfX/v4pgs6FSNrghjntEr72J0iDzPGms=; b=FhnWWQnGoqq/Cf4wJR+SslOmv4vfdb/Y6LgwUHIEzrH+YaObjcON2IgAHikCO6ChTQ lAWh1G+TcYjw2Xh0h7KX6pBesQVLcrBB1Z/80uOaX1d8YNuA4HKLClZt10enlVBvZbQU DatZtdJ7KaZr434BQOn8CWt3Y3XpYIHxOSATCmHx3WmpSNhgAgEG8QjZB/jPdLaMx1Nu WfgIaKRK5f5QjCngt39l+sea5FxA/F32gSKZUdtlgKPTx1SL/F71t6KjwQQUMYZF1Iu9 +r4ycodTfRPVlpxDZsPej8MRZBpyjJx63a5qIW8uUl9lbLdBBK5PsEL4zy/U9Uxm6rL/ RdoQ== 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=vK4z529eQgjlfX/v4pgs6FSNrghjntEr72J0iDzPGms=; b=TkA3DdtBuyA76P+FeLrghLcZPHBEhm73CUi1LHqLiyMX4WNceKpAYUsbyodXwxtL/u 3c+qMFzKgq0IOGSEEACAIAfHhdJlvJ9JjjijTbsvb7NyL1dgI61V99IK1m7/q3RUU7ls RKdSl8SKrwR1dx7AnE6jKYpyjXG5fsDTLwyaNvghByeqt2qc7F5KM8BlBSkb4s2hLrfl UZYA3nzZ8ZAasnl8mHyUygwFlWiLrAcKmKOd6rOzatAG4JQBQ8R+pRh/XrObWYh7zU6W Z8Sk8XV2VXFd+gVi+wdrTEBsLiQoeTotWV6O/mm9CV7WIzlWf9+a9BJD1fGBuHXQVWdU 3SyA== X-Gm-Message-State: APt69E2oaf1nmdDGoiobUYt6IyG3DIHS2l5uRnx/BnaWVQzciiQn1B8z Gwk2WAMhAgXn0gNRTqzOPN8= X-Google-Smtp-Source: ADUXVKLqyvyfQ3kXRdQP3O3KmnifeFYN87VRiPmKwyRLdOQ3FDj+Pqxb7NLwFTNZdP0byATnaiF6hA== X-Received: by 2002:a2e:29cf:: with SMTP id p76-v6mr7624565ljp.12.1528552974782; Sat, 09 Jun 2018 07:02:54 -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.02.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Jun 2018 07:02:54 -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 04/10] Input: ams_delta_serio: Replace power GPIO with regulator Date: Sat, 9 Jun 2018 16:02:18 +0200 Message-Id: <20180609140224.32606-4-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-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Modify the driver so it no longer requests and manipulates the "keybrd_pwr" GPIO pin but a "vcc" regulator supply instead. For this to work with Amstrad Delta, define a regulator over the "keybrd_pwr" GPIO pin with the "vcc" supply for ams-delta-serio device and register it from the board file. Both assign an absulute GPIO number to the soon depreciated .gpio member of the regulator config structure, and also build and register a GPIO lookup table so it is ready for use by the regulator driver as soon as its upcoming update is applied. Signed-off-by: Janusz Krzysztofik --- arch/arm/mach-omap1/board-ams-delta.c | 63 +++++++++++++++++++++++++++++++++-- drivers/input/serio/ams_delta_serio.c | 27 ++++++++++----- 2 files changed, 79 insertions(+), 11 deletions(-) diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index 2119d2d3ba84..706eb2f9301d 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c @@ -509,6 +509,46 @@ static struct platform_device ams_delta_serio_device = { .id = PLATFORM_DEVID_NONE, }; +static struct regulator_consumer_supply keybrd_pwr_consumers[] = { + /* + * Initialize supply .dev_name with NULL. It will be replaced + * with serio dev_name() as soon as the serio device is registered. + */ + REGULATOR_SUPPLY("vcc", NULL), +}; + +static struct regulator_init_data keybrd_pwr_initdata = { + .constraints = { + .valid_ops_mask = REGULATOR_CHANGE_STATUS, + }, + .num_consumer_supplies = ARRAY_SIZE(keybrd_pwr_consumers), + .consumer_supplies = keybrd_pwr_consumers, +}; + +static struct fixed_voltage_config keybrd_pwr_config = { + .supply_name = "keybrd_pwr", + .microvolts = 5000000, + .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_PWR, + .enable_high = 1, + .init_data = &keybrd_pwr_initdata, +}; + +static struct platform_device keybrd_pwr_device = { + .name = "reg-fixed-voltage", + .id = PLATFORM_DEVID_AUTO, + .dev = { + .platform_data = &keybrd_pwr_config, + }, +}; + +static struct gpiod_lookup_table keybrd_pwr_gpio_table = { + .table = { + GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_KEYBRD_PWR, NULL, + GPIO_ACTIVE_HIGH), + { }, + }, +}; + static struct platform_device *ams_delta_devices[] __initdata = { &latch1_gpio_device, &latch2_gpio_device, @@ -526,6 +566,7 @@ static struct platform_device *late_devices[] __initdata = { static struct gpiod_lookup_table *ams_delta_gpio_tables[] __initdata = { &ams_delta_audio_gpio_table, + &keybrd_pwr_gpio_table, }; static struct gpiod_lookup_table *late_gpio_tables[] __initdata = { @@ -566,12 +607,30 @@ static void __init ams_delta_init(void) platform_add_devices(ams_delta_devices, ARRAY_SIZE(ams_delta_devices)); /* - * As soon as devices have been registered, assign their dev_names - * to respective GPIO lookup tables before they are added. + * As soon as regulator consumers have been registered, assign their + * dev_names to consumer supply entries of respective regulators. + */ + keybrd_pwr_consumers[0].dev_name = + dev_name(&ams_delta_serio_device.dev); + + /* + * Once consumer supply entries are populated with dev_names, + * register regulator devices. At this stage only the keyboard + * power regulator has its consumer supply table fully populated. + */ + platform_device_register(&keybrd_pwr_device); + + /* + * As soon as GPIO consumers have been registered, assign + * their dev_names to respective GPIO lookup tables. */ ams_delta_audio_gpio_table.dev_id = dev_name(&ams_delta_audio_device.dev); + keybrd_pwr_gpio_table.dev_id = dev_name(&keybrd_pwr_device.dev); + /* + * Once GPIO lookup tables are populated with dev_names, register them. + */ gpiod_add_lookup_tables(ams_delta_gpio_tables, ARRAY_SIZE(ams_delta_gpio_tables)); diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c index 551a4fa73fe4..d48beab1d00d 100644 --- a/drivers/input/serio/ams_delta_serio.c +++ b/drivers/input/serio/ams_delta_serio.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -39,6 +40,7 @@ MODULE_LICENSE("GPL"); struct ams_delta_serio { struct serio *serio; + struct regulator *vcc; }; static int check_data(struct serio *serio, int data) @@ -94,16 +96,18 @@ static irqreturn_t ams_delta_serio_interrupt(int irq, void *dev_id) static int ams_delta_serio_open(struct serio *serio) { - /* enable keyboard */ - gpio_set_value(AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 1); + struct ams_delta_serio *priv = serio->port_data; - return 0; + /* enable keyboard */ + return regulator_enable(priv->vcc); } static void ams_delta_serio_close(struct serio *serio) { + struct ams_delta_serio *priv = serio->port_data; + /* disable keyboard */ - gpio_set_value(AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 0); + regulator_disable(priv->vcc); } static const struct gpio ams_delta_gpios[] __initconst_or_module = { @@ -117,11 +121,6 @@ static const struct gpio ams_delta_gpios[] __initconst_or_module = { .flags = GPIOF_DIR_IN, .label = "serio-clock", }, - { - .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_PWR, - .flags = GPIOF_OUT_INIT_LOW, - .label = "serio-power", - }, { .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT, .flags = GPIOF_OUT_INIT_LOW, @@ -146,6 +145,16 @@ static int ams_delta_serio_init(struct platform_device *pdev) goto serio; } + priv->vcc = devm_regulator_get(&pdev->dev, "vcc"); + if (IS_ERR(priv->vcc)) { + err = PTR_ERR(priv->vcc); + dev_err(&pdev->dev, "regulator request failed (%d)\n", err); + /* Fail softly if the regulator is not available yet */ + if (err == -ENODEV) + err = -EPROBE_DEFER; + goto gpio; + } + err = request_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), ams_delta_serio_interrupt, IRQ_TYPE_EDGE_RISING, DRIVER_NAME, priv); From patchwork Sat Jun 9 14:02:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 927144 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="QOpHnwO6"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4131HR2Msrz9s3C for ; Sun, 10 Jun 2018 00:04:35 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753231AbeFIOEd (ORCPT ); Sat, 9 Jun 2018 10:04:33 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:34477 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753376AbeFIODB (ORCPT ); Sat, 9 Jun 2018 10:03:01 -0400 Received: by mail-lf0-f68.google.com with SMTP id o9-v6so24194978lfk.1; Sat, 09 Jun 2018 07:03:00 -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=Cllgb48Ha6uWerR09aJv3S2+cDev6DG6WH9tvQJMi9w=; b=QOpHnwO66Pq5QbaGVTCZ23HmrHOOMH/RQYDROTSRT2/0KpwDX8M5eX0BiegT00QNG6 x48ZTFSCx+dPC3bYpYhwseecLUGCl5VQz7meXN79XfEGujo2R1B25S2sG1ixsHITz1u6 ONGIfl04vZGLQCMQrc08RsPsap2+skfIGlVZMZSnY5dwtl5uZ96bKrQlhbJndnLrBpLJ 0ikrocrcKdWmGqlapZF6O4kqO9DDc1DD1tKdC+ViIXzu/VW11c5RXpr0MduGtWEJ8/Ys rpH8UoO2dO3U9ANiIVEF1prBCKl5DKNfNBLkoPRII3C2SwwIdb3FLmSbFrX+y1CgYQ6o ehNw== 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=Cllgb48Ha6uWerR09aJv3S2+cDev6DG6WH9tvQJMi9w=; b=OCNNRQHLymC7QBbGVaVNm3OM7xQGx7XR6EhTIAtXB7vhCuLuSMIjT0qIShpQufkQwF r2efrjM71OsqkxISnhN/2/0FFOeBo01oAsZtUkSvtuazuyqmSS6DQfo1/F5OdBZuoQDV K7xCc4XnWfp3ErN6+9/yb2hTW3F+SwgEzCFLEwZuqNjUdzhwpX7Zx/d3gk0Bhz+km3+C gfcDTFiUwLRHYE+oXdKZaV1dYzjN00iTAmF28P6BCGvjVvSgToSrbS383VfNW2wIS6NB KoyYdBJTUDPBi9CaxTtb8U3mYP6L9/kl9vW+D9BlNR8N2u+teQ60aaj6jvY5Icyte9LC ADXg== X-Gm-Message-State: APt69E1pVWhwugA56JeUXlsgbhrZIg70SVry6WxZQcXH8xPWXe5n8Uyd 6MQXDeKJSf5CPe0ZyB+7EGk= X-Google-Smtp-Source: ADUXVKLg8vI07CGiWyN8GwUv/qV9EhDp5kRn2lsVuCI+lf6shsWJ3n9OQ3ZRr9qgfm370FpbKJd4Sg== X-Received: by 2002:a2e:9b52:: with SMTP id o18-v6mr4877596ljj.49.1528552979402; Sat, 09 Jun 2018 07:02:59 -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.02.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Jun 2018 07:02:58 -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 05/10] ARM: OMAP1: ams-delta: Hog "keybrd_dataout" GPIO pin Date: Sat, 9 Jun 2018 16:02:19 +0200 Message-Id: <20180609140224.32606-5-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-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org "keybrd_dataout" GPIO pin used to be initialized by ams-delta-serio driver to a state safe for ams-delta-serio device function and not changed thereafter. As such, it may be assumed not under the driver control and responsibility for its initialization handed over to board init file. Introduce a GPIO hog table and take over control of the "keybrd_dataout" GPIO pin from the ams-delta-serio driver. Signed-off-by: Janusz Krzysztofik --- arch/arm/mach-omap1/board-ams-delta.c | 8 ++++++++ drivers/input/serio/ams_delta_serio.c | 5 ----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index 706eb2f9301d..2821284aa0c9 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c @@ -574,6 +574,12 @@ static struct gpiod_lookup_table *late_gpio_tables[] __initdata = { &ams_delta_nand_gpio_table, }; +static struct gpiod_hog ams_delta_gpio_hogs[] = { + GPIO_HOG(LATCH2_LABEL, LATCH2_PIN_KEYBRD_DATAOUT, "keybrd_dataout", + GPIO_ACTIVE_HIGH, GPIOD_OUT_LOW), + {}, +}; + static void __init ams_delta_init(void) { /* mux pins for uarts */ @@ -594,6 +600,8 @@ static void __init ams_delta_init(void) omap_cfg_reg(J19_1610_CAM_D6); omap_cfg_reg(J18_1610_CAM_D7); + gpiod_add_hogs(ams_delta_gpio_hogs); + omap_serial_init(); omap_register_i2c_bus(1, 100, NULL, 0); diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c index d48beab1d00d..0b4d5a952ecb 100644 --- a/drivers/input/serio/ams_delta_serio.c +++ b/drivers/input/serio/ams_delta_serio.c @@ -121,11 +121,6 @@ static const struct gpio ams_delta_gpios[] __initconst_or_module = { .flags = GPIOF_DIR_IN, .label = "serio-clock", }, - { - .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT, - .flags = GPIOF_OUT_INIT_LOW, - .label = "serio-dataout", - }, }; static int ams_delta_serio_init(struct platform_device *pdev) From patchwork Sat Jun 9 14:02:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 927142 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="WyS96pq5"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4131HG4T00z9s01 for ; Sun, 10 Jun 2018 00:04:26 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753404AbeFIODK (ORCPT ); Sat, 9 Jun 2018 10:03:10 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:42658 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753336AbeFIODH (ORCPT ); Sat, 9 Jun 2018 10:03:07 -0400 Received: by mail-lf0-f68.google.com with SMTP id v135-v6so24169253lfa.9; Sat, 09 Jun 2018 07:03:05 -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=LBMRVjJgb1pIYSwEyc+rgDmCyfHWYEamH4+KZBQNQKk=; b=WyS96pq5fCRinHd+JLe/5LoJXPLbVOip5URLk04lOlPcJfKuT+s3s9tKXL5b776GVG tTx82QSV5OzQ76F1yKLfDJstIkkBQ4+cG+OxNRc4Aei/llI8dbBGKYBjb6YTpgisHsFe Ekpl8DpjpBGgNXdRDtCRSwMrmcNdLEZofd7be8ZDlaWsCCxukWBaf0Ftzc3dDYd584wD 6AOWPHBSZ8udrsbV8SSIS3S+Qwxz37esMmi7g/gBd6GSTs1EvWHoBI3VsGtrZN1d8p7j JvN6r6Ux23aNihesTSr4bhiiaJGISyb1TlMYvDzEug7AhJOeuQAxeDdG59mD90P06G7j I+ww== 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=LBMRVjJgb1pIYSwEyc+rgDmCyfHWYEamH4+KZBQNQKk=; b=DBsEWT70HsoUUuyleQX5ClD8rUrbUcZbvndlNLX6n+AuvV3hMn1EaQhywMmUKTr1oY 3ZX92o3DPi4ks82WjMWKxQmrw0cwWSJJnEKus7PyVWgzEaPFwE5U+4kcYJ245KPxAqXT fBLGEUphWGTnCCy7o0Yj2yzavTysmNbqKmlqTYWjlqLVAYsyf9HgUj0+KEU5M9HhLwrP Ar0iq99+VeokgO2F9u5b3o2S2m2JaDhsSbXoN5A2HRezilUAAJct14HiZ5BTp7LzZorR 3uKZgUk33q+p1h29KXIczlXldCiLcWJyeGAJqFMxLdF6vqjHwFflpKo4nqtEerkKECmt 9HEA== X-Gm-Message-State: APt69E2/Dgn0wac7ajHoBGWPrG9r/mtog5Qw6MWckjT8mTWHH3fgxsoM 5F8Bao4SCHIA88P4PbTkLnk= X-Google-Smtp-Source: ADUXVKK1+v9JHaIWzHmXIdwYvXZKyO3e33WtjVvGcwJjgE5NoJ7QKhGlkb7g+IjLxA5I/gam0N15ZQ== X-Received: by 2002:a19:d7aa:: with SMTP id q42-v6mr6571566lfi.75.1528552984997; Sat, 09 Jun 2018 07:03:04 -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.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Jun 2018 07:03:04 -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 06/10] ARM: OMAP1: ams-delta FIQ: don't use static GPIO numbers Date: Sat, 9 Jun 2018 16:02:20 +0200 Message-Id: <20180609140224.32606-6-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-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org With introduction of GPIO lookup tables to Amstrad Delta board init file, semantics of symbols representing OMAP GPIO pins defined in changed from statically assigned global GPIO numbers to hardware pin numbers local to OMAP "gpio-0-15" chip. This patch modifies deferred FIQ interrupt handler so it no longer uses static GPIO numbers in favour of IRQ data descriptors obtained at FIQ initialization time from descriptor of the GPIO chip with use of its hardware pin numbers. The chip descriptor is passed from the board init file. As a benefit, the deferred FIQ handler should work faster. Signed-off-by: Janusz Krzysztofik Acked-by: Linus Walleij --- arch/arm/mach-omap1/ams-delta-fiq.c | 48 +++++++++++++++++------- arch/arm/mach-omap1/board-ams-delta.c | 41 +++++++++++++++++++- arch/arm/mach-omap1/include/mach/ams-delta-fiq.h | 2 +- 3 files changed, 74 insertions(+), 17 deletions(-) diff --git a/arch/arm/mach-omap1/ams-delta-fiq.c b/arch/arm/mach-omap1/ams-delta-fiq.c index d7ca9e2b40d2..1d54a6177f14 100644 --- a/arch/arm/mach-omap1/ams-delta-fiq.c +++ b/arch/arm/mach-omap1/ams-delta-fiq.c @@ -13,7 +13,8 @@ * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. */ -#include +#include +#include #include #include #include @@ -40,14 +41,14 @@ static struct fiq_handler fh = { unsigned int fiq_buffer[1024]; EXPORT_SYMBOL(fiq_buffer); +static struct irq_chip *irq_chip; +static struct irq_data *irq_data[16]; static unsigned int irq_counter[16]; static irqreturn_t deferred_fiq(int irq, void *dev_id) { + struct irq_data *d; int gpio, irq_num, fiq_count; - struct irq_chip *irq_chip; - - irq_chip = irq_get_chip(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK)); /* * For each handled GPIO interrupt, keep calling its interrupt handler @@ -55,24 +56,21 @@ static irqreturn_t deferred_fiq(int irq, void *dev_id) */ for (gpio = AMS_DELTA_GPIO_PIN_KEYBRD_CLK; gpio <= AMS_DELTA_GPIO_PIN_HOOK_SWITCH; gpio++) { - irq_num = gpio_to_irq(gpio); + d = irq_data[gpio]; + irq_num = d->irq; fiq_count = fiq_buffer[FIQ_CNT_INT_00 + gpio]; if (irq_counter[gpio] < fiq_count && gpio != AMS_DELTA_GPIO_PIN_KEYBRD_CLK) { - struct irq_data *d = irq_get_irq_data(irq_num); - /* * handle_simple_irq() that OMAP GPIO edge * interrupts default to since commit 80ac93c27441 * requires interrupt already acked and unmasked. */ - if (irq_chip) { - if (irq_chip->irq_ack) - irq_chip->irq_ack(d); - if (irq_chip->irq_unmask) - irq_chip->irq_unmask(d); - } + if (irq_chip->irq_ack) + irq_chip->irq_ack(d); + if (irq_chip->irq_unmask) + irq_chip->irq_unmask(d); } for (; irq_counter[gpio] < fiq_count; irq_counter[gpio]++) generic_handle_irq(irq_num); @@ -80,14 +78,36 @@ static irqreturn_t deferred_fiq(int irq, void *dev_id) return IRQ_HANDLED; } -void __init ams_delta_init_fiq(void) +void __init ams_delta_init_fiq(struct gpio_chip *chip) { + struct gpio_desc *gpiod; void *fiqhandler_start; unsigned int fiqhandler_length; struct pt_regs FIQ_regs; unsigned long val, offset; int i, retval; + /* Store irq_chip location for IRQ handler use */ + irq_chip = chip->irq.chip; + if (!irq_chip) { + pr_err("%s: GPIO chip %s is missing IRQ function\n", __func__, + chip->label); + return; + } + + for (i = 0; i < ARRAY_SIZE(irq_data); i++) { + gpiod = gpiochip_request_own_desc(chip, i, NULL); + if (IS_ERR(gpiod)) { + pr_err("%s: failed to get GPIO pin %d (%ld)\n", + __func__, i, PTR_ERR(gpiod)); + return; + } + /* Store irq_data location for IRQ handler use */ + irq_data[i] = irq_get_irq_data(gpiod_to_irq(gpiod)); + + gpiochip_free_own_desc(gpiod); + } + fiqhandler_start = &qwerty_fiqin_start; fiqhandler_length = &qwerty_fiqin_end - &qwerty_fiqin_start; pr_info("Installing fiq handler from %p, length 0x%x\n", diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index 2821284aa0c9..f15c0793c34b 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c @@ -580,6 +580,44 @@ static struct gpiod_hog ams_delta_gpio_hogs[] = { {}, }; +/* + * Some drivers may not use GPIO lookup tables but need to be provided + * with GPIO numbers. The same applies to GPIO based IRQ lines - some + * drivers may even not use GPIO layer but expect just IRQ numbers. + * We could either define GPIO lookup tables then use them on behalf + * of those devices, or we can use GPIO driver level methods for + * identification of GPIO and IRQ numbers. For the purpose of the latter, + * defina a helper function which identifies GPIO chips by their labels. + */ +static int gpiochip_match_by_label(struct gpio_chip *chip, void *data) +{ + char *label = data; + + return !strcmp(label, chip->label); +} + +/* + * The purpose of this function is to take care of proper initialization of + * devices and data structures which depend on GPIO lines provided by OMAP GPIO + * banks but their drivers don't use GPIO lookup tables or GPIO layer at all. + * The function may be called as soon as OMAP GPIO devices are probed. + * Since that happens at postcore_initcall, it can be called successfully + * from init_machine or later. + * Dependent devices may be registered from within this function or later. + */ +static void __init omap_gpio_deps_init(void) +{ + struct gpio_chip *chip; + + chip = gpiochip_find(OMAP_GPIO_LABEL, gpiochip_match_by_label); + if (!chip) { + pr_err("%s: OMAP GPIO chip not found\n", __func__); + return; + } + + ams_delta_init_fiq(chip); +} + static void __init ams_delta_init(void) { /* mux pins for uarts */ @@ -600,6 +638,7 @@ static void __init ams_delta_init(void) omap_cfg_reg(J19_1610_CAM_D6); omap_cfg_reg(J18_1610_CAM_D7); + omap_gpio_deps_init(); gpiod_add_hogs(ams_delta_gpio_hogs); omap_serial_init(); @@ -642,8 +681,6 @@ static void __init ams_delta_init(void) gpiod_add_lookup_tables(ams_delta_gpio_tables, ARRAY_SIZE(ams_delta_gpio_tables)); - ams_delta_init_fiq(); - omap_writew(omap_readw(ARM_RSTCT1) | 0x0004, ARM_RSTCT1); omapfb_set_lcd_config(&ams_delta_lcd_config); diff --git a/arch/arm/mach-omap1/include/mach/ams-delta-fiq.h b/arch/arm/mach-omap1/include/mach/ams-delta-fiq.h index 6dfc3e1210a3..a9769ff396bc 100644 --- a/arch/arm/mach-omap1/include/mach/ams-delta-fiq.h +++ b/arch/arm/mach-omap1/include/mach/ams-delta-fiq.h @@ -73,7 +73,7 @@ extern unsigned int fiq_buffer[]; extern unsigned char qwerty_fiqin_start, qwerty_fiqin_end; -extern void __init ams_delta_init_fiq(void); +extern void __init ams_delta_init_fiq(struct gpio_chip *chip); #endif #endif From patchwork Sat Jun 9 14:02:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 927141 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FKuuwicw"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4131H51YjZz9s01 for ; Sun, 10 Jun 2018 00:04:16 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753431AbeFIODQ (ORCPT ); Sat, 9 Jun 2018 10:03:16 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:43552 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753336AbeFIODM (ORCPT ); Sat, 9 Jun 2018 10:03:12 -0400 Received: by mail-lf0-f65.google.com with SMTP id n15-v6so24167046lfn.10; Sat, 09 Jun 2018 07:03:11 -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=mTpXdNg/kUL1h8CCG7+VyS+Bu4yjZEBcFSavjJKK+0c=; b=FKuuwicwaGtulq4r5rrdZdnJK4XSOWmSw2M9kkGDrXnLFgFtrq2gzstvZabi9GgW3E J0OZb/co9L5Q4HPfyjPH/ob5as1dMMmKWYCKYckOzCqcwnpmbe/jBsdQY7nyQ6aRcvAK zq1ZEv4qAfPjkWy1EpH9ET98KkLayuvWR8H2UiTIebPupBHo+ZS95Fq2ZoL94wPV8EnZ cQGoG+6PafpzL9zeTAb3dA09eMyxJg7YD2aHOGeIIvYflFuRzRx+7P49NwZ623NDAlEf jWO+fv3m4MWcFU57Gse05Y5/L5DQ/EGiSglCZy5z4NGDNruSzO1AwQKt+Fjz1wfTv/5m XMsA== 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=mTpXdNg/kUL1h8CCG7+VyS+Bu4yjZEBcFSavjJKK+0c=; b=LJA8XxegID/ijEfX1EF8LrWw/a0ZxAQTiFqqSeX3l73x8CuDq0uVJ5KNGlSHNUymJP qxz4bXS/Mqn1eRr7FEeLL8QUXdr+iteRi1QmbGEc4SOZXXbLGygjJx2RNQ3ARcLm1rQ2 bJPSiTlEQsfJkP5ijZW4uvthDgPRSckf6f3fCz6I2JT3VY+dutsDxK8qPEg4XJM3e27Y THbBbiagUqgCL+VIqtbEawnu+HsZxiTTv9+7nFVa3yiT6k1qSEWHtI1v3OHnthKftbrG XKWAcwSHBDZy0xdaF/6IlrOalz7cNUy+NvmYYtTnm0/bXYYv2o3XoyCyYm5y6T451VDr Kbog== X-Gm-Message-State: APt69E3uVv6NmBHqcCVIkqejloGlbjNwqWosX3hQO8cDBVGyZtZXipeM sutA7p75q9zwGqiALmGUWoY= X-Google-Smtp-Source: ADUXVKIqD6pRO7+XqYUbxDb9uZdb/r5IZyGQQWWBGrOTUroA2mPmxE6blPz7KVG4ursBBZo2iav9oA== X-Received: by 2002:a2e:55cf:: with SMTP id g76-v6mr4711105lje.4.1528552990652; Sat, 09 Jun 2018 07:03:10 -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.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Jun 2018 07:03:10 -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 07/10] ARM: OMAP1: ams-delta FIQ: Keep serio input GPIOs requested Date: Sat, 9 Jun 2018 16:02:21 +0200 Message-Id: <20180609140224.32606-7-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-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From the very beginning, input GPIO pins of ams-delta serio port have been used by FIQ handler, not serio driver. Don't request those pins from the ams-delta-serio driver any longer, instead keep them requested and initialized by the FIQ initialization routine which already requests them and releases while identifying GPIO IRQs. Signed-off-by: Janusz Krzysztofik --- arch/arm/mach-omap1/ams-delta-fiq.c | 42 ++++++++++++++++++++++++++++++----- drivers/input/serio/ams_delta_serio.c | 30 ++----------------------- 2 files changed, 39 insertions(+), 33 deletions(-) diff --git a/arch/arm/mach-omap1/ams-delta-fiq.c b/arch/arm/mach-omap1/ams-delta-fiq.c index 1d54a6177f14..5a6c59ac9b5f 100644 --- a/arch/arm/mach-omap1/ams-delta-fiq.c +++ b/arch/arm/mach-omap1/ams-delta-fiq.c @@ -45,6 +45,11 @@ static struct irq_chip *irq_chip; static struct irq_data *irq_data[16]; static unsigned int irq_counter[16]; +static const char *pin_name[16] __initconst = { + [AMS_DELTA_GPIO_PIN_KEYBRD_DATA] = "keybrd_data", + [AMS_DELTA_GPIO_PIN_KEYBRD_CLK] = "keybrd_clk", +}; + static irqreturn_t deferred_fiq(int irq, void *dev_id) { struct irq_data *d; @@ -80,7 +85,7 @@ static irqreturn_t deferred_fiq(int irq, void *dev_id) void __init ams_delta_init_fiq(struct gpio_chip *chip) { - struct gpio_desc *gpiod; + struct gpio_desc *gpiod, *data = NULL, *clk = NULL; void *fiqhandler_start; unsigned int fiqhandler_length; struct pt_regs FIQ_regs; @@ -96,7 +101,7 @@ void __init ams_delta_init_fiq(struct gpio_chip *chip) } for (i = 0; i < ARRAY_SIZE(irq_data); i++) { - gpiod = gpiochip_request_own_desc(chip, i, NULL); + gpiod = gpiochip_request_own_desc(chip, i, pin_name[i]); if (IS_ERR(gpiod)) { pr_err("%s: failed to get GPIO pin %d (%ld)\n", __func__, i, PTR_ERR(gpiod)); @@ -105,8 +110,27 @@ void __init ams_delta_init_fiq(struct gpio_chip *chip) /* Store irq_data location for IRQ handler use */ irq_data[i] = irq_get_irq_data(gpiod_to_irq(gpiod)); - gpiochip_free_own_desc(gpiod); + /* + * FIQ handler takes full control over serio data and clk GPIO + * pins. Initiaize them and keep requested so nobody can + * interfere. Fail if any of those two couldn't be requested. + */ + switch (i) { + case AMS_DELTA_GPIO_PIN_KEYBRD_DATA: + data = gpiod; + gpiod_direction_input(data); + break; + case AMS_DELTA_GPIO_PIN_KEYBRD_CLK: + clk = gpiod; + gpiod_direction_input(clk); + break; + default: + gpiochip_free_own_desc(gpiod); + break; + } } + if (!data || !clk) + goto out_gpio; fiqhandler_start = &qwerty_fiqin_start; fiqhandler_length = &qwerty_fiqin_end - &qwerty_fiqin_start; @@ -117,7 +141,7 @@ void __init ams_delta_init_fiq(struct gpio_chip *chip) if (retval) { pr_err("ams_delta_init_fiq(): couldn't claim FIQ, ret=%d\n", retval); - return; + goto out_gpio; } retval = request_irq(INT_DEFERRED_FIQ, deferred_fiq, @@ -125,7 +149,7 @@ void __init ams_delta_init_fiq(struct gpio_chip *chip) if (retval < 0) { pr_err("Failed to get deferred_fiq IRQ, ret=%d\n", retval); release_fiq(&fh); - return; + goto out_gpio; } /* * Since no set_type() method is provided by OMAP irq chip, @@ -175,4 +199,12 @@ void __init ams_delta_init_fiq(struct gpio_chip *chip) offset = IRQ_ILR0_REG_OFFSET + (INT_GPIO_BANK1 - NR_IRQS_LEGACY) * 0x4; val = omap_readl(OMAP_IH1_BASE + offset) | 1; omap_writel(val, OMAP_IH1_BASE + offset); + + return; + +out_gpio: + if (data) + gpiochip_free_own_desc(data); + if (clk) + gpiochip_free_own_desc(clk); } diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c index 0b4d5a952ecb..a83d8b3cd838 100644 --- a/drivers/input/serio/ams_delta_serio.c +++ b/drivers/input/serio/ams_delta_serio.c @@ -110,19 +110,6 @@ static void ams_delta_serio_close(struct serio *serio) regulator_disable(priv->vcc); } -static const struct gpio ams_delta_gpios[] __initconst_or_module = { - { - .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_DATA, - .flags = GPIOF_DIR_IN, - .label = "serio-data", - }, - { - .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_CLK, - .flags = GPIOF_DIR_IN, - .label = "serio-clock", - }, -}; - static int ams_delta_serio_init(struct platform_device *pdev) { struct ams_delta_serio *priv; @@ -133,13 +120,6 @@ static int ams_delta_serio_init(struct platform_device *pdev) if (!priv) return -ENOMEM; - err = gpio_request_array(ams_delta_gpios, - ARRAY_SIZE(ams_delta_gpios)); - if (err) { - dev_err(&pdev->dev, "Couldn't request gpio pins\n"); - goto serio; - } - priv->vcc = devm_regulator_get(&pdev->dev, "vcc"); if (IS_ERR(priv->vcc)) { err = PTR_ERR(priv->vcc); @@ -147,7 +127,7 @@ static int ams_delta_serio_init(struct platform_device *pdev) /* Fail softly if the regulator is not available yet */ if (err == -ENODEV) err = -EPROBE_DEFER; - goto gpio; + return err; } err = request_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), @@ -155,7 +135,7 @@ static int ams_delta_serio_init(struct platform_device *pdev) DRIVER_NAME, priv); if (err < 0) { dev_err(&pdev->dev, "IRQ request failed (%d)\n", err); - goto gpio; + return err; } /* * Since GPIO register handling for keyboard clock pin is performed @@ -191,10 +171,6 @@ static int ams_delta_serio_init(struct platform_device *pdev) irq: free_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), priv); -gpio: - gpio_free_array(ams_delta_gpios, - ARRAY_SIZE(ams_delta_gpios)); -serio: return err; } @@ -204,8 +180,6 @@ static int ams_delta_serio_exit(struct platform_device *pdev) serio_unregister_port(priv->serio); free_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0); - gpio_free_array(ams_delta_gpios, - ARRAY_SIZE(ams_delta_gpios)); return 0; } From patchwork Sat Jun 9 14:02:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 927140 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Hwn3EpAA"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4131Gv5L2Fz9s01 for ; Sun, 10 Jun 2018 00:04:07 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753446AbeFIODU (ORCPT ); Sat, 9 Jun 2018 10:03:20 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:38224 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753432AbeFIODR (ORCPT ); Sat, 9 Jun 2018 10:03:17 -0400 Received: by mail-lf0-f65.google.com with SMTP id i83-v6so24179168lfh.5; Sat, 09 Jun 2018 07:03:16 -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=DIwkmllE5OHi+wZIxuaETUTsL/3AgjHsyvkIR+Slbw4=; b=Hwn3EpAAkTsxP0lgqX727eQ0EM3ivKfltLVeosDZmRQR0IZ7loGZF9zRDBi5YxqHVv orZCsItRrsiyN9YX5UDL7E6QPP6ooeFCMBdgFg2dMoib+0uJ0nGlmYk5jkMF5gvI8Ddz ITbXh3eMrmtQcetN5f05NAf9GKeAeesziw4gGyxUtpHpRghPmOxpM5l1zcWjyAQfVdb1 YpNwRuHecIoU5UmWtc3uGnVQtIb8PokkYEpq4zKGgYonCI2t7THj0K8/TgSpBMlrFfro p2kplV2U3iy8GJp7OFn3zHmQhUtsAfZKY4YQCNjPNH4IZPw1I+fV3c4KTumYFdmdLI9j niQA== 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=DIwkmllE5OHi+wZIxuaETUTsL/3AgjHsyvkIR+Slbw4=; b=ZgSs+3pv8dgvFcUMEmQml/Kxbv8yfQCZ6PcCwI3CpMuf5eo7w6t7nqLF1jFmO3h/zY AcWPLR7RVpsx6Gsq8z7l11n9N0fIyb0n4flXI17Vl7QzrRdalitMvuB8Mka/7q8P6BTH I2s4uLU3gxeuYHgwLpulPoN1YvT+IcB+7dtXoSyIr2zmJjvfdzTRD/2dzJZyDv3eQMhD 6ktA3CNTeJPGym9VXsLWJqqZ2jDcTe0Nt7XGS1bfMW38RhX8IHqWPJPJ1LSrVrh50h4v FxfFENiALTMXoE79ZjtoSPTijJTLwgHcAmFmyH9yjUgtG0kY1lTzsCGkR4uSrLi3zdcR A3ng== X-Gm-Message-State: APt69E0S9hygIXqLT7O+tkZq/YBv2MHAI1CbuDzF4GZ4tVxcRu0JAL27 vJhN87jxxtNKiW4IL9YtTkw= X-Google-Smtp-Source: ADUXVKIe4dDaHGGme7N1vNWwyxYTzojkwejOQLgjd8EfYOShOD/tU8ho6HKVv3fyRNWqKqQs47pbWQ== X-Received: by 2002:a19:c608:: with SMTP id w8-v6mr5647173lff.64.1528552995558; Sat, 09 Jun 2018 07:03:15 -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.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Jun 2018 07:03:14 -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 08/10] ARM: OMAP1: Get rid of Date: Sat, 9 Jun 2018 16:02:22 +0200 Message-Id: <20180609140224.32606-8-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-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Split the header file into two parts and move them to directories where they belong. Information on internal structure of FIQ buffer is moved to , to be used by ams-delta-serio driver. Other information used by ams-delta board init file and FIQ code is made local to mach-omap1 root directory. Signed-off-by: Janusz Krzysztofik --- MAINTAINERS | 1 + arch/arm/mach-omap1/ams-delta-fiq-handler.S | 5 +-- arch/arm/mach-omap1/ams-delta-fiq.c | 7 ++-- arch/arm/mach-omap1/ams-delta-fiq.h | 41 ++++++++++++++++++++++ arch/arm/mach-omap1/board-ams-delta.c | 2 +- drivers/input/serio/ams_delta_serio.c | 3 +- .../linux/platform_data}/ams-delta-fiq.h | 27 +++----------- 7 files changed, 56 insertions(+), 30 deletions(-) create mode 100644 arch/arm/mach-omap1/ams-delta-fiq.h rename {arch/arm/mach-omap1/include/mach => include/linux/platform_data}/ams-delta-fiq.h (71%) diff --git a/MAINTAINERS b/MAINTAINERS index 14fbc6e94774..c487348da38c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -10391,6 +10391,7 @@ F: arch/arm/plat-omap/ F: arch/arm/configs/omap1_defconfig F: drivers/i2c/busses/i2c-omap.c F: include/linux/platform_data/i2c-omap.h +F: include/linux/platform_data/ams-delta-fiq.h OMAP2+ SUPPORT M: Tony Lindgren diff --git a/arch/arm/mach-omap1/ams-delta-fiq-handler.S b/arch/arm/mach-omap1/ams-delta-fiq-handler.S index bf608441b357..ddc27638ba2a 100644 --- a/arch/arm/mach-omap1/ams-delta-fiq-handler.S +++ b/arch/arm/mach-omap1/ams-delta-fiq-handler.S @@ -14,11 +14,12 @@ */ #include -#include +#include +#include #include -#include +#include "ams-delta-fiq.h" #include "iomap.h" #include "soc.h" diff --git a/arch/arm/mach-omap1/ams-delta-fiq.c b/arch/arm/mach-omap1/ams-delta-fiq.c index 5a6c59ac9b5f..e72935034d42 100644 --- a/arch/arm/mach-omap1/ams-delta-fiq.c +++ b/arch/arm/mach-omap1/ams-delta-fiq.c @@ -19,12 +19,13 @@ #include #include #include +#include #include #include -#include +#include "ams-delta-fiq.h" static struct fiq_handler fh = { .name = "ams-delta-fiq" @@ -35,8 +36,8 @@ static struct fiq_handler fh = { * The FIQ and IRQ isrs can both read and write it. * It is structured as a header section several 32bit slots, * followed by the circular buffer where the FIQ isr stores - * keystrokes received from the qwerty keyboard. - * See ams-delta-fiq.h for details of offsets. + * keystrokes received from the qwerty keyboard. See + * for details of offsets. */ unsigned int fiq_buffer[1024]; EXPORT_SYMBOL(fiq_buffer); diff --git a/arch/arm/mach-omap1/ams-delta-fiq.h b/arch/arm/mach-omap1/ams-delta-fiq.h new file mode 100644 index 000000000000..3f691d68aa62 --- /dev/null +++ b/arch/arm/mach-omap1/ams-delta-fiq.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* + * arch/arm/mach-omap1/ams-delta-fiq.h + * + * Taken from the original Amstrad modifications to fiq.h + * + * Copyright (c) 2004 Amstrad Plc + * Copyright (c) 2006 Matt Callow + * Copyright (c) 2010 Janusz Krzysztofik + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#ifndef __AMS_DELTA_FIQ_H +#define __AMS_DELTA_FIQ_H + +#include + +/* + * Interrupt number used for passing control from FIQ to IRQ. + * IRQ12, described as reserved, has been selected. + */ +#define INT_DEFERRED_FIQ INT_1510_RES12 +/* + * Base address of an interrupt handler that the INT_DEFERRED_FIQ belongs to. + */ +#if (INT_DEFERRED_FIQ < IH2_BASE) +#define DEFERRED_FIQ_IH_BASE OMAP_IH1_BASE +#else +#define DEFERRED_FIQ_IH_BASE OMAP_IH2_BASE +#endif + +#ifndef __ASSEMBLER__ +extern unsigned char qwerty_fiqin_start, qwerty_fiqin_end; + +extern void __init ams_delta_init_fiq(struct gpio_chip *chip); +#endif + +#endif diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index f15c0793c34b..fe9a3e7cbfeb 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c @@ -41,10 +41,10 @@ #include #include -#include #include "camera.h" #include +#include "ams-delta-fiq.h" #include "iomap.h" #include "common.h" diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c index a83d8b3cd838..5d0bd2005648 100644 --- a/drivers/input/serio/ams_delta_serio.c +++ b/drivers/input/serio/ams_delta_serio.c @@ -22,6 +22,7 @@ */ #include #include +#include #include #include #include @@ -30,8 +31,6 @@ #include -#include - #define DRIVER_NAME "ams-delta-serio" MODULE_AUTHOR("Matt Callow"); diff --git a/arch/arm/mach-omap1/include/mach/ams-delta-fiq.h b/include/linux/platform_data/ams-delta-fiq.h similarity index 71% rename from arch/arm/mach-omap1/include/mach/ams-delta-fiq.h rename to include/linux/platform_data/ams-delta-fiq.h index a9769ff396bc..dc0f835ea918 100644 --- a/arch/arm/mach-omap1/include/mach/ams-delta-fiq.h +++ b/include/linux/platform_data/ams-delta-fiq.h @@ -1,5 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + /* - * arch/arm/mach-omap1/include/ams-delta-fiq.h + * include/linux/platform_data/ams-delta-fiq.h * * Taken from the original Amstrad modifications to fiq.h * @@ -11,24 +13,8 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ -#ifndef __AMS_DELTA_FIQ_H -#define __AMS_DELTA_FIQ_H - -#include - -/* - * Interrupt number used for passing control from FIQ to IRQ. - * IRQ12, described as reserved, has been selected. - */ -#define INT_DEFERRED_FIQ INT_1510_RES12 -/* - * Base address of an interrupt handler that the INT_DEFERRED_FIQ belongs to. - */ -#if (INT_DEFERRED_FIQ < IH2_BASE) -#define DEFERRED_FIQ_IH_BASE OMAP_IH1_BASE -#else -#define DEFERRED_FIQ_IH_BASE OMAP_IH2_BASE -#endif +#ifndef __LINUX_PLATFORM_DATA_AMS_DELTA_FIQ_H +#define __LINUX_PLATFORM_DATA_AMS_DELTA_FIQ_H /* * These are the offsets from the beginning of the fiq_buffer. They are put here @@ -71,9 +57,6 @@ #ifndef __ASSEMBLER__ extern unsigned int fiq_buffer[]; -extern unsigned char qwerty_fiqin_start, qwerty_fiqin_end; - -extern void __init ams_delta_init_fiq(struct gpio_chip *chip); #endif #endif 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: 927139 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="PCDkJURh"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4131Gh3ZX4z9s01 for ; Sun, 10 Jun 2018 00:03:56 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753484AbeFIOD0 (ORCPT ); Sat, 9 Jun 2018 10:03:26 -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-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 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-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@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; } From patchwork Sat Jun 9 14:02:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 927138 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="qo0lbknO"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4131GX25Cmz9s01 for ; Sun, 10 Jun 2018 00:03:48 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753508AbeFIODe (ORCPT ); Sat, 9 Jun 2018 10:03:34 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:39865 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753479AbeFIOD1 (ORCPT ); Sat, 9 Jun 2018 10:03:27 -0400 Received: by mail-lf0-f68.google.com with SMTP id t134-v6so24194328lff.6; Sat, 09 Jun 2018 07:03:26 -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=djSnsPBRAqn84tARJhTa0m7NEna6Za9l4TCMdj3DMCQ=; b=qo0lbknOc4CU3V0flBUX9rkduwMFaM7tM01hZqZweTwmDXrdipxwaiw76Si4G3Sjpy cQGTz3yKi9rUozkdAOpsUFkyAYVj5IgmM4bhq9WU1qJs5mMboKVUZ4MFxQfju69HpHPK +vtmpYni6LMLyu0ktnGfBFp7khbHIzp0/DB7840nHaYVQLq2RiGXug5DFsoRZ5JJEi/y sd8SA70CijQLwSANpcDLiEDa8/upg+Q0pNtfyS+KEkZBSUx1Si57XXL3isZDbVkZxaFg GNIzDvwdr3MI/8CavwYM9tckNL0H2AmMYLeM/85g4H+uHhvFpyIag5pMJ1d0TWzHKOfq hpfw== 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=djSnsPBRAqn84tARJhTa0m7NEna6Za9l4TCMdj3DMCQ=; b=t2lOOAOKWjRtd47CB/0gqCU+WOV+xrFCPVzfFzEBX+ThFNwbx/foAQFdHOXSCSWV0u 80iQNDU/Jqn/7FJuLP8il/RwVHnnVoOyBrWSFqleQ87mYRMjBnZY3s3qW5zOWCyTgr29 dcqsXRgXFpLz6Cm5+c+5tth5WA/979D6So4bfkX1Q9K91F9swXacJjmJ+zhi42OiP8gj yrr5Nt4QqKhbT8vnM1vB1PKxcnO7z8Vzjv+lZaputONWQVasqGUJlBT02KCDAXCvzaNB gl+98HEqVbLGGq/bYgDiqXujjCbfZqu3dOP6kJ2FloUa16MdxJDQ6j3hCSLRCfk6GjM3 2kbA== X-Gm-Message-State: APt69E3KX2NkOR+VUVxCStzGxht54dM5+Zm3Po9m/fEgdcwhOxsuzmsv OmbTBbHAJHXmhG2U96HHLgE= X-Google-Smtp-Source: ADUXVKI5O7/TQxE4+uhsdskTYROYkzTZSTVVSSHY9D2F/x/fVELWR/4qVGq9CHHH/s2NIjqFQo9hfg== X-Received: by 2002:a2e:1092:: with SMTP id 18-v6mr7540444ljq.115.1528553005489; Sat, 09 Jun 2018 07:03:25 -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.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Jun 2018 07:03:24 -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 10/10] Input: ams_delta_serio: Get FIQ buffer from platform_data Date: Sat, 9 Jun 2018 16:02:24 +0200 Message-Id: <20180609140224.32606-10-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-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Instead of exporting the FIQ buffer symbol to be used in ams-delta-serio driver, pass it to the driver as platform_data. Signed-off-by: Janusz Krzysztofik --- arch/arm/mach-omap1/ams-delta-fiq.c | 6 +++--- arch/arm/mach-omap1/board-ams-delta.c | 8 ++++++++ drivers/input/serio/ams_delta_serio.c | 20 +++++++++++++------- include/linux/platform_data/ams-delta-fiq.h | 4 ---- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/arch/arm/mach-omap1/ams-delta-fiq.c b/arch/arm/mach-omap1/ams-delta-fiq.c index e9d350117240..983638994bd4 100644 --- a/arch/arm/mach-omap1/ams-delta-fiq.c +++ b/arch/arm/mach-omap1/ams-delta-fiq.c @@ -40,8 +40,7 @@ static struct fiq_handler fh = { * keystrokes received from the qwerty keyboard. See * for details of offsets. */ -unsigned int fiq_buffer[1024]; -EXPORT_SYMBOL(fiq_buffer); +static unsigned int fiq_buffer[1024]; static struct irq_chip *irq_chip; static struct irq_data *irq_data[16]; @@ -203,9 +202,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 */ + /* Initialize serio device IRQ resource and platform_data */ serio->resource[0].start = gpiod_to_irq(clk); serio->resource[0].end = serio->resource[0].start; + serio->dev.platform_data = fiq_buffer; return; diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index 84177ba3e39a..772892487827 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c @@ -520,6 +520,14 @@ static struct resource ams_delta_serio_resources[] = { static struct platform_device ams_delta_serio_device = { .name = "ams-delta-serio", .id = PLATFORM_DEVID_NONE, + .dev = { + /* + * Initialize .platform_data explicitly with NULL to + * indicate it is going to be used. It will be replaced + * with FIQ buffer address as soon as FIQ is initialized. + */ + .platform_data = NULL, + }, .num_resources = ARRAY_SIZE(ams_delta_serio_resources), .resource = ams_delta_serio_resources, }; diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c index 03640b171516..ee38c5140f43 100644 --- a/drivers/input/serio/ams_delta_serio.c +++ b/drivers/input/serio/ams_delta_serio.c @@ -37,6 +37,7 @@ MODULE_LICENSE("GPL"); struct ams_delta_serio { struct serio *serio; struct regulator *vcc; + unsigned int *fiq_buffer; }; static int check_data(struct serio *serio, int data) @@ -66,22 +67,23 @@ static int check_data(struct serio *serio, int data) static irqreturn_t ams_delta_serio_interrupt(int irq, void *dev_id) { struct ams_delta_serio *priv = dev_id; - int *circ_buff = &fiq_buffer[FIQ_CIRC_BUFF]; + int *circ_buff = &priv->fiq_buffer[FIQ_CIRC_BUFF]; int data, dfl; u8 scancode; - fiq_buffer[FIQ_IRQ_PEND] = 0; + priv->fiq_buffer[FIQ_IRQ_PEND] = 0; /* * Read data from the circular buffer, check it * and then pass it on the serio */ - while (fiq_buffer[FIQ_KEYS_CNT] > 0) { + while (priv->fiq_buffer[FIQ_KEYS_CNT] > 0) { - data = circ_buff[fiq_buffer[FIQ_HEAD_OFFSET]++]; - fiq_buffer[FIQ_KEYS_CNT]--; - if (fiq_buffer[FIQ_HEAD_OFFSET] == fiq_buffer[FIQ_BUF_LEN]) - fiq_buffer[FIQ_HEAD_OFFSET] = 0; + data = circ_buff[priv->fiq_buffer[FIQ_HEAD_OFFSET]++]; + priv->fiq_buffer[FIQ_KEYS_CNT]--; + if (priv->fiq_buffer[FIQ_HEAD_OFFSET] == + priv->fiq_buffer[FIQ_BUF_LEN]) + priv->fiq_buffer[FIQ_HEAD_OFFSET] = 0; dfl = check_data(priv->serio, data); scancode = (u8) (data >> 1) & 0xFF; @@ -116,6 +118,10 @@ static int ams_delta_serio_init(struct platform_device *pdev) if (!priv) return -ENOMEM; + priv->fiq_buffer = pdev->dev.platform_data; + if (!priv->fiq_buffer) + return -EINVAL; + priv->vcc = devm_regulator_get(&pdev->dev, "vcc"); if (IS_ERR(priv->vcc)) { err = PTR_ERR(priv->vcc); diff --git a/include/linux/platform_data/ams-delta-fiq.h b/include/linux/platform_data/ams-delta-fiq.h index dc0f835ea918..cf4589ccb720 100644 --- a/include/linux/platform_data/ams-delta-fiq.h +++ b/include/linux/platform_data/ams-delta-fiq.h @@ -55,8 +55,4 @@ #define FIQ_CIRC_BUFF 30 /*Start of circular buffer */ -#ifndef __ASSEMBLER__ -extern unsigned int fiq_buffer[]; -#endif - #endif