From patchwork Mon Jan 9 09:02:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Reid X-Patchwork-Id: 712526 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3txq314WQJz9sDg for ; Mon, 9 Jan 2017 20:04:13 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757570AbdAIJEG (ORCPT ); Mon, 9 Jan 2017 04:04:06 -0500 Received: from anchovy2.45ru.net.au ([203.30.46.146]:59832 "EHLO anchovy.45ru.net.au" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757531AbdAIJDM (ORCPT ); Mon, 9 Jan 2017 04:03:12 -0500 Received: (qmail 30305 invoked by uid 5089); 9 Jan 2017 09:03:02 -0000 Received: by simscan 1.2.0 ppid: 30291, pid: 30292, t: 0.0340s scanners: regex: 1.2.0 attach: 1.2.0 clamav: 0.88.3/m:40/d:1950 Received: from unknown (HELO preid-centos7.electromag.com.au) (preid@electromag.com.au@203.59.230.133) by anchovy3.45ru.net.au with ESMTPA; 9 Jan 2017 09:03:02 -0000 Received: by preid-centos7.electromag.com.au (Postfix, from userid 1000) id AC1223048AC33; Mon, 9 Jan 2017 17:02:58 +0800 (AWST) From: Phil Reid To: peda@axentia.se, wsa@the-dreams.de, robh+dt@kernel.org, mark.rutland@arm.com, preid@electromag.com.au, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v3 5/5] i2c: mux: pca954x: Add irq_mask_en to delay enabling irqs Date: Mon, 9 Jan 2017 17:02:56 +0800 Message-Id: <1483952576-5308-6-git-send-email-preid@electromag.com.au> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1483952576-5308-1-git-send-email-preid@electromag.com.au> References: <1483952576-5308-1-git-send-email-preid@electromag.com.au> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Unfortunately some hardware device will assert their irq line immediately on power on and provide no mechanism to mask the irq. As the i2c muxes provide no method to mask irq line this provides a work around by keeping the parent irq masked until enough device drivers have loaded to service all pending interrupts. For example the the ltc1760 assert its SMBALERT irq immediately on power on. With two ltc1760 attached to bus 0 & 1 on a pca954x mux when the first device is registered irq are enabled and fire continuously as the second device driver has not yet loaded. Setting this parameter to 0x3 while delay the irq being enabled until both devices are ready. Acked-by: Peter Rosin Signed-off-by: Phil Reid --- drivers/i2c/muxes/i2c-mux-pca954x.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index 84fc767..fb1d245 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c @@ -75,6 +75,19 @@ struct chip_desc { } muxtype; }; +/* + * irq_mask_enable: Provides a mechanism to work around hardware that asserts + * their irq immediately on power on. It allows the enabling of the irq to be + * delayed until the corresponding bits in the the irq_mask are set thru + * irq_unmask. + * For example the ltc1760 assert its SMBALERT irq immediately on power on. + * With two ltc1760 attached to bus 0 & 1 on a pca954x mux when the first + * device is registered irq are enabled and fire continuously as the second + * device driver has not yet loaded. Setting this parameter to 0x3 while + * delay the irq being enabled until both devices are ready. + * This workaround will not work if two devices share an interrupt on the + * same bus segment. + */ struct pca954x { const struct chip_desc *chip; @@ -84,6 +97,7 @@ struct pca954x { struct irq_domain *irq; unsigned int irq_mask; + unsigned int irq_mask_enable; }; /* Provide specs for the PCA954x types we know about */ @@ -270,9 +284,12 @@ static void pca954x_irq_unmask(struct irq_data *idata) struct pca954x *data = irq_data_get_irq_chip_data(idata); unsigned int pos = idata->hwirq; - if (!data->irq_mask) + if (!data->irq_mask_enable && !data->irq_mask) enable_irq(data->client->irq); data->irq_mask |= BIT(pos); + if (data->irq_mask_enable && + (data->irq_mask & data->irq_mask) == data->irq_mask_enable) + enable_irq(data->client->irq); } static int pca954x_irq_set_type(struct irq_data *idata, unsigned int type) @@ -395,6 +412,9 @@ static int pca954x_probe(struct i2c_client *client, idle_disconnect_dt = of_node && of_property_read_bool(of_node, "i2c-mux-idle-disconnect"); + of_property_read_u32(of_node, "nxp,irq-mask-enable", + &data->irq_mask_enable); + ret = pca954x_irq_setup(muxc); if (ret) goto fail_del_adapters;