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: 163315 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp315547vqs; Thu, 9 Nov 2023 01:24:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IGdddQK9WbnuJwugugyU5LM+V5JwzLTzgLhlN1De1f/rallt3hXTu/9WO5Z/AlPSeCr+Asd X-Received: by 2002:a17:902:f684:b0:1cc:56b3:efcb with SMTP id l4-20020a170902f68400b001cc56b3efcbmr5181837plg.1.1699521859246; Thu, 09 Nov 2023 01:24:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699521859; cv=none; d=google.com; s=arc-20160816; b=vIZ9bu3euTsaOT5HVHQSvRH7DapbMKLSj7irH4GI0Ah2jKzZ9Ff2nw8qlNwz/VdcpR tEJ8dL9/Pk3Kuvkw1ezhWkeLs8v5J5vhOZlIU1BG1yxUmEFH0mIQXa9/J5A4MyudC6XK GKJr/lsjKekwsq+w3ZWPNx1jxL02wIV//I/iUG1ufaNf0+Jop2Xo5Td1Qb3nCOV2QJ0e iqEWova/yVCSrfG9UTPSGZy3M/egHfE3myhR4T1mXVhV9zX5NLz5HXBsVB+f35ewbsda L8SigFE2gjKtrF790fpOcKq7vqNgENSLh+pDdAjJzY7ARl64EyZdPgWtUDJAMVWlS5ty pAqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KM+51/Ab8q9Ob1ygxdet2j1y8TyHO4eFE3VACdVz/qw=; fh=2nC6Eum3KPrNBmIby8V3XGk+pStcLbxmYHi8gkGLd5Q=; b=awKhzb1zA7VhDHxUaWPycbEB1vQi66ihJPyM/BFOSEgWUrgyN2StOrDAdJad4P844E YrBNi2YANfd/O1BlE6YVNwuUvmNCJ8GNplMEztWjEMG6Ml/uLBmzVaVTUFgBPwqza60K Q7gIIyDSZKJq/gJx9Z8WgKpr8Rwj0bKSw3xyFiUTt1h69WX+9y1gaRmxOP1Beh7CkI3Z WkEy9uj2gaNmd5A03rKzz5GA8X6z5flt9VD2xdSJq7uRrIFP2p1SmWAftFFf4N792AVH ezUrAFI9+HO6MsFIlAVE8pYTCgQTwgTqWRXsiHOvnQS+HP0yPJ/pAnHYEWF0/dwYr3MI 49uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b=NyielVky; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=9elements.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id c9-20020a170903234900b001c604fdbb14si4664660plh.81.2023.11.09.01.24.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 01:24:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b=NyielVky; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=9elements.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id AA0968235253; Thu, 9 Nov 2023 01:24:16 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234327AbjKIJXl (ORCPT + 32 others); Thu, 9 Nov 2023 04:23:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234344AbjKIJXi (ORCPT ); Thu, 9 Nov 2023 04:23:38 -0500 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAA4D2712 for ; Thu, 9 Nov 2023 01:23:35 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-9db6cf8309cso104563766b.0 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=vaxGlYrunQ/DAoWt6PCfsGPLqwZZLJPmoVn3nng+HaANpKaVwIST1MEP/Cd47q37zo uN+hjiDlqQyybivFazcSVRRwfsQtJ6VnyutNkUDZ7794Qi5lvWPcffMfp/4q1FWEPQYE uXTlSK9ABkv/6mQikIaFbSC7Xun8rXRDTrO6Yb1hF/DlWhpxYfhhxOR+YE9vKwDQnDxN fRc/QLON60bx3MtyafMxLyk+aWx3jgszBspRFfz7FTWsj2crZSmBY127N6MAuL3NCd5n l9s2D/n2NvJBA75cnIIxyaCa6Xz85AMi82zed+3qFc3dpVMfgZk47tebYZLW6jA3Nxw/ lpUg== X-Gm-Message-State: AOJu0Yz5Py36oibQq9iKbfhJC9ZI+lFlYicleW7jGeNDOl0J6LVeThfg FSIOp/+aStP6t7yga+0ZlOMMLg== 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-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 09 Nov 2023 01:24:16 -0800 (PST) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782077833261229229 X-GMAIL-MSGID: 1782077833261229229 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;