atmel-aes.c 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199
  1. /*
  2. * Cryptographic API.
  3. *
  4. * Support for ATMEL AES HW acceleration.
  5. *
  6. * Copyright (c) 2012 Eukréa Electromatique - ATMEL
  7. * Author: Nicolas Royer <nicolas@eukrea.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as published
  11. * by the Free Software Foundation.
  12. *
  13. * Some ideas are from omap-aes.c driver.
  14. */
  15. #include <linux/kernel.h>
  16. #include <linux/module.h>
  17. #include <linux/slab.h>
  18. #include <linux/err.h>
  19. #include <linux/clk.h>
  20. #include <linux/io.h>
  21. #include <linux/hw_random.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/device.h>
  24. #include <linux/init.h>
  25. #include <linux/errno.h>
  26. #include <linux/interrupt.h>
  27. #include <linux/irq.h>
  28. #include <linux/scatterlist.h>
  29. #include <linux/dma-mapping.h>
  30. #include <linux/delay.h>
  31. #include <linux/crypto.h>
  32. #include <linux/cryptohash.h>
  33. #include <crypto/scatterwalk.h>
  34. #include <crypto/algapi.h>
  35. #include <crypto/aes.h>
  36. #include <crypto/hash.h>
  37. #include <crypto/internal/hash.h>
  38. #include <linux/platform_data/atmel-aes.h>
  39. #include "atmel-aes-regs.h"
  40. #define CFB8_BLOCK_SIZE 1
  41. #define CFB16_BLOCK_SIZE 2
  42. #define CFB32_BLOCK_SIZE 4
  43. #define CFB64_BLOCK_SIZE 8
  44. /* AES flags */
  45. #define AES_FLAGS_MODE_MASK 0x01ff
  46. #define AES_FLAGS_ENCRYPT BIT(0)
  47. #define AES_FLAGS_CBC BIT(1)
  48. #define AES_FLAGS_CFB BIT(2)
  49. #define AES_FLAGS_CFB8 BIT(3)
  50. #define AES_FLAGS_CFB16 BIT(4)
  51. #define AES_FLAGS_CFB32 BIT(5)
  52. #define AES_FLAGS_CFB64 BIT(6)
  53. #define AES_FLAGS_OFB BIT(7)
  54. #define AES_FLAGS_CTR BIT(8)
  55. #define AES_FLAGS_INIT BIT(16)
  56. #define AES_FLAGS_DMA BIT(17)
  57. #define AES_FLAGS_BUSY BIT(18)
  58. #define AES_FLAGS_DUALBUFF BIT(24)
  59. #define ATMEL_AES_QUEUE_LENGTH 1
  60. #define ATMEL_AES_CACHE_SIZE 0
  61. #define ATMEL_AES_DMA_THRESHOLD 16
  62. struct atmel_aes_dev;
  63. struct atmel_aes_ctx {
  64. struct atmel_aes_dev *dd;
  65. int keylen;
  66. u32 key[AES_KEYSIZE_256 / sizeof(u32)];
  67. };
  68. struct atmel_aes_reqctx {
  69. unsigned long mode;
  70. };
  71. struct atmel_aes_dma {
  72. struct dma_chan *chan;
  73. struct dma_slave_config dma_conf;
  74. };
  75. struct atmel_aes_dev {
  76. struct list_head list;
  77. unsigned long phys_base;
  78. void __iomem *io_base;
  79. struct atmel_aes_ctx *ctx;
  80. struct device *dev;
  81. struct clk *iclk;
  82. int irq;
  83. unsigned long flags;
  84. int err;
  85. spinlock_t lock;
  86. struct crypto_queue queue;
  87. struct tasklet_struct done_task;
  88. struct tasklet_struct queue_task;
  89. struct ablkcipher_request *req;
  90. size_t total;
  91. struct scatterlist *in_sg;
  92. unsigned int nb_in_sg;
  93. struct scatterlist *out_sg;
  94. unsigned int nb_out_sg;
  95. size_t bufcnt;
  96. u8 buf_in[ATMEL_AES_DMA_THRESHOLD] __aligned(sizeof(u32));
  97. int dma_in;
  98. struct atmel_aes_dma dma_lch_in;
  99. u8 buf_out[ATMEL_AES_DMA_THRESHOLD] __aligned(sizeof(u32));
  100. int dma_out;
  101. struct atmel_aes_dma dma_lch_out;
  102. u32 hw_version;
  103. };
  104. struct atmel_aes_drv {
  105. struct list_head dev_list;
  106. spinlock_t lock;
  107. };
  108. static struct atmel_aes_drv atmel_aes = {
  109. .dev_list = LIST_HEAD_INIT(atmel_aes.dev_list),
  110. .lock = __SPIN_LOCK_UNLOCKED(atmel_aes.lock),
  111. };
  112. static int atmel_aes_sg_length(struct ablkcipher_request *req,
  113. struct scatterlist *sg)
  114. {
  115. unsigned int total = req->nbytes;
  116. int sg_nb;
  117. unsigned int len;
  118. struct scatterlist *sg_list;
  119. sg_nb = 0;
  120. sg_list = sg;
  121. total = req->nbytes;
  122. while (total) {
  123. len = min(sg_list->length, total);
  124. sg_nb++;
  125. total -= len;
  126. sg_list = sg_next(sg_list);
  127. if (!sg_list)
  128. total = 0;
  129. }
  130. return sg_nb;
  131. }
  132. static inline u32 atmel_aes_read(struct atmel_aes_dev *dd, u32 offset)
  133. {
  134. return readl_relaxed(dd->io_base + offset);
  135. }
  136. static inline void atmel_aes_write(struct atmel_aes_dev *dd,
  137. u32 offset, u32 value)
  138. {
  139. writel_relaxed(value, dd->io_base + offset);
  140. }
  141. static void atmel_aes_read_n(struct atmel_aes_dev *dd, u32 offset,
  142. u32 *value, int count)
  143. {
  144. for (; count--; value++, offset += 4)
  145. *value = atmel_aes_read(dd, offset);
  146. }
  147. static void atmel_aes_write_n(struct atmel_aes_dev *dd, u32 offset,
  148. u32 *value, int count)
  149. {
  150. for (; count--; value++, offset += 4)
  151. atmel_aes_write(dd, offset, *value);
  152. }
  153. static void atmel_aes_dualbuff_test(struct atmel_aes_dev *dd)
  154. {
  155. atmel_aes_write(dd, AES_MR, AES_MR_DUALBUFF);
  156. if (atmel_aes_read(dd, AES_MR) & AES_MR_DUALBUFF)
  157. dd->flags |= AES_FLAGS_DUALBUFF;
  158. }
  159. static struct atmel_aes_dev *atmel_aes_find_dev(struct atmel_aes_ctx *ctx)
  160. {
  161. struct atmel_aes_dev *aes_dd = NULL;
  162. struct atmel_aes_dev *tmp;
  163. spin_lock_bh(&atmel_aes.lock);
  164. if (!ctx->dd) {
  165. list_for_each_entry(tmp, &atmel_aes.dev_list, list) {
  166. aes_dd = tmp;
  167. break;
  168. }
  169. ctx->dd = aes_dd;
  170. } else {
  171. aes_dd = ctx->dd;
  172. }
  173. spin_unlock_bh(&atmel_aes.lock);
  174. return aes_dd;
  175. }
  176. static int atmel_aes_hw_init(struct atmel_aes_dev *dd)
  177. {
  178. clk_prepare_enable(dd->iclk);
  179. if (!(dd->flags & AES_FLAGS_INIT)) {
  180. atmel_aes_write(dd, AES_CR, AES_CR_SWRST);
  181. atmel_aes_dualbuff_test(dd);
  182. dd->flags |= AES_FLAGS_INIT;
  183. dd->err = 0;
  184. }
  185. return 0;
  186. }
  187. static void atmel_aes_hw_version_init(struct atmel_aes_dev *dd)
  188. {
  189. atmel_aes_hw_init(dd);
  190. dd->hw_version = atmel_aes_read(dd, AES_HW_VERSION);
  191. clk_disable_unprepare(dd->iclk);
  192. }
  193. static void atmel_aes_finish_req(struct atmel_aes_dev *dd, int err)
  194. {
  195. struct ablkcipher_request *req = dd->req;
  196. clk_disable_unprepare(dd->iclk);
  197. dd->flags &= ~AES_FLAGS_BUSY;
  198. req->base.complete(&req->base, err);
  199. }
  200. static void atmel_aes_dma_callback(void *data)
  201. {
  202. struct atmel_aes_dev *dd = data;
  203. /* dma_lch_out - completed */
  204. tasklet_schedule(&dd->done_task);
  205. }
  206. static int atmel_aes_crypt_dma(struct atmel_aes_dev *dd)
  207. {
  208. struct dma_async_tx_descriptor *in_desc, *out_desc;
  209. int nb_dma_sg_in, nb_dma_sg_out;
  210. dd->nb_in_sg = atmel_aes_sg_length(dd->req, dd->in_sg);
  211. if (!dd->nb_in_sg)
  212. goto exit_err;
  213. nb_dma_sg_in = dma_map_sg(dd->dev, dd->in_sg, dd->nb_in_sg,
  214. DMA_TO_DEVICE);
  215. if (!nb_dma_sg_in)
  216. goto exit_err;
  217. in_desc = dmaengine_prep_slave_sg(dd->dma_lch_in.chan, dd->in_sg,
  218. nb_dma_sg_in, DMA_MEM_TO_DEV,
  219. DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
  220. if (!in_desc)
  221. goto unmap_in;
  222. /* callback not needed */
  223. dd->nb_out_sg = atmel_aes_sg_length(dd->req, dd->out_sg);
  224. if (!dd->nb_out_sg)
  225. goto unmap_in;
  226. nb_dma_sg_out = dma_map_sg(dd->dev, dd->out_sg, dd->nb_out_sg,
  227. DMA_FROM_DEVICE);
  228. if (!nb_dma_sg_out)
  229. goto unmap_out;
  230. out_desc = dmaengine_prep_slave_sg(dd->dma_lch_out.chan, dd->out_sg,
  231. nb_dma_sg_out, DMA_DEV_TO_MEM,
  232. DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
  233. if (!out_desc)
  234. goto unmap_out;
  235. out_desc->callback = atmel_aes_dma_callback;
  236. out_desc->callback_param = dd;
  237. dd->total -= dd->req->nbytes;
  238. dmaengine_submit(out_desc);
  239. dma_async_issue_pending(dd->dma_lch_out.chan);
  240. dmaengine_submit(in_desc);
  241. dma_async_issue_pending(dd->dma_lch_in.chan);
  242. return 0;
  243. unmap_out:
  244. dma_unmap_sg(dd->dev, dd->out_sg, dd->nb_out_sg,
  245. DMA_FROM_DEVICE);
  246. unmap_in:
  247. dma_unmap_sg(dd->dev, dd->in_sg, dd->nb_in_sg,
  248. DMA_TO_DEVICE);
  249. exit_err:
  250. return -EINVAL;
  251. }
  252. static int atmel_aes_crypt_cpu_start(struct atmel_aes_dev *dd)
  253. {
  254. dd->flags &= ~AES_FLAGS_DMA;
  255. /* use cache buffers */
  256. dd->nb_in_sg = atmel_aes_sg_length(dd->req, dd->in_sg);
  257. if (!dd->nb_in_sg)
  258. return -EINVAL;
  259. dd->nb_out_sg = atmel_aes_sg_length(dd->req, dd->out_sg);
  260. if (!dd->nb_out_sg)
  261. return -EINVAL;
  262. dd->bufcnt = sg_copy_to_buffer(dd->in_sg, dd->nb_in_sg,
  263. dd->buf_in, dd->total);
  264. if (!dd->bufcnt)
  265. return -EINVAL;
  266. dd->total -= dd->bufcnt;
  267. atmel_aes_write(dd, AES_IER, AES_INT_DATARDY);
  268. atmel_aes_write_n(dd, AES_IDATAR(0), (u32 *) dd->buf_in,
  269. dd->bufcnt >> 2);
  270. return 0;
  271. }
  272. static int atmel_aes_crypt_dma_start(struct atmel_aes_dev *dd)
  273. {
  274. int err;
  275. if (dd->flags & AES_FLAGS_CFB8) {
  276. dd->dma_lch_in.dma_conf.dst_addr_width =
  277. DMA_SLAVE_BUSWIDTH_1_BYTE;
  278. dd->dma_lch_out.dma_conf.src_addr_width =
  279. DMA_SLAVE_BUSWIDTH_1_BYTE;
  280. } else if (dd->flags & AES_FLAGS_CFB16) {
  281. dd->dma_lch_in.dma_conf.dst_addr_width =
  282. DMA_SLAVE_BUSWIDTH_2_BYTES;
  283. dd->dma_lch_out.dma_conf.src_addr_width =
  284. DMA_SLAVE_BUSWIDTH_2_BYTES;
  285. } else {
  286. dd->dma_lch_in.dma_conf.dst_addr_width =
  287. DMA_SLAVE_BUSWIDTH_4_BYTES;
  288. dd->dma_lch_out.dma_conf.src_addr_width =
  289. DMA_SLAVE_BUSWIDTH_4_BYTES;
  290. }
  291. dmaengine_slave_config(dd->dma_lch_in.chan, &dd->dma_lch_in.dma_conf);
  292. dmaengine_slave_config(dd->dma_lch_out.chan, &dd->dma_lch_out.dma_conf);
  293. dd->flags |= AES_FLAGS_DMA;
  294. err = atmel_aes_crypt_dma(dd);
  295. return err;
  296. }
  297. static int atmel_aes_write_ctrl(struct atmel_aes_dev *dd)
  298. {
  299. int err;
  300. u32 valcr = 0, valmr = 0;
  301. err = atmel_aes_hw_init(dd);
  302. if (err)
  303. return err;
  304. /* MR register must be set before IV registers */
  305. if (dd->ctx->keylen == AES_KEYSIZE_128)
  306. valmr |= AES_MR_KEYSIZE_128;
  307. else if (dd->ctx->keylen == AES_KEYSIZE_192)
  308. valmr |= AES_MR_KEYSIZE_192;
  309. else
  310. valmr |= AES_MR_KEYSIZE_256;
  311. if (dd->flags & AES_FLAGS_CBC) {
  312. valmr |= AES_MR_OPMOD_CBC;
  313. } else if (dd->flags & AES_FLAGS_CFB) {
  314. valmr |= AES_MR_OPMOD_CFB;
  315. if (dd->flags & AES_FLAGS_CFB8)
  316. valmr |= AES_MR_CFBS_8b;
  317. else if (dd->flags & AES_FLAGS_CFB16)
  318. valmr |= AES_MR_CFBS_16b;
  319. else if (dd->flags & AES_FLAGS_CFB32)
  320. valmr |= AES_MR_CFBS_32b;
  321. else if (dd->flags & AES_FLAGS_CFB64)
  322. valmr |= AES_MR_CFBS_64b;
  323. } else if (dd->flags & AES_FLAGS_OFB) {
  324. valmr |= AES_MR_OPMOD_OFB;
  325. } else if (dd->flags & AES_FLAGS_CTR) {
  326. valmr |= AES_MR_OPMOD_CTR;
  327. } else {
  328. valmr |= AES_MR_OPMOD_ECB;
  329. }
  330. if (dd->flags & AES_FLAGS_ENCRYPT)
  331. valmr |= AES_MR_CYPHER_ENC;
  332. if (dd->total > ATMEL_AES_DMA_THRESHOLD) {
  333. valmr |= AES_MR_SMOD_IDATAR0;
  334. if (dd->flags & AES_FLAGS_DUALBUFF)
  335. valmr |= AES_MR_DUALBUFF;
  336. } else {
  337. valmr |= AES_MR_SMOD_AUTO;
  338. }
  339. atmel_aes_write(dd, AES_CR, valcr);
  340. atmel_aes_write(dd, AES_MR, valmr);
  341. atmel_aes_write_n(dd, AES_KEYWR(0), dd->ctx->key,
  342. dd->ctx->keylen >> 2);
  343. if (((dd->flags & AES_FLAGS_CBC) || (dd->flags & AES_FLAGS_CFB) ||
  344. (dd->flags & AES_FLAGS_OFB) || (dd->flags & AES_FLAGS_CTR)) &&
  345. dd->req->info) {
  346. atmel_aes_write_n(dd, AES_IVR(0), dd->req->info, 4);
  347. }
  348. return 0;
  349. }
  350. static int atmel_aes_handle_queue(struct atmel_aes_dev *dd,
  351. struct ablkcipher_request *req)
  352. {
  353. struct crypto_async_request *async_req, *backlog;
  354. struct atmel_aes_ctx *ctx;
  355. struct atmel_aes_reqctx *rctx;
  356. unsigned long flags;
  357. int err, ret = 0;
  358. spin_lock_irqsave(&dd->lock, flags);
  359. if (req)
  360. ret = ablkcipher_enqueue_request(&dd->queue, req);
  361. if (dd->flags & AES_FLAGS_BUSY) {
  362. spin_unlock_irqrestore(&dd->lock, flags);
  363. return ret;
  364. }
  365. backlog = crypto_get_backlog(&dd->queue);
  366. async_req = crypto_dequeue_request(&dd->queue);
  367. if (async_req)
  368. dd->flags |= AES_FLAGS_BUSY;
  369. spin_unlock_irqrestore(&dd->lock, flags);
  370. if (!async_req)
  371. return ret;
  372. if (backlog)
  373. backlog->complete(backlog, -EINPROGRESS);
  374. req = ablkcipher_request_cast(async_req);
  375. /* assign new request to device */
  376. dd->req = req;
  377. dd->total = req->nbytes;
  378. dd->in_sg = req->src;
  379. dd->out_sg = req->dst;
  380. rctx = ablkcipher_request_ctx(req);
  381. ctx = crypto_ablkcipher_ctx(crypto_ablkcipher_reqtfm(req));
  382. rctx->mode &= AES_FLAGS_MODE_MASK;
  383. dd->flags = (dd->flags & ~AES_FLAGS_MODE_MASK) | rctx->mode;
  384. dd->ctx = ctx;
  385. ctx->dd = dd;
  386. err = atmel_aes_write_ctrl(dd);
  387. if (!err) {
  388. if (dd->total > ATMEL_AES_DMA_THRESHOLD)
  389. err = atmel_aes_crypt_dma_start(dd);
  390. else
  391. err = atmel_aes_crypt_cpu_start(dd);
  392. }
  393. if (err) {
  394. /* aes_task will not finish it, so do it here */
  395. atmel_aes_finish_req(dd, err);
  396. tasklet_schedule(&dd->queue_task);
  397. }
  398. return ret;
  399. }
  400. static int atmel_aes_crypt_dma_stop(struct atmel_aes_dev *dd)
  401. {
  402. int err = -EINVAL;
  403. if (dd->flags & AES_FLAGS_DMA) {
  404. dma_unmap_sg(dd->dev, dd->out_sg,
  405. dd->nb_out_sg, DMA_FROM_DEVICE);
  406. dma_unmap_sg(dd->dev, dd->in_sg,
  407. dd->nb_in_sg, DMA_TO_DEVICE);
  408. err = 0;
  409. }
  410. return err;
  411. }
  412. static int atmel_aes_crypt(struct ablkcipher_request *req, unsigned long mode)
  413. {
  414. struct atmel_aes_ctx *ctx = crypto_ablkcipher_ctx(
  415. crypto_ablkcipher_reqtfm(req));
  416. struct atmel_aes_reqctx *rctx = ablkcipher_request_ctx(req);
  417. struct atmel_aes_dev *dd;
  418. if (!IS_ALIGNED(req->nbytes, AES_BLOCK_SIZE)) {
  419. pr_err("request size is not exact amount of AES blocks\n");
  420. return -EINVAL;
  421. }
  422. dd = atmel_aes_find_dev(ctx);
  423. if (!dd)
  424. return -ENODEV;
  425. rctx->mode = mode;
  426. return atmel_aes_handle_queue(dd, req);
  427. }
  428. static bool atmel_aes_filter(struct dma_chan *chan, void *slave)
  429. {
  430. struct at_dma_slave *sl = slave;
  431. if (sl && sl->dma_dev == chan->device->dev) {
  432. chan->private = sl;
  433. return true;
  434. } else {
  435. return false;
  436. }
  437. }
  438. static int atmel_aes_dma_init(struct atmel_aes_dev *dd)
  439. {
  440. int err = -ENOMEM;
  441. struct aes_platform_data *pdata;
  442. dma_cap_mask_t mask_in, mask_out;
  443. pdata = dd->dev->platform_data;
  444. if (pdata && pdata->dma_slave->txdata.dma_dev &&
  445. pdata->dma_slave->rxdata.dma_dev) {
  446. /* Try to grab 2 DMA channels */
  447. dma_cap_zero(mask_in);
  448. dma_cap_set(DMA_SLAVE, mask_in);
  449. dd->dma_lch_in.chan = dma_request_channel(mask_in,
  450. atmel_aes_filter, &pdata->dma_slave->rxdata);
  451. if (!dd->dma_lch_in.chan)
  452. goto err_dma_in;
  453. dd->dma_lch_in.dma_conf.direction = DMA_MEM_TO_DEV;
  454. dd->dma_lch_in.dma_conf.dst_addr = dd->phys_base +
  455. AES_IDATAR(0);
  456. dd->dma_lch_in.dma_conf.src_maxburst = 1;
  457. dd->dma_lch_in.dma_conf.dst_maxburst = 1;
  458. dd->dma_lch_in.dma_conf.device_fc = false;
  459. dma_cap_zero(mask_out);
  460. dma_cap_set(DMA_SLAVE, mask_out);
  461. dd->dma_lch_out.chan = dma_request_channel(mask_out,
  462. atmel_aes_filter, &pdata->dma_slave->txdata);
  463. if (!dd->dma_lch_out.chan)
  464. goto err_dma_out;
  465. dd->dma_lch_out.dma_conf.direction = DMA_DEV_TO_MEM;
  466. dd->dma_lch_out.dma_conf.src_addr = dd->phys_base +
  467. AES_ODATAR(0);
  468. dd->dma_lch_out.dma_conf.src_maxburst = 1;
  469. dd->dma_lch_out.dma_conf.dst_maxburst = 1;
  470. dd->dma_lch_out.dma_conf.device_fc = false;
  471. return 0;
  472. } else {
  473. return -ENODEV;
  474. }
  475. err_dma_out:
  476. dma_release_channel(dd->dma_lch_in.chan);
  477. err_dma_in:
  478. return err;
  479. }
  480. static void atmel_aes_dma_cleanup(struct atmel_aes_dev *dd)
  481. {
  482. dma_release_channel(dd->dma_lch_in.chan);
  483. dma_release_channel(dd->dma_lch_out.chan);
  484. }
  485. static int atmel_aes_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
  486. unsigned int keylen)
  487. {
  488. struct atmel_aes_ctx *ctx = crypto_ablkcipher_ctx(tfm);
  489. if (keylen != AES_KEYSIZE_128 && keylen != AES_KEYSIZE_192 &&
  490. keylen != AES_KEYSIZE_256) {
  491. crypto_ablkcipher_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
  492. return -EINVAL;
  493. }
  494. memcpy(ctx->key, key, keylen);
  495. ctx->keylen = keylen;
  496. return 0;
  497. }
  498. static int atmel_aes_ecb_encrypt(struct ablkcipher_request *req)
  499. {
  500. return atmel_aes_crypt(req,
  501. AES_FLAGS_ENCRYPT);
  502. }
  503. static int atmel_aes_ecb_decrypt(struct ablkcipher_request *req)
  504. {
  505. return atmel_aes_crypt(req,
  506. 0);
  507. }
  508. static int atmel_aes_cbc_encrypt(struct ablkcipher_request *req)
  509. {
  510. return atmel_aes_crypt(req,
  511. AES_FLAGS_ENCRYPT | AES_FLAGS_CBC);
  512. }
  513. static int atmel_aes_cbc_decrypt(struct ablkcipher_request *req)
  514. {
  515. return atmel_aes_crypt(req,
  516. AES_FLAGS_CBC);
  517. }
  518. static int atmel_aes_ofb_encrypt(struct ablkcipher_request *req)
  519. {
  520. return atmel_aes_crypt(req,
  521. AES_FLAGS_ENCRYPT | AES_FLAGS_OFB);
  522. }
  523. static int atmel_aes_ofb_decrypt(struct ablkcipher_request *req)
  524. {
  525. return atmel_aes_crypt(req,
  526. AES_FLAGS_OFB);
  527. }
  528. static int atmel_aes_cfb_encrypt(struct ablkcipher_request *req)
  529. {
  530. return atmel_aes_crypt(req,
  531. AES_FLAGS_ENCRYPT | AES_FLAGS_CFB);
  532. }
  533. static int atmel_aes_cfb_decrypt(struct ablkcipher_request *req)
  534. {
  535. return atmel_aes_crypt(req,
  536. AES_FLAGS_CFB);
  537. }
  538. static int atmel_aes_cfb64_encrypt(struct ablkcipher_request *req)
  539. {
  540. return atmel_aes_crypt(req,
  541. AES_FLAGS_ENCRYPT | AES_FLAGS_CFB | AES_FLAGS_CFB64);
  542. }
  543. static int atmel_aes_cfb64_decrypt(struct ablkcipher_request *req)
  544. {
  545. return atmel_aes_crypt(req,
  546. AES_FLAGS_CFB | AES_FLAGS_CFB64);
  547. }
  548. static int atmel_aes_cfb32_encrypt(struct ablkcipher_request *req)
  549. {
  550. return atmel_aes_crypt(req,
  551. AES_FLAGS_ENCRYPT | AES_FLAGS_CFB | AES_FLAGS_CFB32);
  552. }
  553. static int atmel_aes_cfb32_decrypt(struct ablkcipher_request *req)
  554. {
  555. return atmel_aes_crypt(req,
  556. AES_FLAGS_CFB | AES_FLAGS_CFB32);
  557. }
  558. static int atmel_aes_cfb16_encrypt(struct ablkcipher_request *req)
  559. {
  560. return atmel_aes_crypt(req,
  561. AES_FLAGS_ENCRYPT | AES_FLAGS_CFB | AES_FLAGS_CFB16);
  562. }
  563. static int atmel_aes_cfb16_decrypt(struct ablkcipher_request *req)
  564. {
  565. return atmel_aes_crypt(req,
  566. AES_FLAGS_CFB | AES_FLAGS_CFB16);
  567. }
  568. static int atmel_aes_cfb8_encrypt(struct ablkcipher_request *req)
  569. {
  570. return atmel_aes_crypt(req,
  571. AES_FLAGS_ENCRYPT | AES_FLAGS_CFB | AES_FLAGS_CFB8);
  572. }
  573. static int atmel_aes_cfb8_decrypt(struct ablkcipher_request *req)
  574. {
  575. return atmel_aes_crypt(req,
  576. AES_FLAGS_CFB | AES_FLAGS_CFB8);
  577. }
  578. static int atmel_aes_ctr_encrypt(struct ablkcipher_request *req)
  579. {
  580. return atmel_aes_crypt(req,
  581. AES_FLAGS_ENCRYPT | AES_FLAGS_CTR);
  582. }
  583. static int atmel_aes_ctr_decrypt(struct ablkcipher_request *req)
  584. {
  585. return atmel_aes_crypt(req,
  586. AES_FLAGS_CTR);
  587. }
  588. static int atmel_aes_cra_init(struct crypto_tfm *tfm)
  589. {
  590. tfm->crt_ablkcipher.reqsize = sizeof(struct atmel_aes_reqctx);
  591. return 0;
  592. }
  593. static void atmel_aes_cra_exit(struct crypto_tfm *tfm)
  594. {
  595. }
  596. static struct crypto_alg aes_algs[] = {
  597. {
  598. .cra_name = "ecb(aes)",
  599. .cra_driver_name = "atmel-ecb-aes",
  600. .cra_priority = 100,
  601. .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
  602. .cra_blocksize = AES_BLOCK_SIZE,
  603. .cra_ctxsize = sizeof(struct atmel_aes_ctx),
  604. .cra_alignmask = 0x0,
  605. .cra_type = &crypto_ablkcipher_type,
  606. .cra_module = THIS_MODULE,
  607. .cra_init = atmel_aes_cra_init,
  608. .cra_exit = atmel_aes_cra_exit,
  609. .cra_u.ablkcipher = {
  610. .min_keysize = AES_MIN_KEY_SIZE,
  611. .max_keysize = AES_MAX_KEY_SIZE,
  612. .setkey = atmel_aes_setkey,
  613. .encrypt = atmel_aes_ecb_encrypt,
  614. .decrypt = atmel_aes_ecb_decrypt,
  615. }
  616. },
  617. {
  618. .cra_name = "cbc(aes)",
  619. .cra_driver_name = "atmel-cbc-aes",
  620. .cra_priority = 100,
  621. .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
  622. .cra_blocksize = AES_BLOCK_SIZE,
  623. .cra_ctxsize = sizeof(struct atmel_aes_ctx),
  624. .cra_alignmask = 0x0,
  625. .cra_type = &crypto_ablkcipher_type,
  626. .cra_module = THIS_MODULE,
  627. .cra_init = atmel_aes_cra_init,
  628. .cra_exit = atmel_aes_cra_exit,
  629. .cra_u.ablkcipher = {
  630. .min_keysize = AES_MIN_KEY_SIZE,
  631. .max_keysize = AES_MAX_KEY_SIZE,
  632. .ivsize = AES_BLOCK_SIZE,
  633. .setkey = atmel_aes_setkey,
  634. .encrypt = atmel_aes_cbc_encrypt,
  635. .decrypt = atmel_aes_cbc_decrypt,
  636. }
  637. },
  638. {
  639. .cra_name = "ofb(aes)",
  640. .cra_driver_name = "atmel-ofb-aes",
  641. .cra_priority = 100,
  642. .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
  643. .cra_blocksize = AES_BLOCK_SIZE,
  644. .cra_ctxsize = sizeof(struct atmel_aes_ctx),
  645. .cra_alignmask = 0x0,
  646. .cra_type = &crypto_ablkcipher_type,
  647. .cra_module = THIS_MODULE,
  648. .cra_init = atmel_aes_cra_init,
  649. .cra_exit = atmel_aes_cra_exit,
  650. .cra_u.ablkcipher = {
  651. .min_keysize = AES_MIN_KEY_SIZE,
  652. .max_keysize = AES_MAX_KEY_SIZE,
  653. .ivsize = AES_BLOCK_SIZE,
  654. .setkey = atmel_aes_setkey,
  655. .encrypt = atmel_aes_ofb_encrypt,
  656. .decrypt = atmel_aes_ofb_decrypt,
  657. }
  658. },
  659. {
  660. .cra_name = "cfb(aes)",
  661. .cra_driver_name = "atmel-cfb-aes",
  662. .cra_priority = 100,
  663. .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
  664. .cra_blocksize = AES_BLOCK_SIZE,
  665. .cra_ctxsize = sizeof(struct atmel_aes_ctx),
  666. .cra_alignmask = 0x0,
  667. .cra_type = &crypto_ablkcipher_type,
  668. .cra_module = THIS_MODULE,
  669. .cra_init = atmel_aes_cra_init,
  670. .cra_exit = atmel_aes_cra_exit,
  671. .cra_u.ablkcipher = {
  672. .min_keysize = AES_MIN_KEY_SIZE,
  673. .max_keysize = AES_MAX_KEY_SIZE,
  674. .ivsize = AES_BLOCK_SIZE,
  675. .setkey = atmel_aes_setkey,
  676. .encrypt = atmel_aes_cfb_encrypt,
  677. .decrypt = atmel_aes_cfb_decrypt,
  678. }
  679. },
  680. {
  681. .cra_name = "cfb32(aes)",
  682. .cra_driver_name = "atmel-cfb32-aes",
  683. .cra_priority = 100,
  684. .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
  685. .cra_blocksize = CFB32_BLOCK_SIZE,
  686. .cra_ctxsize = sizeof(struct atmel_aes_ctx),
  687. .cra_alignmask = 0x0,
  688. .cra_type = &crypto_ablkcipher_type,
  689. .cra_module = THIS_MODULE,
  690. .cra_init = atmel_aes_cra_init,
  691. .cra_exit = atmel_aes_cra_exit,
  692. .cra_u.ablkcipher = {
  693. .min_keysize = AES_MIN_KEY_SIZE,
  694. .max_keysize = AES_MAX_KEY_SIZE,
  695. .ivsize = AES_BLOCK_SIZE,
  696. .setkey = atmel_aes_setkey,
  697. .encrypt = atmel_aes_cfb32_encrypt,
  698. .decrypt = atmel_aes_cfb32_decrypt,
  699. }
  700. },
  701. {
  702. .cra_name = "cfb16(aes)",
  703. .cra_driver_name = "atmel-cfb16-aes",
  704. .cra_priority = 100,
  705. .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
  706. .cra_blocksize = CFB16_BLOCK_SIZE,
  707. .cra_ctxsize = sizeof(struct atmel_aes_ctx),
  708. .cra_alignmask = 0x0,
  709. .cra_type = &crypto_ablkcipher_type,
  710. .cra_module = THIS_MODULE,
  711. .cra_init = atmel_aes_cra_init,
  712. .cra_exit = atmel_aes_cra_exit,
  713. .cra_u.ablkcipher = {
  714. .min_keysize = AES_MIN_KEY_SIZE,
  715. .max_keysize = AES_MAX_KEY_SIZE,
  716. .ivsize = AES_BLOCK_SIZE,
  717. .setkey = atmel_aes_setkey,
  718. .encrypt = atmel_aes_cfb16_encrypt,
  719. .decrypt = atmel_aes_cfb16_decrypt,
  720. }
  721. },
  722. {
  723. .cra_name = "cfb8(aes)",
  724. .cra_driver_name = "atmel-cfb8-aes",
  725. .cra_priority = 100,
  726. .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
  727. .cra_blocksize = CFB64_BLOCK_SIZE,
  728. .cra_ctxsize = sizeof(struct atmel_aes_ctx),
  729. .cra_alignmask = 0x0,
  730. .cra_type = &crypto_ablkcipher_type,
  731. .cra_module = THIS_MODULE,
  732. .cra_init = atmel_aes_cra_init,
  733. .cra_exit = atmel_aes_cra_exit,
  734. .cra_u.ablkcipher = {
  735. .min_keysize = AES_MIN_KEY_SIZE,
  736. .max_keysize = AES_MAX_KEY_SIZE,
  737. .ivsize = AES_BLOCK_SIZE,
  738. .setkey = atmel_aes_setkey,
  739. .encrypt = atmel_aes_cfb8_encrypt,
  740. .decrypt = atmel_aes_cfb8_decrypt,
  741. }
  742. },
  743. {
  744. .cra_name = "ctr(aes)",
  745. .cra_driver_name = "atmel-ctr-aes",
  746. .cra_priority = 100,
  747. .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
  748. .cra_blocksize = AES_BLOCK_SIZE,
  749. .cra_ctxsize = sizeof(struct atmel_aes_ctx),
  750. .cra_alignmask = 0x0,
  751. .cra_type = &crypto_ablkcipher_type,
  752. .cra_module = THIS_MODULE,
  753. .cra_init = atmel_aes_cra_init,
  754. .cra_exit = atmel_aes_cra_exit,
  755. .cra_u.ablkcipher = {
  756. .min_keysize = AES_MIN_KEY_SIZE,
  757. .max_keysize = AES_MAX_KEY_SIZE,
  758. .ivsize = AES_BLOCK_SIZE,
  759. .setkey = atmel_aes_setkey,
  760. .encrypt = atmel_aes_ctr_encrypt,
  761. .decrypt = atmel_aes_ctr_decrypt,
  762. }
  763. },
  764. };
  765. static struct crypto_alg aes_cfb64_alg[] = {
  766. {
  767. .cra_name = "cfb64(aes)",
  768. .cra_driver_name = "atmel-cfb64-aes",
  769. .cra_priority = 100,
  770. .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
  771. .cra_blocksize = CFB64_BLOCK_SIZE,
  772. .cra_ctxsize = sizeof(struct atmel_aes_ctx),
  773. .cra_alignmask = 0x0,
  774. .cra_type = &crypto_ablkcipher_type,
  775. .cra_module = THIS_MODULE,
  776. .cra_init = atmel_aes_cra_init,
  777. .cra_exit = atmel_aes_cra_exit,
  778. .cra_u.ablkcipher = {
  779. .min_keysize = AES_MIN_KEY_SIZE,
  780. .max_keysize = AES_MAX_KEY_SIZE,
  781. .ivsize = AES_BLOCK_SIZE,
  782. .setkey = atmel_aes_setkey,
  783. .encrypt = atmel_aes_cfb64_encrypt,
  784. .decrypt = atmel_aes_cfb64_decrypt,
  785. }
  786. },
  787. };
  788. static void atmel_aes_queue_task(unsigned long data)
  789. {
  790. struct atmel_aes_dev *dd = (struct atmel_aes_dev *)data;
  791. atmel_aes_handle_queue(dd, NULL);
  792. }
  793. static void atmel_aes_done_task(unsigned long data)
  794. {
  795. struct atmel_aes_dev *dd = (struct atmel_aes_dev *) data;
  796. int err;
  797. if (!(dd->flags & AES_FLAGS_DMA)) {
  798. atmel_aes_read_n(dd, AES_ODATAR(0), (u32 *) dd->buf_out,
  799. dd->bufcnt >> 2);
  800. if (sg_copy_from_buffer(dd->out_sg, dd->nb_out_sg,
  801. dd->buf_out, dd->bufcnt))
  802. err = 0;
  803. else
  804. err = -EINVAL;
  805. goto cpu_end;
  806. }
  807. err = atmel_aes_crypt_dma_stop(dd);
  808. err = dd->err ? : err;
  809. if (dd->total && !err) {
  810. err = atmel_aes_crypt_dma_start(dd);
  811. if (!err)
  812. return; /* DMA started. Not fininishing. */
  813. }
  814. cpu_end:
  815. atmel_aes_finish_req(dd, err);
  816. atmel_aes_handle_queue(dd, NULL);
  817. }
  818. static irqreturn_t atmel_aes_irq(int irq, void *dev_id)
  819. {
  820. struct atmel_aes_dev *aes_dd = dev_id;
  821. u32 reg;
  822. reg = atmel_aes_read(aes_dd, AES_ISR);
  823. if (reg & atmel_aes_read(aes_dd, AES_IMR)) {
  824. atmel_aes_write(aes_dd, AES_IDR, reg);
  825. if (AES_FLAGS_BUSY & aes_dd->flags)
  826. tasklet_schedule(&aes_dd->done_task);
  827. else
  828. dev_warn(aes_dd->dev, "AES interrupt when no active requests.\n");
  829. return IRQ_HANDLED;
  830. }
  831. return IRQ_NONE;
  832. }
  833. static void atmel_aes_unregister_algs(struct atmel_aes_dev *dd)
  834. {
  835. int i;
  836. for (i = 0; i < ARRAY_SIZE(aes_algs); i++)
  837. crypto_unregister_alg(&aes_algs[i]);
  838. if (dd->hw_version >= 0x130)
  839. crypto_unregister_alg(&aes_cfb64_alg[0]);
  840. }
  841. static int atmel_aes_register_algs(struct atmel_aes_dev *dd)
  842. {
  843. int err, i, j;
  844. for (i = 0; i < ARRAY_SIZE(aes_algs); i++) {
  845. err = crypto_register_alg(&aes_algs[i]);
  846. if (err)
  847. goto err_aes_algs;
  848. }
  849. atmel_aes_hw_version_init(dd);
  850. if (dd->hw_version >= 0x130) {
  851. err = crypto_register_alg(&aes_cfb64_alg[0]);
  852. if (err)
  853. goto err_aes_cfb64_alg;
  854. }
  855. return 0;
  856. err_aes_cfb64_alg:
  857. i = ARRAY_SIZE(aes_algs);
  858. err_aes_algs:
  859. for (j = 0; j < i; j++)
  860. crypto_unregister_alg(&aes_algs[j]);
  861. return err;
  862. }
  863. static int atmel_aes_probe(struct platform_device *pdev)
  864. {
  865. struct atmel_aes_dev *aes_dd;
  866. struct aes_platform_data *pdata;
  867. struct device *dev = &pdev->dev;
  868. struct resource *aes_res;
  869. unsigned long aes_phys_size;
  870. int err;
  871. pdata = pdev->dev.platform_data;
  872. if (!pdata) {
  873. err = -ENXIO;
  874. goto aes_dd_err;
  875. }
  876. aes_dd = kzalloc(sizeof(struct atmel_aes_dev), GFP_KERNEL);
  877. if (aes_dd == NULL) {
  878. dev_err(dev, "unable to alloc data struct.\n");
  879. err = -ENOMEM;
  880. goto aes_dd_err;
  881. }
  882. aes_dd->dev = dev;
  883. platform_set_drvdata(pdev, aes_dd);
  884. INIT_LIST_HEAD(&aes_dd->list);
  885. tasklet_init(&aes_dd->done_task, atmel_aes_done_task,
  886. (unsigned long)aes_dd);
  887. tasklet_init(&aes_dd->queue_task, atmel_aes_queue_task,
  888. (unsigned long)aes_dd);
  889. crypto_init_queue(&aes_dd->queue, ATMEL_AES_QUEUE_LENGTH);
  890. aes_dd->irq = -1;
  891. /* Get the base address */
  892. aes_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  893. if (!aes_res) {
  894. dev_err(dev, "no MEM resource info\n");
  895. err = -ENODEV;
  896. goto res_err;
  897. }
  898. aes_dd->phys_base = aes_res->start;
  899. aes_phys_size = resource_size(aes_res);
  900. /* Get the IRQ */
  901. aes_dd->irq = platform_get_irq(pdev, 0);
  902. if (aes_dd->irq < 0) {
  903. dev_err(dev, "no IRQ resource info\n");
  904. err = aes_dd->irq;
  905. goto aes_irq_err;
  906. }
  907. err = request_irq(aes_dd->irq, atmel_aes_irq, IRQF_SHARED, "atmel-aes",
  908. aes_dd);
  909. if (err) {
  910. dev_err(dev, "unable to request aes irq.\n");
  911. goto aes_irq_err;
  912. }
  913. /* Initializing the clock */
  914. aes_dd->iclk = clk_get(&pdev->dev, NULL);
  915. if (IS_ERR(aes_dd->iclk)) {
  916. dev_err(dev, "clock intialization failed.\n");
  917. err = PTR_ERR(aes_dd->iclk);
  918. goto clk_err;
  919. }
  920. aes_dd->io_base = ioremap(aes_dd->phys_base, aes_phys_size);
  921. if (!aes_dd->io_base) {
  922. dev_err(dev, "can't ioremap\n");
  923. err = -ENOMEM;
  924. goto aes_io_err;
  925. }
  926. err = atmel_aes_dma_init(aes_dd);
  927. if (err)
  928. goto err_aes_dma;
  929. spin_lock(&atmel_aes.lock);
  930. list_add_tail(&aes_dd->list, &atmel_aes.dev_list);
  931. spin_unlock(&atmel_aes.lock);
  932. err = atmel_aes_register_algs(aes_dd);
  933. if (err)
  934. goto err_algs;
  935. dev_info(dev, "Atmel AES\n");
  936. return 0;
  937. err_algs:
  938. spin_lock(&atmel_aes.lock);
  939. list_del(&aes_dd->list);
  940. spin_unlock(&atmel_aes.lock);
  941. atmel_aes_dma_cleanup(aes_dd);
  942. err_aes_dma:
  943. iounmap(aes_dd->io_base);
  944. aes_io_err:
  945. clk_put(aes_dd->iclk);
  946. clk_err:
  947. free_irq(aes_dd->irq, aes_dd);
  948. aes_irq_err:
  949. res_err:
  950. tasklet_kill(&aes_dd->done_task);
  951. tasklet_kill(&aes_dd->queue_task);
  952. kfree(aes_dd);
  953. aes_dd = NULL;
  954. aes_dd_err:
  955. dev_err(dev, "initialization failed.\n");
  956. return err;
  957. }
  958. static int atmel_aes_remove(struct platform_device *pdev)
  959. {
  960. static struct atmel_aes_dev *aes_dd;
  961. aes_dd = platform_get_drvdata(pdev);
  962. if (!aes_dd)
  963. return -ENODEV;
  964. spin_lock(&atmel_aes.lock);
  965. list_del(&aes_dd->list);
  966. spin_unlock(&atmel_aes.lock);
  967. atmel_aes_unregister_algs(aes_dd);
  968. tasklet_kill(&aes_dd->done_task);
  969. tasklet_kill(&aes_dd->queue_task);
  970. atmel_aes_dma_cleanup(aes_dd);
  971. iounmap(aes_dd->io_base);
  972. clk_put(aes_dd->iclk);
  973. if (aes_dd->irq > 0)
  974. free_irq(aes_dd->irq, aes_dd);
  975. kfree(aes_dd);
  976. aes_dd = NULL;
  977. return 0;
  978. }
  979. static struct platform_driver atmel_aes_driver = {
  980. .probe = atmel_aes_probe,
  981. .remove = atmel_aes_remove,
  982. .driver = {
  983. .name = "atmel_aes",
  984. .owner = THIS_MODULE,
  985. },
  986. };
  987. module_platform_driver(atmel_aes_driver);
  988. MODULE_DESCRIPTION("Atmel AES hw acceleration support.");
  989. MODULE_LICENSE("GPL v2");
  990. MODULE_AUTHOR("Nicolas Royer - Eukréa Electromatique");