Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Keystone Navigator QMSS driver internal header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Author:	Sandeep Nair <sandeep_n@ti.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *		Cyril Chemparathy <cyril@ti.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *		Santosh Shilimkar <santosh.shilimkar@ti.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #ifndef __KNAV_QMSS_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #define __KNAV_QMSS_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/percpu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #define THRESH_GTE	BIT(7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #define THRESH_LT	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #define PDSP_CTRL_PC_MASK	0xffff0000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #define PDSP_CTRL_SOFT_RESET	BIT(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #define PDSP_CTRL_ENABLE	BIT(1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #define PDSP_CTRL_RUNNING	BIT(15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #define ACC_MAX_CHANNEL		48
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #define ACC_DEFAULT_PERIOD	25 /* usecs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #define ACC_CHANNEL_INT_BASE		2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #define ACC_LIST_ENTRY_TYPE		1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #define ACC_LIST_ENTRY_WORDS		(1 << ACC_LIST_ENTRY_TYPE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #define ACC_LIST_ENTRY_QUEUE_IDX	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #define ACC_LIST_ENTRY_DESC_IDX	(ACC_LIST_ENTRY_WORDS - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #define ACC_CMD_DISABLE_CHANNEL	0x80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #define ACC_CMD_ENABLE_CHANNEL	0x81
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #define ACC_CFG_MULTI_QUEUE		BIT(21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #define ACC_INTD_OFFSET_EOI		(0x0010)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #define ACC_INTD_OFFSET_COUNT(ch)	(0x0300 + 4 * (ch))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #define ACC_INTD_OFFSET_STATUS(ch)	(0x0200 + 4 * ((ch) / 32))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #define RANGE_MAX_IRQS			64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #define ACC_DESCS_MAX		SZ_1K
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #define ACC_DESCS_MASK		(ACC_DESCS_MAX - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #define DESC_SIZE_MASK		0xful
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #define DESC_PTR_MASK		(~DESC_SIZE_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #define KNAV_NAME_SIZE			32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) enum knav_acc_result {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	ACC_RET_IDLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	ACC_RET_SUCCESS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	ACC_RET_INVALID_COMMAND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	ACC_RET_INVALID_CHANNEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	ACC_RET_INACTIVE_CHANNEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	ACC_RET_ACTIVE_CHANNEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	ACC_RET_INVALID_QUEUE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	ACC_RET_INVALID_RET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) struct knav_reg_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	u32		revision;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	u32		__pad1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	u32		divert;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	u32		link_ram_base0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	u32		link_ram_size0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	u32		link_ram_base1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	u32		__pad2[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	u32		starvation[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) struct knav_reg_region {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	u32		base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	u32		start_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	u32		size_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	u32		__pad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) struct knav_reg_pdsp_regs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	u32		control;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	u32		status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	u32		cycle_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	u32		stall_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) struct knav_reg_acc_command {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	u32		command;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	u32		queue_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	u32		list_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	u32		queue_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	u32		timer_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) struct knav_link_ram_block {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	dma_addr_t	 dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	void		*virt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	size_t		 size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) struct knav_acc_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	u32			 pdsp_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	u32			 start_channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	u32			 list_entries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	u32			 pacing_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	u32			 timer_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	int			 mem_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	int			 list_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	struct knav_pdsp_info	*pdsp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) struct knav_acc_channel {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	u32			channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	u32			list_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	u32			open_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	u32			*list_cpu[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	dma_addr_t		list_dma[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	char			name[KNAV_NAME_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	atomic_t		retrigger_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) struct knav_pdsp_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	const char					*name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	struct knav_reg_pdsp_regs  __iomem		*regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		void __iomem				*command;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		struct knav_reg_acc_command __iomem	*acc_command;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		u32 __iomem				*qos_command;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	void __iomem					*intd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	u32 __iomem					*iram;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	u32						id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	struct list_head				list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	bool						loaded;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	bool						started;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) struct knav_qmgr_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	unsigned			start_queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	unsigned			num_queues;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	struct knav_reg_config __iomem	*reg_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	struct knav_reg_region __iomem	*reg_region;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	struct knav_reg_queue __iomem	*reg_push, *reg_pop, *reg_peek;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	void __iomem			*reg_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	struct list_head		list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) #define KNAV_NUM_LINKRAM	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)  * struct knav_queue_stats:	queue statistics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)  * pushes:			number of push operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)  * pops:			number of pop operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)  * push_errors:			number of push errors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)  * pop_errors:			number of pop errors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)  * notifies:			notifier counts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) struct knav_queue_stats {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	unsigned int pushes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	unsigned int pops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	unsigned int push_errors;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	unsigned int pop_errors;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	unsigned int notifies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)  * struct knav_reg_queue:	queue registers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)  * @entry_count:		valid entries in the queue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)  * @byte_count:			total byte count in thhe queue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)  * @packet_size:		packet size for the queue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)  * @ptr_size_thresh:		packet pointer size threshold
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) struct knav_reg_queue {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	u32		entry_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	u32		byte_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	u32		packet_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	u32		ptr_size_thresh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)  * struct knav_region:		qmss region info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)  * @dma_start, dma_end:		start and end dma address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)  * @virt_start, virt_end:	start and end virtual address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)  * @desc_size:			descriptor size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)  * @used_desc:			consumed descriptors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)  * @id:				region number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)  * @num_desc:			total descriptors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)  * @link_index:			index of the first descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)  * @name:			region name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)  * @list:			instance in the device's region list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)  * @pools:			list of descriptor pools in the region
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) struct knav_region {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	dma_addr_t		dma_start, dma_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	void			*virt_start, *virt_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	unsigned		desc_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	unsigned		used_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	unsigned		id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	unsigned		num_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	unsigned		link_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	const char		*name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	struct list_head	list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	struct list_head	pools;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)  * struct knav_pool:		qmss pools
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)  * @dev:			device pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)  * @region:			qmss region info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)  * @queue:			queue registers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)  * @kdev:			qmss device pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)  * @region_offset:		offset from the base
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)  * @num_desc:			total descriptors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)  * @desc_size:			descriptor size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)  * @region_id:			region number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)  * @name:			pool name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)  * @list:			list head
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)  * @region_inst:		instance in the region's pool list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) struct knav_pool {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	struct device			*dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	struct knav_region		*region;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	struct knav_queue		*queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	struct knav_device		*kdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	int				region_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	int				num_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	int				desc_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	int				region_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	const char			*name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	struct list_head		list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	struct list_head		region_inst;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)  * struct knav_queue_inst:		qmss queue instance properties
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)  * @descs:				descriptor pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)  * @desc_head, desc_tail, desc_count:	descriptor counters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)  * @acc:				accumulator channel pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)  * @kdev:				qmss device pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)  * @range:				range info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)  * @qmgr:				queue manager info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)  * @id:					queue instance id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)  * @irq_num:				irq line number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)  * @notify_needed:			notifier needed based on queue type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)  * @num_notifiers:			total notifiers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)  * @handles:				list head
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)  * @name:				queue instance name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)  * @irq_name:				irq line name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) struct knav_queue_inst {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	u32				*descs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	atomic_t			desc_head, desc_tail, desc_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	struct knav_acc_channel	*acc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	struct knav_device		*kdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	struct knav_range_info		*range;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	struct knav_qmgr_info		*qmgr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	u32				id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	int				irq_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	int				notify_needed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	atomic_t			num_notifiers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	struct list_head		handles;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	const char			*name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	const char			*irq_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)  * struct knav_queue:			qmss queue properties
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)  * @reg_push, reg_pop, reg_peek:	push, pop queue registers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)  * @inst:				qmss queue instance properties
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)  * @notifier_fn:			notifier function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)  * @notifier_fn_arg:			notifier function argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)  * @notifier_enabled:			notier enabled for a give queue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)  * @rcu:				rcu head
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)  * @flags:				queue flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)  * @list:				list head
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) struct knav_queue {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	struct knav_reg_queue __iomem	*reg_push, *reg_pop, *reg_peek;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	struct knav_queue_inst		*inst;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	struct knav_queue_stats __percpu	*stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	knav_queue_notify_fn		notifier_fn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	void				*notifier_fn_arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	atomic_t			notifier_enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	struct rcu_head			rcu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	unsigned			flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	struct list_head		list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) enum qmss_version {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	QMSS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	QMSS_66AK2G,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) struct knav_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	struct device				*dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	unsigned				base_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	unsigned				num_queues;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	unsigned				num_queues_in_use;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	unsigned				inst_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	struct knav_link_ram_block		link_rams[KNAV_NUM_LINKRAM];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	void					*instances;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	struct list_head			regions;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	struct list_head			queue_ranges;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	struct list_head			pools;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	struct list_head			pdsps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	struct list_head			qmgrs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	enum qmss_version			version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) struct knav_range_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	int	(*init_range)(struct knav_range_info *range);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	int	(*free_range)(struct knav_range_info *range);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	int	(*init_queue)(struct knav_range_info *range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 			      struct knav_queue_inst *inst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	int	(*open_queue)(struct knav_range_info *range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 			      struct knav_queue_inst *inst, unsigned flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	int	(*close_queue)(struct knav_range_info *range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 			       struct knav_queue_inst *inst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	int	(*set_notify)(struct knav_range_info *range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 			      struct knav_queue_inst *inst, bool enabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) struct knav_irq_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	int		irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	struct cpumask	*cpu_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) struct knav_range_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	const char			*name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	struct knav_device		*kdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	unsigned			queue_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	unsigned			num_queues;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	void				*queue_base_inst;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	unsigned			flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	struct list_head		list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	struct knav_range_ops		*ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	struct knav_acc_info		acc_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	struct knav_acc_channel	*acc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	unsigned			num_irqs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	struct knav_irq_info		irqs[RANGE_MAX_IRQS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) #define RANGE_RESERVED		BIT(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) #define RANGE_HAS_IRQ		BIT(1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) #define RANGE_HAS_ACCUMULATOR	BIT(2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) #define RANGE_MULTI_QUEUE	BIT(3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) #define for_each_region(kdev, region)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	list_for_each_entry(region, &kdev->regions, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) #define first_region(kdev)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	list_first_entry_or_null(&kdev->regions, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 				 struct knav_region, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) #define for_each_queue_range(kdev, range)			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	list_for_each_entry(range, &kdev->queue_ranges, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) #define first_queue_range(kdev)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	list_first_entry_or_null(&kdev->queue_ranges, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 				 struct knav_range_info, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) #define for_each_pool(kdev, pool)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	list_for_each_entry(pool, &kdev->pools, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) #define for_each_pdsp(kdev, pdsp)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	list_for_each_entry(pdsp, &kdev->pdsps, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) #define for_each_qmgr(kdev, qmgr)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	list_for_each_entry(qmgr, &kdev->qmgrs, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) static inline struct knav_pdsp_info *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) knav_find_pdsp(struct knav_device *kdev, unsigned pdsp_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	struct knav_pdsp_info *pdsp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	for_each_pdsp(kdev, pdsp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 		if (pdsp_id == pdsp->id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 			return pdsp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) extern int knav_init_acc_range(struct knav_device *kdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 					struct device_node *node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 					struct knav_range_info *range);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) extern void knav_queue_notify(struct knav_queue_inst *inst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) #endif /* __KNAV_QMSS_H__ */