1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Support for Intel Camera Imaging ISP subsystem.
4 * Copyright (c) 2015, Intel Corporation.
5 */
6
7 #ifndef __ISP_PRIVATE_H_INCLUDED__
8 #define __ISP_PRIVATE_H_INCLUDED__
9
10 #ifdef HRT_MEMORY_ACCESS
11 #include <hrt/api.h>
12 #endif
13
14 #include "isp_public.h"
15
16 #include "device_access.h"
17
18 #include "assert_support.h"
19 #include "type_support.h"
20
isp_ctrl_store(const isp_ID_t ID,const unsigned int reg,const hrt_data value)21 STORAGE_CLASS_ISP_C void isp_ctrl_store(
22 const isp_ID_t ID,
23 const unsigned int reg,
24 const hrt_data value)
25 {
26 assert(ID < N_ISP_ID);
27 assert(ISP_CTRL_BASE[ID] != (hrt_address) - 1);
28 #if !defined(HRT_MEMORY_ACCESS)
29 ia_css_device_store_uint32(ISP_CTRL_BASE[ID] + reg * sizeof(hrt_data), value);
30 #else
31 hrt_master_port_store_32(ISP_CTRL_BASE[ID] + reg * sizeof(hrt_data), value);
32 #endif
33 return;
34 }
35
isp_ctrl_load(const isp_ID_t ID,const unsigned int reg)36 STORAGE_CLASS_ISP_C hrt_data isp_ctrl_load(
37 const isp_ID_t ID,
38 const unsigned int reg)
39 {
40 assert(ID < N_ISP_ID);
41 assert(ISP_CTRL_BASE[ID] != (hrt_address) - 1);
42 #if !defined(HRT_MEMORY_ACCESS)
43 return ia_css_device_load_uint32(ISP_CTRL_BASE[ID] + reg * sizeof(hrt_data));
44 #else
45 return hrt_master_port_uload_32(ISP_CTRL_BASE[ID] + reg * sizeof(hrt_data));
46 #endif
47 }
48
isp_ctrl_getbit(const isp_ID_t ID,const unsigned int reg,const unsigned int bit)49 STORAGE_CLASS_ISP_C bool isp_ctrl_getbit(
50 const isp_ID_t ID,
51 const unsigned int reg,
52 const unsigned int bit)
53 {
54 hrt_data val = isp_ctrl_load(ID, reg);
55
56 return (val & (1UL << bit)) != 0;
57 }
58
isp_ctrl_setbit(const isp_ID_t ID,const unsigned int reg,const unsigned int bit)59 STORAGE_CLASS_ISP_C void isp_ctrl_setbit(
60 const isp_ID_t ID,
61 const unsigned int reg,
62 const unsigned int bit)
63 {
64 hrt_data data = isp_ctrl_load(ID, reg);
65
66 isp_ctrl_store(ID, reg, (data | (1UL << bit)));
67 return;
68 }
69
isp_ctrl_clearbit(const isp_ID_t ID,const unsigned int reg,const unsigned int bit)70 STORAGE_CLASS_ISP_C void isp_ctrl_clearbit(
71 const isp_ID_t ID,
72 const unsigned int reg,
73 const unsigned int bit)
74 {
75 hrt_data data = isp_ctrl_load(ID, reg);
76
77 isp_ctrl_store(ID, reg, (data & ~(1UL << bit)));
78 return;
79 }
80
isp_dmem_store(const isp_ID_t ID,unsigned int addr,const void * data,const size_t size)81 STORAGE_CLASS_ISP_C void isp_dmem_store(
82 const isp_ID_t ID,
83 unsigned int addr,
84 const void *data,
85 const size_t size)
86 {
87 assert(ID < N_ISP_ID);
88 assert(ISP_DMEM_BASE[ID] != (hrt_address) - 1);
89 #if !defined(HRT_MEMORY_ACCESS)
90 ia_css_device_store(ISP_DMEM_BASE[ID] + addr, data, size);
91 #else
92 hrt_master_port_store(ISP_DMEM_BASE[ID] + addr, data, size);
93 #endif
94 return;
95 }
96
isp_dmem_load(const isp_ID_t ID,const unsigned int addr,void * data,const size_t size)97 STORAGE_CLASS_ISP_C void isp_dmem_load(
98 const isp_ID_t ID,
99 const unsigned int addr,
100 void *data,
101 const size_t size)
102 {
103 assert(ID < N_ISP_ID);
104 assert(ISP_DMEM_BASE[ID] != (hrt_address) - 1);
105 #if !defined(HRT_MEMORY_ACCESS)
106 ia_css_device_load(ISP_DMEM_BASE[ID] + addr, data, size);
107 #else
108 hrt_master_port_load(ISP_DMEM_BASE[ID] + addr, data, size);
109 #endif
110 return;
111 }
112
isp_dmem_store_uint32(const isp_ID_t ID,unsigned int addr,const uint32_t data)113 STORAGE_CLASS_ISP_C void isp_dmem_store_uint32(
114 const isp_ID_t ID,
115 unsigned int addr,
116 const uint32_t data)
117 {
118 assert(ID < N_ISP_ID);
119 assert(ISP_DMEM_BASE[ID] != (hrt_address) - 1);
120 (void)ID;
121 #if !defined(HRT_MEMORY_ACCESS)
122 ia_css_device_store_uint32(ISP_DMEM_BASE[ID] + addr, data);
123 #else
124 hrt_master_port_store_32(ISP_DMEM_BASE[ID] + addr, data);
125 #endif
126 return;
127 }
128
isp_dmem_load_uint32(const isp_ID_t ID,const unsigned int addr)129 STORAGE_CLASS_ISP_C uint32_t isp_dmem_load_uint32(
130 const isp_ID_t ID,
131 const unsigned int addr)
132 {
133 assert(ID < N_ISP_ID);
134 assert(ISP_DMEM_BASE[ID] != (hrt_address) - 1);
135 (void)ID;
136 #if !defined(HRT_MEMORY_ACCESS)
137 return ia_css_device_load_uint32(ISP_DMEM_BASE[ID] + addr);
138 #else
139 return hrt_master_port_uload_32(ISP_DMEM_BASE[ID] + addr);
140 #endif
141 }
142
isp_2w_cat_1w(const u16 x0,const uint16_t x1)143 STORAGE_CLASS_ISP_C uint32_t isp_2w_cat_1w(
144 const u16 x0,
145 const uint16_t x1)
146 {
147 u32 out = ((uint32_t)(x1 & HIVE_ISP_VMEM_MASK) << ISP_VMEM_ELEMBITS)
148 | (x0 & HIVE_ISP_VMEM_MASK);
149 return out;
150 }
151
152 #endif /* __ISP_PRIVATE_H_INCLUDED__ */
153