From patchwork Wed Aug 5 18:28:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victoria Milhoan X-Patchwork-Id: 6952471 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 66BAAC05AC for ; Wed, 5 Aug 2015 18:44:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3BF81205D1 for ; Wed, 5 Aug 2015 18:44:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 197E3205CB for ; Wed, 5 Aug 2015 18:44:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752036AbbHESoE (ORCPT ); Wed, 5 Aug 2015 14:44:04 -0400 Received: from mail-bn1on0131.outbound.protection.outlook.com ([157.56.110.131]:20154 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751712AbbHESoD (ORCPT ); Wed, 5 Aug 2015 14:44:03 -0400 Received: from BLUPR0301MB1569.namprd03.prod.outlook.com (10.162.214.15) by BLUPR0301MB1586.namprd03.prod.outlook.com (10.162.214.20) with Microsoft SMTP Server (TLS) id 15.1.231.11; Wed, 5 Aug 2015 18:28:54 +0000 Received: from CH1PR03CA004.namprd03.prod.outlook.com (10.255.156.149) by BLUPR0301MB1569.namprd03.prod.outlook.com (10.162.214.15) with Microsoft SMTP Server (TLS) id 15.1.225.19; Wed, 5 Aug 2015 18:28:53 +0000 Received: from BN1BFFO11FD050.protection.gbl (10.255.156.132) by CH1PR03CA004.outlook.office365.com (10.255.156.149) with Microsoft SMTP Server (TLS) id 15.1.225.19 via Frontend Transport; Wed, 5 Aug 2015 18:28:53 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; kernel.org; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BN1BFFO11FD050.mail.protection.outlook.com (10.58.145.5) with Microsoft SMTP Server (TLS) id 15.1.243.9 via Frontend Transport; Wed, 5 Aug 2015 18:28:51 +0000 Received: from stc-hedley.am.freescale.net (stc-hedley.am.freescale.net [10.67.70.12]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t75ISmA7019320; Wed, 5 Aug 2015 11:28:50 -0700 From: Victoria Milhoan To: CC: , , , , , , Subject: [PATCH v2 03/14] crypto: caam - Enable and disable clocks on Freescale i.MX platforms Date: Wed, 5 Aug 2015 11:28:37 -0700 Message-ID: <1438799328-10757-4-git-send-email-vicki.milhoan@freescale.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1438799328-10757-1-git-send-email-vicki.milhoan@freescale.com> References: <1438228709-27650-1-git-send-email-vicki.milhoan@freescale.com> <1438799328-10757-1-git-send-email-vicki.milhoan@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD050; 1:s+Rs7rKiMBKhc7y12AyAYRobLjqOAq5HyfiK6qi/dBqmBz7lDZMJ2Dsnd9dnHh4l6FEKxbhFPF21/fjho2bGc9rzimWGP5yO9lBK8+1gr4qNbNQiRA25O/vLBezGuPV1CAt9KJGYbLrD5VEzH8ZLdQJWYgqh/BY3gLG1qHKhiNB0wOygf6GItPyFRcBnEpPzW+yTAH8MzsQN344Z3hjjRTFwMC7rISa236MkbDRRfvzVcLUyRgv/6tQN7+jR+rNEjwQtTKY+ebjImlellHuAxGIwwubCYa+z70gNF6oQqyaZldnvfmraHccNzHn4DAoGEmCoPOOVyzOj5GEQSblhDA== X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(339900001)(189002)(199003)(2950100001)(76176999)(5001830100001)(81156007)(97736004)(50466002)(5001960100002)(2351001)(50226001)(104016003)(86362001)(87936001)(19580395003)(68736005)(19580405001)(33646002)(4001540100001)(48376002)(62966003)(85426001)(47776003)(5001860100001)(64706001)(229853001)(6806004)(69596002)(105606002)(110136002)(189998001)(77156002)(92566002)(46102003)(36756003)(50986999)(77096005)(106466001)(5003940100001); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR0301MB1569; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB1569; 2:ZErWADzX1AjDoqH9u+Zg6wHn2jkSLQ7HXzeNj3DUW8eMASIZoP+UdABTEaYw9Rb79pf3ANHgO2NrZuae0UDly7N4rkDRTy7AL5EbMb8j988uXSIAGgmypN4KB2o+ZvmCgMOauE2t2K73PZAuft3cgrW1FpWni7jK/R1Io4aYrVc=; 3:qK2XUeTnwq0fMogCYAtNM2mnL/+AGVKCDR06zlKGAoWglZQyZyLwYj1wdc3jWtOUY+ydEHZcoOpi/lClAnVaxW0s9zke+1ghjF58k48hTNI6EaUZHqCgrQAHueIYrftiq7AjL2+w3E0510PnJg9ZCzMa5ygCA3qyifHFIL98hU8xTMLThSQzJKBxIqtAToulsKBrr7VuZD7vAMHjX9RwaxFHM/xhnmklzz/CQRacMZM=; 25:WJPuvY+qh2TyfD7YUZILydrK5bQiTXelkwXastvcq+dD3NS9blnUMry9XwDCURHHCJXYT0at/lKPERCrW8/h4+5Y4lbiaeYPG6SRYqUpYYeZCZGcUvgRVtcwrcu72lKi/fe7lHLf5T4ceXyd2OOKrJZJWfhsIT0+PNmaz4AzyX+v9Jey5iw4kWpmsFKfVSmHDE2GSt3sZxFtSme0WmUAS6sE8tRxI/Jz2+KCjAiT/M/NHdvL3qNdQ3Ch747PYxFJls/Mm436uw2Y5l7eRcgUCQ== X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0301MB1569; UriScan:; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0301MB1586; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB1569; 20:6DcIN5O/GCW6tGFAnEn43XPnUKaWIHRLkNvCxGiotXGkNZx4jUjQ2l5ALJuv0pxOA9Ohl5/XyXbE1DPZmlLMPAKtOQugy4tNF5OVa7t0Hhzzq/wrOUGmFTDtLCDaTIfrt73s/DTlfxTY1gytXTGAZhmPI1PlJ3QaRUaafe4pU9H2AyXvbooiV/suBaLwz30SPLuygKEOWj3/OVv4bIQ3bk3BihM+c7VtJ0GF6I8ViGYudfQqH4mCsgd1bikCNjJ47K7IXjYNE1S8BoqUhKL+2wYUhAtGoTWNahAzOP1bswUHXGiYYCbDzzz529q/wI5iosQiCIZXyxILJXX00tONPDStjf3dUOhFVwk/reJByGg=; 4:dTyRmfvBs9vgNr9oN1RtMncJ/WVdpoaM6kxF9E/nRYhEfjfoxtGPB5YiUrpb2AgbHCVfom6YPnmjKmt0EqqFqvu+ycLDJyZi9esLOEZuxztlmQPdLTAv0HVzA7d2kwWDLOscLe22cflI/bOI/ZlQ4ebZ1CtBAyBswDbOAJtumUirJdf+94TxuX5ZUcNgPgvDJzyR6kZFOg/axG0KKnxvyXGWMp1V+L1Wpyemz3kL3iqeQOSGKoQSvyYJjiPGJsK+XFIrZoM7bPtyE1jAngzZ5sjBhvRo/Qto06avgsH6lM4= BLUPR0301MB1569: X-MS-Exchange-Organization-RulesExecuted X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:BLUPR0301MB1569; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0301MB1569; X-Forefront-PRVS: 06592CCE58 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0301MB1569; 23:/YeZA0OfHOdURqOwqxqck6Fk7vDgJ00YZOE3ags?= =?us-ascii?Q?mPSru99rz7UzeAZZcno9wi9V+NY8yeh3KvEW7x/MRTKHYphKz9ZoS0iSkcE2?= =?us-ascii?Q?3iwhwQ/Rk9HyYhCJIbZMW92lt5HJMgb9GcB9EkztKAVGDTfO8nCsZpvahrCh?= =?us-ascii?Q?7RTICq93sQbrKaLWvngK6iwq1dJYuZfpD2zuFwd6PFuR+sAVkBEISauY6DeA?= =?us-ascii?Q?vEiQvk/zg0TKuFjt74ydJek2B7+Kk5pKnV/wI8HLzdFUnG1+uAagYkgf3mrk?= =?us-ascii?Q?B0Tt+YYkZAMbFFwVk9hiHnj8eY0OMur0XLIqUnXTKo/ZZMyieiMZG6pgDQjk?= =?us-ascii?Q?8nSCt4zJHnFV4IGXpSE+SQBwbocry3m8UbRwaMBn8b+z73vdnEcH/QVWcgQD?= =?us-ascii?Q?we2BCUGOiTIudS2QeKm+xvF7454GkEb0kv1GGtq2V3uaKDF2UJTCKhrtc5Yq?= =?us-ascii?Q?xjMbXDqSu4s3v2ZUP0to2Fln4uwhHLyoPXAXgY3ZZB0HhDzRjTL71ccDJiWG?= =?us-ascii?Q?qbdOmKGwxqBVc53KV+APfivQaHPxud2pX2A/x9GQiS9bkli72s4YnbWsHMSv?= =?us-ascii?Q?YEWqqo3KqUMzl6GEHrSE1V9/1hZP2QkKTjVhbIIQTrgYzEv4OkDMIGlxIKI7?= =?us-ascii?Q?0pwuMUMekxwAH0Mnax7FTbHwsITC86UIwRKbumWT/DSlaxgV9LJkB7Hq6vfI?= =?us-ascii?Q?MTw25+GYMKW8TkzLFt4JQe4xp8NszDiuKJeyp2k80yBnh9YRutyf3/9LZtpj?= =?us-ascii?Q?YcrMx9L52nDAUZ7RVjQ1EPYQvYjFsG7TA85z0lvxoOGtR+KblIYwpOg9K1Lv?= =?us-ascii?Q?MaTSvxNT8fg3xdXJjziybo9nSDRH1Wqtmr0scfQR/WE6gu9FQbrhNNuI+4yH?= =?us-ascii?Q?LmWzmUYKstq8MjhXHrIwGZOfAYBjC3/rOn7nLmp4JyeFJN4N7nbeeUbdnSoD?= =?us-ascii?Q?63TEhCxuy4P0LRXhnjEY92HOxnHxgCrKqbFnSsw4JoWrlMmBKcZ3cpx0Yk6Q?= =?us-ascii?Q?NyDVkFO/3x8YVrw730P+g/9beCz6krymi05II7PcM4G/mywSYK0iDL6Z/Jr6?= =?us-ascii?Q?uQZPZf0sVELULbglS1Up4UY/iR7ZkI+NJoEL0sdvB9ve1P7zNV7isgbM06P5?= =?us-ascii?Q?+T1x4tT5MEIM=3D?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB1569; 5:9AkkIOwA/n2J7FrOcyF5uCXyA8hrRT8UxaYk/w8kqcKXatYjpx5djOC2u1Don/PbnYazs/tQk1Dy0BZGyDc+TEZuHJNGZaHyEWsba5T1daTAKM8qgQjFf1+drOqNfoNrT9txm4BOlDOLDVxZzKXVcA==; 24:+G9Xkkn6P/7xsZ6PIkuhWUcdzn8TYCKmnMAOKoqhIoLAzJlpx5w+jVEksIg12kaTg4fwdxCGgueEqOdJkLdouKlTwnXc0LsA8MemBp2nUpM=; 20:Jor9XDlmuTpJ3WNRDtMdtSYtV4W/IH0js3lmMFQB7/Zzhugkzvp/CxeXuOQxngwGRPy+QNV9uNHf2Mv4Pyky9w== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2015 18:28:51.1841 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0301MB1569 X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB1586; 2:VTJH1/fhgvrWdVUoJBKYcHHx53wKGIx7Y6ZAqrCdzUn53B+0PIEMeYDSA4Obd7SLYo613aN5r7DDJshrcq1n2MdVwG9Z6q/t9GL2EDyRlmcAb949Wz5BEoQKVsKov7oWrnC5v5I1+Idp6/TW94WdfwRSu/qhN7744KONB48dfZw=; 3:vUp0BUUWYihlWN5pQwjy4lM/8KZx6CT4JhBHKvw88+xdtsuPa7viqCLJgswfvzq68ldKfFHgLg4jmrgyonhsBXN4EMjmV9BXz4Ea7/M+2F5f/XDSzP+Kn+T8tJMtIkgKwE5v2t36kOd3PU3KOJxU4Ci57a9hfBvkEdijqIqIHy+mhf37n1H+tO0TeW1p1MB3S4UPtaFNeeqMwhNt2MHun0jmBuYcKLAWjmEOtxmKg4o=; 25:V5/kHbRQwpU0wWAdZllgajYuyYMcTtEon1EUm/2aHd3LrfZgGk3oYhC3l9sneYkaAzVL3tlyRd0H1IB4ESlkoZhJsNdh197q2a+vESPiN5NmA1uHRSlqv/oaGIM6mfxQ1J8e5Rhs6qvyTnp0RegGxWTIMI234jboAUXU4UZ7jR+/gLVZta6k2Ybl7fIF3YxtinGyMVp+IOYYzZsCT9qoi4vnGM8CQYvowVDngCV+1zDTEJcZhdBHnRQop/6RHA88vIaSKyqA+IpiOfI0jyzyaw==; 23:ybUwhGp22uR8exGEkl2sqOoIou/Xpf9iZakmooYBji95HBalF55TOXO6zukGF4NXxInzDFX6JcrBIVj21/xTXmGMdhs8qUuBA70xxx8+xo53AJD4eHdsWeiGcY9lB0ELpQ+Cd5aHMobQljtJ2HiuQJSLQ23zercsSX24XsC9niMLeTl7h/P0ZnOknAXSVUha X-OriginatorOrg: freescale.com Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 ARM-based systems may disable clocking to the CAAM device on the Freescale i.MX platform for power management purposes. This patch enables the required clocks when the CAAM module is initialized and disables the required clocks when the CAAM module is shut down. Signed-off-by: Victoria Milhoan --- drivers/crypto/caam/compat.h | 1 + drivers/crypto/caam/ctrl.c | 88 ++++++++++++++++++++++++++++++++++++++++++++ drivers/crypto/caam/intern.h | 5 +++ 3 files changed, 94 insertions(+) diff --git a/drivers/crypto/caam/compat.h b/drivers/crypto/caam/compat.h index f57f395..b6955ec 100644 --- a/drivers/crypto/caam/compat.h +++ b/drivers/crypto/caam/compat.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index 660cc3e..37c2d8d 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c @@ -16,6 +16,24 @@ #include "error.h" /* + * ARM targets tend to have clock control subsystems that can + * enable/disable clocking to our device. + */ +#ifdef CONFIG_ARM +static inline struct clk *caam_drv_identify_clk(struct device *dev, + char *clk_name) +{ + return devm_clk_get(dev, clk_name); +} +#else +static inline struct clk *caam_drv_identify_clk(struct device *dev, + char *clk_name) +{ + return NULL; +} +#endif + +/* * Descriptor to instantiate RNG State Handle 0 in normal mode and * load the JDKEK, TDKEK and TDSK registers */ @@ -304,6 +322,12 @@ static int caam_remove(struct platform_device *pdev) /* Unmap controller region */ iounmap(ctrl); + /* shut clocks off before finalizing shutdown */ + clk_disable_unprepare(ctrlpriv->caam_ipg); + clk_disable_unprepare(ctrlpriv->caam_mem); + clk_disable_unprepare(ctrlpriv->caam_aclk); + clk_disable_unprepare(ctrlpriv->caam_emi_slow); + return ret; } @@ -391,6 +415,7 @@ static int caam_probe(struct platform_device *pdev) struct device_node *nprop, *np; struct caam_ctrl __iomem *ctrl; struct caam_drv_private *ctrlpriv; + struct clk *clk; #ifdef CONFIG_DEBUG_FS struct caam_perfmon *perfmon; #endif @@ -409,6 +434,69 @@ static int caam_probe(struct platform_device *pdev) ctrlpriv->pdev = pdev; nprop = pdev->dev.of_node; + /* Enable clocking */ + clk = caam_drv_identify_clk(&pdev->dev, "ipg"); + if (IS_ERR(clk)) { + ret = PTR_ERR(clk); + dev_err(&pdev->dev, + "can't identify CAAM ipg clk: %d\n", ret); + return -ENODEV; + } + ctrlpriv->caam_ipg = clk; + + clk = caam_drv_identify_clk(&pdev->dev, "mem"); + if (IS_ERR(clk)) { + ret = PTR_ERR(clk); + dev_err(&pdev->dev, + "can't identify CAAM mem clk: %d\n", ret); + return -ENODEV; + } + ctrlpriv->caam_mem = clk; + + clk = caam_drv_identify_clk(&pdev->dev, "aclk"); + if (IS_ERR(clk)) { + ret = PTR_ERR(clk); + dev_err(&pdev->dev, + "can't identify CAAM aclk clk: %d\n", ret); + return -ENODEV; + } + ctrlpriv->caam_aclk = clk; + + clk = caam_drv_identify_clk(&pdev->dev, "emi_slow"); + if (IS_ERR(clk)) { + ret = PTR_ERR(clk); + dev_err(&pdev->dev, + "can't identify CAAM emi_slow clk: %d\n", ret); + return -ENODEV; + } + ctrlpriv->caam_emi_slow = clk; + + ret = clk_prepare_enable(ctrlpriv->caam_ipg); + if (ret < 0) { + dev_err(&pdev->dev, "can't enable CAAM ipg clock: %d\n", ret); + return -ENODEV; + } + + ret = clk_prepare_enable(ctrlpriv->caam_mem); + if (ret < 0) { + dev_err(&pdev->dev, "can't enable CAAM secure mem clock: %d\n", + ret); + return -ENODEV; + } + + ret = clk_prepare_enable(ctrlpriv->caam_aclk); + if (ret < 0) { + dev_err(&pdev->dev, "can't enable CAAM aclk clock: %d\n", ret); + return -ENODEV; + } + + ret = clk_prepare_enable(ctrlpriv->caam_emi_slow); + if (ret < 0) { + dev_err(&pdev->dev, "can't enable CAAM emi slow clock: %d\n", + ret); + return -ENODEV; + } + /* Get configuration properties from device tree */ /* First, get register page */ ctrl = of_iomap(nprop, 0); diff --git a/drivers/crypto/caam/intern.h b/drivers/crypto/caam/intern.h index 89b94cc..e2bcacc 100644 --- a/drivers/crypto/caam/intern.h +++ b/drivers/crypto/caam/intern.h @@ -91,6 +91,11 @@ struct caam_drv_private { Handles of the RNG4 block are initialized by this driver */ + struct clk *caam_ipg; + struct clk *caam_mem; + struct clk *caam_aclk; + struct clk *caam_emi_slow; + /* * debugfs entries for developer view into driver/device * variables at runtime.