Received: by 2002:a05:7412:d008:b0:f9:6acb:47ec with SMTP id bd8csp418575rdb; Wed, 20 Dec 2023 00:29:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEmNRRP9DSf6WZa5d2B+iQiwa/5fk/kbSLuz2v9Pj94kAhYW2QNrnww47vtslJfmmu8uNJd X-Received: by 2002:a05:6a20:ba02:b0:194:1d9:aafc with SMTP id fa2-20020a056a20ba0200b0019401d9aafcmr2550153pzb.46.1703060996551; Wed, 20 Dec 2023 00:29:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703060996; cv=none; d=google.com; s=arc-20160816; b=zsopvAPDnu6AjpbHaa7f7cgMo0iK1GuwguZ3y8zDtQE5kCnl06NE3JpywgRGS9qWz7 MYVkB5l+GaINYUUK8ggWrDNONOrg6tIS/qec0DtGhbxWIriWgveU225htOAUvrUFqqPb Vb0auffQgf4iAoYr4k7Y1/slH0BazyaLIccg8EQl7v5WWMghPXDVdYtmpnr33mmswwQP xIlOZFyKN0NpgNgAqHoGHUgtXrjuTsJIpKJJwnGUzkLqeZmJIO4IameFq/oskSl/4mJS lqAbkgUjbtvTZ+l19M0xUyqIEoEazoHUSjHeGM6NUtYbOF3eMMJLPr3sMQ8qF9sy8pOq QIvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=fsZ/9HB6yqurIFZ++8sH/zT31UdGeaTqC79G9+iRJHI=; fh=JTJ3G4p8sqAKk/6d5cSR9ApBg0xV1RfiDmBUkxSplto=; b=NUV3v51H2CIrH1iEZLHlIjIpwzIJnJcFy5TGqJYARJySuDZi9s6hgD9veDIti1+11q FnnJ3uSuG2Ybne3cKRTAdyp1QBq5nIbzt9We3U/bRUWn+8urWAycKlO8AC5fP/Vh1uX+ tsPes0Ul+VIY8SYXn3hoUDwcM2YAb547nvba41CxRrDlbNFfxOB+s6wBoAPb6gTwy/wM MDsxwpAxNCNErQ8d9cnsJ6LZio6y/YPyqqPtdXQ+uCEu3lmsi7eGET2FHEMjx5dseOXE afX9j6ODyhDnG+uuW37x+4f9r7CKjNLKueV0fABBb8gE2IW8SaZf1JBJU6cmAEMmCHYa AcJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b=TnYbtwfb; spf=pass (google.com: domain of linux-kernel+bounces-6571-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6571-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=9elements.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id u2-20020a63df02000000b005b96c2ab110si20733433pgg.131.2023.12.20.00.29.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 00:29:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6571-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b=TnYbtwfb; spf=pass (google.com: domain of linux-kernel+bounces-6571-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6571-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=9elements.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A3EF6B25B89 for ; Wed, 20 Dec 2023 08:28:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4964A1D6BE; Wed, 20 Dec 2023 08:28:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=9elements.com header.i=@9elements.com header.b="TnYbtwfb" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0C571D120 for ; Wed, 20 Dec 2023 08:28:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=9elements.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=9elements.com Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a1915034144so629942066b.0 for ; Wed, 20 Dec 2023 00:28:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1703060889; x=1703665689; 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=fsZ/9HB6yqurIFZ++8sH/zT31UdGeaTqC79G9+iRJHI=; b=TnYbtwfbauuNmhGkedlV5XQIWbDJ9dFObg4f/+uioRFOHLJ33aZxnEUpaPeNkP+U22 9WBqnKkVyU/jwM7fx0BdvllAgbTRb5a2zRBXeHZmECSMrvMERrcc9vPuG1lRoEceehRB 4UkLbV0Un+X8bG20OFCxfQJ4I3h/lWrvG5sP4b3z0dUfsVg+PBWUj3Vrtv/07HQeoy56 seahj64Ch79Xl6pxJVQGXofcI96D/gwd8TO8A5/3Q8muTnp6rcftzdVoPvNl5d0KMYcH eqxi/WEmVXj/kcIkj/QD+jpdDOfHheboXsCjoP7AU1cZ/AQ+Uq3asDnBwH5HaKL3SBcB q+VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703060889; x=1703665689; 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=fsZ/9HB6yqurIFZ++8sH/zT31UdGeaTqC79G9+iRJHI=; b=PszdgKdnRaj4tKJg7wq9ENiPvnOKEmc4MU7uypeJUTl2gDVsxkNi08h3QHpn1oH7fV BNyVbTQFznwbkf/XRkcBFdOlQWQ1svZVcBlHPX86SyoCMV67/nz6XtTW+WpgcVGZX5v5 hFpppd/7FlR1U9lDUgLVO8KwDykBelssHoN6ocDwk/X5rT5XMe81NauTBrUqArLWPpe2 ODs7M1s9/K2eCi5E2tQ8PVhkT48/xzWi0j4CT4AJ9vxKcyjIfTy7NK0TQkRhMYItMJjI jFsJm3ofz7XFFEQ5F/JCg+MsEjwjaTzkB09NtSYJpoUvEjpnJJV+fOSRWvT8BFneudcI vyBg== X-Gm-Message-State: AOJu0YyzLWv1tPS+O6UNHkRvb5hlnYqHTfAog6+HmUXGTygwk1D3z3vc Vy1smeOP+VOajEM+sFZkAxrdgA== X-Received: by 2002:a17:906:2085:b0:a1b:714f:c59d with SMTP id 5-20020a170906208500b00a1b714fc59dmr9868165ejq.30.1703060889101; Wed, 20 Dec 2023 00:28:09 -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 s20-20020a170906bc5400b00a26965e4caesm334778ejv.43.2023.12.20.00.28.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 00:28:08 -0800 (PST) From: Naresh Solanki To: Peter Rosin Cc: Patrick Rudolph , Naresh Solanki , Andi Shyti , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RESEND PATCH v5 2/2] i2c: muxes: pca954x: Enable features on MAX7357 Date: Wed, 20 Dec 2023 13:58:02 +0530 Message-ID: <20231220082803.345153-2-naresh.solanki@9elements.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231220082803.345153-1-naresh.solanki@9elements.com> References: <20231220082803.345153-1-naresh.solanki@9elements.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Andi Shyti --- 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