mv_cesa.c 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217
  1. /*
  2. * Support for Marvell's crypto engine which can be found on some Orion5X
  3. * boards.
  4. *
  5. * Author: Sebastian Andrzej Siewior < sebastian at breakpoint dot cc >
  6. * License: GPLv2
  7. *
  8. */
  9. #include <crypto/aes.h>
  10. #include <crypto/algapi.h>
  11. #include <linux/crypto.h>
  12. #include <linux/genalloc.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/io.h>
  15. #include <linux/kthread.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/scatterlist.h>
  18. #include <linux/slab.h>
  19. #include <linux/module.h>
  20. #include <linux/clk.h>
  21. #include <crypto/hmac.h>
  22. #include <crypto/internal/hash.h>
  23. #include <crypto/sha.h>
  24. #include <linux/of.h>
  25. #include <linux/of_platform.h>
  26. #include <linux/of_irq.h>
  27. #include "mv_cesa.h"
  28. #define MV_CESA "MV-CESA:"
  29. #define MAX_HW_HASH_SIZE 0xFFFF
  30. #define MV_CESA_EXPIRE 500 /* msec */
  31. #define MV_CESA_DEFAULT_SRAM_SIZE 2048
  32. /*
  33. * STM:
  34. * /---------------------------------------\
  35. * | | request complete
  36. * \./ |
  37. * IDLE -> new request -> BUSY -> done -> DEQUEUE
  38. * /°\ |
  39. * | | more scatter entries
  40. * \________________/
  41. */
  42. enum engine_status {
  43. ENGINE_IDLE,
  44. ENGINE_BUSY,
  45. ENGINE_W_DEQUEUE,
  46. };
  47. /**
  48. * struct req_progress - used for every crypt request
  49. * @src_sg_it: sg iterator for src
  50. * @dst_sg_it: sg iterator for dst
  51. * @sg_src_left: bytes left in src to process (scatter list)
  52. * @src_start: offset to add to src start position (scatter list)
  53. * @crypt_len: length of current hw crypt/hash process
  54. * @hw_nbytes: total bytes to process in hw for this request
  55. * @copy_back: whether to copy data back (crypt) or not (hash)
  56. * @sg_dst_left: bytes left dst to process in this scatter list
  57. * @dst_start: offset to add to dst start position (scatter list)
  58. * @hw_processed_bytes: number of bytes processed by hw (request).
  59. *
  60. * sg helper are used to iterate over the scatterlist. Since the size of the
  61. * SRAM may be less than the scatter size, this struct struct is used to keep
  62. * track of progress within current scatterlist.
  63. */
  64. struct req_progress {
  65. struct sg_mapping_iter src_sg_it;
  66. struct sg_mapping_iter dst_sg_it;
  67. void (*complete) (void);
  68. void (*process) (int is_first);
  69. /* src mostly */
  70. int sg_src_left;
  71. int src_start;
  72. int crypt_len;
  73. int hw_nbytes;
  74. /* dst mostly */
  75. int copy_back;
  76. int sg_dst_left;
  77. int dst_start;
  78. int hw_processed_bytes;
  79. };
  80. struct crypto_priv {
  81. void __iomem *reg;
  82. void __iomem *sram;
  83. struct gen_pool *sram_pool;
  84. dma_addr_t sram_dma;
  85. int irq;
  86. struct clk *clk;
  87. struct task_struct *queue_th;
  88. /* the lock protects queue and eng_st */
  89. spinlock_t lock;
  90. struct crypto_queue queue;
  91. enum engine_status eng_st;
  92. struct timer_list completion_timer;
  93. struct crypto_async_request *cur_req;
  94. struct req_progress p;
  95. int max_req_size;
  96. int sram_size;
  97. int has_sha1;
  98. int has_hmac_sha1;
  99. };
  100. static struct crypto_priv *cpg;
  101. struct mv_ctx {
  102. u8 aes_enc_key[AES_KEY_LEN];
  103. u32 aes_dec_key[8];
  104. int key_len;
  105. u32 need_calc_aes_dkey;
  106. };
  107. enum crypto_op {
  108. COP_AES_ECB,
  109. COP_AES_CBC,
  110. };
  111. struct mv_req_ctx {
  112. enum crypto_op op;
  113. int decrypt;
  114. };
  115. enum hash_op {
  116. COP_SHA1,
  117. COP_HMAC_SHA1
  118. };
  119. struct mv_tfm_hash_ctx {
  120. struct crypto_shash *fallback;
  121. struct crypto_shash *base_hash;
  122. u32 ivs[2 * SHA1_DIGEST_SIZE / 4];
  123. int count_add;
  124. enum hash_op op;
  125. };
  126. struct mv_req_hash_ctx {
  127. u64 count;
  128. u32 state[SHA1_DIGEST_SIZE / 4];
  129. u8 buffer[SHA1_BLOCK_SIZE];
  130. int first_hash; /* marks that we don't have previous state */
  131. int last_chunk; /* marks that this is the 'final' request */
  132. int extra_bytes; /* unprocessed bytes in buffer */
  133. enum hash_op op;
  134. int count_add;
  135. };
  136. static void mv_completion_timer_callback(unsigned long unused)
  137. {
  138. int active = readl(cpg->reg + SEC_ACCEL_CMD) & SEC_CMD_EN_SEC_ACCL0;
  139. printk(KERN_ERR MV_CESA
  140. "completion timer expired (CESA %sactive), cleaning up.\n",
  141. active ? "" : "in");
  142. del_timer(&cpg->completion_timer);
  143. writel(SEC_CMD_DISABLE_SEC, cpg->reg + SEC_ACCEL_CMD);
  144. while(readl(cpg->reg + SEC_ACCEL_CMD) & SEC_CMD_DISABLE_SEC)
  145. printk(KERN_INFO MV_CESA "%s: waiting for engine finishing\n", __func__);
  146. cpg->eng_st = ENGINE_W_DEQUEUE;
  147. wake_up_process(cpg->queue_th);
  148. }
  149. static void mv_setup_timer(void)
  150. {
  151. setup_timer(&cpg->completion_timer, &mv_completion_timer_callback, 0);
  152. mod_timer(&cpg->completion_timer,
  153. jiffies + msecs_to_jiffies(MV_CESA_EXPIRE));
  154. }
  155. static void compute_aes_dec_key(struct mv_ctx *ctx)
  156. {
  157. struct crypto_aes_ctx gen_aes_key;
  158. int key_pos;
  159. if (!ctx->need_calc_aes_dkey)
  160. return;
  161. crypto_aes_expand_key(&gen_aes_key, ctx->aes_enc_key, ctx->key_len);
  162. key_pos = ctx->key_len + 24;
  163. memcpy(ctx->aes_dec_key, &gen_aes_key.key_enc[key_pos], 4 * 4);
  164. switch (ctx->key_len) {
  165. case AES_KEYSIZE_256:
  166. key_pos -= 2;
  167. /* fall */
  168. case AES_KEYSIZE_192:
  169. key_pos -= 2;
  170. memcpy(&ctx->aes_dec_key[4], &gen_aes_key.key_enc[key_pos],
  171. 4 * 4);
  172. break;
  173. }
  174. ctx->need_calc_aes_dkey = 0;
  175. }
  176. static int mv_setkey_aes(struct crypto_ablkcipher *cipher, const u8 *key,
  177. unsigned int len)
  178. {
  179. struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher);
  180. struct mv_ctx *ctx = crypto_tfm_ctx(tfm);
  181. switch (len) {
  182. case AES_KEYSIZE_128:
  183. case AES_KEYSIZE_192:
  184. case AES_KEYSIZE_256:
  185. break;
  186. default:
  187. crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN);
  188. return -EINVAL;
  189. }
  190. ctx->key_len = len;
  191. ctx->need_calc_aes_dkey = 1;
  192. memcpy(ctx->aes_enc_key, key, AES_KEY_LEN);
  193. return 0;
  194. }
  195. static void copy_src_to_buf(struct req_progress *p, char *dbuf, int len)
  196. {
  197. int ret;
  198. void *sbuf;
  199. int copy_len;
  200. while (len) {
  201. if (!p->sg_src_left) {
  202. ret = sg_miter_next(&p->src_sg_it);
  203. BUG_ON(!ret);
  204. p->sg_src_left = p->src_sg_it.length;
  205. p->src_start = 0;
  206. }
  207. sbuf = p->src_sg_it.addr + p->src_start;
  208. copy_len = min(p->sg_src_left, len);
  209. memcpy(dbuf, sbuf, copy_len);
  210. p->src_start += copy_len;
  211. p->sg_src_left -= copy_len;
  212. len -= copy_len;
  213. dbuf += copy_len;
  214. }
  215. }
  216. static void setup_data_in(void)
  217. {
  218. struct req_progress *p = &cpg->p;
  219. int data_in_sram =
  220. min(p->hw_nbytes - p->hw_processed_bytes, cpg->max_req_size);
  221. copy_src_to_buf(p, cpg->sram + SRAM_DATA_IN_START + p->crypt_len,
  222. data_in_sram - p->crypt_len);
  223. p->crypt_len = data_in_sram;
  224. }
  225. static void mv_process_current_q(int first_block)
  226. {
  227. struct ablkcipher_request *req = ablkcipher_request_cast(cpg->cur_req);
  228. struct mv_ctx *ctx = crypto_tfm_ctx(req->base.tfm);
  229. struct mv_req_ctx *req_ctx = ablkcipher_request_ctx(req);
  230. struct sec_accel_config op;
  231. switch (req_ctx->op) {
  232. case COP_AES_ECB:
  233. op.config = CFG_OP_CRYPT_ONLY | CFG_ENCM_AES | CFG_ENC_MODE_ECB;
  234. break;
  235. case COP_AES_CBC:
  236. default:
  237. op.config = CFG_OP_CRYPT_ONLY | CFG_ENCM_AES | CFG_ENC_MODE_CBC;
  238. op.enc_iv = ENC_IV_POINT(SRAM_DATA_IV) |
  239. ENC_IV_BUF_POINT(SRAM_DATA_IV_BUF);
  240. if (first_block)
  241. memcpy(cpg->sram + SRAM_DATA_IV, req->info, 16);
  242. break;
  243. }
  244. if (req_ctx->decrypt) {
  245. op.config |= CFG_DIR_DEC;
  246. memcpy(cpg->sram + SRAM_DATA_KEY_P, ctx->aes_dec_key,
  247. AES_KEY_LEN);
  248. } else {
  249. op.config |= CFG_DIR_ENC;
  250. memcpy(cpg->sram + SRAM_DATA_KEY_P, ctx->aes_enc_key,
  251. AES_KEY_LEN);
  252. }
  253. switch (ctx->key_len) {
  254. case AES_KEYSIZE_128:
  255. op.config |= CFG_AES_LEN_128;
  256. break;
  257. case AES_KEYSIZE_192:
  258. op.config |= CFG_AES_LEN_192;
  259. break;
  260. case AES_KEYSIZE_256:
  261. op.config |= CFG_AES_LEN_256;
  262. break;
  263. }
  264. op.enc_p = ENC_P_SRC(SRAM_DATA_IN_START) |
  265. ENC_P_DST(SRAM_DATA_OUT_START);
  266. op.enc_key_p = SRAM_DATA_KEY_P;
  267. setup_data_in();
  268. op.enc_len = cpg->p.crypt_len;
  269. memcpy(cpg->sram + SRAM_CONFIG, &op,
  270. sizeof(struct sec_accel_config));
  271. /* GO */
  272. mv_setup_timer();
  273. writel(SEC_CMD_EN_SEC_ACCL0, cpg->reg + SEC_ACCEL_CMD);
  274. }
  275. static void mv_crypto_algo_completion(void)
  276. {
  277. struct ablkcipher_request *req = ablkcipher_request_cast(cpg->cur_req);
  278. struct mv_req_ctx *req_ctx = ablkcipher_request_ctx(req);
  279. sg_miter_stop(&cpg->p.src_sg_it);
  280. sg_miter_stop(&cpg->p.dst_sg_it);
  281. if (req_ctx->op != COP_AES_CBC)
  282. return ;
  283. memcpy(req->info, cpg->sram + SRAM_DATA_IV_BUF, 16);
  284. }
  285. static void mv_process_hash_current(int first_block)
  286. {
  287. struct ahash_request *req = ahash_request_cast(cpg->cur_req);
  288. const struct mv_tfm_hash_ctx *tfm_ctx = crypto_tfm_ctx(req->base.tfm);
  289. struct mv_req_hash_ctx *req_ctx = ahash_request_ctx(req);
  290. struct req_progress *p = &cpg->p;
  291. struct sec_accel_config op = { 0 };
  292. int is_last;
  293. switch (req_ctx->op) {
  294. case COP_SHA1:
  295. default:
  296. op.config = CFG_OP_MAC_ONLY | CFG_MACM_SHA1;
  297. break;
  298. case COP_HMAC_SHA1:
  299. op.config = CFG_OP_MAC_ONLY | CFG_MACM_HMAC_SHA1;
  300. memcpy(cpg->sram + SRAM_HMAC_IV_IN,
  301. tfm_ctx->ivs, sizeof(tfm_ctx->ivs));
  302. break;
  303. }
  304. op.mac_src_p =
  305. MAC_SRC_DATA_P(SRAM_DATA_IN_START) | MAC_SRC_TOTAL_LEN((u32)
  306. req_ctx->
  307. count);
  308. setup_data_in();
  309. op.mac_digest =
  310. MAC_DIGEST_P(SRAM_DIGEST_BUF) | MAC_FRAG_LEN(p->crypt_len);
  311. op.mac_iv =
  312. MAC_INNER_IV_P(SRAM_HMAC_IV_IN) |
  313. MAC_OUTER_IV_P(SRAM_HMAC_IV_OUT);
  314. is_last = req_ctx->last_chunk
  315. && (p->hw_processed_bytes + p->crypt_len >= p->hw_nbytes)
  316. && (req_ctx->count <= MAX_HW_HASH_SIZE);
  317. if (req_ctx->first_hash) {
  318. if (is_last)
  319. op.config |= CFG_NOT_FRAG;
  320. else
  321. op.config |= CFG_FIRST_FRAG;
  322. req_ctx->first_hash = 0;
  323. } else {
  324. if (is_last)
  325. op.config |= CFG_LAST_FRAG;
  326. else
  327. op.config |= CFG_MID_FRAG;
  328. if (first_block) {
  329. writel(req_ctx->state[0], cpg->reg + DIGEST_INITIAL_VAL_A);
  330. writel(req_ctx->state[1], cpg->reg + DIGEST_INITIAL_VAL_B);
  331. writel(req_ctx->state[2], cpg->reg + DIGEST_INITIAL_VAL_C);
  332. writel(req_ctx->state[3], cpg->reg + DIGEST_INITIAL_VAL_D);
  333. writel(req_ctx->state[4], cpg->reg + DIGEST_INITIAL_VAL_E);
  334. }
  335. }
  336. memcpy(cpg->sram + SRAM_CONFIG, &op, sizeof(struct sec_accel_config));
  337. /* GO */
  338. mv_setup_timer();
  339. writel(SEC_CMD_EN_SEC_ACCL0, cpg->reg + SEC_ACCEL_CMD);
  340. }
  341. static inline int mv_hash_import_sha1_ctx(const struct mv_req_hash_ctx *ctx,
  342. struct shash_desc *desc)
  343. {
  344. int i;
  345. struct sha1_state shash_state;
  346. shash_state.count = ctx->count + ctx->count_add;
  347. for (i = 0; i < 5; i++)
  348. shash_state.state[i] = ctx->state[i];
  349. memcpy(shash_state.buffer, ctx->buffer, sizeof(shash_state.buffer));
  350. return crypto_shash_import(desc, &shash_state);
  351. }
  352. static int mv_hash_final_fallback(struct ahash_request *req)
  353. {
  354. const struct mv_tfm_hash_ctx *tfm_ctx = crypto_tfm_ctx(req->base.tfm);
  355. struct mv_req_hash_ctx *req_ctx = ahash_request_ctx(req);
  356. SHASH_DESC_ON_STACK(shash, tfm_ctx->fallback);
  357. int rc;
  358. shash->tfm = tfm_ctx->fallback;
  359. shash->flags = CRYPTO_TFM_REQ_MAY_SLEEP;
  360. if (unlikely(req_ctx->first_hash)) {
  361. crypto_shash_init(shash);
  362. crypto_shash_update(shash, req_ctx->buffer,
  363. req_ctx->extra_bytes);
  364. } else {
  365. /* only SHA1 for now....
  366. */
  367. rc = mv_hash_import_sha1_ctx(req_ctx, shash);
  368. if (rc)
  369. goto out;
  370. }
  371. rc = crypto_shash_final(shash, req->result);
  372. out:
  373. return rc;
  374. }
  375. static void mv_save_digest_state(struct mv_req_hash_ctx *ctx)
  376. {
  377. ctx->state[0] = readl(cpg->reg + DIGEST_INITIAL_VAL_A);
  378. ctx->state[1] = readl(cpg->reg + DIGEST_INITIAL_VAL_B);
  379. ctx->state[2] = readl(cpg->reg + DIGEST_INITIAL_VAL_C);
  380. ctx->state[3] = readl(cpg->reg + DIGEST_INITIAL_VAL_D);
  381. ctx->state[4] = readl(cpg->reg + DIGEST_INITIAL_VAL_E);
  382. }
  383. static void mv_hash_algo_completion(void)
  384. {
  385. struct ahash_request *req = ahash_request_cast(cpg->cur_req);
  386. struct mv_req_hash_ctx *ctx = ahash_request_ctx(req);
  387. if (ctx->extra_bytes)
  388. copy_src_to_buf(&cpg->p, ctx->buffer, ctx->extra_bytes);
  389. sg_miter_stop(&cpg->p.src_sg_it);
  390. if (likely(ctx->last_chunk)) {
  391. if (likely(ctx->count <= MAX_HW_HASH_SIZE)) {
  392. memcpy(req->result, cpg->sram + SRAM_DIGEST_BUF,
  393. crypto_ahash_digestsize(crypto_ahash_reqtfm
  394. (req)));
  395. } else {
  396. mv_save_digest_state(ctx);
  397. mv_hash_final_fallback(req);
  398. }
  399. } else {
  400. mv_save_digest_state(ctx);
  401. }
  402. }
  403. static void dequeue_complete_req(void)
  404. {
  405. struct crypto_async_request *req = cpg->cur_req;
  406. void *buf;
  407. int ret;
  408. cpg->p.hw_processed_bytes += cpg->p.crypt_len;
  409. if (cpg->p.copy_back) {
  410. int need_copy_len = cpg->p.crypt_len;
  411. int sram_offset = 0;
  412. do {
  413. int dst_copy;
  414. if (!cpg->p.sg_dst_left) {
  415. ret = sg_miter_next(&cpg->p.dst_sg_it);
  416. BUG_ON(!ret);
  417. cpg->p.sg_dst_left = cpg->p.dst_sg_it.length;
  418. cpg->p.dst_start = 0;
  419. }
  420. buf = cpg->p.dst_sg_it.addr;
  421. buf += cpg->p.dst_start;
  422. dst_copy = min(need_copy_len, cpg->p.sg_dst_left);
  423. memcpy(buf,
  424. cpg->sram + SRAM_DATA_OUT_START + sram_offset,
  425. dst_copy);
  426. sram_offset += dst_copy;
  427. cpg->p.sg_dst_left -= dst_copy;
  428. need_copy_len -= dst_copy;
  429. cpg->p.dst_start += dst_copy;
  430. } while (need_copy_len > 0);
  431. }
  432. cpg->p.crypt_len = 0;
  433. BUG_ON(cpg->eng_st != ENGINE_W_DEQUEUE);
  434. if (cpg->p.hw_processed_bytes < cpg->p.hw_nbytes) {
  435. /* process next scatter list entry */
  436. cpg->eng_st = ENGINE_BUSY;
  437. cpg->p.process(0);
  438. } else {
  439. cpg->p.complete();
  440. cpg->eng_st = ENGINE_IDLE;
  441. local_bh_disable();
  442. req->complete(req, 0);
  443. local_bh_enable();
  444. }
  445. }
  446. static int count_sgs(struct scatterlist *sl, unsigned int total_bytes)
  447. {
  448. int i = 0;
  449. size_t cur_len;
  450. while (sl) {
  451. cur_len = sl[i].length;
  452. ++i;
  453. if (total_bytes > cur_len)
  454. total_bytes -= cur_len;
  455. else
  456. break;
  457. }
  458. return i;
  459. }
  460. static void mv_start_new_crypt_req(struct ablkcipher_request *req)
  461. {
  462. struct req_progress *p = &cpg->p;
  463. int num_sgs;
  464. cpg->cur_req = &req->base;
  465. memset(p, 0, sizeof(struct req_progress));
  466. p->hw_nbytes = req->nbytes;
  467. p->complete = mv_crypto_algo_completion;
  468. p->process = mv_process_current_q;
  469. p->copy_back = 1;
  470. num_sgs = count_sgs(req->src, req->nbytes);
  471. sg_miter_start(&p->src_sg_it, req->src, num_sgs, SG_MITER_FROM_SG);
  472. num_sgs = count_sgs(req->dst, req->nbytes);
  473. sg_miter_start(&p->dst_sg_it, req->dst, num_sgs, SG_MITER_TO_SG);
  474. mv_process_current_q(1);
  475. }
  476. static void mv_start_new_hash_req(struct ahash_request *req)
  477. {
  478. struct req_progress *p = &cpg->p;
  479. struct mv_req_hash_ctx *ctx = ahash_request_ctx(req);
  480. int num_sgs, hw_bytes, old_extra_bytes, rc;
  481. cpg->cur_req = &req->base;
  482. memset(p, 0, sizeof(struct req_progress));
  483. hw_bytes = req->nbytes + ctx->extra_bytes;
  484. old_extra_bytes = ctx->extra_bytes;
  485. ctx->extra_bytes = hw_bytes % SHA1_BLOCK_SIZE;
  486. if (ctx->extra_bytes != 0
  487. && (!ctx->last_chunk || ctx->count > MAX_HW_HASH_SIZE))
  488. hw_bytes -= ctx->extra_bytes;
  489. else
  490. ctx->extra_bytes = 0;
  491. num_sgs = count_sgs(req->src, req->nbytes);
  492. sg_miter_start(&p->src_sg_it, req->src, num_sgs, SG_MITER_FROM_SG);
  493. if (hw_bytes) {
  494. p->hw_nbytes = hw_bytes;
  495. p->complete = mv_hash_algo_completion;
  496. p->process = mv_process_hash_current;
  497. if (unlikely(old_extra_bytes)) {
  498. memcpy(cpg->sram + SRAM_DATA_IN_START, ctx->buffer,
  499. old_extra_bytes);
  500. p->crypt_len = old_extra_bytes;
  501. }
  502. mv_process_hash_current(1);
  503. } else {
  504. copy_src_to_buf(p, ctx->buffer + old_extra_bytes,
  505. ctx->extra_bytes - old_extra_bytes);
  506. sg_miter_stop(&p->src_sg_it);
  507. if (ctx->last_chunk)
  508. rc = mv_hash_final_fallback(req);
  509. else
  510. rc = 0;
  511. cpg->eng_st = ENGINE_IDLE;
  512. local_bh_disable();
  513. req->base.complete(&req->base, rc);
  514. local_bh_enable();
  515. }
  516. }
  517. static int queue_manag(void *data)
  518. {
  519. cpg->eng_st = ENGINE_IDLE;
  520. do {
  521. struct crypto_async_request *async_req = NULL;
  522. struct crypto_async_request *backlog = NULL;
  523. __set_current_state(TASK_INTERRUPTIBLE);
  524. if (cpg->eng_st == ENGINE_W_DEQUEUE)
  525. dequeue_complete_req();
  526. spin_lock_irq(&cpg->lock);
  527. if (cpg->eng_st == ENGINE_IDLE) {
  528. backlog = crypto_get_backlog(&cpg->queue);
  529. async_req = crypto_dequeue_request(&cpg->queue);
  530. if (async_req) {
  531. BUG_ON(cpg->eng_st != ENGINE_IDLE);
  532. cpg->eng_st = ENGINE_BUSY;
  533. }
  534. }
  535. spin_unlock_irq(&cpg->lock);
  536. if (backlog) {
  537. backlog->complete(backlog, -EINPROGRESS);
  538. backlog = NULL;
  539. }
  540. if (async_req) {
  541. if (crypto_tfm_alg_type(async_req->tfm) !=
  542. CRYPTO_ALG_TYPE_AHASH) {
  543. struct ablkcipher_request *req =
  544. ablkcipher_request_cast(async_req);
  545. mv_start_new_crypt_req(req);
  546. } else {
  547. struct ahash_request *req =
  548. ahash_request_cast(async_req);
  549. mv_start_new_hash_req(req);
  550. }
  551. async_req = NULL;
  552. }
  553. schedule();
  554. } while (!kthread_should_stop());
  555. return 0;
  556. }
  557. static int mv_handle_req(struct crypto_async_request *req)
  558. {
  559. unsigned long flags;
  560. int ret;
  561. spin_lock_irqsave(&cpg->lock, flags);
  562. ret = crypto_enqueue_request(&cpg->queue, req);
  563. spin_unlock_irqrestore(&cpg->lock, flags);
  564. wake_up_process(cpg->queue_th);
  565. return ret;
  566. }
  567. static int mv_enc_aes_ecb(struct ablkcipher_request *req)
  568. {
  569. struct mv_req_ctx *req_ctx = ablkcipher_request_ctx(req);
  570. req_ctx->op = COP_AES_ECB;
  571. req_ctx->decrypt = 0;
  572. return mv_handle_req(&req->base);
  573. }
  574. static int mv_dec_aes_ecb(struct ablkcipher_request *req)
  575. {
  576. struct mv_ctx *ctx = crypto_tfm_ctx(req->base.tfm);
  577. struct mv_req_ctx *req_ctx = ablkcipher_request_ctx(req);
  578. req_ctx->op = COP_AES_ECB;
  579. req_ctx->decrypt = 1;
  580. compute_aes_dec_key(ctx);
  581. return mv_handle_req(&req->base);
  582. }
  583. static int mv_enc_aes_cbc(struct ablkcipher_request *req)
  584. {
  585. struct mv_req_ctx *req_ctx = ablkcipher_request_ctx(req);
  586. req_ctx->op = COP_AES_CBC;
  587. req_ctx->decrypt = 0;
  588. return mv_handle_req(&req->base);
  589. }
  590. static int mv_dec_aes_cbc(struct ablkcipher_request *req)
  591. {
  592. struct mv_ctx *ctx = crypto_tfm_ctx(req->base.tfm);
  593. struct mv_req_ctx *req_ctx = ablkcipher_request_ctx(req);
  594. req_ctx->op = COP_AES_CBC;
  595. req_ctx->decrypt = 1;
  596. compute_aes_dec_key(ctx);
  597. return mv_handle_req(&req->base);
  598. }
  599. static int mv_cra_init(struct crypto_tfm *tfm)
  600. {
  601. tfm->crt_ablkcipher.reqsize = sizeof(struct mv_req_ctx);
  602. return 0;
  603. }
  604. static void mv_init_hash_req_ctx(struct mv_req_hash_ctx *ctx, int op,
  605. int is_last, unsigned int req_len,
  606. int count_add)
  607. {
  608. memset(ctx, 0, sizeof(*ctx));
  609. ctx->op = op;
  610. ctx->count = req_len;
  611. ctx->first_hash = 1;
  612. ctx->last_chunk = is_last;
  613. ctx->count_add = count_add;
  614. }
  615. static void mv_update_hash_req_ctx(struct mv_req_hash_ctx *ctx, int is_last,
  616. unsigned req_len)
  617. {
  618. ctx->last_chunk = is_last;
  619. ctx->count += req_len;
  620. }
  621. static int mv_hash_init(struct ahash_request *req)
  622. {
  623. const struct mv_tfm_hash_ctx *tfm_ctx = crypto_tfm_ctx(req->base.tfm);
  624. mv_init_hash_req_ctx(ahash_request_ctx(req), tfm_ctx->op, 0, 0,
  625. tfm_ctx->count_add);
  626. return 0;
  627. }
  628. static int mv_hash_update(struct ahash_request *req)
  629. {
  630. if (!req->nbytes)
  631. return 0;
  632. mv_update_hash_req_ctx(ahash_request_ctx(req), 0, req->nbytes);
  633. return mv_handle_req(&req->base);
  634. }
  635. static int mv_hash_final(struct ahash_request *req)
  636. {
  637. struct mv_req_hash_ctx *ctx = ahash_request_ctx(req);
  638. ahash_request_set_crypt(req, NULL, req->result, 0);
  639. mv_update_hash_req_ctx(ctx, 1, 0);
  640. return mv_handle_req(&req->base);
  641. }
  642. static int mv_hash_finup(struct ahash_request *req)
  643. {
  644. mv_update_hash_req_ctx(ahash_request_ctx(req), 1, req->nbytes);
  645. return mv_handle_req(&req->base);
  646. }
  647. static int mv_hash_digest(struct ahash_request *req)
  648. {
  649. const struct mv_tfm_hash_ctx *tfm_ctx = crypto_tfm_ctx(req->base.tfm);
  650. mv_init_hash_req_ctx(ahash_request_ctx(req), tfm_ctx->op, 1,
  651. req->nbytes, tfm_ctx->count_add);
  652. return mv_handle_req(&req->base);
  653. }
  654. static void mv_hash_init_ivs(struct mv_tfm_hash_ctx *ctx, const void *istate,
  655. const void *ostate)
  656. {
  657. const struct sha1_state *isha1_state = istate, *osha1_state = ostate;
  658. int i;
  659. for (i = 0; i < 5; i++) {
  660. ctx->ivs[i] = cpu_to_be32(isha1_state->state[i]);
  661. ctx->ivs[i + 5] = cpu_to_be32(osha1_state->state[i]);
  662. }
  663. }
  664. static int mv_hash_setkey(struct crypto_ahash *tfm, const u8 * key,
  665. unsigned int keylen)
  666. {
  667. int rc;
  668. struct mv_tfm_hash_ctx *ctx = crypto_tfm_ctx(&tfm->base);
  669. int bs, ds, ss;
  670. if (!ctx->base_hash)
  671. return 0;
  672. rc = crypto_shash_setkey(ctx->fallback, key, keylen);
  673. if (rc)
  674. return rc;
  675. /* Can't see a way to extract the ipad/opad from the fallback tfm
  676. so I'm basically copying code from the hmac module */
  677. bs = crypto_shash_blocksize(ctx->base_hash);
  678. ds = crypto_shash_digestsize(ctx->base_hash);
  679. ss = crypto_shash_statesize(ctx->base_hash);
  680. {
  681. SHASH_DESC_ON_STACK(shash, ctx->base_hash);
  682. unsigned int i;
  683. char ipad[ss];
  684. char opad[ss];
  685. shash->tfm = ctx->base_hash;
  686. shash->flags = crypto_shash_get_flags(ctx->base_hash) &
  687. CRYPTO_TFM_REQ_MAY_SLEEP;
  688. if (keylen > bs) {
  689. int err;
  690. err =
  691. crypto_shash_digest(shash, key, keylen, ipad);
  692. if (err)
  693. return err;
  694. keylen = ds;
  695. } else
  696. memcpy(ipad, key, keylen);
  697. memset(ipad + keylen, 0, bs - keylen);
  698. memcpy(opad, ipad, bs);
  699. for (i = 0; i < bs; i++) {
  700. ipad[i] ^= HMAC_IPAD_VALUE;
  701. opad[i] ^= HMAC_OPAD_VALUE;
  702. }
  703. rc = crypto_shash_init(shash) ? :
  704. crypto_shash_update(shash, ipad, bs) ? :
  705. crypto_shash_export(shash, ipad) ? :
  706. crypto_shash_init(shash) ? :
  707. crypto_shash_update(shash, opad, bs) ? :
  708. crypto_shash_export(shash, opad);
  709. if (rc == 0)
  710. mv_hash_init_ivs(ctx, ipad, opad);
  711. return rc;
  712. }
  713. }
  714. static int mv_cra_hash_init(struct crypto_tfm *tfm, const char *base_hash_name,
  715. enum hash_op op, int count_add)
  716. {
  717. const char *fallback_driver_name = crypto_tfm_alg_name(tfm);
  718. struct mv_tfm_hash_ctx *ctx = crypto_tfm_ctx(tfm);
  719. struct crypto_shash *fallback_tfm = NULL;
  720. struct crypto_shash *base_hash = NULL;
  721. int err = -ENOMEM;
  722. ctx->op = op;
  723. ctx->count_add = count_add;
  724. /* Allocate a fallback and abort if it failed. */
  725. fallback_tfm = crypto_alloc_shash(fallback_driver_name, 0,
  726. CRYPTO_ALG_NEED_FALLBACK);
  727. if (IS_ERR(fallback_tfm)) {
  728. printk(KERN_WARNING MV_CESA
  729. "Fallback driver '%s' could not be loaded!\n",
  730. fallback_driver_name);
  731. err = PTR_ERR(fallback_tfm);
  732. goto out;
  733. }
  734. ctx->fallback = fallback_tfm;
  735. if (base_hash_name) {
  736. /* Allocate a hash to compute the ipad/opad of hmac. */
  737. base_hash = crypto_alloc_shash(base_hash_name, 0,
  738. CRYPTO_ALG_NEED_FALLBACK);
  739. if (IS_ERR(base_hash)) {
  740. printk(KERN_WARNING MV_CESA
  741. "Base driver '%s' could not be loaded!\n",
  742. base_hash_name);
  743. err = PTR_ERR(base_hash);
  744. goto err_bad_base;
  745. }
  746. }
  747. ctx->base_hash = base_hash;
  748. crypto_ahash_set_reqsize(__crypto_ahash_cast(tfm),
  749. sizeof(struct mv_req_hash_ctx) +
  750. crypto_shash_descsize(ctx->fallback));
  751. return 0;
  752. err_bad_base:
  753. crypto_free_shash(fallback_tfm);
  754. out:
  755. return err;
  756. }
  757. static void mv_cra_hash_exit(struct crypto_tfm *tfm)
  758. {
  759. struct mv_tfm_hash_ctx *ctx = crypto_tfm_ctx(tfm);
  760. crypto_free_shash(ctx->fallback);
  761. if (ctx->base_hash)
  762. crypto_free_shash(ctx->base_hash);
  763. }
  764. static int mv_cra_hash_sha1_init(struct crypto_tfm *tfm)
  765. {
  766. return mv_cra_hash_init(tfm, NULL, COP_SHA1, 0);
  767. }
  768. static int mv_cra_hash_hmac_sha1_init(struct crypto_tfm *tfm)
  769. {
  770. return mv_cra_hash_init(tfm, "sha1", COP_HMAC_SHA1, SHA1_BLOCK_SIZE);
  771. }
  772. static irqreturn_t crypto_int(int irq, void *priv)
  773. {
  774. u32 val;
  775. val = readl(cpg->reg + SEC_ACCEL_INT_STATUS);
  776. if (!(val & SEC_INT_ACCEL0_DONE))
  777. return IRQ_NONE;
  778. if (!del_timer(&cpg->completion_timer)) {
  779. printk(KERN_WARNING MV_CESA
  780. "got an interrupt but no pending timer?\n");
  781. }
  782. val &= ~SEC_INT_ACCEL0_DONE;
  783. writel(val, cpg->reg + FPGA_INT_STATUS);
  784. writel(val, cpg->reg + SEC_ACCEL_INT_STATUS);
  785. BUG_ON(cpg->eng_st != ENGINE_BUSY);
  786. cpg->eng_st = ENGINE_W_DEQUEUE;
  787. wake_up_process(cpg->queue_th);
  788. return IRQ_HANDLED;
  789. }
  790. static struct crypto_alg mv_aes_alg_ecb = {
  791. .cra_name = "ecb(aes)",
  792. .cra_driver_name = "mv-ecb-aes",
  793. .cra_priority = 300,
  794. .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER |
  795. CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC,
  796. .cra_blocksize = 16,
  797. .cra_ctxsize = sizeof(struct mv_ctx),
  798. .cra_alignmask = 0,
  799. .cra_type = &crypto_ablkcipher_type,
  800. .cra_module = THIS_MODULE,
  801. .cra_init = mv_cra_init,
  802. .cra_u = {
  803. .ablkcipher = {
  804. .min_keysize = AES_MIN_KEY_SIZE,
  805. .max_keysize = AES_MAX_KEY_SIZE,
  806. .setkey = mv_setkey_aes,
  807. .encrypt = mv_enc_aes_ecb,
  808. .decrypt = mv_dec_aes_ecb,
  809. },
  810. },
  811. };
  812. static struct crypto_alg mv_aes_alg_cbc = {
  813. .cra_name = "cbc(aes)",
  814. .cra_driver_name = "mv-cbc-aes",
  815. .cra_priority = 300,
  816. .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER |
  817. CRYPTO_ALG_KERN_DRIVER_ONLY | CRYPTO_ALG_ASYNC,
  818. .cra_blocksize = AES_BLOCK_SIZE,
  819. .cra_ctxsize = sizeof(struct mv_ctx),
  820. .cra_alignmask = 0,
  821. .cra_type = &crypto_ablkcipher_type,
  822. .cra_module = THIS_MODULE,
  823. .cra_init = mv_cra_init,
  824. .cra_u = {
  825. .ablkcipher = {
  826. .ivsize = AES_BLOCK_SIZE,
  827. .min_keysize = AES_MIN_KEY_SIZE,
  828. .max_keysize = AES_MAX_KEY_SIZE,
  829. .setkey = mv_setkey_aes,
  830. .encrypt = mv_enc_aes_cbc,
  831. .decrypt = mv_dec_aes_cbc,
  832. },
  833. },
  834. };
  835. static struct ahash_alg mv_sha1_alg = {
  836. .init = mv_hash_init,
  837. .update = mv_hash_update,
  838. .final = mv_hash_final,
  839. .finup = mv_hash_finup,
  840. .digest = mv_hash_digest,
  841. .halg = {
  842. .digestsize = SHA1_DIGEST_SIZE,
  843. .base = {
  844. .cra_name = "sha1",
  845. .cra_driver_name = "mv-sha1",
  846. .cra_priority = 300,
  847. .cra_flags =
  848. CRYPTO_ALG_ASYNC | CRYPTO_ALG_KERN_DRIVER_ONLY |
  849. CRYPTO_ALG_NEED_FALLBACK,
  850. .cra_blocksize = SHA1_BLOCK_SIZE,
  851. .cra_ctxsize = sizeof(struct mv_tfm_hash_ctx),
  852. .cra_init = mv_cra_hash_sha1_init,
  853. .cra_exit = mv_cra_hash_exit,
  854. .cra_module = THIS_MODULE,
  855. }
  856. }
  857. };
  858. static struct ahash_alg mv_hmac_sha1_alg = {
  859. .init = mv_hash_init,
  860. .update = mv_hash_update,
  861. .final = mv_hash_final,
  862. .finup = mv_hash_finup,
  863. .digest = mv_hash_digest,
  864. .setkey = mv_hash_setkey,
  865. .halg = {
  866. .digestsize = SHA1_DIGEST_SIZE,
  867. .base = {
  868. .cra_name = "hmac(sha1)",
  869. .cra_driver_name = "mv-hmac-sha1",
  870. .cra_priority = 300,
  871. .cra_flags =
  872. CRYPTO_ALG_ASYNC | CRYPTO_ALG_KERN_DRIVER_ONLY |
  873. CRYPTO_ALG_NEED_FALLBACK,
  874. .cra_blocksize = SHA1_BLOCK_SIZE,
  875. .cra_ctxsize = sizeof(struct mv_tfm_hash_ctx),
  876. .cra_init = mv_cra_hash_hmac_sha1_init,
  877. .cra_exit = mv_cra_hash_exit,
  878. .cra_module = THIS_MODULE,
  879. }
  880. }
  881. };
  882. static int mv_cesa_get_sram(struct platform_device *pdev,
  883. struct crypto_priv *cp)
  884. {
  885. struct resource *res;
  886. u32 sram_size = MV_CESA_DEFAULT_SRAM_SIZE;
  887. of_property_read_u32(pdev->dev.of_node, "marvell,crypto-sram-size",
  888. &sram_size);
  889. cp->sram_size = sram_size;
  890. cp->sram_pool = of_gen_pool_get(pdev->dev.of_node,
  891. "marvell,crypto-srams", 0);
  892. if (cp->sram_pool) {
  893. cp->sram = gen_pool_dma_alloc(cp->sram_pool, sram_size,
  894. &cp->sram_dma);
  895. if (cp->sram)
  896. return 0;
  897. return -ENOMEM;
  898. }
  899. res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
  900. "sram");
  901. if (!res || resource_size(res) < cp->sram_size)
  902. return -EINVAL;
  903. cp->sram = devm_ioremap_resource(&pdev->dev, res);
  904. if (IS_ERR(cp->sram))
  905. return PTR_ERR(cp->sram);
  906. return 0;
  907. }
  908. static int mv_probe(struct platform_device *pdev)
  909. {
  910. struct crypto_priv *cp;
  911. struct resource *res;
  912. int irq;
  913. int ret;
  914. if (cpg) {
  915. printk(KERN_ERR MV_CESA "Second crypto dev?\n");
  916. return -EEXIST;
  917. }
  918. res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
  919. if (!res)
  920. return -ENXIO;
  921. cp = devm_kzalloc(&pdev->dev, sizeof(*cp), GFP_KERNEL);
  922. if (!cp)
  923. return -ENOMEM;
  924. spin_lock_init(&cp->lock);
  925. crypto_init_queue(&cp->queue, 50);
  926. cp->reg = devm_ioremap_resource(&pdev->dev, res);
  927. if (IS_ERR(cp->reg)) {
  928. ret = PTR_ERR(cp->reg);
  929. goto err;
  930. }
  931. ret = mv_cesa_get_sram(pdev, cp);
  932. if (ret)
  933. goto err;
  934. cp->max_req_size = cp->sram_size - SRAM_CFG_SPACE;
  935. irq = platform_get_irq(pdev, 0);
  936. if (irq < 0) {
  937. ret = irq;
  938. goto err;
  939. }
  940. cp->irq = irq;
  941. platform_set_drvdata(pdev, cp);
  942. cpg = cp;
  943. cp->queue_th = kthread_run(queue_manag, cp, "mv_crypto");
  944. if (IS_ERR(cp->queue_th)) {
  945. ret = PTR_ERR(cp->queue_th);
  946. goto err;
  947. }
  948. ret = request_irq(irq, crypto_int, 0, dev_name(&pdev->dev),
  949. cp);
  950. if (ret)
  951. goto err_thread;
  952. /* Not all platforms can gate the clock, so it is not
  953. an error if the clock does not exists. */
  954. cp->clk = clk_get(&pdev->dev, NULL);
  955. if (!IS_ERR(cp->clk))
  956. clk_prepare_enable(cp->clk);
  957. writel(0, cpg->reg + SEC_ACCEL_INT_STATUS);
  958. writel(SEC_INT_ACCEL0_DONE, cpg->reg + SEC_ACCEL_INT_MASK);
  959. writel(SEC_CFG_STOP_DIG_ERR, cpg->reg + SEC_ACCEL_CFG);
  960. writel(SRAM_CONFIG, cpg->reg + SEC_ACCEL_DESC_P0);
  961. ret = crypto_register_alg(&mv_aes_alg_ecb);
  962. if (ret) {
  963. printk(KERN_WARNING MV_CESA
  964. "Could not register aes-ecb driver\n");
  965. goto err_irq;
  966. }
  967. ret = crypto_register_alg(&mv_aes_alg_cbc);
  968. if (ret) {
  969. printk(KERN_WARNING MV_CESA
  970. "Could not register aes-cbc driver\n");
  971. goto err_unreg_ecb;
  972. }
  973. ret = crypto_register_ahash(&mv_sha1_alg);
  974. if (ret == 0)
  975. cpg->has_sha1 = 1;
  976. else
  977. printk(KERN_WARNING MV_CESA "Could not register sha1 driver\n");
  978. ret = crypto_register_ahash(&mv_hmac_sha1_alg);
  979. if (ret == 0) {
  980. cpg->has_hmac_sha1 = 1;
  981. } else {
  982. printk(KERN_WARNING MV_CESA
  983. "Could not register hmac-sha1 driver\n");
  984. }
  985. return 0;
  986. err_unreg_ecb:
  987. crypto_unregister_alg(&mv_aes_alg_ecb);
  988. err_irq:
  989. free_irq(irq, cp);
  990. if (!IS_ERR(cp->clk)) {
  991. clk_disable_unprepare(cp->clk);
  992. clk_put(cp->clk);
  993. }
  994. err_thread:
  995. kthread_stop(cp->queue_th);
  996. err:
  997. cpg = NULL;
  998. return ret;
  999. }
  1000. static int mv_remove(struct platform_device *pdev)
  1001. {
  1002. struct crypto_priv *cp = platform_get_drvdata(pdev);
  1003. crypto_unregister_alg(&mv_aes_alg_ecb);
  1004. crypto_unregister_alg(&mv_aes_alg_cbc);
  1005. if (cp->has_sha1)
  1006. crypto_unregister_ahash(&mv_sha1_alg);
  1007. if (cp->has_hmac_sha1)
  1008. crypto_unregister_ahash(&mv_hmac_sha1_alg);
  1009. kthread_stop(cp->queue_th);
  1010. free_irq(cp->irq, cp);
  1011. memset(cp->sram, 0, cp->sram_size);
  1012. if (!IS_ERR(cp->clk)) {
  1013. clk_disable_unprepare(cp->clk);
  1014. clk_put(cp->clk);
  1015. }
  1016. cpg = NULL;
  1017. return 0;
  1018. }
  1019. static const struct of_device_id mv_cesa_of_match_table[] = {
  1020. { .compatible = "marvell,orion-crypto", },
  1021. { .compatible = "marvell,kirkwood-crypto", },
  1022. { .compatible = "marvell,dove-crypto", },
  1023. {}
  1024. };
  1025. MODULE_DEVICE_TABLE(of, mv_cesa_of_match_table);
  1026. static struct platform_driver marvell_crypto = {
  1027. .probe = mv_probe,
  1028. .remove = mv_remove,
  1029. .driver = {
  1030. .name = "mv_crypto",
  1031. .of_match_table = mv_cesa_of_match_table,
  1032. },
  1033. };
  1034. MODULE_ALIAS("platform:mv_crypto");
  1035. module_platform_driver(marvell_crypto);
  1036. MODULE_AUTHOR("Sebastian Andrzej Siewior <sebastian@breakpoint.cc>");
  1037. MODULE_DESCRIPTION("Support for Marvell's cryptographic engine");
  1038. MODULE_LICENSE("GPL");