From patchwork Sun Dec 13 11:15:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Ricard X-Patchwork-Id: 7839021 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6B5C19F387 for ; Sun, 13 Dec 2015 11:16:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 849E320361 for ; Sun, 13 Dec 2015 11:16:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AD30320375 for ; Sun, 13 Dec 2015 11:16:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751843AbbLMLQL (ORCPT ); Sun, 13 Dec 2015 06:16:11 -0500 Received: from mail-wm0-f43.google.com ([74.125.82.43]:38613 "EHLO mail-wm0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751759AbbLMLQH (ORCPT ); Sun, 13 Dec 2015 06:16:07 -0500 Received: by wmpp66 with SMTP id p66so26645289wmp.1; Sun, 13 Dec 2015 03:16:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CNmlABEYDlq/pyRbicdIgXF0OlYxGn9mpCCtCEifEq0=; b=i6lxNg0S+U7L9mizMXAzKgaVNZ5ijjry1UJkCoz44ZSus++O11yA5hhyiLNqae+WvT WSLOurd3TS//jymFSv17r/qhMMheZ3BoU8os/fghiZ7aYr1S8BdT8aSeGrKEmQlDbgQm HM34Ocm+t3RVicbUdshF63ychBAV38UAZMoPcOF3T7Tn7MxzFILEh0lny/R4vg3DUmQr Orez42tCFfvYTESIfXvnQ6sSJK5Nvf2WNkeDlLX7VFCSwWvDHT+yMJETLMPMn+NgD4NA Oz3z6tDhr0k61hBQnTEmJuVK0O0e4/pgq2urGLlK0n8zPjWtmVjuU2QLy7e6vTQ3BQ23 0XCg== X-Received: by 10.194.121.35 with SMTP id lh3mr30958854wjb.164.1450005366368; Sun, 13 Dec 2015 03:16:06 -0800 (PST) Received: from localhost.localdomain (ax113-6-78-236-204-66.fbx.proxad.net. [78.236.204.66]) by smtp.gmail.com with ESMTPSA id 193sm11265773wmp.16.2015.12.13.03.16.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 13 Dec 2015 03:16:05 -0800 (PST) From: Christophe Ricard X-Google-Original-From: Christophe Ricard To: rjw@rjwysocki.net, lenb@kernel.org, linus.walleij@linaro.org, gnurou@gmail.com, andriy.shevchenko@linux.intel.com, mika.westerberg@linux.intel.com, broonie@kernel.org Cc: linux-spi@vger.kernel.org, linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, Christophe Ricard Subject: [PATCH v6 2/3] ACPI / gpio: Add irq_type when a gpio is used as an interrupt Date: Sun, 13 Dec 2015 12:15:54 +0100 Message-Id: <1450005355-6633-3-git-send-email-christophe-h.ricard@st.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1450005355-6633-1-git-send-email-christophe-h.ricard@st.com> References: <1450005355-6633-1-git-send-email-christophe-h.ricard@st.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When a gpio is used as an interrupt in acpi, the irq_type was not available for device driver. Make available polarity and triggering information in acpi_find_gpio by renaming acpi_gpio_info field active_low to polarity and adding triggering field (edge/level). For sanity, in gpiolib.c replace info.active_low by "info.polarity == GPIO_ACTIVE_LOW". Set the irq_type if necessary in acpi_dev_gpio_irq_get. Signed-off-by: Christophe Ricard --- drivers/gpio/gpiolib-acpi.c | 28 ++++++++++++++++++++++------ drivers/gpio/gpiolib.c | 4 ++-- drivers/gpio/gpiolib.h | 6 ++++-- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index bbcac3a..85d6e91 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -416,9 +416,10 @@ static int acpi_find_gpio(struct acpi_resource *ares, void *data) * GpioIo is used then the only way to set the flag is * to use _DSD "gpios" property. */ - if (lookup->info.gpioint) - lookup->info.active_low = - agpio->polarity == ACPI_ACTIVE_LOW; + if (lookup->info.gpioint) { + lookup->info.polarity = agpio->polarity; + lookup->info.triggering = agpio->triggering; + } } return 1; @@ -510,7 +511,7 @@ struct gpio_desc *acpi_get_gpiod_by_index(struct acpi_device *adev, if (lookup.desc && info) { *info = lookup.info; if (active_low) - info->active_low = active_low; + info->polarity = active_low; } return lookup.desc ? lookup.desc : ERR_PTR(-ENOENT); @@ -530,6 +531,7 @@ struct gpio_desc *acpi_get_gpiod_by_index(struct acpi_device *adev, int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) { int idx, i; + unsigned int irq_flags; for (i = 0, idx = 0; idx <= index; i++) { struct acpi_gpio_info info; @@ -538,8 +540,22 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) desc = acpi_get_gpiod_by_index(adev, NULL, i, &info); if (IS_ERR(desc)) break; - if (info.gpioint && idx++ == index) - return gpiod_to_irq(desc); + if (info.gpioint && idx++ == index) { + int irq = gpiod_to_irq(desc); + + if (irq < 0) + return irq; + + irq_flags = acpi_dev_get_irq_type(info.triggering, + info.polarity); + + /* Set type if specified and different than the current one */ + if (irq_flags != IRQ_TYPE_NONE && + irq_flags != irq_get_trigger_type(irq)) + irq_set_irq_type(irq, irq_flags); + + return irq; + } } return -ENOENT; } diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 6798355..90e737f 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1873,7 +1873,7 @@ static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id, return desc; } - if (info.active_low) + if (info.polarity == GPIO_ACTIVE_LOW) *flags |= GPIO_ACTIVE_LOW; return desc; @@ -2212,7 +2212,7 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, desc = acpi_get_gpiod_by_index(to_acpi_node(fwnode), propname, 0, &info); if (!IS_ERR(desc)) - active_low = info.active_low; + active_low = info.polarity == GPIO_ACTIVE_LOW; } if (IS_ERR(desc)) diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index 78e634d..4da5b19 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h @@ -22,11 +22,13 @@ struct acpi_device; /** * struct acpi_gpio_info - ACPI GPIO specific information * @gpioint: if %true this GPIO is of type GpioInt otherwise type is GpioIo - * @active_low: in case of @gpioint, the pin is active low + * @polarity: in case of @gpioint, the pin is active low + * @triggering: in case of @gpioint, interrupt triggering mode (edge or level) */ struct acpi_gpio_info { bool gpioint; - bool active_low; + int polarity; + int triggering; }; /* gpio suffixes used for ACPI and device tree lookup */