Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1072652rda; Mon, 23 Oct 2023 01:13:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG1koUXIWtI97BOCKU/Uxb+zl0kEA71O532VOTvc8cw0xX/3U6wwCZgRSY+VNW2RTSPFcWp X-Received: by 2002:a05:6a00:1595:b0:6be:22db:7a13 with SMTP id u21-20020a056a00159500b006be22db7a13mr6341391pfk.25.1698048812197; Mon, 23 Oct 2023 01:13:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698048812; cv=none; d=google.com; s=arc-20160816; b=UKUdRaZ/uGmhWAIwuUNqD/fQLt33GMjMrbB01CmzNxmK5MDyI65kcY9FmahJawPJoc 9dvMJocvIWgknFTvEihVOdxpCXiOS78zx8v8BtFUsJpnKCL8KRbRqoXlSIw7SA4M2y5y trFPXnIHGWvoRNZXgq2lRCJ5NZAAtROh0xVXDPj05NrMFuM3XiyrBOBwaZw3IMCHCbUK KSlDo1ZMDGbhGAvFjt2rPamNpbKQzvk/o78NzDw4xyZfuzUQGVHAUGdk++eoZBFT4EWM D5Wf2dz91T/RC2L0TZ3jNUU2Q/Zp0bmUmSFDfRZuX5142vNnWPBZDj5tlQQSxSWeeXwk aweg== 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=lWtPGgA2CTNG/FvY1S0LCnG31r7erzfeswL3QYMJVTc=; fh=ZqJ3xrq0DGyvWtPBQo5VWOM7gaftcxyjM72UWd4YoC8=; b=sTVmlJHQH4BwvbZJRKIPU8weuZwo5Iz6lI+YSB3kVHgyqyJVJSn+wcRB/gtRRnBj+9 iaMFslC7RqaoEGEr2FFMx/Kzi8rSgi3jRhtmPD2mkHu8wwMjKfid8KDUsUjPwH8Q1Bcy NYkg9zA2Hob4dYXyZPgdGwGs0TQJWAxy7gOx9VIsG7b+Sz2s2Jd0PoC3GzE7cm/DurNQ jdjFxoMJA/mJIuUBQDhum9OtZ3jcZoiJd4wvFTE5oPQ0HMMgNyscshCof5MC0Ykkyk8J 7zmH824NqrKW7aPC4H75Mm1wPuBqUjwF7A0JrSZTEVrX9NTvY7pUKbhIupen4TSHtZ1x hmYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id h184-20020a6383c1000000b005ad5178d053si5930911pge.347.2023.10.23.01.13.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 01:13:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 059B18096A5B; Mon, 23 Oct 2023 01:13:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231909AbjJWINP (ORCPT + 99 others); Mon, 23 Oct 2023 04:13:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231149AbjJWIM6 (ORCPT ); Mon, 23 Oct 2023 04:12:58 -0400 Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B28910F7; Mon, 23 Oct 2023 01:12:55 -0700 (PDT) Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 39N8CTrq060057; Mon, 23 Oct 2023 16:12: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 4SDSVZ53kgz2LHnPx; Mon, 23 Oct 2023 16:08:06 +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; Mon, 23 Oct 2023 16:12:27 +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: Mon, 23 Oct 2023 16:11:52 +0800 Message-ID: <20231023081158.10654-2-Huangzheng.Lai@unisoc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231023081158.10654-1-Huangzheng.Lai@unisoc.com> References: <20231023081158.10654-1-Huangzheng.Lai@unisoc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.13.2.29] X-ClientProxiedBy: SHCAS01.spreadtrum.com (10.0.1.201) To shmbx04.spreadtrum.com (10.0.1.214) X-MAIL: SHSQR01.spreadtrum.com 39N8CTrq060057 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 fry.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 (fry.vger.email [0.0.0.0]); Mon, 23 Oct 2023 01:13:28 -0700 (PDT) Add support for 1Mhz and 3.4Mhz frequency configuration. 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