From: Leonard Crestez Subject: [PATCH v2 2/4] crypto: mxs-dcp - Add support for dcp clk Date: Mon, 15 Oct 2018 13:27:37 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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" To: Shawn Guo , Fabio Estevam Return-path: In-Reply-To: Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-crypto.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 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/crypto/mxs-dcp.c b/drivers/crypto/mxs-dcp.c index 849a81ece079..fd13787a2a0e 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, @@ -1027,10 +1029,24 @@ static int mxs_dcp_probe(struct platform_device *pd= ev) sdcp->dev =3D dev; sdcp->base =3D devm_ioremap_resource(dev, iores); if (IS_ERR(sdcp->base)) return PTR_ERR(sdcp->base); =20 + /* 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(sdcp->dcp_clk); + if (ret) + return ret; + ret =3D clk_enable(sdcp->dcp_clk); + if (ret) + return ret; =20 ret =3D devm_request_irq(dev, dcp_vmi_irq, mxs_dcp_irq, 0, "dcp-vmi-irq", sdcp); if (ret) { dev_err(dev, "Failed to claim DCP VMI IRQ!\n"); @@ -1168,10 +1184,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(sdcp->dcp_clk); + platform_set_drvdata(pdev, NULL); =20 global_sdcp =3D NULL; =20 return 0; --=20 2.17.1