From patchwork Thu Feb 27 20:51:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Warren X-Patchwork-Id: 3735691 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B54D99F35F for ; Thu, 27 Feb 2014 20:52:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DC98520258 for ; Thu, 27 Feb 2014 20:52:03 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DDDD320255 for ; Thu, 27 Feb 2014 20:52:02 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WJ7vz-0006H2-3g; Thu, 27 Feb 2014 20:51:59 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WJ7vw-0003Ar-H7; Thu, 27 Feb 2014 20:51:56 +0000 Received: from avon.wwwdotorg.org ([70.85.31.133]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WJ7vt-00038o-El for linux-arm-kernel@lists.infradead.org; Thu, 27 Feb 2014 20:51:54 +0000 Received: from severn.wwwdotorg.org (unknown [192.168.65.5]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by avon.wwwdotorg.org (Postfix) with ESMTPS id 6BDB663FA; Thu, 27 Feb 2014 13:51:31 -0700 (MST) Received: from swarren-lx1.nvidia.com (localhost [127.0.0.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by severn.wwwdotorg.org (Postfix) with ESMTPSA id 917EDE4611; Thu, 27 Feb 2014 13:51:10 -0700 (MST) From: Stephen Warren To: Samuel Ortiz , Lee Jones Subject: [PATCH V2 2/3] mfd: palmas: support IRQ inversion at the board level Date: Thu, 27 Feb 2014 13:51:20 -0700 Message-Id: <1393534281-30759-2-git-send-email-swarren@wwwdotorg.org> X-Mailer: git-send-email 1.8.1.5 In-Reply-To: <1393534281-30759-1-git-send-email-swarren@wwwdotorg.org> References: <1393534281-30759-1-git-send-email-swarren@wwwdotorg.org> X-NVConfidentiality: public X-Virus-Scanned: clamav-milter 0.97.8 at avon.wwwdotorg.org X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140227_155153_583921_F9F7F121 X-CRM114-Status: GOOD ( 15.48 ) X-Spam-Score: 1.2 (+) Cc: Mark Rutland , devicetree@vger.kernel.org, Stephen Warren , Pawel Moll , Ian Campbell , J Keerthy , Ian Lartey , Rob Herring , Kumar Gala , linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=no 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 From: Stephen Warren Implement the new DT property ti,irq-externally-inverted, and add an equivalent platform data field to match. This allows the driver to correctly automatically configure the IRQ output polarity when the board or SoC contains an inverter between the Palmas IRQ output and IRQ controller input. Signed-off-by: Stephen Warren Acked-by: Laxman Dewangan Acked-by: Lee Jones --- v2: Split V1's patch 1/2 into separate patches 1/3 and 2/3. If this patch (and likely 1/3 too) could be applied to its own branch (w/ signed tag) in the MFD tree, that would great; then I can pull patch it into the Tegra tree so that I can apply patch 3/3 on top. Thanks. --- drivers/mfd/palmas.c | 4 ++++ include/linux/mfd/palmas.h | 1 + 2 files changed, 5 insertions(+) diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c index d280d789e55a..f4ea932adf8d 100644 --- a/drivers/mfd/palmas.c +++ b/drivers/mfd/palmas.c @@ -293,6 +293,8 @@ static int palmas_set_pdata_irq_flag(struct i2c_client *i2c, } pdata->irq_flags = irqd_get_trigger_type(irq_data); + pdata->irq_external_inversion = of_property_read_bool(i2c->dev.of_node, + "ti,irq-externally-inverted"); dev_info(&i2c->dev, "Irq flag is 0x%08x\n", pdata->irq_flags); return 0; } @@ -447,6 +449,8 @@ static int palmas_i2c_probe(struct i2c_client *i2c, reg = PALMAS_POLARITY_CTRL_INT_POLARITY; else reg = 0; + if (pdata->irq_external_inversion) + reg ^= PALMAS_POLARITY_CTRL_INT_POLARITY; ret = palmas_update_bits(palmas, PALMAS_PU_PD_OD_BASE, PALMAS_POLARITY_CTRL, PALMAS_POLARITY_CTRL_INT_POLARITY, reg); diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h index 9974e387e483..2fdf08c50a48 100644 --- a/include/linux/mfd/palmas.h +++ b/include/linux/mfd/palmas.h @@ -292,6 +292,7 @@ struct palmas_clk_platform_data { struct palmas_platform_data { int irq_flags; + bool irq_external_inversion; int gpio_base; /* bit value to be loaded to the POWER_CTRL register */