9 #include <linux/module.h>
10 #include <linux/kernel.h>
11 #include <linux/pci.h>
16 #include <crypto/aes.h>
33 for (i = 0; i < 4; i++)
34 iowrite32(((
u32 *) value)[i], _iobase + offset + (i * 4));
39 _readfield(
u32 offset,
void *value)
42 for (i = 0; i < 4; i++)
43 ((
u32 *) value)[
i] =
ioread32(_iobase + offset + (i * 4));
66 return counter ? 0 : 1;
103 ret = do_crypt(op->
src, op->
dst, op->
len, flags);
109 spin_unlock_irqrestore(&lock, iflags);
141 ret = crypto_cipher_setkey(op->
fallback.
cip, key, len);
149 static int geode_setkey_blk(
struct crypto_tfm *tfm,
const u8 *key,
174 ret = crypto_blkcipher_setkey(op->
fallback.
blk, key, len);
193 ret = crypto_blkcipher_decrypt_iv(desc, dst, src, nbytes);
209 ret = crypto_blkcipher_encrypt_iv(desc, dst, src, nbytes);
221 crypto_cipher_encrypt_one(op->
fallback.
cip, out, in);
225 op->
src = (
void *) in;
226 op->
dst = (
void *) out;
242 crypto_cipher_decrypt_one(op->
fallback.
cip, out, in);
246 op->
src = (
void *) in;
247 op->
dst = (
void *) out;
256 static int fallback_init_cip(
struct crypto_tfm *tfm)
272 static void fallback_exit_cip(
struct crypto_tfm *tfm)
282 .cra_driver_name =
"geode-aes",
287 .cra_init = fallback_init_cip,
288 .cra_exit = fallback_exit_cip,
296 .cia_setkey = geode_setkey_cip,
297 .cia_encrypt = geode_encrypt,
298 .cia_decrypt = geode_decrypt
313 return fallback_blk_dec(desc, dst, src, nbytes);
315 blkcipher_walk_init(&walk, dst, src, nbytes);
319 while ((nbytes = walk.nbytes)) {
320 op->
src = walk.src.virt.addr,
321 op->
dst = walk.dst.virt.addr;
326 ret = geode_aes_crypt(op);
345 return fallback_blk_enc(desc, dst, src, nbytes);
347 blkcipher_walk_init(&walk, dst, src, nbytes);
351 while ((nbytes = walk.nbytes)) {
352 op->
src = walk.src.virt.addr,
353 op->
dst = walk.dst.virt.addr;
358 ret = geode_aes_crypt(op);
366 static int fallback_init_blk(
struct crypto_tfm *tfm)
368 const char *name = tfm->
__crt_alg->cra_name;
382 static void fallback_exit_blk(
struct crypto_tfm *tfm)
391 .cra_name =
"cbc(aes)",
392 .cra_driver_name =
"cbc-aes-geode",
397 .cra_init = fallback_init_blk,
398 .cra_exit = fallback_exit_blk,
408 .setkey = geode_setkey_blk,
409 .encrypt = geode_cbc_encrypt,
410 .decrypt = geode_cbc_decrypt,
426 return fallback_blk_dec(desc, dst, src, nbytes);
428 blkcipher_walk_init(&walk, dst, src, nbytes);
431 while ((nbytes = walk.nbytes)) {
432 op->
src = walk.src.virt.addr,
433 op->
dst = walk.dst.virt.addr;
438 ret = geode_aes_crypt(op);
456 return fallback_blk_enc(desc, dst, src, nbytes);
458 blkcipher_walk_init(&walk, dst, src, nbytes);
461 while ((nbytes = walk.nbytes)) {
462 op->
src = walk.src.virt.addr,
463 op->
dst = walk.dst.virt.addr;
468 ret = geode_aes_crypt(op);
477 .cra_name =
"ecb(aes)",
478 .cra_driver_name =
"ecb-aes-geode",
483 .cra_init = fallback_init_blk,
484 .cra_exit = fallback_exit_blk,
494 .setkey = geode_setkey_blk,
495 .encrypt = geode_ecb_encrypt,
496 .decrypt = geode_ecb_decrypt,
528 _iobase = pci_iomap(dev, 0, 0);
530 if (_iobase ==
NULL) {
582 .name =
"Geode LX AES",
583 .id_table = geode_aes_tbl,
584 .probe = geode_aes_probe,