.. | .. |
---|
10 | 10 | |
---|
11 | 11 | #include "mpp_rkvdec2.h" |
---|
12 | 12 | |
---|
| 13 | +#define RKVDEC_REG_IMPORTANT_BASE 0x2c |
---|
| 14 | +#define RKVDEC_REG_IMPORTANT_INDEX 11 |
---|
| 15 | +#define RKVDEC_SOFTREST_EN BIT(20) |
---|
| 16 | + |
---|
13 | 17 | #define RKVDEC_REG_SECOND_EN_BASE 0x30 |
---|
14 | 18 | #define RKVDEC_REG_SECOND_EN_INDEX 12 |
---|
15 | 19 | #define RKVDEC_WAIT_RESET_EN BIT(7) |
---|
| 20 | + |
---|
| 21 | +#define RKVDEC_REG_EN_MODE_SET 13 |
---|
| 22 | + |
---|
| 23 | +#define RKVDEC_REG_DEBUG_INT_BASE 0x440 |
---|
| 24 | +#define RKVDEC_REG_DEBUG_INT_INDEX 272 |
---|
| 25 | +#define RKVDEC_BIT_BUS_IDLE BIT(0) |
---|
| 26 | + |
---|
| 27 | +#define RKVDEC_REG_TIMEOUT_THRESHOLD 32 |
---|
16 | 28 | |
---|
17 | 29 | /* define for link hardware */ |
---|
18 | 30 | #define RKVDEC_LINK_ADD_CFG_NUM 1 |
---|
.. | .. |
---|
21 | 33 | #define RKVDEC_LINK_BIT_IRQ_DIS BIT(2) |
---|
22 | 34 | #define RKVDEC_LINK_BIT_IRQ BIT(8) |
---|
23 | 35 | #define RKVDEC_LINK_BIT_IRQ_RAW BIT(9) |
---|
| 36 | +#define RKVDEC_LINK_BIT_CORE_WORK_MODE BIT(16) |
---|
| 37 | +#define RKVDEC_LINK_BIT_CCU_WORK_MODE BIT(17) |
---|
24 | 38 | |
---|
25 | 39 | #define RKVDEC_LINK_CFG_ADDR_BASE 0x004 |
---|
26 | 40 | |
---|
.. | .. |
---|
43 | 57 | |
---|
44 | 58 | #define RKVDEC_LINK_REG_CYCLE_CNT 179 |
---|
45 | 59 | |
---|
| 60 | +/* define for ccu link hardware */ |
---|
| 61 | +#define RKVDEC_CCU_CTRL_BASE 0x000 |
---|
| 62 | +#define RKVDEC_CCU_BIT_AUTOGATE BIT(0) |
---|
| 63 | +#define RKVDEC_CCU_BIT_FIX_RCB BIT(20) |
---|
| 64 | + |
---|
| 65 | +#define RKVDEC_CCU_CFG_ADDR_BASE 0x004 |
---|
| 66 | +#define RKVDEC_CCU_LINK_MODE_BASE 0x008 |
---|
| 67 | +#define RKVDEC_CCU_BIT_ADD_MODE BIT(31) |
---|
| 68 | + |
---|
| 69 | +#define RKVDEC_CCU_CFG_DONE_BASE 0x00c |
---|
| 70 | +#define RKVDEC_CCU_BIT_CFG_DONE BIT(0) |
---|
| 71 | + |
---|
| 72 | +#define RKVDEC_CCU_DEC_NUM_BASE 0x010 |
---|
| 73 | +#define RKVDEC_CCU_TOTAL_NUM_BASE 0x014 |
---|
| 74 | + |
---|
| 75 | +#define RKVDEC_CCU_WORK_BASE 0x018 |
---|
| 76 | +#define RKVDEC_CCU_BIT_WORK_EN BIT(0) |
---|
| 77 | + |
---|
| 78 | +#define RKVDEC_CCU_SEND_NUM_BASE 0x024 |
---|
| 79 | +#define RKVDEC_CCU_WORK_MODE_BASE 0x040 |
---|
| 80 | +#define RKVDEC_CCU_BIT_WORK_MODE BIT(0) |
---|
| 81 | + |
---|
| 82 | +#define RKVDEC_CCU_CORE_WORK_BASE 0x044 |
---|
| 83 | +#define RKVDEC_CCU_CORE_STA_BASE 0x048 |
---|
| 84 | +#define RKVDEC_CCU_CORE_IDLE_BASE 0x04c |
---|
| 85 | +#define RKVDEC_CCU_CORE_ERR_BASE 0x054 |
---|
| 86 | + |
---|
| 87 | +#define RKVDEC_CCU_CORE_RW_MASK 0x30000 |
---|
| 88 | + |
---|
| 89 | +#define RKVDEC_MAX_WRITE_PART 6 |
---|
| 90 | +#define RKVDEC_MAX_READ_PART 2 |
---|
| 91 | + |
---|
| 92 | +struct rkvdec_link_part { |
---|
| 93 | + /* register offset of table buffer */ |
---|
| 94 | + u32 tb_reg_off; |
---|
| 95 | + /* start idx of task register */ |
---|
| 96 | + u32 reg_start; |
---|
| 97 | + /* number of task register */ |
---|
| 98 | + u32 reg_num; |
---|
| 99 | +}; |
---|
| 100 | + |
---|
| 101 | +struct rkvdec_link_status { |
---|
| 102 | + u32 dec_num_mask; |
---|
| 103 | + u32 err_flag_base; |
---|
| 104 | + u32 err_flag_bit; |
---|
| 105 | +}; |
---|
| 106 | + |
---|
| 107 | +struct rkvdec_link_info { |
---|
| 108 | + dma_addr_t iova; |
---|
| 109 | + /* total register for link table buffer */ |
---|
| 110 | + u32 tb_reg_num; |
---|
| 111 | + /* next link table addr in table buffer */ |
---|
| 112 | + u32 tb_reg_next; |
---|
| 113 | + /* current read back addr in table buffer */ |
---|
| 114 | + u32 tb_reg_r; |
---|
| 115 | + /* secondary enable in table buffer */ |
---|
| 116 | + u32 tb_reg_second_en; |
---|
| 117 | + u32 part_w_num; |
---|
| 118 | + u32 part_r_num; |
---|
| 119 | + |
---|
| 120 | + struct rkvdec_link_part part_w[RKVDEC_MAX_WRITE_PART]; |
---|
| 121 | + struct rkvdec_link_part part_r[RKVDEC_MAX_READ_PART]; |
---|
| 122 | + |
---|
| 123 | + /* interrupt read back in table buffer */ |
---|
| 124 | + u32 tb_reg_int; |
---|
| 125 | + u32 tb_reg_cycle; |
---|
| 126 | + bool hack_setup; |
---|
| 127 | + struct rkvdec_link_status reg_status; |
---|
| 128 | +}; |
---|
| 129 | + |
---|
46 | 130 | struct rkvdec_link_dev { |
---|
47 | 131 | struct device *dev; |
---|
48 | 132 | struct mpp_dev *mpp; |
---|
.. | .. |
---|
56 | 140 | u32 decoded; |
---|
57 | 141 | u32 total; |
---|
58 | 142 | u32 error; |
---|
59 | | - u32 stuff_err; |
---|
60 | | - u32 stuff_total; |
---|
61 | | - u32 stuff_on_error; |
---|
| 143 | + u32 hack_task_running; |
---|
62 | 144 | |
---|
63 | 145 | struct rkvdec_link_info *info; |
---|
64 | 146 | struct mpp_dma_buffer *table; |
---|
65 | 147 | u32 link_node_size; |
---|
66 | 148 | u32 link_reg_count; |
---|
67 | 149 | |
---|
68 | | - struct mpp_task **tasks_hw; |
---|
69 | | - u32 task_capacity; |
---|
70 | | - s32 task_total; |
---|
71 | | - s32 task_decoded; |
---|
72 | | - s32 task_size; |
---|
73 | | - s32 task_count; |
---|
74 | | - s32 task_write; |
---|
75 | | - s32 task_read; |
---|
76 | | - s32 task_send; |
---|
77 | | - s32 task_recv; |
---|
78 | | - |
---|
79 | 150 | /* taskqueue variables */ |
---|
80 | 151 | u32 task_running; |
---|
81 | | - u32 task_prepared; |
---|
82 | | - s32 task_to_run; |
---|
83 | | - u32 task_on_timeout; |
---|
84 | | - |
---|
85 | | - /* taskqueue trigger variables */ |
---|
86 | | - u32 task_irq; |
---|
87 | | - u32 task_irq_prev; |
---|
| 152 | + atomic_t task_pending; |
---|
88 | 153 | /* timeout can be trigger in different thread so atomic is needed */ |
---|
89 | 154 | atomic_t task_timeout; |
---|
90 | 155 | u32 task_timeout_prev; |
---|
.. | .. |
---|
99 | 164 | u32 task_cnt; |
---|
100 | 165 | u64 stuff_cycle_sum; |
---|
101 | 166 | u32 stuff_cnt; |
---|
| 167 | + |
---|
| 168 | + /* link info */ |
---|
| 169 | + u32 task_capacity; |
---|
| 170 | + struct mpp_dma_buffer *table_array; |
---|
| 171 | + struct list_head unused_list; |
---|
| 172 | + struct list_head used_list; |
---|
102 | 173 | }; |
---|
103 | 174 | |
---|
104 | | -extern struct rkvdec_link_info rkvdec_link_rk3568_hw_info; |
---|
| 175 | +enum RKVDEC2_CCU_MODE { |
---|
| 176 | + RKVDEC2_CCU_MODE_NULL = 0, |
---|
| 177 | + RKVDEC2_CCU_TASK_SOFT = 1, |
---|
| 178 | + RKVDEC2_CCU_TASK_HARD = 2, |
---|
| 179 | + RKVDEC2_CCU_MODE_BUTT, |
---|
| 180 | +}; |
---|
| 181 | + |
---|
| 182 | +struct rkvdec2_ccu { |
---|
| 183 | + struct device *dev; |
---|
| 184 | + /* register base */ |
---|
| 185 | + void __iomem *reg_base; |
---|
| 186 | + |
---|
| 187 | + atomic_t power_enabled; |
---|
| 188 | + struct mpp_clk_info aclk_info; |
---|
| 189 | +#ifdef CONFIG_ROCKCHIP_MPP_PROC_FS |
---|
| 190 | + struct proc_dir_entry *procfs; |
---|
| 191 | +#endif |
---|
| 192 | + struct reset_control *rst_a; |
---|
| 193 | + enum RKVDEC2_CCU_MODE ccu_mode; |
---|
| 194 | + u32 ccu_core_work_mode; |
---|
| 195 | + |
---|
| 196 | + struct mpp_dma_buffer *table_array; |
---|
| 197 | + struct list_head unused_list; |
---|
| 198 | + struct list_head used_list; |
---|
| 199 | + u32 timeout_flag; |
---|
| 200 | +}; |
---|
| 201 | + |
---|
| 202 | +extern struct rkvdec_link_info rkvdec_link_rk356x_hw_info; |
---|
105 | 203 | extern struct rkvdec_link_info rkvdec_link_v2_hw_info; |
---|
| 204 | +extern struct rkvdec_link_info rkvdec_link_vdpu382_hw_info; |
---|
106 | 205 | |
---|
107 | 206 | int rkvdec_link_dump(struct mpp_dev *mpp); |
---|
108 | 207 | |
---|
.. | .. |
---|
118 | 217 | void rkvdec2_link_worker(struct kthread_work *work_s); |
---|
119 | 218 | void rkvdec2_link_session_deinit(struct mpp_session *session); |
---|
120 | 219 | |
---|
| 220 | +/* for ccu link */ |
---|
| 221 | +int rkvdec2_attach_ccu(struct device *dev, struct rkvdec2_dev *dec); |
---|
| 222 | +int rkvdec2_ccu_link_init(struct platform_device *pdev, struct rkvdec2_dev *dec); |
---|
| 223 | +void *rkvdec2_ccu_alloc_task(struct mpp_session *session, struct mpp_task_msgs *msgs); |
---|
| 224 | +int rkvdec2_soft_ccu_iommu_fault_handle(struct iommu_domain *iommu, |
---|
| 225 | + struct device *iommu_dev, |
---|
| 226 | + unsigned long iova, int status, void *arg); |
---|
| 227 | +irqreturn_t rkvdec2_soft_ccu_irq(int irq, void *param); |
---|
| 228 | +void rkvdec2_soft_ccu_worker(struct kthread_work *work_s); |
---|
| 229 | + |
---|
| 230 | +int rkvdec2_ccu_alloc_table(struct rkvdec2_dev *dec, |
---|
| 231 | + struct rkvdec_link_dev *link_dec); |
---|
| 232 | +irqreturn_t rkvdec2_hard_ccu_irq(int irq, void *param); |
---|
| 233 | +void rkvdec2_hard_ccu_worker(struct kthread_work *work_s); |
---|
| 234 | +int rkvdec2_hard_ccu_iommu_fault_handle(struct iommu_domain *iommu, |
---|
| 235 | + struct device *iommu_dev, |
---|
| 236 | + unsigned long iova, int status, void *arg); |
---|
| 237 | + |
---|
121 | 238 | #endif |
---|