• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Hantro VPU codec driver
4  *
5  * Copyright (C) 2021 Collabora Ltd, Andrzej Pietrasiewicz <andrzej.p@collabora.com>
6  */
7 
8 #include "hantro_hw.h"
9 #include "hantro_g2_regs.h"
10 
hantro_g2_check_idle(struct hantro_dev * vpu)11 void hantro_g2_check_idle(struct hantro_dev *vpu)
12 {
13 	int i;
14 
15 	for (i = 0; i < 3; i++) {
16 		u32 status;
17 
18 		/* Make sure the VPU is idle */
19 		status = vdpu_read(vpu, G2_REG_INTERRUPT);
20 		if (status & G2_REG_INTERRUPT_DEC_E) {
21 			dev_warn(vpu->dev, "device still running, aborting");
22 			status |= G2_REG_INTERRUPT_DEC_ABORT_E | G2_REG_INTERRUPT_DEC_IRQ_DIS;
23 			vdpu_write(vpu, status, G2_REG_INTERRUPT);
24 		}
25 	}
26 }
27 
hantro_g2_irq(int irq,void * dev_id)28 irqreturn_t hantro_g2_irq(int irq, void *dev_id)
29 {
30 	struct hantro_dev *vpu = dev_id;
31 	enum vb2_buffer_state state;
32 	u32 status;
33 
34 	status = vdpu_read(vpu, G2_REG_INTERRUPT);
35 	state = (status & G2_REG_INTERRUPT_DEC_RDY_INT) ?
36 		 VB2_BUF_STATE_DONE : VB2_BUF_STATE_ERROR;
37 
38 	vdpu_write(vpu, 0, G2_REG_INTERRUPT);
39 	vdpu_write(vpu, G2_REG_CONFIG_DEC_CLK_GATE_E, G2_REG_CONFIG);
40 
41 	hantro_irq_done(vpu, state);
42 
43 	return IRQ_HANDLED;
44 }
45