From patchwork Fri Nov 14 15:40:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 40835 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B1E52240ED for ; Fri, 14 Nov 2014 15:40:52 +0000 (UTC) Received: by mail-wg0-f72.google.com with SMTP id a1sf784499wgh.3 for ; Fri, 14 Nov 2014 07:40:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:cc:subject:references:in-reply-to:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe :content-type:content-transfer-encoding; bh=PfbjmMzytMbMaGSGkwyYOeBKFwwU7hJ5fASzbTk/WYY=; b=Y533pYAOquTBvtDIcf0qIIDq6u7mXyG88LJajzOS7ZdJbT4qPWA51WuE2tCIkIlfY3 22RBolweCOACzOZCoszPadiWqdM0tJGvrkuSLQ6TqdBTr+Kn/L49s9sLq/+uxAMYWrQY ykFLscizJ1GQ6xzideR59qDRFsWtNzHP94Hgrt+MD0Gyg9vO9wjo3wBgznSFYWWbmKXo Yu/XG0GS3I6bau1c3FH2w4WW3DZSVYr6IrqVMnZE75V/R3dQxi+nZ52kpqJL14BL/Ho/ 01UwMD3K13eKMoxrr5D4G6/JW1MJMaIoy5NO5dpkh8aAbbFXqa4nW/SoxMOcZbSPcA7C oxfw== X-Gm-Message-State: ALoCoQn1Cy+ctAaExOUyt909xf56HWJOMvdpie++b4ExrML2miINrQ9auPhriCIeKxKUcen/zaro X-Received: by 10.152.27.38 with SMTP id q6mr4715578lag.5.1415979651944; Fri, 14 Nov 2014 07:40:51 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.166 with SMTP id t6ls1054802lat.20.gmail; Fri, 14 Nov 2014 07:40:51 -0800 (PST) X-Received: by 10.152.44.197 with SMTP id g5mr9120512lam.4.1415979651277; Fri, 14 Nov 2014 07:40:51 -0800 (PST) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id dv6si42086139lbc.52.2014.11.14.07.40.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Nov 2014 07:40:51 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by mail-lb0-f171.google.com with SMTP id b6so12889544lbj.2 for ; Fri, 14 Nov 2014 07:40:51 -0800 (PST) X-Received: by 10.112.62.166 with SMTP id z6mr3333003lbr.74.1415979651196; Fri, 14 Nov 2014 07:40:51 -0800 (PST) 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.112.184.201 with SMTP id ew9csp781966lbc; Fri, 14 Nov 2014 07:40:50 -0800 (PST) X-Received: by 10.68.249.133 with SMTP id yu5mr10794777pbc.31.1415979649196; Fri, 14 Nov 2014 07:40:49 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fd10si23367356pad.4.2014.11.14.07.40.48 for ; Fri, 14 Nov 2014 07:40:49 -0800 (PST) Received-SPF: none (google.com: linux-omap-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 S1161234AbaKNPkr (ORCPT + 5 others); Fri, 14 Nov 2014 10:40:47 -0500 Received: from devils.ext.ti.com ([198.47.26.153]:55837 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161182AbaKNPkq (ORCPT ); Fri, 14 Nov 2014 10:40:46 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id sAEFeJ24013389; Fri, 14 Nov 2014 09:40:19 -0600 Received: from DLEE70.ent.ti.com (dlemailx.itg.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id sAEFeJ34029338; Fri, 14 Nov 2014 09:40:19 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.174.1; Fri, 14 Nov 2014 09:40:18 -0600 Received: from [192.168.2.6] (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id sAEFeENS032480; Fri, 14 Nov 2014 09:40:14 -0600 Message-ID: <5466225D.2070202@ti.com> Date: Fri, 14 Nov 2014 17:40:13 +0200 From: Roger Quadros User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: , CC: , , , , , , , , , , , , Roger Quadros Subject: [PATCH v7 6/8] net: can: c_can: Disable pins when CAN interface is down References: <1415371762-29885-1-git-send-email-rogerq@ti.com> <1415371762-29885-7-git-send-email-rogerq@ti.com> <5464CCFF.5010004@ti.com> In-Reply-To: <5464CCFF.5010004@ti.com> Sender: linux-omap-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-omap@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.217.171 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: , DRA7 CAN IP suffers from a problem which causes it to be prevented from fully turning OFF (i.e. stuck in transition) if the module was disabled while there was traffic on the CAN_RX line. To work around this issue we select the SLEEP pin state by default on probe and use the DEFAULT pin state on CAN up and back to the SLEEP pin state on CAN down. Signed-off-by: Roger Quadros Reviewed-by: Linus Walleij --- drivers/net/can/c_can/c_can.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c index 8e78bb4..f94a9fa 100644 --- a/drivers/net/can/c_can/c_can.c +++ b/drivers/net/can/c_can/c_can.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -603,6 +604,8 @@ static int c_can_start(struct net_device *dev) priv->can.state = CAN_STATE_ERROR_ACTIVE; + /* activate pins */ + pinctrl_pm_select_default_state(dev->dev.parent); return 0; } @@ -611,6 +614,9 @@ static void c_can_stop(struct net_device *dev) struct c_can_priv *priv = netdev_priv(dev); c_can_irq_control(priv, false); + + /* deactivate pins */ + pinctrl_pm_select_sleep_state(dev->dev.parent); priv->can.state = CAN_STATE_STOPPED; } @@ -1244,6 +1250,13 @@ int register_c_can_dev(struct net_device *dev) struct c_can_priv *priv = netdev_priv(dev); int err; + /* Deactivate pins to prevent DRA7 DCAN IP from being + * stuck in transition when module is disabled. + * Pins are activated in c_can_start() and deactivated + * in c_can_stop() + */ + pinctrl_pm_select_sleep_state(dev->dev.parent); + c_can_pm_runtime_enable(priv); dev->flags |= IFF_ECHO; /* we support local echo */