Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: mxs-dcp - Add support for dcp clk

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 <leonard.crestez@nxp.com>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Leonard Crestez and committed by
Herbert Xu
57f00289 70db8b79

+25 -3
+25 -3
drivers/crypto/mxs-dcp.c
··· 20 20 #include <linux/of.h> 21 21 #include <linux/platform_device.h> 22 22 #include <linux/stmp_device.h> 23 + #include <linux/clk.h> 23 24 24 25 #include <crypto/aes.h> 25 26 #include <crypto/sha.h> ··· 83 82 spinlock_t lock[DCP_MAX_CHANS]; 84 83 struct task_struct *thread[DCP_MAX_CHANS]; 85 84 struct crypto_queue queue[DCP_MAX_CHANS]; 85 + struct clk *dcp_clk; 86 86 }; 87 87 88 88 enum dcp_chan { ··· 1055 1053 /* Re-align the structure so it fits the DCP constraints. */ 1056 1054 sdcp->coh = PTR_ALIGN(sdcp->coh, DCP_ALIGNMENT); 1057 1055 1058 - /* Restart the DCP block. */ 1059 - ret = stmp_reset_block(sdcp->base); 1056 + /* DCP clock is optional, only used on some SOCs */ 1057 + sdcp->dcp_clk = devm_clk_get(dev, "dcp"); 1058 + if (IS_ERR(sdcp->dcp_clk)) { 1059 + if (sdcp->dcp_clk != ERR_PTR(-ENOENT)) 1060 + return PTR_ERR(sdcp->dcp_clk); 1061 + sdcp->dcp_clk = NULL; 1062 + } 1063 + ret = clk_prepare_enable(sdcp->dcp_clk); 1060 1064 if (ret) 1061 1065 return ret; 1066 + 1067 + /* Restart the DCP block. */ 1068 + ret = stmp_reset_block(sdcp->base); 1069 + if (ret) { 1070 + dev_err(dev, "Failed reset\n"); 1071 + goto err_disable_unprepare_clk; 1072 + } 1062 1073 1063 1074 /* Initialize control register. */ 1064 1075 writel(MXS_DCP_CTRL_GATHER_RESIDUAL_WRITES | ··· 1109 1094 NULL, "mxs_dcp_chan/sha"); 1110 1095 if (IS_ERR(sdcp->thread[DCP_CHAN_HASH_SHA])) { 1111 1096 dev_err(dev, "Error starting SHA thread!\n"); 1112 - return PTR_ERR(sdcp->thread[DCP_CHAN_HASH_SHA]); 1097 + ret = PTR_ERR(sdcp->thread[DCP_CHAN_HASH_SHA]); 1098 + goto err_disable_unprepare_clk; 1113 1099 } 1114 1100 1115 1101 sdcp->thread[DCP_CHAN_CRYPTO] = kthread_run(dcp_chan_thread_aes, ··· 1167 1151 1168 1152 err_destroy_sha_thread: 1169 1153 kthread_stop(sdcp->thread[DCP_CHAN_HASH_SHA]); 1154 + 1155 + err_disable_unprepare_clk: 1156 + clk_disable_unprepare(sdcp->dcp_clk); 1157 + 1170 1158 return ret; 1171 1159 } 1172 1160 ··· 1189 1169 1190 1170 kthread_stop(sdcp->thread[DCP_CHAN_HASH_SHA]); 1191 1171 kthread_stop(sdcp->thread[DCP_CHAN_CRYPTO]); 1172 + 1173 + clk_disable_unprepare(sdcp->dcp_clk); 1192 1174 1193 1175 platform_set_drvdata(pdev, NULL); 1194 1176