From patchwork Wed Oct 9 14:01:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Th=C3=A9o_Lebrun?= X-Patchwork-Id: 13828485 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F01FFCEDD97 for ; Wed, 9 Oct 2024 14:05:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=GRl0oDUhVdNBfOFkIyXrQQ0mGfXjI5s9AX24o2wX49U=; b=Ng2T84BLUwu9DkfmHLPC21J3oa gcKV47tuiPQBxTNBqUf5pD+zvBuqqMq+7Dfxg5ti2OT4KHWK1dpVnAPJpO5Lxwk+DCHD0d3GMHZnN IBv0uq6aNP6Zcz51FqeoUhYxGwfX8EsQ39+hQIsn3UZWgHxBmL8V0vVXSTezRdS7BhFldIXJuC2Gf Lw/92rUmrNJV7ZKl2ky2VDZLkXI1sLeEBsZL+U5FYAqat/WPQsF6FuaCI7jZ/xLl0/yrWrAWlUsSr IwigWb6aM8js7c/8rRwDe9l66v1SP/xWVvPLOODdzTgxLST4djGtc49xQDngP1ekeMbu79pEdpv90 foFMItZQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syXJe-00000009WV8-2dcA; Wed, 09 Oct 2024 14:05:26 +0000 Received: from relay8-d.mail.gandi.net ([217.70.183.201]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syXFX-00000009VIT-08JC for linux-arm-kernel@lists.infradead.org; Wed, 09 Oct 2024 14:01:14 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 0C2371BF208; Wed, 9 Oct 2024 14:01:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728482468; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GRl0oDUhVdNBfOFkIyXrQQ0mGfXjI5s9AX24o2wX49U=; b=QOtzPyaq8gmyrFlK2iT5M7O8TCY7xw5/mlTNjwLNHYwWaindmPyfdlXvXfVTbwgc8M6BoM 2LjWcfhMFaR0DKrxRVJlRU8Exa24gkVD/3+YC4djPgqcsOztNrWOU18rgQoOzF111j3CQ6 xTVbPijLsqb5Zwe4PIngdkHIue0OEJlmEPzowHoURhV+sS4m+ERtyYhwQlVqHYjuertucz L0exLmmfcBLzblvgO/Gda/qO4351PZoog7x/bvcRaTsRDBa0Uj7JprQe5XuCH6prDe0/Af wMmo4VpFsRgcXsBywq11AdnzywnSoaUxfIEIBxV06r5sv1yx05/8e6JxiSuvBQ== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Wed, 09 Oct 2024 16:01:07 +0200 Subject: [PATCH v3 1/6] dt-bindings: i2c: nomadik: add mobileye,eyeq6h-i2c bindings MIME-Version: 1.0 Message-Id: <20241009-mbly-i2c-v3-1-e7fd13bcf1c4@bootlin.com> References: <20241009-mbly-i2c-v3-0-e7fd13bcf1c4@bootlin.com> In-Reply-To: <20241009-mbly-i2c-v3-0-e7fd13bcf1c4@bootlin.com> To: Linus Walleij , Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Vladimir Kondratiev , =?utf-8?q?Gr=C3=A9?= =?utf-8?q?gory_Clement?= , Thomas Petazzoni , Tawfik Bayouk , =?utf-8?q?Th=C3=A9o_Lebrun?= X-Mailer: b4 0.14.2 X-GND-Sasl: theo.lebrun@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241009_070111_415736_1CF2F93A X-CRM114-Status: UNSURE ( 9.40 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org After EyeQ5, it is time for Mobileye EyeQ6H to reuse the Nomadik I2C controller. Add a specific compatible because its HW integration is slightly different from EyeQ5. Do NOT add an example as it looks like EyeQ5 from a DT standpoint (without the mobileye,olb property). Reviewed-by: Linus Walleij Signed-off-by: Théo Lebrun Reviewed-by: Rob Herring (Arm) --- Documentation/devicetree/bindings/i2c/st,nomadik-i2c.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/i2c/st,nomadik-i2c.yaml b/Documentation/devicetree/bindings/i2c/st,nomadik-i2c.yaml index 44c54b162bb10741ec7aac70d165403c28176eba..7e84465c20094b799697a71a66c66d144d621f46 100644 --- a/Documentation/devicetree/bindings/i2c/st,nomadik-i2c.yaml +++ b/Documentation/devicetree/bindings/i2c/st,nomadik-i2c.yaml @@ -22,6 +22,7 @@ select: enum: - st,nomadik-i2c - mobileye,eyeq5-i2c + - mobileye,eyeq6h-i2c required: - compatible @@ -29,15 +30,15 @@ properties: compatible: oneOf: - items: - - const: st,nomadik-i2c + - enum: + - st,nomadik-i2c + - mobileye,eyeq5-i2c + - mobileye,eyeq6h-i2c - const: arm,primecell - items: - const: stericsson,db8500-i2c - const: st,nomadik-i2c - const: arm,primecell - - items: - - const: mobileye,eyeq5-i2c - - const: arm,primecell reg: maxItems: 1 @@ -54,7 +55,7 @@ properties: - items: - const: mclk - const: apb_pclk - # Clock name in DB8500 or EyeQ5 + # Clock name in DB8500 or EyeQ - items: - const: i2cclk - const: apb_pclk From patchwork Wed Oct 9 14:01:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Th=C3=A9o_Lebrun?= X-Patchwork-Id: 13828476 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1AD8CCEDD97 for ; Wed, 9 Oct 2024 14:02:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=gA2VtzJur2fLfrAh7HiOZK9GKI0XRlL4niun8+mE/+k=; b=PEPOpD0YySdJzmIGrb26Nt6NAu qtPjdII/HDARWorvoLQEtUzN7tK0XwDH1YZJ01BvrZ7nmqKWIjTk3mZFYLHguLixpDsTrvzM5cANu lLG28sy1DkPn12B7T8K1kKGYuONoHkZXa5n0txrJLsIlb8xiwB25rjo4IsV3/MO+2l0p0fYDKoIHD IcCErj4EvrR2xreK1I66/q63P3OrcEXOoeRLHwLAPlba8OEa63jkG5RGgfx6g70Iqj4W8u77/KOUU VTArB8Tt68RHczh11dYWPb0fqmboh0IE+2bkZpawL7sebCXeSAD8fDo+ITkAerga2noEKModdHFAr 3X5ypZ0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syXH3-00000009Vx8-0Thf; Wed, 09 Oct 2024 14:02:45 +0000 Received: from relay8-d.mail.gandi.net ([217.70.183.201]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syXFX-00000009VIe-08yz for linux-arm-kernel@lists.infradead.org; Wed, 09 Oct 2024 14:01:12 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 9DA7B1BF205; Wed, 9 Oct 2024 14:01:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728482469; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gA2VtzJur2fLfrAh7HiOZK9GKI0XRlL4niun8+mE/+k=; b=b2jo1umh/A1j9iiRQpuv8IobE+8z3xMSlPprZC7+qc/zEYrw9hdJxIPIVSWQcSOwq+ATWR cBqbqhPTca8N7tm2EY/PCleh5FgDGsnbZRqTGNeABg8QpsrNyWc+hOYMRFEvKP4SekANYI peYF2opUr/J5GXkFIuSzJaCoemNceFMo5NH7ZMayeEZtDUkTOvPQfpb0/JvbW775e7H/xL W76H8vbHBa86aL5meHk7UXBbVHALrvosc/c0GzvF4a2aSGCxUl2vWab0gquF3xnORQXsEl zQCzI6LCQwb+XC/58lF4IALwgHmtPsep+Tr0sp4elDjCROPMzV/3vJlQL8+TOQ== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Wed, 09 Oct 2024 16:01:08 +0200 Subject: [PATCH v3 2/6] dt-bindings: i2c: nomadik: support 400kHz < clock-frequency <= 3.4MHz MIME-Version: 1.0 Message-Id: <20241009-mbly-i2c-v3-2-e7fd13bcf1c4@bootlin.com> References: <20241009-mbly-i2c-v3-0-e7fd13bcf1c4@bootlin.com> In-Reply-To: <20241009-mbly-i2c-v3-0-e7fd13bcf1c4@bootlin.com> To: Linus Walleij , Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Vladimir Kondratiev , =?utf-8?q?Gr=C3=A9?= =?utf-8?q?gory_Clement?= , Thomas Petazzoni , Tawfik Bayouk , =?utf-8?q?Th=C3=A9o_Lebrun?= X-Mailer: b4 0.14.2 X-GND-Sasl: theo.lebrun@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241009_070111_417866_DC2DC176 X-CRM114-Status: GOOD ( 10.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hardware is not limited to 400kHz, its documentation does mention how to configure it for high-speed (a specific Speed-Mode enum value and a different bus rate clock divider register to be used). Reviewed-by: Linus Walleij Signed-off-by: Théo Lebrun Reviewed-by: Rob Herring (Arm) --- Documentation/devicetree/bindings/i2c/st,nomadik-i2c.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/i2c/st,nomadik-i2c.yaml b/Documentation/devicetree/bindings/i2c/st,nomadik-i2c.yaml index 7e84465c20094b799697a71a66c66d144d621f46..012402debfeb244b85dcecdc0411a77ada4494df 100644 --- a/Documentation/devicetree/bindings/i2c/st,nomadik-i2c.yaml +++ b/Documentation/devicetree/bindings/i2c/st,nomadik-i2c.yaml @@ -68,7 +68,7 @@ properties: clock-frequency: minimum: 1 - maximum: 400000 + maximum: 3400000 mobileye,olb: $ref: /schemas/types.yaml#/definitions/phandle-array From patchwork Wed Oct 9 14:01:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Th=C3=A9o_Lebrun?= X-Patchwork-Id: 13828477 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A114ECEDD99 for ; Wed, 9 Oct 2024 14:04:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=51tFhwkIfjKQ6rs73rgZmRnnNukZhWLjQRX8i+8ldQ4=; b=eARd8TuPtRivTGhuRrGttSGF7u 17HOaDvncsQfkSD460FU4Lo2LrlgfmMx8oXTb1Inoxf1wUzNZUDhip50tSNj77xYlmEad/FCnFVNC 1rOC4Wd4WgXOH0j9t1k+ZpK55Oqp33Q3TWPFcGm73aksnheym1IlHyrswkHhMFFsYvksV2Tq8Ph3R zb5K8dF43Q6+aF6DyLl9iyiZxdWfjrbc6g6LzHYOhXP3LGwjzyHbFMBSElxOC45qLTGoNIulyu0j0 Pxfvy1uxsTIqnx/NrFyJFRpyfMumqVN1J0NzB4z31HzKbi3EtKpkCP1ZICTnkSqK2UUqrJqhqDM4a fBlmBjfg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syXIN-00000009WKZ-0sGR; Wed, 09 Oct 2024 14:04:07 +0000 Received: from relay8-d.mail.gandi.net ([217.70.183.201]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syXFX-00000009VIl-0MQD for linux-arm-kernel@lists.infradead.org; Wed, 09 Oct 2024 14:01:14 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 38E7E1BF209; Wed, 9 Oct 2024 14:01:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728482469; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=51tFhwkIfjKQ6rs73rgZmRnnNukZhWLjQRX8i+8ldQ4=; b=fgy1aY3lMaGsku5c0wMK7goxdf6EpwET4Lj+sHWKLdxzWf1H4X7BS1TgDXcx2PHQzAnPtY mtMAsnTgjEGP3Tt03BpBIuXkK8+xrTj3V3+4UGNTu5HGbMnJWlgvST8lfyVa8HtAXRtS/G a5iHduX3rgjlxxqjwb1XzltPNNKNsNvXmOWZqcIIeVB4cq9I1xq81q79CYPjaGrftmUTU9 PhB9/CQykCjNSV2sOEwHPWBmn2BVOwgYpQhcJdJ+R1tE9bSo2jgEbchHyrOkBkx5tTGzVD Kzonp6YG6j7Ve/d5rE2gAEteZYx4T7IwvPyOSf2OSQCv2L8E38G+zy7dgzhaKQ== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Wed, 09 Oct 2024 16:01:09 +0200 Subject: [PATCH v3 3/6] i2c: nomadik: switch from of_device_is_compatible() to of_match_device() MIME-Version: 1.0 Message-Id: <20241009-mbly-i2c-v3-3-e7fd13bcf1c4@bootlin.com> References: <20241009-mbly-i2c-v3-0-e7fd13bcf1c4@bootlin.com> In-Reply-To: <20241009-mbly-i2c-v3-0-e7fd13bcf1c4@bootlin.com> To: Linus Walleij , Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Vladimir Kondratiev , =?utf-8?q?Gr=C3=A9?= =?utf-8?q?gory_Clement?= , Thomas Petazzoni , Tawfik Bayouk , =?utf-8?q?Th=C3=A9o_Lebrun?= X-Mailer: b4 0.14.2 X-GND-Sasl: theo.lebrun@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241009_070111_470536_1978ED41 X-CRM114-Status: GOOD ( 18.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Compatible-specific behavior is implemented using a if-condition on the return value from of_device_is_compatible(), from probe. It does not scale well when compatible number increases. Switch to using a match table and a call to of_match_device(). We DO NOT attach a .of_match_table field to our amba driver, as we do not use the table to match our driver to devices. Sort probe variable declarations in reverse christmas tree to try and introduce some logic into the ordering. Reviewed-by: Linus Walleij Signed-off-by: Théo Lebrun --- drivers/i2c/busses/i2c-nomadik.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index ad0f02acdb1215a1c04729f97bb14a4d93f88456..c40328d1bca6cdefc61906cf9160f8411e37922a 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -1046,8 +1047,6 @@ static int nmk_i2c_eyeq5_probe(struct nmk_i2c_dev *priv) struct regmap *olb; unsigned int id; - priv->has_32b_bus = true; - olb = syscon_regmap_lookup_by_phandle_args(np, "mobileye,olb", 1, &id); if (IS_ERR(olb)) return PTR_ERR(olb); @@ -1068,15 +1067,35 @@ static int nmk_i2c_eyeq5_probe(struct nmk_i2c_dev *priv) return 0; } +#define NMK_I2C_EYEQ_FLAG_32B_BUS BIT(0) +#define NMK_I2C_EYEQ_FLAG_IS_EYEQ5 BIT(1) + +static const struct of_device_id nmk_i2c_eyeq_match_table[] = { + { + .compatible = "mobileye,eyeq5-i2c", + .data = (void *)(NMK_I2C_EYEQ_FLAG_32B_BUS | NMK_I2C_EYEQ_FLAG_IS_EYEQ5), + }, +}; + static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id) { - int ret = 0; - struct nmk_i2c_dev *priv; - struct device_node *np = adev->dev.of_node; - struct device *dev = &adev->dev; - struct i2c_adapter *adap; struct i2c_vendor_data *vendor = id->data; u32 max_fifo_threshold = (vendor->fifodepth / 2) - 1; + struct device_node *np = adev->dev.of_node; + const struct of_device_id *match; + struct device *dev = &adev->dev; + unsigned long match_flags = 0; + struct nmk_i2c_dev *priv; + struct i2c_adapter *adap; + int ret = 0; + + /* + * We do not want to attach a .of_match_table to our amba driver. + * Do not convert to device_get_match_data(). + */ + match = of_match_device(nmk_i2c_eyeq_match_table, dev); + if (match) + match_flags = (unsigned long)match->data; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) @@ -1084,10 +1103,10 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id) priv->vendor = vendor; priv->adev = adev; - priv->has_32b_bus = false; + priv->has_32b_bus = match_flags & NMK_I2C_EYEQ_FLAG_32B_BUS; nmk_i2c_of_probe(np, priv); - if (of_device_is_compatible(np, "mobileye,eyeq5-i2c")) { + if (match_flags & NMK_I2C_EYEQ_FLAG_IS_EYEQ5) { ret = nmk_i2c_eyeq5_probe(priv); if (ret) return dev_err_probe(dev, ret, "failed OLB lookup\n"); From patchwork Wed Oct 9 14:01:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Th=C3=A9o_Lebrun?= X-Patchwork-Id: 13828488 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5C83ECEDD9A for ; Wed, 9 Oct 2024 14:09:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2PT2bSMDA58VSAM1Q9Akc5IbSMb7rRJeyxTRzP7FAJ8=; b=1liBCxrnSARGuKO9KgBLajK3NZ eO+4jqNlT18oR3MUOS3ggC1OX0KbtRJd6ahwmsHEK1hBVCBhjn1tsoGN+jvQhoS1c2fcSzUybMGhR +HsyOzgweDwKtlLBKc0LrwkCDS3IBEnXwhs5mE7lmI/KwmDv4emdh7X1+dtHSdAM5ZZpJj8wWiWyR G77afQGOUS6G4mV2iMJHu93ccAejbDcjvYVv6cv72eppT9jpnkfgWREsqwtkbOK6WHbh50n+bHzt6 PLi+ZyDqUG7lLDCPDBtz7wOYi5ju2XeN5Rp/tJ5KjZBsrs/lH++9BDjehOJ0B7VnozUxGEqBtmOMf dZmwFSSw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syXNY-00000009XBF-33aH; Wed, 09 Oct 2024 14:09:28 +0000 Received: from relay8-d.mail.gandi.net ([2001:4b98:dc4:8::228]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syXFb-00000009VIs-0Wfp for linux-arm-kernel@lists.infradead.org; Wed, 09 Oct 2024 14:01:16 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id CF36E1BF20E; Wed, 9 Oct 2024 14:01:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728482470; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2PT2bSMDA58VSAM1Q9Akc5IbSMb7rRJeyxTRzP7FAJ8=; b=a8NfnaQsS+Jzoxbcv4gY17SL9n5+x7zfsvdNPXdI7XrpvaBaq17tS1D6Z7tQoR/AR3v0Xj McNGKxxGqo4HO/Vjt8+zswwAcVGpbaI4e2eZ9PAPFAm+I1BsI0IYPTa8wiOFdAUehrpkWG tP4RVgDdkcNc8JVRhjQ+opJMDk4r7ll1C3M+SAXbkYG7e1JYjvDAUfBcTbWeV74X+EzEO6 /9dSzBoyWKzZA6kVEvkhloI2twwTjeI6xlvE4YoyvbCj4vlibBKTP4OoBYzCKBKy9+BRhe tRMugjaYSLFUnM6eRhszVB2Kgd/0LVehoLnntwuy8z5ulKblxUnF1FJ92OB5zA== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Wed, 09 Oct 2024 16:01:10 +0200 Subject: [PATCH v3 4/6] i2c: nomadik: support Mobileye EyeQ6H I2C controller MIME-Version: 1.0 Message-Id: <20241009-mbly-i2c-v3-4-e7fd13bcf1c4@bootlin.com> References: <20241009-mbly-i2c-v3-0-e7fd13bcf1c4@bootlin.com> In-Reply-To: <20241009-mbly-i2c-v3-0-e7fd13bcf1c4@bootlin.com> To: Linus Walleij , Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Vladimir Kondratiev , =?utf-8?q?Gr=C3=A9?= =?utf-8?q?gory_Clement?= , Thomas Petazzoni , Tawfik Bayouk , =?utf-8?q?Th=C3=A9o_Lebrun?= X-Mailer: b4 0.14.2 X-GND-Sasl: theo.lebrun@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241009_070115_561274_F8A2A8EE X-CRM114-Status: GOOD ( 13.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add EyeQ6H support to the nmk-i2c AMBA driver. It shares the same quirk as EyeQ5: the memory bus only supports 32-bit accesses. Avoid writeb() and readb() by reusing the same `priv->has_32b_bus` flag. It does NOT need to write speed-mode specific value into a register; therefore it does not depend on the mobileye,olb DT property. Reviewed-by: Linus Walleij Signed-off-by: Théo Lebrun --- drivers/i2c/busses/i2c-nomadik.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index c40328d1bca6cdefc61906cf9160f8411e37922a..8f52ae4d6285af2dd2b3dc7070672757e831a019 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -6,10 +6,10 @@ * I2C master mode controller driver, used in Nomadik 8815 * and Ux500 platforms. * - * The Mobileye EyeQ5 platform is also supported; it uses + * The Mobileye EyeQ5 and EyeQ6H platforms are also supported; they use * the same Ux500/DB8500 IP block with two quirks: * - The memory bus only supports 32-bit accesses. - * - A register must be configured for the I2C speed mode; + * - (only EyeQ5) A register must be configured for the I2C speed mode; * it is located in a shared register region called OLB. * * Author: Srinidhi Kasagar @@ -1075,6 +1075,10 @@ static const struct of_device_id nmk_i2c_eyeq_match_table[] = { .compatible = "mobileye,eyeq5-i2c", .data = (void *)(NMK_I2C_EYEQ_FLAG_32B_BUS | NMK_I2C_EYEQ_FLAG_IS_EYEQ5), }, + { + .compatible = "mobileye,eyeq6h-i2c", + .data = (void *)NMK_I2C_EYEQ_FLAG_32B_BUS, + }, }; static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id) From patchwork Wed Oct 9 14:01:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Th=C3=A9o_Lebrun?= X-Patchwork-Id: 13828487 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B4B58CEDD99 for ; Wed, 9 Oct 2024 14:08:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=21HMetQOB+SaHvQI49UY0p8Ueen8RrlyJb33LwQyLmE=; b=ujul7DbainQEQnA/WdtMBT2BI+ PBjJdK+ZZAK18sfYU101mcK9H6hPFkSrF2Ql9suU3dA6LacWNTTPSsBOhaBBFzveWkbNd3v6v4kjd fU1CK9QZsSgdrM1prHzNK4+r6xDJks/nNp7WBjyve8xXAqaviwKV9EyVcks+qDvFqGoBL3OmLdrdU 12ylCozSl/HjnIXApq/4QTC1SUuQgYrY3PM457tUB4DCd4K8pVkCCyrcO62pd5kOHcqwqXc77vNtg VbUa3m4VhI1ACmfPxPGY3SEovOvVD2dpmoMcjPNucNMfSFkfzl83goMZcKv2d0iW4QuL1A9gpboJp wWJSU2vw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syXMG-00000009X1c-00GY; Wed, 09 Oct 2024 14:08:08 +0000 Received: from relay8-d.mail.gandi.net ([217.70.183.201]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syXFY-00000009VJ1-1Plb for linux-arm-kernel@lists.infradead.org; Wed, 09 Oct 2024 14:01:14 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 77EEC1BF20D; Wed, 9 Oct 2024 14:01:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728482471; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=21HMetQOB+SaHvQI49UY0p8Ueen8RrlyJb33LwQyLmE=; b=iAQ96K4opWXLxs+g8ssUsorkBfi3YbyCkyZ/iAdhAMOpzQ+lVw2hR/MAMmm8wXXUMcKJmc yQqjrM9z+NDI1KW2Pq35sMwD3GIY4rzeR8kNshzaPsBjClcROU1COWTzwwuBt+B1MB6Kep WxRrkQebHBfe0ub1xb3UFBVkXTmnMpq2cTRDzuAWAfBXYgF++x/jG0ZgPztCCgqDN0KnrU tzchQ4Q206nthTtc61aXfLa7tP1Xy0HJz40rCH9+/jLOZGlSP6ZFzvHrL2azDXOKyPbGm3 PiAsMqvQm9CPKIXS4pEqI0nypV0OHgzz16Kf237yaHvxHk5YxYyOwKpd4u3W5Q== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Wed, 09 Oct 2024 16:01:11 +0200 Subject: [PATCH v3 5/6] i2c: nomadik: fix BRCR computation MIME-Version: 1.0 Message-Id: <20241009-mbly-i2c-v3-5-e7fd13bcf1c4@bootlin.com> References: <20241009-mbly-i2c-v3-0-e7fd13bcf1c4@bootlin.com> In-Reply-To: <20241009-mbly-i2c-v3-0-e7fd13bcf1c4@bootlin.com> To: Linus Walleij , Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Vladimir Kondratiev , =?utf-8?q?Gr=C3=A9?= =?utf-8?q?gory_Clement?= , Thomas Petazzoni , Tawfik Bayouk , =?utf-8?q?Th=C3=A9o_Lebrun?= X-Mailer: b4 0.14.2 X-GND-Sasl: theo.lebrun@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241009_070112_706280_D96B8771 X-CRM114-Status: GOOD ( 11.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Current BRCR computation is: brcr = floor(i2cclk / (clkfreq * div)) With brcr: "baud rate counter", an internal clock divider, and i2cclk: input clock rate (24MHz, 38.4MHz or 48MHz), and clkfreq: desired bus rate, and div: speed-mode dependent divider (2 for standard, 3 otherwise). Assume i2cclk=48MHz, clkfreq=3.4MHz, div=3, then brcr = floor(48MHz / (3.4MHz * 3)) = 4 and resulting bus rate = 48MHz / (4 * 3) = 4MHz Assume i2cclk=38.4MHz, clkfreq=1.0MHz, div=3, then brcr = floor(38.4MHz / (1.0MHz * 3)) = 12 and resulting bus rate = 38.4MHz / (12 * 3) = 1066kHz The current computation means we always pick the smallest divider that gives a bus rate above target. We should instead pick the largest divider that gives a bus rate below target, using: brcr = floor(i2cclk / (clkfreq * div)) + 1 If we redo the above examples: Assume i2cclk=48MHz, clkfreq=3.4MHz, div=3, then brcr = floor(48MHz / (3.4MHz * 3)) + 1 = 5 and resulting bus rate = 48MHz / (5 * 3) = 3.2MHz Assume i2cclk=38.4MHz, clkfreq=1.0MHz, div=3, then brcr = floor(38.4MHz / (1.0MHz * 3)) + 1 = 13 and resulting bus rate = 38.4MHz / (13 * 3) = 985kHz In kernel C code, floor(x) is DIV_ROUND_DOWN() and, floor(x)+1 is DIV_ROUND_UP(). This is much less of an issue with slower bus rates (ie those currently supported), because the gap from one divider to the next is much smaller. It however keeps us from always using bus rates superior to the target. This fix is required for later on supporting faster bus rates: I2C_FREQ_MODE_FAST_PLUS (1MHz) and I2C_FREQ_MODE_HIGH_SPEED (3.4MHz). Signed-off-by: Théo Lebrun Reviewed-by: Linus Walleij --- drivers/i2c/busses/i2c-nomadik.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index 8f52ae4d6285af2dd2b3dc7070672757e831a019..90e3390cd66de5b3aa47d94de7fb30e1d67ac70e 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -454,9 +454,13 @@ static void setup_i2c_controller(struct nmk_i2c_dev *priv) * operation, and the other is for std, fast mode, fast mode * plus operation. Currently we do not supprt high speed mode * so set brcr1 to 0. + * + * BRCR is a clock divider amount. Pick highest value that + * leads to rate strictly below target. Eg when asking for + * 400kHz you want a bus rate <=400kHz (and not >=400kHz). */ brcr1 = FIELD_PREP(I2C_BRCR_BRCNT1, 0); - brcr2 = FIELD_PREP(I2C_BRCR_BRCNT2, i2c_clk / (priv->clk_freq * div)); + brcr2 = FIELD_PREP(I2C_BRCR_BRCNT2, DIV_ROUND_UP(i2c_clk, priv->clk_freq * div)); /* set the baud rate counter register */ writel((brcr1 | brcr2), priv->virtbase + I2C_BRCR); From patchwork Wed Oct 9 14:01:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Th=C3=A9o_Lebrun?= X-Patchwork-Id: 13828491 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6D8D8CEDD9A for ; Wed, 9 Oct 2024 14:12:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=KN4a14PZ8SWOObiK/DnNIgNJ+gCkWYqBAi+54cWiank=; b=WY3d8nasDlHMgMsCpSZoTs4pPW r68pCEFIpbx54Fn9aewMoAiYxDj+tgrwbN8xEWxBsSnzSkzN7S8s3SvEfRG3tKLnHLyhtFBzWpdPE TllXB/jSo+XvMyH48O9pjNjK6hB/C0OfAsLcdF07Hg5HlmmCgO6aVVasZQQ5c7hFjnKyy131zCWDu 2zT+IohBGrD3rGBpxCf3H2eaQyCm/oKBNIVI3G+4HGZBI63tVxwPFkxkedSaCOmQmc9xx13woHVNB OoasoDWotI6dLwNFjMunLKLAlhnAKnbv7nmfA3fcJ3RoSxWYkMwHqsI/rnAf/UEe6PQbKccHwp23Q hxgIi3LA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syXQY-00000009XsN-3X6O; Wed, 09 Oct 2024 14:12:34 +0000 Received: from relay8-d.mail.gandi.net ([2001:4b98:dc4:8::228]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syXFb-00000009VKI-0els for linux-arm-kernel@lists.infradead.org; Wed, 09 Oct 2024 14:01:17 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 0E36B1BF20F; Wed, 9 Oct 2024 14:01:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728482471; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KN4a14PZ8SWOObiK/DnNIgNJ+gCkWYqBAi+54cWiank=; b=V9WBB2Io+6zw/6SSxWaygTW2qxD+pr0kCkqPuKUogz+niFRH/WqurvOvsNdkgvY+v9WG++ 7quuOThLEQrCPzWM8Ot/8Psm8WFsex3ibZ0F+KTBbJqVY6NIW1zVhQ1GOEmiZkYdkyyKtX 0FGJwbqLQqLcXO7LFQdM1PKyQj8aBwhI7bs8FaW4wprwJlp9d4/OQvaVQnN0kRbNHWYMvk l1vxqOQxE4OBHnrNR1Sp8ON8mOLGnVWKtQO1zO0/iCnT9anaXAn+RmNRQ97nNr2LoE53os TnBMJ3AF0UVw3zmaJb08+DptPEPfKb+2nR0sh8WHXaG3h2oD1nzFtrzSjdnw6Q== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Wed, 09 Oct 2024 16:01:12 +0200 Subject: [PATCH v3 6/6] i2c: nomadik: support >=1MHz speed modes MIME-Version: 1.0 Message-Id: <20241009-mbly-i2c-v3-6-e7fd13bcf1c4@bootlin.com> References: <20241009-mbly-i2c-v3-0-e7fd13bcf1c4@bootlin.com> In-Reply-To: <20241009-mbly-i2c-v3-0-e7fd13bcf1c4@bootlin.com> To: Linus Walleij , Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Vladimir Kondratiev , =?utf-8?q?Gr=C3=A9?= =?utf-8?q?gory_Clement?= , Thomas Petazzoni , Tawfik Bayouk , =?utf-8?q?Th=C3=A9o_Lebrun?= X-Mailer: b4 0.14.2 X-GND-Sasl: theo.lebrun@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241009_070116_426053_7603A3C7 X-CRM114-Status: GOOD ( 16.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org - BRCR value must go into the BRCR1 field when in high-speed mode. It goes into BRCR2 otherwise. - Remove fallback to standard mode if priv->sm > I2C_FREQ_MODE_FAST. - Set SM properly in probe; previously it only checked STANDARD versus FAST. Now we set STANDARD, FAST, FAST_PLUS or HIGH_SPEED. - Remove all comment sections saying we only support low-speeds. Reviewed-by: Linus Walleij Signed-off-by: Théo Lebrun --- drivers/i2c/busses/i2c-nomadik.c | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index 90e3390cd66de5b3aa47d94de7fb30e1d67ac70e..efb33802804fdde82fe6d38d4f89d0b898f1667e 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -397,7 +397,7 @@ static u32 load_i2c_mcr_reg(struct nmk_i2c_dev *priv, u16 flags) */ static void setup_i2c_controller(struct nmk_i2c_dev *priv) { - u32 brcr1, brcr2; + u32 brcr; u32 i2c_clk, div; u32 ns; u16 slsu; @@ -444,7 +444,7 @@ static void setup_i2c_controller(struct nmk_i2c_dev *priv) /* * The spec says, in case of std. mode the divider is * 2 whereas it is 3 for fast and fastplus mode of - * operation. TODO - high speed support. + * operation. */ div = (priv->clk_freq > I2C_MAX_STANDARD_MODE_FREQ) ? 3 : 2; @@ -452,34 +452,23 @@ static void setup_i2c_controller(struct nmk_i2c_dev *priv) * generate the mask for baud rate counters. The controller * has two baud rate counters. One is used for High speed * operation, and the other is for std, fast mode, fast mode - * plus operation. Currently we do not supprt high speed mode - * so set brcr1 to 0. + * plus operation. * * BRCR is a clock divider amount. Pick highest value that * leads to rate strictly below target. Eg when asking for * 400kHz you want a bus rate <=400kHz (and not >=400kHz). */ - brcr1 = FIELD_PREP(I2C_BRCR_BRCNT1, 0); - brcr2 = FIELD_PREP(I2C_BRCR_BRCNT2, DIV_ROUND_UP(i2c_clk, priv->clk_freq * div)); + brcr = DIV_ROUND_UP(i2c_clk, priv->clk_freq * div); + + if (priv->sm == I2C_FREQ_MODE_HIGH_SPEED) + brcr = FIELD_PREP(I2C_BRCR_BRCNT1, brcr); + else + brcr = FIELD_PREP(I2C_BRCR_BRCNT2, brcr); /* set the baud rate counter register */ - writel((brcr1 | brcr2), priv->virtbase + I2C_BRCR); + writel(brcr, priv->virtbase + I2C_BRCR); - /* - * set the speed mode. Currently we support - * only standard and fast mode of operation - * TODO - support for fast mode plus (up to 1Mb/s) - * and high speed (up to 3.4 Mb/s) - */ - if (priv->sm > I2C_FREQ_MODE_FAST) { - dev_err(&priv->adev->dev, - "do not support this mode defaulting to std. mode\n"); - brcr2 = FIELD_PREP(I2C_BRCR_BRCNT2, - i2c_clk / (I2C_MAX_STANDARD_MODE_FREQ * 2)); - writel((brcr1 | brcr2), priv->virtbase + I2C_BRCR); - writel(FIELD_PREP(I2C_CR_SM, I2C_FREQ_MODE_STANDARD), - priv->virtbase + I2C_CR); - } + /* set the speed mode */ writel(FIELD_PREP(I2C_CR_SM, priv->sm), priv->virtbase + I2C_CR); /* set the Tx and Rx FIFO threshold */ @@ -1020,11 +1009,14 @@ static void nmk_i2c_of_probe(struct device_node *np, if (of_property_read_u32(np, "clock-frequency", &priv->clk_freq)) priv->clk_freq = I2C_MAX_STANDARD_MODE_FREQ; - /* This driver only supports 'standard' and 'fast' modes of operation. */ if (priv->clk_freq <= I2C_MAX_STANDARD_MODE_FREQ) priv->sm = I2C_FREQ_MODE_STANDARD; - else + else if (priv->clk_freq <= I2C_MAX_FAST_MODE_FREQ) priv->sm = I2C_FREQ_MODE_FAST; + else if (priv->clk_freq <= I2C_MAX_FAST_MODE_PLUS_FREQ) + priv->sm = I2C_FREQ_MODE_FAST_PLUS; + else + priv->sm = I2C_FREQ_MODE_HIGH_SPEED; priv->tft = 1; /* Tx FIFO threshold */ priv->rft = 8; /* Rx FIFO threshold */