1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 2010-2015, Intel Corporation.
5  */
6 
7 #include <linux/delay.h>
8 
9 #include <system_global.h>
10 #include "isp.h"
11 
12 #ifndef __INLINE_ISP__
13 #include "isp_private.h"
14 #endif /* __INLINE_ISP__ */
15 
16 #include "assert_support.h"
17 
cnd_isp_irq_enable(const isp_ID_t ID,const bool cnd)18 void cnd_isp_irq_enable(
19     const isp_ID_t		ID,
20     const bool		cnd)
21 {
22 	if (cnd) {
23 		isp_ctrl_setbit(ID, ISP_IRQ_READY_REG, ISP_IRQ_READY_BIT);
24 		/* Enabling the IRQ immediately triggers an interrupt, clear it */
25 		isp_ctrl_setbit(ID, ISP_IRQ_CLEAR_REG, ISP_IRQ_CLEAR_BIT);
26 	} else {
27 		isp_ctrl_clearbit(ID, ISP_IRQ_READY_REG,
28 				  ISP_IRQ_READY_BIT);
29 	}
30 	return;
31 }
32 
33 /* ISP functions to control the ISP state from the host, even in crun. */
34 
35 /* Inspect readiness of an ISP indexed by ID */
isp_is_ready(isp_ID_t ID)36 unsigned int isp_is_ready(isp_ID_t ID)
37 {
38 	assert(ID < N_ISP_ID);
39 	return isp_ctrl_getbit(ID, ISP_SC_REG, ISP_IDLE_BIT);
40 }
41 
42 /* Inspect sleeping of an ISP indexed by ID */
isp_is_sleeping(isp_ID_t ID)43 unsigned int isp_is_sleeping(isp_ID_t ID)
44 {
45 	assert(ID < N_ISP_ID);
46 	return isp_ctrl_getbit(ID, ISP_SC_REG, ISP_SLEEPING_BIT);
47 }
48 
49 /* To be called by the host immediately before starting ISP ID. */
isp_start(isp_ID_t ID)50 void isp_start(isp_ID_t ID)
51 {
52 	assert(ID < N_ISP_ID);
53 }
54 
55 /* Wake up ISP ID. */
isp_wake(isp_ID_t ID)56 void isp_wake(isp_ID_t ID)
57 {
58 	assert(ID < N_ISP_ID);
59 	isp_ctrl_setbit(ID, ISP_SC_REG, ISP_START_BIT);
60 	udelay(1);
61 }
62