1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Support for Intel Camera Imaging ISP subsystem.
4 * Copyright (c) 2015, Intel Corporation.
5 */
6
7 #include "platform_support.h"
8
9 #include "sh_css_hrt.h"
10 #include "ia_css_debug.h"
11
12 #include "device_access.h"
13
14 #define __INLINE_EVENT__
15 #include "event_fifo.h"
16 #define __INLINE_SP__
17 #include "sp.h"
18 #define __INLINE_ISP__
19 #include "isp.h"
20 #define __INLINE_IRQ__
21 #include "irq.h"
22 #define __INLINE_FIFO_MONITOR__
23 #include "fifo_monitor.h"
24
25 /* System independent */
26 #include "sh_css_internal.h"
27
sh_css_hrt_system_is_idle(void)28 bool sh_css_hrt_system_is_idle(void)
29 {
30 bool not_idle = false, idle;
31 fifo_channel_t ch;
32
33 idle = sp_ctrl_getbit(SP0_ID, SP_SC_REG, SP_IDLE_BIT);
34 not_idle |= !idle;
35 if (!idle)
36 IA_CSS_WARNING("SP not idle");
37
38 idle = isp_ctrl_getbit(ISP0_ID, ISP_SC_REG, ISP_IDLE_BIT);
39 not_idle |= !idle;
40 if (!idle)
41 IA_CSS_WARNING("ISP not idle");
42
43 for (ch = 0; ch < N_FIFO_CHANNEL; ch++) {
44 fifo_channel_state_t state;
45
46 fifo_channel_get_state(FIFO_MONITOR0_ID, ch, &state);
47 if (state.fifo_valid) {
48 IA_CSS_WARNING("FIFO channel %d is not empty", ch);
49 not_idle = true;
50 }
51 }
52
53 return !not_idle;
54 }
55
sh_css_hrt_sp_wait(void)56 int sh_css_hrt_sp_wait(void)
57 {
58 irq_sw_channel_id_t irq_id = IRQ_SW_CHANNEL0_ID;
59 /*
60 * Wait till SP is idle or till there is a SW2 interrupt
61 * The SW2 interrupt will be used when frameloop runs on SP
62 * and signals an event with similar meaning as SP idle
63 * (e.g. frame_done)
64 */
65 while (!sp_ctrl_getbit(SP0_ID, SP_SC_REG, SP_IDLE_BIT) &&
66 ((irq_reg_load(IRQ0_ID,
67 _HRT_IRQ_CONTROLLER_STATUS_REG_IDX) &
68 (1U << (irq_id + IRQ_SW_CHANNEL_OFFSET))) == 0)) {
69 udelay(1);
70 }
71
72 return 0;
73 }
74