Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2266306ybc; Wed, 20 Nov 2019 11:22:39 -0800 (PST) X-Google-Smtp-Source: APXvYqxoDeAEX3q+4amtWWPpaaZhL/3yRKykyJOpWwb5YMo2AP+qiD5W589BrD2rOFB5FPJt2lcF X-Received: by 2002:a05:600c:2248:: with SMTP id a8mr5382244wmm.139.1574277759613; Wed, 20 Nov 2019 11:22:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574277759; cv=none; d=google.com; s=arc-20160816; b=DNbhGlhJwRZXEr83p+/truxeu7C3JlnnSEZHm1397f3EvTz9DdhDIt9IrPKSGkdxWk n3TcxkOofb2l0SVUdb5CN5ZKiENp9cVPxLCctz5WSuf+CTPyLpnPGTY/ypDj6xgeYrdm wN7ePepayZi/YVtfSa6ViiPo/WDOjshX175IuDDUi9mUk7pFgEROrRw6EmyQ3UgA5XX7 Fs1Su+CoVHveUl0Mren/0RGZYh9N+B8nGzU23AlNivDFg0OP4gxWOiH2uFFSIpz4URSK 3D9CsR7u7NpL8ym/OBdd0FXoz7LYUpSkECzm9XgnubxA6AslmfaD5cLupNbmm3YIWdjV h/ug== 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:references :in-reply-to:message-id:date:subject:cc:to:from; bh=/Dnk9m6GmCr4t3OmP2kit89mv7kb/TJRAbdCEbxCjS0=; b=VmEmbDRDDtSH752A4ZeVj4mn5+MlmGXGzKXnvTTqoC9OY4Z9VTo3aSvbJDJiLKnRnl yrW+EUliimu0T0Ymz7qp4rFqdmC4MXxhyh61DP1X+wQJMLDRLIJx7QF4FFRVp2tkfLKt H+eUwfbwHBmD6QE3wpmpxCHFf0vdl/RGqUfCVXmD+FkwO/pbvBSQ98dF1qTOu3xnbyUT BehQsM6sy5/kL5DiFet6YTWlLfQq8u/c83ey5zyugFwn8H4uBJgG0rqRY1boTCPUtFb9 xhfN89DnAlrgS+8bjDlWuSgVnj7oWgVvGgEqvCs+tlGBgH02I1bhHk3o3WMxnMLyijfK YxEg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a55si275064edc.13.2019.11.20.11.22.15; Wed, 20 Nov 2019 11:22:39 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727579AbfKTTUa (ORCPT + 99 others); Wed, 20 Nov 2019 14:20:30 -0500 Received: from goliath.siemens.de ([192.35.17.28]:42197 "EHLO goliath.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726634AbfKTTUa (ORCPT ); Wed, 20 Nov 2019 14:20:30 -0500 Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id xAKJKF28030990 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Nov 2019 20:20:15 +0100 Received: from md1f2u6c.ad001.siemens.net ([139.25.68.37]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id xAKJKFQf024611; Wed, 20 Nov 2019 20:20:15 +0100 From: Jan Kiszka To: Andy Shevchenko , Linus Walleij , Bartosz Golaszewski Cc: Linux Kernel Mailing List , linux-gpio@vger.kernel.org, Mika Westerberg , ACPI Devel Maling List , "Rafael J . Wysocki" Subject: [PATCH v3 2/2] gpio: sch: Hook into ACPI SCI handler to catch GPIO edge events Date: Wed, 20 Nov 2019 20:20:14 +0100 Message-Id: X-Mailer: git-send-email 2.16.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Kiszka The ACPI description on the Quark platform does not provide the required information to do establish generic handling. Therefore, we need to hook from the driver directly into SCI handler of the ACPI subsystem in order to catch and report GPIO-related events. Validated on the Quark-based IOT2000 platform. Signed-off-by: Jan Kiszka --- drivers/gpio/gpio-sch.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/gpio/gpio-sch.c b/drivers/gpio/gpio-sch.c index 6a9c5500800c..75c95da145d8 100644 --- a/drivers/gpio/gpio-sch.c +++ b/drivers/gpio/gpio-sch.c @@ -155,6 +155,31 @@ static const struct gpio_chip sch_gpio_chip = { .to_irq = sch_gpio_to_irq, }; +static u32 sch_sci_handler(void *context) +{ + struct sch_gpio *sch = context; + unsigned long core_status, resume_status; + unsigned int resume_gpios, offset; + + core_status = inl(sch->iobase + GTS); + resume_status = inl(sch->iobase + GTS + 0x20); + + if (core_status == 0 && resume_status == 0) + return ACPI_INTERRUPT_NOT_HANDLED; + + for_each_set_bit(offset, &core_status, sch->resume_base) + generic_handle_irq(sch->irq_base + offset); + + resume_gpios = sch->chip.ngpio - sch->resume_base; + for_each_set_bit(offset, &resume_status, resume_gpios) + generic_handle_irq(sch->irq_base + sch->resume_base + offset); + + outl(core_status, sch->iobase + GTS); + outl(resume_status, sch->iobase + GTS + 0x20); + + return ACPI_INTERRUPT_HANDLED; +} + static int sch_irq_type(struct irq_data *d, unsigned int type) { struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); @@ -215,6 +240,7 @@ static int sch_gpio_probe(struct platform_device *pdev) struct irq_chip_type *ct; struct sch_gpio *sch; struct resource *res; + acpi_status status; int irq_base, ret; sch = devm_kzalloc(&pdev->dev, sizeof(*sch), GFP_KERNEL); @@ -303,6 +329,10 @@ static int sch_gpio_probe(struct platform_device *pdev) if (ret) return ret; + status = acpi_install_sci_handler(sch_sci_handler, sch); + if (ACPI_FAILURE(status)) + return -EINVAL; + return 0; } -- 2.16.4