GNU Linux-libre 4.14.266-gnu1
[releases.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / ia_css_device_access.c
1 /*
2  * Support for Intel Camera Imaging ISP subsystem.
3  * Copyright (c) 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 #include "ia_css_device_access.h"
16 #include <type_support.h>   /* for uint*, size_t */
17 #include <system_types.h>   /* for hrt_address */
18 #include <ia_css_env.h>     /* for ia_css_hw_access_env */
19 #include <assert_support.h> /* for assert */
20
21 static struct ia_css_hw_access_env my_env;
22
23 void
24 ia_css_device_access_init(const struct ia_css_hw_access_env *env)
25 {
26         assert(env != NULL);
27
28         my_env = *env;
29 }
30
31 uint8_t
32 ia_css_device_load_uint8(const hrt_address addr)
33 {
34         return my_env.load_8(addr);
35 }
36
37 uint16_t
38 ia_css_device_load_uint16(const hrt_address addr)
39 {
40         return my_env.load_16(addr);
41 }
42
43 uint32_t
44 ia_css_device_load_uint32(const hrt_address addr)
45 {
46         return my_env.load_32(addr);
47 }
48
49 uint64_t
50 ia_css_device_load_uint64(const hrt_address addr)
51 {
52         assert(0);
53
54         (void)addr;
55         return 0;
56 }
57
58 void
59 ia_css_device_store_uint8(const hrt_address addr, const uint8_t data)
60 {
61         my_env.store_8(addr, data);
62 }
63
64 void
65 ia_css_device_store_uint16(const hrt_address addr, const uint16_t data)
66 {
67         my_env.store_16(addr, data);
68 }
69
70 void
71 ia_css_device_store_uint32(const hrt_address addr, const uint32_t data)
72 {
73         my_env.store_32(addr, data);
74 }
75
76 void
77 ia_css_device_store_uint64(const hrt_address addr, const uint64_t data)
78 {
79         assert(0);
80
81         (void)addr;
82         (void)data;
83 }
84
85 void
86 ia_css_device_load(const hrt_address addr, void *data, const size_t size)
87 {
88         my_env.load(addr, data, (uint32_t)size);
89 }
90
91 void
92 ia_css_device_store(const hrt_address addr, const void *data, const size_t size)
93 {
94         my_env.store(addr, data, (uint32_t)size);
95 }