From patchwork Thu Mar 5 16:46:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 446797 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 529E6140146 for ; Fri, 6 Mar 2015 03:50:38 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 344FC1A084E for ; Fri, 6 Mar 2015 03:50:38 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mailhub1.si.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by lists.ozlabs.org (Postfix) with ESMTP id D04FA1A01DC for ; Fri, 6 Mar 2015 03:46:14 +1100 (AEDT) Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id A63861C8330; Thu, 5 Mar 2015 17:46:12 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from mailhub1.si.c-s.fr ([192.168.12.234]) by localhost (mailhub1.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id M8Wxe6qH5pFh; Thu, 5 Mar 2015 17:46:12 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 8A4011C8301; Thu, 5 Mar 2015 17:46:12 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id D0170C73CD; Thu, 5 Mar 2015 17:46:10 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id bK7oL3ZK_VA1; Thu, 5 Mar 2015 17:46:10 +0100 (CET) Received: from PO10863.localdomain (unknown [172.25.231.75]) by messagerie.si.c-s.fr (Postfix) with ESMTP id DD66AC73C5; Thu, 5 Mar 2015 17:46:07 +0100 (CET) Received: by localhost.localdomain (Postfix, from userid 0) id 637E61A241D; Thu, 5 Mar 2015 17:46:05 +0100 (CET) From: Christophe Leroy To: Kim Phillips , Herbert Xu , "David S. Miller" Subject: [PATCH 02/17] crypto: talitos - Externalise specific SEC2 reset actions Message-Id: <20150305164606.637E61A241D@localhost.localdomain> Date: Thu, 5 Mar 2015 17:46:05 +0100 (CET) Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" During init and reset, some actions are different between SEC1 and SEC2 This patch isolates them in small helper functions that we will be able to redefine for SEC1 Signed-off-by: Christophe Leroy --- drivers/crypto/talitos.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index ebbae8d..e3a2d75 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -88,9 +88,8 @@ static void unmap_single_talitos_ptr(struct device *dev, be16_to_cpu(talitos_ptr->len), dir); } -static int reset_channel(struct device *dev, int ch) +static unsigned int do_reset_channel(struct talitos_private *priv, int ch) { - struct talitos_private *priv = dev_get_drvdata(dev); unsigned int timeout = TALITOS_TIMEOUT; setbits32(priv->chan[ch].reg + TALITOS_CCCR, TALITOS_CCCR_RESET); @@ -99,6 +98,14 @@ static int reset_channel(struct device *dev, int ch) && --timeout) cpu_relax(); + return timeout; +} + +static int reset_channel(struct device *dev, int ch) +{ + struct talitos_private *priv = dev_get_drvdata(dev); + unsigned int timeout = do_reset_channel(priv, ch); + if (timeout == 0) { dev_err(dev, "failed to reset channel %d\n", ch); return -EIO; @@ -144,6 +151,12 @@ static int reset_device(struct device *dev) /* * Reset and initialize the device */ +static void do_init_device(struct talitos_private *priv) +{ + setbits32(priv->reg + TALITOS_IMR, TALITOS_IMR_INIT); + setbits32(priv->reg + TALITOS_IMR_LO, TALITOS_IMR_LO_INIT); +} + static int init_device(struct device *dev) { struct talitos_private *priv = dev_get_drvdata(dev); @@ -171,8 +184,7 @@ static int init_device(struct device *dev) } /* enable channel done and error interrupts */ - setbits32(priv->reg + TALITOS_IMR, TALITOS_IMR_INIT); - setbits32(priv->reg + TALITOS_IMR_LO, TALITOS_IMR_LO_INIT); + do_init_device(priv); /* disable integrity check error interrupts (use writeback instead) */ if (priv->features & TALITOS_FTR_HW_AUTH_CHECK)