1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 2015, Intel Corporation.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  */
15 
16 #include "ia_css_device_access.h"
17 #include <type_support.h>   /* for uint*, size_t */
18 #include <system_local.h>   /* for hrt_address */
19 #include <ia_css_env.h>     /* for ia_css_hw_access_env */
20 #include <assert_support.h> /* for assert */
21 
22 static struct ia_css_hw_access_env my_env;
23 
24 void
ia_css_device_access_init(const struct ia_css_hw_access_env * env)25 ia_css_device_access_init(const struct ia_css_hw_access_env *env)
26 {
27 	assert(env);
28 
29 	my_env = *env;
30 }
31 
32 uint8_t
ia_css_device_load_uint8(const hrt_address addr)33 ia_css_device_load_uint8(const hrt_address addr)
34 {
35 	return my_env.load_8(addr);
36 }
37 
38 uint16_t
ia_css_device_load_uint16(const hrt_address addr)39 ia_css_device_load_uint16(const hrt_address addr)
40 {
41 	return my_env.load_16(addr);
42 }
43 
44 uint32_t
ia_css_device_load_uint32(const hrt_address addr)45 ia_css_device_load_uint32(const hrt_address addr)
46 {
47 	return my_env.load_32(addr);
48 }
49 
50 uint64_t
ia_css_device_load_uint64(const hrt_address addr)51 ia_css_device_load_uint64(const hrt_address addr)
52 {
53 	assert(0);
54 
55 	(void)addr;
56 	return 0;
57 }
58 
59 void
ia_css_device_store_uint8(const hrt_address addr,const uint8_t data)60 ia_css_device_store_uint8(const hrt_address addr, const uint8_t data)
61 {
62 	my_env.store_8(addr, data);
63 }
64 
65 void
ia_css_device_store_uint16(const hrt_address addr,const uint16_t data)66 ia_css_device_store_uint16(const hrt_address addr, const uint16_t data)
67 {
68 	my_env.store_16(addr, data);
69 }
70 
71 void
ia_css_device_store_uint32(const hrt_address addr,const uint32_t data)72 ia_css_device_store_uint32(const hrt_address addr, const uint32_t data)
73 {
74 	my_env.store_32(addr, data);
75 }
76 
77 void
ia_css_device_store_uint64(const hrt_address addr,const uint64_t data)78 ia_css_device_store_uint64(const hrt_address addr, const uint64_t data)
79 {
80 	assert(0);
81 
82 	(void)addr;
83 	(void)data;
84 }
85 
86 void
ia_css_device_load(const hrt_address addr,void * data,const size_t size)87 ia_css_device_load(const hrt_address addr, void *data, const size_t size)
88 {
89 	my_env.load(addr, data, (uint32_t)size);
90 }
91 
92 void
ia_css_device_store(const hrt_address addr,const void * data,const size_t size)93 ia_css_device_store(const hrt_address addr, const void *data, const size_t size)
94 {
95 	my_env.store(addr, data, (uint32_t)size);
96 }
97