Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp12703pja; Fri, 22 Nov 2019 02:47:58 -0800 (PST) X-Google-Smtp-Source: APXvYqx2hSe3J6PKoMoUPwNLxnXOjOXET2pbKtSaneTtgT0cU2qwifVkVYKFj1zZMb/glYXHBwOE X-Received: by 2002:a50:bac2:: with SMTP id x60mr235418ede.114.1574419678140; Fri, 22 Nov 2019 02:47:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574419678; cv=none; d=google.com; s=arc-20160816; b=E3SjACXcoLAsU3XUBCLhPyvwQunyDIbSYXbE2smxOzKoe2wKqaJ+Lut+4PukcjGvq6 4nCJq/a4wCKB44QvoIYzKPmDxPM/FB6p3QTTKkr0SIIo+yZ/BBc3MaZKUvTGyLxQFhhp EMw1ja+feTR+jHpvm9aVEfo2SVpw8ouyF2fi6O99tuWAbfm71afkJ+erD6FWTEaLk1AP XzNR8HL6NxWUhoZU/9qxURH/phS01ArReRl8YCYKSmXvOLETlmSQtWu4krn7ESH1y0A9 U6buqz/rRJ+XsJkINR3CRH8d7wvu9c9qqDIrWoYV/Noc40TF9FEUiCdDbjpyvYwPpqGG N3Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=IR64BvDFCiGH/GjfzuXMfycHLfu9trfku8Ivdpv1Utk=; b=NBF8UE2X+KHGEjGom/khVVjjNtxEzM0Ne/x6Kc3bOoPC8J8FSHCQtCYTaT/Rlwnluc +WiM5eIYW81zikzz3II61pb0/2Ba5adKJOoEG0hAjBMoXprJF7bKcmvxwgPGJVmeE/Vx b/ctlnMjdxGnBYk/UuUHe0MPkmtcxwzoqxsDridMHCbKTHe0Og/mXdoCQrY7dkqdqN9X nUnNOJAtNhtGRcRP/ttwcOx9sEg1vhb1HlSbdmDjAjl82DpbscU2vu0e/5CUtBeZCJs5 1fZyfXAuzzYmKYFhD3oHodU3WRkHI5sQFHn3F9kdMkXUBjg2DWnoIHlmnZBWlQcTnkQq T/ow== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d16si4012471edp.283.2019.11.22.02.47.34; Fri, 22 Nov 2019 02:47:58 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729242AbfKVKn3 (ORCPT + 99 others); Fri, 22 Nov 2019 05:43:29 -0500 Received: from mga18.intel.com ([134.134.136.126]:47785 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729217AbfKVKnZ (ORCPT ); Fri, 22 Nov 2019 05:43:25 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Nov 2019 02:43:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,229,1571727600"; d="scan'208";a="216341366" Received: from lahna.fi.intel.com (HELO lahna) ([10.237.72.163]) by fmsmga001.fm.intel.com with SMTP; 22 Nov 2019 02:43:20 -0800 Received: by lahna (sSMTP sendmail emulation); Fri, 22 Nov 2019 12:43:20 +0200 Date: Fri, 22 Nov 2019 12:43:19 +0200 From: Mika Westerberg To: Jan Kiszka Cc: Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , Linux Kernel Mailing List , linux-gpio@vger.kernel.org, ACPI Devel Maling List , "Rafael J . Wysocki" Subject: Re: [PATCH v3 2/2] gpio: sch: Hook into ACPI SCI handler to catch GPIO edge events Message-ID: <20191122104319.GC11621@lahna.fi.intel.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 20, 2019 at 08:20:14PM +0100, Jan Kiszka wrote: > 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 Reviewed-by: Mika Westerberg Below one minor stylistic comment. > --- > 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) You can also write this like if (!core_status &&& !resume_status) > + 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