Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp609736imm; Wed, 17 Oct 2018 05:40:09 -0700 (PDT) X-Google-Smtp-Source: ACcGV62DzCFV9Mo3n7ijX5HhL3oLNmZMQezwIAVh9dLrLXV32j4lfHR7ruUTOhaRbETxm/imXpxz X-Received: by 2002:a62:830e:: with SMTP id h14-v6mr26825440pfe.29.1539780009028; Wed, 17 Oct 2018 05:40:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539780008; cv=none; d=google.com; s=arc-20160816; b=IxbTAeaiZ97ypbrvb9OpnyL7NBBc1YMmm2C/By5uLfxJ0Hpr9t5So/YFRH/vCHozmX SPQaXnAPbQvaqfcSvZ9bILQhXCV7MpQemplfYxc+fIxuWzHJsnw8KM35DB3zaidF3mFF ptIPekYYfuFsf4Lnvh4gU/jWyIYbwJKmL46nsZvmylwTjEMetRLEsT/9LTeuugqOQR6I gJoGV5q1l+m6cY0G262UYeftQiJsPHXcWAQIKCpnPbuva7J5/6wG2PXVmunff/BSR/bA oLcVdYLFdu2s1sv8iMNmrY6wS05UWX8/DcJKaiqFFpJ+eINONYj5tqT76pXV3PHKqTgh /6PQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature; bh=YjEsZ3YDpb4PmUooqzUS9/tlVt8PAZjLWajq36Z3dFo=; b=RM8x9zRtSUe+gIAvflg4PE2aITMIh2RieHUiSAC2Xhh1hbKxfO+Za9YnDWKY/tbs41 LDgp4R41PZ9kbrnVFjIbrZQ22oWeJEBmu+lm3qusKtWrHvj8/KwOsNK7dQikCNgdFJlY 2C7NJw8R/LCnzAk9ia5HpfRCo4054AvEIrxbomzIghKVcis4g806UbeDBu8b8uO8iP77 Bl0ehixejv7LXlDCOheGYplD4uVCoVnUREUDKz+9L82oG2EFaO6x3Zs2WXUjsh6tvGGC RvLEGhHLydQ8zGM0DOlPMjAOM2/i5HhLedpq9UdhW4UFEAsIDE+S+Ei4iOg/h2dajgPG +DBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=uj3O1kjE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v13-v6si18027084pfc.257.2018.10.17.05.39.53; Wed, 17 Oct 2018 05:40:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=uj3O1kjE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727401AbeJQUdc (ORCPT + 99 others); Wed, 17 Oct 2018 16:33:32 -0400 Received: from mail-eopbgr80055.outbound.protection.outlook.com ([40.107.8.55]:8163 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727331AbeJQUdb (ORCPT ); Wed, 17 Oct 2018 16:33:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YjEsZ3YDpb4PmUooqzUS9/tlVt8PAZjLWajq36Z3dFo=; b=uj3O1kjEdO0NsQTnuCpkkbMtQZgTD5RS+WkHHg+SAAoy3iVstbUk/N39TZvbhnE3Nkz4D519SwRHyw1Yal4rFt/Ok1BWtyLfrjYkXfJlFGia3oT2Vx4EnF1BPoIHMU3j4Sx4YfpWDzyxEcMtLe1M/PSJKYFi/X0LOJUEK4Ig4aU= Received: from AM0PR04MB4290.eurprd04.prod.outlook.com (52.134.126.145) by AM0PR04MB4212.eurprd04.prod.outlook.com (52.134.126.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.26; Wed, 17 Oct 2018 12:37:53 +0000 Received: from AM0PR04MB4290.eurprd04.prod.outlook.com ([fe80::3836:6416:4ebd:34ef]) by AM0PR04MB4290.eurprd04.prod.outlook.com ([fe80::3836:6416:4ebd:34ef%3]) with mapi id 15.20.1228.032; Wed, 17 Oct 2018 12:37:53 +0000 From: Leonard Crestez To: Shawn Guo , Fabio Estevam CC: Rob Herring , Marek Vasut , Herbert Xu , Horia Geanta , Franck Lenormand , Aymen Sghaier , "David S . Miller " , Mark Rutland , "devicetree@vger.kernel.org" , "linux-crypto@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , dl-linux-imx , "kernel@pengutronix.de" , "linux-kernel@vger.kernel.org" Subject: [PATCH v4 2/4] crypto: mxs-dcp - Add support for dcp clk Thread-Topic: [PATCH v4 2/4] crypto: mxs-dcp - Add support for dcp clk Thread-Index: AQHUZhY4HefM3c9m50qn78KSFJ8+NA== Date: Wed, 17 Oct 2018 12:37:53 +0000 Message-ID: <95dce7010676581691b1ac9906e9298470e0aa1a.1539779579.git.leonard.crestez@nxp.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [95.76.156.53] x-mailer: git-send-email 2.17.1 x-clientproxiedby: AM6P191CA0098.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:8a::39) To AM0PR04MB4290.eurprd04.prod.outlook.com (2603:10a6:208:67::17) x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;AM0PR04MB4212;6:4L5EVe8HIPMLs3VxJ3B0lWCzLUev1du1VX+6/eNjxqhoiBShYoq1C2KLC4ImoAJfcqA74lldlioFfTaQVGYVLUL4oo32r2JMYDtKIezmqb7GgIsZdZxzmqQuKKtqIsqL+Kme96sUQhKy15bmQ29C7d0JfvWOkvHgqBphG5Az1JzXNyehmAiJ3PAKfqfu3FctJpsOTNTqbW8LtlFOCU1wPPQ8mU4Ghaz5mTeH5b/9obqXuKunEpe6kfzqVx/ty9Zhhh2PSQAfHZdmQzpXJ3NRFGm+AHCQs+j8SW79Vsrxqgmle5tQHBa+ERhPXBoKtQZXzxWZopERmjZizW+vr57PsKdZuXu1pBnzHLczh7yQpqAmbk/5/k2juqOFOASFHdIHiyO0poaGlRehL0qSLQlCk2Sx6U+UWvd2ak4HYub8V5GgnUV9PLfT3TnyGp+n3l4h1Y5My03xm5EXiJERhcx1Vg==;5:JJ53mFOhA9oQaVRRKBx+rAFURtDSQQTLjjrDlTI3Q7WJG4ifbtKiUheqU3XyCPbOUQiCb2mmwdIwEh0pl1YjAYaZXD/NIZGV6TS0jPmQrgH2kNwo7CfhEJK6vWCk8HcON4K+26QiB51LmQ2V1uZ1WUEA0IpxxRzccfrSm/ofzvQ=;7:AVNd5SIw9ErmE05Gexck5CmC+fZ31V3x+1seQnD5nLtEdCbbEZr65GOFaRU7v7FrySjekQoPxvaeVob597+rAD4G/krpSPJAzcGMe8R2MbKGDSdsvOoe96Ey1FeAab1fx3ZAQ4kelTdWxhYpmgI71MIEEc3i0+bsvVtsm0/E7y0Ae2EA48FLggYByPLd0d+8/TELzJ4yv6WGgHrmZcqIboTPtkRjVX6+76ASsSIeQElUal2AdrFR6gPfWhcndxo7 x-ms-office365-filtering-correlation-id: ce36bcb5-2b43-40b7-fb78-08d6342d5b2a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:AM0PR04MB4212; x-ms-traffictypediagnostic: AM0PR04MB4212: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(185117386973197); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231355)(944501410)(52105095)(6055026)(149066)(150057)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095);SRVR:AM0PR04MB4212;BCL:0;PCL:0;RULEID:;SRVR:AM0PR04MB4212; x-forefront-prvs: 08286A0BE2 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(136003)(396003)(366004)(346002)(39860400002)(376002)(189003)(199004)(71200400001)(71190400001)(6636002)(446003)(118296001)(11346002)(54906003)(110136005)(52116002)(476003)(2616005)(81166006)(6486002)(81156014)(7736002)(8676002)(50226002)(316002)(256004)(5660300001)(86362001)(305945005)(66066001)(68736007)(53936002)(4326008)(486006)(25786009)(478600001)(44832011)(39060400002)(14454004)(6436002)(6512007)(8936002)(386003)(26005)(76176011)(6346003)(36756003)(97736004)(3846002)(6506007)(6116002)(102836004)(2900100001)(7416002)(2906002)(99286004)(186003)(105586002)(106356001)(5250100002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR04MB4212;H:AM0PR04MB4290.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=leonard.crestez@nxp.com; x-microsoft-antispam-message-info: CKJUZAaEXmueAGRakQfsUbugDTNy/UbhbluN1TRpK3nu4jiw/KSCbrv7HUer9AabSAjJVfi+Pn7/x8jUX/iRciv1ffT80txfkJPD4JYRxA7aqRZHA3LLA20EL4aWZBTHHKFgR0DSHD/6MJYme6dOPQ8ikYDgqfoj608hiiALSks9v6PNgkI9jkaTqeITKQJFmLooBAkSLXI/IuO2LUbXKProm2y8l3T/U/R8ggS9+F0TXTQ8Rs9OjD9D+VmfsJzsMNlLrLLKQPUY98jM4E6cDnEeo69TcVwb/1DqdgWZO74f0GtgTHoXRFsFd5Y3RPGs3B+i71Wp2fu5zW4/TVMlLfLtqmLlf/QkA0VhV0U/oTQ= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ce36bcb5-2b43-40b7-fb78-08d6342d5b2a X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Oct 2018 12:37:53.0962 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4212 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6ull and 6sll the DCP block has a clock which needs to be explicitly enabled. Add minimal handling for this at probe/remove time. Signed-off-by: Leonard Crestez --- drivers/crypto/mxs-dcp.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/mxs-dcp.c b/drivers/crypto/mxs-dcp.c index 4e6ff32f8a7e..a2105cf33abb 100644 --- a/drivers/crypto/mxs-dcp.c +++ b/drivers/crypto/mxs-dcp.c @@ -18,10 +18,11 @@ #include #include #include #include #include +#include =20 #include #include #include #include @@ -80,10 +81,11 @@ struct dcp { =20 struct completion completion[DCP_MAX_CHANS]; spinlock_t lock[DCP_MAX_CHANS]; struct task_struct *thread[DCP_MAX_CHANS]; struct crypto_queue queue[DCP_MAX_CHANS]; + struct clk *dcp_clk; }; =20 enum dcp_chan { DCP_CHAN_HASH_SHA =3D 0, DCP_CHAN_CRYPTO =3D 2, @@ -1051,15 +1053,28 @@ static int mxs_dcp_probe(struct platform_device *pd= ev) return -ENOMEM; =20 /* Re-align the structure so it fits the DCP constraints. */ sdcp->coh =3D PTR_ALIGN(sdcp->coh, DCP_ALIGNMENT); =20 - /* Restart the DCP block. */ - ret =3D stmp_reset_block(sdcp->base); + /* DCP clock is optional, only used on some SOCs */ + sdcp->dcp_clk =3D devm_clk_get(dev, "dcp"); + if (IS_ERR(sdcp->dcp_clk)) { + if (sdcp->dcp_clk !=3D ERR_PTR(-ENOENT)) + return PTR_ERR(sdcp->dcp_clk); + sdcp->dcp_clk =3D NULL; + } + ret =3D clk_prepare_enable(sdcp->dcp_clk); if (ret) return ret; =20 + /* Restart the DCP block. */ + ret =3D stmp_reset_block(sdcp->base); + if (ret) { + dev_err(dev, "Failed reset\n"); + goto err_disable_unprepare_clk; + } + /* Initialize control register. */ writel(MXS_DCP_CTRL_GATHER_RESIDUAL_WRITES | MXS_DCP_CTRL_ENABLE_CONTEXT_CACHING | 0xf, sdcp->base + MXS_DCP_CTRL); =20 @@ -1092,11 +1107,12 @@ static int mxs_dcp_probe(struct platform_device *pd= ev) /* Create the SHA and AES handler threads. */ sdcp->thread[DCP_CHAN_HASH_SHA] =3D kthread_run(dcp_chan_thread_sha, NULL, "mxs_dcp_chan/sha"); if (IS_ERR(sdcp->thread[DCP_CHAN_HASH_SHA])) { dev_err(dev, "Error starting SHA thread!\n"); - return PTR_ERR(sdcp->thread[DCP_CHAN_HASH_SHA]); + ret =3D PTR_ERR(sdcp->thread[DCP_CHAN_HASH_SHA]); + goto err_disable_unprepare_clk; } =20 sdcp->thread[DCP_CHAN_CRYPTO] =3D kthread_run(dcp_chan_thread_aes, NULL, "mxs_dcp_chan/aes"); if (IS_ERR(sdcp->thread[DCP_CHAN_CRYPTO])) { @@ -1149,10 +1165,14 @@ static int mxs_dcp_probe(struct platform_device *pd= ev) err_destroy_aes_thread: kthread_stop(sdcp->thread[DCP_CHAN_CRYPTO]); =20 err_destroy_sha_thread: kthread_stop(sdcp->thread[DCP_CHAN_HASH_SHA]); + +err_disable_unprepare_clk: + clk_disable_unprepare(sdcp->dcp_clk); + return ret; } =20 static int mxs_dcp_remove(struct platform_device *pdev) { @@ -1168,10 +1188,12 @@ static int mxs_dcp_remove(struct platform_device *p= dev) crypto_unregister_algs(dcp_aes_algs, ARRAY_SIZE(dcp_aes_algs)); =20 kthread_stop(sdcp->thread[DCP_CHAN_HASH_SHA]); kthread_stop(sdcp->thread[DCP_CHAN_CRYPTO]); =20 + clk_disable_unprepare(sdcp->dcp_clk); + platform_set_drvdata(pdev, NULL); =20 global_sdcp =3D NULL; =20 return 0; --=20 2.17.1