From patchwork Thu Apr 20 15:25:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Franklin S Cooper Jr X-Patchwork-Id: 752840 X-Patchwork-Delegate: hs@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3w82n33Hjmz9s4s for ; Fri, 21 Apr 2017 01:27:51 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="b/HV/o7B"; dkim-atps=neutral Received: by lists.denx.de (Postfix, from userid 105) id 27A25C21CFC; Thu, 20 Apr 2017 15:26:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 5AC66C21E0B; Thu, 20 Apr 2017 15:26:38 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 846E6C21E35; Thu, 20 Apr 2017 15:26:09 +0000 (UTC) Received: from lelnx193.ext.ti.com (lelnx193.ext.ti.com [198.47.27.77]) by lists.denx.de (Postfix) with ESMTPS id 6B3ACC21E42 for ; Thu, 20 Apr 2017 15:26:06 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id v3KFQ4AP020144 for ; Thu, 20 Apr 2017 10:26:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1492701964; bh=/X20H7cIf/MDn3ZhNWzJUQjmM02/Vz897wAwlOKEavQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=b/HV/o7BzQzWPCCtLekYXgDWLtWx6DWPmy7ZLfvFiyPQrVIxl057iTjtm/3eXPmte 6REPy5dR7PrI5zVHqr8XhfDp5XepMDk/exzDV+f6JArBJEZg+MVppZ7VBlTguKe4gF 1pKYUy8DF4MMfb4tDByoCAxN5ylOWlGLx3Or1WGE= Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v3KFQ3P9013081 for ; Thu, 20 Apr 2017 10:26:04 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.294.0; Thu, 20 Apr 2017 10:26:02 -0500 Received: from dbdmail01.india.ti.com (dbdmail01.india.ti.com [172.24.162.206]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v3KFQ2JJ000458; Thu, 20 Apr 2017 10:26:02 -0500 Received: from udb0273011.am.dhcp.ti.com (udb0273011.am.dhcp.ti.com [128.247.83.178]) by dbdmail01.india.ti.com (8.14.3/8.14.3/SuSE Linux 0.8) with ESMTP id v3KFPptX015503; Thu, 20 Apr 2017 20:56:00 +0530 From: Franklin S Cooper Jr To: , , , Date: Thu, 20 Apr 2017 10:25:45 -0500 Message-ID: <20170420152549.28031-5-fcooper@ti.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20170420152549.28031-1-fcooper@ti.com> References: <20170420152549.28031-1-fcooper@ti.com> MIME-Version: 1.0 Cc: Franklin S Cooper Jr Subject: [U-Boot] [PATCH v2 4/8] ti: common: board_detect: Set alen to expected value before i2c read X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" In non DM I2C read operations the address length passed in during a read operation will be used automatically. However, in DM I2C the address length is set to a default value of one which causes problems when trying to perform a read with a differing alen. Therefore, before the first read in a series of read operations set the alen to the correct value. Signed-off-by: Franklin S Cooper Jr Reviewed-by: Tom Rini Reviewed-by: Heiko Schocher --- board/ti/common/board_detect.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c index 1e695f4..6fdcb61 100644 --- a/board/ti/common/board_detect.c +++ b/board/ti/common/board_detect.c @@ -83,7 +83,17 @@ static int __maybe_unused ti_i2c_eeprom_init(int i2c_bus, int dev_addr) static int __maybe_unused ti_i2c_eeprom_read(int dev_addr, int offset, uchar *ep, int epsize) { - return i2c_read(dev_addr, offset, 2, ep, epsize); + int bus_num, rc, alen; + + bus_num = i2c_get_bus_num(); + + alen = 2; + + rc = ti_i2c_set_alen(bus_num, dev_addr, alen); + if (rc) + return rc; + + return i2c_read(dev_addr, offset, alen, ep, epsize); } /** @@ -125,6 +135,11 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr, * Read the header first then only read the other contents. */ byte = 2; + + rc = ti_i2c_set_alen(bus_addr, dev_addr, byte); + if (rc) + return rc; + rc = i2c_read(dev_addr, 0x0, byte, (uint8_t *)&hdr_read, 4); if (rc) return rc; @@ -137,9 +152,14 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr, * 1 byte address (some legacy boards need this..) */ byte = 1; - if (rc) + if (rc) { + rc = ti_i2c_set_alen(bus_addr, dev_addr, byte); + if (rc) + return rc; + rc = i2c_read(dev_addr, 0x0, byte, (uint8_t *)&hdr_read, 4); + } if (rc) return rc; }