1
2
3
4
5
6
7
8
9
10#ifndef INTERN_H
11#define INTERN_H
12
13
14#define JOBR_DEPTH (1 << CONFIG_CRYPTO_DEV_FSL_CAAM_RINGSIZE)
15
16
17#ifdef CONFIG_CRYPTO_DEV_FSL_CAAM_INTC
18#define JOBR_INTC JRCFG_ICEN
19#define JOBR_INTC_TIME_THLD CONFIG_CRYPTO_DEV_FSL_CAAM_INTC_TIME_THLD
20#define JOBR_INTC_COUNT_THLD CONFIG_CRYPTO_DEV_FSL_CAAM_INTC_COUNT_THLD
21#else
22#define JOBR_INTC 0
23#define JOBR_INTC_TIME_THLD 0
24#define JOBR_INTC_COUNT_THLD 0
25#endif
26
27
28
29
30
31struct caam_jrentry_info {
32 void (*callbk)(struct device *dev, u32 *desc, u32 status, void *arg);
33 void *cbkarg;
34 u32 *desc_addr_virt;
35 dma_addr_t desc_addr_dma;
36 u32 desc_size;
37};
38
39
40struct caam_drv_private_jr {
41 struct list_head list_node;
42 struct device *dev;
43 int ridx;
44 struct caam_job_ring __iomem *rregs;
45 struct tasklet_struct irqtask;
46 int irq;
47
48
49 atomic_t tfm_count ____cacheline_aligned;
50
51
52 int ringsize;
53 struct caam_jrentry_info *entinfo;
54 spinlock_t inplock ____cacheline_aligned;
55 int inp_ring_write_index;
56 int head;
57 dma_addr_t *inpring;
58 spinlock_t outlock ____cacheline_aligned;
59 int out_ring_read_index;
60 int tail;
61 struct jr_outentry *outring;
62};
63
64
65
66
67struct caam_drv_private {
68#ifdef CONFIG_CAAM_QI
69 struct device *qidev;
70#endif
71
72
73 struct caam_ctrl __iomem *ctrl;
74 struct caam_deco __iomem *deco;
75 struct caam_assurance __iomem *assure;
76 struct caam_queue_if __iomem *qi;
77 struct caam_job_ring __iomem *jr[4];
78
79
80
81
82
83 u8 total_jobrs;
84 u8 qi_present;
85 u8 mc_en;
86 int secvio_irq;
87 int virt_en;
88 int era;
89
90#define RNG4_MAX_HANDLES 2
91
92 u32 rng4_sh_init;
93
94
95
96 struct clk *caam_ipg;
97 struct clk *caam_mem;
98 struct clk *caam_aclk;
99 struct clk *caam_emi_slow;
100
101
102
103
104
105#ifdef CONFIG_DEBUG_FS
106 struct dentry *dfs_root;
107 struct dentry *ctl;
108 struct debugfs_blob_wrapper ctl_kek_wrap, ctl_tkek_wrap, ctl_tdsk_wrap;
109#endif
110};
111
112void caam_jr_algapi_init(struct device *dev);
113void caam_jr_algapi_remove(struct device *dev);
114
115#ifdef CONFIG_DEBUG_FS
116static int caam_debugfs_u64_get(void *data, u64 *val)
117{
118 *val = caam64_to_cpu(*(u64 *)data);
119 return 0;
120}
121
122static int caam_debugfs_u32_get(void *data, u64 *val)
123{
124 *val = caam32_to_cpu(*(u32 *)data);
125 return 0;
126}
127
128DEFINE_SIMPLE_ATTRIBUTE(caam_fops_u32_ro, caam_debugfs_u32_get, NULL, "%llu\n");
129DEFINE_SIMPLE_ATTRIBUTE(caam_fops_u64_ro, caam_debugfs_u64_get, NULL, "%llu\n");
130#endif
131
132#endif
133