From patchwork Fri Feb 14 21:58:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Warren X-Patchwork-Id: 320533 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 1775C2C0040 for ; Sat, 15 Feb 2014 08:58:39 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752282AbaBNV6i (ORCPT ); Fri, 14 Feb 2014 16:58:38 -0500 Received: from avon.wwwdotorg.org ([70.85.31.133]:41005 "EHLO avon.wwwdotorg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752031AbaBNV6h (ORCPT ); Fri, 14 Feb 2014 16:58:37 -0500 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 835996205; Fri, 14 Feb 2014 14:58:36 -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 2D29DE40F4; Fri, 14 Feb 2014 14:58:16 -0700 (MST) From: Stephen Warren To: Samuel Ortiz , Lee Jones Cc: devicetree@vger.kernel.org, Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org, J Keerthy , Ian Lartey , Stefan Agner , josephl@nvidia.com, ldewangan@nvidia.com, Stephen Warren Subject: [PATCH 1/2] mfd: palmas: support IRQ inversion at the board level Date: Fri, 14 Feb 2014 14:58:27 -0700 Message-Id: <1392415108-4365-1-git-send-email-swarren@wwwdotorg.org> X-Mailer: git-send-email 1.8.1.5 X-NVConfidentiality: public X-Virus-Scanned: clamav-milter 0.97.8 at avon.wwwdotorg.org X-Virus-Status: Clean Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Stephen Warren Some boards or SoCs have an inverter between the PMIC IRQ output pin and the IRQ controller input signal. The IRQ specifier in DT is meant to represent the IRQ flags at the input to the IRQ controller. The Palmas HW's IRQ output has configurable polarity. The driver currently selects the output polarity by querying the input polarity at the IRQ controller. This works fine if the IRQ signal is routed directly from the PMIC to the IRQ controller with no intervening logic. However, if the signal is inverted between the two, this automatic polarity selection gets the wrong answer. Add an additional optional DT and platform data parameter which indicates that such an inversion occurs. If this option is enabled, the Palmas driver will configure its IRQ output to the opposite polarity of the IRQ controller's input. An alternative would have been to add a new non-optional DT parameter to indicate the exact desired output polarity. However, this would have been an incompatible change to the DT binding. Signed-off-by: Stephen Warren Acked-by: Laxman Dewangan Acked-by: Laxman Dewangan --- If this patch could be applied to its own branch (w/ signed tag) in the MFD tree, that would great; then I can pull patch 1/2 into the Tegra tree so that I can apply patch 2/2 to the Tegra tree. Thanks. --- Documentation/devicetree/bindings/mfd/palmas.txt | 6 ++++++ drivers/mfd/palmas.c | 4 ++++ include/linux/mfd/palmas.h | 1 + 3 files changed, 11 insertions(+) diff --git a/Documentation/devicetree/bindings/mfd/palmas.txt b/Documentation/devicetree/bindings/mfd/palmas.txt index e5f0f8303461..76ec509d5f87 100644 --- a/Documentation/devicetree/bindings/mfd/palmas.txt +++ b/Documentation/devicetree/bindings/mfd/palmas.txt @@ -18,6 +18,12 @@ Required properties: ti,tps659038 and also the generic series names ti,palmas +- interrupts : Should contain a single entry for the IRQ output. +- ti,irq-externally-inverted : If missing, the polarity of the Palmas IRQ + output should be set to the opposite of the polarity indicated by the IRQ + specifier in the interrupts property. If absent, the polarity should be + configured to match. This allows the representation of an inverter between + the Palmas IRQ output and the interrupt parent's IRQ input. - interrupt-controller : palmas has its own internal IRQs - #interrupt-cells : should be set to 2 for IRQ number and flags The first cell is the IRQ number. 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 */