2 * Support for Intel Camera Imaging ISP subsystem.
3 * Copyright (c) 2015, Intel Corporation.
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.
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
15 #ifndef __ISP_PRIVATE_H_INCLUDED__
16 #define __ISP_PRIVATE_H_INCLUDED__
18 #ifdef HRT_MEMORY_ACCESS
22 #include "isp_public.h"
25 #include <string.h> /* memcpy() */
28 #include "device_access.h"
30 #include "assert_support.h"
31 #include "type_support.h"
33 STORAGE_CLASS_ISP_C
void isp_ctrl_store(
35 const unsigned int reg
,
38 assert(ID
< N_ISP_ID
);
39 assert(ISP_CTRL_BASE
[ID
] != (hrt_address
)-1);
40 #if !defined(HRT_MEMORY_ACCESS)
41 ia_css_device_store_uint32(ISP_CTRL_BASE
[ID
] + reg
*sizeof(hrt_data
), value
);
43 hrt_master_port_store_32(ISP_CTRL_BASE
[ID
] + reg
*sizeof(hrt_data
), value
);
48 STORAGE_CLASS_ISP_C hrt_data
isp_ctrl_load(
50 const unsigned int reg
)
52 assert(ID
< N_ISP_ID
);
53 assert(ISP_CTRL_BASE
[ID
] != (hrt_address
)-1);
54 #if !defined(HRT_MEMORY_ACCESS)
55 return ia_css_device_load_uint32(ISP_CTRL_BASE
[ID
] + reg
*sizeof(hrt_data
));
57 return hrt_master_port_uload_32(ISP_CTRL_BASE
[ID
] + reg
*sizeof(hrt_data
));
61 STORAGE_CLASS_ISP_C
bool isp_ctrl_getbit(
63 const unsigned int reg
,
64 const unsigned int bit
)
66 hrt_data val
= isp_ctrl_load(ID
, reg
);
67 return (val
& (1UL << bit
)) != 0;
70 STORAGE_CLASS_ISP_C
void isp_ctrl_setbit(
72 const unsigned int reg
,
73 const unsigned int bit
)
75 hrt_data data
= isp_ctrl_load(ID
, reg
);
76 isp_ctrl_store(ID
, reg
, (data
| (1UL << bit
)));
80 STORAGE_CLASS_ISP_C
void isp_ctrl_clearbit(
82 const unsigned int reg
,
83 const unsigned int bit
)
85 hrt_data data
= isp_ctrl_load(ID
, reg
);
86 isp_ctrl_store(ID
, reg
, (data
& ~(1UL << bit
)));
90 STORAGE_CLASS_ISP_C
void isp_dmem_store(
96 assert(ID
< N_ISP_ID
);
97 assert(ISP_DMEM_BASE
[ID
] != (hrt_address
)-1);
99 memcpy((void *)addr
, data
, size
);
100 #elif !defined(HRT_MEMORY_ACCESS)
101 ia_css_device_store(ISP_DMEM_BASE
[ID
] + addr
, data
, size
);
103 hrt_master_port_store(ISP_DMEM_BASE
[ID
] + addr
, data
, size
);
108 STORAGE_CLASS_ISP_C
void isp_dmem_load(
110 const unsigned int addr
,
114 assert(ID
< N_ISP_ID
);
115 assert(ISP_DMEM_BASE
[ID
] != (hrt_address
)-1);
117 memcpy(data
, (void *)addr
, size
);
118 #elif !defined(HRT_MEMORY_ACCESS)
119 ia_css_device_load(ISP_DMEM_BASE
[ID
] + addr
, data
, size
);
121 hrt_master_port_load(ISP_DMEM_BASE
[ID
] + addr
, data
, size
);
126 STORAGE_CLASS_ISP_C
void isp_dmem_store_uint32(
131 assert(ID
< N_ISP_ID
);
132 assert(ISP_DMEM_BASE
[ID
] != (hrt_address
)-1);
135 *(uint32_t *)addr
= data
;
136 #elif !defined(HRT_MEMORY_ACCESS)
137 ia_css_device_store_uint32(ISP_DMEM_BASE
[ID
] + addr
, data
);
139 hrt_master_port_store_32(ISP_DMEM_BASE
[ID
] + addr
, data
);
144 STORAGE_CLASS_ISP_C
uint32_t isp_dmem_load_uint32(
146 const unsigned int addr
)
148 assert(ID
< N_ISP_ID
);
149 assert(ISP_DMEM_BASE
[ID
] != (hrt_address
)-1);
152 return *(uint32_t *)addr
;
153 #elif !defined(HRT_MEMORY_ACCESS)
154 return ia_css_device_load_uint32(ISP_DMEM_BASE
[ID
] + addr
);
156 return hrt_master_port_uload_32(ISP_DMEM_BASE
[ID
] + addr
);
160 STORAGE_CLASS_ISP_C
uint32_t isp_2w_cat_1w(
164 uint32_t out
= ((uint32_t)(x1
& HIVE_ISP_VMEM_MASK
) << ISP_VMEM_ELEMBITS
)
165 | (x0
& HIVE_ISP_VMEM_MASK
);
169 #endif /* __ISP_PRIVATE_H_INCLUDED__ */