From patchwork Tue Sep 9 14:31:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 37118 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f200.google.com (mail-ig0-f200.google.com [209.85.213.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 65D6720566 for ; Tue, 9 Sep 2014 14:32:04 +0000 (UTC) Received: by mail-ig0-f200.google.com with SMTP id uq10sf77813150igb.7 for ; Tue, 09 Sep 2014 07:32:04 -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=ifKS60lmKClKFXszyssvVTcgbOjyjfMBINBL5/gBUSE9guGnJexLMmvUESfHB4gcIi mauguCvqwm93sAbWlWD858IaaU/VLRZU17i8tpQseX7Hic95wBZZqmULEqhSFGClLAbw 3ITtN1bvW5sQfoLPuaI+/3ZF6qRYbKckZgMcz/Ty+TuTl+69xG2DfCRDHYE3vuONte5N fggkZt6iJ3uX149IkstwE8n7XtNdahjHVegEwd0dPXBQkPJJ8zccUTQa+/J1zCr9VvMG 4YzqTK9DDwH64Dcr7fRj9JrJwixUQVm2GLdkcHsddCiSeXbJAsKhICIM2ec3tkkA7Ggs OiDw== X-Gm-Message-State: ALoCoQmEiVDBZLEY8uWACEkoaok28AuEdHfWH9jidEFvKqGBCQbNBPYS/Ua8ba492lw6EbHeK6fY X-Received: by 10.182.117.231 with SMTP id kh7mr22035224obb.0.1410273121016; Tue, 09 Sep 2014 07:32:01 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.27.242 with SMTP id 105ls2231060qgx.17.gmail; Tue, 09 Sep 2014 07:32:00 -0700 (PDT) X-Received: by 10.220.184.70 with SMTP id cj6mr30779478vcb.5.1410273120795; Tue, 09 Sep 2014 07:32:00 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id lr17si5844709vdb.24.2014.09.09.07.32.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Sep 2014 07:32:00 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id ik5so553774vcb.0 for ; Tue, 09 Sep 2014 07:32:00 -0700 (PDT) X-Received: by 10.220.97.5 with SMTP id j5mr31259292vcn.16.1410273120654; Tue, 09 Sep 2014 07:32:00 -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 uj3csp293076vcb; Tue, 9 Sep 2014 07:32:00 -0700 (PDT) X-Received: by 10.68.95.227 with SMTP id dn3mr30773727pbb.108.1410273119809; Tue, 09 Sep 2014 07:31:59 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id jg1si23662592pbb.40.2014.09.09.07.31.59 for ; Tue, 09 Sep 2014 07:31:59 -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 S1755976AbaIIOb5 (ORCPT + 3 others); Tue, 9 Sep 2014 10:31:57 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:55577 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751361AbaIIObz (ORCPT ); Tue, 9 Sep 2014 10:31:55 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s89EVLOe026695; Tue, 9 Sep 2014 09:31:21 -0500 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 s89EVLiO024420; Tue, 9 Sep 2014 09:31:21 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Tue, 9 Sep 2014 09:31:20 -0500 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s89EVD14002296; Tue, 9 Sep 2014 09:31:17 -0500 From: Roger Quadros To: , CC: , , , , , , , , , , , Roger Quadros Subject: [PATCH v2 1/3] can: c_can_platform: Fix c_can_hw_raminit_ti() and add timeout Date: Tue, 9 Sep 2014 17:31:08 +0300 Message-ID: <1410273070-22485-2-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1410273070-22485-1-git-send-email-rogerq@ti.com> References: <1410273070-22485-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.169 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); }