From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 26A636774C for ; Tue, 30 Jan 2024 12:19:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706617163; cv=none; b=pDMnw6eHPacky6WaiM41iZ62LxPE4CqF2CTftnA7O4XM0piojniWuYDXX6WLn7l+aUM4wOPg+Nr0BpLAH+bY/c8O1NdjsCEMbSe4X66ePoAmwYinC3KxXnzs3D3UWULWVLdPnon9zd49LydChWfaSWOj51XnrMBYjA8yxXb/Xgo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706617163; c=relaxed/simple; bh=7+q8GPfVwFO7bpxSjP9H+90yU5XY210jEE+Z+p/ICSw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N5Pv0ijVWLLQWtbu0CyxySKh7GRT6ceyQBNGQb5iv7MGh5o2fhf+nLDxN/YOWNMD8SoAPEcBVc/kQcAK7jvYa1yqj8Iu0bXi3UQuhbfjkUVct+2+7zGYWXRzB6OVEuy4gKhMtbh0o+TvNneyhDqdwkjsMKmedscQ+Cq9PPWU8YE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=9elements.com; spf=pass smtp.mailfrom=9elements.com; dkim=pass (2048-bit key) header.d=9elements.com header.i=@9elements.com header.b=L18Fpe3M; arc=none smtp.client-ip=209.85.221.43 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=9elements.com header.i=@9elements.com header.b="L18Fpe3M" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-3394bec856fso2797884f8f.0 for ; Tue, 30 Jan 2024 04:19:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1706617160; x=1707221960; 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=PLC7OQwXNA+weg5GGKNWBcjnhtbq7adOLjbHLyswK3A=; b=L18Fpe3MQQAljD/IvY9uhCEAHEp8gJzchJ80wWiLlzLLd8/5hVcd75Ue9/kYZqNb37 fHYyYE/r1W6nwE4gJQ2S5mHrnn4e0/9p4RGZoUcbxIpJqc2D7TZmmxUjltlEuWZnsVfg fYOKAD3oW7uOLAYGwDzeGgPdAPjUjUPLcS77/Di6QIWu3/i4VSG8lM/Xn+Y9bB7ZeFDR hMuvA0siktypJgCNj+ovVN9fBrEp6UBpcVWewlutoVj7XJPav0ZnFujmyik8My8+TYgd S56/lrPO3qtP9eIQlAh+XI6ly/fzBHC4zeukMxCT0NDWzx7Aqr409nYJUDoreC7/693o 1PYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706617160; x=1707221960; 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=PLC7OQwXNA+weg5GGKNWBcjnhtbq7adOLjbHLyswK3A=; b=mXGQtnO5AjiRwp84DupQU2/vsCapZGmB5xVQhBv7s1mYly8BBCcr21g0RSRGMLYHgW GRKer0wIQnR+DlCuD5RNiKmYe8U5qy7DjYtc/rMbHZPef0IvnZZ3cTHyQAZ0ysHCHV8F APpr+9s50QpX32Jtt57TuycPjIk5VCs0tvIhn0M66RC1zoe0KVXGNL5ATDWV/uJvjhpX VTpc9fanV8+plrtFCe3r3CuP8vqudbLxGHDMkrswkhkwsuHNM8VsInEsOvMs7YLzNWN+ 6Y4eCue64d6e3/QH4hO8OnjsOH5dfQwY1un6fi2vwDXKAtjKjcoeof7c+IFZz1OHgQ19 ktew== X-Gm-Message-State: AOJu0Yzq11Husg5oVjDVksM49+RcAmVgE8TauS+4FN3He6gWnipKtL7J yjrRvyOuIKijTTSIwqEEgPekdu6whDo0gsX5GZ8gQ5c2kbLHEw6SMr/dz94UoW0= X-Google-Smtp-Source: AGHT+IGPDHT5czbJRotrJkVVDimObm4QYo+5LSvJK1xwx6ODiopc4gwaOYkJ3u+SCSYsdlTDlm1a6w== X-Received: by 2002:adf:e701:0:b0:33a:f48d:1a16 with SMTP id c1-20020adfe701000000b0033af48d1a16mr1235916wrm.22.1706617160310; Tue, 30 Jan 2024 04:19:20 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUYKxQzOIuGPD0ZgoGUJkRTt/8/ALVHo1tzgL/IzKEFEpR0cA3UL9H0J3I9C0wXV54kFleZQBansmTGsN4eGH1AK2y8XP7I6MIkGBankPy5soC19//DhfjUTTRwopC5lW2GZl0teIRxpGbS3ztsRPcDNvUCHI7PTzBO8CQIfVT3z6icwdLR8xJCr0HdI8+6soTy9qn1EvsctmQuelPd+QO6vC9avw== 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 n21-20020a05600c4f9500b0040efb503d58sm4049446wmq.28.2024.01.30.04.19.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 04:19:19 -0800 (PST) From: Naresh Solanki To: Peter Rosin Cc: mazziesaccount@gmail.com, 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, 30 Jan 2024 17:49:01 +0530 Message-ID: <20240130121902.462619-2-naresh.solanki@9elements.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240130121902.462619-1-naresh.solanki@9elements.com> References: <20240130121902.462619-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 --- 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.42.0