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 "timed_ctrl.h"
8 
9 #ifndef __INLINE_TIMED_CTRL__
10 #include "timed_ctrl_private.h"
11 #endif /* __INLINE_TIMED_CTRL__ */
12 
13 #include "assert_support.h"
14 
timed_ctrl_snd_commnd(const timed_ctrl_ID_t ID,hrt_data mask,hrt_data condition,hrt_data counter,hrt_address addr,hrt_data value)15 void timed_ctrl_snd_commnd(
16     const timed_ctrl_ID_t			ID,
17     hrt_data				mask,
18     hrt_data				condition,
19     hrt_data				counter,
20     hrt_address				addr,
21     hrt_data				value)
22 {
23 	OP___assert(ID == TIMED_CTRL0_ID);
24 	OP___assert(TIMED_CTRL_BASE[ID] != (hrt_address)-1);
25 
26 	timed_ctrl_reg_store(ID, _HRT_TIMED_CONTROLLER_CMD_REG_IDX, mask);
27 	timed_ctrl_reg_store(ID, _HRT_TIMED_CONTROLLER_CMD_REG_IDX, condition);
28 	timed_ctrl_reg_store(ID, _HRT_TIMED_CONTROLLER_CMD_REG_IDX, counter);
29 	timed_ctrl_reg_store(ID, _HRT_TIMED_CONTROLLER_CMD_REG_IDX, (hrt_data)addr);
30 	timed_ctrl_reg_store(ID, _HRT_TIMED_CONTROLLER_CMD_REG_IDX, value);
31 }
32 
33 /* pqiao TODO: make sure the following commands get
34 	correct BASE address both for csim and android */
35 
timed_ctrl_snd_sp_commnd(const timed_ctrl_ID_t ID,hrt_data mask,hrt_data condition,hrt_data counter,const sp_ID_t SP_ID,hrt_address offset,hrt_data value)36 void timed_ctrl_snd_sp_commnd(
37     const timed_ctrl_ID_t			ID,
38     hrt_data				mask,
39     hrt_data				condition,
40     hrt_data				counter,
41     const sp_ID_t				SP_ID,
42     hrt_address				offset,
43     hrt_data				value)
44 {
45 	OP___assert(SP_ID < N_SP_ID);
46 	OP___assert(SP_DMEM_BASE[SP_ID] != (hrt_address)-1);
47 
48 	timed_ctrl_snd_commnd(ID, mask, condition, counter,
49 			      SP_DMEM_BASE[SP_ID] + offset, value);
50 }
51 
timed_ctrl_snd_gpio_commnd(const timed_ctrl_ID_t ID,hrt_data mask,hrt_data condition,hrt_data counter,const gpio_ID_t GPIO_ID,hrt_address offset,hrt_data value)52 void timed_ctrl_snd_gpio_commnd(
53     const timed_ctrl_ID_t			ID,
54     hrt_data				mask,
55     hrt_data				condition,
56     hrt_data				counter,
57     const gpio_ID_t				GPIO_ID,
58     hrt_address				offset,
59     hrt_data				value)
60 {
61 	OP___assert(GPIO_ID < N_GPIO_ID);
62 	OP___assert(GPIO_BASE[GPIO_ID] != (hrt_address)-1);
63 
64 	timed_ctrl_snd_commnd(ID, mask, condition, counter,
65 			      GPIO_BASE[GPIO_ID] + offset, value);
66 }
67