Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2141582rda; Tue, 24 Oct 2023 13:45:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFbvCxSEoNnOZHNawAioUWQY3c+/KywVy906kPLMnfQVqbgENAYiJ6Jb//3tpiQvp7ZSYrJ X-Received: by 2002:a17:90a:1d9:b0:27c:fb63:9c89 with SMTP id 25-20020a17090a01d900b0027cfb639c89mr13824774pjd.0.1698180337625; Tue, 24 Oct 2023 13:45:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698180337; cv=none; d=google.com; s=arc-20160816; b=LZSRu75dYheMBmMIQf2VtGjMTGyfrcLA89Rmi8UL5pKZUpAPW9TvUGlNy8Lk5JHN1c Ld2AVQPOIrLZc8REhlizCNCcvgdEnfLT8Aw7OUS2ga7f5HcYXMgeVdMDxCQebpto0p9k DB4QXwEFgkcafWpzs4As30Mok00ntJ8pWIbus0fbitF2BDlJEwUyihSFKnp2yDLfU3PI wqceocwLuWZA3Uw57ija3+MsLIrCBk6JEhZIZvvqnHjr3N6MguOSVi+h2pK9wScQHKhc OOa0DYo+ZxNEmTgjPiqZSGC+bef3t9U1LQkwk3FHbkgOsUgdEg+4LO30jgBnxj0DXxpq r/zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ydChYp02JdZCTZS8+DqvPBOgTumcxuGeE5IJVT1cApI=; fh=SwXRDT3wef7eYr+GiOVvHhMXJPt0P6DhPR6I4tBQCDQ=; b=vkK+UNjJf9I1VxWW57pR+RVszM+zrxnNSgs5CueSnJDqAbX+Rnsat2/cA6oGXw+py2 KR4WvhH5jg/h/DdGoQcoprZUz20Zv4J0EQVpts46hYuQq5X1yS9hLZVyThAiEt1kdipp Fmrleh4cc4vQAgXPqiDkOwOTbnUKUNs5gP2HCzj3Lj2qMSja2AL+JqdTc5E0WU8gTtNm z9nEsOkXS8by2CUwGwwvoFuNc7UzEySQdY5KyCm6m+47Or/N3dNum/U+GyImda6Ts6KE FiIW8wkM8MWajTFrTdk7/qNOjEfE9KV6uwqFqeMzfK8KP0swVPnohz6FvMOfgXDjpnoB UNbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="M8hx/GLv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id nv9-20020a17090b1b4900b002791a73ab07si9395112pjb.54.2023.10.24.13.45.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 13:45:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="M8hx/GLv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 4A5FC80681EF; Tue, 24 Oct 2023 13:45:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344129AbjJXUpX (ORCPT + 99 others); Tue, 24 Oct 2023 16:45:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232399AbjJXUpV (ORCPT ); Tue, 24 Oct 2023 16:45:21 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D520F10CE; Tue, 24 Oct 2023 13:45:19 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0104C433C8; Tue, 24 Oct 2023 20:45:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698180319; bh=63z3mlCd2bt7TLC2rgpK22XXpUyWBM3XWwyJwKwVcdQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=M8hx/GLvW100t1CqGc4S2MJRFmDcQ+LGLfN46BJqv1FvMwlfj/E8ZZ1GETqW8mtA6 YEn+V8M2jPbJPIbhS27Jx3w05BRTeOYex8TWiBgqGu5BhxyCjsCjyrCPDBSeVerxh+ 1hDVufmVTTGsu6qM8Uy/1omphgUKFx6x1nl72XLb3YE8nm5wUgXEo2+p//wqS6H5we MW9pcqWdzAfReIT+fh+HbWvDb4Cwz9rZ05E6HF59ZY9X0uPA40yHPgXDfv5ogySMqU ANn/d8Ems9MH/h0bVHQEV1tbEQElgwbVvhGJIjR8Y6AqUEkqcUaaO3JdasmRMMxJ3j zL4w5qOFvmwOw== Date: Tue, 24 Oct 2023 22:45:15 +0200 From: Andi Shyti To: Huangzheng Lai Cc: Orson Zhai , Baolin Wang , Chunyan Zhang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, huangzheng lai , Xiongpeng Wu Subject: Re: [PATCH V2 1/7] i2c: sprd: Add configurations that support 1Mhz and 3.4Mhz frequencies Message-ID: <20231024204515.vsmu5sllt7qafbq4@zenone.zhora.eu> References: <20231023081158.10654-1-Huangzheng.Lai@unisoc.com> <20231023081158.10654-2-Huangzheng.Lai@unisoc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231023081158.10654-2-Huangzheng.Lai@unisoc.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Tue, 24 Oct 2023 13:45:35 -0700 (PDT) Hi Huangzheng, On Mon, Oct 23, 2023 at 04:11:52PM +0800, Huangzheng Lai wrote: > Add support for 1Mhz and 3.4Mhz frequency configuration. > > Signed-off-by: Huangzheng Lai > Acked-by: Andi Shyti you can make this: Reviewed-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; so these were defined but not used. > + 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; This is a bit of a weird management of the bus_freq because it goes like this: i2c_dev->bus_freq = I2C_MAX_STANDARD_MODE_FREQ; ... if (!of_property_read_u32(dev->of_node, "clock-frequency", &prop)) i2c_dev->bus_freq = prop; if (...) return -EINVAL; A follow-up cleanup can be removing the first assignement and instead of returning -EINVAL, we can keep going: if (!of_property_read_u32(dev->of_node, "clock-frequency", &prop)) i2c_dev->bus_freq = prop; if (...) { dev_warn("..."); i2c_dev->bus_freq = I2C_MAX_STANDARD_MODE_FREQ; } But this is topic for a different patch. Andi > > ret = sprd_i2c_clk_init(i2c_dev); > -- > 2.17.1 >