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 __INPUT_SYSTEM_PRIVATE_H_INCLUDED__
17 #define __INPUT_SYSTEM_PRIVATE_H_INCLUDED__
18 
19 #include "input_system_public.h"
20 
21 #include "device_access.h"
22 
23 #include "assert_support.h"
24 
input_system_reg_store(const input_system_ID_t ID,const hrt_address reg,const hrt_data value)25 STORAGE_CLASS_INPUT_SYSTEM_C void input_system_reg_store(
26     const input_system_ID_t			ID,
27     const hrt_address			reg,
28     const hrt_data				value)
29 {
30 	assert(ID < N_INPUT_SYSTEM_ID);
31 	assert(INPUT_SYSTEM_BASE[ID] != (hrt_address)-1);
32 	ia_css_device_store_uint32(INPUT_SYSTEM_BASE[ID] + reg * sizeof(hrt_data),
33 				   value);
34 	return;
35 }
36 
input_system_reg_load(const input_system_ID_t ID,const hrt_address reg)37 STORAGE_CLASS_INPUT_SYSTEM_C hrt_data input_system_reg_load(
38     const input_system_ID_t			ID,
39     const hrt_address			reg)
40 {
41 	assert(ID < N_INPUT_SYSTEM_ID);
42 	assert(INPUT_SYSTEM_BASE[ID] != (hrt_address)-1);
43 	return ia_css_device_load_uint32(INPUT_SYSTEM_BASE[ID] + reg * sizeof(
44 					     hrt_data));
45 }
46 
receiver_reg_store(const rx_ID_t ID,const hrt_address reg,const hrt_data value)47 STORAGE_CLASS_INPUT_SYSTEM_C void receiver_reg_store(
48     const rx_ID_t				ID,
49     const hrt_address			reg,
50     const hrt_data				value)
51 {
52 	assert(ID < N_RX_ID);
53 	assert(RX_BASE[ID] != (hrt_address)-1);
54 	ia_css_device_store_uint32(RX_BASE[ID] + reg * sizeof(hrt_data), value);
55 	return;
56 }
57 
receiver_reg_load(const rx_ID_t ID,const hrt_address reg)58 STORAGE_CLASS_INPUT_SYSTEM_C hrt_data receiver_reg_load(
59     const rx_ID_t				ID,
60     const hrt_address			reg)
61 {
62 	assert(ID < N_RX_ID);
63 	assert(RX_BASE[ID] != (hrt_address)-1);
64 	return ia_css_device_load_uint32(RX_BASE[ID] + reg * sizeof(hrt_data));
65 }
66 
receiver_port_reg_store(const rx_ID_t ID,const enum mipi_port_id port_ID,const hrt_address reg,const hrt_data value)67 STORAGE_CLASS_INPUT_SYSTEM_C void receiver_port_reg_store(
68     const rx_ID_t				ID,
69     const enum mipi_port_id			port_ID,
70     const hrt_address			reg,
71     const hrt_data				value)
72 {
73 	assert(ID < N_RX_ID);
74 	assert(port_ID < N_MIPI_PORT_ID);
75 	assert(RX_BASE[ID] != (hrt_address)-1);
76 	assert(MIPI_PORT_OFFSET[port_ID] != (hrt_address)-1);
77 	ia_css_device_store_uint32(RX_BASE[ID] + MIPI_PORT_OFFSET[port_ID] + reg *
78 				   sizeof(hrt_data), value);
79 	return;
80 }
81 
receiver_port_reg_load(const rx_ID_t ID,const enum mipi_port_id port_ID,const hrt_address reg)82 STORAGE_CLASS_INPUT_SYSTEM_C hrt_data receiver_port_reg_load(
83     const rx_ID_t				ID,
84     const enum mipi_port_id			port_ID,
85     const hrt_address			reg)
86 {
87 	assert(ID < N_RX_ID);
88 	assert(port_ID < N_MIPI_PORT_ID);
89 	assert(RX_BASE[ID] != (hrt_address)-1);
90 	assert(MIPI_PORT_OFFSET[port_ID] != (hrt_address)-1);
91 	return ia_css_device_load_uint32(RX_BASE[ID] + MIPI_PORT_OFFSET[port_ID] + reg *
92 					 sizeof(hrt_data));
93 }
94 
input_system_sub_system_reg_store(const input_system_ID_t ID,const sub_system_ID_t sub_ID,const hrt_address reg,const hrt_data value)95 STORAGE_CLASS_INPUT_SYSTEM_C void input_system_sub_system_reg_store(
96     const input_system_ID_t			ID,
97     const sub_system_ID_t			sub_ID,
98     const hrt_address			reg,
99     const hrt_data				value)
100 {
101 	assert(ID < N_INPUT_SYSTEM_ID);
102 	assert(sub_ID < N_SUB_SYSTEM_ID);
103 	assert(INPUT_SYSTEM_BASE[ID] != (hrt_address)-1);
104 	assert(SUB_SYSTEM_OFFSET[sub_ID] != (hrt_address)-1);
105 	ia_css_device_store_uint32(INPUT_SYSTEM_BASE[ID] + SUB_SYSTEM_OFFSET[sub_ID] +
106 				   reg * sizeof(hrt_data), value);
107 	return;
108 }
109 
input_system_sub_system_reg_load(const input_system_ID_t ID,const sub_system_ID_t sub_ID,const hrt_address reg)110 STORAGE_CLASS_INPUT_SYSTEM_C hrt_data input_system_sub_system_reg_load(
111     const input_system_ID_t			ID,
112     const sub_system_ID_t			sub_ID,
113     const hrt_address			reg)
114 {
115 	assert(ID < N_INPUT_SYSTEM_ID);
116 	assert(sub_ID < N_SUB_SYSTEM_ID);
117 	assert(INPUT_SYSTEM_BASE[ID] != (hrt_address)-1);
118 	assert(SUB_SYSTEM_OFFSET[sub_ID] != (hrt_address)-1);
119 	return ia_css_device_load_uint32(INPUT_SYSTEM_BASE[ID] +
120 					 SUB_SYSTEM_OFFSET[sub_ID] + reg * sizeof(hrt_data));
121 }
122 
123 #endif /* __INPUT_SYSTEM_PRIVATE_H_INCLUDED__ */
124