From patchwork Sun Jun 9 02:36:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 2693631 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork1.kernel.org (Postfix) with ESMTP id 3E85A3FC23 for ; Sun, 9 Jun 2013 02:43:21 +0000 (UTC) Received: from merlin.infradead.org ([205.233.59.134]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UlVb7-0000pY-SV; Sun, 09 Jun 2013 02:43:14 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UlVXZ-0007jO-B8; Sun, 09 Jun 2013 02:39:33 +0000 Received: from mail-pd0-f181.google.com ([209.85.192.181]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UlVXO-0007ie-06 for linux-arm-kernel@lists.infradead.org; Sun, 09 Jun 2013 02:39:31 +0000 Received: by mail-pd0-f181.google.com with SMTP id 14so3539365pdj.40 for ; Sat, 08 Jun 2013 19:38:26 -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=WFOV5UC7rj8x/zM4mtKzAtM6143t2UTRTWpKqBrNk2c=; b=XIfKdvW384TfxtD7m8K8hgcufWDq1Hbn1kf1JcT5tAmFGTn6vQkGYSSHlvHhgsa4II AW9mGyMJ9l5kXiZNvabnTrMS4YIbCX6j9Ku+GgbCr1dUWTNODrt2YkgytR25aFj6kIOY My/AItxSnZmAohivOQ5Bhqq7iy6HJI3dKhC2iTccTFfxPsRQ6Erj4qKDvH0QCeE/bELP k1scynvgmgdXlvWDA541OnxqQLNlCR5/EGED8b1w+m4RmjtMltUeOWbSv88cUO7LTVFs Yrac71C724LTiLweSAI1mKK7rr81lnEpEkj3LQjI1BWnqOR57rtbA0PyT/UTux8wx6wj fSNQ== X-Received: by 10.66.21.37 with SMTP id s5mr2386244pae.103.1370745506483; Sat, 08 Jun 2013 19:38:26 -0700 (PDT) Received: from localhost.localdomain ([124.73.8.29]) by mx.google.com with ESMTPSA id xu10sm9578181pab.3.2013.06.08.19.38.22 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 08 Jun 2013 19:38:25 -0700 (PDT) From: Zhangfei Gao To: Wolfram Sang , Dirk Brandewie Subject: [PATCH 1/2] i2c-designware: support no DW_IC_COMP_TYPE platform Date: Sun, 9 Jun 2013 10:36:41 +0800 Message-Id: <1370745402-11844-2-git-send-email-zhangfei.gao@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1370745402-11844-1-git-send-email-zhangfei.gao@linaro.org> References: <1370745402-11844-1-git-send-email-zhangfei.gao@linaro.org> X-Gm-Message-State: ALoCoQn4Swt/2z8CvyqCLw3dUgY1Q856oMawxwBlWEMt89+nSh/Qi6BgWIVPoPMjQGVhppeDfHkV X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130608_223922_115577_B67E95A6 X-CRM114-Status: GOOD ( 12.53 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.192.181 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Zhangfei Gao , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Check accessor_flags before reading DW_IC_COMP_TYPE Give chance to platform no such register Signed-off-by: Zhangfei Gao --- drivers/i2c/busses/i2c-designware-core.c | 24 +++++++++++++----------- drivers/i2c/busses/i2c-designware-core.h | 1 + 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c index c41ca63..80cabbd 100644 --- a/drivers/i2c/busses/i2c-designware-core.c +++ b/drivers/i2c/busses/i2c-designware-core.c @@ -286,17 +286,19 @@ int i2c_dw_init(struct dw_i2c_dev *dev) input_clock_khz = dev->get_clk_rate_khz(dev); - reg = dw_readl(dev, DW_IC_COMP_TYPE); - if (reg == ___constant_swab32(DW_IC_COMP_TYPE_VALUE)) { - /* Configure register endianess access */ - dev->accessor_flags |= ACCESS_SWAP; - } else if (reg == (DW_IC_COMP_TYPE_VALUE & 0x0000ffff)) { - /* Configure register access mode 16bit */ - dev->accessor_flags |= ACCESS_16BIT; - } else if (reg != DW_IC_COMP_TYPE_VALUE) { - dev_err(dev->dev, "Unknown Synopsys component type: " - "0x%08x\n", reg); - return -ENODEV; + if (!dev->accessor_flags) { + reg = dw_readl(dev, DW_IC_COMP_TYPE); + if (reg == ___constant_swab32(DW_IC_COMP_TYPE_VALUE)) { + /* Configure register endianess access */ + dev->accessor_flags |= ACCESS_SWAP; + } else if (reg == (DW_IC_COMP_TYPE_VALUE & 0x0000ffff)) { + /* Configure register access mode 16bit */ + dev->accessor_flags |= ACCESS_16BIT; + } else if (reg != DW_IC_COMP_TYPE_VALUE) { + dev_err(dev->dev, "Unknown Synopsys component type: " + "0x%08x\n", reg); + return -ENODEV; + } } /* Disable the adapter */ diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h index e761ad1..b38b54e 100644 --- a/drivers/i2c/busses/i2c-designware-core.h +++ b/drivers/i2c/busses/i2c-designware-core.h @@ -94,6 +94,7 @@ struct dw_i2c_dev { #define ACCESS_SWAP 0x00000001 #define ACCESS_16BIT 0x00000002 +#define ACCESS_32BIT 0x00000004 extern u32 dw_readl(struct dw_i2c_dev *dev, int offset); extern void dw_writel(struct dw_i2c_dev *dev, u32 b, int offset);