GNU Linux-libre 4.14.290-gnu1
[releases.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / hive_isp_css_common / host / sp_private.h
1 /*
2  * Support for Intel Camera Imaging ISP subsystem.
3  * Copyright (c) 2010-2015, Intel Corporation.
4  *
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.
8  *
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
12  * more details.
13  */
14
15 #ifndef __SP_PRIVATE_H_INCLUDED__
16 #define __SP_PRIVATE_H_INCLUDED__
17
18 #include "sp_public.h"
19
20 #include "device_access.h"
21
22 #include "assert_support.h"
23
24 STORAGE_CLASS_SP_C void sp_ctrl_store(
25         const sp_ID_t           ID,
26         const hrt_address       reg,
27         const hrt_data          value)
28 {
29 assert(ID < N_SP_ID);
30 assert(SP_CTRL_BASE[ID] != (hrt_address)-1);
31         ia_css_device_store_uint32(SP_CTRL_BASE[ID] + reg*sizeof(hrt_data), value);
32 return;
33 }
34
35 STORAGE_CLASS_SP_C hrt_data sp_ctrl_load(
36         const sp_ID_t           ID,
37         const hrt_address       reg)
38 {
39 assert(ID < N_SP_ID);
40 assert(SP_CTRL_BASE[ID] != (hrt_address)-1);
41 return ia_css_device_load_uint32(SP_CTRL_BASE[ID] + reg*sizeof(hrt_data));
42 }
43
44 STORAGE_CLASS_SP_C bool sp_ctrl_getbit(
45         const sp_ID_t           ID,
46         const hrt_address       reg,
47         const unsigned int      bit)
48 {
49         hrt_data val = sp_ctrl_load(ID, reg);
50 return (val & (1UL << bit)) != 0;
51 }
52
53 STORAGE_CLASS_SP_C void sp_ctrl_setbit(
54         const sp_ID_t           ID,
55         const hrt_address       reg,
56         const unsigned int      bit)
57 {
58         hrt_data        data = sp_ctrl_load(ID, reg);
59         sp_ctrl_store(ID, reg, (data | (1UL << bit)));
60 return;
61 }
62
63 STORAGE_CLASS_SP_C void sp_ctrl_clearbit(
64         const sp_ID_t           ID,
65         const hrt_address       reg,
66         const unsigned int      bit)
67 {
68         hrt_data        data = sp_ctrl_load(ID, reg);
69         sp_ctrl_store(ID, reg, (data & ~(1UL << bit)));
70 return;
71 }
72
73 STORAGE_CLASS_SP_C void sp_dmem_store(
74         const sp_ID_t           ID,
75         hrt_address             addr,
76         const void                      *data,
77         const size_t            size)
78 {
79 assert(ID < N_SP_ID);
80 assert(SP_DMEM_BASE[ID] != (hrt_address)-1);
81         ia_css_device_store(SP_DMEM_BASE[ID] + addr, data, size);
82 return;
83 }
84
85 STORAGE_CLASS_SP_C void sp_dmem_load(
86         const sp_ID_t           ID,
87         const hrt_address       addr,
88         void                            *data,
89         const size_t            size)
90 {
91 assert(ID < N_SP_ID);
92 assert(SP_DMEM_BASE[ID] != (hrt_address)-1);
93         ia_css_device_load(SP_DMEM_BASE[ID] + addr, data, size);
94 return;
95 }
96
97 STORAGE_CLASS_SP_C void sp_dmem_store_uint8(
98         const sp_ID_t           ID,
99         hrt_address             addr,
100         const uint8_t           data)
101 {
102 assert(ID < N_SP_ID);
103 assert(SP_DMEM_BASE[ID] != (hrt_address)-1);
104         (void)ID;
105         ia_css_device_store_uint8(SP_DMEM_BASE[SP0_ID] + addr, data);
106 return;
107 }
108
109 STORAGE_CLASS_SP_C void sp_dmem_store_uint16(
110         const sp_ID_t           ID,
111         hrt_address             addr,
112         const uint16_t          data)
113 {
114 assert(ID < N_SP_ID);
115 assert(SP_DMEM_BASE[ID] != (hrt_address)-1);
116         (void)ID;
117         ia_css_device_store_uint16(SP_DMEM_BASE[SP0_ID] + addr, data);
118 return;
119 }
120
121 STORAGE_CLASS_SP_C void sp_dmem_store_uint32(
122         const sp_ID_t           ID,
123         hrt_address             addr,
124         const uint32_t          data)
125 {
126 assert(ID < N_SP_ID);
127 assert(SP_DMEM_BASE[ID] != (hrt_address)-1);
128         (void)ID;
129         ia_css_device_store_uint32(SP_DMEM_BASE[SP0_ID] + addr, data);
130 return;
131 }
132
133 STORAGE_CLASS_SP_C uint8_t sp_dmem_load_uint8(
134         const sp_ID_t           ID,
135         const hrt_address       addr)
136 {
137 assert(ID < N_SP_ID);
138 assert(SP_DMEM_BASE[ID] != (hrt_address)-1);
139         (void)ID;
140         return ia_css_device_load_uint8(SP_DMEM_BASE[SP0_ID] + addr);
141 }
142
143 STORAGE_CLASS_SP_C uint16_t sp_dmem_load_uint16(
144         const sp_ID_t           ID,
145         const hrt_address       addr)
146 {
147 assert(ID < N_SP_ID);
148 assert(SP_DMEM_BASE[ID] != (hrt_address)-1);
149         (void)ID;
150         return ia_css_device_load_uint16(SP_DMEM_BASE[SP0_ID] + addr);
151 }
152
153 STORAGE_CLASS_SP_C uint32_t sp_dmem_load_uint32(
154         const sp_ID_t           ID,
155         const hrt_address       addr)
156 {
157 assert(ID < N_SP_ID);
158 assert(SP_DMEM_BASE[ID] != (hrt_address)-1);
159         (void)ID;
160         return ia_css_device_load_uint32(SP_DMEM_BASE[SP0_ID] + addr);
161 }
162
163 #endif /* __SP_PRIVATE_H_INCLUDED__ */