From patchwork Thu Nov 9 09:23:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naresh Solanki X-Patchwork-Id: 743649 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 D5C7BC4167D for ; Thu, 9 Nov 2023 09:23:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234297AbjKIJXi (ORCPT ); Thu, 9 Nov 2023 04:23:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234320AbjKIJXh (ORCPT ); Thu, 9 Nov 2023 04:23:37 -0500 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BCA1270C for ; Thu, 9 Nov 2023 01:23:34 -0800 (PST) Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-9d2e6c8b542so101501966b.0 for ; Thu, 09 Nov 2023 01:23:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1699521813; x=1700126613; 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=eNQIp/KBXkssBnXnURnyXEtwPP/esZe3h0yYIlPjhVo=; b=eOaLlZmgZ43wYgk2ruMRhebXYpyIQ7XB4SRsMaBi6YL/6ZTQcH99pW/YABiy7Sp5jZ 1ZdudT7FgqCm2LLATi+sOemtp/XHipyJaHDct+mwwMPzXLI1pPvsm+8sPfeRQhD3DlfT FPa+jLxskb5kvEPFGJlBHnlwXXZfDz6lzZHgQfodEj2J0MTPnsmDfxMI9mx++Guuma86 PmTAvBZVy09qZlKPbQY4K1yrhrfXyGX38ef+NHsA0W91UyDwjZ5VxO761yzNv8teeAYV H6ML3jcX+/fHPMp1fVujCzMyymb/nUDCKyhNal4zeG2jMSMGgzBU1dCSXCLPbeNuWMcu 2+Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699521813; x=1700126613; 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=eNQIp/KBXkssBnXnURnyXEtwPP/esZe3h0yYIlPjhVo=; b=saE0jnjQH0OjQspZ0YANGnDIDBGb06HxbaVWvVRpN9xD4U/838/pnOWjm+5K5/BucM w3SbrKZ5GxTsGN7xkNAxRbB3c1At3hI667PZbVrtAyDuPbVtWt/a/K/Nn8HROL4OjN+E Bb4vNbkjetQfnQ7mb5qAI6YOPZ2CyoiBk2CjIi+9nEkD/JD6Ylfnd8KN62Sv0GPFqaY2 Bzk613SB2KS03tYXi/yhnZLMsn2bb8+sHtQgii276U4QV7oeD7upjKnBUBhIcCpYiJYm CYN1MNl68KQVCyhExbiYv5uUHSX6FTo8LbUyvg2SXixyoGVJFIXDcJBlOAknnBBIGgkC dd6Q== X-Gm-Message-State: AOJu0Yx5SfmfCUFv7IEtRvsKqPiKsKcfIIm4lB2PoJXrh3xJjgYXP0De CYnnPi46DXfCECItmayt/G9dcvenFts2dNxoiCOZDQ== X-Google-Smtp-Source: AGHT+IH4me2HKSYcglcNZV5PHQM7TvfR+M1iz+M5Q/szKPL4PSN4JIOUc+KCQ7mA3sUCi/3NYyrCPw== X-Received: by 2002:a17:907:d1d:b0:9bf:4e0b:fb11 with SMTP id gn29-20020a1709070d1d00b009bf4e0bfb11mr3964112ejc.8.1699521812481; Thu, 09 Nov 2023 01:23:32 -0800 (PST) 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 c7-20020a7bc847000000b0040836519dd9sm1453917wml.25.2023.11.09.01.23.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 01:23:32 -0800 (PST) From: Naresh Solanki To: Peter Rosin , Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Laurent Pinchart Cc: robh@kernel.org, Patrick Rudolph , Naresh Solanki , linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RESEND PATCH v5 1/2] dt-bindings: i2c: pca954x: Add custom properties for MAX7357 Date: Thu, 9 Nov 2023 09:23:26 +0000 Message-ID: <20231109092328.3238241-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 Maxim Max7357 has a configuration register to enable additional features. These features aren't enabled by default & its up to board designer to enable the same as it may have unexpected side effects. These should be validated for proper functioning & detection of devices in secondary bus as sometimes it can cause secondary bus being disabled. Add booleans for: - maxim,isolate-stuck-channel - maxim,send-flush-out-sequence - maxim,preconnection-wiggle-test-enable Signed-off-by: Patrick Rudolph Signed-off-by: Naresh Solanki Reviewed-by: Rob Herring --- Changes in V4: - Drop max7358. Changes in V3: - Update commit message Changes in V2: - Update properties. --- .../bindings/i2c/i2c-mux-pca954x.yaml | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) base-commit: 9b156db7e479ac996ae9dc93a0cce3b3df3d0307 diff --git a/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml b/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml index 2d7bb998b0e9..9aa0585200c9 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml +++ b/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml @@ -71,6 +71,23 @@ 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,isolate-stuck-channel: + type: boolean + description: Allows to use non faulty channels while a stuck channel is + isolated from the upstream bus. If not set all channels are isolated from + the upstream bus until the fault is cleared. + + maxim,send-flush-out-sequence: + type: boolean + description: Send a flush-out sequence to stuck auxiliary buses + automatically after a stuck channel is being detected. + + maxim,preconnection-wiggle-test-enable: + type: boolean + description: Send a STOP condition to the auxiliary buses when the switch + register activates a channel to detect a stuck high fault. On fault the + channel is isolated from the upstream bus. + required: - compatible - reg @@ -95,6 +112,19 @@ allOf: "#interrupt-cells": false interrupt-controller: false + - if: + not: + properties: + compatible: + contains: + enum: + - maxim,max7357 + then: + properties: + maxim,isolate-stuck-channel: false + maxim,send-flush-out-sequence: false + maxim,preconnection-wiggle-test-enable: false + unevaluatedProperties: false examples: From patchwork Thu Nov 9 09:23:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naresh Solanki X-Patchwork-Id: 742706 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 7D4C1C4167B for ; Thu, 9 Nov 2023 09:23:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234342AbjKIJXj (ORCPT ); Thu, 9 Nov 2023 04:23:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234333AbjKIJXh (ORCPT ); Thu, 9 Nov 2023 04:23:37 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83F3726B1 for ; Thu, 9 Nov 2023 01:23:35 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-9c53e8b7cf4so102502066b.1 for ; Thu, 09 Nov 2023 01:23:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1699521814; x=1700126614; 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=KM+51/Ab8q9Ob1ygxdet2j1y8TyHO4eFE3VACdVz/qw=; b=NyielVkyhghbYaYkE+xEF7ifhuYLssoBlbepRZFZOZX2xpLJMHRZVR4Jxah0zY2GBT vG/ICtUL6ZerkuR5zg3tyLQVVZ8LapkyPzpusvA0u0WK93cs2iX3ibeB5LQHdhU7WbsP +uMaR6BAi0gHejFg4W06ePQrUGuXibEGqt4LQYFiYm1PcvtPDG1jezrLmMZyti7Uj50r E+3ayK094mZruRafd7IkWhM2VIJo2d226gpfopoyTny7+RqpEbcKNcc+ID9SjWcNcbH6 nIGEHvynq8P9dSqced7oNtvqKqmfxVKU8l1KXzQKloi9OX86Y2zggjMM/TOZW4UNUunx fVgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699521814; x=1700126614; 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=KM+51/Ab8q9Ob1ygxdet2j1y8TyHO4eFE3VACdVz/qw=; b=hOK5p9W/yJ8MqNV6/XkpXBir/ZTHWkacW+RWqYbQve/XeetmczEvDMT9OQD4gXrPsA 2qkmN1jrpiC4xhiBu+7ZZkeWKEii7oo//ja4EL4iXi95xFJb/OaKEUV9Ref0BSYh7XHB KfDDoNWWqxQ8l9dUhHs0bQBHnalGVqGEVVfOKaZUeCBbvVa9sVnhxdGkg9gDTxJkCXBM kU9E13ZJ6GiHdPHOG/vCEPcwVzzKq8ZAfZKkg/VEmgPLARkLV+i9YDhELKq1R64DpVvw K7TxXzxjqe8QvT8d2Tp0aUgfxlpc9XvYHuXDh932rvLUCo7MF8THO/4YcLzcdoMDebTa P+aA== X-Gm-Message-State: AOJu0YzXvf42I9A8TO8TBH9QTdr//cu6eypJERZfAk6+rWNCAQGz41t9 I3yFekElwaipet52JjhQSROmUg== X-Google-Smtp-Source: AGHT+IG8NylJbk6sL0rgMWAxvKR4U7Rs8ENCxcPPyl4ucM5zPQY1D4dVZPN98Dd+djq6QCHybRLZDg== X-Received: by 2002:a17:907:7f1e:b0:9d5:ecf9:e6a0 with SMTP id qf30-20020a1709077f1e00b009d5ecf9e6a0mr2305594ejc.0.1699521813764; Thu, 09 Nov 2023 01:23:33 -0800 (PST) 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 c7-20020a7bc847000000b0040836519dd9sm1453917wml.25.2023.11.09.01.23.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 01:23:33 -0800 (PST) From: Naresh Solanki To: Peter Rosin Cc: andi.shyti@kernel.org, robh@kernel.org, Patrick Rudolph , Naresh Solanki , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RESEND PATCH v5 2/2] i2c: muxes: pca954x: Enable features on MAX7357 Date: Thu, 9 Nov 2023 09:23:27 +0000 Message-ID: <20231109092328.3238241-2-naresh.solanki@9elements.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231109092328.3238241-1-naresh.solanki@9elements.com> References: <20231109092328.3238241-1-naresh.solanki@9elements.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Patrick Rudolph Enable additional features based on DT settings and unconditionally release the shared interrupt pin after 1.6 seconds and allow to use it as reset. These features aren't enabled by default and it's up to board designer to validate for proper functioning and detection of devices in secondary bus as sometimes it can cause secondary bus being disabled. Signed-off-by: Patrick Rudolph Signed-off-by: Naresh Solanki --- Changes in V5: - Fix typos - Update comment - Add newline in dev_warn Changes in V4: - Drop max7358 - Update #define - Move conf variable - Print warning when I2C_FUNC_SMBUS_WRITE_BYTE_DATA isn't supported Changes in V3: - Delete unused #define - Update pca954x_init - Update commit message Changes in V2: - Update comments - Update check for DT properties --- drivers/i2c/muxes/i2c-mux-pca954x.c | 43 ++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index 2219062104fb..f5dfc33b97c0 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c @@ -57,6 +57,20 @@ #define PCA954X_IRQ_OFFSET 4 +/* + * MAX7357's configuration register is writeable after POR, but + * can be locked by setting the basic mode bit. MAX7358 configuration + * register is locked by default and needs to be unlocked first. + * 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_DISCON_SINGLE_CHAN BIT(4) +#define MAX7357_CONF_PRECONNECT_TEST BIT(7) + +#define MAX7357_POR_DEFAULT_CONF MAX7357_CONF_INT_ENABLE + enum pca_type { max_7356, max_7357, @@ -470,7 +484,34 @@ static int pca954x_init(struct i2c_client *client, struct pca954x *data) else data->last_chan = 0; /* Disconnect multiplexer */ - ret = i2c_smbus_write_byte(client, data->last_chan); + if (device_is_compatible(&client->dev, "maxim,max7357")) { + if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { + u8 conf = MAX7357_POR_DEFAULT_CONF; + /* + * The interrupt signal is shared with the reset pin. Release the + * interrupt after 1.6 seconds to allow using the pin as reset. + */ + conf |= MAX7357_CONF_RELEASE_INT; + + if (device_property_read_bool(&client->dev, "maxim,isolate-stuck-channel")) + conf |= MAX7357_CONF_DISCON_SINGLE_CHAN; + if (device_property_read_bool(&client->dev, + "maxim,send-flush-out-sequence")) + conf |= MAX7357_CONF_FLUSH_OUT; + if (device_property_read_bool(&client->dev, + "maxim,preconnection-wiggle-test-enable")) + conf |= MAX7357_CONF_PRECONNECT_TEST; + + ret = i2c_smbus_write_byte_data(client, data->last_chan, conf); + } else { + dev_warn(&client->dev, "Write byte data not supported." + "Cannot enable enhanced mode features\n"); + ret = i2c_smbus_write_byte(client, data->last_chan); + } + } else { + ret = i2c_smbus_write_byte(client, data->last_chan); + } + if (ret < 0) data->last_chan = 0;