From mboxrd@z Thu Jan 1 00:00:00 1970 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=1796035042; b=3biem6QEdTiJxlCam2mSuwq3cI1+WrYsOgbWO+xWzoDMzdVCYb8cnNCoJLR4NykY2+9B JdYjGmufJc0OX9U2pXXMNZPaOFt4M+T4kaZF77KVkwKwjtSFD4RnG66scdTq2gXIy4C4T 68KYrQkv/0xRRgvQfhGi73sqQfO5sMDrKeFp6zdOtTyfWECVwF6LbAYw4ODoTS5VRU16i LcC9Troigqr4VkVNwIBPRffg49AxppY43J3M1yX/T/FMi5YfJX3G4CWKas/fMKw9etG9N CnTDYo2/NJ1NMcgpnD4RODgB3xK2V7zBbasH4zQhxwvjhifI7J9BEAPaU+tBbDst4VQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796035042; 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-Proofpoint-ORIG-GUID:X-Proofpoint-Spam-Info:X-Proofpoint-GUID: X-Authority-Analysis:X-Proofpoint-Spam-Details-Enc: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=cT219pMbAeWmm72NbFN32J64lIRpI60H6wmFocHcGlg=; b=WOwVT0zW+wgJu3+GwCRyKBKuKDEu7qnYRK3Nvl+VdaLejpEt67tYVJOSMeHQvY+kMrlb HzvEF0/eTCtToBBvhqV2xdssidQmYCavCF2t5heULL1WMDq8tqBUExYdZhvHnw/SP5Pc8 gJTUY3QLotstUgAgTXw1mwyKpXk6ELJ+ESZz3dyP2Xq3gX+SuRMTIEd/Om8Xtt8E3gCiM 2anrwGjHvYg+WFSHO4PAig1tYrsR5XeKl1VatvsHIFTRhIso0BExv0HDtEwqHBYzxwqwY MZ7+UXzKdBlOI1Kr6O4bkRtuWVGrO90OT7QGhKv5h4hFVRX0eJCx1ISarTsWiTSeZOA== 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=JjLFla+X; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=bSqdr0yS; 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 8A9D1606A330 for ; Mon, 30 Nov 2026 10:37:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8A9D1606A330 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=JjLFla+X; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=bSqdr0yS Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AU9V0DX2004039 for ; Mon, 30 Nov 2026 10:37:20 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= cT219pMbAeWmm72NbFN32J64lIRpI60H6wmFocHcGlg=; b=JjLFla+X2BrjmmTL TujIL1EQf/lYydQeLlsQx+hfIgUpsC9I7xcygBcnOQuzSY1jbMYR8hLAuvn3k5U/ RW5zed+FZ6Oe2qL3pX6Extns+VLOPorXksjNXVoTj4xzC8hYuBJr9ygdJoAAhTg1 y3Ex04mBQiT+joiHiL4oZpuOpRJM9hrSLfoxxq+2Aj6q5biCqP8AyKXpY6vFKGzS Y5YhGPCFHMdvljQhT1sVjF3084AXI4PWc+Z8GmGVlcnPjkXDIXZoWKmk6oqAaRdB rpj/4U+dVBKraada5Q5SlNuEbqOlFKtp9AXIzHnprjBFUHhBHNRtyFCGuxJjURB7 i0GNrQ== Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j9477gw3c-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 30 Nov 2026 10:37:20 +0000 (GMT) Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-944138ed63fso1031927085a.3 for ; Mon, 30 Nov 2026 02:37:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1796035040; x=1796639840; 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=cT219pMbAeWmm72NbFN32J64lIRpI60H6wmFocHcGlg=; b=bSqdr0ySmgShU1Yz6+lUbTEVfPZIOyWx9vHAB+fxGWTLsQOhrJOao9ThLO2wniEsQp 5d+nbjXSYO0WCHD2XD1ARsn/rxxO5+7aFTfSiKXXG/lMrxcwpYNuv8HK/FDdILlUt3JR n3XyXo+tUfbW9TS3pNeWG+s2K90FD8RpL/zbvbBLDGCisJfykObcX2aSFr8UQM18iVB2 RgRSW9gECYaU6jwXTX/aigfPoTHhTJiC9meqZ3IrsR7JmkpAyD5LgDnlALQlmQ0hJJl6 1O/COXmQpfM+ugHAKYPhXbznpKl6ZM9l8ToSvPy+PLZBMAWmaTPSGz/Oo8EZm9Qj3Pq9 A7oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796035040; x=1796639840; 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=cT219pMbAeWmm72NbFN32J64lIRpI60H6wmFocHcGlg=; b=QMu0XgcoGBtWP4A9TS6TA2oj/k0AuBEVt1tYMAx/MwWbe6T4+kZaofdh6FVzHGxmvX 3SepPoH2tTrhLqrvZKH7pYDpqlGvqJu+awYAcm9HFJwS6YYzOqYhQYgrXgzcM+//sjyG GyKyUOYxqzwXnUd9XJtyzeSuC8KxTCrmGH9sU4la9/GnBTHTYpAN4FIMqnATnG/G8YEt CYn6VGqUAjnEebhwYciUsrXcUBg1gHYCaqJBbtxI4LtNJ2zmc/RdHmkKUMJrg2Kqa9OJ aHV/n12f0Cph9mn+2rcXciVg6QCAPP+Gmg0Dwq6ojcQoXCEyc+hix1ptptHM3GGKQ/c8 MeNw== X-Forwarded-Encrypted: i=1; AL+hErEyLczeLeBuoG273yWX8BILLLalDKs7gAEoJkR6YMiupBfDMWcVm4AIEj/h3jhdJMvP9vf6aRZAjvkuXls=@vger.kernel.org X-Gm-Message-State: APuU4Z9EVsglKgeNmpbpM9Rdn73zDQgZ1XtBXuAJ5PseDtNgtpI83H55 caSGQC88PhM8lTlr+FH/KBqRts9CkRiUqSchCf9Yxba8X9ZR5DFnpSRX5BVSO7p/Bf23VQ59Ji8 fDEKW+yjF4sbvg2R+7eBmVc8/XeBuxE1ZECl5FNzX7HZgyFZmlj82lLWNhuhGdeOH2CE= X-Gm-Gg: AZFdTZdQb0fmu2004HhBsCEvXuJD59sDGHzmCQnLS2DSF9BTph69/r+HKeUoG8tUGdI x++jchs+HhQvJk7WJCMZwQs2gsE6hlfwumHw7+ycuVhu2GUvsjcLP5SFZGC2o4gwS70O2JjmKF5 39UeKQ2vxQZRsLpGpkjj/f+FW/mGdxOthTAZSL4K0T8RvMkCaSqfz3E9gyNTNymSS25kcIrvVW8 crd1Z0vDZikVPiavPcqrcsKl+TtF/YK3YeqnYHg6Uz3VmfV8v33r5wI/U6EAAsJN0gXvEBa3T4N +/kJzBFKism4n/m9pxbtCBesfF1y9dm+vdsB0PfLIu7T09fxUE4RXiNiMcgrGEqbdykcEo9/QEp Hy4J7KYuyv0qo/nCUQfI1FXu/cAbgaoCthyJ+hF1ErgomgJhtsT7o4rmIYuEgUQVCv6yg5r53Vz IAJDGQbcxmzyGwTVx/3V9W3TndnRRuG/bnM+AgqSDvgwH8r9EuQKNDylddyTXmoCEuSH424aL6+ kH6e3/qQOGD734NJHTD1IYU4R1c X-Received: by 2002:a05:620a:27c1:b0:93f:1ed3:a9cc with SMTP id af79cd13be357-949ba9b3a47mr5553430285a.17.1796035039516; Mon, 30 Nov 2026 02:37:19 -0800 (PST) X-Received: by 2002:a05:620a:27c1:b0:93f:1ed3:a9cc with SMTP id af79cd13be357-949ba9b3a47mr5553427685a.17.1796035038932; Mon, 30 Nov 2026 02:37:18 -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.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 02:37:18 -0800 (PST) From: Loic Poulain Date: Mon, 30 Nov 2026 11:36:59 +0100 Subject: [PATCH v5 3/7] i2c: qcom-cci: Detect capabilities from CCI_HW_VERSION at runtime X-Mailing-List: linux-kernel@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-3-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-Proofpoint-ORIG-GUID: WSyVLWsMh7jBCJUUw_U5Q76v7ReXgS4K X-Proofpoint-Spam-Info: AW1haW4tMjYxMTMwMDA0MiBTYWx0ZWRfX3f1mv4RyTHbB RW5laaGQuQTfBDu1dugvyDLEy4V4FzJX+ZK+JM6QWWiVssOJgqKziAYnmGCedZECl/O8OFY3rlD jHkDqbfAsOPpTEnnSdeYSQbWWxvXPe0= X-Proofpoint-GUID: WSyVLWsMh7jBCJUUw_U5Q76v7ReXgS4K X-Authority-Analysis: v=2.4 cv=CN6/zhrD c=1 sm=1 tr=0 ts=6b0d51e0 cx=c_pps a=hnmNkyzTK/kJ09Xio7VxxA==:117 a=xqWC_Br6kY4A:10 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=ZpdpYltYx_vBUK5n70dp:22 a=EUspDBNiAAAA:8 a=8R-5LDRAFMUVkZqLBecA:9 a=QEXdDO2ut3YA:10 a=PEH46H7Ffwr30OY-TuGO:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTMwMDA0MiBTYWx0ZWRfX/yxtGZtsbkYY 24bGOWOcel3INpbuu9ykGVTXswcnxc7Ll4EFebHgiJmm/RuOYMMnbkvtsUs6BfMai7lTwh0t4R4 VtsoOF7zj05UW4/QqehSOPcL0r4nYYQrUUWxPWqrt229q2k6ula7d7YJDF/GTVCfH33nm6q7uuV /o0rDpWw6VfP/xzxOGPGn+QxmJ0vTL2/LMZcuRspgXNJYlBTgIo7yB7/4XLtDUeLhIPwbiB7RSs 9j5R0HvIvD8xWfmG47Gb9BkQLZ6+BPm0dizuQsZl4STwV8g00VtWczuOzUIUerRqnbe9mZtuSug EMzoASyua2kxgaJwAnOKfRGGSTsqi0wKOvuDC57cxgVCBI+o92usQaSVNFpY/fWjCm38ESnhqju 9jVgO1ejb7+KE9sItU/O/RJYRqO4LTMuEwLUHZDiYfTrI8DDlhq+hvT8kM1eHwexTKEy9u4dZFc yBdpWx3QG8+WDRAV74g== 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 bulkscore=0 impostorscore=0 priorityscore=1501 spamscore=0 malwarescore=0 clxscore=1015 suspectscore=0 phishscore=0 adultscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611300042 In theory, every SoC integrating a CCI revision that differs from an existing one should introduce a dedicated compatible string. In practice, most CCI instances still fall back to the msm8996 compat (v1.4.0), one of the oldest supported versions. In order to take advantage of capabilities introduced in later versions, such as larger queues (v1.6.0) or threshold IRQ support (v1.7.0), we need to properly distinguish the different variants. Replace the static per-compatible cci_data definitions with a version-sorted capability table keyed by (hw_major, hw_minor). During probe, read CCI hardware revision register and select the newest capability entry whose version is less than or equal to the detected hardware revision. This allows revisions to automatically inherit the closest supported capability set without requiring additional compatible strings. Several compatibles that currently fall back to the msm8996 configuration (e.g. sdm845, sm8250 and sm8450) will now resolve to the corresponding capability tier, gaining access to their larger queue sizes instead of the conservative msm8996 defaults. - v1.2.x CCI increase I2C write payload + burst write support - v1.6.x CCI has increased queue sizes (64,16) -> (128,32) - v1.7.x CCI introduces threshold IRQs (leveraged later) - v1.10.x CCI increase queue 0 size (128) -> (1024) Suggested-by: Konrad Dybcio Reviewed-by: Konrad Dybcio Signed-off-by: Loic Poulain --- drivers/i2c/busses/i2c-qcom-cci.c | 165 ++++++++++++++++++++++++-------------- 1 file changed, 107 insertions(+), 58 deletions(-) diff --git a/drivers/i2c/busses/i2c-qcom-cci.c b/drivers/i2c/busses/i2c-qcom-cci.c index fff71c5e4ea544f5d4c57916f25eaced74fc3aa1..02e170182357fba4cb05113c3eb9665cc03ebad5 100644 --- a/drivers/i2c/busses/i2c-qcom-cci.c +++ b/drivers/i2c/busses/i2c-qcom-cci.c @@ -2,6 +2,7 @@ // Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. // Copyright (c) 2017-2022 Linaro Limited. +#include #include #include #include @@ -14,6 +15,10 @@ #include #define CCI_HW_VERSION 0x0 +#define CCI_HW_VERSION_MAJOR_MASK GENMASK(31, 28) +#define CCI_HW_VERSION_MINOR_MASK GENMASK(27, 16) +#define CCI_HW_VERSION_STEP_MASK GENMASK(15, 0) +#define QCOM_CCI_VERSION(major, minor) .hw_major = (major), .hw_minor = (minor) #define CCI_RESET_CMD 0x004 #define CCI_RESET_CMD_MASK 0x0f73f3f7 #define CCI_RESET_CMD_M0_MASK 0x000003f1 @@ -133,7 +138,8 @@ struct cci_master { }; struct cci_data { - unsigned int num_masters; + u16 hw_major; + u16 hw_minor; struct i2c_adapter_quirks quirks; u16 queue_size[NUM_QUEUES]; /* Highest I2C mode supported by this variant. */ @@ -144,6 +150,7 @@ struct cci { struct device *dev; void __iomem *base; unsigned int irq; + unsigned int num_masters; const struct cci_data *data; struct clk_bulk_data *clocks; int nclocks; @@ -245,7 +252,7 @@ static int cci_halt(struct cci *cci, u8 master_num) struct cci_master *master; u32 val; - if (master_num >= cci->data->num_masters) { + if (master_num >= cci->num_masters) { dev_err(cci->dev, "Unsupported master idx (%u)\n", master_num); return -EINVAL; } @@ -366,7 +373,7 @@ static int cci_init(struct cci *cci) writel(val, cci->base + CCI_IRQ_MASK_0); - for (i = 0; i < cci->data->num_masters; i++) { + for (i = 0; i < cci->num_masters; i++) { int mode = cci->master[i].mode; const struct hw_params *hw; @@ -616,7 +623,7 @@ static int cci_get_required_rate(struct cci *cci, unsigned long *rate) if (clk_round_rate(cci->cci_clk, cci_clk_rates[ri]) != cci_clk_rates[ri]) continue; - for (int i = 0; i < cci->data->num_masters; i++) { + for (int i = 0; i < cci->num_masters; i++) { int mode = cci->master[i].mode; if (!cci->master[i].cci) @@ -696,6 +703,81 @@ static void cci_put_of_node(void *data) of_node_put(data); } +/* Hardware capabilities, ascending by version major,minor */ +static const struct cci_data cci_hw_catalog[] = { + { + QCOM_CCI_VERSION(1, 0), + .max_mode = I2C_MODE_FAST, + .queue_size = { 64, 16 }, + .quirks = { + .max_write_len = 10, + .max_read_len = 12, + }, + }, + { + QCOM_CCI_VERSION(1, 2), + .max_mode = I2C_MODE_FAST_PLUS, + .queue_size = { 64, 16 }, + .quirks = { + .max_write_len = 11, + .max_read_len = 12, + }, + }, + { + QCOM_CCI_VERSION(1, 6), + .max_mode = I2C_MODE_FAST_PLUS, + .queue_size = { 128, 32 }, + .quirks = { + .max_write_len = 11, + .max_read_len = 12, + }, + }, + { + QCOM_CCI_VERSION(1, 7), + .max_mode = I2C_MODE_FAST_PLUS, + .queue_size = { 128, 32 }, + .quirks = { + .max_write_len = 11, + .max_read_len = 12, + }, + }, + { + QCOM_CCI_VERSION(1, 10), + .max_mode = I2C_MODE_FAST_PLUS, + .queue_size = { 1024, 32 }, + .quirks = { + .max_write_len = 11, + .max_read_len = 12, + }, + }, +}; + +static void cci_detect_hw_caps(struct cci *cci, u32 hw_version) +{ + u8 major = FIELD_GET(CCI_HW_VERSION_MAJOR_MASK, hw_version); + u16 minor = FIELD_GET(CCI_HW_VERSION_MINOR_MASK, hw_version); + u16 step = FIELD_GET(CCI_HW_VERSION_STEP_MASK, hw_version); + const struct cci_data *data = &cci_hw_catalog[0]; + int i; + + for (i = 0; i < ARRAY_SIZE(cci_hw_catalog); i++) { + if (cci_hw_catalog[i].hw_major > major || + (cci_hw_catalog[i].hw_major == major && cci_hw_catalog[i].hw_minor > minor)) + break; + data = &cci_hw_catalog[i]; + } + + dev_dbg(cci->dev, "CCI HW version %u.%u.%u, using caps tier %u.%u\n", + major, minor, step, data->hw_major, data->hw_minor); + + cci->data = data; + + for (i = 0; i < cci->num_masters; i++) { + if (cci->master[i].cci) + cci->master[i].adap.quirks = &cci->data->quirks; + } +} + static int cci_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -710,9 +792,6 @@ static int cci_probe(struct platform_device *pdev) cci->dev = dev; platform_set_drvdata(pdev, cci); - cci->data = device_get_match_data(dev); - if (!cci->data) - return -ENOENT; for_each_available_child_of_node_scoped(dev->of_node, child) { struct cci_master *master; @@ -724,14 +803,16 @@ static int cci_probe(struct platform_device *pdev) continue; } - if (idx >= cci->data->num_masters) { + if (idx >= NUM_MASTERS) { dev_err(dev, "%pOF invalid 'reg' value: %u (max is %u)", - child, idx, cci->data->num_masters - 1); + child, idx, NUM_MASTERS - 1); continue; } + if (idx >= cci->num_masters) + cci->num_masters = idx + 1; + master = &cci->master[idx]; - master->adap.quirks = &cci->data->quirks; master->adap.algo = &cci_algo; master->adap.dev.parent = dev; master->adap.dev.of_node = of_node_get(child); @@ -785,16 +866,14 @@ static int cci_probe(struct platform_device *pdev) if (ret && ret != -ENODEV) return dev_err_probe(dev, ret, "failed to add OPP table\n"); - ret = cci_set_core_rate(cci); - if (ret) - return ret; - ret = cci_enable_clocks(cci); if (ret < 0) return ret; - /* Interrupt */ + val = readl(cci->base + CCI_HW_VERSION); + cci_detect_hw_caps(cci, val); + /* Interrupt */ ret = platform_get_irq(pdev, 0); if (ret < 0) goto disable_clocks; @@ -806,8 +885,9 @@ static int cci_probe(struct platform_device *pdev) goto disable_clocks; } - val = readl(cci->base + CCI_HW_VERSION); - dev_dbg(dev, "CCI HW version = 0x%08x", val); + ret = cci_set_core_rate(cci); + if (ret) + goto disable_clocks; ret = cci_reset(cci); if (ret < 0) @@ -820,7 +900,7 @@ static int cci_probe(struct platform_device *pdev) pm_runtime_use_autosuspend(dev); - for (i = 0; i < cci->data->num_masters; i++) { + for (i = 0; i < cci->num_masters; i++) { if (!cci->master[i].cci) continue; @@ -855,7 +935,7 @@ static void cci_remove(struct platform_device *pdev) /* Ensure the device is clocked before issuing the halt requests */ ret = pm_runtime_get_sync(cci->dev); - for (i = 0; i < cci->data->num_masters; i++) { + for (i = 0; i < cci->num_masters; i++) { if (cci->master[i].cci) { i2c_del_adapter(&cci->master[i].adap); if (ret >= 0) @@ -866,51 +946,20 @@ static void cci_remove(struct platform_device *pdev) pm_runtime_put_sync(cci->dev); } -static const struct cci_data cci_v1_data = { - .num_masters = 1, - .queue_size = { 64, 16 }, - .quirks = { - .max_write_len = 10, - .max_read_len = 12, - }, - .max_mode = I2C_MODE_FAST, -}; - -static const struct cci_data cci_v1_5_data = { - .num_masters = 2, - .queue_size = { 64, 16 }, - .quirks = { - .max_write_len = 10, - .max_read_len = 12, - }, - .max_mode = I2C_MODE_FAST, -}; - -static const struct cci_data cci_v2_data = { - .num_masters = 2, - .queue_size = { 64, 16 }, - .quirks = { - .max_write_len = 11, - .max_read_len = 12, - }, - .max_mode = I2C_MODE_FAST_PLUS, -}; - static const struct of_device_id cci_dt_match[] = { - { .compatible = "qcom,msm8226-cci", .data = &cci_v1_data}, - { .compatible = "qcom,msm8953-cci", .data = &cci_v2_data}, - { .compatible = "qcom,msm8974-cci", .data = &cci_v1_5_data}, - { .compatible = "qcom,msm8996-cci", .data = &cci_v2_data}, - + { .compatible = "qcom,msm8226-cci" }, + { .compatible = "qcom,msm8953-cci" }, + { .compatible = "qcom,msm8974-cci" }, + { .compatible = "qcom,msm8996-cci" }, /* * Legacy compatibles kept for backwards compatibility. * Do not add any new ones unless they introduce a new config */ - { .compatible = "qcom,msm8916-cci", .data = &cci_v1_data}, - { .compatible = "qcom,sdm845-cci", .data = &cci_v2_data}, - { .compatible = "qcom,sm8250-cci", .data = &cci_v2_data}, - { .compatible = "qcom,sm8450-cci", .data = &cci_v2_data}, + { .compatible = "qcom,msm8916-cci" }, + { .compatible = "qcom,sdm845-cci" }, + { .compatible = "qcom,sm8250-cci" }, + { .compatible = "qcom,sm8450-cci" }, {} }; MODULE_DEVICE_TABLE(of, cci_dt_match); -- 2.34.1