GNU Linux-libre 4.14.302-gnu1
[releases.git] / drivers / staging / media / atomisp / pci / atomisp2 / hrt / hive_isp_css_custom_host_hrt.h
1 /*
2  * Support for Medifield PNW Camera Imaging ISP subsystem.
3  *
4  * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
5  *
6  * Copyright (c) 2010 Silicon Hive www.siliconhive.com.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License version
10  * 2 as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  * 02110-1301, USA.
21  *
22  */
23 #ifndef _hive_isp_css_custom_host_hrt_h_
24 #define _hive_isp_css_custom_host_hrt_h_
25
26 #include <linux/delay.h>
27 #include "atomisp_helper.h"
28
29 /*
30  * _hrt_master_port_store/load/uload -macros using __force attributed
31  * cast to intentional dereferencing __iomem attributed (noderef)
32  * pointer from atomisp_get_io_virt_addr
33  */
34 #define _hrt_master_port_store_8(a, d) \
35         (*((s8 __force *)atomisp_get_io_virt_addr(a)) = (d))
36
37 #define _hrt_master_port_store_16(a, d) \
38         (*((s16 __force *)atomisp_get_io_virt_addr(a)) = (d))
39
40 #define _hrt_master_port_store_32(a, d) \
41         (*((s32 __force *)atomisp_get_io_virt_addr(a)) = (d))
42
43 #define _hrt_master_port_load_8(a) \
44         (*(s8 __force *)atomisp_get_io_virt_addr(a))
45
46 #define _hrt_master_port_load_16(a) \
47         (*(s16 __force *)atomisp_get_io_virt_addr(a))
48
49 #define _hrt_master_port_load_32(a) \
50         (*(s32 __force *)atomisp_get_io_virt_addr(a))
51
52 #define _hrt_master_port_uload_8(a) \
53         (*(u8 __force *)atomisp_get_io_virt_addr(a))
54
55 #define _hrt_master_port_uload_16(a) \
56         (*(u16 __force *)atomisp_get_io_virt_addr(a))
57
58 #define _hrt_master_port_uload_32(a) \
59         (*(u32 __force *)atomisp_get_io_virt_addr(a))
60
61 #define _hrt_master_port_store_8_volatile(a, d)  _hrt_master_port_store_8(a, d)
62 #define _hrt_master_port_store_16_volatile(a, d) _hrt_master_port_store_16(a, d)
63 #define _hrt_master_port_store_32_volatile(a, d) _hrt_master_port_store_32(a, d)
64
65 #define _hrt_master_port_load_8_volatile(a)      _hrt_master_port_load_8(a)
66 #define _hrt_master_port_load_16_volatile(a)     _hrt_master_port_load_16(a)
67 #define _hrt_master_port_load_32_volatile(a)     _hrt_master_port_load_32(a)
68
69 #define _hrt_master_port_uload_8_volatile(a)     _hrt_master_port_uload_8(a)
70 #define _hrt_master_port_uload_16_volatile(a)    _hrt_master_port_uload_16(a)
71 #define _hrt_master_port_uload_32_volatile(a)    _hrt_master_port_uload_32(a)
72
73 static inline void hrt_sleep(void)
74 {
75         udelay(1);
76 }
77
78 static inline uint32_t _hrt_mem_store(uint32_t to, const void *from, size_t n)
79 {
80         unsigned i;
81         uint32_t _to = to;
82         const char *_from = (const char *)from;
83         for (i = 0; i < n; i++, _to++, _from++)
84                 _hrt_master_port_store_8(_to, *_from);
85         return _to;
86 }
87
88 static inline void *_hrt_mem_load(uint32_t from, void *to, size_t n)
89 {
90         unsigned i;
91         char *_to = (char *)to;
92         uint32_t _from = from;
93         for (i = 0; i < n; i++, _to++, _from++)
94                 *_to = _hrt_master_port_load_8(_from);
95         return _to;
96 }
97
98 static inline uint32_t _hrt_mem_set(uint32_t to, int c, size_t n)
99 {
100         unsigned i;
101         uint32_t _to = to;
102         for (i = 0; i < n; i++, _to++)
103                 _hrt_master_port_store_8(_to, c);
104         return _to;
105 }
106
107 #endif /* _hive_isp_css_custom_host_hrt_h_ */