From patchwork Wed Apr 4 19:00:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H. Nikolaus Schaller" X-Patchwork-Id: 895111 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=none (p=none dis=none) header.from=goldelico.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=goldelico.com header.i=@goldelico.com header.b="psCAsLxX"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40Gb0x1LSyz9s0x for ; Thu, 5 Apr 2018 05:01:53 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752239AbeDDTBu (ORCPT ); Wed, 4 Apr 2018 15:01:50 -0400 Received: from mo4-p02-ob.smtp.rzone.de ([81.169.146.171]:26697 "EHLO mo4-p02-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751971AbeDDTAn (ORCPT ); Wed, 4 Apr 2018 15:00:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1522868440; s=strato-dkim-0002; d=goldelico.com; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=WXVgAJXt4T7Vy/FZwABpF/70wnxp21PU60ZVJZU76/Y=; b=psCAsLxXWv1Gl2vIOK1aL/C+wQblZ+yfrijxEHAmqgSOYsupCze34H9ID6cCvLLan4 LOiOp1NF/NL9CX9BNkS47JicMJd9adEpoXnb1nIIDVsYcjd7BRcxwA+wRsZ9sVtn51JZ euwpoq+vZTwaoqZ4JG553SxE8xbPXnlHeTvNgBFDgmiLld9cHZYYTKvSXihqi4Sm7pI9 +nOgGYa3KmMgJ0iusgiqAEdG3bVPNy36JA+tZ9t4lOYQclDmopXvZ+E8kipIYDsRgEYV UiEuWiqIf3FfAhYQml0pgdnt+sDwtvj3qQZns+dtgc2LZeGaH3yaquIkgW8GmZ41RLOl vTQA== X-RZG-AUTH: :JGIXVUS7cutRB/49FwqZ7WcJeFKiMhflhwDubTJ9o12DNO4Ij0pA1dWeZVY= X-RZG-CLASS-ID: mo00 Received: from localhost.localdomain (p57AE0B8C.dip0.t-ipconnect.de [87.174.11.140]) by smtp.strato.de (RZmta 43.1 DYNA|AUTH) with ESMTPSA id K02537u34J0QIEo (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Wed, 4 Apr 2018 21:00:26 +0200 (CEST) From: "H. Nikolaus Schaller" To: galak@codeaurora.org, andy.shevchenko@gmail.com, Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Linus Walleij , Alexandre Courbot Cc: devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, letux-kernel@openphoenux.org, kernel@pyra-handheld.com, "H. Nikolaus Schaller" Subject: [PATCH v2 3/5] [RFC] gpio: pca953x: hack to map LEVEL irqs to EDGE irqs (may loose interrupts/hang) Date: Wed, 4 Apr 2018 21:00:22 +0200 Message-Id: <637f00dd7da98cfeffdc6080914a5f67b433da50.1522868423.git.hns@goldelico.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: References: In-Reply-To: References: Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org So far the interrupt type from the DTS is ignored, i.e. interrupt-parent = <&pcal6524> interrupts = <10 IRQ_TYPE_EDGE_RISING> does not overwrite a devm_request_threaded_irq(..., IRQ_TYPE_LEVEL_LOW, ...) in driver code. Therefore, the pca953x driver rejects the setup of the irq because it can only handle EDGE interrupts so far. This hack translates level interrupts to edge interrupts for the pca953x chips. This is enough for initial testing, but not a good solution since interrupts may be lost. If for example the connected chip requests a IRQ_TYPE_LEVEL_LOW this may have the reason that there may be multiple different interrupt sources in the chip - wired-or together to the input of the pca953x. Now if we do edge detecion only, the first interrupt will generate an EDGE_FALLING, but a second one won't ever if the first interrupt wasn't already processed. IMHO a better solution would be to make the pca953x interrupt handler check if the irq input is still in the active level and run the device specific handler again. But this is a major rework that I must leave to others with more knowledge and time to work on it. This RFC patch is for having a reminder. Not Signed-off-by: H. Nikolaus Schaller --- drivers/gpio/gpio-pca953x.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index c70acba710c7..c21cfdee2eb6 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -521,6 +521,11 @@ static int pca953x_irq_set_type(struct irq_data *d, unsigned int type) int bank_nb = d->hwirq / BANK_SZ; u8 mask = 1 << (d->hwirq % BANK_SZ); + if (type & IRQ_TYPE_LEVEL_LOW) + type |= IRQ_TYPE_EDGE_FALLING; + if (type & IRQ_TYPE_LEVEL_HIGH) + type |= IRQ_TYPE_EDGE_RISING; + if (!(type & IRQ_TYPE_EDGE_BOTH)) { dev_err(&chip->client->dev, "irq %d: unsupported type %d\n", d->irq, type);