1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) */
2 /* Copyright(c) 2014 - 2020 Intel Corporation */
3 #ifndef ADF_TRANSPORT_INTRN_H
4 #define ADF_TRANSPORT_INTRN_H
5 
6 #include <linux/interrupt.h>
7 #include <linux/spinlock_types.h>
8 #include "adf_transport.h"
9 
10 struct adf_etr_ring_debug_entry {
11 	char ring_name[ADF_CFG_MAX_KEY_LEN_IN_BYTES];
12 	struct dentry *debug;
13 };
14 
15 struct adf_etr_ring_data {
16 	void *base_addr;
17 	atomic_t *inflights;
18 	adf_callback_fn callback;
19 	struct adf_etr_bank_data *bank;
20 	dma_addr_t dma_addr;
21 	struct adf_etr_ring_debug_entry *ring_debug;
22 	spinlock_t lock;	/* protects ring data struct */
23 	u16 head;
24 	u16 tail;
25 	u32 threshold;
26 	u8 ring_number;
27 	u8 ring_size;
28 	u8 msg_size;
29 };
30 
31 struct adf_etr_bank_data {
32 	struct adf_etr_ring_data *rings;
33 	struct tasklet_struct resp_handler;
34 	void __iomem *csr_addr;
35 	u32 irq_coalesc_timer;
36 	u32 bank_number;
37 	u16 ring_mask;
38 	u16 irq_mask;
39 	spinlock_t lock;	/* protects bank data struct */
40 	struct adf_accel_dev *accel_dev;
41 	struct dentry *bank_debug_dir;
42 	struct dentry *bank_debug_cfg;
43 };
44 
45 struct adf_etr_data {
46 	struct adf_etr_bank_data *banks;
47 	struct dentry *debug;
48 };
49 
50 void adf_response_handler(uintptr_t bank_addr);
51 #ifdef CONFIG_DEBUG_FS
52 #include <linux/debugfs.h>
53 int adf_bank_debugfs_add(struct adf_etr_bank_data *bank);
54 void adf_bank_debugfs_rm(struct adf_etr_bank_data *bank);
55 int adf_ring_debugfs_add(struct adf_etr_ring_data *ring, const char *name);
56 void adf_ring_debugfs_rm(struct adf_etr_ring_data *ring);
57 #else
adf_bank_debugfs_add(struct adf_etr_bank_data * bank)58 static inline int adf_bank_debugfs_add(struct adf_etr_bank_data *bank)
59 {
60 	return 0;
61 }
62 
63 #define adf_bank_debugfs_rm(bank) do {} while (0)
64 
adf_ring_debugfs_add(struct adf_etr_ring_data * ring,const char * name)65 static inline int adf_ring_debugfs_add(struct adf_etr_ring_data *ring,
66 				       const char *name)
67 {
68 	return 0;
69 }
70 
71 #define adf_ring_debugfs_rm(ring) do {} while (0)
72 #endif
73 #endif
74