#include <linux/bitfield.h>
#include <linux/clk.h>
#include <linux/dma-mapping.h>
#include <linux/dmaengine.h>
#include <linux/dmapool.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <crypto/aes.h>
#include <crypto/authenc.h>
#include <crypto/des.h>
#include <crypto/internal/aead.h>
#include <crypto/internal/hash.h>
#include <crypto/internal/skcipher.h>
#include <crypto/scatterwalk.h>
#include <crypto/sha1.h>
#include <crypto/sha2.h>
#include "sa2ul.h"
#define SC_ENC_KEY_OFFSET …
#define SC_ENC_AUX1_OFFSET …
#define SA_CMDL_UPD_ENC …
#define SA_CMDL_UPD_AUTH …
#define SA_CMDL_UPD_ENC_IV …
#define SA_CMDL_UPD_AUTH_IV …
#define SA_CMDL_UPD_AUX_KEY …
#define SA_AUTH_SUBKEY_LEN …
#define SA_CMDL_PAYLOAD_LENGTH_MASK …
#define SA_CMDL_SOP_BYPASS_LEN_MASK …
#define MODE_CONTROL_BYTES …
#define SA_HASH_PROCESSING …
#define SA_CRYPTO_PROCESSING …
#define SA_UPLOAD_HASH_TO_TLR …
#define SA_SW0_FLAGS_MASK …
#define SA_SW0_CMDL_INFO_MASK …
#define SA_SW0_CMDL_PRESENT …
#define SA_SW0_ENG_ID_MASK …
#define SA_SW0_DEST_INFO_PRESENT …
#define SA_SW2_EGRESS_LENGTH …
#define SA_BASIC_HASH …
#define SHA256_DIGEST_WORDS …
#define SA_MK_U32(b0, b1, b2, b3) …
#define SA_SCCTL_SZ …
#define SA_MAX_AUTH_TAG_SZ …
enum sa_algo_id { … };
struct sa_match_data { … };
static struct device *sa_k3_dev;
struct sa_cmdl_cfg { … };
struct algo_data { … };
struct sa_alg_tmpl { … };
struct sa_mapped_sg { … };
struct sa_rx_data { … };
struct sa_req { … };
static u8 mci_cbc_enc_array[3][MODE_CONTROL_BYTES] = …;
static u8 mci_cbc_dec_array[3][MODE_CONTROL_BYTES] = …;
static u8 mci_cbc_enc_no_iv_array[3][MODE_CONTROL_BYTES] = …;
static u8 mci_cbc_dec_no_iv_array[3][MODE_CONTROL_BYTES] = …;
static u8 mci_ecb_enc_array[3][27] = …;
static u8 mci_ecb_dec_array[3][27] = …;
static u8 mci_cbc_3des_enc_array[MODE_CONTROL_BYTES] = …;
static u8 mci_cbc_3des_dec_array[MODE_CONTROL_BYTES] = …;
static u8 mci_ecb_3des_enc_array[MODE_CONTROL_BYTES] = …;
static u8 mci_ecb_3des_dec_array[MODE_CONTROL_BYTES] = …;
static void sa_swiz_128(u8 *in, u16 len)
{ … }
static void prepare_kipad(u8 *k_ipad, const u8 *key, u16 key_sz)
{ … }
static void prepare_kopad(u8 *k_opad, const u8 *key, u16 key_sz)
{ … }
static void sa_export_shash(void *state, struct shash_desc *hash,
int digest_size, __be32 *out)
{ … }
static void sa_prepare_iopads(struct algo_data *data, const u8 *key,
u16 key_sz, __be32 *ipad, __be32 *opad)
{ … }
static inline int sa_aes_inv_key(u8 *inv_key, const u8 *key, u16 key_sz)
{ … }
static int sa_set_sc_enc(struct algo_data *ad, const u8 *key, u16 key_sz,
u8 enc, u8 *sc_buf)
{ … }
static void sa_set_sc_auth(struct algo_data *ad, const u8 *key, u16 key_sz,
u8 *sc_buf)
{ … }
static inline void sa_copy_iv(__be32 *out, const u8 *iv, bool size16)
{ … }
static int sa_format_cmdl_gen(struct sa_cmdl_cfg *cfg, u8 *cmdl,
struct sa_cmdl_upd_info *upd_info)
{ … }
static inline void sa_update_cmdl(struct sa_req *req, u32 *cmdl,
struct sa_cmdl_upd_info *upd_info)
{ … }
static
void sa_set_swinfo(u8 eng_id, u16 sc_id, dma_addr_t sc_phys,
u8 cmdl_present, u8 cmdl_offset, u8 flags,
u8 hash_size, u32 *swinfo)
{ … }
static void sa_dump_sc(u8 *buf, dma_addr_t dma_addr)
{ … }
static
int sa_init_sc(struct sa_ctx_info *ctx, const struct sa_match_data *match_data,
const u8 *enc_key, u16 enc_key_sz,
const u8 *auth_key, u16 auth_key_sz,
struct algo_data *ad, u8 enc, u32 *swinfo)
{ … }
static void sa_free_ctx_info(struct sa_ctx_info *ctx,
struct sa_crypto_data *data)
{ … }
static int sa_init_ctx_info(struct sa_ctx_info *ctx,
struct sa_crypto_data *data)
{ … }
static void sa_cipher_cra_exit(struct crypto_skcipher *tfm)
{ … }
static int sa_cipher_cra_init(struct crypto_skcipher *tfm)
{ … }
static int sa_cipher_setkey(struct crypto_skcipher *tfm, const u8 *key,
unsigned int keylen, struct algo_data *ad)
{ … }
static int sa_aes_cbc_setkey(struct crypto_skcipher *tfm, const u8 *key,
unsigned int keylen)
{ … }
static int sa_aes_ecb_setkey(struct crypto_skcipher *tfm, const u8 *key,
unsigned int keylen)
{ … }
static int sa_3des_cbc_setkey(struct crypto_skcipher *tfm, const u8 *key,
unsigned int keylen)
{ … }
static int sa_3des_ecb_setkey(struct crypto_skcipher *tfm, const u8 *key,
unsigned int keylen)
{ … }
static void sa_sync_from_device(struct sa_rx_data *rxd)
{ … }
static void sa_free_sa_rx_data(struct sa_rx_data *rxd)
{ … }
static void sa_aes_dma_in_callback(void *data)
{ … }
static void
sa_prepare_tx_desc(u32 *mdptr, u32 pslen, u32 *psdata, u32 epiblen, u32 *epib)
{ … }
static int sa_run(struct sa_req *req)
{ … }
static int sa_cipher_run(struct skcipher_request *req, u8 *iv, int enc)
{ … }
static int sa_encrypt(struct skcipher_request *req)
{ … }
static int sa_decrypt(struct skcipher_request *req)
{ … }
static void sa_sha_dma_in_callback(void *data)
{ … }
static int zero_message_process(struct ahash_request *req)
{ … }
static int sa_sha_run(struct ahash_request *req)
{ … }
static int sa_sha_setup(struct sa_tfm_ctx *ctx, struct algo_data *ad)
{ … }
static int sa_sha_cra_init_alg(struct crypto_tfm *tfm, const char *alg_base)
{ … }
static int sa_sha_digest(struct ahash_request *req)
{ … }
static int sa_sha_init(struct ahash_request *req)
{ … }
static int sa_sha_update(struct ahash_request *req)
{ … }
static int sa_sha_final(struct ahash_request *req)
{ … }
static int sa_sha_finup(struct ahash_request *req)
{ … }
static int sa_sha_import(struct ahash_request *req, const void *in)
{ … }
static int sa_sha_export(struct ahash_request *req, void *out)
{ … }
static int sa_sha1_cra_init(struct crypto_tfm *tfm)
{ … }
static int sa_sha256_cra_init(struct crypto_tfm *tfm)
{ … }
static int sa_sha512_cra_init(struct crypto_tfm *tfm)
{ … }
static void sa_sha_cra_exit(struct crypto_tfm *tfm)
{ … }
static void sa_aead_dma_in_callback(void *data)
{ … }
static int sa_cra_init_aead(struct crypto_aead *tfm, const char *hash,
const char *fallback)
{ … }
static int sa_cra_init_aead_sha1(struct crypto_aead *tfm)
{ … }
static int sa_cra_init_aead_sha256(struct crypto_aead *tfm)
{ … }
static void sa_exit_tfm_aead(struct crypto_aead *tfm)
{ … }
static int sa_aead_setkey(struct crypto_aead *authenc,
const u8 *key, unsigned int keylen,
struct algo_data *ad)
{ … }
static int sa_aead_setauthsize(struct crypto_aead *tfm, unsigned int authsize)
{ … }
static int sa_aead_cbc_sha1_setkey(struct crypto_aead *authenc,
const u8 *key, unsigned int keylen)
{ … }
static int sa_aead_cbc_sha256_setkey(struct crypto_aead *authenc,
const u8 *key, unsigned int keylen)
{ … }
static int sa_aead_run(struct aead_request *req, u8 *iv, int enc)
{ … }
static int sa_aead_encrypt(struct aead_request *req)
{ … }
static int sa_aead_decrypt(struct aead_request *req)
{ … }
static struct sa_alg_tmpl sa_algs[] = …;
static void sa_register_algos(struct sa_crypto_data *dev_data)
{ … }
static void sa_unregister_algos(const struct device *dev)
{ … }
static int sa_init_mem(struct sa_crypto_data *dev_data)
{ … }
static int sa_dma_init(struct sa_crypto_data *dd)
{ … }
static int sa_link_child(struct device *dev, void *data)
{ … }
static struct sa_match_data am654_match_data = …;
static struct sa_match_data am64_match_data = …;
static const struct of_device_id of_match[] = …;
MODULE_DEVICE_TABLE(of, of_match);
static int sa_ul_probe(struct platform_device *pdev)
{ … }
static void sa_ul_remove(struct platform_device *pdev)
{ … }
static struct platform_driver sa_ul_driver = …;
module_platform_driver(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;