xref: /linux/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/fifo_monitor_private.h (revision 4b4193256c8d3bc3a5397b5cd9494c2ad386317d)
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  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  */
15 
16 #ifndef __FIFO_MONITOR_PRIVATE_H_INCLUDED__
17 #define __FIFO_MONITOR_PRIVATE_H_INCLUDED__
18 
19 #include "fifo_monitor_public.h"
20 
21 #define __INLINE_GP_DEVICE__
22 #include "gp_device.h"
23 
24 #include "device_access.h"
25 
26 #include "assert_support.h"
27 
28 #ifdef __INLINE_FIFO_MONITOR__
29 extern const unsigned int FIFO_SWITCH_ADDR[N_FIFO_SWITCH];
30 #endif
31 
fifo_switch_set(const fifo_monitor_ID_t ID,const fifo_switch_t switch_id,const hrt_data sel)32 STORAGE_CLASS_FIFO_MONITOR_C void fifo_switch_set(
33     const fifo_monitor_ID_t		ID,
34     const fifo_switch_t			switch_id,
35     const hrt_data				sel)
36 {
37 	assert(ID == FIFO_MONITOR0_ID);
38 	assert(FIFO_MONITOR_BASE[ID] != (hrt_address) - 1);
39 	assert(switch_id < N_FIFO_SWITCH);
40 	(void)ID;
41 
42 	gp_device_reg_store(GP_DEVICE0_ID, FIFO_SWITCH_ADDR[switch_id], sel);
43 
44 	return;
45 }
46 
fifo_switch_get(const fifo_monitor_ID_t ID,const fifo_switch_t switch_id)47 STORAGE_CLASS_FIFO_MONITOR_C hrt_data fifo_switch_get(
48     const fifo_monitor_ID_t		ID,
49     const fifo_switch_t			switch_id)
50 {
51 	assert(ID == FIFO_MONITOR0_ID);
52 	assert(FIFO_MONITOR_BASE[ID] != (hrt_address) - 1);
53 	assert(switch_id < N_FIFO_SWITCH);
54 	(void)ID;
55 
56 	return gp_device_reg_load(GP_DEVICE0_ID, FIFO_SWITCH_ADDR[switch_id]);
57 }
58 
fifo_monitor_reg_store(const fifo_monitor_ID_t ID,const unsigned int reg,const hrt_data value)59 STORAGE_CLASS_FIFO_MONITOR_C void fifo_monitor_reg_store(
60     const fifo_monitor_ID_t		ID,
61     const unsigned int			reg,
62     const hrt_data				value)
63 {
64 	assert(ID < N_FIFO_MONITOR_ID);
65 	assert(FIFO_MONITOR_BASE[ID] != (hrt_address) - 1);
66 	ia_css_device_store_uint32(FIFO_MONITOR_BASE[ID] + reg * sizeof(hrt_data),
67 				   value);
68 	return;
69 }
70 
fifo_monitor_reg_load(const fifo_monitor_ID_t ID,const unsigned int reg)71 STORAGE_CLASS_FIFO_MONITOR_C hrt_data fifo_monitor_reg_load(
72     const fifo_monitor_ID_t		ID,
73     const unsigned int			reg)
74 {
75 	assert(ID < N_FIFO_MONITOR_ID);
76 	assert(FIFO_MONITOR_BASE[ID] != (hrt_address) - 1);
77 	return ia_css_device_load_uint32(FIFO_MONITOR_BASE[ID] + reg * sizeof(
78 					     hrt_data));
79 }
80 
81 #endif /* __FIFO_MONITOR_PRIVATE_H_INCLUDED__ */
82