From mboxrd@z Thu Jan 1 00:00:00 1970 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 E15DACEF148 for ; Tue, 8 Oct 2024 10:32:27 +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=PtMmHbPZ23pwesmORM0pCnGzFJGwj7VpWxVSSzjsLkQ=; b=fn91O9Vki20no6MG9RIq3+bHLM 7s6DTNJDyWN8S4v25hiAFbtWlvYuMW2AlDSN9Gikr0G/45nylMu7m9r4ymP9l8wLwDkxETF5SS147 bOWhD7fdnaO49FI1kSAzeZr1mgk1SEoOJ606kG/AFhKSRYpdAKehego6GGKLQmM7MpgESCIg2IeEq n4au4venXFNNornPbnqZdWkLun+YB1FxGoehjD55OzokRGyxvE6p91jUIyExvwYRjwqVXMgAqrgow COuONf4NXfkB1ZrwDECzY3VCUGiTwSb64uYY8d73/WaH15lPxsDt3Vp6+vAwZbAGZLM3avpaU3IpO 8t8ripRw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sy7Vn-00000005TC9-0hlk; Tue, 08 Oct 2024 10:32:15 +0000 Received: from relay4-d.mail.gandi.net ([217.70.183.196]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sy7TP-00000005Sar-3CdZ for linux-arm-kernel@lists.infradead.org; Tue, 08 Oct 2024 10:29:49 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id AFA76E0002; Tue, 8 Oct 2024 10:29:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728383384; 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=PtMmHbPZ23pwesmORM0pCnGzFJGwj7VpWxVSSzjsLkQ=; b=Z7uD+DCK6v4FGhL99TUZKfwrJsnhkqG0UVklqLvkNggxE3Tcpyd1ndQ24xFqjANZZEECjn oKq7L1SwWTZuNfX2uGb6e+dzTjbpEByx3xZqnQ0NhWTdlXFG70uUeYrEdVDEowJbvNDEas xrn8WGlP8+RYZYsCgEMc5z1yFJHAa2QTySSj4kvsKqz8zLN9drSft3vFlee2Tcae3HsjYb 9/imEtE6hfw8KPK5eRH9hTg6tbAhrvRuBMel2fX+mSw3u4Tyd90GMHm9vjWBxgbkXS0/jE GLjkAio7LAR7VMjHsPtQvFtg6sci/z0GupRVmfBKh8bTu0kTO2inc/49maQ25A== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Tue, 08 Oct 2024 12:29:41 +0200 Subject: [PATCH 2/4] i2c: nomadik: support Mobileye EyeQ6H I2C controller MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20241008-mbly-i2c-v1-2-a06c1317a2f7@bootlin.com> References: <20241008-mbly-i2c-v1-0-a06c1317a2f7@bootlin.com> In-Reply-To: <20241008-mbly-i2c-v1-0-a06c1317a2f7@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=A9gory_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-20241008_032948_113824_E40BFE62 X-CRM114-Status: GOOD ( 17.32 ) 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. Refactoring is done using is_eyeq5 and is_eyeq6h boolean local variables. Sort variables in reverse christmas tree to try and introduce some logic into the ordering. Signed-off-by: Théo Lebrun --- drivers/i2c/busses/i2c-nomadik.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index ad0f02acdb1215a1c04729f97bb14a4d93f88456..ea511d3a58073eaedb63850026e05b59427a69c6 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 @@ -1046,8 +1046,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); @@ -1070,13 +1068,15 @@ static int nmk_i2c_eyeq5_probe(struct nmk_i2c_dev *priv) 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; + struct device_node *np = adev->dev.of_node; + bool is_eyeq6h = of_device_is_compatible(np, "mobileye,eyeq6h-i2c"); + bool is_eyeq5 = of_device_is_compatible(np, "mobileye,eyeq5-i2c"); u32 max_fifo_threshold = (vendor->fifodepth / 2) - 1; + struct device *dev = &adev->dev; + struct nmk_i2c_dev *priv; + struct i2c_adapter *adap; + int ret = 0; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) @@ -1084,10 +1084,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 = is_eyeq5 || is_eyeq6h; nmk_i2c_of_probe(np, priv); - if (of_device_is_compatible(np, "mobileye,eyeq5-i2c")) { + if (is_eyeq5) { ret = nmk_i2c_eyeq5_probe(priv); if (ret) return dev_err_probe(dev, ret, "failed OLB lookup\n"); -- 2.46.2