Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Ruchika Gupta | b9eebfa | 2014-10-15 11:35:30 +0530 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2008-2014 Freescale Semiconductor, Inc. |
| 4 | * |
Ruchika Gupta | b9eebfa | 2014-10-15 11:35:30 +0530 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef __JR_H |
| 8 | #define __JR_H |
| 9 | |
| 10 | #include <linux/compiler.h> |
| 11 | |
| 12 | #define JR_SIZE 4 |
| 13 | /* Timeout currently defined as 90 sec */ |
| 14 | #define CONFIG_SEC_DEQ_TIMEOUT 90000000U |
| 15 | |
| 16 | #define DEFAULT_JR_ID 0 |
| 17 | #define DEFAULT_JR_LIODN 0 |
| 18 | #define DEFAULT_IRQ 0 /* Interrupts not to be configured */ |
| 19 | |
| 20 | #define MCFGR_SWRST ((uint32_t)(1)<<31) /* Software Reset */ |
| 21 | #define MCFGR_DMA_RST ((uint32_t)(1)<<28) /* DMA Reset */ |
| 22 | #define MCFGR_PS_SHIFT 16 |
horia.geanta@freescale.com | 3ef2412 | 2015-07-08 17:24:57 +0300 | [diff] [blame] | 23 | #define MCFGR_AWCACHE_SHIFT 8 |
| 24 | #define MCFGR_AWCACHE_MASK (0xf << MCFGR_AWCACHE_SHIFT) |
Saksham Jain | 8a6f83d | 2016-03-23 16:24:42 +0530 | [diff] [blame] | 25 | #define MCFGR_ARCACHE_SHIFT 12 |
| 26 | #define MCFGR_ARCACHE_MASK (0xf << MCFGR_ARCACHE_SHIFT) |
| 27 | |
Ruchika Gupta | b9eebfa | 2014-10-15 11:35:30 +0530 | [diff] [blame] | 28 | #define JR_INTMASK 0x00000001 |
| 29 | #define JRCR_RESET 0x01 |
| 30 | #define JRINT_ERR_HALT_INPROGRESS 0x4 |
| 31 | #define JRINT_ERR_HALT_MASK 0xc |
| 32 | #define JRNSLIODN_SHIFT 16 |
| 33 | #define JRNSLIODN_MASK 0x0fff0000 |
| 34 | #define JRSLIODN_SHIFT 0 |
| 35 | #define JRSLIODN_MASK 0x00000fff |
| 36 | |
| 37 | #define JQ_DEQ_ERR -1 |
| 38 | #define JQ_DEQ_TO_ERR -2 |
| 39 | #define JQ_ENQ_ERR -3 |
| 40 | |
Lukas Auer | dfaec76 | 2018-01-25 14:11:17 +0100 | [diff] [blame] | 41 | #define RNG4_MAX_HANDLES 2 |
| 42 | |
Ruchika Gupta | b9eebfa | 2014-10-15 11:35:30 +0530 | [diff] [blame] | 43 | struct op_ring { |
Aneesh Bansal | f59e69c | 2015-10-29 22:58:03 +0530 | [diff] [blame] | 44 | phys_addr_t desc; |
Ruchika Gupta | b9eebfa | 2014-10-15 11:35:30 +0530 | [diff] [blame] | 45 | uint32_t status; |
| 46 | } __packed; |
| 47 | |
| 48 | struct jr_info { |
Aneesh Bansal | f59e69c | 2015-10-29 22:58:03 +0530 | [diff] [blame] | 49 | void (*callback)(uint32_t status, void *arg); |
| 50 | phys_addr_t desc_phys_addr; |
Ruchika Gupta | b9eebfa | 2014-10-15 11:35:30 +0530 | [diff] [blame] | 51 | uint32_t desc_len; |
| 52 | uint32_t op_done; |
| 53 | void *arg; |
| 54 | }; |
| 55 | |
| 56 | struct jobring { |
| 57 | int jq_id; |
| 58 | int irq; |
| 59 | int liodn; |
| 60 | /* Head is the index where software would enq the descriptor in |
| 61 | * the i/p ring |
| 62 | */ |
| 63 | int head; |
| 64 | /* Tail index would be used by s/w ehile enqueuing to determine if |
| 65 | * there is any space left in the s/w maintained i/p rings |
| 66 | */ |
| 67 | /* Also in case of deq tail will be incremented only in case of |
| 68 | * in-order job completion |
| 69 | */ |
| 70 | int tail; |
| 71 | /* Read index of the output ring. It may not match with tail in case |
| 72 | * of out of order completetion |
| 73 | */ |
| 74 | int read_idx; |
| 75 | /* Write index to input ring. Would be always equal to head */ |
| 76 | int write_idx; |
| 77 | /* Size of the rings. */ |
| 78 | int size; |
Ruchika Gupta | 7f4736b | 2016-01-22 16:12:55 +0530 | [diff] [blame] | 79 | /* Op ring size aligned to cache line size */ |
| 80 | int op_size; |
Ruchika Gupta | b9eebfa | 2014-10-15 11:35:30 +0530 | [diff] [blame] | 81 | /* The ip and output rings have to be accessed by SEC. So the |
| 82 | * pointers will ahve to point to the housekeeping region provided |
| 83 | * by SEC |
| 84 | */ |
| 85 | /*Circular Ring of i/p descriptors */ |
| 86 | dma_addr_t *input_ring; |
| 87 | /* Circular Ring of o/p descriptors */ |
| 88 | /* Circula Ring containing info regarding descriptors in i/p |
| 89 | * and o/p ring |
| 90 | */ |
| 91 | /* This ring can be on the stack */ |
| 92 | struct jr_info info[JR_SIZE]; |
| 93 | struct op_ring *output_ring; |
Alex Porosanu | 76394c9 | 2016-04-29 15:18:00 +0300 | [diff] [blame] | 94 | /* Offset in CCSR to the SEC engine to which this JR belongs */ |
| 95 | uint32_t sec_offset; |
| 96 | |
Ruchika Gupta | b9eebfa | 2014-10-15 11:35:30 +0530 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | struct result { |
| 100 | int done; |
| 101 | uint32_t status; |
| 102 | }; |
| 103 | |
| 104 | void caam_jr_strstatus(u32 status); |
| 105 | int run_descriptor_jr(uint32_t *desc); |
| 106 | |
| 107 | #endif |