Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Cryptographic API. |
| 3 | * |
| 4 | * Support for OMAP SHA1/MD5 HW acceleration. |
| 5 | * |
| 6 | * Copyright (c) 2010 Nokia Corporation |
| 7 | * Author: Dmitry Kasatkin <dmitry.kasatkin@nokia.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 old omap-sha1-md5.c driver. |
| 14 | */ |
| 15 | |
| 16 | #define pr_fmt(fmt) "%s: " fmt, __func__ |
| 17 | |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 18 | #include <linux/err.h> |
| 19 | #include <linux/device.h> |
| 20 | #include <linux/module.h> |
| 21 | #include <linux/init.h> |
| 22 | #include <linux/errno.h> |
| 23 | #include <linux/interrupt.h> |
| 24 | #include <linux/kernel.h> |
| 25 | #include <linux/clk.h> |
| 26 | #include <linux/irq.h> |
| 27 | #include <linux/io.h> |
| 28 | #include <linux/platform_device.h> |
| 29 | #include <linux/scatterlist.h> |
| 30 | #include <linux/dma-mapping.h> |
| 31 | #include <linux/delay.h> |
| 32 | #include <linux/crypto.h> |
| 33 | #include <linux/cryptohash.h> |
| 34 | #include <crypto/scatterwalk.h> |
| 35 | #include <crypto/algapi.h> |
| 36 | #include <crypto/sha.h> |
| 37 | #include <crypto/hash.h> |
| 38 | #include <crypto/internal/hash.h> |
| 39 | |
| 40 | #include <plat/cpu.h> |
| 41 | #include <plat/dma.h> |
| 42 | #include <mach/irqs.h> |
| 43 | |
| 44 | #define SHA_REG_DIGEST(x) (0x00 + ((x) * 0x04)) |
| 45 | #define SHA_REG_DIN(x) (0x1C + ((x) * 0x04)) |
| 46 | |
| 47 | #define SHA1_MD5_BLOCK_SIZE SHA1_BLOCK_SIZE |
| 48 | #define MD5_DIGEST_SIZE 16 |
| 49 | |
| 50 | #define SHA_REG_DIGCNT 0x14 |
| 51 | |
| 52 | #define SHA_REG_CTRL 0x18 |
| 53 | #define SHA_REG_CTRL_LENGTH (0xFFFFFFFF << 5) |
| 54 | #define SHA_REG_CTRL_CLOSE_HASH (1 << 4) |
| 55 | #define SHA_REG_CTRL_ALGO_CONST (1 << 3) |
| 56 | #define SHA_REG_CTRL_ALGO (1 << 2) |
| 57 | #define SHA_REG_CTRL_INPUT_READY (1 << 1) |
| 58 | #define SHA_REG_CTRL_OUTPUT_READY (1 << 0) |
| 59 | |
| 60 | #define SHA_REG_REV 0x5C |
| 61 | #define SHA_REG_REV_MAJOR 0xF0 |
| 62 | #define SHA_REG_REV_MINOR 0x0F |
| 63 | |
| 64 | #define SHA_REG_MASK 0x60 |
| 65 | #define SHA_REG_MASK_DMA_EN (1 << 3) |
| 66 | #define SHA_REG_MASK_IT_EN (1 << 2) |
| 67 | #define SHA_REG_MASK_SOFTRESET (1 << 1) |
| 68 | #define SHA_REG_AUTOIDLE (1 << 0) |
| 69 | |
| 70 | #define SHA_REG_SYSSTATUS 0x64 |
| 71 | #define SHA_REG_SYSSTATUS_RESETDONE (1 << 0) |
| 72 | |
| 73 | #define DEFAULT_TIMEOUT_INTERVAL HZ |
| 74 | |
| 75 | #define FLAGS_FIRST 0x0001 |
| 76 | #define FLAGS_FINUP 0x0002 |
| 77 | #define FLAGS_FINAL 0x0004 |
| 78 | #define FLAGS_FAST 0x0008 |
| 79 | #define FLAGS_SHA1 0x0010 |
| 80 | #define FLAGS_DMA_ACTIVE 0x0020 |
| 81 | #define FLAGS_OUTPUT_READY 0x0040 |
| 82 | #define FLAGS_CLEAN 0x0080 |
| 83 | #define FLAGS_INIT 0x0100 |
| 84 | #define FLAGS_CPU 0x0200 |
| 85 | #define FLAGS_HMAC 0x0400 |
Dmitry Kasatkin | 3e133c8 | 2010-11-19 16:04:24 +0200 | [diff] [blame] | 86 | #define FLAGS_ERROR 0x0800 |
Dmitry Kasatkin | a5d8723 | 2010-11-19 16:04:25 +0200 | [diff] [blame] | 87 | #define FLAGS_BUSY 0x1000 |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 88 | |
| 89 | #define OP_UPDATE 1 |
| 90 | #define OP_FINAL 2 |
| 91 | |
Dmitry Kasatkin | 798eed5d | 2010-11-19 16:04:26 +0200 | [diff] [blame] | 92 | #define OMAP_ALIGN_MASK (sizeof(u32)-1) |
| 93 | #define OMAP_ALIGNED __attribute__((aligned(sizeof(u32)))) |
| 94 | |
| 95 | #define BUFLEN PAGE_SIZE |
| 96 | |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 97 | struct omap_sham_dev; |
| 98 | |
| 99 | struct omap_sham_reqctx { |
| 100 | struct omap_sham_dev *dd; |
| 101 | unsigned long flags; |
| 102 | unsigned long op; |
| 103 | |
Dmitry Kasatkin | 798eed5d | 2010-11-19 16:04:26 +0200 | [diff] [blame] | 104 | u8 digest[SHA1_DIGEST_SIZE] OMAP_ALIGNED; |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 105 | size_t digcnt; |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 106 | size_t bufcnt; |
| 107 | size_t buflen; |
| 108 | dma_addr_t dma_addr; |
| 109 | |
| 110 | /* walk state */ |
| 111 | struct scatterlist *sg; |
| 112 | unsigned int offset; /* offset in current sg */ |
| 113 | unsigned int total; /* total request */ |
Dmitry Kasatkin | 798eed5d | 2010-11-19 16:04:26 +0200 | [diff] [blame] | 114 | |
| 115 | u8 buffer[0] OMAP_ALIGNED; |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 116 | }; |
| 117 | |
| 118 | struct omap_sham_hmac_ctx { |
| 119 | struct crypto_shash *shash; |
| 120 | u8 ipad[SHA1_MD5_BLOCK_SIZE]; |
| 121 | u8 opad[SHA1_MD5_BLOCK_SIZE]; |
| 122 | }; |
| 123 | |
| 124 | struct omap_sham_ctx { |
| 125 | struct omap_sham_dev *dd; |
| 126 | |
| 127 | unsigned long flags; |
| 128 | |
| 129 | /* fallback stuff */ |
| 130 | struct crypto_shash *fallback; |
| 131 | |
| 132 | struct omap_sham_hmac_ctx base[0]; |
| 133 | }; |
| 134 | |
| 135 | #define OMAP_SHAM_QUEUE_LENGTH 1 |
| 136 | |
| 137 | struct omap_sham_dev { |
| 138 | struct list_head list; |
| 139 | unsigned long phys_base; |
| 140 | struct device *dev; |
| 141 | void __iomem *io_base; |
| 142 | int irq; |
| 143 | struct clk *iclk; |
| 144 | spinlock_t lock; |
Dmitry Kasatkin | 3e133c8 | 2010-11-19 16:04:24 +0200 | [diff] [blame] | 145 | int err; |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 146 | int dma; |
| 147 | int dma_lch; |
| 148 | struct tasklet_struct done_task; |
| 149 | struct tasklet_struct queue_task; |
| 150 | |
| 151 | unsigned long flags; |
| 152 | struct crypto_queue queue; |
| 153 | struct ahash_request *req; |
| 154 | }; |
| 155 | |
| 156 | struct omap_sham_drv { |
| 157 | struct list_head dev_list; |
| 158 | spinlock_t lock; |
| 159 | unsigned long flags; |
| 160 | }; |
| 161 | |
| 162 | static struct omap_sham_drv sham = { |
| 163 | .dev_list = LIST_HEAD_INIT(sham.dev_list), |
| 164 | .lock = __SPIN_LOCK_UNLOCKED(sham.lock), |
| 165 | }; |
| 166 | |
| 167 | static inline u32 omap_sham_read(struct omap_sham_dev *dd, u32 offset) |
| 168 | { |
| 169 | return __raw_readl(dd->io_base + offset); |
| 170 | } |
| 171 | |
| 172 | static inline void omap_sham_write(struct omap_sham_dev *dd, |
| 173 | u32 offset, u32 value) |
| 174 | { |
| 175 | __raw_writel(value, dd->io_base + offset); |
| 176 | } |
| 177 | |
| 178 | static inline void omap_sham_write_mask(struct omap_sham_dev *dd, u32 address, |
| 179 | u32 value, u32 mask) |
| 180 | { |
| 181 | u32 val; |
| 182 | |
| 183 | val = omap_sham_read(dd, address); |
| 184 | val &= ~mask; |
| 185 | val |= value; |
| 186 | omap_sham_write(dd, address, val); |
| 187 | } |
| 188 | |
| 189 | static inline int omap_sham_wait(struct omap_sham_dev *dd, u32 offset, u32 bit) |
| 190 | { |
| 191 | unsigned long timeout = jiffies + DEFAULT_TIMEOUT_INTERVAL; |
| 192 | |
| 193 | while (!(omap_sham_read(dd, offset) & bit)) { |
| 194 | if (time_is_before_jiffies(timeout)) |
| 195 | return -ETIMEDOUT; |
| 196 | } |
| 197 | |
| 198 | return 0; |
| 199 | } |
| 200 | |
| 201 | static void omap_sham_copy_hash(struct ahash_request *req, int out) |
| 202 | { |
| 203 | struct omap_sham_reqctx *ctx = ahash_request_ctx(req); |
Dmitry Kasatkin | 0c3cf4c | 2010-11-19 16:04:22 +0200 | [diff] [blame] | 204 | u32 *hash = (u32 *)ctx->digest; |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 205 | int i; |
| 206 | |
Dmitry Kasatkin | 3c8d758 | 2010-11-19 16:04:27 +0200 | [diff] [blame^] | 207 | /* MD5 is almost unused. So copy sha1 size to reduce code */ |
| 208 | for (i = 0; i < SHA1_DIGEST_SIZE / sizeof(u32); i++) { |
| 209 | if (out) |
| 210 | hash[i] = omap_sham_read(ctx->dd, |
| 211 | SHA_REG_DIGEST(i)); |
| 212 | else |
| 213 | omap_sham_write(ctx->dd, |
| 214 | SHA_REG_DIGEST(i), hash[i]); |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | static void omap_sham_copy_ready_hash(struct ahash_request *req) |
| 219 | { |
| 220 | struct omap_sham_reqctx *ctx = ahash_request_ctx(req); |
| 221 | u32 *in = (u32 *)ctx->digest; |
| 222 | u32 *hash = (u32 *)req->result; |
| 223 | int i; |
| 224 | |
| 225 | if (!hash) |
| 226 | return; |
| 227 | |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 228 | if (likely(ctx->flags & FLAGS_SHA1)) { |
| 229 | /* SHA1 results are in big endian */ |
| 230 | for (i = 0; i < SHA1_DIGEST_SIZE / sizeof(u32); i++) |
Dmitry Kasatkin | 3c8d758 | 2010-11-19 16:04:27 +0200 | [diff] [blame^] | 231 | hash[i] = be32_to_cpu(in[i]); |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 232 | } else { |
| 233 | /* MD5 results are in little endian */ |
| 234 | for (i = 0; i < MD5_DIGEST_SIZE / sizeof(u32); i++) |
Dmitry Kasatkin | 3c8d758 | 2010-11-19 16:04:27 +0200 | [diff] [blame^] | 235 | hash[i] = le32_to_cpu(in[i]); |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 236 | } |
| 237 | } |
| 238 | |
Dmitry Kasatkin | 798eed5d | 2010-11-19 16:04:26 +0200 | [diff] [blame] | 239 | static int omap_sham_hw_init(struct omap_sham_dev *dd) |
| 240 | { |
| 241 | clk_enable(dd->iclk); |
| 242 | |
| 243 | if (!(dd->flags & FLAGS_INIT)) { |
| 244 | omap_sham_write_mask(dd, SHA_REG_MASK, |
| 245 | SHA_REG_MASK_SOFTRESET, SHA_REG_MASK_SOFTRESET); |
| 246 | |
| 247 | if (omap_sham_wait(dd, SHA_REG_SYSSTATUS, |
| 248 | SHA_REG_SYSSTATUS_RESETDONE)) |
| 249 | return -ETIMEDOUT; |
| 250 | |
| 251 | dd->flags |= FLAGS_INIT; |
| 252 | dd->err = 0; |
| 253 | } |
| 254 | |
| 255 | return 0; |
| 256 | } |
| 257 | |
| 258 | static void omap_sham_write_ctrl(struct omap_sham_dev *dd, size_t length, |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 259 | int final, int dma) |
| 260 | { |
| 261 | struct omap_sham_reqctx *ctx = ahash_request_ctx(dd->req); |
| 262 | u32 val = length << 5, mask; |
| 263 | |
Dmitry Kasatkin | 798eed5d | 2010-11-19 16:04:26 +0200 | [diff] [blame] | 264 | if (likely(ctx->digcnt)) |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 265 | omap_sham_write(dd, SHA_REG_DIGCNT, ctx->digcnt); |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 266 | |
| 267 | omap_sham_write_mask(dd, SHA_REG_MASK, |
| 268 | SHA_REG_MASK_IT_EN | (dma ? SHA_REG_MASK_DMA_EN : 0), |
| 269 | SHA_REG_MASK_IT_EN | SHA_REG_MASK_DMA_EN); |
| 270 | /* |
| 271 | * Setting ALGO_CONST only for the first iteration |
| 272 | * and CLOSE_HASH only for the last one. |
| 273 | */ |
| 274 | if (ctx->flags & FLAGS_SHA1) |
| 275 | val |= SHA_REG_CTRL_ALGO; |
| 276 | if (!ctx->digcnt) |
| 277 | val |= SHA_REG_CTRL_ALGO_CONST; |
| 278 | if (final) |
| 279 | val |= SHA_REG_CTRL_CLOSE_HASH; |
| 280 | |
| 281 | mask = SHA_REG_CTRL_ALGO_CONST | SHA_REG_CTRL_CLOSE_HASH | |
| 282 | SHA_REG_CTRL_ALGO | SHA_REG_CTRL_LENGTH; |
| 283 | |
| 284 | omap_sham_write_mask(dd, SHA_REG_CTRL, val, mask); |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | static int omap_sham_xmit_cpu(struct omap_sham_dev *dd, const u8 *buf, |
| 288 | size_t length, int final) |
| 289 | { |
| 290 | struct omap_sham_reqctx *ctx = ahash_request_ctx(dd->req); |
Dmitry Kasatkin | 798eed5d | 2010-11-19 16:04:26 +0200 | [diff] [blame] | 291 | int count, len32; |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 292 | const u32 *buffer = (const u32 *)buf; |
| 293 | |
| 294 | dev_dbg(dd->dev, "xmit_cpu: digcnt: %d, length: %d, final: %d\n", |
| 295 | ctx->digcnt, length, final); |
| 296 | |
Dmitry Kasatkin | 798eed5d | 2010-11-19 16:04:26 +0200 | [diff] [blame] | 297 | omap_sham_write_ctrl(dd, length, final, 0); |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 298 | |
Dmitry Kasatkin | 3e133c8 | 2010-11-19 16:04:24 +0200 | [diff] [blame] | 299 | /* should be non-zero before next lines to disable clocks later */ |
| 300 | ctx->digcnt += length; |
| 301 | |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 302 | if (omap_sham_wait(dd, SHA_REG_CTRL, SHA_REG_CTRL_INPUT_READY)) |
| 303 | return -ETIMEDOUT; |
| 304 | |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 305 | if (final) |
| 306 | ctx->flags |= FLAGS_FINAL; /* catch last interrupt */ |
| 307 | |
| 308 | len32 = DIV_ROUND_UP(length, sizeof(u32)); |
| 309 | |
| 310 | for (count = 0; count < len32; count++) |
| 311 | omap_sham_write(dd, SHA_REG_DIN(count), buffer[count]); |
| 312 | |
| 313 | return -EINPROGRESS; |
| 314 | } |
| 315 | |
| 316 | static int omap_sham_xmit_dma(struct omap_sham_dev *dd, dma_addr_t dma_addr, |
| 317 | size_t length, int final) |
| 318 | { |
| 319 | struct omap_sham_reqctx *ctx = ahash_request_ctx(dd->req); |
Dmitry Kasatkin | 798eed5d | 2010-11-19 16:04:26 +0200 | [diff] [blame] | 320 | int len32; |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 321 | |
| 322 | dev_dbg(dd->dev, "xmit_dma: digcnt: %d, length: %d, final: %d\n", |
| 323 | ctx->digcnt, length, final); |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 324 | |
| 325 | len32 = DIV_ROUND_UP(length, sizeof(u32)); |
| 326 | |
| 327 | omap_set_dma_transfer_params(dd->dma_lch, OMAP_DMA_DATA_TYPE_S32, len32, |
Samu Onkalo | 584db6a | 2010-09-03 19:20:19 +0800 | [diff] [blame] | 328 | 1, OMAP_DMA_SYNC_PACKET, dd->dma, |
| 329 | OMAP_DMA_DST_SYNC_PREFETCH); |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 330 | |
| 331 | omap_set_dma_src_params(dd->dma_lch, 0, OMAP_DMA_AMODE_POST_INC, |
| 332 | dma_addr, 0, 0); |
| 333 | |
Dmitry Kasatkin | 798eed5d | 2010-11-19 16:04:26 +0200 | [diff] [blame] | 334 | omap_sham_write_ctrl(dd, length, final, 1); |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 335 | |
| 336 | ctx->digcnt += length; |
| 337 | |
| 338 | if (final) |
| 339 | ctx->flags |= FLAGS_FINAL; /* catch last interrupt */ |
| 340 | |
| 341 | dd->flags |= FLAGS_DMA_ACTIVE; |
| 342 | |
| 343 | omap_start_dma(dd->dma_lch); |
| 344 | |
| 345 | return -EINPROGRESS; |
| 346 | } |
| 347 | |
| 348 | static size_t omap_sham_append_buffer(struct omap_sham_reqctx *ctx, |
| 349 | const u8 *data, size_t length) |
| 350 | { |
| 351 | size_t count = min(length, ctx->buflen - ctx->bufcnt); |
| 352 | |
| 353 | count = min(count, ctx->total); |
| 354 | if (count <= 0) |
| 355 | return 0; |
| 356 | memcpy(ctx->buffer + ctx->bufcnt, data, count); |
| 357 | ctx->bufcnt += count; |
| 358 | |
| 359 | return count; |
| 360 | } |
| 361 | |
| 362 | static size_t omap_sham_append_sg(struct omap_sham_reqctx *ctx) |
| 363 | { |
| 364 | size_t count; |
| 365 | |
| 366 | while (ctx->sg) { |
| 367 | count = omap_sham_append_buffer(ctx, |
| 368 | sg_virt(ctx->sg) + ctx->offset, |
| 369 | ctx->sg->length - ctx->offset); |
| 370 | if (!count) |
| 371 | break; |
| 372 | ctx->offset += count; |
| 373 | ctx->total -= count; |
| 374 | if (ctx->offset == ctx->sg->length) { |
| 375 | ctx->sg = sg_next(ctx->sg); |
| 376 | if (ctx->sg) |
| 377 | ctx->offset = 0; |
| 378 | else |
| 379 | ctx->total = 0; |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | return 0; |
| 384 | } |
| 385 | |
Dmitry Kasatkin | 798eed5d | 2010-11-19 16:04:26 +0200 | [diff] [blame] | 386 | static int omap_sham_xmit_dma_map(struct omap_sham_dev *dd, |
| 387 | struct omap_sham_reqctx *ctx, |
| 388 | size_t length, int final) |
| 389 | { |
| 390 | ctx->dma_addr = dma_map_single(dd->dev, ctx->buffer, ctx->buflen, |
| 391 | DMA_TO_DEVICE); |
| 392 | if (dma_mapping_error(dd->dev, ctx->dma_addr)) { |
| 393 | dev_err(dd->dev, "dma %u bytes error\n", ctx->buflen); |
| 394 | return -EINVAL; |
| 395 | } |
| 396 | |
| 397 | /* next call does not fail... so no unmap in the case of error */ |
| 398 | return omap_sham_xmit_dma(dd, ctx->dma_addr, length, final); |
| 399 | } |
| 400 | |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 401 | static int omap_sham_update_dma_slow(struct omap_sham_dev *dd) |
| 402 | { |
| 403 | struct omap_sham_reqctx *ctx = ahash_request_ctx(dd->req); |
| 404 | unsigned int final; |
| 405 | size_t count; |
| 406 | |
| 407 | if (!ctx->total) |
| 408 | return 0; |
| 409 | |
| 410 | omap_sham_append_sg(ctx); |
| 411 | |
| 412 | final = (ctx->flags & FLAGS_FINUP) && !ctx->total; |
| 413 | |
| 414 | dev_dbg(dd->dev, "slow: bufcnt: %u, digcnt: %d, final: %d\n", |
| 415 | ctx->bufcnt, ctx->digcnt, final); |
| 416 | |
| 417 | if (final || (ctx->bufcnt == ctx->buflen && ctx->total)) { |
| 418 | count = ctx->bufcnt; |
| 419 | ctx->bufcnt = 0; |
Dmitry Kasatkin | 798eed5d | 2010-11-19 16:04:26 +0200 | [diff] [blame] | 420 | return omap_sham_xmit_dma_map(dd, ctx, count, final); |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | return 0; |
| 424 | } |
| 425 | |
| 426 | static int omap_sham_update_dma_fast(struct omap_sham_dev *dd) |
| 427 | { |
| 428 | struct omap_sham_reqctx *ctx = ahash_request_ctx(dd->req); |
| 429 | unsigned int length; |
| 430 | |
| 431 | ctx->flags |= FLAGS_FAST; |
| 432 | |
| 433 | length = min(ctx->total, sg_dma_len(ctx->sg)); |
| 434 | ctx->total = length; |
| 435 | |
| 436 | if (!dma_map_sg(dd->dev, ctx->sg, 1, DMA_TO_DEVICE)) { |
| 437 | dev_err(dd->dev, "dma_map_sg error\n"); |
| 438 | return -EINVAL; |
| 439 | } |
| 440 | |
| 441 | ctx->total -= length; |
| 442 | |
Dmitry Kasatkin | 798eed5d | 2010-11-19 16:04:26 +0200 | [diff] [blame] | 443 | /* next call does not fail... so no unmap in the case of error */ |
| 444 | return omap_sham_xmit_dma(dd, sg_dma_address(ctx->sg), length, 1); |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | static int omap_sham_update_cpu(struct omap_sham_dev *dd) |
| 448 | { |
| 449 | struct omap_sham_reqctx *ctx = ahash_request_ctx(dd->req); |
| 450 | int bufcnt; |
| 451 | |
| 452 | omap_sham_append_sg(ctx); |
| 453 | bufcnt = ctx->bufcnt; |
| 454 | ctx->bufcnt = 0; |
| 455 | |
| 456 | return omap_sham_xmit_cpu(dd, ctx->buffer, bufcnt, 1); |
| 457 | } |
| 458 | |
| 459 | static int omap_sham_update_dma_stop(struct omap_sham_dev *dd) |
| 460 | { |
| 461 | struct omap_sham_reqctx *ctx = ahash_request_ctx(dd->req); |
| 462 | |
| 463 | omap_stop_dma(dd->dma_lch); |
| 464 | if (ctx->flags & FLAGS_FAST) |
| 465 | dma_unmap_sg(dd->dev, ctx->sg, 1, DMA_TO_DEVICE); |
Dmitry Kasatkin | 798eed5d | 2010-11-19 16:04:26 +0200 | [diff] [blame] | 466 | else |
| 467 | dma_unmap_single(dd->dev, ctx->dma_addr, ctx->buflen, |
| 468 | DMA_TO_DEVICE); |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 469 | |
| 470 | return 0; |
| 471 | } |
| 472 | |
| 473 | static void omap_sham_cleanup(struct ahash_request *req) |
| 474 | { |
| 475 | struct omap_sham_reqctx *ctx = ahash_request_ctx(req); |
| 476 | struct omap_sham_dev *dd = ctx->dd; |
| 477 | unsigned long flags; |
| 478 | |
| 479 | spin_lock_irqsave(&dd->lock, flags); |
| 480 | if (ctx->flags & FLAGS_CLEAN) { |
| 481 | spin_unlock_irqrestore(&dd->lock, flags); |
| 482 | return; |
| 483 | } |
| 484 | ctx->flags |= FLAGS_CLEAN; |
| 485 | spin_unlock_irqrestore(&dd->lock, flags); |
| 486 | |
Dmitry Kasatkin | 798eed5d | 2010-11-19 16:04:26 +0200 | [diff] [blame] | 487 | if (ctx->digcnt) |
Dmitry Kasatkin | 3c8d758 | 2010-11-19 16:04:27 +0200 | [diff] [blame^] | 488 | omap_sham_copy_ready_hash(req); |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 489 | |
| 490 | dev_dbg(dd->dev, "digcnt: %d, bufcnt: %d\n", ctx->digcnt, ctx->bufcnt); |
| 491 | } |
| 492 | |
| 493 | static int omap_sham_init(struct ahash_request *req) |
| 494 | { |
| 495 | struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); |
| 496 | struct omap_sham_ctx *tctx = crypto_ahash_ctx(tfm); |
| 497 | struct omap_sham_reqctx *ctx = ahash_request_ctx(req); |
| 498 | struct omap_sham_dev *dd = NULL, *tmp; |
| 499 | |
| 500 | spin_lock_bh(&sham.lock); |
| 501 | if (!tctx->dd) { |
| 502 | list_for_each_entry(tmp, &sham.dev_list, list) { |
| 503 | dd = tmp; |
| 504 | break; |
| 505 | } |
| 506 | tctx->dd = dd; |
| 507 | } else { |
| 508 | dd = tctx->dd; |
| 509 | } |
| 510 | spin_unlock_bh(&sham.lock); |
| 511 | |
| 512 | ctx->dd = dd; |
| 513 | |
| 514 | ctx->flags = 0; |
| 515 | |
| 516 | ctx->flags |= FLAGS_FIRST; |
| 517 | |
| 518 | dev_dbg(dd->dev, "init: digest size: %d\n", |
| 519 | crypto_ahash_digestsize(tfm)); |
| 520 | |
| 521 | if (crypto_ahash_digestsize(tfm) == SHA1_DIGEST_SIZE) |
| 522 | ctx->flags |= FLAGS_SHA1; |
| 523 | |
| 524 | ctx->bufcnt = 0; |
| 525 | ctx->digcnt = 0; |
Dmitry Kasatkin | 798eed5d | 2010-11-19 16:04:26 +0200 | [diff] [blame] | 526 | ctx->buflen = BUFLEN; |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 527 | |
| 528 | if (tctx->flags & FLAGS_HMAC) { |
| 529 | struct omap_sham_hmac_ctx *bctx = tctx->base; |
| 530 | |
| 531 | memcpy(ctx->buffer, bctx->ipad, SHA1_MD5_BLOCK_SIZE); |
| 532 | ctx->bufcnt = SHA1_MD5_BLOCK_SIZE; |
| 533 | ctx->flags |= FLAGS_HMAC; |
| 534 | } |
| 535 | |
| 536 | return 0; |
| 537 | |
| 538 | } |
| 539 | |
| 540 | static int omap_sham_update_req(struct omap_sham_dev *dd) |
| 541 | { |
| 542 | struct ahash_request *req = dd->req; |
| 543 | struct omap_sham_reqctx *ctx = ahash_request_ctx(req); |
| 544 | int err; |
| 545 | |
| 546 | dev_dbg(dd->dev, "update_req: total: %u, digcnt: %d, finup: %d\n", |
| 547 | ctx->total, ctx->digcnt, (ctx->flags & FLAGS_FINUP) != 0); |
| 548 | |
| 549 | if (ctx->flags & FLAGS_CPU) |
| 550 | err = omap_sham_update_cpu(dd); |
| 551 | else if (ctx->flags & FLAGS_FAST) |
| 552 | err = omap_sham_update_dma_fast(dd); |
| 553 | else |
| 554 | err = omap_sham_update_dma_slow(dd); |
| 555 | |
| 556 | /* wait for dma completion before can take more data */ |
| 557 | dev_dbg(dd->dev, "update: err: %d, digcnt: %d\n", err, ctx->digcnt); |
| 558 | |
| 559 | return err; |
| 560 | } |
| 561 | |
| 562 | static int omap_sham_final_req(struct omap_sham_dev *dd) |
| 563 | { |
| 564 | struct ahash_request *req = dd->req; |
| 565 | struct omap_sham_reqctx *ctx = ahash_request_ctx(req); |
| 566 | int err = 0, use_dma = 1; |
| 567 | |
| 568 | if (ctx->bufcnt <= 64) |
| 569 | /* faster to handle last block with cpu */ |
| 570 | use_dma = 0; |
| 571 | |
| 572 | if (use_dma) |
Dmitry Kasatkin | 798eed5d | 2010-11-19 16:04:26 +0200 | [diff] [blame] | 573 | err = omap_sham_xmit_dma_map(dd, ctx, ctx->bufcnt, 1); |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 574 | else |
| 575 | err = omap_sham_xmit_cpu(dd, ctx->buffer, ctx->bufcnt, 1); |
| 576 | |
| 577 | ctx->bufcnt = 0; |
| 578 | |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 579 | dev_dbg(dd->dev, "final_req: err: %d\n", err); |
| 580 | |
| 581 | return err; |
| 582 | } |
| 583 | |
| 584 | static int omap_sham_finish_req_hmac(struct ahash_request *req) |
| 585 | { |
Dmitry Kasatkin | 0c3cf4c | 2010-11-19 16:04:22 +0200 | [diff] [blame] | 586 | struct omap_sham_reqctx *ctx = ahash_request_ctx(req); |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 587 | struct omap_sham_ctx *tctx = crypto_tfm_ctx(req->base.tfm); |
| 588 | struct omap_sham_hmac_ctx *bctx = tctx->base; |
| 589 | int bs = crypto_shash_blocksize(bctx->shash); |
| 590 | int ds = crypto_shash_digestsize(bctx->shash); |
| 591 | struct { |
| 592 | struct shash_desc shash; |
| 593 | char ctx[crypto_shash_descsize(bctx->shash)]; |
| 594 | } desc; |
| 595 | |
| 596 | desc.shash.tfm = bctx->shash; |
| 597 | desc.shash.flags = 0; /* not CRYPTO_TFM_REQ_MAY_SLEEP */ |
| 598 | |
| 599 | return crypto_shash_init(&desc.shash) ?: |
| 600 | crypto_shash_update(&desc.shash, bctx->opad, bs) ?: |
Dmitry Kasatkin | 0c3cf4c | 2010-11-19 16:04:22 +0200 | [diff] [blame] | 601 | crypto_shash_finup(&desc.shash, ctx->digest, ds, ctx->digest); |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | static void omap_sham_finish_req(struct ahash_request *req, int err) |
| 605 | { |
| 606 | struct omap_sham_reqctx *ctx = ahash_request_ctx(req); |
Dmitry Kasatkin | 798eed5d | 2010-11-19 16:04:26 +0200 | [diff] [blame] | 607 | struct omap_sham_dev *dd = ctx->dd; |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 608 | |
| 609 | if (!err) { |
| 610 | omap_sham_copy_hash(ctx->dd->req, 1); |
| 611 | if (ctx->flags & FLAGS_HMAC) |
| 612 | err = omap_sham_finish_req_hmac(req); |
Dmitry Kasatkin | 3e133c8 | 2010-11-19 16:04:24 +0200 | [diff] [blame] | 613 | } else { |
| 614 | ctx->flags |= FLAGS_ERROR; |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 615 | } |
| 616 | |
Dmitry Kasatkin | 3e133c8 | 2010-11-19 16:04:24 +0200 | [diff] [blame] | 617 | if ((ctx->flags & FLAGS_FINAL) || err) |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 618 | omap_sham_cleanup(req); |
| 619 | |
Dmitry Kasatkin | 798eed5d | 2010-11-19 16:04:26 +0200 | [diff] [blame] | 620 | clk_disable(dd->iclk); |
| 621 | dd->flags &= ~FLAGS_BUSY; |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 622 | |
| 623 | if (req->base.complete) |
| 624 | req->base.complete(&req->base, err); |
| 625 | } |
| 626 | |
Dmitry Kasatkin | a5d8723 | 2010-11-19 16:04:25 +0200 | [diff] [blame] | 627 | static int omap_sham_handle_queue(struct omap_sham_dev *dd, |
| 628 | struct ahash_request *req) |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 629 | { |
Dmitry Kasatkin | 798eed5d | 2010-11-19 16:04:26 +0200 | [diff] [blame] | 630 | struct crypto_async_request *async_req, *backlog = 0; |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 631 | struct omap_sham_reqctx *ctx; |
Dmitry Kasatkin | a5d8723 | 2010-11-19 16:04:25 +0200 | [diff] [blame] | 632 | struct ahash_request *prev_req; |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 633 | unsigned long flags; |
Dmitry Kasatkin | a5d8723 | 2010-11-19 16:04:25 +0200 | [diff] [blame] | 634 | int err = 0, ret = 0; |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 635 | |
| 636 | spin_lock_irqsave(&dd->lock, flags); |
Dmitry Kasatkin | a5d8723 | 2010-11-19 16:04:25 +0200 | [diff] [blame] | 637 | if (req) |
| 638 | ret = ahash_enqueue_request(&dd->queue, req); |
| 639 | if (dd->flags & FLAGS_BUSY) { |
| 640 | spin_unlock_irqrestore(&dd->lock, flags); |
| 641 | return ret; |
| 642 | } |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 643 | async_req = crypto_dequeue_request(&dd->queue); |
Dmitry Kasatkin | a5d8723 | 2010-11-19 16:04:25 +0200 | [diff] [blame] | 644 | if (async_req) { |
| 645 | dd->flags |= FLAGS_BUSY; |
| 646 | backlog = crypto_get_backlog(&dd->queue); |
| 647 | } |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 648 | spin_unlock_irqrestore(&dd->lock, flags); |
| 649 | |
| 650 | if (!async_req) |
Dmitry Kasatkin | a5d8723 | 2010-11-19 16:04:25 +0200 | [diff] [blame] | 651 | return ret; |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 652 | |
| 653 | if (backlog) |
| 654 | backlog->complete(backlog, -EINPROGRESS); |
| 655 | |
| 656 | req = ahash_request_cast(async_req); |
| 657 | |
| 658 | prev_req = dd->req; |
| 659 | dd->req = req; |
| 660 | |
| 661 | ctx = ahash_request_ctx(req); |
| 662 | |
| 663 | dev_dbg(dd->dev, "handling new req, op: %lu, nbytes: %d\n", |
| 664 | ctx->op, req->nbytes); |
| 665 | |
Dmitry Kasatkin | 798eed5d | 2010-11-19 16:04:26 +0200 | [diff] [blame] | 666 | |
| 667 | err = omap_sham_hw_init(dd); |
| 668 | if (err) |
| 669 | goto err1; |
| 670 | |
| 671 | omap_set_dma_dest_params(dd->dma_lch, 0, |
| 672 | OMAP_DMA_AMODE_CONSTANT, |
| 673 | dd->phys_base + SHA_REG_DIN(0), 0, 16); |
| 674 | |
| 675 | omap_set_dma_dest_burst_mode(dd->dma_lch, |
| 676 | OMAP_DMA_DATA_BURST_16); |
| 677 | |
| 678 | omap_set_dma_src_burst_mode(dd->dma_lch, |
| 679 | OMAP_DMA_DATA_BURST_4); |
| 680 | |
| 681 | if (ctx->digcnt) |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 682 | /* request has changed - restore hash */ |
| 683 | omap_sham_copy_hash(req, 0); |
| 684 | |
| 685 | if (ctx->op == OP_UPDATE) { |
| 686 | err = omap_sham_update_req(dd); |
| 687 | if (err != -EINPROGRESS && (ctx->flags & FLAGS_FINUP)) |
| 688 | /* no final() after finup() */ |
| 689 | err = omap_sham_final_req(dd); |
| 690 | } else if (ctx->op == OP_FINAL) { |
| 691 | err = omap_sham_final_req(dd); |
| 692 | } |
Dmitry Kasatkin | 798eed5d | 2010-11-19 16:04:26 +0200 | [diff] [blame] | 693 | err1: |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 694 | if (err != -EINPROGRESS) { |
| 695 | /* done_task will not finish it, so do it here */ |
| 696 | omap_sham_finish_req(req, err); |
| 697 | tasklet_schedule(&dd->queue_task); |
| 698 | } |
| 699 | |
| 700 | dev_dbg(dd->dev, "exit, err: %d\n", err); |
| 701 | |
Dmitry Kasatkin | a5d8723 | 2010-11-19 16:04:25 +0200 | [diff] [blame] | 702 | return ret; |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 703 | } |
| 704 | |
| 705 | static int omap_sham_enqueue(struct ahash_request *req, unsigned int op) |
| 706 | { |
| 707 | struct omap_sham_reqctx *ctx = ahash_request_ctx(req); |
| 708 | struct omap_sham_ctx *tctx = crypto_tfm_ctx(req->base.tfm); |
| 709 | struct omap_sham_dev *dd = tctx->dd; |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 710 | |
| 711 | ctx->op = op; |
| 712 | |
Dmitry Kasatkin | a5d8723 | 2010-11-19 16:04:25 +0200 | [diff] [blame] | 713 | return omap_sham_handle_queue(dd, req); |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 714 | } |
| 715 | |
| 716 | static int omap_sham_update(struct ahash_request *req) |
| 717 | { |
| 718 | struct omap_sham_reqctx *ctx = ahash_request_ctx(req); |
| 719 | |
| 720 | if (!req->nbytes) |
| 721 | return 0; |
| 722 | |
| 723 | ctx->total = req->nbytes; |
| 724 | ctx->sg = req->src; |
| 725 | ctx->offset = 0; |
| 726 | |
| 727 | if (ctx->flags & FLAGS_FINUP) { |
| 728 | if ((ctx->digcnt + ctx->bufcnt + ctx->total) < 9) { |
| 729 | /* |
| 730 | * OMAP HW accel works only with buffers >= 9 |
| 731 | * will switch to bypass in final() |
| 732 | * final has the same request and data |
| 733 | */ |
| 734 | omap_sham_append_sg(ctx); |
| 735 | return 0; |
| 736 | } else if (ctx->bufcnt + ctx->total <= 64) { |
| 737 | ctx->flags |= FLAGS_CPU; |
| 738 | } else if (!ctx->bufcnt && sg_is_last(ctx->sg)) { |
| 739 | /* may be can use faster functions */ |
| 740 | int aligned = IS_ALIGNED((u32)ctx->sg->offset, |
| 741 | sizeof(u32)); |
| 742 | |
| 743 | if (aligned && (ctx->flags & FLAGS_FIRST)) |
| 744 | /* digest: first and final */ |
| 745 | ctx->flags |= FLAGS_FAST; |
| 746 | |
| 747 | ctx->flags &= ~FLAGS_FIRST; |
| 748 | } |
| 749 | } else if (ctx->bufcnt + ctx->total <= ctx->buflen) { |
| 750 | /* if not finaup -> not fast */ |
| 751 | omap_sham_append_sg(ctx); |
| 752 | return 0; |
| 753 | } |
| 754 | |
| 755 | return omap_sham_enqueue(req, OP_UPDATE); |
| 756 | } |
| 757 | |
| 758 | static int omap_sham_shash_digest(struct crypto_shash *shash, u32 flags, |
| 759 | const u8 *data, unsigned int len, u8 *out) |
| 760 | { |
| 761 | struct { |
| 762 | struct shash_desc shash; |
| 763 | char ctx[crypto_shash_descsize(shash)]; |
| 764 | } desc; |
| 765 | |
| 766 | desc.shash.tfm = shash; |
| 767 | desc.shash.flags = flags & CRYPTO_TFM_REQ_MAY_SLEEP; |
| 768 | |
| 769 | return crypto_shash_digest(&desc.shash, data, len, out); |
| 770 | } |
| 771 | |
| 772 | static int omap_sham_final_shash(struct ahash_request *req) |
| 773 | { |
| 774 | struct omap_sham_ctx *tctx = crypto_tfm_ctx(req->base.tfm); |
| 775 | struct omap_sham_reqctx *ctx = ahash_request_ctx(req); |
| 776 | |
| 777 | return omap_sham_shash_digest(tctx->fallback, req->base.flags, |
| 778 | ctx->buffer, ctx->bufcnt, req->result); |
| 779 | } |
| 780 | |
| 781 | static int omap_sham_final(struct ahash_request *req) |
| 782 | { |
| 783 | struct omap_sham_reqctx *ctx = ahash_request_ctx(req); |
| 784 | int err = 0; |
| 785 | |
| 786 | ctx->flags |= FLAGS_FINUP; |
| 787 | |
Dmitry Kasatkin | 3e133c8 | 2010-11-19 16:04:24 +0200 | [diff] [blame] | 788 | if (!(ctx->flags & FLAGS_ERROR)) { |
| 789 | /* OMAP HW accel works only with buffers >= 9 */ |
| 790 | /* HMAC is always >= 9 because of ipad */ |
| 791 | if ((ctx->digcnt + ctx->bufcnt) < 9) |
| 792 | err = omap_sham_final_shash(req); |
| 793 | else if (ctx->bufcnt) |
| 794 | return omap_sham_enqueue(req, OP_FINAL); |
| 795 | } |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 796 | |
| 797 | omap_sham_cleanup(req); |
| 798 | |
| 799 | return err; |
| 800 | } |
| 801 | |
| 802 | static int omap_sham_finup(struct ahash_request *req) |
| 803 | { |
| 804 | struct omap_sham_reqctx *ctx = ahash_request_ctx(req); |
| 805 | int err1, err2; |
| 806 | |
| 807 | ctx->flags |= FLAGS_FINUP; |
| 808 | |
| 809 | err1 = omap_sham_update(req); |
| 810 | if (err1 == -EINPROGRESS) |
| 811 | return err1; |
| 812 | /* |
| 813 | * final() has to be always called to cleanup resources |
| 814 | * even if udpate() failed, except EINPROGRESS |
| 815 | */ |
| 816 | err2 = omap_sham_final(req); |
| 817 | |
| 818 | return err1 ?: err2; |
| 819 | } |
| 820 | |
| 821 | static int omap_sham_digest(struct ahash_request *req) |
| 822 | { |
| 823 | return omap_sham_init(req) ?: omap_sham_finup(req); |
| 824 | } |
| 825 | |
| 826 | static int omap_sham_setkey(struct crypto_ahash *tfm, const u8 *key, |
| 827 | unsigned int keylen) |
| 828 | { |
| 829 | struct omap_sham_ctx *tctx = crypto_ahash_ctx(tfm); |
| 830 | struct omap_sham_hmac_ctx *bctx = tctx->base; |
| 831 | int bs = crypto_shash_blocksize(bctx->shash); |
| 832 | int ds = crypto_shash_digestsize(bctx->shash); |
| 833 | int err, i; |
| 834 | err = crypto_shash_setkey(tctx->fallback, key, keylen); |
| 835 | if (err) |
| 836 | return err; |
| 837 | |
| 838 | if (keylen > bs) { |
| 839 | err = omap_sham_shash_digest(bctx->shash, |
| 840 | crypto_shash_get_flags(bctx->shash), |
| 841 | key, keylen, bctx->ipad); |
| 842 | if (err) |
| 843 | return err; |
| 844 | keylen = ds; |
| 845 | } else { |
| 846 | memcpy(bctx->ipad, key, keylen); |
| 847 | } |
| 848 | |
| 849 | memset(bctx->ipad + keylen, 0, bs - keylen); |
| 850 | memcpy(bctx->opad, bctx->ipad, bs); |
| 851 | |
| 852 | for (i = 0; i < bs; i++) { |
| 853 | bctx->ipad[i] ^= 0x36; |
| 854 | bctx->opad[i] ^= 0x5c; |
| 855 | } |
| 856 | |
| 857 | return err; |
| 858 | } |
| 859 | |
| 860 | static int omap_sham_cra_init_alg(struct crypto_tfm *tfm, const char *alg_base) |
| 861 | { |
| 862 | struct omap_sham_ctx *tctx = crypto_tfm_ctx(tfm); |
| 863 | const char *alg_name = crypto_tfm_alg_name(tfm); |
| 864 | |
Dmitry Kasatkin | 3e133c8 | 2010-11-19 16:04:24 +0200 | [diff] [blame] | 865 | pr_info("enter\n"); |
| 866 | |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 867 | /* Allocate a fallback and abort if it failed. */ |
| 868 | tctx->fallback = crypto_alloc_shash(alg_name, 0, |
| 869 | CRYPTO_ALG_NEED_FALLBACK); |
| 870 | if (IS_ERR(tctx->fallback)) { |
| 871 | pr_err("omap-sham: fallback driver '%s' " |
| 872 | "could not be loaded.\n", alg_name); |
| 873 | return PTR_ERR(tctx->fallback); |
| 874 | } |
| 875 | |
| 876 | crypto_ahash_set_reqsize(__crypto_ahash_cast(tfm), |
Dmitry Kasatkin | 798eed5d | 2010-11-19 16:04:26 +0200 | [diff] [blame] | 877 | sizeof(struct omap_sham_reqctx) + BUFLEN); |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 878 | |
| 879 | if (alg_base) { |
| 880 | struct omap_sham_hmac_ctx *bctx = tctx->base; |
| 881 | tctx->flags |= FLAGS_HMAC; |
| 882 | bctx->shash = crypto_alloc_shash(alg_base, 0, |
| 883 | CRYPTO_ALG_NEED_FALLBACK); |
| 884 | if (IS_ERR(bctx->shash)) { |
| 885 | pr_err("omap-sham: base driver '%s' " |
| 886 | "could not be loaded.\n", alg_base); |
| 887 | crypto_free_shash(tctx->fallback); |
| 888 | return PTR_ERR(bctx->shash); |
| 889 | } |
| 890 | |
| 891 | } |
| 892 | |
| 893 | return 0; |
| 894 | } |
| 895 | |
| 896 | static int omap_sham_cra_init(struct crypto_tfm *tfm) |
| 897 | { |
| 898 | return omap_sham_cra_init_alg(tfm, NULL); |
| 899 | } |
| 900 | |
| 901 | static int omap_sham_cra_sha1_init(struct crypto_tfm *tfm) |
| 902 | { |
| 903 | return omap_sham_cra_init_alg(tfm, "sha1"); |
| 904 | } |
| 905 | |
| 906 | static int omap_sham_cra_md5_init(struct crypto_tfm *tfm) |
| 907 | { |
| 908 | return omap_sham_cra_init_alg(tfm, "md5"); |
| 909 | } |
| 910 | |
| 911 | static void omap_sham_cra_exit(struct crypto_tfm *tfm) |
| 912 | { |
| 913 | struct omap_sham_ctx *tctx = crypto_tfm_ctx(tfm); |
| 914 | |
| 915 | crypto_free_shash(tctx->fallback); |
| 916 | tctx->fallback = NULL; |
| 917 | |
| 918 | if (tctx->flags & FLAGS_HMAC) { |
| 919 | struct omap_sham_hmac_ctx *bctx = tctx->base; |
| 920 | crypto_free_shash(bctx->shash); |
| 921 | } |
| 922 | } |
| 923 | |
| 924 | static struct ahash_alg algs[] = { |
| 925 | { |
| 926 | .init = omap_sham_init, |
| 927 | .update = omap_sham_update, |
| 928 | .final = omap_sham_final, |
| 929 | .finup = omap_sham_finup, |
| 930 | .digest = omap_sham_digest, |
| 931 | .halg.digestsize = SHA1_DIGEST_SIZE, |
| 932 | .halg.base = { |
| 933 | .cra_name = "sha1", |
| 934 | .cra_driver_name = "omap-sha1", |
| 935 | .cra_priority = 100, |
| 936 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | |
| 937 | CRYPTO_ALG_ASYNC | |
| 938 | CRYPTO_ALG_NEED_FALLBACK, |
| 939 | .cra_blocksize = SHA1_BLOCK_SIZE, |
| 940 | .cra_ctxsize = sizeof(struct omap_sham_ctx), |
| 941 | .cra_alignmask = 0, |
| 942 | .cra_module = THIS_MODULE, |
| 943 | .cra_init = omap_sham_cra_init, |
| 944 | .cra_exit = omap_sham_cra_exit, |
| 945 | } |
| 946 | }, |
| 947 | { |
| 948 | .init = omap_sham_init, |
| 949 | .update = omap_sham_update, |
| 950 | .final = omap_sham_final, |
| 951 | .finup = omap_sham_finup, |
| 952 | .digest = omap_sham_digest, |
| 953 | .halg.digestsize = MD5_DIGEST_SIZE, |
| 954 | .halg.base = { |
| 955 | .cra_name = "md5", |
| 956 | .cra_driver_name = "omap-md5", |
| 957 | .cra_priority = 100, |
| 958 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | |
| 959 | CRYPTO_ALG_ASYNC | |
| 960 | CRYPTO_ALG_NEED_FALLBACK, |
| 961 | .cra_blocksize = SHA1_BLOCK_SIZE, |
| 962 | .cra_ctxsize = sizeof(struct omap_sham_ctx), |
Dmitry Kasatkin | 798eed5d | 2010-11-19 16:04:26 +0200 | [diff] [blame] | 963 | .cra_alignmask = OMAP_ALIGN_MASK, |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 964 | .cra_module = THIS_MODULE, |
| 965 | .cra_init = omap_sham_cra_init, |
| 966 | .cra_exit = omap_sham_cra_exit, |
| 967 | } |
| 968 | }, |
| 969 | { |
| 970 | .init = omap_sham_init, |
| 971 | .update = omap_sham_update, |
| 972 | .final = omap_sham_final, |
| 973 | .finup = omap_sham_finup, |
| 974 | .digest = omap_sham_digest, |
| 975 | .setkey = omap_sham_setkey, |
| 976 | .halg.digestsize = SHA1_DIGEST_SIZE, |
| 977 | .halg.base = { |
| 978 | .cra_name = "hmac(sha1)", |
| 979 | .cra_driver_name = "omap-hmac-sha1", |
| 980 | .cra_priority = 100, |
| 981 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | |
| 982 | CRYPTO_ALG_ASYNC | |
| 983 | CRYPTO_ALG_NEED_FALLBACK, |
| 984 | .cra_blocksize = SHA1_BLOCK_SIZE, |
| 985 | .cra_ctxsize = sizeof(struct omap_sham_ctx) + |
| 986 | sizeof(struct omap_sham_hmac_ctx), |
Dmitry Kasatkin | 798eed5d | 2010-11-19 16:04:26 +0200 | [diff] [blame] | 987 | .cra_alignmask = OMAP_ALIGN_MASK, |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 988 | .cra_module = THIS_MODULE, |
| 989 | .cra_init = omap_sham_cra_sha1_init, |
| 990 | .cra_exit = omap_sham_cra_exit, |
| 991 | } |
| 992 | }, |
| 993 | { |
| 994 | .init = omap_sham_init, |
| 995 | .update = omap_sham_update, |
| 996 | .final = omap_sham_final, |
| 997 | .finup = omap_sham_finup, |
| 998 | .digest = omap_sham_digest, |
| 999 | .setkey = omap_sham_setkey, |
| 1000 | .halg.digestsize = MD5_DIGEST_SIZE, |
| 1001 | .halg.base = { |
| 1002 | .cra_name = "hmac(md5)", |
| 1003 | .cra_driver_name = "omap-hmac-md5", |
| 1004 | .cra_priority = 100, |
| 1005 | .cra_flags = CRYPTO_ALG_TYPE_AHASH | |
| 1006 | CRYPTO_ALG_ASYNC | |
| 1007 | CRYPTO_ALG_NEED_FALLBACK, |
| 1008 | .cra_blocksize = SHA1_BLOCK_SIZE, |
| 1009 | .cra_ctxsize = sizeof(struct omap_sham_ctx) + |
| 1010 | sizeof(struct omap_sham_hmac_ctx), |
Dmitry Kasatkin | 798eed5d | 2010-11-19 16:04:26 +0200 | [diff] [blame] | 1011 | .cra_alignmask = OMAP_ALIGN_MASK, |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 1012 | .cra_module = THIS_MODULE, |
| 1013 | .cra_init = omap_sham_cra_md5_init, |
| 1014 | .cra_exit = omap_sham_cra_exit, |
| 1015 | } |
| 1016 | } |
| 1017 | }; |
| 1018 | |
| 1019 | static void omap_sham_done_task(unsigned long data) |
| 1020 | { |
| 1021 | struct omap_sham_dev *dd = (struct omap_sham_dev *)data; |
| 1022 | struct ahash_request *req = dd->req; |
| 1023 | struct omap_sham_reqctx *ctx = ahash_request_ctx(req); |
Dmitry Kasatkin | 3e133c8 | 2010-11-19 16:04:24 +0200 | [diff] [blame] | 1024 | int ready = 0, err = 0; |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 1025 | |
| 1026 | if (ctx->flags & FLAGS_OUTPUT_READY) { |
| 1027 | ctx->flags &= ~FLAGS_OUTPUT_READY; |
| 1028 | ready = 1; |
| 1029 | } |
| 1030 | |
| 1031 | if (dd->flags & FLAGS_DMA_ACTIVE) { |
| 1032 | dd->flags &= ~FLAGS_DMA_ACTIVE; |
| 1033 | omap_sham_update_dma_stop(dd); |
Dmitry Kasatkin | 3e133c8 | 2010-11-19 16:04:24 +0200 | [diff] [blame] | 1034 | if (!dd->err) |
| 1035 | err = omap_sham_update_dma_slow(dd); |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 1036 | } |
| 1037 | |
Dmitry Kasatkin | 3e133c8 | 2010-11-19 16:04:24 +0200 | [diff] [blame] | 1038 | err = dd->err ? : err; |
| 1039 | |
| 1040 | if (err != -EINPROGRESS && (ready || err)) { |
| 1041 | dev_dbg(dd->dev, "update done: err: %d\n", err); |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 1042 | /* finish curent request */ |
Dmitry Kasatkin | 3e133c8 | 2010-11-19 16:04:24 +0200 | [diff] [blame] | 1043 | omap_sham_finish_req(req, err); |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 1044 | /* start new request */ |
Dmitry Kasatkin | a5d8723 | 2010-11-19 16:04:25 +0200 | [diff] [blame] | 1045 | omap_sham_handle_queue(dd, NULL); |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 1046 | } |
| 1047 | } |
| 1048 | |
| 1049 | static void omap_sham_queue_task(unsigned long data) |
| 1050 | { |
| 1051 | struct omap_sham_dev *dd = (struct omap_sham_dev *)data; |
| 1052 | |
Dmitry Kasatkin | a5d8723 | 2010-11-19 16:04:25 +0200 | [diff] [blame] | 1053 | omap_sham_handle_queue(dd, NULL); |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 1054 | } |
| 1055 | |
| 1056 | static irqreturn_t omap_sham_irq(int irq, void *dev_id) |
| 1057 | { |
| 1058 | struct omap_sham_dev *dd = dev_id; |
| 1059 | struct omap_sham_reqctx *ctx = ahash_request_ctx(dd->req); |
| 1060 | |
| 1061 | if (!ctx) { |
| 1062 | dev_err(dd->dev, "unknown interrupt.\n"); |
| 1063 | return IRQ_HANDLED; |
| 1064 | } |
| 1065 | |
| 1066 | if (unlikely(ctx->flags & FLAGS_FINAL)) |
| 1067 | /* final -> allow device to go to power-saving mode */ |
| 1068 | omap_sham_write_mask(dd, SHA_REG_CTRL, 0, SHA_REG_CTRL_LENGTH); |
| 1069 | |
| 1070 | omap_sham_write_mask(dd, SHA_REG_CTRL, SHA_REG_CTRL_OUTPUT_READY, |
| 1071 | SHA_REG_CTRL_OUTPUT_READY); |
| 1072 | omap_sham_read(dd, SHA_REG_CTRL); |
| 1073 | |
| 1074 | ctx->flags |= FLAGS_OUTPUT_READY; |
Dmitry Kasatkin | 3e133c8 | 2010-11-19 16:04:24 +0200 | [diff] [blame] | 1075 | dd->err = 0; |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 1076 | tasklet_schedule(&dd->done_task); |
| 1077 | |
| 1078 | return IRQ_HANDLED; |
| 1079 | } |
| 1080 | |
| 1081 | static void omap_sham_dma_callback(int lch, u16 ch_status, void *data) |
| 1082 | { |
| 1083 | struct omap_sham_dev *dd = data; |
| 1084 | |
Dmitry Kasatkin | 3e133c8 | 2010-11-19 16:04:24 +0200 | [diff] [blame] | 1085 | if (ch_status != OMAP_DMA_BLOCK_IRQ) { |
| 1086 | pr_err("omap-sham DMA error status: 0x%hx\n", ch_status); |
| 1087 | dd->err = -EIO; |
| 1088 | dd->flags &= ~FLAGS_INIT; /* request to re-initialize */ |
| 1089 | } |
| 1090 | |
| 1091 | tasklet_schedule(&dd->done_task); |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 1092 | } |
| 1093 | |
| 1094 | static int omap_sham_dma_init(struct omap_sham_dev *dd) |
| 1095 | { |
| 1096 | int err; |
| 1097 | |
| 1098 | dd->dma_lch = -1; |
| 1099 | |
| 1100 | err = omap_request_dma(dd->dma, dev_name(dd->dev), |
| 1101 | omap_sham_dma_callback, dd, &dd->dma_lch); |
| 1102 | if (err) { |
| 1103 | dev_err(dd->dev, "Unable to request DMA channel\n"); |
| 1104 | return err; |
| 1105 | } |
Samu Onkalo | 584db6a | 2010-09-03 19:20:19 +0800 | [diff] [blame] | 1106 | |
Dmitry Kasatkin | 8628e7c | 2010-05-03 11:10:59 +0800 | [diff] [blame] | 1107 | return 0; |
| 1108 | } |
| 1109 | |
| 1110 | static void omap_sham_dma_cleanup(struct omap_sham_dev *dd) |
| 1111 | { |
| 1112 | if (dd->dma_lch >= 0) { |
| 1113 | omap_free_dma(dd->dma_lch); |
| 1114 | dd->dma_lch = -1; |
| 1115 | } |
| 1116 | } |
| 1117 | |
| 1118 | static int __devinit omap_sham_probe(struct platform_device *pdev) |
| 1119 | { |
| 1120 | struct omap_sham_dev *dd; |
| 1121 | struct device *dev = &pdev->dev; |
| 1122 | struct resource *res; |
| 1123 | int err, i, j; |
| 1124 | |
| 1125 | dd = kzalloc(sizeof(struct omap_sham_dev), GFP_KERNEL); |
| 1126 | if (dd == NULL) { |
| 1127 | dev_err(dev, "unable to alloc data struct.\n"); |
| 1128 | err = -ENOMEM; |
| 1129 | goto data_err; |
| 1130 | } |
| 1131 | dd->dev = dev; |
| 1132 | platform_set_drvdata(pdev, dd); |
| 1133 | |
| 1134 | INIT_LIST_HEAD(&dd->list); |
| 1135 | spin_lock_init(&dd->lock); |
| 1136 | tasklet_init(&dd->done_task, omap_sham_done_task, (unsigned long)dd); |
| 1137 | tasklet_init(&dd->queue_task, omap_sham_queue_task, (unsigned long)dd); |
| 1138 | crypto_init_queue(&dd->queue, OMAP_SHAM_QUEUE_LENGTH); |
| 1139 | |
| 1140 | dd->irq = -1; |
| 1141 | |
| 1142 | /* Get the base address */ |
| 1143 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 1144 | if (!res) { |
| 1145 | dev_err(dev, "no MEM resource info\n"); |
| 1146 | err = -ENODEV; |
| 1147 | goto res_err; |
| 1148 | } |
| 1149 | dd->phys_base = res->start; |
| 1150 | |
| 1151 | /* Get the DMA */ |
| 1152 | res = platform_get_resource(pdev, IORESOURCE_DMA, 0); |
| 1153 | if (!res) { |
| 1154 | dev_err(dev, "no DMA resource info\n"); |
| 1155 | err = -ENODEV; |
| 1156 | goto res_err; |
| 1157 | } |
| 1158 | dd->dma = res->start; |
| 1159 | |
| 1160 | /* Get the IRQ */ |
| 1161 | dd->irq = platform_get_irq(pdev, 0); |
| 1162 | if (dd->irq < 0) { |
| 1163 | dev_err(dev, "no IRQ resource info\n"); |
| 1164 | err = dd->irq; |
| 1165 | goto res_err; |
| 1166 | } |
| 1167 | |
| 1168 | err = request_irq(dd->irq, omap_sham_irq, |
| 1169 | IRQF_TRIGGER_LOW, dev_name(dev), dd); |
| 1170 | if (err) { |
| 1171 | dev_err(dev, "unable to request irq.\n"); |
| 1172 | goto res_err; |
| 1173 | } |
| 1174 | |
| 1175 | err = omap_sham_dma_init(dd); |
| 1176 | if (err) |
| 1177 | goto dma_err; |
| 1178 | |
| 1179 | /* Initializing the clock */ |
| 1180 | dd->iclk = clk_get(dev, "ick"); |
| 1181 | if (!dd->iclk) { |
| 1182 | dev_err(dev, "clock intialization failed.\n"); |
| 1183 | err = -ENODEV; |
| 1184 | goto clk_err; |
| 1185 | } |
| 1186 | |
| 1187 | dd->io_base = ioremap(dd->phys_base, SZ_4K); |
| 1188 | if (!dd->io_base) { |
| 1189 | dev_err(dev, "can't ioremap\n"); |
| 1190 | err = -ENOMEM; |
| 1191 | goto io_err; |
| 1192 | } |
| 1193 | |
| 1194 | clk_enable(dd->iclk); |
| 1195 | dev_info(dev, "hw accel on OMAP rev %u.%u\n", |
| 1196 | (omap_sham_read(dd, SHA_REG_REV) & SHA_REG_REV_MAJOR) >> 4, |
| 1197 | omap_sham_read(dd, SHA_REG_REV) & SHA_REG_REV_MINOR); |
| 1198 | clk_disable(dd->iclk); |
| 1199 | |
| 1200 | spin_lock(&sham.lock); |
| 1201 | list_add_tail(&dd->list, &sham.dev_list); |
| 1202 | spin_unlock(&sham.lock); |
| 1203 | |
| 1204 | for (i = 0; i < ARRAY_SIZE(algs); i++) { |
| 1205 | err = crypto_register_ahash(&algs[i]); |
| 1206 | if (err) |
| 1207 | goto err_algs; |
| 1208 | } |
| 1209 | |
| 1210 | return 0; |
| 1211 | |
| 1212 | err_algs: |
| 1213 | for (j = 0; j < i; j++) |
| 1214 | crypto_unregister_ahash(&algs[j]); |
| 1215 | iounmap(dd->io_base); |
| 1216 | io_err: |
| 1217 | clk_put(dd->iclk); |
| 1218 | clk_err: |
| 1219 | omap_sham_dma_cleanup(dd); |
| 1220 | dma_err: |
| 1221 | if (dd->irq >= 0) |
| 1222 | free_irq(dd->irq, dd); |
| 1223 | res_err: |
| 1224 | kfree(dd); |
| 1225 | dd = NULL; |
| 1226 | data_err: |
| 1227 | dev_err(dev, "initialization failed.\n"); |
| 1228 | |
| 1229 | return err; |
| 1230 | } |
| 1231 | |
| 1232 | static int __devexit omap_sham_remove(struct platform_device *pdev) |
| 1233 | { |
| 1234 | static struct omap_sham_dev *dd; |
| 1235 | int i; |
| 1236 | |
| 1237 | dd = platform_get_drvdata(pdev); |
| 1238 | if (!dd) |
| 1239 | return -ENODEV; |
| 1240 | spin_lock(&sham.lock); |
| 1241 | list_del(&dd->list); |
| 1242 | spin_unlock(&sham.lock); |
| 1243 | for (i = 0; i < ARRAY_SIZE(algs); i++) |
| 1244 | crypto_unregister_ahash(&algs[i]); |
| 1245 | tasklet_kill(&dd->done_task); |
| 1246 | tasklet_kill(&dd->queue_task); |
| 1247 | iounmap(dd->io_base); |
| 1248 | clk_put(dd->iclk); |
| 1249 | omap_sham_dma_cleanup(dd); |
| 1250 | if (dd->irq >= 0) |
| 1251 | free_irq(dd->irq, dd); |
| 1252 | kfree(dd); |
| 1253 | dd = NULL; |
| 1254 | |
| 1255 | return 0; |
| 1256 | } |
| 1257 | |
| 1258 | static struct platform_driver omap_sham_driver = { |
| 1259 | .probe = omap_sham_probe, |
| 1260 | .remove = omap_sham_remove, |
| 1261 | .driver = { |
| 1262 | .name = "omap-sham", |
| 1263 | .owner = THIS_MODULE, |
| 1264 | }, |
| 1265 | }; |
| 1266 | |
| 1267 | static int __init omap_sham_mod_init(void) |
| 1268 | { |
| 1269 | pr_info("loading %s driver\n", "omap-sham"); |
| 1270 | |
| 1271 | if (!cpu_class_is_omap2() || |
| 1272 | omap_type() != OMAP2_DEVICE_TYPE_SEC) { |
| 1273 | pr_err("Unsupported cpu\n"); |
| 1274 | return -ENODEV; |
| 1275 | } |
| 1276 | |
| 1277 | return platform_driver_register(&omap_sham_driver); |
| 1278 | } |
| 1279 | |
| 1280 | static void __exit omap_sham_mod_exit(void) |
| 1281 | { |
| 1282 | platform_driver_unregister(&omap_sham_driver); |
| 1283 | } |
| 1284 | |
| 1285 | module_init(omap_sham_mod_init); |
| 1286 | module_exit(omap_sham_mod_exit); |
| 1287 | |
| 1288 | MODULE_DESCRIPTION("OMAP SHA1/MD5 hw acceleration support."); |
| 1289 | MODULE_LICENSE("GPL v2"); |
| 1290 | MODULE_AUTHOR("Dmitry Kasatkin"); |