1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Support for Intel Camera Imaging ISP subsystem. 4 * Copyright (c) 2010-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 #ifndef __SP_PRIVATE_H_INCLUDED__ 17 #define __SP_PRIVATE_H_INCLUDED__ 18 19 #include "sp_public.h" 20 21 #include "device_access.h" 22 23 #include "assert_support.h" 24 25 STORAGE_CLASS_SP_C void sp_ctrl_store( 26 const sp_ID_t ID, 27 const hrt_address reg, 28 const hrt_data value) 29 { 30 assert(ID < N_SP_ID); 31 assert(SP_CTRL_BASE[ID] != (hrt_address)-1); 32 ia_css_device_store_uint32(SP_CTRL_BASE[ID] + reg * sizeof(hrt_data), value); 33 return; 34 } 35 36 STORAGE_CLASS_SP_C hrt_data sp_ctrl_load( 37 const sp_ID_t ID, 38 const hrt_address reg) 39 { 40 assert(ID < N_SP_ID); 41 assert(SP_CTRL_BASE[ID] != (hrt_address)-1); 42 return ia_css_device_load_uint32(SP_CTRL_BASE[ID] + reg * sizeof(hrt_data)); 43 } 44 45 STORAGE_CLASS_SP_C bool sp_ctrl_getbit( 46 const sp_ID_t ID, 47 const hrt_address reg, 48 const unsigned int bit) 49 { 50 hrt_data val = sp_ctrl_load(ID, reg); 51 52 return (val & (1UL << bit)) != 0; 53 } 54 55 STORAGE_CLASS_SP_C void sp_ctrl_setbit( 56 const sp_ID_t ID, 57 const hrt_address reg, 58 const unsigned int bit) 59 { 60 hrt_data data = sp_ctrl_load(ID, reg); 61 62 sp_ctrl_store(ID, reg, (data | (1UL << bit))); 63 return; 64 } 65 66 STORAGE_CLASS_SP_C void sp_ctrl_clearbit( 67 const sp_ID_t ID, 68 const hrt_address reg, 69 const unsigned int bit) 70 { 71 hrt_data data = sp_ctrl_load(ID, reg); 72 73 sp_ctrl_store(ID, reg, (data & ~(1UL << bit))); 74 return; 75 } 76 77 STORAGE_CLASS_SP_C void sp_dmem_store( 78 const sp_ID_t ID, 79 hrt_address addr, 80 const void *data, 81 const size_t size) 82 { 83 assert(ID < N_SP_ID); 84 assert(SP_DMEM_BASE[ID] != (hrt_address)-1); 85 ia_css_device_store(SP_DMEM_BASE[ID] + addr, data, size); 86 return; 87 } 88 89 STORAGE_CLASS_SP_C void sp_dmem_load( 90 const sp_ID_t ID, 91 const hrt_address addr, 92 void *data, 93 const size_t size) 94 { 95 assert(ID < N_SP_ID); 96 assert(SP_DMEM_BASE[ID] != (hrt_address)-1); 97 ia_css_device_load(SP_DMEM_BASE[ID] + addr, data, size); 98 return; 99 } 100 101 STORAGE_CLASS_SP_C void sp_dmem_store_uint8( 102 const sp_ID_t ID, 103 hrt_address addr, 104 const uint8_t data) 105 { 106 assert(ID < N_SP_ID); 107 assert(SP_DMEM_BASE[ID] != (hrt_address)-1); 108 (void)ID; 109 ia_css_device_store_uint8(SP_DMEM_BASE[SP0_ID] + addr, data); 110 return; 111 } 112 113 STORAGE_CLASS_SP_C void sp_dmem_store_uint16( 114 const sp_ID_t ID, 115 hrt_address addr, 116 const uint16_t data) 117 { 118 assert(ID < N_SP_ID); 119 assert(SP_DMEM_BASE[ID] != (hrt_address)-1); 120 (void)ID; 121 ia_css_device_store_uint16(SP_DMEM_BASE[SP0_ID] + addr, data); 122 return; 123 } 124 125 STORAGE_CLASS_SP_C void sp_dmem_store_uint32( 126 const sp_ID_t ID, 127 hrt_address addr, 128 const uint32_t data) 129 { 130 assert(ID < N_SP_ID); 131 assert(SP_DMEM_BASE[ID] != (hrt_address)-1); 132 (void)ID; 133 ia_css_device_store_uint32(SP_DMEM_BASE[SP0_ID] + addr, data); 134 return; 135 } 136 137 STORAGE_CLASS_SP_C uint8_t sp_dmem_load_uint8( 138 const sp_ID_t ID, 139 const hrt_address addr) 140 { 141 assert(ID < N_SP_ID); 142 assert(SP_DMEM_BASE[ID] != (hrt_address)-1); 143 (void)ID; 144 return ia_css_device_load_uint8(SP_DMEM_BASE[SP0_ID] + addr); 145 } 146 147 STORAGE_CLASS_SP_C uint16_t sp_dmem_load_uint16( 148 const sp_ID_t ID, 149 const hrt_address addr) 150 { 151 assert(ID < N_SP_ID); 152 assert(SP_DMEM_BASE[ID] != (hrt_address)-1); 153 (void)ID; 154 return ia_css_device_load_uint16(SP_DMEM_BASE[SP0_ID] + addr); 155 } 156 157 STORAGE_CLASS_SP_C uint32_t sp_dmem_load_uint32( 158 const sp_ID_t ID, 159 const hrt_address addr) 160 { 161 assert(ID < N_SP_ID); 162 assert(SP_DMEM_BASE[ID] != (hrt_address)-1); 163 (void)ID; 164 return ia_css_device_load_uint32(SP_DMEM_BASE[SP0_ID] + addr); 165 } 166 167 #endif /* __SP_PRIVATE_H_INCLUDED__ */ 168