Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796035043; b=OzvTKDgA8nDsSx8Qye0slE8IFI0k0ofXWpvGlfONJ+Y0JYkhXJnEQMq9/36/i8byzyEr ktKvhQDzROrI1WEl6zvyGn6YtEHuNyACc6sCc8hU3I6E+VKW0jTJgM8FACBHtcmtcp82o 4nwlkAivReqLD5F5JzVPyGH+UKiE08IUCsedhgkr99HOf7B1OjZUef4TVV0YuR9knW1OP Se9XQu6whSmT+ta66eqRBmhlWws/y1ympnxgQo8nx00cK7cBjf/Xx26+iaVYl3u/qOR13 D8ujEXY2MXX+oa/unIQx9EBg8wly+b+vzEvLhL/DCzrH/Oo/gjL19fQJTKH49Xkk6VA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796035043; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:From:Date: Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer:X-Authority-Analysis: X-Proofpoint-ORIG-GUID:X-Proofpoint-GUID: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-Spam-Info: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=zIAwCxt7MbLQ0OShnaMC/+FYwaOfw3/hRITBRgP+/p0=; b=iDnaCOZ7y2bSO+hhUeJqJMs1twp+lyDwsWarZuILqznNkq++HvPDjiRnf6Z/pWrP9rnA O1m85Z/qV2zycHshjX/5G7KKJoL2GnTJbqME+3rJKwtTGwfqctQ/dSDAxh9hzFCBiX0Wi 0qHks/bMIhUS+/ADlEPIldCXZ87pVm/Dq7uFJ74rPyG9mxu3PuvHRqHxocKS7+h1a0O+H UswX0DP9aN2qKJJpqun35l4yZSKRuNXAq8uKZsWvZwVAJJHpxN7+4H2M8LHc3IaF3uJ61 yiZKgoaRKn2Xr4MeDWCtfIP5XY3t65ocanUKbOAjXCBrTCdg9npkuVxwAJ0lmzP1v1Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=Y+2wX97p; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=epVGBxyU; arc=none smtp.remote-ip=205.220.180.131 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82B08606A32A for ; Mon, 30 Nov 2026 10:37:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 82B08606A32A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=Y+2wX97p; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=epVGBxyU Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AU9V9C3367291 for ; Mon, 30 Nov 2026 10:37:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= zIAwCxt7MbLQ0OShnaMC/+FYwaOfw3/hRITBRgP+/p0=; b=Y+2wX97pz4WNlHO9 3LN176iLjvhZ/6X9lsDra5UsmiOWMbHFEPpBrnqorJQzA/HZGlmWaDWdipwCh8IV YgsleUIiwhX1n8gORuZZQnKppcrJ00e/PGb38AmkyxUfSyQdS8YgSVPENxewQZ1J zv6z59LpMxcdqcg8z87uJJwlr158Hs9gV0t4aaT2pXEDALqCI8w6DKMSBSlPg1rA K/GneuiwxGT+rif6W9zI6vdA5mhuQKVZxg9Aaqz4qOHAlpXIPtQWUUQxu0PSoJ8D ozgLj5oJYP6KQ3k3QJw65ghK8h4oSi/gvM39ko587pSjdtYL2P48xhkPbxHBQKRd Irp5/g== Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j90c1snnj-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 30 Nov 2026 10:37:21 +0000 (GMT) Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-934963b2bc0so1756551985a.3 for ; Mon, 30 Nov 2026 02:37:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1796035041; x=1796639841; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=zIAwCxt7MbLQ0OShnaMC/+FYwaOfw3/hRITBRgP+/p0=; b=epVGBxyU7o/uoxSTcJyrCuE179wYTVeHrCdgR6FhCCk6l6jXH9GVovw20+SgATOZEm +UFOdLeVMStToZ2rPyD5wB2jB053q8chIA4aargU37niYZPp1OVvEGCqSmXpR0qVRkck uHlFgnKu1amznP+3TSZ0C6aMDU0+8gyG7oVQZGPqyptuVbQAMXx++0GwvJavM3lvAxZz etEcaTnRs9RkLhGFFFrRDWk1clDUZeoQCKMh8ttvFcMeZtbmB1y5kjUZDo5saIU9cVZX EqdAlrjb8hpXm8bXE4Ze95TWOMqFSZweCNvltbjZ3Jzb7WDc7t9Q1sgDFRMGgETi3/cB 075A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796035041; x=1796639841; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=zIAwCxt7MbLQ0OShnaMC/+FYwaOfw3/hRITBRgP+/p0=; b=wWwdtj8JUfEdSUwCl9X1zFKGefdfIueLdJJ+LuH3/FwlXnXld2LMzmsFrMXBoVcIhN 76BQc1xtXjXat/TC3bzcf9aKyTtV5HUWnTu5jPAHJp/n2+X/MxT7EDwxWcB21VWzJLH4 Zo8P0/mW0Pda3tksRRDLTy8Pg97mvU+IHDyKYEpyJqNgQGAANpg4l81NQywjTetevzK+ ZBffl0cKgm0GjhC/sWwcUpoRBxFz3zUMNwa84N8CgdHVp+XiKZBXE+QZQIDUw1ClmfwL Sr/ooRJOAmyx30kS62txC7mogpTVwbKt/5dQcDSXe5JuJDAq1Ie7DyBBjzcItNmfLDYj uFSA== X-Forwarded-Encrypted: i=1; AL+hErEQCH+hycjHusARG0jBJFoCEDddg4zg3eAXaZXy068JQK03G4i6IE6gcx7r9gfF1qaAVKQP8tPRjLkV2JvC@vger.kernel.org X-Gm-Message-State: APuU4Z/7EIPUOB6ihnzuJgzvWjT6gzG/nSUbWPQOKX9mEljD6Yt7LXb2 FKxVZUrwnuVHfApjwemPK5kOhGDEIM3iW5X7bOXqDfDWBVFAZvbhrFJsDjTcgDQQtdr2gnCjPqA c7KLadU77axTZnFye1LIy2PP2MEePCdpJ2pAPygRvaDRrR0HP/UPeT6+YlBcti/wLYWag X-Gm-Gg: AZFdTZd25W7QVqNYqugko8t5h1HE0wEhsZYx31uwAUO7Gy1Na0OoWqzwIK23s/hPAqH GSrNwspXANgc6BOsJcbZFcCkp3dAhEG229l5+qxSVD4qxIXOwAU97R2rUzSAA/eStE/6wxQcZWZ bEEfaH0KM+uOvI+U5CK5ciYqK2p/bWgWrGOapmed8dNTGhzlyt32zm4lWyxuSaN3Gw9Ywmaw6tm QdBrB3ZT+YKNYpmi+9ddtK6M/mg9P45UHlcR/jVVT8GCHcliBZmXDl1ay/rpnWCt5OKfGA8SYNM Xck7G/QfgD9xT+PBxbh+W68i+h8SUIMyzesiGe31Seb8QUWY+QBpg9v/6HcDbK06nVe6K9PsXkp YXTRM4V3O1UdaCPJmlH4E2tV4vNw8BHcUSjCwyCJ/rezMlEiQe/btBe8uoTAhksEVDkjgM1yje3 Jm3xM4YLX1XoKzQsGmFFhnPlmAr7KzdNhzFBGI8rkIG/tDyf1qnWHXg897GeyOiyujm9qWFYlyw bQfsrh8JSBP9uFtjes9D+60i7Zf X-Received: by 2002:a05:620a:6910:b0:949:ac4e:fad2 with SMTP id af79cd13be357-949bab38112mr5732837385a.51.1796035040746; Mon, 30 Nov 2026 02:37:20 -0800 (PST) X-Received: by 2002:a05:620a:6910:b0:949:ac4e:fad2 with SMTP id af79cd13be357-949bab38112mr5732834985a.51.1796035040292; Mon, 30 Nov 2026 02:37:20 -0800 (PST) Received: from QCOM-eG0v1AUPpu.na.qualcomm.com ([2a01:e0a:830:450:6046:9c83:ea4b:ae9c]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbab390cf5sm486441005e9.7.2026.11.30.02.37.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 02:37:19 -0800 (PST) From: Loic Poulain Date: Mon, 30 Nov 2026 11:37:00 +0100 Subject: [PATCH v5 4/7] i2c: qcom-cci: Add burst write support X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261130-cci-imp-v5-4-d2ac891f2bc6@oss.qualcomm.com> References: <20261130-cci-imp-v5-0-d2ac891f2bc6@oss.qualcomm.com> In-Reply-To: <20261130-cci-imp-v5-0-d2ac891f2bc6@oss.qualcomm.com> To: Robert Foss , Andi Shyti , Konrad Dybcio Cc: linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Loic Poulain X-Mailer: b4 0.14.2 X-Authority-Analysis: v=2.4 cv=R7+WitRX c=1 sm=1 tr=0 ts=6b0d51e1 cx=c_pps a=50t2pK5VMbmlHzFWWp8p/g==:117 a=xqWC_Br6kY4A:10 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=EUspDBNiAAAA:8 a=Yp3SuMTfTe4RQKdpiVsA:9 a=QEXdDO2ut3YA:10 a=IoWCM6iH3mJn3m4BftBB:22 X-Proofpoint-ORIG-GUID: hCdev1M2ScqUSOtTeDAK5OQYpGiyMQmk X-Proofpoint-GUID: hCdev1M2ScqUSOtTeDAK5OQYpGiyMQmk X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTMwMDA0MiBTYWx0ZWRfX+KCqsflqgbYN PMD8q7XCbVogOA5HzAX/f8/4jEBCBqhEVDZleXM4fkUeYinklHKuL52YEsFrAatN5M7TMJ2Jinc pEDWQWtOvLAkjocoOY4IueyI0CbvSYVygNrEvFVk0n3i2hF1e5lAlahTA8rUwFLJ1a2c/+MgT8H kW0Uo7yO/3oKisXHG2aHnB2tznODhs4iLdHQU3r17QdsiqP0gmP5WeDaycyyUhu1UVcEczZLh3D mMJeohmZF/AVceoq5li0MYKbgHTarCUnhAcgkwQGduGDegAQtnnyoBHW2PGYfXDwRJKHdYmrT83 bgXb7WkWULmSUGhnsCQUtd8cxBWxCsxBRItPMbaXcjjqQRyYU/ssUfL5S/ymbMrCsxzeuHrvUQP HaqciOAXNezol9iZv5UA87VieSwygsTd4/JA5jSnoKBx3UcYD9cZyVTv8KDCuV9kMDHu+TSF1mv 3x5pQf2X5NtEtYSsMfA== X-Proofpoint-Spam-Info: AW1haW4tMjYxMTMwMDA0MiBTYWx0ZWRfX4io9t7hlRbXx owXZ6XyGGbloaeX7Sktwb85UgzJ3tRv201TKSPjkt/sNPqud9ALfSZibWm9KT9kONvDHBcbcwgY B3zoT9qMId976Tg81QCBK3XLibXrATU= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-30_03,2026-11-27_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 lowpriorityscore=0 malwarescore=0 spamscore=0 bulkscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 suspectscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611300042 A single CCI_I2C_WRITE command can only carry up to 11 bytes, so every i2c write was capped at that size via i2c max_write quirk. CCI v1.2 introduces burst mode support, where consecutive write commands (marked as burst) run back-to-back as a single transfer. Use this in cci_i2c_write() to allow longer writes across the whole queue instead of a single command's payload, and raise max_write_len accordingly for every CCI revision that supports burst mode. unlock/lock commands are required to ensure the commands for a given transfer are executed atomically. Reviewed-by: Konrad Dybcio Signed-off-by: Loic Poulain --- drivers/i2c/busses/i2c-qcom-cci.c | 43 +++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/drivers/i2c/busses/i2c-qcom-cci.c b/drivers/i2c/busses/i2c-qcom-cci.c index 02e170182357fba4cb05113c3eb9665cc03ebad5..5bb39534578e8887a7bf54e9fe219a58433c91cc 100644 --- a/drivers/i2c/busses/i2c-qcom-cci.c +++ b/drivers/i2c/busses/i2c-qcom-cci.c @@ -83,18 +83,30 @@ #define CCI_IRQ_STATUS_0_I2C_M1_ERROR 0x60ee6000 #define CCI_TIMEOUT (msecs_to_jiffies(100)) +#define CCI_XFER_TIMEOUT (msecs_to_jiffies(500)) /* Sized for the worst case */ + #define NUM_MASTERS 2 #define NUM_QUEUES 2 #define CCI_I2C_SET_PARAM 1 +#define CCI_I2C_LOCK 6 +#define CCI_I2C_UNLOCK 7 #define CCI_I2C_REPORT 8 #define CCI_I2C_WRITE 9 #define CCI_I2C_READ 10 +#define CCI_I2C_REPORT_IRQ_EN BIT(8) + #define CCI_I2C_WRITE_WC 3 +#define CCI_I2C_WRITE_MAX_LEN (CCI_I2C_WRITE_WC * sizeof(u32) - 1) #define CCI_I2C_WRITE_NWORDS(len) DIV_ROUND_UP((len) + 1, sizeof(u32)) +#define CCI_I2C_WRITE_BURST 0xf +#define CCI_I2C_BURST_OVERHEAD 4 /* LOCK + SET_PARAM + UNLOCK + REPORT */ -#define CCI_I2C_REPORT_IRQ_EN BIT(8) +/* Largest write that can be bursted through a queue of @qsize words */ +#define CCI_I2C_BURST_MAX_LEN(qsize) \ + (((qsize) - CCI_I2C_BURST_OVERHEAD) / CCI_I2C_WRITE_WC * \ + CCI_I2C_WRITE_MAX_LEN) enum { I2C_MODE_STANDARD, @@ -436,7 +448,7 @@ static int cci_run_queue(struct cci *cci, u8 master, u8 queue) writel(val, cci->base + CCI_QUEUE_START); if (!wait_for_completion_timeout(&cci->master[master].irq_complete, - CCI_TIMEOUT)) { + CCI_XFER_TIMEOUT)) { dev_err(cci->dev, "master %d queue %d timeout\n", master, queue); cci_reset(cci); @@ -516,11 +528,11 @@ static int cci_i2c_read(struct cci *cci, u16 master, return 0; } -static void cci_i2c_load_write(u8 *buf, u16 len, void __iomem *loadq) +static void cci_i2c_load_write(void __iomem *loadq, u8 *buf, u16 len, bool burst) { u32 cmd[CCI_I2C_WRITE_WC] = { }; - cmd[0] = CCI_I2C_WRITE | len << 4; + cmd[0] = CCI_I2C_WRITE | (burst ? CCI_I2C_WRITE_BURST : len) << 4; memcpy((u8 *)cmd + 1, buf, len); iowrite32_rep(loadq, cmd, CCI_I2C_WRITE_NWORDS(len)); } @@ -529,6 +541,7 @@ static int cci_i2c_write(struct cci *cci, u16 master, u16 addr, u8 *buf, u16 len) { void __iomem *loadq = cci->base + CCI_I2C_Mm_Qn_LOAD_DATA(master, QUEUE_0); + bool burst = len > CCI_I2C_WRITE_MAX_LEN; int ret; u32 val; @@ -546,10 +559,22 @@ static int cci_i2c_write(struct cci *cci, u16 master, if (ret < 0) return ret; + if (burst) + writel(CCI_I2C_LOCK, loadq); + val = CCI_I2C_SET_PARAM | (addr & 0x7f) << 4; writel(val, loadq); - cci_i2c_load_write(buf, len, loadq); + do { + u16 to_write = min_t(u16, len, CCI_I2C_WRITE_MAX_LEN); + + len -= to_write; + cci_i2c_load_write(loadq, buf, to_write, len > 0); + buf += to_write; + } while (len); + + if (burst) + writel(CCI_I2C_UNLOCK, loadq); val = CCI_I2C_REPORT | CCI_I2C_REPORT_IRQ_EN; writel(val, loadq); @@ -719,7 +744,7 @@ static const struct cci_data cci_hw_catalog[] = { .max_mode = I2C_MODE_FAST_PLUS, .queue_size = { 64, 16 }, .quirks = { - .max_write_len = 11, + .max_write_len = CCI_I2C_BURST_MAX_LEN(64), .max_read_len = 12, }, }, @@ -728,7 +753,7 @@ static const struct cci_data cci_hw_catalog[] = { .max_mode = I2C_MODE_FAST_PLUS, .queue_size = { 128, 32 }, .quirks = { - .max_write_len = 11, + .max_write_len = CCI_I2C_BURST_MAX_LEN(128), .max_read_len = 12, }, }, @@ -737,7 +762,7 @@ static const struct cci_data cci_hw_catalog[] = { .max_mode = I2C_MODE_FAST_PLUS, .queue_size = { 128, 32 }, .quirks = { - .max_write_len = 11, + .max_write_len = CCI_I2C_BURST_MAX_LEN(128), .max_read_len = 12, }, }, @@ -746,7 +771,7 @@ static const struct cci_data cci_hw_catalog[] = { .max_mode = I2C_MODE_FAST_PLUS, .queue_size = { 1024, 32 }, .quirks = { - .max_write_len = 11, + .max_write_len = CCI_I2C_BURST_MAX_LEN(1024), .max_read_len = 12, }, }, -- 2.34.1