Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / drivers / mmc / host / cqhci-crypto.h
blobd7fb084f563b0e01ac2c42c341ede7bc2842fb61
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * CQHCI crypto engine (inline encryption) support
5 * Copyright 2020 Google LLC
6 */
8 #ifndef LINUX_MMC_CQHCI_CRYPTO_H
9 #define LINUX_MMC_CQHCI_CRYPTO_H
11 #include <linux/mmc/host.h>
13 #include "cqhci.h"
15 #ifdef CONFIG_MMC_CRYPTO
17 int cqhci_crypto_init(struct cqhci_host *host);
20 * Returns the crypto bits that should be set in bits 64-127 of the
21 * task descriptor.
23 static inline u64 cqhci_crypto_prep_task_desc(struct mmc_request *mrq)
25 if (!mrq->crypto_ctx)
26 return 0;
28 /* We set max_dun_bytes_supported=4, so all DUNs should be 32-bit. */
29 WARN_ON_ONCE(mrq->crypto_ctx->bc_dun[0] > U32_MAX);
31 return CQHCI_CRYPTO_ENABLE_BIT |
32 CQHCI_CRYPTO_KEYSLOT(mrq->crypto_key_slot) |
33 mrq->crypto_ctx->bc_dun[0];
36 #else /* CONFIG_MMC_CRYPTO */
38 static inline int cqhci_crypto_init(struct cqhci_host *host)
40 return 0;
43 static inline u64 cqhci_crypto_prep_task_desc(struct mmc_request *mrq)
45 return 0;
48 #endif /* !CONFIG_MMC_CRYPTO */
50 #endif /* LINUX_MMC_CQHCI_CRYPTO_H */