Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Cryptographic API. |
| 3 | * |
| 4 | * Support for OMAP AES HW acceleration. |
| 5 | * |
| 6 | * Copyright (c) 2010 Nokia Corporation |
| 7 | * Author: Dmitry Kasatkin <dmitry.kasatkin@nokia.com> |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 8 | * Copyright (c) 2011 Texas Instruments Incorporated |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License version 2 as published |
| 12 | * by the Free Software Foundation. |
| 13 | * |
| 14 | */ |
| 15 | |
Joel Fernandes | 016af9b | 2013-08-18 00:56:11 -0500 | [diff] [blame] | 16 | #define pr_fmt(fmt) "%20s: " fmt, __func__ |
| 17 | #define prn(num) pr_debug(#num "=%d\n", num) |
| 18 | #define prx(num) pr_debug(#num "=%x\n", num) |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 19 | |
| 20 | #include <linux/err.h> |
| 21 | #include <linux/module.h> |
| 22 | #include <linux/init.h> |
| 23 | #include <linux/errno.h> |
| 24 | #include <linux/kernel.h> |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 25 | #include <linux/platform_device.h> |
| 26 | #include <linux/scatterlist.h> |
| 27 | #include <linux/dma-mapping.h> |
Mark A. Greer | ebedbf7 | 2013-01-08 11:57:42 -0700 | [diff] [blame] | 28 | #include <linux/dmaengine.h> |
Mark A. Greer | 5946c4a | 2013-01-08 11:57:40 -0700 | [diff] [blame] | 29 | #include <linux/pm_runtime.h> |
Mark A. Greer | bc69d12 | 2013-01-08 11:57:44 -0700 | [diff] [blame] | 30 | #include <linux/of.h> |
| 31 | #include <linux/of_device.h> |
| 32 | #include <linux/of_address.h> |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 33 | #include <linux/io.h> |
| 34 | #include <linux/crypto.h> |
| 35 | #include <linux/interrupt.h> |
| 36 | #include <crypto/scatterwalk.h> |
| 37 | #include <crypto/aes.h> |
Corentin LABBE | 2589ad8 | 2016-08-31 14:02:57 +0200 | [diff] [blame] | 38 | #include <crypto/engine.h> |
Lokesh Vutla | 9fcb191 | 2016-08-04 13:28:44 +0300 | [diff] [blame] | 39 | #include <crypto/internal/skcipher.h> |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 40 | |
Tero Kristo | afc2dc1 | 2017-05-24 10:35:28 +0300 | [diff] [blame^] | 41 | #include "omap-crypto.h" |
| 42 | |
Mark A. Greer | ebedbf7 | 2013-01-08 11:57:42 -0700 | [diff] [blame] | 43 | #define DST_MAXBURST 4 |
| 44 | #define DMA_MIN (DST_MAXBURST * sizeof(u32)) |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 45 | |
Joel Fernandes | 1bf95cc | 2013-08-17 21:42:29 -0500 | [diff] [blame] | 46 | #define _calc_walked(inout) (dd->inout##_walk.offset - dd->inout##_sg->offset) |
| 47 | |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 48 | /* OMAP TRM gives bitfields as start:end, where start is the higher bit |
| 49 | number. For example 7:0 */ |
| 50 | #define FLD_MASK(start, end) (((1 << ((start) - (end) + 1)) - 1) << (end)) |
| 51 | #define FLD_VAL(val, start, end) (((val) << (end)) & FLD_MASK(start, end)) |
| 52 | |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 53 | #define AES_REG_KEY(dd, x) ((dd)->pdata->key_ofs - \ |
| 54 | ((x ^ 0x01) * 0x04)) |
| 55 | #define AES_REG_IV(dd, x) ((dd)->pdata->iv_ofs + ((x) * 0x04)) |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 56 | |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 57 | #define AES_REG_CTRL(dd) ((dd)->pdata->ctrl_ofs) |
Vutla, Lokesh | 340d9d3 | 2015-07-07 21:01:46 +0530 | [diff] [blame] | 58 | #define AES_REG_CTRL_CTR_WIDTH_MASK GENMASK(8, 7) |
| 59 | #define AES_REG_CTRL_CTR_WIDTH_32 0 |
| 60 | #define AES_REG_CTRL_CTR_WIDTH_64 BIT(7) |
| 61 | #define AES_REG_CTRL_CTR_WIDTH_96 BIT(8) |
| 62 | #define AES_REG_CTRL_CTR_WIDTH_128 GENMASK(8, 7) |
| 63 | #define AES_REG_CTRL_CTR BIT(6) |
| 64 | #define AES_REG_CTRL_CBC BIT(5) |
| 65 | #define AES_REG_CTRL_KEY_SIZE GENMASK(4, 3) |
| 66 | #define AES_REG_CTRL_DIRECTION BIT(2) |
| 67 | #define AES_REG_CTRL_INPUT_READY BIT(1) |
| 68 | #define AES_REG_CTRL_OUTPUT_READY BIT(0) |
Vutla, Lokesh | 5396c6c | 2015-07-07 21:01:45 +0530 | [diff] [blame] | 69 | #define AES_REG_CTRL_MASK GENMASK(24, 2) |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 70 | |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 71 | #define AES_REG_DATA_N(dd, x) ((dd)->pdata->data_ofs + ((x) * 0x04)) |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 72 | |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 73 | #define AES_REG_REV(dd) ((dd)->pdata->rev_ofs) |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 74 | |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 75 | #define AES_REG_MASK(dd) ((dd)->pdata->mask_ofs) |
Vutla, Lokesh | 340d9d3 | 2015-07-07 21:01:46 +0530 | [diff] [blame] | 76 | #define AES_REG_MASK_SIDLE BIT(6) |
| 77 | #define AES_REG_MASK_START BIT(5) |
| 78 | #define AES_REG_MASK_DMA_OUT_EN BIT(3) |
| 79 | #define AES_REG_MASK_DMA_IN_EN BIT(2) |
| 80 | #define AES_REG_MASK_SOFTRESET BIT(1) |
| 81 | #define AES_REG_AUTOIDLE BIT(0) |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 82 | |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 83 | #define AES_REG_LENGTH_N(x) (0x54 + ((x) * 0x04)) |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 84 | |
Joel Fernandes | 6721675 | 2013-08-17 21:42:28 -0500 | [diff] [blame] | 85 | #define AES_REG_IRQ_STATUS(dd) ((dd)->pdata->irq_status_ofs) |
| 86 | #define AES_REG_IRQ_ENABLE(dd) ((dd)->pdata->irq_enable_ofs) |
| 87 | #define AES_REG_IRQ_DATA_IN BIT(1) |
| 88 | #define AES_REG_IRQ_DATA_OUT BIT(2) |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 89 | #define DEFAULT_TIMEOUT (5*HZ) |
| 90 | |
Tero Kristo | f303b45 | 2016-08-04 13:28:42 +0300 | [diff] [blame] | 91 | #define DEFAULT_AUTOSUSPEND_DELAY 1000 |
| 92 | |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 93 | #define FLAGS_MODE_MASK 0x000f |
| 94 | #define FLAGS_ENCRYPT BIT(0) |
| 95 | #define FLAGS_CBC BIT(1) |
| 96 | #define FLAGS_GIV BIT(2) |
Mark A. Greer | f9fb69e | 2013-01-08 11:57:47 -0700 | [diff] [blame] | 97 | #define FLAGS_CTR BIT(3) |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 98 | |
Dmitry Kasatkin | 67a730c | 2010-11-30 10:13:30 +0200 | [diff] [blame] | 99 | #define FLAGS_INIT BIT(4) |
| 100 | #define FLAGS_FAST BIT(5) |
| 101 | #define FLAGS_BUSY BIT(6) |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 102 | |
Tero Kristo | afc2dc1 | 2017-05-24 10:35:28 +0300 | [diff] [blame^] | 103 | #define FLAGS_IN_DATA_ST_SHIFT 8 |
| 104 | #define FLAGS_OUT_DATA_ST_SHIFT 10 |
| 105 | |
Joel Fernandes | 1bf95cc | 2013-08-17 21:42:29 -0500 | [diff] [blame] | 106 | #define AES_BLOCK_WORDS (AES_BLOCK_SIZE >> 2) |
| 107 | |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 108 | struct omap_aes_ctx { |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 109 | int keylen; |
| 110 | u32 key[AES_KEYSIZE_256 / sizeof(u32)]; |
Lokesh Vutla | 9fcb191 | 2016-08-04 13:28:44 +0300 | [diff] [blame] | 111 | struct crypto_skcipher *fallback; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 112 | }; |
| 113 | |
| 114 | struct omap_aes_reqctx { |
Tero Kristo | 619ce70 | 2017-05-24 10:35:23 +0300 | [diff] [blame] | 115 | struct omap_aes_dev *dd; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 116 | unsigned long mode; |
| 117 | }; |
| 118 | |
| 119 | #define OMAP_AES_QUEUE_LENGTH 1 |
| 120 | #define OMAP_AES_CACHE_SIZE 0 |
| 121 | |
Mark A. Greer | f9fb69e | 2013-01-08 11:57:47 -0700 | [diff] [blame] | 122 | struct omap_aes_algs_info { |
| 123 | struct crypto_alg *algs_list; |
| 124 | unsigned int size; |
| 125 | unsigned int registered; |
| 126 | }; |
| 127 | |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 128 | struct omap_aes_pdata { |
Mark A. Greer | f9fb69e | 2013-01-08 11:57:47 -0700 | [diff] [blame] | 129 | struct omap_aes_algs_info *algs_info; |
| 130 | unsigned int algs_info_size; |
| 131 | |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 132 | void (*trigger)(struct omap_aes_dev *dd, int length); |
| 133 | |
| 134 | u32 key_ofs; |
| 135 | u32 iv_ofs; |
| 136 | u32 ctrl_ofs; |
| 137 | u32 data_ofs; |
| 138 | u32 rev_ofs; |
| 139 | u32 mask_ofs; |
Joel Fernandes | 6721675 | 2013-08-17 21:42:28 -0500 | [diff] [blame] | 140 | u32 irq_enable_ofs; |
| 141 | u32 irq_status_ofs; |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 142 | |
| 143 | u32 dma_enable_in; |
| 144 | u32 dma_enable_out; |
| 145 | u32 dma_start; |
| 146 | |
| 147 | u32 major_mask; |
| 148 | u32 major_shift; |
| 149 | u32 minor_mask; |
| 150 | u32 minor_shift; |
| 151 | }; |
| 152 | |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 153 | struct omap_aes_dev { |
| 154 | struct list_head list; |
| 155 | unsigned long phys_base; |
Dmitry Kasatkin | efce41b | 2010-11-30 10:13:32 +0200 | [diff] [blame] | 156 | void __iomem *io_base; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 157 | struct omap_aes_ctx *ctx; |
| 158 | struct device *dev; |
| 159 | unsigned long flags; |
Dmitry Kasatkin | 21fe976 | 2010-11-30 10:13:29 +0200 | [diff] [blame] | 160 | int err; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 161 | |
Dmitry Kasatkin | 21fe976 | 2010-11-30 10:13:29 +0200 | [diff] [blame] | 162 | struct tasklet_struct done_task; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 163 | |
| 164 | struct ablkcipher_request *req; |
Baolin Wang | 0529900 | 2016-01-26 20:25:40 +0800 | [diff] [blame] | 165 | struct crypto_engine *engine; |
Joel Fernandes | 6242332 | 2013-08-17 21:42:32 -0500 | [diff] [blame] | 166 | |
| 167 | /* |
| 168 | * total is used by PIO mode for book keeping so introduce |
| 169 | * variable total_save as need it to calc page_order |
| 170 | */ |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 171 | size_t total; |
Joel Fernandes | 6242332 | 2013-08-17 21:42:32 -0500 | [diff] [blame] | 172 | size_t total_save; |
| 173 | |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 174 | struct scatterlist *in_sg; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 175 | struct scatterlist *out_sg; |
Joel Fernandes | 6242332 | 2013-08-17 21:42:32 -0500 | [diff] [blame] | 176 | |
| 177 | /* Buffers for copying for unaligned cases */ |
| 178 | struct scatterlist in_sgl; |
| 179 | struct scatterlist out_sgl; |
| 180 | struct scatterlist *orig_out; |
Joel Fernandes | 6242332 | 2013-08-17 21:42:32 -0500 | [diff] [blame] | 181 | |
Joel Fernandes | 1bf95cc | 2013-08-17 21:42:29 -0500 | [diff] [blame] | 182 | struct scatter_walk in_walk; |
| 183 | struct scatter_walk out_walk; |
Mark A. Greer | ebedbf7 | 2013-01-08 11:57:42 -0700 | [diff] [blame] | 184 | struct dma_chan *dma_lch_in; |
Mark A. Greer | ebedbf7 | 2013-01-08 11:57:42 -0700 | [diff] [blame] | 185 | struct dma_chan *dma_lch_out; |
Joel Fernandes | e77c756 | 2013-08-17 21:42:24 -0500 | [diff] [blame] | 186 | int in_sg_len; |
| 187 | int out_sg_len; |
Joel Fernandes | 98837ab | 2013-08-17 21:42:30 -0500 | [diff] [blame] | 188 | int pio_only; |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 189 | const struct omap_aes_pdata *pdata; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 190 | }; |
| 191 | |
| 192 | /* keep registered devices data here */ |
| 193 | static LIST_HEAD(dev_list); |
| 194 | static DEFINE_SPINLOCK(list_lock); |
| 195 | |
Joel Fernandes | 016af9b | 2013-08-18 00:56:11 -0500 | [diff] [blame] | 196 | #ifdef DEBUG |
| 197 | #define omap_aes_read(dd, offset) \ |
| 198 | ({ \ |
| 199 | int _read_ret; \ |
| 200 | _read_ret = __raw_readl(dd->io_base + offset); \ |
| 201 | pr_debug("omap_aes_read(" #offset "=%#x)= %#x\n", \ |
| 202 | offset, _read_ret); \ |
| 203 | _read_ret; \ |
| 204 | }) |
| 205 | #else |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 206 | static inline u32 omap_aes_read(struct omap_aes_dev *dd, u32 offset) |
| 207 | { |
| 208 | return __raw_readl(dd->io_base + offset); |
| 209 | } |
Joel Fernandes | 016af9b | 2013-08-18 00:56:11 -0500 | [diff] [blame] | 210 | #endif |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 211 | |
Joel Fernandes | 016af9b | 2013-08-18 00:56:11 -0500 | [diff] [blame] | 212 | #ifdef DEBUG |
| 213 | #define omap_aes_write(dd, offset, value) \ |
| 214 | do { \ |
| 215 | pr_debug("omap_aes_write(" #offset "=%#x) value=%#x\n", \ |
| 216 | offset, value); \ |
| 217 | __raw_writel(value, dd->io_base + offset); \ |
| 218 | } while (0) |
| 219 | #else |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 220 | static inline void omap_aes_write(struct omap_aes_dev *dd, u32 offset, |
| 221 | u32 value) |
| 222 | { |
| 223 | __raw_writel(value, dd->io_base + offset); |
| 224 | } |
Joel Fernandes | 016af9b | 2013-08-18 00:56:11 -0500 | [diff] [blame] | 225 | #endif |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 226 | |
| 227 | static inline void omap_aes_write_mask(struct omap_aes_dev *dd, u32 offset, |
| 228 | u32 value, u32 mask) |
| 229 | { |
| 230 | u32 val; |
| 231 | |
| 232 | val = omap_aes_read(dd, offset); |
| 233 | val &= ~mask; |
| 234 | val |= value; |
| 235 | omap_aes_write(dd, offset, val); |
| 236 | } |
| 237 | |
| 238 | static void omap_aes_write_n(struct omap_aes_dev *dd, u32 offset, |
| 239 | u32 *value, int count) |
| 240 | { |
| 241 | for (; count--; value++, offset += 4) |
| 242 | omap_aes_write(dd, offset, *value); |
| 243 | } |
| 244 | |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 245 | static int omap_aes_hw_init(struct omap_aes_dev *dd) |
| 246 | { |
Tero Kristo | f303b45 | 2016-08-04 13:28:42 +0300 | [diff] [blame] | 247 | int err; |
| 248 | |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 249 | if (!(dd->flags & FLAGS_INIT)) { |
Dmitry Kasatkin | eeb2b20 | 2010-11-30 10:13:28 +0200 | [diff] [blame] | 250 | dd->flags |= FLAGS_INIT; |
Dmitry Kasatkin | 21fe976 | 2010-11-30 10:13:29 +0200 | [diff] [blame] | 251 | dd->err = 0; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 252 | } |
| 253 | |
Tero Kristo | f303b45 | 2016-08-04 13:28:42 +0300 | [diff] [blame] | 254 | err = pm_runtime_get_sync(dd->dev); |
| 255 | if (err < 0) { |
| 256 | dev_err(dd->dev, "failed to get sync: %d\n", err); |
| 257 | return err; |
| 258 | } |
| 259 | |
Dmitry Kasatkin | eeb2b20 | 2010-11-30 10:13:28 +0200 | [diff] [blame] | 260 | return 0; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 261 | } |
| 262 | |
Dmitry Kasatkin | 21fe976 | 2010-11-30 10:13:29 +0200 | [diff] [blame] | 263 | static int omap_aes_write_ctrl(struct omap_aes_dev *dd) |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 264 | { |
| 265 | unsigned int key32; |
Dmitry Kasatkin | 67a730c | 2010-11-30 10:13:30 +0200 | [diff] [blame] | 266 | int i, err; |
Vutla, Lokesh | 5396c6c | 2015-07-07 21:01:45 +0530 | [diff] [blame] | 267 | u32 val; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 268 | |
Dmitry Kasatkin | 21fe976 | 2010-11-30 10:13:29 +0200 | [diff] [blame] | 269 | err = omap_aes_hw_init(dd); |
| 270 | if (err) |
| 271 | return err; |
| 272 | |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 273 | key32 = dd->ctx->keylen / sizeof(u32); |
Dmitry Kasatkin | 67a730c | 2010-11-30 10:13:30 +0200 | [diff] [blame] | 274 | |
| 275 | /* it seems a key should always be set even if it has not changed */ |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 276 | for (i = 0; i < key32; i++) { |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 277 | omap_aes_write(dd, AES_REG_KEY(dd, i), |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 278 | __le32_to_cpu(dd->ctx->key[i])); |
| 279 | } |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 280 | |
Mark A. Greer | f9fb69e | 2013-01-08 11:57:47 -0700 | [diff] [blame] | 281 | if ((dd->flags & (FLAGS_CBC | FLAGS_CTR)) && dd->req->info) |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 282 | omap_aes_write_n(dd, AES_REG_IV(dd, 0), dd->req->info, 4); |
Dmitry Kasatkin | 67a730c | 2010-11-30 10:13:30 +0200 | [diff] [blame] | 283 | |
| 284 | val = FLD_VAL(((dd->ctx->keylen >> 3) - 1), 4, 3); |
| 285 | if (dd->flags & FLAGS_CBC) |
| 286 | val |= AES_REG_CTRL_CBC; |
Vutla, Lokesh | 5396c6c | 2015-07-07 21:01:45 +0530 | [diff] [blame] | 287 | if (dd->flags & FLAGS_CTR) |
Joel Fernandes | 8ed49c7 | 2013-10-29 17:37:38 -0500 | [diff] [blame] | 288 | val |= AES_REG_CTRL_CTR | AES_REG_CTRL_CTR_WIDTH_128; |
Vutla, Lokesh | 5396c6c | 2015-07-07 21:01:45 +0530 | [diff] [blame] | 289 | |
Dmitry Kasatkin | 67a730c | 2010-11-30 10:13:30 +0200 | [diff] [blame] | 290 | if (dd->flags & FLAGS_ENCRYPT) |
| 291 | val |= AES_REG_CTRL_DIRECTION; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 292 | |
Vutla, Lokesh | 5396c6c | 2015-07-07 21:01:45 +0530 | [diff] [blame] | 293 | omap_aes_write_mask(dd, AES_REG_CTRL(dd), val, AES_REG_CTRL_MASK); |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 294 | |
Dmitry Kasatkin | 21fe976 | 2010-11-30 10:13:29 +0200 | [diff] [blame] | 295 | return 0; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 296 | } |
| 297 | |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 298 | static void omap_aes_dma_trigger_omap2(struct omap_aes_dev *dd, int length) |
| 299 | { |
| 300 | u32 mask, val; |
| 301 | |
| 302 | val = dd->pdata->dma_start; |
| 303 | |
| 304 | if (dd->dma_lch_out != NULL) |
| 305 | val |= dd->pdata->dma_enable_out; |
| 306 | if (dd->dma_lch_in != NULL) |
| 307 | val |= dd->pdata->dma_enable_in; |
| 308 | |
| 309 | mask = dd->pdata->dma_enable_out | dd->pdata->dma_enable_in | |
| 310 | dd->pdata->dma_start; |
| 311 | |
| 312 | omap_aes_write_mask(dd, AES_REG_MASK(dd), val, mask); |
| 313 | |
| 314 | } |
| 315 | |
| 316 | static void omap_aes_dma_trigger_omap4(struct omap_aes_dev *dd, int length) |
| 317 | { |
| 318 | omap_aes_write(dd, AES_REG_LENGTH_N(0), length); |
| 319 | omap_aes_write(dd, AES_REG_LENGTH_N(1), 0); |
| 320 | |
| 321 | omap_aes_dma_trigger_omap2(dd, length); |
| 322 | } |
| 323 | |
| 324 | static void omap_aes_dma_stop(struct omap_aes_dev *dd) |
| 325 | { |
| 326 | u32 mask; |
| 327 | |
| 328 | mask = dd->pdata->dma_enable_out | dd->pdata->dma_enable_in | |
| 329 | dd->pdata->dma_start; |
| 330 | |
| 331 | omap_aes_write_mask(dd, AES_REG_MASK(dd), 0, mask); |
| 332 | } |
| 333 | |
Tero Kristo | 619ce70 | 2017-05-24 10:35:23 +0300 | [diff] [blame] | 334 | static struct omap_aes_dev *omap_aes_find_dev(struct omap_aes_reqctx *rctx) |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 335 | { |
Lokesh Vutla | 164f3ef | 2016-08-04 13:28:43 +0300 | [diff] [blame] | 336 | struct omap_aes_dev *dd; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 337 | |
| 338 | spin_lock_bh(&list_lock); |
Lokesh Vutla | 164f3ef | 2016-08-04 13:28:43 +0300 | [diff] [blame] | 339 | dd = list_first_entry(&dev_list, struct omap_aes_dev, list); |
| 340 | list_move_tail(&dd->list, &dev_list); |
Tero Kristo | 619ce70 | 2017-05-24 10:35:23 +0300 | [diff] [blame] | 341 | rctx->dd = dd; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 342 | spin_unlock_bh(&list_lock); |
| 343 | |
| 344 | return dd; |
| 345 | } |
| 346 | |
Mark A. Greer | ebedbf7 | 2013-01-08 11:57:42 -0700 | [diff] [blame] | 347 | static void omap_aes_dma_out_callback(void *data) |
| 348 | { |
| 349 | struct omap_aes_dev *dd = data; |
| 350 | |
| 351 | /* dma_lch_out - completed */ |
| 352 | tasklet_schedule(&dd->done_task); |
| 353 | } |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 354 | |
| 355 | static int omap_aes_dma_init(struct omap_aes_dev *dd) |
| 356 | { |
Peter Ujfalusi | da8b29a | 2016-04-29 16:02:18 +0300 | [diff] [blame] | 357 | int err; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 358 | |
Mark A. Greer | ebedbf7 | 2013-01-08 11:57:42 -0700 | [diff] [blame] | 359 | dd->dma_lch_out = NULL; |
| 360 | dd->dma_lch_in = NULL; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 361 | |
Peter Ujfalusi | da8b29a | 2016-04-29 16:02:18 +0300 | [diff] [blame] | 362 | dd->dma_lch_in = dma_request_chan(dd->dev, "rx"); |
| 363 | if (IS_ERR(dd->dma_lch_in)) { |
Mark A. Greer | ebedbf7 | 2013-01-08 11:57:42 -0700 | [diff] [blame] | 364 | dev_err(dd->dev, "Unable to request in DMA channel\n"); |
Peter Ujfalusi | da8b29a | 2016-04-29 16:02:18 +0300 | [diff] [blame] | 365 | return PTR_ERR(dd->dma_lch_in); |
Mark A. Greer | ebedbf7 | 2013-01-08 11:57:42 -0700 | [diff] [blame] | 366 | } |
| 367 | |
Peter Ujfalusi | da8b29a | 2016-04-29 16:02:18 +0300 | [diff] [blame] | 368 | dd->dma_lch_out = dma_request_chan(dd->dev, "tx"); |
| 369 | if (IS_ERR(dd->dma_lch_out)) { |
Mark A. Greer | ebedbf7 | 2013-01-08 11:57:42 -0700 | [diff] [blame] | 370 | dev_err(dd->dev, "Unable to request out DMA channel\n"); |
Peter Ujfalusi | da8b29a | 2016-04-29 16:02:18 +0300 | [diff] [blame] | 371 | err = PTR_ERR(dd->dma_lch_out); |
Mark A. Greer | ebedbf7 | 2013-01-08 11:57:42 -0700 | [diff] [blame] | 372 | goto err_dma_out; |
| 373 | } |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 374 | |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 375 | return 0; |
| 376 | |
| 377 | err_dma_out: |
Mark A. Greer | ebedbf7 | 2013-01-08 11:57:42 -0700 | [diff] [blame] | 378 | dma_release_channel(dd->dma_lch_in); |
Peter Ujfalusi | da8b29a | 2016-04-29 16:02:18 +0300 | [diff] [blame] | 379 | |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 380 | return err; |
| 381 | } |
| 382 | |
| 383 | static void omap_aes_dma_cleanup(struct omap_aes_dev *dd) |
| 384 | { |
Peter Ujfalusi | da8b29a | 2016-04-29 16:02:18 +0300 | [diff] [blame] | 385 | if (dd->pio_only) |
| 386 | return; |
| 387 | |
Mark A. Greer | ebedbf7 | 2013-01-08 11:57:42 -0700 | [diff] [blame] | 388 | dma_release_channel(dd->dma_lch_out); |
| 389 | dma_release_channel(dd->dma_lch_in); |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 390 | } |
| 391 | |
Tero Kristo | 619ce70 | 2017-05-24 10:35:23 +0300 | [diff] [blame] | 392 | static int omap_aes_crypt_dma(struct omap_aes_dev *dd, |
| 393 | struct scatterlist *in_sg, |
| 394 | struct scatterlist *out_sg, |
| 395 | int in_sg_len, int out_sg_len) |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 396 | { |
Mark A. Greer | ebedbf7 | 2013-01-08 11:57:42 -0700 | [diff] [blame] | 397 | struct dma_async_tx_descriptor *tx_in, *tx_out; |
| 398 | struct dma_slave_config cfg; |
Joel Fernandes | 4b645c9 | 2013-08-17 21:42:25 -0500 | [diff] [blame] | 399 | int ret; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 400 | |
Joel Fernandes | 98837ab | 2013-08-17 21:42:30 -0500 | [diff] [blame] | 401 | if (dd->pio_only) { |
| 402 | scatterwalk_start(&dd->in_walk, dd->in_sg); |
| 403 | scatterwalk_start(&dd->out_walk, dd->out_sg); |
| 404 | |
| 405 | /* Enable DATAIN interrupt and let it take |
| 406 | care of the rest */ |
| 407 | omap_aes_write(dd, AES_REG_IRQ_ENABLE(dd), 0x2); |
| 408 | return 0; |
| 409 | } |
| 410 | |
Joel Fernandes | 0a64171 | 2013-08-17 21:42:26 -0500 | [diff] [blame] | 411 | dma_sync_sg_for_device(dd->dev, dd->in_sg, in_sg_len, DMA_TO_DEVICE); |
| 412 | |
Mark A. Greer | ebedbf7 | 2013-01-08 11:57:42 -0700 | [diff] [blame] | 413 | memset(&cfg, 0, sizeof(cfg)); |
| 414 | |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 415 | cfg.src_addr = dd->phys_base + AES_REG_DATA_N(dd, 0); |
| 416 | cfg.dst_addr = dd->phys_base + AES_REG_DATA_N(dd, 0); |
Mark A. Greer | ebedbf7 | 2013-01-08 11:57:42 -0700 | [diff] [blame] | 417 | cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; |
| 418 | cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; |
| 419 | cfg.src_maxburst = DST_MAXBURST; |
| 420 | cfg.dst_maxburst = DST_MAXBURST; |
| 421 | |
| 422 | /* IN */ |
| 423 | ret = dmaengine_slave_config(dd->dma_lch_in, &cfg); |
| 424 | if (ret) { |
| 425 | dev_err(dd->dev, "can't configure IN dmaengine slave: %d\n", |
| 426 | ret); |
| 427 | return ret; |
| 428 | } |
| 429 | |
Joel Fernandes | 4b645c9 | 2013-08-17 21:42:25 -0500 | [diff] [blame] | 430 | tx_in = dmaengine_prep_slave_sg(dd->dma_lch_in, in_sg, in_sg_len, |
Mark A. Greer | ebedbf7 | 2013-01-08 11:57:42 -0700 | [diff] [blame] | 431 | DMA_MEM_TO_DEV, |
| 432 | DMA_PREP_INTERRUPT | DMA_CTRL_ACK); |
| 433 | if (!tx_in) { |
| 434 | dev_err(dd->dev, "IN prep_slave_sg() failed\n"); |
| 435 | return -EINVAL; |
| 436 | } |
| 437 | |
| 438 | /* No callback necessary */ |
| 439 | tx_in->callback_param = dd; |
| 440 | |
| 441 | /* OUT */ |
| 442 | ret = dmaengine_slave_config(dd->dma_lch_out, &cfg); |
| 443 | if (ret) { |
| 444 | dev_err(dd->dev, "can't configure OUT dmaengine slave: %d\n", |
| 445 | ret); |
| 446 | return ret; |
| 447 | } |
| 448 | |
Joel Fernandes | 4b645c9 | 2013-08-17 21:42:25 -0500 | [diff] [blame] | 449 | tx_out = dmaengine_prep_slave_sg(dd->dma_lch_out, out_sg, out_sg_len, |
Mark A. Greer | ebedbf7 | 2013-01-08 11:57:42 -0700 | [diff] [blame] | 450 | DMA_DEV_TO_MEM, |
| 451 | DMA_PREP_INTERRUPT | DMA_CTRL_ACK); |
| 452 | if (!tx_out) { |
| 453 | dev_err(dd->dev, "OUT prep_slave_sg() failed\n"); |
| 454 | return -EINVAL; |
| 455 | } |
| 456 | |
| 457 | tx_out->callback = omap_aes_dma_out_callback; |
| 458 | tx_out->callback_param = dd; |
| 459 | |
| 460 | dmaengine_submit(tx_in); |
| 461 | dmaengine_submit(tx_out); |
| 462 | |
| 463 | dma_async_issue_pending(dd->dma_lch_in); |
| 464 | dma_async_issue_pending(dd->dma_lch_out); |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 465 | |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 466 | /* start DMA */ |
Joel Fernandes | 4b645c9 | 2013-08-17 21:42:25 -0500 | [diff] [blame] | 467 | dd->pdata->trigger(dd, dd->total); |
Dmitry Kasatkin | 83ea7e0 | 2010-11-30 10:13:31 +0200 | [diff] [blame] | 468 | |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 469 | return 0; |
| 470 | } |
| 471 | |
| 472 | static int omap_aes_crypt_dma_start(struct omap_aes_dev *dd) |
| 473 | { |
Joel Fernandes | 4b645c9 | 2013-08-17 21:42:25 -0500 | [diff] [blame] | 474 | int err; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 475 | |
| 476 | pr_debug("total: %d\n", dd->total); |
| 477 | |
Joel Fernandes | 98837ab | 2013-08-17 21:42:30 -0500 | [diff] [blame] | 478 | if (!dd->pio_only) { |
| 479 | err = dma_map_sg(dd->dev, dd->in_sg, dd->in_sg_len, |
| 480 | DMA_TO_DEVICE); |
| 481 | if (!err) { |
| 482 | dev_err(dd->dev, "dma_map_sg() error\n"); |
| 483 | return -EINVAL; |
| 484 | } |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 485 | |
Joel Fernandes | 98837ab | 2013-08-17 21:42:30 -0500 | [diff] [blame] | 486 | err = dma_map_sg(dd->dev, dd->out_sg, dd->out_sg_len, |
| 487 | DMA_FROM_DEVICE); |
| 488 | if (!err) { |
| 489 | dev_err(dd->dev, "dma_map_sg() error\n"); |
| 490 | return -EINVAL; |
| 491 | } |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 492 | } |
| 493 | |
Tero Kristo | 619ce70 | 2017-05-24 10:35:23 +0300 | [diff] [blame] | 494 | err = omap_aes_crypt_dma(dd, dd->in_sg, dd->out_sg, dd->in_sg_len, |
Joel Fernandes | 4b645c9 | 2013-08-17 21:42:25 -0500 | [diff] [blame] | 495 | dd->out_sg_len); |
Joel Fernandes | 98837ab | 2013-08-17 21:42:30 -0500 | [diff] [blame] | 496 | if (err && !dd->pio_only) { |
Joel Fernandes | 4b645c9 | 2013-08-17 21:42:25 -0500 | [diff] [blame] | 497 | dma_unmap_sg(dd->dev, dd->in_sg, dd->in_sg_len, DMA_TO_DEVICE); |
| 498 | dma_unmap_sg(dd->dev, dd->out_sg, dd->out_sg_len, |
| 499 | DMA_FROM_DEVICE); |
Dmitry Kasatkin | 21fe976 | 2010-11-30 10:13:29 +0200 | [diff] [blame] | 500 | } |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 501 | |
| 502 | return err; |
| 503 | } |
| 504 | |
| 505 | static void omap_aes_finish_req(struct omap_aes_dev *dd, int err) |
| 506 | { |
Dmitry Kasatkin | 21fe976 | 2010-11-30 10:13:29 +0200 | [diff] [blame] | 507 | struct ablkcipher_request *req = dd->req; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 508 | |
| 509 | pr_debug("err: %d\n", err); |
| 510 | |
Corentin LABBE | 4cba7cf | 2016-08-31 14:02:58 +0200 | [diff] [blame] | 511 | crypto_finalize_cipher_request(dd->engine, req, err); |
Tero Kristo | f303b45 | 2016-08-04 13:28:42 +0300 | [diff] [blame] | 512 | |
| 513 | pm_runtime_mark_last_busy(dd->dev); |
| 514 | pm_runtime_put_autosuspend(dd->dev); |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 515 | } |
| 516 | |
| 517 | static int omap_aes_crypt_dma_stop(struct omap_aes_dev *dd) |
| 518 | { |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 519 | pr_debug("total: %d\n", dd->total); |
| 520 | |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 521 | omap_aes_dma_stop(dd); |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 522 | |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 523 | |
Rahul Pathak | 16f080a | 2015-12-14 08:45:23 +0000 | [diff] [blame] | 524 | return 0; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 525 | } |
| 526 | |
Dmitry Kasatkin | 21fe976 | 2010-11-30 10:13:29 +0200 | [diff] [blame] | 527 | static int omap_aes_handle_queue(struct omap_aes_dev *dd, |
Baolin Wang | 0529900 | 2016-01-26 20:25:40 +0800 | [diff] [blame] | 528 | struct ablkcipher_request *req) |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 529 | { |
Dmitry Kasatkin | eeb2b20 | 2010-11-30 10:13:28 +0200 | [diff] [blame] | 530 | if (req) |
Corentin LABBE | 4cba7cf | 2016-08-31 14:02:58 +0200 | [diff] [blame] | 531 | return crypto_transfer_cipher_request_to_engine(dd->engine, req); |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 532 | |
Baolin Wang | 0529900 | 2016-01-26 20:25:40 +0800 | [diff] [blame] | 533 | return 0; |
| 534 | } |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 535 | |
Baolin Wang | 0529900 | 2016-01-26 20:25:40 +0800 | [diff] [blame] | 536 | static int omap_aes_prepare_req(struct crypto_engine *engine, |
| 537 | struct ablkcipher_request *req) |
| 538 | { |
| 539 | struct omap_aes_ctx *ctx = crypto_ablkcipher_ctx( |
| 540 | crypto_ablkcipher_reqtfm(req)); |
Tero Kristo | 619ce70 | 2017-05-24 10:35:23 +0300 | [diff] [blame] | 541 | struct omap_aes_reqctx *rctx = ablkcipher_request_ctx(req); |
| 542 | struct omap_aes_dev *dd = rctx->dd; |
Tero Kristo | afc2dc1 | 2017-05-24 10:35:28 +0300 | [diff] [blame^] | 543 | int ret; |
| 544 | u16 flags; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 545 | |
Baolin Wang | 0529900 | 2016-01-26 20:25:40 +0800 | [diff] [blame] | 546 | if (!dd) |
| 547 | return -ENODEV; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 548 | |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 549 | /* assign new request to device */ |
| 550 | dd->req = req; |
| 551 | dd->total = req->nbytes; |
Joel Fernandes | 6242332 | 2013-08-17 21:42:32 -0500 | [diff] [blame] | 552 | dd->total_save = req->nbytes; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 553 | dd->in_sg = req->src; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 554 | dd->out_sg = req->dst; |
Tero Kristo | afc2dc1 | 2017-05-24 10:35:28 +0300 | [diff] [blame^] | 555 | dd->orig_out = req->dst; |
| 556 | |
| 557 | flags = OMAP_CRYPTO_COPY_DATA; |
| 558 | if (req->src == req->dst) |
| 559 | flags |= OMAP_CRYPTO_FORCE_COPY; |
| 560 | |
| 561 | ret = omap_crypto_align_sg(&dd->in_sg, dd->total, AES_BLOCK_SIZE, |
| 562 | &dd->in_sgl, flags, |
| 563 | FLAGS_IN_DATA_ST_SHIFT, &dd->flags); |
| 564 | if (ret) |
| 565 | return ret; |
| 566 | |
| 567 | ret = omap_crypto_align_sg(&dd->out_sg, dd->total, AES_BLOCK_SIZE, |
| 568 | &dd->out_sgl, 0, |
| 569 | FLAGS_OUT_DATA_ST_SHIFT, &dd->flags); |
| 570 | if (ret) |
| 571 | return ret; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 572 | |
Herbert Xu | 7c001a8 | 2016-07-12 13:17:52 +0800 | [diff] [blame] | 573 | dd->in_sg_len = sg_nents_for_len(dd->in_sg, dd->total); |
| 574 | if (dd->in_sg_len < 0) |
| 575 | return dd->in_sg_len; |
| 576 | |
| 577 | dd->out_sg_len = sg_nents_for_len(dd->out_sg, dd->total); |
| 578 | if (dd->out_sg_len < 0) |
| 579 | return dd->out_sg_len; |
| 580 | |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 581 | rctx->mode &= FLAGS_MODE_MASK; |
| 582 | dd->flags = (dd->flags & ~FLAGS_MODE_MASK) | rctx->mode; |
| 583 | |
Dmitry Kasatkin | 67a730c | 2010-11-30 10:13:30 +0200 | [diff] [blame] | 584 | dd->ctx = ctx; |
Tero Kristo | 619ce70 | 2017-05-24 10:35:23 +0300 | [diff] [blame] | 585 | rctx->dd = dd; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 586 | |
Baolin Wang | 0529900 | 2016-01-26 20:25:40 +0800 | [diff] [blame] | 587 | return omap_aes_write_ctrl(dd); |
| 588 | } |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 589 | |
Baolin Wang | 0529900 | 2016-01-26 20:25:40 +0800 | [diff] [blame] | 590 | static int omap_aes_crypt_req(struct crypto_engine *engine, |
| 591 | struct ablkcipher_request *req) |
| 592 | { |
Tero Kristo | 619ce70 | 2017-05-24 10:35:23 +0300 | [diff] [blame] | 593 | struct omap_aes_reqctx *rctx = ablkcipher_request_ctx(req); |
| 594 | struct omap_aes_dev *dd = rctx->dd; |
Baolin Wang | 0529900 | 2016-01-26 20:25:40 +0800 | [diff] [blame] | 595 | |
| 596 | if (!dd) |
| 597 | return -ENODEV; |
| 598 | |
| 599 | return omap_aes_crypt_dma_start(dd); |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 600 | } |
| 601 | |
Dmitry Kasatkin | 21fe976 | 2010-11-30 10:13:29 +0200 | [diff] [blame] | 602 | static void omap_aes_done_task(unsigned long data) |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 603 | { |
| 604 | struct omap_aes_dev *dd = (struct omap_aes_dev *)data; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 605 | |
Joel Fernandes | 4b645c9 | 2013-08-17 21:42:25 -0500 | [diff] [blame] | 606 | pr_debug("enter done_task\n"); |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 607 | |
Joel Fernandes | 98837ab | 2013-08-17 21:42:30 -0500 | [diff] [blame] | 608 | if (!dd->pio_only) { |
| 609 | dma_sync_sg_for_device(dd->dev, dd->out_sg, dd->out_sg_len, |
| 610 | DMA_FROM_DEVICE); |
Joel Fernandes | 6242332 | 2013-08-17 21:42:32 -0500 | [diff] [blame] | 611 | dma_unmap_sg(dd->dev, dd->in_sg, dd->in_sg_len, DMA_TO_DEVICE); |
| 612 | dma_unmap_sg(dd->dev, dd->out_sg, dd->out_sg_len, |
| 613 | DMA_FROM_DEVICE); |
Joel Fernandes | 98837ab | 2013-08-17 21:42:30 -0500 | [diff] [blame] | 614 | omap_aes_crypt_dma_stop(dd); |
| 615 | } |
Joel Fernandes | 6242332 | 2013-08-17 21:42:32 -0500 | [diff] [blame] | 616 | |
Tero Kristo | afc2dc1 | 2017-05-24 10:35:28 +0300 | [diff] [blame^] | 617 | omap_crypto_cleanup(&dd->in_sgl, NULL, 0, dd->total_save, |
| 618 | FLAGS_IN_DATA_ST_SHIFT, dd->flags); |
Joel Fernandes | 6242332 | 2013-08-17 21:42:32 -0500 | [diff] [blame] | 619 | |
Tero Kristo | afc2dc1 | 2017-05-24 10:35:28 +0300 | [diff] [blame^] | 620 | omap_crypto_cleanup(&dd->out_sgl, dd->orig_out, 0, dd->total_save, |
| 621 | FLAGS_OUT_DATA_ST_SHIFT, dd->flags); |
Joel Fernandes | 6242332 | 2013-08-17 21:42:32 -0500 | [diff] [blame] | 622 | |
Joel Fernandes | 4b645c9 | 2013-08-17 21:42:25 -0500 | [diff] [blame] | 623 | omap_aes_finish_req(dd, 0); |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 624 | |
| 625 | pr_debug("exit\n"); |
| 626 | } |
| 627 | |
| 628 | static int omap_aes_crypt(struct ablkcipher_request *req, unsigned long mode) |
| 629 | { |
| 630 | struct omap_aes_ctx *ctx = crypto_ablkcipher_ctx( |
| 631 | crypto_ablkcipher_reqtfm(req)); |
| 632 | struct omap_aes_reqctx *rctx = ablkcipher_request_ctx(req); |
| 633 | struct omap_aes_dev *dd; |
Lokesh Vutla | 9fcb191 | 2016-08-04 13:28:44 +0300 | [diff] [blame] | 634 | int ret; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 635 | |
| 636 | pr_debug("nbytes: %d, enc: %d, cbc: %d\n", req->nbytes, |
| 637 | !!(mode & FLAGS_ENCRYPT), |
| 638 | !!(mode & FLAGS_CBC)); |
| 639 | |
Lokesh Vutla | 9fcb191 | 2016-08-04 13:28:44 +0300 | [diff] [blame] | 640 | if (req->nbytes < 200) { |
| 641 | SKCIPHER_REQUEST_ON_STACK(subreq, ctx->fallback); |
| 642 | |
| 643 | skcipher_request_set_tfm(subreq, ctx->fallback); |
| 644 | skcipher_request_set_callback(subreq, req->base.flags, NULL, |
| 645 | NULL); |
| 646 | skcipher_request_set_crypt(subreq, req->src, req->dst, |
| 647 | req->nbytes, req->info); |
| 648 | |
| 649 | if (mode & FLAGS_ENCRYPT) |
| 650 | ret = crypto_skcipher_encrypt(subreq); |
| 651 | else |
| 652 | ret = crypto_skcipher_decrypt(subreq); |
| 653 | |
| 654 | skcipher_request_zero(subreq); |
| 655 | return ret; |
| 656 | } |
Tero Kristo | 619ce70 | 2017-05-24 10:35:23 +0300 | [diff] [blame] | 657 | dd = omap_aes_find_dev(rctx); |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 658 | if (!dd) |
| 659 | return -ENODEV; |
| 660 | |
| 661 | rctx->mode = mode; |
| 662 | |
Dmitry Kasatkin | 21fe976 | 2010-11-30 10:13:29 +0200 | [diff] [blame] | 663 | return omap_aes_handle_queue(dd, req); |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 664 | } |
| 665 | |
| 666 | /* ********************** ALG API ************************************ */ |
| 667 | |
| 668 | static int omap_aes_setkey(struct crypto_ablkcipher *tfm, const u8 *key, |
| 669 | unsigned int keylen) |
| 670 | { |
| 671 | struct omap_aes_ctx *ctx = crypto_ablkcipher_ctx(tfm); |
Lokesh Vutla | 9fcb191 | 2016-08-04 13:28:44 +0300 | [diff] [blame] | 672 | int ret; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 673 | |
| 674 | if (keylen != AES_KEYSIZE_128 && keylen != AES_KEYSIZE_192 && |
| 675 | keylen != AES_KEYSIZE_256) |
| 676 | return -EINVAL; |
| 677 | |
| 678 | pr_debug("enter, keylen: %d\n", keylen); |
| 679 | |
| 680 | memcpy(ctx->key, key, keylen); |
| 681 | ctx->keylen = keylen; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 682 | |
Lokesh Vutla | 9fcb191 | 2016-08-04 13:28:44 +0300 | [diff] [blame] | 683 | crypto_skcipher_clear_flags(ctx->fallback, CRYPTO_TFM_REQ_MASK); |
| 684 | crypto_skcipher_set_flags(ctx->fallback, tfm->base.crt_flags & |
| 685 | CRYPTO_TFM_REQ_MASK); |
| 686 | |
| 687 | ret = crypto_skcipher_setkey(ctx->fallback, key, keylen); |
| 688 | if (!ret) |
| 689 | return 0; |
| 690 | |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 691 | return 0; |
| 692 | } |
| 693 | |
| 694 | static int omap_aes_ecb_encrypt(struct ablkcipher_request *req) |
| 695 | { |
| 696 | return omap_aes_crypt(req, FLAGS_ENCRYPT); |
| 697 | } |
| 698 | |
| 699 | static int omap_aes_ecb_decrypt(struct ablkcipher_request *req) |
| 700 | { |
| 701 | return omap_aes_crypt(req, 0); |
| 702 | } |
| 703 | |
| 704 | static int omap_aes_cbc_encrypt(struct ablkcipher_request *req) |
| 705 | { |
| 706 | return omap_aes_crypt(req, FLAGS_ENCRYPT | FLAGS_CBC); |
| 707 | } |
| 708 | |
| 709 | static int omap_aes_cbc_decrypt(struct ablkcipher_request *req) |
| 710 | { |
| 711 | return omap_aes_crypt(req, FLAGS_CBC); |
| 712 | } |
| 713 | |
Mark A. Greer | f9fb69e | 2013-01-08 11:57:47 -0700 | [diff] [blame] | 714 | static int omap_aes_ctr_encrypt(struct ablkcipher_request *req) |
| 715 | { |
| 716 | return omap_aes_crypt(req, FLAGS_ENCRYPT | FLAGS_CTR); |
| 717 | } |
| 718 | |
| 719 | static int omap_aes_ctr_decrypt(struct ablkcipher_request *req) |
| 720 | { |
| 721 | return omap_aes_crypt(req, FLAGS_CTR); |
| 722 | } |
| 723 | |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 724 | static int omap_aes_cra_init(struct crypto_tfm *tfm) |
| 725 | { |
Lokesh Vutla | 9fcb191 | 2016-08-04 13:28:44 +0300 | [diff] [blame] | 726 | const char *name = crypto_tfm_alg_name(tfm); |
| 727 | const u32 flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK; |
| 728 | struct omap_aes_ctx *ctx = crypto_tfm_ctx(tfm); |
| 729 | struct crypto_skcipher *blk; |
| 730 | |
| 731 | blk = crypto_alloc_skcipher(name, 0, flags); |
| 732 | if (IS_ERR(blk)) |
| 733 | return PTR_ERR(blk); |
| 734 | |
| 735 | ctx->fallback = blk; |
| 736 | |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 737 | tfm->crt_ablkcipher.reqsize = sizeof(struct omap_aes_reqctx); |
| 738 | |
| 739 | return 0; |
| 740 | } |
| 741 | |
| 742 | static void omap_aes_cra_exit(struct crypto_tfm *tfm) |
| 743 | { |
Lokesh Vutla | 9fcb191 | 2016-08-04 13:28:44 +0300 | [diff] [blame] | 744 | struct omap_aes_ctx *ctx = crypto_tfm_ctx(tfm); |
| 745 | |
| 746 | if (ctx->fallback) |
| 747 | crypto_free_skcipher(ctx->fallback); |
| 748 | |
| 749 | ctx->fallback = NULL; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 750 | } |
| 751 | |
| 752 | /* ********************** ALGS ************************************ */ |
| 753 | |
Mark A. Greer | f9fb69e | 2013-01-08 11:57:47 -0700 | [diff] [blame] | 754 | static struct crypto_alg algs_ecb_cbc[] = { |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 755 | { |
| 756 | .cra_name = "ecb(aes)", |
| 757 | .cra_driver_name = "ecb-aes-omap", |
Vutla, Lokesh | 6e2e3d1 | 2015-07-07 21:01:44 +0530 | [diff] [blame] | 758 | .cra_priority = 300, |
Nikos Mavrogiannopoulos | d912bb7 | 2011-11-01 13:39:56 +0100 | [diff] [blame] | 759 | .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | |
| 760 | CRYPTO_ALG_KERN_DRIVER_ONLY | |
Lokesh Vutla | 9fcb191 | 2016-08-04 13:28:44 +0300 | [diff] [blame] | 761 | CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK, |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 762 | .cra_blocksize = AES_BLOCK_SIZE, |
| 763 | .cra_ctxsize = sizeof(struct omap_aes_ctx), |
Dmitry Kasatkin | efce41b | 2010-11-30 10:13:32 +0200 | [diff] [blame] | 764 | .cra_alignmask = 0, |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 765 | .cra_type = &crypto_ablkcipher_type, |
| 766 | .cra_module = THIS_MODULE, |
| 767 | .cra_init = omap_aes_cra_init, |
| 768 | .cra_exit = omap_aes_cra_exit, |
| 769 | .cra_u.ablkcipher = { |
| 770 | .min_keysize = AES_MIN_KEY_SIZE, |
| 771 | .max_keysize = AES_MAX_KEY_SIZE, |
| 772 | .setkey = omap_aes_setkey, |
| 773 | .encrypt = omap_aes_ecb_encrypt, |
| 774 | .decrypt = omap_aes_ecb_decrypt, |
| 775 | } |
| 776 | }, |
| 777 | { |
| 778 | .cra_name = "cbc(aes)", |
| 779 | .cra_driver_name = "cbc-aes-omap", |
Vutla, Lokesh | 6e2e3d1 | 2015-07-07 21:01:44 +0530 | [diff] [blame] | 780 | .cra_priority = 300, |
Nikos Mavrogiannopoulos | d912bb7 | 2011-11-01 13:39:56 +0100 | [diff] [blame] | 781 | .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | |
| 782 | CRYPTO_ALG_KERN_DRIVER_ONLY | |
Lokesh Vutla | 9fcb191 | 2016-08-04 13:28:44 +0300 | [diff] [blame] | 783 | CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK, |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 784 | .cra_blocksize = AES_BLOCK_SIZE, |
| 785 | .cra_ctxsize = sizeof(struct omap_aes_ctx), |
Dmitry Kasatkin | efce41b | 2010-11-30 10:13:32 +0200 | [diff] [blame] | 786 | .cra_alignmask = 0, |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 787 | .cra_type = &crypto_ablkcipher_type, |
| 788 | .cra_module = THIS_MODULE, |
| 789 | .cra_init = omap_aes_cra_init, |
| 790 | .cra_exit = omap_aes_cra_exit, |
| 791 | .cra_u.ablkcipher = { |
| 792 | .min_keysize = AES_MIN_KEY_SIZE, |
| 793 | .max_keysize = AES_MAX_KEY_SIZE, |
| 794 | .ivsize = AES_BLOCK_SIZE, |
| 795 | .setkey = omap_aes_setkey, |
| 796 | .encrypt = omap_aes_cbc_encrypt, |
| 797 | .decrypt = omap_aes_cbc_decrypt, |
| 798 | } |
| 799 | } |
| 800 | }; |
| 801 | |
Mark A. Greer | f9fb69e | 2013-01-08 11:57:47 -0700 | [diff] [blame] | 802 | static struct crypto_alg algs_ctr[] = { |
| 803 | { |
| 804 | .cra_name = "ctr(aes)", |
| 805 | .cra_driver_name = "ctr-aes-omap", |
Vutla, Lokesh | 6e2e3d1 | 2015-07-07 21:01:44 +0530 | [diff] [blame] | 806 | .cra_priority = 300, |
Mark A. Greer | f9fb69e | 2013-01-08 11:57:47 -0700 | [diff] [blame] | 807 | .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | |
| 808 | CRYPTO_ALG_KERN_DRIVER_ONLY | |
Lokesh Vutla | 9fcb191 | 2016-08-04 13:28:44 +0300 | [diff] [blame] | 809 | CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK, |
Mark A. Greer | f9fb69e | 2013-01-08 11:57:47 -0700 | [diff] [blame] | 810 | .cra_blocksize = AES_BLOCK_SIZE, |
| 811 | .cra_ctxsize = sizeof(struct omap_aes_ctx), |
| 812 | .cra_alignmask = 0, |
| 813 | .cra_type = &crypto_ablkcipher_type, |
| 814 | .cra_module = THIS_MODULE, |
| 815 | .cra_init = omap_aes_cra_init, |
| 816 | .cra_exit = omap_aes_cra_exit, |
| 817 | .cra_u.ablkcipher = { |
| 818 | .min_keysize = AES_MIN_KEY_SIZE, |
| 819 | .max_keysize = AES_MAX_KEY_SIZE, |
| 820 | .geniv = "eseqiv", |
| 821 | .ivsize = AES_BLOCK_SIZE, |
| 822 | .setkey = omap_aes_setkey, |
| 823 | .encrypt = omap_aes_ctr_encrypt, |
| 824 | .decrypt = omap_aes_ctr_decrypt, |
| 825 | } |
| 826 | } , |
| 827 | }; |
| 828 | |
| 829 | static struct omap_aes_algs_info omap_aes_algs_info_ecb_cbc[] = { |
| 830 | { |
| 831 | .algs_list = algs_ecb_cbc, |
| 832 | .size = ARRAY_SIZE(algs_ecb_cbc), |
| 833 | }, |
| 834 | }; |
| 835 | |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 836 | static const struct omap_aes_pdata omap_aes_pdata_omap2 = { |
Mark A. Greer | f9fb69e | 2013-01-08 11:57:47 -0700 | [diff] [blame] | 837 | .algs_info = omap_aes_algs_info_ecb_cbc, |
| 838 | .algs_info_size = ARRAY_SIZE(omap_aes_algs_info_ecb_cbc), |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 839 | .trigger = omap_aes_dma_trigger_omap2, |
| 840 | .key_ofs = 0x1c, |
| 841 | .iv_ofs = 0x20, |
| 842 | .ctrl_ofs = 0x30, |
| 843 | .data_ofs = 0x34, |
| 844 | .rev_ofs = 0x44, |
| 845 | .mask_ofs = 0x48, |
| 846 | .dma_enable_in = BIT(2), |
| 847 | .dma_enable_out = BIT(3), |
| 848 | .dma_start = BIT(5), |
| 849 | .major_mask = 0xf0, |
| 850 | .major_shift = 4, |
| 851 | .minor_mask = 0x0f, |
| 852 | .minor_shift = 0, |
| 853 | }; |
| 854 | |
Mark A. Greer | bc69d12 | 2013-01-08 11:57:44 -0700 | [diff] [blame] | 855 | #ifdef CONFIG_OF |
Mark A. Greer | f9fb69e | 2013-01-08 11:57:47 -0700 | [diff] [blame] | 856 | static struct omap_aes_algs_info omap_aes_algs_info_ecb_cbc_ctr[] = { |
| 857 | { |
| 858 | .algs_list = algs_ecb_cbc, |
| 859 | .size = ARRAY_SIZE(algs_ecb_cbc), |
| 860 | }, |
| 861 | { |
| 862 | .algs_list = algs_ctr, |
| 863 | .size = ARRAY_SIZE(algs_ctr), |
| 864 | }, |
| 865 | }; |
| 866 | |
| 867 | static const struct omap_aes_pdata omap_aes_pdata_omap3 = { |
| 868 | .algs_info = omap_aes_algs_info_ecb_cbc_ctr, |
| 869 | .algs_info_size = ARRAY_SIZE(omap_aes_algs_info_ecb_cbc_ctr), |
| 870 | .trigger = omap_aes_dma_trigger_omap2, |
| 871 | .key_ofs = 0x1c, |
| 872 | .iv_ofs = 0x20, |
| 873 | .ctrl_ofs = 0x30, |
| 874 | .data_ofs = 0x34, |
| 875 | .rev_ofs = 0x44, |
| 876 | .mask_ofs = 0x48, |
| 877 | .dma_enable_in = BIT(2), |
| 878 | .dma_enable_out = BIT(3), |
| 879 | .dma_start = BIT(5), |
| 880 | .major_mask = 0xf0, |
| 881 | .major_shift = 4, |
| 882 | .minor_mask = 0x0f, |
| 883 | .minor_shift = 0, |
| 884 | }; |
| 885 | |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 886 | static const struct omap_aes_pdata omap_aes_pdata_omap4 = { |
Mark A. Greer | f9fb69e | 2013-01-08 11:57:47 -0700 | [diff] [blame] | 887 | .algs_info = omap_aes_algs_info_ecb_cbc_ctr, |
| 888 | .algs_info_size = ARRAY_SIZE(omap_aes_algs_info_ecb_cbc_ctr), |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 889 | .trigger = omap_aes_dma_trigger_omap4, |
| 890 | .key_ofs = 0x3c, |
| 891 | .iv_ofs = 0x40, |
| 892 | .ctrl_ofs = 0x50, |
| 893 | .data_ofs = 0x60, |
| 894 | .rev_ofs = 0x80, |
| 895 | .mask_ofs = 0x84, |
Joel Fernandes | 6721675 | 2013-08-17 21:42:28 -0500 | [diff] [blame] | 896 | .irq_status_ofs = 0x8c, |
| 897 | .irq_enable_ofs = 0x90, |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 898 | .dma_enable_in = BIT(5), |
| 899 | .dma_enable_out = BIT(6), |
| 900 | .major_mask = 0x0700, |
| 901 | .major_shift = 8, |
| 902 | .minor_mask = 0x003f, |
| 903 | .minor_shift = 0, |
| 904 | }; |
| 905 | |
Joel Fernandes | 1bf95cc | 2013-08-17 21:42:29 -0500 | [diff] [blame] | 906 | static irqreturn_t omap_aes_irq(int irq, void *dev_id) |
| 907 | { |
| 908 | struct omap_aes_dev *dd = dev_id; |
| 909 | u32 status, i; |
| 910 | u32 *src, *dst; |
| 911 | |
| 912 | status = omap_aes_read(dd, AES_REG_IRQ_STATUS(dd)); |
| 913 | if (status & AES_REG_IRQ_DATA_IN) { |
| 914 | omap_aes_write(dd, AES_REG_IRQ_ENABLE(dd), 0x0); |
| 915 | |
| 916 | BUG_ON(!dd->in_sg); |
| 917 | |
| 918 | BUG_ON(_calc_walked(in) > dd->in_sg->length); |
| 919 | |
| 920 | src = sg_virt(dd->in_sg) + _calc_walked(in); |
| 921 | |
| 922 | for (i = 0; i < AES_BLOCK_WORDS; i++) { |
| 923 | omap_aes_write(dd, AES_REG_DATA_N(dd, i), *src); |
| 924 | |
| 925 | scatterwalk_advance(&dd->in_walk, 4); |
| 926 | if (dd->in_sg->length == _calc_walked(in)) { |
Cristian Stoica | 5be4d4c | 2015-01-20 10:06:16 +0200 | [diff] [blame] | 927 | dd->in_sg = sg_next(dd->in_sg); |
Joel Fernandes | 1bf95cc | 2013-08-17 21:42:29 -0500 | [diff] [blame] | 928 | if (dd->in_sg) { |
| 929 | scatterwalk_start(&dd->in_walk, |
| 930 | dd->in_sg); |
| 931 | src = sg_virt(dd->in_sg) + |
| 932 | _calc_walked(in); |
| 933 | } |
| 934 | } else { |
| 935 | src++; |
| 936 | } |
| 937 | } |
| 938 | |
| 939 | /* Clear IRQ status */ |
| 940 | status &= ~AES_REG_IRQ_DATA_IN; |
| 941 | omap_aes_write(dd, AES_REG_IRQ_STATUS(dd), status); |
| 942 | |
| 943 | /* Enable DATA_OUT interrupt */ |
| 944 | omap_aes_write(dd, AES_REG_IRQ_ENABLE(dd), 0x4); |
| 945 | |
| 946 | } else if (status & AES_REG_IRQ_DATA_OUT) { |
| 947 | omap_aes_write(dd, AES_REG_IRQ_ENABLE(dd), 0x0); |
| 948 | |
| 949 | BUG_ON(!dd->out_sg); |
| 950 | |
| 951 | BUG_ON(_calc_walked(out) > dd->out_sg->length); |
| 952 | |
| 953 | dst = sg_virt(dd->out_sg) + _calc_walked(out); |
| 954 | |
| 955 | for (i = 0; i < AES_BLOCK_WORDS; i++) { |
| 956 | *dst = omap_aes_read(dd, AES_REG_DATA_N(dd, i)); |
| 957 | scatterwalk_advance(&dd->out_walk, 4); |
| 958 | if (dd->out_sg->length == _calc_walked(out)) { |
Cristian Stoica | 5be4d4c | 2015-01-20 10:06:16 +0200 | [diff] [blame] | 959 | dd->out_sg = sg_next(dd->out_sg); |
Joel Fernandes | 1bf95cc | 2013-08-17 21:42:29 -0500 | [diff] [blame] | 960 | if (dd->out_sg) { |
| 961 | scatterwalk_start(&dd->out_walk, |
| 962 | dd->out_sg); |
| 963 | dst = sg_virt(dd->out_sg) + |
| 964 | _calc_walked(out); |
| 965 | } |
| 966 | } else { |
| 967 | dst++; |
| 968 | } |
| 969 | } |
| 970 | |
Vutla, Lokesh | 310b0d5 | 2015-07-07 21:01:43 +0530 | [diff] [blame] | 971 | dd->total -= min_t(size_t, AES_BLOCK_SIZE, dd->total); |
Joel Fernandes | 1bf95cc | 2013-08-17 21:42:29 -0500 | [diff] [blame] | 972 | |
| 973 | /* Clear IRQ status */ |
| 974 | status &= ~AES_REG_IRQ_DATA_OUT; |
| 975 | omap_aes_write(dd, AES_REG_IRQ_STATUS(dd), status); |
| 976 | |
| 977 | if (!dd->total) |
| 978 | /* All bytes read! */ |
| 979 | tasklet_schedule(&dd->done_task); |
| 980 | else |
| 981 | /* Enable DATA_IN interrupt for next block */ |
| 982 | omap_aes_write(dd, AES_REG_IRQ_ENABLE(dd), 0x2); |
| 983 | } |
| 984 | |
| 985 | return IRQ_HANDLED; |
| 986 | } |
| 987 | |
Mark A. Greer | bc69d12 | 2013-01-08 11:57:44 -0700 | [diff] [blame] | 988 | static const struct of_device_id omap_aes_of_match[] = { |
| 989 | { |
| 990 | .compatible = "ti,omap2-aes", |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 991 | .data = &omap_aes_pdata_omap2, |
| 992 | }, |
| 993 | { |
Mark A. Greer | f9fb69e | 2013-01-08 11:57:47 -0700 | [diff] [blame] | 994 | .compatible = "ti,omap3-aes", |
| 995 | .data = &omap_aes_pdata_omap3, |
| 996 | }, |
| 997 | { |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 998 | .compatible = "ti,omap4-aes", |
| 999 | .data = &omap_aes_pdata_omap4, |
Mark A. Greer | bc69d12 | 2013-01-08 11:57:44 -0700 | [diff] [blame] | 1000 | }, |
| 1001 | {}, |
| 1002 | }; |
| 1003 | MODULE_DEVICE_TABLE(of, omap_aes_of_match); |
| 1004 | |
| 1005 | static int omap_aes_get_res_of(struct omap_aes_dev *dd, |
| 1006 | struct device *dev, struct resource *res) |
| 1007 | { |
| 1008 | struct device_node *node = dev->of_node; |
| 1009 | const struct of_device_id *match; |
| 1010 | int err = 0; |
| 1011 | |
| 1012 | match = of_match_device(of_match_ptr(omap_aes_of_match), dev); |
| 1013 | if (!match) { |
| 1014 | dev_err(dev, "no compatible OF match\n"); |
| 1015 | err = -EINVAL; |
| 1016 | goto err; |
| 1017 | } |
| 1018 | |
| 1019 | err = of_address_to_resource(node, 0, res); |
| 1020 | if (err < 0) { |
| 1021 | dev_err(dev, "can't translate OF node address\n"); |
| 1022 | err = -EINVAL; |
| 1023 | goto err; |
| 1024 | } |
| 1025 | |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 1026 | dd->pdata = match->data; |
| 1027 | |
Mark A. Greer | bc69d12 | 2013-01-08 11:57:44 -0700 | [diff] [blame] | 1028 | err: |
| 1029 | return err; |
| 1030 | } |
| 1031 | #else |
| 1032 | static const struct of_device_id omap_aes_of_match[] = { |
| 1033 | {}, |
| 1034 | }; |
| 1035 | |
| 1036 | static int omap_aes_get_res_of(struct omap_aes_dev *dd, |
| 1037 | struct device *dev, struct resource *res) |
| 1038 | { |
| 1039 | return -EINVAL; |
| 1040 | } |
| 1041 | #endif |
| 1042 | |
| 1043 | static int omap_aes_get_res_pdev(struct omap_aes_dev *dd, |
| 1044 | struct platform_device *pdev, struct resource *res) |
| 1045 | { |
| 1046 | struct device *dev = &pdev->dev; |
| 1047 | struct resource *r; |
| 1048 | int err = 0; |
| 1049 | |
| 1050 | /* Get the base address */ |
| 1051 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 1052 | if (!r) { |
| 1053 | dev_err(dev, "no MEM resource info\n"); |
| 1054 | err = -ENODEV; |
| 1055 | goto err; |
| 1056 | } |
| 1057 | memcpy(res, r, sizeof(*res)); |
| 1058 | |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 1059 | /* Only OMAP2/3 can be non-DT */ |
| 1060 | dd->pdata = &omap_aes_pdata_omap2; |
| 1061 | |
Mark A. Greer | bc69d12 | 2013-01-08 11:57:44 -0700 | [diff] [blame] | 1062 | err: |
| 1063 | return err; |
| 1064 | } |
| 1065 | |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 1066 | static int omap_aes_probe(struct platform_device *pdev) |
| 1067 | { |
| 1068 | struct device *dev = &pdev->dev; |
| 1069 | struct omap_aes_dev *dd; |
Mark A. Greer | f9fb69e | 2013-01-08 11:57:47 -0700 | [diff] [blame] | 1070 | struct crypto_alg *algp; |
Mark A. Greer | bc69d12 | 2013-01-08 11:57:44 -0700 | [diff] [blame] | 1071 | struct resource res; |
Joel Fernandes | 1801ad9 | 2013-08-17 21:42:31 -0500 | [diff] [blame] | 1072 | int err = -ENOMEM, i, j, irq = -1; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 1073 | u32 reg; |
| 1074 | |
Joel Fernandes | 05007c1 | 2013-08-17 21:42:33 -0500 | [diff] [blame] | 1075 | dd = devm_kzalloc(dev, sizeof(struct omap_aes_dev), GFP_KERNEL); |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 1076 | if (dd == NULL) { |
| 1077 | dev_err(dev, "unable to alloc data struct.\n"); |
| 1078 | goto err_data; |
| 1079 | } |
| 1080 | dd->dev = dev; |
| 1081 | platform_set_drvdata(pdev, dd); |
| 1082 | |
Mark A. Greer | bc69d12 | 2013-01-08 11:57:44 -0700 | [diff] [blame] | 1083 | err = (dev->of_node) ? omap_aes_get_res_of(dd, dev, &res) : |
| 1084 | omap_aes_get_res_pdev(dd, pdev, &res); |
| 1085 | if (err) |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 1086 | goto err_res; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 1087 | |
Laurent Navet | 3086228 | 2013-05-02 14:00:38 +0200 | [diff] [blame] | 1088 | dd->io_base = devm_ioremap_resource(dev, &res); |
| 1089 | if (IS_ERR(dd->io_base)) { |
| 1090 | err = PTR_ERR(dd->io_base); |
Mark A. Greer | 5946c4a | 2013-01-08 11:57:40 -0700 | [diff] [blame] | 1091 | goto err_res; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 1092 | } |
Mark A. Greer | bc69d12 | 2013-01-08 11:57:44 -0700 | [diff] [blame] | 1093 | dd->phys_base = res.start; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 1094 | |
Tero Kristo | f303b45 | 2016-08-04 13:28:42 +0300 | [diff] [blame] | 1095 | pm_runtime_use_autosuspend(dev); |
| 1096 | pm_runtime_set_autosuspend_delay(dev, DEFAULT_AUTOSUSPEND_DELAY); |
| 1097 | |
Mark A. Greer | 5946c4a | 2013-01-08 11:57:40 -0700 | [diff] [blame] | 1098 | pm_runtime_enable(dev); |
Nishanth Menon | f7b2b5d | 2013-12-03 19:43:13 -0600 | [diff] [blame] | 1099 | err = pm_runtime_get_sync(dev); |
| 1100 | if (err < 0) { |
| 1101 | dev_err(dev, "%s: failed to get_sync(%d)\n", |
| 1102 | __func__, err); |
| 1103 | goto err_res; |
| 1104 | } |
Mark A. Greer | 5946c4a | 2013-01-08 11:57:40 -0700 | [diff] [blame] | 1105 | |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 1106 | omap_aes_dma_stop(dd); |
| 1107 | |
| 1108 | reg = omap_aes_read(dd, AES_REG_REV(dd)); |
Mark A. Greer | 5946c4a | 2013-01-08 11:57:40 -0700 | [diff] [blame] | 1109 | |
| 1110 | pm_runtime_put_sync(dev); |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 1111 | |
Mark A. Greer | 0d35583 | 2013-01-08 11:57:46 -0700 | [diff] [blame] | 1112 | dev_info(dev, "OMAP AES hw accel rev: %u.%u\n", |
| 1113 | (reg & dd->pdata->major_mask) >> dd->pdata->major_shift, |
| 1114 | (reg & dd->pdata->minor_mask) >> dd->pdata->minor_shift); |
| 1115 | |
Dmitry Kasatkin | 21fe976 | 2010-11-30 10:13:29 +0200 | [diff] [blame] | 1116 | tasklet_init(&dd->done_task, omap_aes_done_task, (unsigned long)dd); |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 1117 | |
| 1118 | err = omap_aes_dma_init(dd); |
Peter Ujfalusi | da8b29a | 2016-04-29 16:02:18 +0300 | [diff] [blame] | 1119 | if (err == -EPROBE_DEFER) { |
| 1120 | goto err_irq; |
| 1121 | } else if (err && AES_REG_IRQ_STATUS(dd) && AES_REG_IRQ_ENABLE(dd)) { |
Joel Fernandes | 1801ad9 | 2013-08-17 21:42:31 -0500 | [diff] [blame] | 1122 | dd->pio_only = 1; |
| 1123 | |
| 1124 | irq = platform_get_irq(pdev, 0); |
| 1125 | if (irq < 0) { |
| 1126 | dev_err(dev, "can't get IRQ resource\n"); |
| 1127 | goto err_irq; |
| 1128 | } |
| 1129 | |
Joel Fernandes | bce2a22 | 2013-08-17 21:42:34 -0500 | [diff] [blame] | 1130 | err = devm_request_irq(dev, irq, omap_aes_irq, 0, |
Joel Fernandes | 1801ad9 | 2013-08-17 21:42:31 -0500 | [diff] [blame] | 1131 | dev_name(dev), dd); |
| 1132 | if (err) { |
| 1133 | dev_err(dev, "Unable to grab omap-aes IRQ\n"); |
| 1134 | goto err_irq; |
| 1135 | } |
| 1136 | } |
| 1137 | |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 1138 | |
| 1139 | INIT_LIST_HEAD(&dd->list); |
| 1140 | spin_lock(&list_lock); |
| 1141 | list_add_tail(&dd->list, &dev_list); |
| 1142 | spin_unlock(&list_lock); |
| 1143 | |
Tero Kristo | 0d0cda93 | 2016-08-04 13:28:45 +0300 | [diff] [blame] | 1144 | /* Initialize crypto engine */ |
| 1145 | dd->engine = crypto_engine_alloc_init(dev, 1); |
Wei Yongjun | c98ef8d | 2016-09-15 03:27:32 +0000 | [diff] [blame] | 1146 | if (!dd->engine) { |
| 1147 | err = -ENOMEM; |
Tero Kristo | 0d0cda93 | 2016-08-04 13:28:45 +0300 | [diff] [blame] | 1148 | goto err_engine; |
Wei Yongjun | c98ef8d | 2016-09-15 03:27:32 +0000 | [diff] [blame] | 1149 | } |
Tero Kristo | 0d0cda93 | 2016-08-04 13:28:45 +0300 | [diff] [blame] | 1150 | |
| 1151 | dd->engine->prepare_cipher_request = omap_aes_prepare_req; |
| 1152 | dd->engine->cipher_one_request = omap_aes_crypt_req; |
| 1153 | err = crypto_engine_start(dd->engine); |
| 1154 | if (err) |
| 1155 | goto err_engine; |
| 1156 | |
Mark A. Greer | f9fb69e | 2013-01-08 11:57:47 -0700 | [diff] [blame] | 1157 | for (i = 0; i < dd->pdata->algs_info_size; i++) { |
Lokesh Vutla | 3741bbb | 2016-06-01 11:56:02 +0300 | [diff] [blame] | 1158 | if (!dd->pdata->algs_info[i].registered) { |
| 1159 | for (j = 0; j < dd->pdata->algs_info[i].size; j++) { |
| 1160 | algp = &dd->pdata->algs_info[i].algs_list[j]; |
Mark A. Greer | f9fb69e | 2013-01-08 11:57:47 -0700 | [diff] [blame] | 1161 | |
Lokesh Vutla | 3741bbb | 2016-06-01 11:56:02 +0300 | [diff] [blame] | 1162 | pr_debug("reg alg: %s\n", algp->cra_name); |
| 1163 | INIT_LIST_HEAD(&algp->cra_list); |
Mark A. Greer | f9fb69e | 2013-01-08 11:57:47 -0700 | [diff] [blame] | 1164 | |
Lokesh Vutla | 3741bbb | 2016-06-01 11:56:02 +0300 | [diff] [blame] | 1165 | err = crypto_register_alg(algp); |
| 1166 | if (err) |
| 1167 | goto err_algs; |
Mark A. Greer | f9fb69e | 2013-01-08 11:57:47 -0700 | [diff] [blame] | 1168 | |
Lokesh Vutla | 3741bbb | 2016-06-01 11:56:02 +0300 | [diff] [blame] | 1169 | dd->pdata->algs_info[i].registered++; |
| 1170 | } |
Mark A. Greer | f9fb69e | 2013-01-08 11:57:47 -0700 | [diff] [blame] | 1171 | } |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 1172 | } |
| 1173 | |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 1174 | return 0; |
| 1175 | err_algs: |
Mark A. Greer | f9fb69e | 2013-01-08 11:57:47 -0700 | [diff] [blame] | 1176 | for (i = dd->pdata->algs_info_size - 1; i >= 0; i--) |
| 1177 | for (j = dd->pdata->algs_info[i].registered - 1; j >= 0; j--) |
| 1178 | crypto_unregister_alg( |
| 1179 | &dd->pdata->algs_info[i].algs_list[j]); |
Peter Ujfalusi | da8b29a | 2016-04-29 16:02:18 +0300 | [diff] [blame] | 1180 | |
Tero Kristo | 0d0cda93 | 2016-08-04 13:28:45 +0300 | [diff] [blame] | 1181 | err_engine: |
| 1182 | if (dd->engine) |
| 1183 | crypto_engine_exit(dd->engine); |
| 1184 | |
Peter Ujfalusi | da8b29a | 2016-04-29 16:02:18 +0300 | [diff] [blame] | 1185 | omap_aes_dma_cleanup(dd); |
Joel Fernandes | 1801ad9 | 2013-08-17 21:42:31 -0500 | [diff] [blame] | 1186 | err_irq: |
Dmitry Kasatkin | 21fe976 | 2010-11-30 10:13:29 +0200 | [diff] [blame] | 1187 | tasklet_kill(&dd->done_task); |
Mark A. Greer | 5946c4a | 2013-01-08 11:57:40 -0700 | [diff] [blame] | 1188 | pm_runtime_disable(dev); |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 1189 | err_res: |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 1190 | dd = NULL; |
| 1191 | err_data: |
| 1192 | dev_err(dev, "initialization failed.\n"); |
| 1193 | return err; |
| 1194 | } |
| 1195 | |
| 1196 | static int omap_aes_remove(struct platform_device *pdev) |
| 1197 | { |
| 1198 | struct omap_aes_dev *dd = platform_get_drvdata(pdev); |
Mark A. Greer | f9fb69e | 2013-01-08 11:57:47 -0700 | [diff] [blame] | 1199 | int i, j; |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 1200 | |
| 1201 | if (!dd) |
| 1202 | return -ENODEV; |
| 1203 | |
| 1204 | spin_lock(&list_lock); |
| 1205 | list_del(&dd->list); |
| 1206 | spin_unlock(&list_lock); |
| 1207 | |
Mark A. Greer | f9fb69e | 2013-01-08 11:57:47 -0700 | [diff] [blame] | 1208 | for (i = dd->pdata->algs_info_size - 1; i >= 0; i--) |
| 1209 | for (j = dd->pdata->algs_info[i].registered - 1; j >= 0; j--) |
| 1210 | crypto_unregister_alg( |
| 1211 | &dd->pdata->algs_info[i].algs_list[j]); |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 1212 | |
Baolin Wang | 0529900 | 2016-01-26 20:25:40 +0800 | [diff] [blame] | 1213 | crypto_engine_exit(dd->engine); |
Dmitry Kasatkin | 21fe976 | 2010-11-30 10:13:29 +0200 | [diff] [blame] | 1214 | tasklet_kill(&dd->done_task); |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 1215 | omap_aes_dma_cleanup(dd); |
Mark A. Greer | 5946c4a | 2013-01-08 11:57:40 -0700 | [diff] [blame] | 1216 | pm_runtime_disable(dd->dev); |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 1217 | dd = NULL; |
| 1218 | |
| 1219 | return 0; |
| 1220 | } |
| 1221 | |
Mark A. Greer | 0635fb3 | 2013-01-08 11:57:41 -0700 | [diff] [blame] | 1222 | #ifdef CONFIG_PM_SLEEP |
| 1223 | static int omap_aes_suspend(struct device *dev) |
| 1224 | { |
| 1225 | pm_runtime_put_sync(dev); |
| 1226 | return 0; |
| 1227 | } |
| 1228 | |
| 1229 | static int omap_aes_resume(struct device *dev) |
| 1230 | { |
| 1231 | pm_runtime_get_sync(dev); |
| 1232 | return 0; |
| 1233 | } |
| 1234 | #endif |
| 1235 | |
Jingoo Han | ea7b284 | 2014-02-27 20:31:38 +0900 | [diff] [blame] | 1236 | static SIMPLE_DEV_PM_OPS(omap_aes_pm_ops, omap_aes_suspend, omap_aes_resume); |
Mark A. Greer | 0635fb3 | 2013-01-08 11:57:41 -0700 | [diff] [blame] | 1237 | |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 1238 | static struct platform_driver omap_aes_driver = { |
| 1239 | .probe = omap_aes_probe, |
| 1240 | .remove = omap_aes_remove, |
| 1241 | .driver = { |
| 1242 | .name = "omap-aes", |
Mark A. Greer | 0635fb3 | 2013-01-08 11:57:41 -0700 | [diff] [blame] | 1243 | .pm = &omap_aes_pm_ops, |
Mark A. Greer | bc69d12 | 2013-01-08 11:57:44 -0700 | [diff] [blame] | 1244 | .of_match_table = omap_aes_of_match, |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 1245 | }, |
| 1246 | }; |
| 1247 | |
Sachin Kamat | 94e51df | 2013-03-04 15:09:42 +0530 | [diff] [blame] | 1248 | module_platform_driver(omap_aes_driver); |
Dmitry Kasatkin | 537559a | 2010-09-03 19:16:02 +0800 | [diff] [blame] | 1249 | |
| 1250 | MODULE_DESCRIPTION("OMAP AES hw acceleration support."); |
| 1251 | MODULE_LICENSE("GPL v2"); |
| 1252 | MODULE_AUTHOR("Dmitry Kasatkin"); |
| 1253 | |