xref: /openbmc/u-boot/drivers/crypto/fsl/jr.h (revision ed09a554)
1 /*
2  * Copyright 2008-2014 Freescale Semiconductor, Inc.
3  *
4  * SPDX-License-Identifier:	GPL-2.0+
5  *
6  */
7 
8 #ifndef __JR_H
9 #define __JR_H
10 
11 #include <linux/compiler.h>
12 
13 #define JR_SIZE 4
14 /* Timeout currently defined as 90 sec */
15 #define CONFIG_SEC_DEQ_TIMEOUT	90000000U
16 
17 #define DEFAULT_JR_ID		0
18 #define DEFAULT_JR_LIODN	0
19 #define DEFAULT_IRQ		0	/* Interrupts not to be configured */
20 
21 #define MCFGR_SWRST       ((uint32_t)(1)<<31) /* Software Reset */
22 #define MCFGR_DMA_RST     ((uint32_t)(1)<<28) /* DMA Reset */
23 #define MCFGR_PS_SHIFT          16
24 #define JR_INTMASK	  0x00000001
25 #define JRCR_RESET                  0x01
26 #define JRINT_ERR_HALT_INPROGRESS   0x4
27 #define JRINT_ERR_HALT_MASK         0xc
28 #define JRNSLIODN_SHIFT		16
29 #define JRNSLIODN_MASK		0x0fff0000
30 #define JRSLIODN_SHIFT		0
31 #define JRSLIODN_MASK		0x00000fff
32 
33 #define JQ_DEQ_ERR		-1
34 #define JQ_DEQ_TO_ERR		-2
35 #define JQ_ENQ_ERR		-3
36 
37 struct op_ring {
38 	dma_addr_t desc;
39 	uint32_t status;
40 } __packed;
41 
42 struct jr_info {
43 	void (*callback)(dma_addr_t desc, uint32_t status, void *arg);
44 	dma_addr_t desc_phys_addr;
45 	uint32_t desc_addr;
46 	uint32_t desc_len;
47 	uint32_t op_done;
48 	void *arg;
49 };
50 
51 struct jobring {
52 	int jq_id;
53 	int irq;
54 	int liodn;
55 	/* Head is the index where software would enq the descriptor in
56 	 * the i/p ring
57 	 */
58 	int head;
59 	/* Tail index would be used by s/w ehile enqueuing to determine if
60 	 * there is any space left in the s/w maintained i/p rings
61 	 */
62 	/* Also in case of deq tail will be incremented only in case of
63 	 * in-order job completion
64 	 */
65 	int tail;
66 	/* Read index of the output ring. It may not match with tail in case
67 	 * of out of order completetion
68 	 */
69 	int read_idx;
70 	/* Write index to input ring. Would be always equal to head */
71 	int write_idx;
72 	/* Size of the rings. */
73 	int size;
74 	/* The ip and output rings have to be accessed by SEC. So the
75 	 * pointers will ahve to point to the housekeeping region provided
76 	 * by SEC
77 	 */
78 	/*Circular  Ring of i/p descriptors */
79 	dma_addr_t *input_ring;
80 	/* Circular Ring of o/p descriptors */
81 	/* Circula Ring containing info regarding descriptors in i/p
82 	 * and o/p ring
83 	 */
84 	/* This ring can be on the stack */
85 	struct jr_info info[JR_SIZE];
86 	struct op_ring *output_ring;
87 };
88 
89 struct result {
90 	int done;
91 	uint32_t status;
92 };
93 
94 void caam_jr_strstatus(u32 status);
95 int run_descriptor_jr(uint32_t *desc);
96 
97 #endif
98