Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1148018rda; Mon, 23 Oct 2023 04:19:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG8C1p4JBCBgSGmXwVBwXya8mr7BF9/2Ct8NCuFEkl3i7ihxkFGvfs5XU6C4NEu5PN7MVJe X-Received: by 2002:a05:6a20:da9f:b0:16b:c20d:fcd1 with SMTP id iy31-20020a056a20da9f00b0016bc20dfcd1mr13018120pzb.21.1698059958383; Mon, 23 Oct 2023 04:19:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698059958; cv=none; d=google.com; s=arc-20160816; b=J9WKUFN8IOkCV1yVAAcYqfSeIGsIc/JSKinDPXJ0Wn3KNRk6Pw1SUkeVmJlXfQVCjj F5H1fmJNMjtA+FK4I9OqKNjmRATVL+ct78AJvE9iuZz7537mPYXHLRSQPYVavjHKangG TI+ZIPzImpY9f+FWpj5OSO+KGVjs/bURtSLsxUnp6xNQPdYZci0R4zc74yymnLUCyuQQ Rh6v8uqiDgxcqpisMybisjpTZfyB7JeH8egTNltEgZjn3JrPAdw4YBC4JnwVkVUs5fkC hQILGM28eVFgYY5WNCuHJqVoNCmcNbR0gcR1xiMQ7IgZOuTMzUg1f0KqP9h2YCoGw1Ux SDOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=LANd1J3pJrPnsn8a4Ch33vsZvT4vibhoWLQH1V4lFbY=; fh=tr/fgHUcpLpbS4VIozjfnV7mG4hJKNrvAEbZeaGGeJc=; b=ILbfB686zYmTpMHlMnMfgLvFpEp+IeTMquWO0RYQe/hr0lsatrGakN8MalMfkUOEg5 k2Od5fAnBcsKZPUhWcH+iEjtlcIoWYXU/hyKATBa4UO82DmC37FBhzB2GQPwUdan6dwO 6xkxPh1iCcBuBYwWDGy6IrAc+48UixONEmyizPjrjKZlv1CoHnW8Nsrv5ckhWyYhH20s WGzejEooKLAEb0YXZZ2b9x+KduR7oAjNIRemjoxqSypzMkZc+P7gx7yjTxQBX8gnPiGg 3cBQrYVQo3OVGhNr/9QDk7IqEAwoX7IzxXPH9xEqmeGksCAh9zL1+5sSJrNJAd0k3Xo0 6wgw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id 145-20020a630097000000b005b7e6ff6c01si6147058pga.677.2023.10.23.04.19.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 04:19:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 151048040380; Mon, 23 Oct 2023 04:19:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233765AbjJWLTI (ORCPT + 99 others); Mon, 23 Oct 2023 07:19:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233548AbjJWLTH (ORCPT ); Mon, 23 Oct 2023 07:19:07 -0400 Received: from out30-118.freemail.mail.aliyun.com (out30-118.freemail.mail.aliyun.com [115.124.30.118]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8EBF92; Mon, 23 Oct 2023 04:19:04 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0VukswFj_1698059941; Received: from 30.97.48.63(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VukswFj_1698059941) by smtp.aliyun-inc.com; Mon, 23 Oct 2023 19:19:01 +0800 Message-ID: <9b623c51-2052-9c0e-9ef7-6e9d841ad5ce@linux.alibaba.com> Date: Mon, 23 Oct 2023 19:19:17 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH V2 1/7] i2c: sprd: Add configurations that support 1Mhz and 3.4Mhz frequencies To: Huangzheng Lai , Andi Shyti Cc: Orson Zhai , Chunyan Zhang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, huangzheng lai , Xiongpeng Wu References: <20231023081158.10654-1-Huangzheng.Lai@unisoc.com> <20231023081158.10654-2-Huangzheng.Lai@unisoc.com> From: Baolin Wang In-Reply-To: <20231023081158.10654-2-Huangzheng.Lai@unisoc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.1 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.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 (morse.vger.email [0.0.0.0]); Mon, 23 Oct 2023 04:19:16 -0700 (PDT) On 10/23/2023 4:11 PM, Huangzheng Lai wrote: > 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) Can you keep the same alignment format as the previous code? Otherwise look good to me. Reviewed-by: Baolin Wang