Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2265797rdb; Thu, 21 Sep 2023 13:23:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGScq7BijA19hvuUjmTgz8CMHKlihZB9E+ad9fOVB3xrFCZhRkPs+8X6o3kfsGf8QNjeTl0 X-Received: by 2002:a05:6a00:24d2:b0:68f:c057:b54c with SMTP id d18-20020a056a0024d200b0068fc057b54cmr6600637pfv.1.1695327814161; Thu, 21 Sep 2023 13:23:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695327814; cv=none; d=google.com; s=arc-20160816; b=JT4t6gKr6CsJiB3HZ00vKcMeiUQ9hbDqN2tF50wtAm8nTTYM/mfoMJ4iHPCXcvRgnA MDUbtRCzce04GrFmRwswivvIRuxolrZQLaRscPXlmiJy8IxbFRtISsu+30tK3azkLVWe VhLKjOJTu0hN+SSzmO5cW3IkgoEcciWP5kivQheKvz0rzfvUOytkpDLjbM8uytpGjYA1 c7cmdxCrBHt1LdnHfx5h3wFnDcE/itdWEQ9944yma4eK402z0L02gQcgbzDzbbLrrrJ+ BLzkxacAxRc6ylrI7okh/rx7Ei18iYbBw7PIowaM2wHO8JLfU+FMObH3FElWXVysN869 fEjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=yL+B2kLk79R6fDcUtVvh5j8AHYQLWXGyOh4df78oSX0=; fh=ZqJ3xrq0DGyvWtPBQo5VWOM7gaftcxyjM72UWd4YoC8=; b=nDcSApa2QzOEMBcQSKHuWpp2sEC3lTO6u6AgssG7jX/KHe2anxiHwO1AYZ336olfTH Oyu7pQtJFN0oqNbPVVo5F8PkoXIW9xHSpJ3iSwgWOMBDtRp2DnNLJtEmleYqMmMT6sbd TSlky4vSvVWidFsUfQF9C4+oKx5l5773pxlBUwk+SJRElRgB5qBrSYJGrH9nSyDlCqqi ZXxAxq0yvObbQinuvdShN2oh7SvrcsGFPE4owrF9UEOmHTT1tcTuzdkHsGuLDUnhTW+L yI8x/tNGT4I9quft40F0ai73pa/wrMZUGFlqXS8OcOiJ6/ZmWjk1/rby918KeTnQgF2J pRmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id x5-20020a654145000000b0057b55b52870si1838999pgp.170.2023.09.21.13.23.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 13:23:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 00F04803D03E; Thu, 21 Sep 2023 13:08:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230105AbjIUUIa (ORCPT + 99 others); Thu, 21 Sep 2023 16:08:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231462AbjIUT7o (ORCPT ); Thu, 21 Sep 2023 15:59:44 -0400 Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30DF456D3A; Thu, 21 Sep 2023 10:18:27 -0700 (PDT) Received: from SHSQR01.spreadtrum.com (localhost [127.0.0.2] (may be forged)) by SHSQR01.spreadtrum.com with ESMTP id 38L8vCPM047518; Thu, 21 Sep 2023 16:57:12 +0800 (+08) (envelope-from Huangzheng.Lai@unisoc.com) Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 38L8tTPm040533; Thu, 21 Sep 2023 16:55:29 +0800 (+08) (envelope-from Huangzheng.Lai@unisoc.com) Received: from SHDLP.spreadtrum.com (shmbx04.spreadtrum.com [10.0.1.214]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4Rrq093gD3z2SZtbS; Thu, 21 Sep 2023 16:52:09 +0800 (CST) Received: from xm9614pcu.spreadtrum.com (10.13.2.29) by shmbx04.spreadtrum.com (10.0.1.214) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Thu, 21 Sep 2023 16:55:28 +0800 From: Huangzheng Lai To: Andi Shyti CC: Orson Zhai , Baolin Wang , Chunyan Zhang , , , huangzheng lai , Huangzheng Lai , Xiongpeng Wu Subject: [PATCH V2 1/7] i2c: sprd: Add configurations that support 1Mhz and 3.4Mhz frequencies Date: Thu, 21 Sep 2023 16:54:51 +0800 Message-ID: <20230921085457.32446-2-Huangzheng.Lai@unisoc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230921085457.32446-1-Huangzheng.Lai@unisoc.com> References: <20230921085457.32446-1-Huangzheng.Lai@unisoc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.13.2.29] X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To shmbx04.spreadtrum.com (10.0.1.214) X-MAIL: SHSQR01.spreadtrum.com 38L8tTPm040533 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 21 Sep 2023 13:08:50 -0700 (PDT) This patch adds I2C controller driver support for 1Mhz and 3.4Mhz frequency configurations. Signed-off-by: Huangzheng Lai Acked-by: Andi Shyti --- drivers/i2c/busses/i2c-sprd.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/busses/i2c-sprd.c b/drivers/i2c/busses/i2c-sprd.c index ffc54fbf814d..b44916c6741d 100644 --- a/drivers/i2c/busses/i2c-sprd.c +++ b/drivers/i2c/busses/i2c-sprd.c @@ -343,10 +343,23 @@ static void sprd_i2c_set_clk(struct sprd_i2c *i2c_dev, u32 freq) writel(div1, i2c_dev->base + ADDR_DVD1); /* Start hold timing = hold time(us) * source clock */ - if (freq == I2C_MAX_FAST_MODE_FREQ) - writel((6 * apb_clk) / 10000000, i2c_dev->base + ADDR_STA0_DVD); - else if (freq == I2C_MAX_STANDARD_MODE_FREQ) + switch (freq) { + case I2C_MAX_STANDARD_MODE_FREQ: writel((4 * apb_clk) / 1000000, i2c_dev->base + ADDR_STA0_DVD); + break; + case I2C_MAX_FAST_MODE_FREQ: + writel((6 * apb_clk) / 10000000, i2c_dev->base + ADDR_STA0_DVD); + break; + case I2C_MAX_FAST_MODE_PLUS_FREQ: + writel((8 * apb_clk) / 10000000, i2c_dev->base + ADDR_STA0_DVD); + break; + case I2C_MAX_HIGH_SPEED_MODE_FREQ: + writel((8 * apb_clk) / 10000000, i2c_dev->base + ADDR_STA0_DVD); + break; + default: + dev_err(i2c_dev->dev, "Unsupported frequency: %d\n", freq); + break; + } } static void sprd_i2c_enable(struct sprd_i2c *i2c_dev) @@ -519,9 +532,11 @@ static int sprd_i2c_probe(struct platform_device *pdev) if (!of_property_read_u32(dev->of_node, "clock-frequency", &prop)) i2c_dev->bus_freq = prop; - /* We only support 100k and 400k now, otherwise will return error. */ + /* We only support 100k\400k\1m\3.4m now, otherwise will return error. */ if (i2c_dev->bus_freq != I2C_MAX_STANDARD_MODE_FREQ && - i2c_dev->bus_freq != I2C_MAX_FAST_MODE_FREQ) + i2c_dev->bus_freq != I2C_MAX_FAST_MODE_FREQ && + i2c_dev->bus_freq != I2C_MAX_FAST_MODE_PLUS_FREQ && + i2c_dev->bus_freq != I2C_MAX_HIGH_SPEED_MODE_FREQ) return -EINVAL; ret = sprd_i2c_clk_init(i2c_dev); -- 2.17.1