From patchwork Mon Jun 17 12:08:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Curutchet X-Patchwork-Id: 805017 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50307194AF1; Mon, 17 Jun 2024 12:08:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718626106; cv=none; b=VXWEwF4dN6m/DrsGNC9vAQIbrf5/TbhwC9OO3ts3zvWFNiRMFan5JIZbSGyAnpMt949dOup5/Lwqj28yFScx//e+qiM79/lm2UfeB5yvx5nANHvHe+sGk/X+Zgfq2XXcfVEcakwdeyHFB2WRP+wp0L0JT4rqMzr4RFjoUMEjpgg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718626106; c=relaxed/simple; bh=UY1Iw0rvqx5zQz63sj8jJEEYKZwoD3UQTi+vP8BO7SA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jP05rBHHtIHSXUSeMsoAz8vqbZR7Knka1n6bjublESDMvg6S/qkY1f/MPIXyhVg+18xoHV+ZvhbFBHT2WqUMCRannxESh6AFscn+HhvVPpIdX399HToFZsc9kdwIV3zcfUf70ef0/lPzOLVdrv7NA9IiBDFrxhdAAUvsdcQB2ek= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=aLWYx4Wz; arc=none smtp.client-ip=217.70.183.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="aLWYx4Wz" Received: by mail.gandi.net (Postfix) with ESMTPA id 23D354000D; Mon, 17 Jun 2024 12:08:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1718626102; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YLinVnUNOZtit/gGceqUFqQVwx/hRti2F9+Kbo6Qvmc=; b=aLWYx4Wzpmvk5RDQ2pljHQl5ku2JtkydyRQtx7Rxtx7Z+0t9P7r77x70RaygiFsfgk5s0+ AsRTramofkMR9BrIeKwCw+jk0B5a3LOjWomGpkCn1bzl2+/YBaP+Nrc6YkJual2uJjl3gk CsYU6s9+HSxuN0nQ/9+t+vQLrWvwpH48zNH9lLPrdUiiA5v870Cj7YMpJ0E1pE36VYDUWJ i7dTfB/+CdaB4icQmSxBwo+8TfrlPoH3NQLLqJ2wZVDdy7ca7Mz7Nq9Oa+lCMrsxCq/lhg e1EKXi5w5awYuTWoZFcSd171yaMfPRTZSFuNGx4Js6iCfH7GIgWxWREDt3F9wA== From: Bastien Curutchet To: Peter Rosin , Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Peter Korsgaard , Wolfram Sang Cc: linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Petazzoni , Herve Codina , Christopher Cordahi , Bastien Curutchet Subject: [PATCH v3 1/3] dt-bindings: i2c: gpio: Add 'settle-time-us' property Date: Mon, 17 Jun 2024 14:08:16 +0200 Message-ID: <20240617120818.81237-2-bastien.curutchet@bootlin.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240617120818.81237-1-bastien.curutchet@bootlin.com> References: <20240617120818.81237-1-bastien.curutchet@bootlin.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: bastien.curutchet@bootlin.com I2C MUXes described by the i2c-gpio-mux sometimes need a significant amount of time to switch from a bus to another. When a new bus is selected, the first I2C transfer can fail if it occurs too early. There is no way to describe this transition delay that has to be waited before starting the first I2C transfer. Add a 'settle-time-us' property that indicates the delay to be respected before doing the first i2c transfer. Signed-off-by: Bastien Curutchet --- Documentation/devicetree/bindings/i2c/i2c-mux-gpio.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/i2c/i2c-mux-gpio.yaml b/Documentation/devicetree/bindings/i2c/i2c-mux-gpio.yaml index f34cc7ad5a00..4a93d1f78f93 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-mux-gpio.yaml +++ b/Documentation/devicetree/bindings/i2c/i2c-mux-gpio.yaml @@ -57,6 +57,9 @@ properties: last value used. $ref: /schemas/types.yaml#/definitions/uint32 + settle-time-us: + description: Delay to wait before doing any transfer when a new bus gets selected. + allOf: - $ref: i2c-mux.yaml From patchwork Mon Jun 17 12:08:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Curutchet X-Patchwork-Id: 805016 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3FEF91953A4; Mon, 17 Jun 2024 12:08:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718626109; cv=none; b=hY0yV1i8Y0uy0K4yuJFn4dUgHispBHSfs/4jgeOkbSU0b9gFtjJZT4qz62XPLr0+fv5YjVmNncMN3BmW2AQagmFcH0j5NifHYL/RdgnMIzW6z+S+5WBnbnCMLVSFu0tPfJLTaC9TK5brWnk9TlzAIFTos5tDTpYL509SwTJx/Fo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718626109; c=relaxed/simple; bh=TfKKBv8AFhA+vH8mhW8s7HZ2r28DhWriurHkhv7w9+o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bGaRq/uHDrlvaQXI8EyXauYxOCH+4C4cIdYNbBoFw3z4YiaTRu5RT6FMXqmUEgw1WBX/fi5Ke/HhzvmdRYc+BPpculzZUVTSoXRi+DlH2upMoUfmw56jPHK9vDyxM3krK4pamt7GzzIxbD0un2ewwVsu/HmxUvOSXg2bOw7J8tA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=p3i7z+U3; arc=none smtp.client-ip=217.70.183.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="p3i7z+U3" Received: by mail.gandi.net (Postfix) with ESMTPA id 0123B40009; Mon, 17 Jun 2024 12:08:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1718626105; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2bbFLl2ripxc9Dqv54mu21YE1HBXoGgxRaBaWn9NKxQ=; b=p3i7z+U3yCQnjYykDY+5OanbA4Bkc++6/CmQ5ttudqGf6fHxaaxptox5joY7/rzFj+JERP ThK2G9nJlrLzc85+e0aOTNZGUiSjrS0keA/9hAZWMIFuywrdzKOIye4miuyswWmphWfmor LiUZ3rUz+Wa5Rezf1TeHuHmd0JNHkTJOv0VjmXYaXrhWPI5JwQLj3n4TpfIyK0OrFjxctF kf6NFyHg/0vLv53mmSwreL6LRu2eY+LP0zj9CbkW7zi0sgNiM3Kue4aBD5MiGsItXJ11ej k/tO9ZQAkkxGoow+p2GRrOibHVFmTCOxUu+bL0ng1w0hVHk1lCRuEoK1ufyxmQ== From: Bastien Curutchet To: Peter Rosin , Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Peter Korsgaard , Wolfram Sang Cc: linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Petazzoni , Herve Codina , Christopher Cordahi , Bastien Curutchet Subject: [PATCH v3 3/3] i2c: mux: gpio: Add support for the 'settle-time-us' property Date: Mon, 17 Jun 2024 14:08:18 +0200 Message-ID: <20240617120818.81237-4-bastien.curutchet@bootlin.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240617120818.81237-1-bastien.curutchet@bootlin.com> References: <20240617120818.81237-1-bastien.curutchet@bootlin.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: bastien.curutchet@bootlin.com Some hardware need some time to switch from a bus to another. This can cause the first transfers following the selection of a bus to fail. There is no way to configure this kind of waiting time in the driver. Add support for the 'settle-time-us' device-tree property. When set, the i2c_mux_gpio_select() applies a delay before returning, leaving enough time to the hardware to switch to the new bus. Signed-off-by: Bastien Curutchet --- drivers/i2c/muxes/i2c-mux-gpio.c | 6 ++++++ include/linux/platform_data/i2c-mux-gpio.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c index c61e9d9ea695..944577bb09c1 100644 --- a/drivers/i2c/muxes/i2c-mux-gpio.c +++ b/drivers/i2c/muxes/i2c-mux-gpio.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -37,6 +38,9 @@ static int i2c_mux_gpio_select(struct i2c_mux_core *muxc, u32 chan) i2c_mux_gpio_set(mux, chan); + if (mux->data.settle_time) + fsleep(mux->data.settle_time); + return 0; } @@ -116,6 +120,8 @@ static int i2c_mux_gpio_probe_fw(struct gpiomux *mux, if (device_property_read_u32(dev, "idle-state", &mux->data.idle)) mux->data.idle = I2C_MUX_GPIO_NO_IDLE; + device_property_read_u32(dev, "settle-time-us", &mux->data.settle_time); + return 0; } diff --git a/include/linux/platform_data/i2c-mux-gpio.h b/include/linux/platform_data/i2c-mux-gpio.h index 816a4cd3ccb5..b548588aa1f2 100644 --- a/include/linux/platform_data/i2c-mux-gpio.h +++ b/include/linux/platform_data/i2c-mux-gpio.h @@ -19,6 +19,7 @@ * position * @n_values: Number of multiplexer positions (busses to instantiate) * @idle: Bitmask to write to MUX when idle or GPIO_I2CMUX_NO_IDLE if not used + * @settle_time: Delay to wait when a new bus is selected */ struct i2c_mux_gpio_platform_data { int parent; @@ -26,6 +27,7 @@ struct i2c_mux_gpio_platform_data { const unsigned *values; int n_values; unsigned idle; + int settle_time; }; #endif /* _LINUX_I2C_MUX_GPIO_H */