From patchwork Fri Jun 22 04:12:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Troy Kisky X-Patchwork-Id: 166482 X-Patchwork-Delegate: hs@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 77478B6EF1 for ; Fri, 22 Jun 2012 14:14:16 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2E45F280C3; Fri, 22 Jun 2012 06:13:43 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HXejFGtjCa61; Fri, 22 Jun 2012 06:13:42 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9DACF280CF; Fri, 22 Jun 2012 06:12:44 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C42AD2808A for ; Fri, 22 Jun 2012 06:12:32 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 81hIxrTGGwER for ; Fri, 22 Jun 2012 06:12:32 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pz0-f44.google.com (mail-pz0-f44.google.com [209.85.210.44]) by theia.denx.de (Postfix) with ESMTPS id B29682808F for ; Fri, 22 Jun 2012 06:12:27 +0200 (CEST) Received: by dacx6 with SMTP id x6so1729050dac.3 for ; Thu, 21 Jun 2012 21:12:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=6+5fNypSxDIJQhrHOrHX5xmJQNssWFzn/QwjTWdQgEE=; b=IcG0VfoXDbJ9gnSFR5VDG+ZYnaor6jyPh8mH/eusCbiBlAEtOuWQsKn07HQsle6XsY WOajmkTcwzK1vbDrEii1kX/Pl4x6xPKt+5CQh7FmooKQFEDVG30QgsJghjtusY9DYijN W3ImbytNj04h0hvqlE0rptTJXCGQG6dJLP+aNkYFv5u6zWwnu+rx0MnQeygm/K9WOSfe VJ2Sj+dePdtWLBTW/1ERNRjoYnQyLVi1WwdIfdjVOlDrkW3ppLv9z9kEsbRvxBHcs01r bVYXpPg4iSCOlmtf6viQVw3XDZV6j3mtd0Thkx9DCcKeXSK5qPErR/CRPPr5I1JDhe4w UXBQ== Received: by 10.68.130.67 with SMTP id oc3mr6004969pbb.18.1340338344704; Thu, 21 Jun 2012 21:12:24 -0700 (PDT) Received: from officeserver-2 ([70.96.116.236]) by mx.google.com with ESMTPS id b10sm37672769pbr.46.2012.06.21.21.12.23 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 21 Jun 2012 21:12:24 -0700 (PDT) Received: from tkisky by officeserver-2 with local (Exim 4.76) (envelope-from ) id 1ShvEM-00032p-6E; Thu, 21 Jun 2012 21:12:22 -0700 From: Troy Kisky To: hs@denx.de, sbabic@denx.de Date: Thu, 21 Jun 2012 21:12:08 -0700 Message-Id: <1340338339-11626-13-git-send-email-troy.kisky@boundarydevices.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1340338339-11626-1-git-send-email-troy.kisky@boundarydevices.com> References: <1340338339-11626-1-git-send-email-troy.kisky@boundarydevices.com> X-Gm-Message-State: ALoCoQkA9U723E5qcohscR0FPzOfwIvxgHnx47UA+0+ZNT+6pof3DD4wYJiR5xC7d/j8eHU+tRlK Cc: u-boot@lists.denx.de, r49496@freescale.com, jason.hui@linaro.org Subject: [U-Boot] [PATCH 13/24] mxc_i2c: check for arbitration lost X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de No need to continue waiting if arbitration lost. Signed-off-by: Troy Kisky Acked-by: Marek Vasut --- drivers/i2c/mxc_i2c.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c index 2bff2b8..df033ea 100644 --- a/drivers/i2c/mxc_i2c.c +++ b/drivers/i2c/mxc_i2c.c @@ -54,6 +54,7 @@ struct mxc_i2c_regs { #define I2SR_ICF (1 << 7) #define I2SR_IBB (1 << 5) +#define I2SR_IAL (1 << 4) #define I2SR_IIF (1 << 1) #define I2SR_RX_NO_AK (1 << 0) @@ -164,6 +165,12 @@ static unsigned wait_for_sr_state(struct mxc_i2c_regs *i2c_regs, unsigned state) ulong start_time = get_timer(0); for (;;) { sr = readb(&i2c_regs->i2sr); + if (sr & I2SR_IAL) { + writeb(sr & ~I2SR_IAL, &i2c_regs->i2sr); + printf("%s: Arbitration lost sr=%x cr=%x state=%x\n", + __func__, sr, readb(&i2c_regs->i2cr), state); + return -ERESTART; + } if ((sr & (state >> 8)) == (unsigned char)state) return sr; elapsed = get_timer(start_time);