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 Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AABE6C433F5 for ; Sat, 18 Dec 2021 13:43:06 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1D89F82FE0; Sat, 18 Dec 2021 14:43:03 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1639834983; bh=D1igOokTERGl0A2hkrcDXDaDSqhmZQn3mH/vGtEnwog=; h=Date:Subject:From:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=QYfs2s7c0qI5bcGFpF/GzRugr01l/QBxeDCHvrKfpXfHJD3+pSGQV3aVhdfBp6/Ft DN6Tcx4w83QtB69JGjtmADZhihP2wIfgkhSs5pC+mjxWhQv0FlpVUQBHiu3TnWtrVK e+pJHrSBVNVXTQaaMTJkJfz/4VKvAXkm8BYJpXJc8txH2kmzJkEqKUBb9AftiUKFU+ XizCYBDxlUj5Dl17E6Iu4k0QzqvEuHBGXlsyysTVOhv11Q6iboaElRccMoQBP+3auT IyiaCO80OJnydMExSbmtKVdHcIrBmmQZ8e5gcweejt488mXTpGtQx15Ek7MxeCRdRb EwCOXRI91Qi8w== Received: by phobos.denx.de (Postfix, from userid 109) id 560B980202; Sat, 18 Dec 2021 14:43:01 +0100 (CET) Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [91.198.250.253]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2B5A082FE0 for ; Sat, 18 Dec 2021 14:42:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp202.mailbox.org (unknown [91.198.250.118]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4JGRr14WWnzQjbj; Sat, 18 Dec 2021 14:42:57 +0100 (CET) Message-ID: <3542e49a-aedf-406c-8927-a47fff172f92@denx.de> Date: Sat, 18 Dec 2021 14:42:51 +0100 MIME-Version: 1.0 Subject: Re: [PATCH] i2c: mvtwsi: Swab the register address if its size is > 1 Content-Language: en-US From: Stefan Roese To: u-boot@lists.denx.de Cc: Heiko Schocher , Samuel Holland , Baruch Siach , =?UTF-8?Q?Pali_Roh=c3=a1r?= , =?UTF-8?Q?Marek_Beh=c3=ban?= References: <20211118081841.861158-1-sr@denx.de> In-Reply-To: <20211118081841.861158-1-sr@denx.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Hi Heiko, On 11/18/21 09:18, Stefan Roese wrote: > Testing on Armada XP with an EEPROM using register address with size > of 2 has shown, that the register address bytes are sent to the I2C > EEPROM in the incorrect order. This patch swabs the address bytes so > that the correct address is transferred to the I2C device. > > BTW: This worked without any issues before migrating Armada XP to > DM I2C. > > Signed-off-by: Stefan Roese > Cc: Heiko Schocher > Cc: Samuel Holland > Cc: Baruch Siach > Cc: Pali Rohár > Cc: Marek Behún > --- > It would be good if other users of this I2C driver could test this change > with e.g. I2C EEPROM devices using 2 bytes (or more) for addressing. Could you and other please take a look at this? Would be great, if this could be pulled in the next merge window. Thanks, Stefan > drivers/i2c/mvtwsi.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c > index 236bfb8d8e7f..ff21e3c52b58 100644 > --- a/drivers/i2c/mvtwsi.c > +++ b/drivers/i2c/mvtwsi.c > @@ -860,6 +860,9 @@ static int mvtwsi_i2c_xfer(struct udevice *bus, struct i2c_msg *msg, int nmsgs) > { > struct mvtwsi_i2c_dev *dev = dev_get_priv(bus); > struct i2c_msg *dmsg, *omsg, dummy; > + u8 *addr_buf_ptr; > + u8 addr_buf[4]; > + int i; > > memset(&dummy, 0, sizeof(struct i2c_msg)); > > @@ -873,12 +876,17 @@ static int mvtwsi_i2c_xfer(struct udevice *bus, struct i2c_msg *msg, int nmsgs) > omsg = nmsgs == 1 ? &dummy : msg; > dmsg = nmsgs == 1 ? msg : msg + 1; > > + /* We need to swap the register address if its size is > 1 */ > + addr_buf_ptr = &addr_buf[0]; > + for (i = omsg->len; i > 0; i--) > + *addr_buf_ptr++ = omsg->buf[i - 1]; > + > if (dmsg->flags & I2C_M_RD) > - return __twsi_i2c_read(dev->base, dmsg->addr, omsg->buf, > + return __twsi_i2c_read(dev->base, dmsg->addr, addr_buf, > omsg->len, dmsg->buf, dmsg->len, > dev->tick); > else > - return __twsi_i2c_write(dev->base, dmsg->addr, omsg->buf, > + return __twsi_i2c_write(dev->base, dmsg->addr, addr_buf, > omsg->len, dmsg->buf, dmsg->len, > dev->tick); > } > Viele Grüße, Stefan Roese -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de