From patchwork Thu Nov 5 21:26:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Duffin, CooperX" X-Patchwork-Id: 1395335 X-Patchwork-Delegate: hs@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CS0CC6ZkWz9sRK for ; Fri, 6 Nov 2020 10:31:11 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B6554825C6; Fri, 6 Nov 2020 00:31:00 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 354E8825C7; Thu, 5 Nov 2020 22:26:44 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 043A4825BE for ; Thu, 5 Nov 2020 22:26:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=cooperx.duffin@intel.com IronPort-SDR: taBt8yhF4g/iz+bj6e9q/kVjx3gxS0P6QC3Ee8gyDzaXv+nmlk4SfUAVr0L6UxNfSBJ3Mindhg ino5Cr9RhjSQ== X-IronPort-AV: E=McAfee;i="6000,8403,9796"; a="156458552" X-IronPort-AV: E=Sophos;i="5.77,454,1596524400"; d="scan'208";a="156458552" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2020 13:26:31 -0800 IronPort-SDR: 1w3+JgA5uX+LFEJwgaLaQiyi9xhtIUHyJpBj6Rlnjh0DJEQ/Kfe4286w6MDKlYBWaPisKkNp2T oaqCjgMo9XSw== X-IronPort-AV: E=Sophos;i="5.77,454,1596524400"; d="scan'208";a="471813556" Received: from unknown (HELO localhost.localdomain) ([10.234.46.250]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2020 13:26:30 -0800 From: cduffinx To: u-boot@lists.denx.de, uboot-snps-arc@synopsys.com Cc: Simon Glass , cduffinx , Tom Rini , Robert Beckett , Heiko Schocher , Wolgang Denk , Ian Ray Subject: [dwi2c PATCH v1] dwi2c add offsets to reads Date: Thu, 5 Nov 2020 13:26:27 -0800 Message-Id: <20201105212627.1382451-1-cooperx.duffin@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 06 Nov 2020 00:30:58 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean modify the designware_i2c_xfer function to use 1 byte per address, it was set to 0 before which makes it think its reading a register type. Added offset of where it is supposed to read from. Before it was always reading from offset 0 despite specifying the offset in the higher level function. Signed-off-by: Cooper Duffin Signed-off-by: cduffinx --- drivers/i2c/designware_i2c.c | 5 +++-- drivers/i2c/i2c-uclass.c | 1 + include/i2c.h | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c index 0b5e70af59..46f5d1e56c 100644 --- a/drivers/i2c/designware_i2c.c +++ b/drivers/i2c/designware_i2c.c @@ -658,8 +658,9 @@ static int designware_i2c_xfer(struct udevice *bus, struct i2c_msg *msg, for (; nmsgs > 0; nmsgs--, msg++) { debug("i2c_xfer: chip=0x%x, len=0x%x\n", msg->addr, msg->len); if (msg->flags & I2C_M_RD) { - ret = __dw_i2c_read(i2c->regs, msg->addr, 0, 0, - msg->buf, msg->len); + ret = __dw_i2c_read(i2c->regs, msg->addr, + msg->offset, 1, msg->buf, + msg->len); } else { ret = __dw_i2c_write(i2c->regs, msg->addr, 0, 0, msg->buf, msg->len); diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c index 2aa3efe8aa..455d56c3b8 100644 --- a/drivers/i2c/i2c-uclass.c +++ b/drivers/i2c/i2c-uclass.c @@ -147,6 +147,7 @@ int dm_i2c_read(struct udevice *dev, uint offset, uint8_t *buffer, int len) ptr->flags |= I2C_M_RD; ptr->len = len; ptr->buf = buffer; + ptr->offset = offset; ptr++; } msg_count = ptr - msg; diff --git a/include/i2c.h b/include/i2c.h index 0faf8542e2..f997c2537e 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -141,6 +141,7 @@ struct i2c_msg { uint addr; uint flags; uint len; + uint offset; u8 *buf; };