Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3725422rdh; Tue, 28 Nov 2023 02:01:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IG6HEn6Dhsai6xY3h+mw28Ssi0Yfnkg4YInMRZ4NtMW8GHCv2QOe6r1eYc9UawBrbtxXn+b X-Received: by 2002:a05:6830:213:b0:6d7:ed0f:87d4 with SMTP id em19-20020a056830021300b006d7ed0f87d4mr15564520otb.33.1701165665618; Tue, 28 Nov 2023 02:01:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701165665; cv=none; d=google.com; s=arc-20160816; b=YEjhnXD8BMSAslx2aMuZ5nNWy2iVKFvjrUSPQzji5d0SSFBegiWhBLJXO2wHsLxIk5 jkFVfG1yUftWUahlsLo2lEjGtuVquACC776ZxrEeLhYlxSInurT4bavycIBUrSy/9U7B KSywVQ1F7WCMyEscwxtNBKZd73STQ2MzgATdRTPMZjTLkti2qiZhv7bOonkFr3CgEyEA T5UE2IqdkD4+CDLEYV6FR1tWFPR4/7II2Ivi3ez8Ye/hMWhOR+d+rvOvsiSmQf/Sv7iY 0UGuVuuvMlfelXm+2t5WdwgH3ZaoV84XhznBWaAQVn0V5YSjlfEjUpbGXL4cjl9wJhE7 hT+Q== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=KM+51/Ab8q9Ob1ygxdet2j1y8TyHO4eFE3VACdVz/qw=; fh=2nC6Eum3KPrNBmIby8V3XGk+pStcLbxmYHi8gkGLd5Q=; b=hLH+pvdrcgig8U3IJvWaFdwW8Caqj8qI+DCo+nWYAcWQzMRfVfeF8CpPkrje05Md1V CQI1A/kDn9fpckVtTVWhSftJQ1/PDdt+XCKD1QnsvpUF8ofz2FjuqNNtissgpbT4SFDY 4PZpRLAf7noN9j+odug03tQftoBa6omnlUA/zoJlTvU8vZl0H0+VhNMKl8VaEBOS6yoB GKk1TlgUG+xc+tcjpX4BQim6rHd25eM5XOPIxese1mjOerblroJsl6fsRYRFkWcKt0kJ UXnsh7PfLpauGonwO5eN/Q9tcloT8h0x35ajzo9Tjy09RU0TgTUlTrYdLAOLOEeeSCqS GLiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b=DPmy9lQD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=9elements.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id 1-20020a631541000000b005c1cc7273bcsi12260318pgv.731.2023.11.28.02.00.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 02:01:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b=DPmy9lQD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 C06578057B25; Tue, 28 Nov 2023 02:00:54 -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 S1343928AbjK1KAO (ORCPT + 99 others); Tue, 28 Nov 2023 05:00:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343965AbjK1KAL (ORCPT ); Tue, 28 Nov 2023 05:00:11 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0920AD41 for ; Tue, 28 Nov 2023 02:00:17 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-332ca7f95e1so3660212f8f.0 for ; Tue, 28 Nov 2023 02:00:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1701165615; x=1701770415; 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=KM+51/Ab8q9Ob1ygxdet2j1y8TyHO4eFE3VACdVz/qw=; b=DPmy9lQD8Oa8gozxHMssDF4akvL8spS8WhcoTdR1cXi/IbG1+0ra0JGQCzaN8hCmUA ypV7h25+dNieVZxrWHck5nMFM0Mce2BZ4hkUbp42MsT1FPagR01/z+5gEioByxw7NYFW YnP9tvr89pVV+gSQblrhEO3ckPk2mwgv8SojmHjXmTaGuoGWr4ncgXej2A1JmfO//a2Z acO4dBWGazMn6FfltV86MRAiaxcbzHM6OASRwGrYmV95UrK0xghrg7bbFAfFcwSh8Nkf aEJY8/9trkS3ErMakqIHhjR46415jiHPS502cgc/buo/aVzpNaKX44mDrhg421eIviue wRNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701165615; x=1701770415; 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=KM+51/Ab8q9Ob1ygxdet2j1y8TyHO4eFE3VACdVz/qw=; b=SLzFNsGqAl4o8/V1Xz0CwGirMFrZIUVWcc7yLCs6K9g3l1xAUmJFDPZF2KHgvhkM5y sXQdzoyAXnP4d9rxZO6sEIl23pusdMrPcXRA3ydLnqc0hpLAp4Vfjoie468gpPxf2p60 8UNVUd//rUbcq7GYST9F3f/kbVeqVklIc+/Uz4LIHnlxjsipTjCAcljOn1RAa/hxOpxa 28HOWWtrkelJxv25oW1tlP6paPty/vxj4x+jLPqCoNvY2k8TR/gD/WHO6z1iIRDX9SDr 4778qMkCJ5EwdAMVn+eS0Ksc3RzsP5hnB6gRxaCzeeJGnlgmqALXmvEOSV91XMtRETYB 5URA== X-Gm-Message-State: AOJu0YyxBZmMbpKgMVoyksF8zYhfK5l5SwiFK50KEJ4HB+M1OHhd2j3h 5zHl4+qiB3sL6qHaf+v/x2GzbA== X-Received: by 2002:a5d:4a4e:0:b0:332:e715:f0c3 with SMTP id v14-20020a5d4a4e000000b00332e715f0c3mr9596437wrs.60.1701165615169; Tue, 28 Nov 2023 02:00:15 -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 m5-20020a5d56c5000000b00332cbd59f8bsm14437444wrw.25.2023.11.28.02.00.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 02:00:14 -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: Tue, 28 Nov 2023 10:00:08 +0000 Message-ID: <20231128100009.3727407-2-naresh.solanki@9elements.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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]); Tue, 28 Nov 2023 02:00:54 -0800 (PST) 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; -- 2.41.0