1*1e80709bSEric Biggers /* SPDX-License-Identifier: GPL-2.0-only */ 2*1e80709bSEric Biggers /* 3*1e80709bSEric Biggers * CQHCI crypto engine (inline encryption) support 4*1e80709bSEric Biggers * 5*1e80709bSEric Biggers * Copyright 2020 Google LLC 6*1e80709bSEric Biggers */ 7*1e80709bSEric Biggers 8*1e80709bSEric Biggers #ifndef LINUX_MMC_CQHCI_CRYPTO_H 9*1e80709bSEric Biggers #define LINUX_MMC_CQHCI_CRYPTO_H 10*1e80709bSEric Biggers 11*1e80709bSEric Biggers #include <linux/mmc/host.h> 12*1e80709bSEric Biggers 13*1e80709bSEric Biggers #include "cqhci.h" 14*1e80709bSEric Biggers 15*1e80709bSEric Biggers #ifdef CONFIG_MMC_CRYPTO 16*1e80709bSEric Biggers 17*1e80709bSEric Biggers int cqhci_crypto_init(struct cqhci_host *host); 18*1e80709bSEric Biggers 19*1e80709bSEric Biggers /* 20*1e80709bSEric Biggers * Returns the crypto bits that should be set in bits 64-127 of the 21*1e80709bSEric Biggers * task descriptor. 22*1e80709bSEric Biggers */ 23*1e80709bSEric Biggers static inline u64 cqhci_crypto_prep_task_desc(struct mmc_request *mrq) 24*1e80709bSEric Biggers { 25*1e80709bSEric Biggers if (!mrq->crypto_enabled) 26*1e80709bSEric Biggers return 0; 27*1e80709bSEric Biggers 28*1e80709bSEric Biggers return CQHCI_CRYPTO_ENABLE_BIT | 29*1e80709bSEric Biggers CQHCI_CRYPTO_KEYSLOT(mrq->crypto_key_slot) | 30*1e80709bSEric Biggers mrq->data_unit_num; 31*1e80709bSEric Biggers } 32*1e80709bSEric Biggers 33*1e80709bSEric Biggers #else /* CONFIG_MMC_CRYPTO */ 34*1e80709bSEric Biggers 35*1e80709bSEric Biggers static inline int cqhci_crypto_init(struct cqhci_host *host) 36*1e80709bSEric Biggers { 37*1e80709bSEric Biggers return 0; 38*1e80709bSEric Biggers } 39*1e80709bSEric Biggers 40*1e80709bSEric Biggers static inline u64 cqhci_crypto_prep_task_desc(struct mmc_request *mrq) 41*1e80709bSEric Biggers { 42*1e80709bSEric Biggers return 0; 43*1e80709bSEric Biggers } 44*1e80709bSEric Biggers 45*1e80709bSEric Biggers #endif /* !CONFIG_MMC_CRYPTO */ 46*1e80709bSEric Biggers 47*1e80709bSEric Biggers #endif /* LINUX_MMC_CQHCI_CRYPTO_H */ 48