From patchwork Wed Aug 30 11:57:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naresh Solanki X-Patchwork-Id: 718836 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7645AC83F18 for ; Wed, 30 Aug 2023 18:38:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229986AbjH3Sig (ORCPT ); Wed, 30 Aug 2023 14:38:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243856AbjH3L61 (ORCPT ); Wed, 30 Aug 2023 07:58:27 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C53321B0 for ; Wed, 30 Aug 2023 04:58:24 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-523100882f2so7099762a12.2 for ; Wed, 30 Aug 2023 04:58:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1693396703; x=1694001503; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=xraLT5LJsBHpcTpLojfKH2C0VbKrtJqn2idXpO3Q7k4=; b=fKbvTNAcYIqvUBvyQCGYCQZn7YLtQKydWCHBlKKCw+z0TYo8PbPLOk2L5DsvqTrOuu hw/2Z4J58tcFB0Klb0u1IrtkMEQ6gt//damfvOWX2AZf/XFVlpkYFEPBpNavkexNxeD+ Aw9n3WSp5bI2zLjnpLjmXzXg6/taXmrE/6gpLtMVmoXKOVLZfSO7f6q1tmVbt88JOzkB gB+I+Ff6ImldVV3XzKX+NIQktDDzJEU5LhrdrZmcPDWKs538vDUeurVwCiVWTVE5JiyZ dq6tVYfNfXpHINrflzM1b+l9SPwOuwUEJ7E1B5THa5aNGPf4dYn/Y63NNv0sfamAB8S+ +32Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693396703; x=1694001503; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xraLT5LJsBHpcTpLojfKH2C0VbKrtJqn2idXpO3Q7k4=; b=EUJ1k/FGywmzGAypmms/Lwe5ainFIZFDBRy/RLE7ayg2rEhG9FPyxY1vB6B/0V9vE/ 3m6iBFb422AZJBJjWdjtd0u9F8WRWDlERy+ef5mrCgzKg5AJZ/YnS77vHPbBqGTD1XcG I9pzeEwjKSBtUJiTKwLl1G97onUkYgO0daLSdViqGnU0cYq4SdaPN5aTsy+rVg+l5rki SvQ5f1J3NWDy+erej8FaOuyFXtr2Q27FrW8l8jClwRH6mce+NbNF8xH3CCnngJ9WsEwA 2+V3LvgPvZKrFlAajlAA2Bd/0l+QErwLVUileKqaqeIJtN1WgN1vaN4kTt4kLizmt3kR k10A== X-Gm-Message-State: AOJu0Yz8z2oSZyoUrXCKkXuHKZQ0858S1mijoY8MmEnvdqBUMIFydhj4 CwJdxpmByEwh86II8cfZdGXZ6A== X-Google-Smtp-Source: AGHT+IHvDPZ/6vvBEBfGlIX7oJAvbPEoFEmwc2hCyzNLDGBhuPPNYL7+Ecr9I/J2Mc1Sq/3iq7xFGw== X-Received: by 2002:a05:6402:1206:b0:525:7da7:af10 with SMTP id c6-20020a056402120600b005257da7af10mr1907238edw.23.1693396703233; Wed, 30 Aug 2023 04:58:23 -0700 (PDT) Received: from stroh80.sec.9e.network (ip-078-094-000-051.um19.pools.vodafone-ip.de. [78.94.0.51]) by smtp.gmail.com with ESMTPSA id u8-20020aa7d888000000b00527e7087d5dsm6681571edq.15.2023.08.30.04.58.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Aug 2023 04:58:22 -0700 (PDT) From: Naresh Solanki X-Google-Original-From: Naresh Solanki To: Peter Rosin , Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Laurent Pinchart Cc: Patrick Rudolph , Naresh Solanki , linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] dt-binding: Add custom property for MAX7357 Date: Wed, 30 Aug 2023 13:57:42 +0200 Message-ID: <20230830115744.4102929-1-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Patrick Rudolph Add a custom property "maxim,bus-lockup-fix" to enable proprietary features on MAX7357. The driver configures MAX7357 to isolate the failing channel and trigger a flush-out sequence for bus lock-up resolution. Signed-off-by: Patrick Rudolph Signed-off-by: Naresh Solanki --- .../devicetree/bindings/i2c/i2c-mux-pca954x.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) base-commit: f9ea75e087b81081f33e34c4e1ba8b4abe841d9f diff --git a/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml b/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml index 2d7bb998b0e9..984d4614a270 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml +++ b/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml @@ -71,6 +71,11 @@ properties: description: A voltage regulator supplying power to the chip. On PCA9846 the regulator supplies power to VDD2 (core logic) and optionally to VDD1. + maxim,bus-lockup-fix: + type: boolean + description: Isolates only the stuck channel and generates a flush-out sequence + to attempt to clear the bus lock-up. + required: - compatible - reg @@ -95,6 +100,16 @@ allOf: "#interrupt-cells": false interrupt-controller: false + - if: + not: + properties: + compatible: + contains: + const: maxim,max7357 + then: + properties: + maxim,bus-lockup-fix: false + unevaluatedProperties: false examples: From patchwork Wed Aug 30 11:57:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naresh Solanki X-Patchwork-Id: 719296 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 106BBC83F19 for ; Wed, 30 Aug 2023 18:38:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235152AbjH3Sil (ORCPT ); Wed, 30 Aug 2023 14:38:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243860AbjH3L63 (ORCPT ); Wed, 30 Aug 2023 07:58:29 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 907761BB for ; Wed, 30 Aug 2023 04:58:26 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-4ffa248263cso8540581e87.2 for ; Wed, 30 Aug 2023 04:58:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1693396705; x=1694001505; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CkHk2loL9NCqNiqGYQo3IA9z812u1ZOg7XOjk7HU8JU=; b=JJQqQbbICnk/RWUXTMPBWSQDIVKDLT4hbfpAHWxb8oVwVIYZsBkYbToOeVccWAB7sq EWWkDZ148GYVDxBeiwKfcli1oNMK39lJazCwJywpjj1oynfsAuqHJqH9VLkO9G1gBElQ 1oSVWtVPWwFqjqNtG6s1Q4rbCDSoDuF1kuT98L1epITZk+PV6cGfzxqN0mrK4OWi+rvt wiseHic+glhiheSTE3ayPZYb3v4gE1sZHr0JBQR8C3UbpGNIV8qXumRFKf4DHHhMB6at aquLbVLXPNXaq0wvtWFBU8o4sqEpFh2JpsQaGYPZckd64UabZ8WVMXrXNMFUgv2o4b+E d8Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693396705; x=1694001505; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CkHk2loL9NCqNiqGYQo3IA9z812u1ZOg7XOjk7HU8JU=; b=kekFlY0EDbYT5eMuUrgYPeal/gBdk5+TVs+zhujnf4rw5tAxxEI3UV33ziWr/h+8t1 1A9ElxKgMPBDfRqESQA8KcfQUJjyuD/5KOUNYKuS26eABjLc/iKFZhyMqGl5b+wto8OE d3Z/7adwrmpGZWn68NBeRUVja24CGA/7zo5UKvqfUZlaum8DGCrUOjR53pgMYcfRyRUM 1w2vXGPGgqfs20JghFPvDst10H6JpYqhkq6N+/NqGcH5wePbtU7ube9zqLAR51stx1oQ aL3Z5a8fsa3P3o2t/jPDAbqy6yt4fkoVYRgs/XglSelS5LdyYjdfASbm8qfUBHfj9kHE o9+g== X-Gm-Message-State: AOJu0Yyed0Z23xxHi718K4zbM0aoEZ+zJ+qDfgRBqx6RbxBLYDhg6Yvy ceINpEihEcJ9iyHprFBzcnRqLQ== X-Google-Smtp-Source: AGHT+IFLaUbs5W43ZQ5OArheWLh5UIXhU8Ue0fD5xs9o+zwVEcgOHyPA0VLUxWvozqztFYinc1Lx1g== X-Received: by 2002:a05:6512:2829:b0:4fd:b1f6:b6ca with SMTP id cf41-20020a056512282900b004fdb1f6b6camr1408368lfb.25.1693396704396; Wed, 30 Aug 2023 04:58:24 -0700 (PDT) Received: from stroh80.sec.9e.network (ip-078-094-000-051.um19.pools.vodafone-ip.de. [78.94.0.51]) by smtp.gmail.com with ESMTPSA id u8-20020aa7d888000000b00527e7087d5dsm6681571edq.15.2023.08.30.04.58.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Aug 2023 04:58:24 -0700 (PDT) From: Naresh Solanki X-Google-Original-From: Naresh Solanki To: Peter Rosin Cc: Patrick Rudolph , Naresh Solanki , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] i2c: muxes: Enable features on MAX7357 Date: Wed, 30 Aug 2023 13:57:43 +0200 Message-ID: <20230830115744.4102929-2-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230830115744.4102929-1-Naresh.Solanki@9elements.com> References: <20230830115744.4102929-1-Naresh.Solanki@9elements.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Patrick Rudolph Detect that max7357 is being used and run custom init sequence. By default MAX7357 disconnects all channels on a bus lock-up and signals this condition to the bus master using an interrupt. Disable the interrupt as it's not useful within the kernel and it might conflict with the reset functionality that shares the same pin. Use the introduced 'maxim,bus-lockup-fix' property to enable faulty channel isolation and flush-out sequence generation. Signed-off-by: Patrick Rudolph Signed-off-by: Naresh Solanki --- drivers/i2c/muxes/i2c-mux-pca954x.c | 56 ++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index 2219062104fb..0c1ff1438e7c 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c @@ -57,6 +57,21 @@ #define PCA954X_IRQ_OFFSET 4 +/* + * MAX7357 exposes 7 registers on POR which allow to configure additional + * features. The configuration register holds the following settings: + */ +#define MAX7357_CONF_INT_ENABLE BIT(0) +#define MAX7357_CONF_FLUSH_OUT BIT(1) +#define MAX7357_CONF_RELEASE_INT BIT(2) +#define MAX7357_CONF_LOCK_UP_CLEAR BIT(3) +#define MAX7357_CONF_DISCON_SINGLE_CHAN BIT(4) +#define MAX7357_CONF_BUS_LOCKUP_DETECT_DIS BIT(5) +#define MAX7357_CONF_ENABLE_BASIC_MODE BIT(6) +#define MAX7357_CONF_PRECONNECT_TEST BIT(7) + +#define MAX7357_POR_DEFAULT_CONF BIT(0) + enum pca_type { max_7356, max_7357, @@ -477,6 +492,41 @@ static int pca954x_init(struct i2c_client *client, struct pca954x *data) return ret; } +static int max7357_init(struct i2c_client *client, struct pca954x *data) +{ + struct i2c_adapter *adap = client->adapter; + u8 conf = MAX7357_POR_DEFAULT_CONF; + int ret; + + if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) + return pca954x_init(client, data); + + if (data->idle_state >= 0) + data->last_chan = pca954x_regval(data, data->idle_state); + else + data->last_chan = 0; /* Disconnect multiplexer */ + + /* + * The interrupt signals downstream channels that are stuck, but + * there's nothing to do and it prevents using the shared pin as reset. + */ + conf &= MAX7357_CONF_INT_ENABLE; + + /* + * On bus lock-up isolate the failing channel and try to clear the + * fault by sending the flush-out sequence. + */ + if (device_property_read_bool(&client->dev, "maxim,bus-lockup-fix")) + conf |= MAX7357_CONF_DISCON_SINGLE_CHAN | + MAX7357_CONF_FLUSH_OUT; + + ret = i2c_smbus_write_byte_data(client, data->last_chan, conf); + if (ret < 0) + data->last_chan = 0; + + return ret; +} + /* * I2C init/probing/exit functions */ @@ -560,7 +610,11 @@ static int pca954x_probe(struct i2c_client *client) * initializes the mux to a channel * or disconnected state. */ - ret = pca954x_init(client, data); + if ((dev->of_node && of_device_is_compatible(dev->of_node, "maxim,max7357")) || + id->driver_data == max_7357) + ret = max7357_init(client, data); + else + ret = pca954x_init(client, data); if (ret < 0) { dev_warn(dev, "probe failed\n"); ret = -ENODEV;