blob: b781445d2fcca267704aef26e94623b2690301c5 [file] [log] [blame]
Kim Phillips8e8ec592011-03-13 16:54:26 +08001/*
2 * CAAM/SEC 4.x driver backend
3 * Private/internal definitions between modules
4 *
5 * Copyright 2008-2011 Freescale Semiconductor, Inc.
6 *
7 */
8
9#ifndef INTERN_H
10#define INTERN_H
11
Kim Phillips8e8ec592011-03-13 16:54:26 +080012/* Currently comes from Kconfig param as a ^2 (driver-required) */
13#define JOBR_DEPTH (1 << CONFIG_CRYPTO_DEV_FSL_CAAM_RINGSIZE)
14
15/* Kconfig params for interrupt coalescing if selected (else zero) */
16#ifdef CONFIG_CRYPTO_DEV_FSL_CAAM_INTC
17#define JOBR_INTC JRCFG_ICEN
18#define JOBR_INTC_TIME_THLD CONFIG_CRYPTO_DEV_FSL_CAAM_INTC_TIME_THLD
19#define JOBR_INTC_COUNT_THLD CONFIG_CRYPTO_DEV_FSL_CAAM_INTC_COUNT_THLD
20#else
21#define JOBR_INTC 0
22#define JOBR_INTC_TIME_THLD 0
23#define JOBR_INTC_COUNT_THLD 0
24#endif
25
26/*
27 * Storage for tracking each in-process entry moving across a ring
28 * Each entry on an output ring needs one of these
29 */
30struct caam_jrentry_info {
31 void (*callbk)(struct device *dev, u32 *desc, u32 status, void *arg);
32 void *cbkarg; /* Argument per ring entry */
33 u32 *desc_addr_virt; /* Stored virt addr for postprocessing */
34 dma_addr_t desc_addr_dma; /* Stored bus addr for done matching */
35 u32 desc_size; /* Stored size for postprocessing, header derived */
36};
37
38/* Private sub-storage for a single JobR */
39struct caam_drv_private_jr {
Ruchika Gupta313ea292013-10-25 12:01:01 +053040 struct list_head list_node; /* Job Ring device list */
41 struct device *dev;
Kim Phillips8e8ec592011-03-13 16:54:26 +080042 int ridx;
43 struct caam_job_ring __iomem *rregs; /* JobR's register space */
Kim Phillipsa0ca6ca2012-06-22 19:48:57 -050044 struct tasklet_struct irqtask;
Kim Phillips8e8ec592011-03-13 16:54:26 +080045 int irq; /* One per queue */
Kim Phillips8e8ec592011-03-13 16:54:26 +080046
Ruchika Gupta07defbf2013-10-25 12:01:02 +053047 /* Number of scatterlist crypt transforms active on the JobR */
48 atomic_t tfm_count ____cacheline_aligned;
49
Kim Phillips8e8ec592011-03-13 16:54:26 +080050 /* Job ring info */
51 int ringsize; /* Size of rings (assume input = output) */
52 struct caam_jrentry_info *entinfo; /* Alloc'ed 1 per ring entry */
53 spinlock_t inplock ____cacheline_aligned; /* Input ring index lock */
54 int inp_ring_write_index; /* Input index "tail" */
55 int head; /* entinfo (s/w ring) head index */
56 dma_addr_t *inpring; /* Base of input ring, alloc DMA-safe */
57 spinlock_t outlock ____cacheline_aligned; /* Output ring index lock */
58 int out_ring_read_index; /* Output index "tail" */
59 int tail; /* entinfo (s/w ring) tail index */
60 struct jr_outentry *outring; /* Base of output ring, DMA-safe */
61};
62
63/*
64 * Driver-private storage for a single CAAM block instance
65 */
66struct caam_drv_private {
67
68 struct device *dev;
Ruchika Gupta313ea292013-10-25 12:01:01 +053069 struct platform_device **jrpdev; /* Alloc'ed array per sub-device */
Kim Phillips8e8ec592011-03-13 16:54:26 +080070 struct platform_device *pdev;
71
72 /* Physical-presence section */
73 struct caam_ctrl *ctrl; /* controller region */
74 struct caam_deco **deco; /* DECO/CCB views */
75 struct caam_assurance *ac;
76 struct caam_queue_if *qi; /* QI control region */
77
78 /*
79 * Detected geometry block. Filled in from device tree if powerpc,
80 * or from register-based version detection code
81 */
82 u8 total_jobrs; /* Total Job Rings in device */
83 u8 qi_present; /* Nonzero if QI present in device */
84 int secvio_irq; /* Security violation interrupt number */
85
86 /* which jr allocated to scatterlist crypto */
87 atomic_t tfm_count ____cacheline_aligned;
Kim Phillips8e8ec592011-03-13 16:54:26 +080088 /* list of registered crypto algorithms (mk generic context handle?) */
89 struct list_head alg_list;
Yuan Kang045e3672012-06-22 19:48:47 -050090 /* list of registered hash algorithms (mk generic context handle?) */
91 struct list_head hash_list;
Kim Phillips8e8ec592011-03-13 16:54:26 +080092
Alex Porosanu1005bcc2013-09-09 18:56:34 +030093#define RNG4_MAX_HANDLES 2
Alex Porosanub1f996e02013-09-09 18:56:32 +030094 /* RNG4 block */
Alex Porosanu1005bcc2013-09-09 18:56:34 +030095 u32 rng4_sh_init; /* This bitmap shows which of the State
96 Handles of the RNG4 block are initialized
97 by this driver */
Alex Porosanub1f996e02013-09-09 18:56:32 +030098
Kim Phillips8e8ec592011-03-13 16:54:26 +080099 /*
100 * debugfs entries for developer view into driver/device
101 * variables at runtime.
102 */
103#ifdef CONFIG_DEBUG_FS
104 struct dentry *dfs_root;
105 struct dentry *ctl; /* controller dir */
106 struct dentry *ctl_rq_dequeued, *ctl_ob_enc_req, *ctl_ib_dec_req;
107 struct dentry *ctl_ob_enc_bytes, *ctl_ob_prot_bytes;
108 struct dentry *ctl_ib_dec_bytes, *ctl_ib_valid_bytes;
109 struct dentry *ctl_faultaddr, *ctl_faultdetail, *ctl_faultstatus;
110
111 struct debugfs_blob_wrapper ctl_kek_wrap, ctl_tkek_wrap, ctl_tdsk_wrap;
112 struct dentry *ctl_kek, *ctl_tkek, *ctl_tdsk;
113#endif
114};
115
116void caam_jr_algapi_init(struct device *dev);
117void caam_jr_algapi_remove(struct device *dev);
118#endif /* INTERN_H */