From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (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 1EA68299922 for ; Mon, 23 Feb 2026 14:33:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771857230; cv=none; b=nI7bb8BT3OoGUiDfDpkwMk0RMZFpi5RBIW6tn3BZHVo4NNf6EimaZXvJAB22BHDQGVfzHTMyY5lC1V2DpBrGCiM2IG6VrE51ae2bJ+D2PCxptp0pWlrgpJrJkQcKvQykPeBf73v5J5Q/AVwixjkpUdHIskTSYAih7EvF1jf+aL0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771857230; c=relaxed/simple; bh=mCCRKMHtlBgmqWNXcSQwKAWkgQ/vQ+w7dOXdt7vYJB4=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=cc+uIIOoro8kmGZVX+cMMTKPLgG3z8qt5aXfJQ7JNSoSvlXthr16eK4goH01s57aVTSX4moh3vbm613+/QsZR8413tbPM4UCaGFZZvJ+0JQEV7DoAaoRqMihXX6LDyHRyBGwdIvVJDuHaJ95QRb0b2t/uQmp9YmauYXKIoP49e4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HB+cNXjN; arc=none smtp.client-ip=209.85.167.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HB+cNXjN" Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-59e5ea93a1aso3563429e87.1 for ; Mon, 23 Feb 2026 06:33:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771857227; x=1772462027; darn=vger.kernel.org; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:from:to:cc:subject:date:message-id:reply-to; bh=pe8kS/HsQYwBP5zgL7z8pBoY1N27zjF7IHjDKICG/rE=; b=HB+cNXjN6X+Ld8NbDjZC/Vxqiq1gKrF5cSD4somfwRGOepS+xGkDysnMcrPUkBXtPo WINi1MOwBgF5vwJF0dvPVurbX9Xe+Y6W/UgdMwuVBfnWBsqbyGjFcPo8lASrGe5o4yIM d3B25hX7n7Q/rOyBmK1hWgiuv11RrU4gCR8vt4n3OGURTcPJ3mOYOKJi/gsnKYftIS8b m0ErmSb+ZreeAFCj9PJj+5b8Py+gAi3lS6jC8FRRCPGWEUhP1NXvRHp4GpZFuIILDVJE pVYhDpvIGRhTljtPtqgRd6MuP78SG+C/JT+R/+ZNNIrATRCXQiDEdzfMLIOmE6mHCG08 vG0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771857227; x=1772462027; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=pe8kS/HsQYwBP5zgL7z8pBoY1N27zjF7IHjDKICG/rE=; b=Vc2qFuJpNpxP9vimzL4tepilCKJ/ARYmD4PB+y/JFOa0OdALHU6P5u1gvowElZ6Nh5 HC1t4OJvuqKifbCLWpWf+DwakKQyWbNEpfrwlDYYBQxWQIS8Df7D0Nd5nDVe6l5UGVM2 7AHoAzGVBkrFCHfJMvdb8I3DC1Ur6iQSBTXG1jyEhU/SrOZ93hKVUWszjMfSI4meP/Yc heFI47AaOR8dae/X+y82txArS6B14pQjHgGzoub4KHuvHfPfHgtq4GEX6iCKSFuj0yt5 y5mqKMvUO3FG98sXfJsq2Bkr99vb2nDXLuYu1R0mRFuc+UPD6CvLWW8Ud4Gu5UKr6rHO wLEg== X-Forwarded-Encrypted: i=1; AJvYcCWhXwSguzdTRGN0c2dpq7hSCb6AKCjf7X6MCaqZ1UliCWTSaZAO8x6R28oh9ASwZn9qs+efiOWzIc/0FTk=@vger.kernel.org X-Gm-Message-State: AOJu0Yxh2dJHH3tZLxovxD6ai1qR6F50fcErpuBsphMZN6+T0JU3d3Ei ElSVv/5wcywwh8KVvC5BkTkH+E1/e/hj4SpwwkeOALkTMnNK4bePZ2IS X-Gm-Gg: AZuq6aKeOog3KRGMdFZDld/WFTOPVpx1UMH/hdw/e5Upvi8hxtaOwi9TFg7r6WsbR3S gpQEcH40gmFdnNq8PlZf/aiwuixIluuMmW6Z31QjNiD2DCLXFijjyHHBWW7WSfdWfJzUyTW0gav 0V9MVeGB1HLZhpSAdtAp7mpQQxSKpE2gDtvPa/CPRNayekus+txPVApBFlyu5Woc2NCA9k1az46 hUjEFLGOEK4ejoUjZQg6C7pqzpaJNDg2qw60C8Eu1e1VRAv1NqfDUQQ/0EJV/wrvw0BtpghFppv XbAbk6m2eSWDPD6aPib/7hKZ15H0mxCLW1Hjp7baEm99Cp8lU2Aj9MolPCvNJ9XXZRC7iXk6rw/ Am75/Z+jCN97h744C3ziyfcsuoTtNrtHnRfTKQsKZ7TuOqwsi6oKFTK0ysaL2L89UOFrXOaGpG9 V6Wm4mftIFpEynduzAtnZo1JZJdqogDC+YY8MVCQNil1//KkTk6M1jik3qyHW8P77frlgi X-Received: by 2002:a05:6512:130b:b0:5a0:f5b0:401 with SMTP id 2adb3069b0e04-5a0f5b00a51mr671916e87.27.1771857226970; Mon, 23 Feb 2026 06:33:46 -0800 (PST) Received: from [192.168.1.135] (83-233-6-197.cust.bredband2.com. [83.233.6.197]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5a0eeb16344sm1631709e87.37.2026.02.23.06.33.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 06:33:46 -0800 (PST) From: Marcus Folkesson Subject: [PATCH v7 0/5] I2C Mux per channel bus speed Date: Mon, 23 Feb 2026 15:33:49 +0100 Message-Id: <20260223-i2c-mux-v7-0-ec75b214718a@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAAAAAAAC/2XQTW7DIBAF4KtErEs1DD+GrnqPqgszjBOkOo7sF qWKfPfiqI3dZPkQ3+OJi5h4zDyJl91FjFzylIdjDc3TTtChPe5Z5lSzQEALQWmZkWT/dZYRwOn E2LJJot4+jdzl87Xp7b3mQ54+h/H7WlzUcvrbgXjrKEqCRE/BtE5B0PC679v88UxDL5aOgjenA DYOq4sueOsMpWDdvdMbh7A6XV0A35Klrg7R9878OQcK/epMdYnZBGJsHD3stKvDzR8VW10XkWI XQhPiw3tu69zq3LIzMnqmLjX8z83z/AObzOzptgEAAA== X-Change-ID: 20250913-i2c-mux-b0063de2ae4d To: Wolfram Sang , Peter Rosin , Michael Hennerich , Bartosz Golaszewski , Andi Shyti , Andy Shevchenko , Bartosz Golaszewski Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Marcus Folkesson , Bartosz Golaszewski X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=4457; i=marcus.folkesson@gmail.com; h=from:subject:message-id; bh=mCCRKMHtlBgmqWNXcSQwKAWkgQ/vQ+w7dOXdt7vYJB4=; b=owEBbQKS/ZANAwAKAYiATm9ZXVIyAcsmYgBpnGVPQ0nZwdk3uxE+uw/9EflWtmk7bBklAPLD3 2yZUWYqF2uJAjMEAAEKAB0WIQQFUaLotmy1TWTBLGWIgE5vWV1SMgUCaZxlTwAKCRCIgE5vWV1S MkDxD/9ochrRo0neboyepOM6GpwWUs/3INBmv+86oHhHBoyycSsEOmJHQjpHvkPyKeiJc5P6OZb 76WLe20FxmuQJ37JoIYfHcnOxoltRG7IyVpx2BRnUtwYP9kXJVzgduQQk5nXyhbMJA7N4/Kpi4F wPyhFWmEimO4g4cvrscjnGScievyf3+7lcCXMDOTM/TUHMvSy1y2wjjHi3U5hgkWux4+Ts/uL6F koMnjJMVjKzr/AFKQiRwysFFJ9oeUIzsCiBhWjbfgj8oIKlzR5+8/CBAMPLQaNPEni17ARunbXO RpRzmq7xT9K7JVWX89bof4ruCS89j/PlzvMjgSZV+6/HdeZjs1r8oD73Mt1Tni7eTjX8tstr6om m2uXlu+XU0jRzUbk9SKa4lzvz1TmPmUHuCcMoQG1ZfCejzH6xN+6NXHXSCWYuRCyrIvrM/E7Otr KRnuuEjG30uDBwhURdVyeXerpR/sT0tzXeV/GuaYZszAcPAvdEP2msfnYYS8hU3pOI2YrhoLdRY CgeM1NWQLB9Bxixkpbh9ZRIZsuqJgD30PBqwaWqgt6hedZ1HgRFN5ZAaP5o6VqaAKxtP6JgTxpj 9RLUt5o0SFCpCUVIpKyxhHMoVeT66eFcQYi7GDFpXoY4JAaIm/K86t3QtQSqaG+i4aM3Na5u7JC P5chRZjJ3Xn1edw== X-Developer-Key: i=marcus.folkesson@gmail.com; a=openpgp; fpr=AB91D46C7E0F6E6FB2AB640EC0FE25D598F6C127 This was a RFC on how to implement a feature to have different bus speeds on different channels with an I2C multiplexer/switch. As no major complaints on the design came up during the review, I decided to submit the series without the RFC tag. The benefit with this feature is that you may group devices after the fastest bus speed they can handle. A real-world example is that you could have e.g. a display running @400kHz and a smart battery running @100kHz using the same I2C controller. There are many corner cases where this may cause a problem for some hardware topologies. I've tried to describe those I could think of in the documentation, see Patch #5. E.g. one risk is that if the mux driver does not disconnect channels when Idle, this may cause a higher frequency to "leak" through to devices that are supposed to run at lower bus speed. This is not only a "problem" for changing bus speed but could also be an issue for potential address conflicts. This patchset has been used and tested heavily the last months on a custom board based on a da850 (DaVinci) platform. The implementation is split up into several patches: Patch #1 Introduce a callback for the i2c controller to set bus speed Patch #2 Introduce functionality to adjust bus speed depending on mux channel. Patch #3 Cleanup i2c-davinci driver a bit to prepare it for set_clk_freq Parch #4 Implement set_clk_freq for the i2c-davinci driver Parch #5 Update documentation with this feature Signed-off-by: Marcus Folkesson --- Changes in v7: - Remove code for finding first mux-locked ancestor - Introduce a unlocked (i2c_adapter_set_clk_freq) and unlocked (__i2c_adapter_set_clk_freq) variant - Let the locking be handled in __i2c_adapter_set_clk_freq - Use I2C_MAX_STANDARD_MODE_FREQ instead of magic numbers where appropriate - Link to v6: https://lore.kernel.org/r/20260216-i2c-mux-v6-0-9be28ecfd7e3@gmail.com Changes in v6: - Change logic to find which ancestor to lock with I2C_LOCK_ROOT_ADAPTER It now find the first mux-locked ancestor and then lock its parent. - Remove bus_freq_hz in i2c-davinci and only use clock_hz instead - Mention in commit message that clock_hz can be used to store frequency in an uniform way - Swap order for change freq/deselect to keep symmetry - Only allow bus frequency to be lowered in select() This to not allow an intermediate frequency to be set when it is not supposed to - check if(ret) instead of ret(<0) where appropriate - Fix typos in documentation - Change i2c_adapter.clock_hz from int to u32 - Simplify i2c_adapter_set_clk_freq() by removing 'ret' - Link to v5: https://lore.kernel.org/r/20260213-i2c-mux-v5-0-fb2cbf9979b3@gmail.com Changes in v5: - Take the lock of the top-most mutex locked mux to make sure that the root is locked - Link to v4: https://lore.kernel.org/r/20260128-i2c-mux-v4-0-dee49ce276c0@gmail.com Changes in v4: - Rebase on master - Swap order for printing warning about "channel %u is slower than parent on a non parent-locked mux\n" - Fix typo in comment, adaper->adapter - Link to v3: https://lore.kernel.org/r/20251020-i2c-mux-v3-0-908ac5cf9223@gmail.com Changes in v3: - Return -EINVAL if channel is faster than parent (kernel test robot) - Link to v2: https://lore.kernel.org/r/20251002-i2c-mux-v2-0-b698564cd956@gmail.com Changes in v2: - Changed bus_freq field to bus_freq_hz in davinci_i2c_dev (Bartosz Golaszewski) - Removed idle_state from mux core (Peter Rosin) - Link to v1: https://lore.kernel.org/r/20250922-i2c-mux-v1-0-28c94a610930@gmail.com --- Marcus Folkesson (5): i2c: core: add callback to change bus frequency i2c: mux: add support for per channel bus frequency i2c: davinci: calculate bus freq from Hz instead of kHz i2c: davinci: add support for setting bus frequency docs: i2c: i2c-topology: add section about bus speed Documentation/i2c/i2c-topology.rst | 178 +++++++++++++++++++++++++++++++++++++ drivers/i2c/busses/i2c-davinci.c | 42 ++++++--- drivers/i2c/i2c-mux.c | 107 +++++++++++++++++++--- include/linux/i2c.h | 34 +++++++ 4 files changed, 338 insertions(+), 23 deletions(-) --- base-commit: 1f97d9dcf53649c41c33227b345a36902cbb08ad change-id: 20250913-i2c-mux-b0063de2ae4d Best regards, -- Marcus Folkesson