aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/media/atomisp/pci/atomisp2/css2400/hive_isp_css_common/host/sp_private.h
blob: 5ea81c0e82d18c08d2b05fab4ca86e27a0d87dd5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
 * Support for Intel Camera Imaging ISP subsystem.
 * Copyright (c) 2010-2015, Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 */

#ifndef __SP_PRIVATE_H_INCLUDED__
#define __SP_PRIVATE_H_INCLUDED__

#include "sp_public.h"

#include "device_access.h"

#include "assert_support.h"

STORAGE_CLASS_SP_C void sp_ctrl_store(
	const sp_ID_t		ID,
	const hrt_address	reg,
	const hrt_data		value)
{
	assert(ID < N_SP_ID);
	assert(SP_CTRL_BASE[ID] != (hrt_address)-1);
	ia_css_device_store_uint32(SP_CTRL_BASE[ID] + reg*sizeof(hrt_data), value);
	return;
}

STORAGE_CLASS_SP_C hrt_data sp_ctrl_load(
	const sp_ID_t		ID,
	const hrt_address	reg)
{
	assert(ID < N_SP_ID);
	assert(SP_CTRL_BASE[ID] != (hrt_address)-1);
	return ia_css_device_load_uint32(SP_CTRL_BASE[ID] + reg*sizeof(hrt_data));
}

STORAGE_CLASS_SP_C bool sp_ctrl_getbit(
	const sp_ID_t		ID,
	const hrt_address	reg,
	const unsigned int	bit)
{
	hrt_data val = sp_ctrl_load(ID, reg);
	return (val & (1UL << bit)) != 0;
}

STORAGE_CLASS_SP_C void sp_ctrl_setbit(
	const sp_ID_t		ID,
	const hrt_address	reg,
	const unsigned int	bit)
{
	hrt_data	data = sp_ctrl_load(ID, reg);
	sp_ctrl_store(ID, reg, (data | (1UL << bit)));
	return;
}

STORAGE_CLASS_SP_C void sp_ctrl_clearbit(
	const sp_ID_t		ID,
	const hrt_address	reg,
	const unsigned int	bit)
{
	hrt_data	data = sp_ctrl_load(ID, reg);
	sp_ctrl_store(ID, reg, (data & ~(1UL << bit)));
	return;
}

STORAGE_CLASS_SP_C void sp_dmem_store(
	const sp_ID_t		ID,
	hrt_address		addr,
	const void			*data,
	const size_t		size)
{
	assert(ID < N_SP_ID);
	assert(SP_DMEM_BASE[ID] != (hrt_address)-1);
	ia_css_device_store(SP_DMEM_BASE[ID] + addr, data, size);
	return;
}

STORAGE_CLASS_SP_C void sp_dmem_load(
	const sp_ID_t		ID,
	const hrt_address	addr,
	void				*data,
	const size_t		size)
{
	assert(ID < N_SP_ID);
	assert(SP_DMEM_BASE[ID] != (hrt_address)-1);
	ia_css_device_load(SP_DMEM_BASE[ID] + addr, data, size);
	return;
}

STORAGE_CLASS_SP_C void sp_dmem_store_uint8(
	const sp_ID_t		ID,
	hrt_address		addr,
	const uint8_t		data)
{
	assert(ID < N_SP_ID);
	assert(SP_DMEM_BASE[ID] != (hrt_address)-1);
	(void)ID;
	ia_css_device_store_uint8(SP_DMEM_BASE[SP0_ID] + addr, data);
	return;
}

STORAGE_CLASS_SP_C void sp_dmem_store_uint16(
	const sp_ID_t		ID,
	hrt_address		addr,
	const uint16_t		data)
{
	assert(ID < N_SP_ID);
	assert(SP_DMEM_BASE[ID] != (hrt_address)-1);
	(void)ID;
	ia_css_device_store_uint16(SP_DMEM_BASE[SP0_ID] + addr, data);
	return;
}

STORAGE_CLASS_SP_C void sp_dmem_store_uint32(
	const sp_ID_t		ID,
	hrt_address		addr,
	const uint32_t		data)
{
	assert(ID < N_SP_ID);
	assert(SP_DMEM_BASE[ID] != (hrt_address)-1);
	(void)ID;
	ia_css_device_store_uint32(SP_DMEM_BASE[SP0_ID] + addr, data);
	return;
}

STORAGE_CLASS_SP_C uint8_t sp_dmem_load_uint8(
	const sp_ID_t		ID,
	const hrt_address	addr)
{
	assert(ID < N_SP_ID);
	assert(SP_DMEM_BASE[ID] != (hrt_address)-1);
	(void)ID;
	return ia_css_device_load_uint8(SP_DMEM_BASE[SP0_ID] + addr);
}

STORAGE_CLASS_SP_C uint16_t sp_dmem_load_uint16(
	const sp_ID_t		ID,
	const hrt_address	addr)
{
	assert(ID < N_SP_ID);
	assert(SP_DMEM_BASE[ID] != (hrt_address)-1);
	(void)ID;
	return ia_css_device_load_uint16(SP_DMEM_BASE[SP0_ID] + addr);
}

STORAGE_CLASS_SP_C uint32_t sp_dmem_load_uint32(
	const sp_ID_t		ID,
	const hrt_address	addr)
{
	assert(ID < N_SP_ID);
	assert(SP_DMEM_BASE[ID] != (hrt_address)-1);
	(void)ID;
	return ia_css_device_load_uint32(SP_DMEM_BASE[SP0_ID] + addr);
}

#endif /* __SP_PRIVATE_H_INCLUDED__ */