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 X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09BD9C433DB for ; Tue, 16 Feb 2021 22:10:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D473564E7C for ; Tue, 16 Feb 2021 22:10:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229912AbhBPWKR (ORCPT ); Tue, 16 Feb 2021 17:10:17 -0500 Received: from smtp2.axis.com ([195.60.68.18]:30576 "EHLO smtp2.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229722AbhBPWKQ (ORCPT ); Tue, 16 Feb 2021 17:10:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1613513416; x=1645049416; h=date:to:cc:subject:message-id:references:mime-version: content-transfer-encoding:in-reply-to:from; bh=jlpRjvnBwlHe14+tAbAX/DLQjSwvp1QJtpM4pjNbj+w=; b=koZW1J88s94/NDcC1oWaVm1zVQkL5Z2wdkjfV3Vje93/A/z8pQNDw5mH sOvszUwedB2qXASz/8Na0aeSXySaRoVSc6r5xDJ9/te2Y7x6syLDHulNr jmj6Tm+mnK4hX91r4yZrIaerLkO/Uki46O9MLEoq/K+YcF5MRBPkgj76u Js71hQqRr0TJu3a2XWd1iYcYrhFy82ouu3E7P/3zQKgLU7NF6jLS+5Cip IfIpx7RpAycXaZQSWtuBrRyafbIvMDdpFQ1TtqemGiusnDV2Mky8RnW08 0xhpvfOR/GmAxBb44aIt/29YLjckUmCBL9T6VkDp0XieHTtvoeUXO/qBl w==; Date: Tue, 16 Feb 2021 23:09:33 +0100 To: Krzysztof Kozlowski CC: , , , , Subject: Re: [PATCH] i2c: exynos5: Preserve high speed master code Message-ID: <20210216220933.2wzmft72bhjptzl3@axis.com> References: <20210215190322.22094-1-marten.lindahl@axis.com> <20210216075141.o4wjnwmmjze2p3cn@kozik-lap> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210216075141.o4wjnwmmjze2p3cn@kozik-lap> User-Agent: NeoMutt/20170113 (1.7.2) From: Marten Lindahl Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Hi Krzysztof! Thank you for your comments! Please see my reply below. I will send v2 in a moment. On Tue, Feb 16, 2021 at 08:51:41AM +0100, Krzysztof Kozlowski wrote: > On Mon, Feb 15, 2021 at 08:03:21PM +0100, Mårten Lindahl wrote: > > From: Mårten Lindahl > > > > When the controller starts to send a message with the MASTER_ID field > > set (high speed), the whole I2C_ADDR register is overwritten including > > MASTER_ID as the SLV_ADDR_MAS field is set. > > Are you here describing bug in driver or hardware (the controller?)? > Looking at the code, I think the driver, but description got me > confused. > Yes, it is the driver. I will change. > > > > This patch preserves already written fields in I2C_ADDR when writing > > SLV_ADDR_MAS. > > > > Signed-off-by: Mårten Lindahl > > --- > > drivers/i2c/busses/i2c-exynos5.c | 8 +++++++- > > 1 file changed, 7 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/i2c/busses/i2c-exynos5.c b/drivers/i2c/busses/i2c-exynos5.c > > index 20a9881a0d6c..f2d04c241299 100644 > > --- a/drivers/i2c/busses/i2c-exynos5.c > > +++ b/drivers/i2c/busses/i2c-exynos5.c > > @@ -606,6 +606,7 @@ static void exynos5_i2c_message_start(struct exynos5_i2c *i2c, int stop) > > u32 i2c_ctl; > > u32 int_en = 0; > > u32 i2c_auto_conf = 0; > > + u32 i2c_addr = 0; > > u32 fifo_ctl; > > unsigned long flags; > > unsigned short trig_lvl; > > @@ -640,7 +641,12 @@ static void exynos5_i2c_message_start(struct exynos5_i2c *i2c, int stop) > > int_en |= HSI2C_INT_TX_ALMOSTEMPTY_EN; > > } > > > > - writel(HSI2C_SLV_ADDR_MAS(i2c->msg->addr), i2c->regs + HSI2C_ADDR); > > + i2c_addr = HSI2C_SLV_ADDR_MAS(i2c->msg->addr); > > + > > + if (i2c->op_clock >= I2C_MAX_FAST_MODE_PLUS_FREQ) > > + i2c_addr |= readl(i2c->regs + HSI2C_ADDR); > > Any reason why not "|= MASTER_ID(i2c->adap.nr)" here instead of more > expensive IO read? It's quite important because your current code will > bitwise-or old I2C slave address with a new one... This should break > during tests with multiple I2C slave devices, shouldn't it? > You are correct. It is better to use the macro instead, and yes, safer too. I only have one device that supports high speed i2c, but I get your point. It could potentially break. > On which HW did you test it? I used an Artpec development board as master and INA230EVM board as slave. > > Best regards, > Krzysztof > Best regards Mårten > > > + > > + writel(i2c_addr, i2c->regs + HSI2C_ADDR); 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 X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAEC5C433DB for ; Tue, 16 Feb 2021 22:10:47 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A7FA364E04 for ; Tue, 16 Feb 2021 22:10:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A7FA364E04 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=axis.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:From:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=eiTpbM59hNFGeEMpdn7CJ+50dBBbhLsk3/+1TTyQutw=; b=CVkoz5ZAvadXNnWMvUx7Kl8J9 PW4qL2MHypXH8ib+4JIP7mZ62A8GAf44hHqrmHSTJsPdDgBuZ1usvlheJj5mEenhGTWjUbD/LOXwI rPD9USU8SVEqL1HgVBDtNA6kN77CfpopdIhpx9ug88OCA33xzjUeSev+FKILe8SOGjaFW6rZLZe+B Myrvp20xVzf/BWI/l/OfFlwQMfl0gwlvAHsRXU3FdCXXNv9Fj972oxWj8nYKrhfOplAvZSkKQU+km 3G+XcAeVQsDrYi2cnARJ71dtnfqKmDFa+tCXekMSWxj+8shJG4tQHXAbpSk5tGVMeKy61KKZaZyZ3 gbh9oeauQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lC8XN-0000ie-AO; Tue, 16 Feb 2021 22:09:41 +0000 Received: from smtp2.axis.com ([195.60.68.18]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lC8XK-0000iH-3L for linux-arm-kernel@lists.infradead.org; Tue, 16 Feb 2021 22:09:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1613513378; x=1645049378; h=date:to:cc:subject:message-id:references:mime-version: content-transfer-encoding:in-reply-to:from; bh=jlpRjvnBwlHe14+tAbAX/DLQjSwvp1QJtpM4pjNbj+w=; b=BK7JpEDk8JQc+p6/LwLX/hmt1KA4SPfZohEKBeg/7DyTVdYSzZ615+i0 DU8yQlVQys5afZDRC8PYddnJkT2bWTB/V5HX2w9Gb25QbqULkM2wJ6sTy VYr6/MZm86zOeXBKAWMUXxMcVIftvLcj/lF2nnwcLyIqiMjJRbdn5JY6M vPVVQzTxf0BRfuTmQ1GD7Xc2wAjWSOVj8ar+W3ePb2HmUYiPgjO4Fk5+N HtWABFshcDEqQwtW7N6ef+Tqzc8T9m0y0mu+iUYATfwXWlXGQtPsoerrS h6RwPIxDeH18WsJ0mH+EclJ047tqXwZ8MCu3QTTfF2lWALFHTol8JhwCb Q==; Date: Tue, 16 Feb 2021 23:09:33 +0100 To: Krzysztof Kozlowski Subject: Re: [PATCH] i2c: exynos5: Preserve high speed master code Message-ID: <20210216220933.2wzmft72bhjptzl3@axis.com> References: <20210215190322.22094-1-marten.lindahl@axis.com> <20210216075141.o4wjnwmmjze2p3cn@kozik-lap> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210216075141.o4wjnwmmjze2p3cn@kozik-lap> User-Agent: NeoMutt/20170113 (1.7.2) From: Marten Lindahl X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210216_170938_703795_28D7C651 X-CRM114-Status: GOOD ( 24.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-samsung-soc@vger.kernel.org, kernel@axis.com, linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Krzysztof! Thank you for your comments! Please see my reply below. I will send v2 in a moment. On Tue, Feb 16, 2021 at 08:51:41AM +0100, Krzysztof Kozlowski wrote: > On Mon, Feb 15, 2021 at 08:03:21PM +0100, M=E5rten Lindahl wrote: > > From: M=E5rten Lindahl > > = > > When the controller starts to send a message with the MASTER_ID field > > set (high speed), the whole I2C_ADDR register is overwritten including > > MASTER_ID as the SLV_ADDR_MAS field is set. > = > Are you here describing bug in driver or hardware (the controller?)? > Looking at the code, I think the driver, but description got me > confused. > = Yes, it is the driver. I will change. > > = > > This patch preserves already written fields in I2C_ADDR when writing > > SLV_ADDR_MAS. > > = > > Signed-off-by: M=E5rten Lindahl > > --- > > drivers/i2c/busses/i2c-exynos5.c | 8 +++++++- > > 1 file changed, 7 insertions(+), 1 deletion(-) > > = > > diff --git a/drivers/i2c/busses/i2c-exynos5.c b/drivers/i2c/busses/i2c-= exynos5.c > > index 20a9881a0d6c..f2d04c241299 100644 > > --- a/drivers/i2c/busses/i2c-exynos5.c > > +++ b/drivers/i2c/busses/i2c-exynos5.c > > @@ -606,6 +606,7 @@ static void exynos5_i2c_message_start(struct exynos= 5_i2c *i2c, int stop) > > u32 i2c_ctl; > > u32 int_en =3D 0; > > u32 i2c_auto_conf =3D 0; > > + u32 i2c_addr =3D 0; > > u32 fifo_ctl; > > unsigned long flags; > > unsigned short trig_lvl; > > @@ -640,7 +641,12 @@ static void exynos5_i2c_message_start(struct exyno= s5_i2c *i2c, int stop) > > int_en |=3D HSI2C_INT_TX_ALMOSTEMPTY_EN; > > } > > = > > - writel(HSI2C_SLV_ADDR_MAS(i2c->msg->addr), i2c->regs + HSI2C_ADDR); > > + i2c_addr =3D HSI2C_SLV_ADDR_MAS(i2c->msg->addr); > > + > > + if (i2c->op_clock >=3D I2C_MAX_FAST_MODE_PLUS_FREQ) > > + i2c_addr |=3D readl(i2c->regs + HSI2C_ADDR); > = > Any reason why not "|=3D MASTER_ID(i2c->adap.nr)" here instead of more > expensive IO read? It's quite important because your current code will > bitwise-or old I2C slave address with a new one... This should break > during tests with multiple I2C slave devices, shouldn't it? > = You are correct. It is better to use the macro instead, and yes, safer too. I only have one device that supports high speed i2c, but I get your point. It could potentially break. > On which HW did you test it? I used an Artpec development board as master and INA230EVM board as slave. > = > Best regards, > Krzysztof > = Best regards M=E5rten > = > > + > > + writel(i2c_addr, i2c->regs + HSI2C_ADDR); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel