From patchwork Wed Dec 16 18:44:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 7865641 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 52C3B9F1C2 for ; Wed, 16 Dec 2015 18:44:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 82FC1203A5 for ; Wed, 16 Dec 2015 18:44:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8EC862026F for ; Wed, 16 Dec 2015 18:44:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933027AbbLPSof (ORCPT ); Wed, 16 Dec 2015 13:44:35 -0500 Received: from sauhun.de ([89.238.76.85]:56571 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755071AbbLPSoe (ORCPT ); Wed, 16 Dec 2015 13:44:34 -0500 Received: from p4fe2420c.dip0.t-ipconnect.de ([79.226.66.12]:53066 helo=localhost) by pokefinder.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1a9H3w-0000fF-FJ; Wed, 16 Dec 2015 19:44:32 +0100 From: Wolfram Sang To: linux-i2c@vger.kernel.org Cc: linux-sh@vger.kernel.org, Magnus Damm , Simon Horman , Laurent Pinchart , Geert Uytterhoeven , Wolfram Sang , linux-pm@vger.kernel.org Subject: [RFC 3/3] i2c: rcar: disable PM in multi-master mode Date: Wed, 16 Dec 2015 19:44:20 +0100 Message-Id: <1450291460-10514-4-git-send-email-wsa@the-dreams.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1450291460-10514-1-git-send-email-wsa@the-dreams.de> References: <1450291460-10514-1-git-send-email-wsa@the-dreams.de> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wolfram Sang In multi master mode, the IP core needs to be always active for arbitration reasons. Get the config from DT and set up PM depending on the config. Signed-off-by: Wolfram Sang --- drivers/i2c/busses/i2c-rcar.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c index 79fd2aab8fa087..7c523dcaee3e48 100644 --- a/drivers/i2c/busses/i2c-rcar.c +++ b/drivers/i2c/busses/i2c-rcar.c @@ -96,6 +96,9 @@ #define ID_DONE (1 << 2) #define ID_ARBLOST (1 << 3) #define ID_NACK (1 << 4) +/* persistent flags */ +#define ID_P_PM_BLOCKED (1 << 31) +#define ID_P_MASK ID_P_PM_BLOCKED enum rcar_i2c_type { I2C_RCAR_GEN1, @@ -277,7 +280,7 @@ static void rcar_i2c_next_msg(struct rcar_i2c_priv *priv) { priv->msg++; priv->msgs_left--; - priv->flags = 0; + priv->flags &= ID_P_MASK; rcar_i2c_prepare_msg(priv); } @@ -495,7 +498,7 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap, /* init first message */ priv->msg = msgs; priv->msgs_left = num; - priv->flags = ID_FIRST_MSG; + priv->flags = (priv->flags & ID_P_MASK) | ID_FIRST_MSG; rcar_i2c_prepare_msg(priv); time_left = wait_event_timeout(priv->wait, priv->flags & ID_DONE, @@ -630,7 +633,13 @@ static int rcar_i2c_probe(struct platform_device *pdev) goto out_pm_put; rcar_i2c_init(priv); - pm_runtime_put(dev); + + /* Don't suspend when multi-master to keep arbitration working */ + if (of_get_property(dev->of_node, "multi-master", NULL)) + priv->flags |= ID_P_PM_BLOCKED; + else + pm_runtime_put(dev); + irq = platform_get_irq(pdev, 0); ret = devm_request_irq(dev, irq, rcar_i2c_irq, 0, dev_name(dev), priv); @@ -664,6 +673,8 @@ static int rcar_i2c_remove(struct platform_device *pdev) struct device *dev = &pdev->dev; i2c_del_adapter(&priv->adap); + if (priv->flags & ID_P_PM_BLOCKED) + pm_runtime_put(dev); pm_runtime_disable(dev); return 0;