2 * Support for Intel Camera Imaging ISP subsystem.
3 * Copyright (c) 2015, Intel Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 #include "platform_support.h"
17 #include "sh_css_hrt.h"
18 #include "ia_css_debug.h"
20 #include "device_access.h"
22 #define __INLINE_EVENT__
23 #include "event_fifo.h"
26 #define __INLINE_ISP__
28 #define __INLINE_IRQ__
30 #define __INLINE_FIFO_MONITOR__
31 #include "fifo_monitor.h"
33 /* System independent */
34 #include "sh_css_internal.h"
36 bool sh_css_hrt_system_is_idle(void)
38 bool not_idle = false, idle;
41 idle = sp_ctrl_getbit(SP0_ID, SP_SC_REG, SP_IDLE_BIT);
44 IA_CSS_WARNING("SP not idle");
46 idle = isp_ctrl_getbit(ISP0_ID, ISP_SC_REG, ISP_IDLE_BIT);
49 IA_CSS_WARNING("ISP not idle");
51 for (ch=0; ch<N_FIFO_CHANNEL; ch++) {
52 fifo_channel_state_t state;
53 fifo_channel_get_state(FIFO_MONITOR0_ID, ch, &state);
54 if (state.fifo_valid) {
55 IA_CSS_WARNING("FIFO channel %d is not empty", ch);
63 enum ia_css_err sh_css_hrt_sp_wait(void)
65 #if defined(HAS_IRQ_MAP_VERSION_2)
66 irq_sw_channel_id_t irq_id = IRQ_SW_CHANNEL0_ID;
68 irq_sw_channel_id_t irq_id = IRQ_SW_CHANNEL2_ID;
71 * Wait till SP is idle or till there is a SW2 interrupt
72 * The SW2 interrupt will be used when frameloop runs on SP
73 * and signals an event with similar meaning as SP idle
76 while (!sp_ctrl_getbit(SP0_ID, SP_SC_REG, SP_IDLE_BIT) &&
77 ((irq_reg_load(IRQ0_ID,
78 _HRT_IRQ_CONTROLLER_STATUS_REG_IDX) &
79 (1U<<(irq_id + IRQ_SW_CHANNEL_OFFSET))) == 0)) {
83 return IA_CSS_SUCCESS;