crypto: caam - remove unused sg_to_sec4_sg_len()
[linux-2.6-block.git] / drivers / crypto / caam / sg_sw_sec4.h
CommitLineData
4c1ec1f9
YK
1/*
2 * CAAM/SEC 4.x functions for using scatterlists in caam driver
3 *
4 * Copyright 2008-2011 Freescale Semiconductor, Inc.
5 *
6 */
7
261ea058
HG
8#include "regs.h"
9
e25ff92e
HG
10struct sec4_sg_entry {
11 u64 ptr;
12 u32 len;
13 u32 bpid_offset;
14};
4c1ec1f9
YK
15
16/*
17 * convert single dma address to h/w link table format
18 */
a299c837 19static inline void dma_to_sec4_sg_one(struct sec4_sg_entry *sec4_sg_ptr,
bd52f1c2 20 dma_addr_t dma, u32 len, u16 offset)
4c1ec1f9 21{
f97581cf 22 sec4_sg_ptr->ptr = cpu_to_caam_dma64(dma);
261ea058
HG
23 sec4_sg_ptr->len = cpu_to_caam32(len);
24 sec4_sg_ptr->bpid_offset = cpu_to_caam32(offset & SEC4_SG_OFFSET_MASK);
4c1ec1f9 25#ifdef DEBUG
a299c837
YK
26 print_hex_dump(KERN_ERR, "sec4_sg_ptr@: ",
27 DUMP_PREFIX_ADDRESS, 16, 4, sec4_sg_ptr,
28 sizeof(struct sec4_sg_entry), 1);
4c1ec1f9
YK
29#endif
30}
31
32/*
33 * convert scatterlist to h/w link table format
34 * but does not have final bit; instead, returns last entry
35 */
a299c837
YK
36static inline struct sec4_sg_entry *
37sg_to_sec4_sg(struct scatterlist *sg, int sg_count,
bd52f1c2 38 struct sec4_sg_entry *sec4_sg_ptr, u16 offset)
4c1ec1f9
YK
39{
40 while (sg_count) {
a299c837 41 dma_to_sec4_sg_one(sec4_sg_ptr, sg_dma_address(sg),
4c1ec1f9 42 sg_dma_len(sg), offset);
a299c837 43 sec4_sg_ptr++;
5be4d4c9 44 sg = sg_next(sg);
4c1ec1f9
YK
45 sg_count--;
46 }
a299c837 47 return sec4_sg_ptr - 1;
4c1ec1f9
YK
48}
49
50/*
51 * convert scatterlist to h/w link table format
52 * scatterlist must have been previously dma mapped
53 */
a299c837
YK
54static inline void sg_to_sec4_sg_last(struct scatterlist *sg, int sg_count,
55 struct sec4_sg_entry *sec4_sg_ptr,
bd52f1c2 56 u16 offset)
4c1ec1f9 57{
a299c837 58 sec4_sg_ptr = sg_to_sec4_sg(sg, sg_count, sec4_sg_ptr, offset);
261ea058 59 sec4_sg_ptr->len |= cpu_to_caam32(SEC4_SG_LEN_FIN);
4c1ec1f9 60}