From patchwork Mon Sep 8 14:10:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 36990 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EC3362054D for ; Mon, 8 Sep 2014 14:11:23 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id id10sf42846519vcb.6 for ; Mon, 08 Sep 2014 07:11:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=KXpEeN3E0OB2IuE9rxevz8jQKcKbmfcQutbuO8LArMI=; b=JjVk0QNW8uWDHvIbqegYeIYmqrLcxOegfetB8J71SDm5zf89FIUxTp5D6cI+8R6BWv cmmCmlbM7vYs94kMbzBnlk6pNUohxVVmW+7aLcD1XOclrSLoKuKJCbJQrw1OBlIwfF3T P7YDMJlh7W/KpRl6fQxEAadG/e2a6t7/nwCXeG2bmm6fCOHmFYM+mq2Yr/ymIpSHxdQW 5b/8B7fzkz2D1nPYY4YJ4c05kgRs+t9NIlWGKi8osGqZQKjqq2O2GmNfldGARnBXJGIR NRe6im02IOngknt+28G1TPKfnoMTzMgXzkkivhZtLMIMtlVdRUzRHIJ0kphn9jDEQL22 tlRw== X-Gm-Message-State: ALoCoQlImbqiYdgnbffigG+OgIpsp/0g0QImcn+yOpQ4EXpXKkQOFnQpOyc0e6Z1ZvtO1QSpo34+ X-Received: by 10.224.0.142 with SMTP id 14mr5721972qab.8.1410185483666; Mon, 08 Sep 2014 07:11:23 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.37.35 with SMTP id q32ls1749679qgq.50.gmail; Mon, 08 Sep 2014 07:11:23 -0700 (PDT) X-Received: by 10.52.6.138 with SMTP id b10mr184545vda.84.1410185483493; Mon, 08 Sep 2014 07:11:23 -0700 (PDT) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id f2si4522614vdf.74.2014.09.08.07.11.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 08 Sep 2014 07:11:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.173 as permitted sender) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id le20so1419688vcb.18 for ; Mon, 08 Sep 2014 07:11:23 -0700 (PDT) X-Received: by 10.221.29.5 with SMTP id rw5mr868174vcb.49.1410185483417; Mon, 08 Sep 2014 07:11:23 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp139950vcb; Mon, 8 Sep 2014 07:11:22 -0700 (PDT) X-Received: by 10.68.238.137 with SMTP id vk9mr765946pbc.165.1410185482534; Mon, 08 Sep 2014 07:11:22 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x13si16459309pdk.119.2014.09.08.07.11.22 for ; Mon, 08 Sep 2014 07:11:22 -0700 (PDT) Received-SPF: none (google.com: netdev-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754309AbaIHOLS (ORCPT + 3 others); Mon, 8 Sep 2014 10:11:18 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:58818 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753500AbaIHOLP (ORCPT ); Mon, 8 Sep 2014 10:11:15 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s88EAqKj017268; Mon, 8 Sep 2014 09:10:52 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s88EApd9032564; Mon, 8 Sep 2014 09:10:51 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Mon, 8 Sep 2014 09:10:51 -0500 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s88EAi07014173; Mon, 8 Sep 2014 09:10:48 -0500 From: Roger Quadros To: , , CC: , , , , , , , , , Roger Quadros Subject: [PATCH 01/13] can: c_can_platform: Fix c_can_hw_raminit_ti() and add timeout Date: Mon, 8 Sep 2014 17:10:30 +0300 Message-ID: <1410185442-907-2-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1410185442-907-1-git-send-email-rogerq@ti.com> References: <1410185442-907-1-git-send-email-rogerq@ti.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: netdev@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: rogerq@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.173 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Pass the correct 'mask' and 'value' bits to c_can_hw_raminit_wait_ti(). They seem to have been swapped in the usage instances. TI's RAMINIT DONE mechanism is buggy and may not always be set after the START bit is set. So add a timeout mechanism to c_can_hw_raminit_wait_ti(). Signed-off-by: Roger Quadros --- drivers/net/can/c_can/c_can_platform.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c index 109cb44..b144e71 100644 --- a/drivers/net/can/c_can/c_can_platform.c +++ b/drivers/net/can/c_can/c_can_platform.c @@ -75,10 +75,18 @@ static void c_can_plat_write_reg_aligned_to_32bit(const struct c_can_priv *priv, static void c_can_hw_raminit_wait_ti(const struct c_can_priv *priv, u32 mask, u32 val) { + int timeout = 0; /* We look only at the bits of our instance. */ val &= mask; - while ((readl(priv->raminit_ctrlreg) & mask) != val) + while ((readl(priv->raminit_ctrlreg) & mask) != val) { udelay(1); + timeout++; + + if (timeout == 1000) { + dev_err(&priv->dev->dev, "%s: time out\n", __func__); + break; + } + } } static void c_can_hw_raminit_ti(const struct c_can_priv *priv, bool enable) @@ -97,14 +105,14 @@ static void c_can_hw_raminit_ti(const struct c_can_priv *priv, bool enable) ctrl |= CAN_RAMINIT_DONE_MASK(priv->instance); writel(ctrl, priv->raminit_ctrlreg); ctrl &= ~CAN_RAMINIT_DONE_MASK(priv->instance); - c_can_hw_raminit_wait_ti(priv, ctrl, mask); + c_can_hw_raminit_wait_ti(priv, mask, ctrl); if (enable) { /* Set start bit and wait for the done bit. */ ctrl |= CAN_RAMINIT_START_MASK(priv->instance); writel(ctrl, priv->raminit_ctrlreg); ctrl |= CAN_RAMINIT_DONE_MASK(priv->instance); - c_can_hw_raminit_wait_ti(priv, ctrl, mask); + c_can_hw_raminit_wait_ti(priv, mask, ctrl); } spin_unlock(&raminit_lock); }