From patchwork Wed May 29 09:17:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Curutchet X-Patchwork-Id: 800362 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 7566E169AD1; Wed, 29 May 2024 09:17:51 +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=1716974273; cv=none; b=gKktC9yotmd1o+hoOTI9AnZf+KUhexKBR8JiLDK5L+ZqJl59MUqR6tRY3u/9m95t8ZqF0xWVbKMxF0TGWBOsBTB2s+Lz/39rHMMygjm3GHsENu5bdS//PMq4jFz+Mjd6murTRKC72Yf/D39xelE5fosOrESuqDsjxtfOgeYG2SA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716974273; c=relaxed/simple; bh=l2cYH5DO9BxfSbaKKQ7q+5RKiD4WnwLONqPtXAYMNsI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=my5cji6GKCrxuc3TtnvxvkOOB+tUEeMqHBXY/8Fmj/leQng7no2js9MNpjPiItZOMWIeyNonVKuLeL8AtbPFqXOsRWQRiUpMKFE8MYa7IMAjP5wLbPy9+N4mNKiPsaqH+zel+BPCS4cYR1CuS3FdGXYZnKL3OIlW3Q7v1z6zPoQ= 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=Ufpv6dxm; 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="Ufpv6dxm" Received: by mail.gandi.net (Postfix) with ESMTPA id 2492C40002; Wed, 29 May 2024 09:17:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1716974263; 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=F+Uj9V8vQpSPX6d1BoZ2cs5q7owsR97LnfY1SKzEsDs=; b=Ufpv6dxma+VCHd8mqMdUizaOu0z8teZYax62fxwy0HYRdbmZr0GfZC41HuJSNSq9xG4+Qf CH6a4lIpRbFrD5knztVwqBVpv3D44jvzAb69SMB/Ucm21Yi0s6kmzBMqDckPy5kwK0aE2O NKeE2E7LG63r+iaLzkERzXolnf5zFSGea+1APzCfBkpD6BdcvzEynhFbLDb9fg++9cIxtc 07i9mkagUn2sMQ5489YE33UjCvBH+NXR86GZB9OjtV/EveAnR9jZrZ1Au5h4CxwZM+qxgC xlKHwCYGr5YYIVRhuvK5HFPrlz7TCFMFePvLCkCkM1TSqwfh8TWBq4WWv+fkXA== 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 v2 1/3] dt-bindings: i2c: gpio: Add 'transition-delay-us' property Date: Wed, 29 May 2024 11:17:37 +0200 Message-ID: <20240529091739.10808-2-bastien.curutchet@bootlin.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240529091739.10808-1-bastien.curutchet@bootlin.com> References: <20240529091739.10808-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 'transition-delay-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..20d72c3e1e10 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 + transition-delay-us: + description: Delay to wait before doing any transfer when a new bus gets selected. + allOf: - $ref: i2c-mux.yaml From patchwork Wed May 29 09:17:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Curutchet X-Patchwork-Id: 800084 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 AA5D216A362; Wed, 29 May 2024 09:17:52 +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=1716974274; cv=none; b=N49iojq47qYQEN6vQH7f5RGy1lfNMTZJfpbtT1h1TJ5O/cFAU3Zs/8RwcrkwCNGdjunT1ttcOab5N/GT7NZHLDVjzE8A96/1iePz1Mk5OnYmMyedGlPXMrn8AEAGeZz2KBcOJ9h/7CycPs4tlTYkHCX6ppi7QDoWiye72xjB044= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716974274; c=relaxed/simple; bh=8Q8bUe5t7Cc3xBL4MsSFOl/19C3f3eghMC1wwMxip+U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BUj0PkbzyQArUaqkL3WtRCTDDvZtbJbvJE/tLNWng24EEUlIHS9AczC0P4NZIHNAykP+V/1pem4Qb4aBjcLgxB0JxjOMBPemaifCoflFdWSC67vxAgN47vaOERKaCuZ+X6GeFpAKjDSQ4gKDfojN1v5g96jR+PweO4qkdsPYWOA= 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=Ag7y8wJu; 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="Ag7y8wJu" Received: by mail.gandi.net (Postfix) with ESMTPA id 644A540008; Wed, 29 May 2024 09:17:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1716974265; 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=0ltCzBYQuXG2u5FgNITnslerb1IuiczmEUWFQZ/f86s=; b=Ag7y8wJuduiSMmSRM2ZYkpkhP1tQiRS9laxVzjhQxs0hLTa9rMcbioOHahTcK+r0K2yfI/ N5Pn55ivrT8LeZM1izPRQAtHAz/4WQwdX6xLFF6qrIFdDxWkrNC/0ME/125LhLlPUaA5XV 9MTH2v+PVVD1VO3eQGuWlqVRUlt7QtVQfpFzFxCaQORQea8NAVbR3+PHwsNtwpSOKMna2G cqPNEyLv8UbWGaqLbTOGW9vrMwg2QJQREkzWDrkoR3vSNqW4PG+nVgXpktq9lGuf///Gbr 3pioFx3LhqJk7VJNieNya41esHfq9EQHpKlJP4szkMUgDTckJoE2iCzztEBvYQ== 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 v2 2/3] i2c: mux: gpio: Re-order #include to match alphabetic order Date: Wed, 29 May 2024 11:17:38 +0200 Message-ID: <20240529091739.10808-3-bastien.curutchet@bootlin.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240529091739.10808-1-bastien.curutchet@bootlin.com> References: <20240529091739.10808-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 The #includes don't match alphabetic order. Re-order #includes to match the alphabetic order before adding a new one. Signed-off-by: Bastien Curutchet --- drivers/i2c/muxes/i2c-mux-gpio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c index d6bbb8b68333..c61e9d9ea695 100644 --- a/drivers/i2c/muxes/i2c-mux-gpio.c +++ b/drivers/i2c/muxes/i2c-mux-gpio.c @@ -5,16 +5,16 @@ * Peter Korsgaard */ +#include +#include +#include #include #include +#include #include #include #include -#include #include -#include -#include -#include struct gpiomux { struct i2c_mux_gpio_platform_data data; From patchwork Wed May 29 09:17:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Curutchet X-Patchwork-Id: 800361 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 7EDFD16A375; Wed, 29 May 2024 09:17:53 +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=1716974275; cv=none; b=jzDvHMKmJwQDatC+GOCUmzYzlcCr3P0IbcdugnXv4Vm2bT9RYetYz2YCoIqzeEB/4N9n7BSyA0aiD6h9IT5fPmz3IfjQ74k9Ft7oDgwNbKcVXJdAegXnar4/Y5YLQC0J2kTzfC/dWVGUTEP/vzKYAyWv6yK6ZC+FrPoLB2+ybdg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716974275; c=relaxed/simple; bh=rAquyJjGl8AvRSJGDILkpKhh6ptv3dUO3G5M0U8rfq4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z5+maAOZGZl46JWZclXq75OTkL10LVPByac2XVAMsSatWBDxKGdxdoGIzthf2p8S2O1gZldLTVyyoNezoDXB4Ey6rjFeipXLfj1/N4g/drqM2OuAJakRVz/hdL+KHqYQ0GYA6L8rQvVbJtjQlpN5C0MKrPUlDd1EPlrVkky3rtI= 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=H0r7cZOl; 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="H0r7cZOl" Received: by mail.gandi.net (Postfix) with ESMTPA id C6BE740009; Wed, 29 May 2024 09:17:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1716974266; 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=avFH+TZR+wV/3lFdLJG11Lahbf9QsDr/KQUzB649vpc=; b=H0r7cZOlg4xUHgNF6KRBu97q0RWPV3zMDpjmjiulr6EXDEx6COUcc3lg9xIFuVgh2VSavM gmc8kRdvwLGhIuv2r3BIjci74MoiNRvmyaHCT4Vb3thdGVp8ZxfjJMJaAFEPMmAVa87/3q e2icDhz1jZ/B+C1kUeJZk+C1SMksPhIIs5ZcRJvLoCs2jJsNqX9eSLZi77E1ZhBNfNekhR G9wmNVj5Onn+u6wxN/yx+mdNd64sPFiAKkwmkE9gsFBhZ/nAJzOCfGcMkTJ7vHqZgAjYz0 ucQHGCC1flZTO6ft8JxV3hgffAu4ruTLIIy0uwLJ47b2crTb6QfquWIywBlyfw== 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 v2 3/3] i2c: mux: gpio: Add support for the 'transition-delay-us' property Date: Wed, 29 May 2024 11:17:39 +0200 Message-ID: <20240529091739.10808-4-bastien.curutchet@bootlin.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240529091739.10808-1-bastien.curutchet@bootlin.com> References: <20240529091739.10808-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 'transition-delay-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..b9cfc80660e2 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.transition_delay) + udelay(mux->data.transition_delay); + 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, "transition-delay-us", &mux->data.transition_delay); + return 0; } diff --git a/include/linux/platform_data/i2c-mux-gpio.h b/include/linux/platform_data/i2c-mux-gpio.h index 816a4cd3ccb5..c449f714d32b 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 + * @transition_delay: 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 transition_delay; }; #endif /* _LINUX_I2C_MUX_GPIO_H */