blob: 2c3cb1b607e9ad8cc6b7dfca80e84bac1368b8f0 [file] [log] [blame]
Soren Brinkmann76fcae32016-03-06 20:16:27 -08001/*
Michal Simek2a47faa2023-04-14 08:43:51 +02002 * Copyright (c) 2013-2020, Arm Limited and Contributors. All rights reserved.
Rajan Vaja566b2f92022-08-31 12:54:38 +02003 * Copyright (c) 2019-2022, Xilinx, Inc. All rights reserved.
4 * Copyright (c) 2022, Advanced Micro Devices, Inc. All rights reserved.
Soren Brinkmann76fcae32016-03-06 20:16:27 -08005 *
dp-armfa3cf0b2017-05-03 09:38:09 +01006 * SPDX-License-Identifier: BSD-3-Clause
Soren Brinkmann76fcae32016-03-06 20:16:27 -08007 */
8
Jolly Shah259afe52019-01-09 12:37:57 -08009
Isla Mitchelle3631462017-07-14 10:46:32 +010010#include <arch_helpers.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000011#include <lib/bakery_lock.h>
12#include <lib/mmio.h>
Jay Buddhabhattic6d624b2023-03-02 02:47:36 -080013#include <lib/spinlock.h>
Jolly Shahc2583ab2019-01-08 11:31:49 -080014#include <ipi.h>
Jolly Shah4c172372019-01-08 11:21:29 -080015#include <plat_ipi.h>
Jolly Shah0bfd7002019-01-08 11:10:47 -080016#include <plat_private.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000017#include <plat/common/platform.h>
18
Rajan Vaja566b2f92022-08-31 12:54:38 +020019#include "pm_defs.h"
Isla Mitchelle3631462017-07-14 10:46:32 +010020#include "pm_ipi.h"
Soren Brinkmann76fcae32016-03-06 20:16:27 -080021
HariBabu Gattem9f9db612022-09-15 22:35:11 -070022#define ERROR_CODE_MASK (0xFFFFU)
HariBabu Gattemaa811712022-10-07 00:07:49 -070023#define PM_OFFSET (0U)
Ravi Patel65123712020-11-23 04:19:08 -080024
Jay Buddhabhattic6d624b2023-03-02 02:47:36 -080025/*
26 * ARM v8.2, the cache will turn off automatically when cpu
27 * power down. Therefore, there is no doubt to use the spin_lock here.
28 */
29#if !HW_ASSISTED_COHERENCY
Stefan Krsmanovicc5e9f662016-05-20 15:51:08 +020030DEFINE_BAKERY_LOCK(pm_secure_lock);
Jay Buddhabhattic6d624b2023-03-02 02:47:36 -080031static inline void pm_ipi_lock_get(void)
32{
33 bakery_lock_get(&pm_secure_lock);
34}
35
36static inline void pm_ipi_lock_release(void)
37{
38 bakery_lock_release(&pm_secure_lock);
39}
40#else
41spinlock_t pm_secure_lock;
42static inline void pm_ipi_lock_get(void)
43{
44 spin_lock(&pm_secure_lock);
45}
46
47static inline void pm_ipi_lock_release(void)
48{
49 spin_unlock(&pm_secure_lock);
50}
51#endif
Soren Brinkmann76fcae32016-03-06 20:16:27 -080052
Soren Brinkmann76fcae32016-03-06 20:16:27 -080053/**
Jolly Shah9bb628d2019-01-07 12:53:32 -080054 * pm_ipi_init() - Initialize IPI peripheral for communication with
55 * remote processor
Soren Brinkmann76fcae32016-03-06 20:16:27 -080056 *
Wendy Liang328105c2017-10-03 23:21:11 -070057 * @proc Pointer to the processor who is initiating request
Soren Brinkmann76fcae32016-03-06 20:16:27 -080058 * @return On success, the initialization function must return 0.
59 * Any other return value will cause the framework to ignore
60 * the service
61 *
Soren Brinkmann76fcae32016-03-06 20:16:27 -080062 * Called from pm_setup initialization function
63 */
HariBabu Gattemaa811712022-10-07 00:07:49 -070064void pm_ipi_init(const struct pm_proc *proc)
Soren Brinkmann76fcae32016-03-06 20:16:27 -080065{
Jolly Shah36c930b2019-01-07 12:51:40 -080066 ipi_mb_open(proc->ipi->local_ipi_id, proc->ipi->remote_ipi_id);
Soren Brinkmann76fcae32016-03-06 20:16:27 -080067}
68
69/**
Jolly Shah9bb628d2019-01-07 12:53:32 -080070 * pm_ipi_send_common() - Sends IPI request to the remote processor
Soren Brinkmann76fcae32016-03-06 20:16:27 -080071 * @proc Pointer to the processor who is initiating request
72 * @payload API id and call arguments to be written in IPI buffer
73 *
74 * Send an IPI request to the power controller. Caller needs to hold
75 * the 'pm_secure_lock' lock.
76 *
77 * @return Returns status, either success or error+reason
78 */
79static enum pm_ret_status pm_ipi_send_common(const struct pm_proc *proc,
Tejas Patelaf4b10e2018-02-09 02:42:59 -080080 uint32_t payload[PAYLOAD_ARG_CNT],
81 uint32_t is_blocking)
Soren Brinkmann76fcae32016-03-06 20:16:27 -080082{
HariBabu Gattemaa811712022-10-07 00:07:49 -070083 uint32_t offset = PM_OFFSET;
Soren Brinkmann76fcae32016-03-06 20:16:27 -080084 uintptr_t buffer_base = proc->ipi->buffer_base +
Jolly Shah9bb628d2019-01-07 12:53:32 -080085 IPI_BUFFER_TARGET_REMOTE_OFFSET +
Soren Brinkmann76fcae32016-03-06 20:16:27 -080086 IPI_BUFFER_REQ_OFFSET;
Venkatesh Yadav Abbarapubfa2a2a2021-02-19 01:40:14 -070087#if IPI_CRC_CHECK
Venkatesh Yadav Abbarapu35a8be92019-04-04 14:23:32 +053088 payload[PAYLOAD_CRC_POS] = calculate_crc(payload, IPI_W0_TO_W6_SIZE);
89#endif
Soren Brinkmann76fcae32016-03-06 20:16:27 -080090
Soren Brinkmann76fcae32016-03-06 20:16:27 -080091 /* Write payload into IPI buffer */
92 for (size_t i = 0; i < PAYLOAD_ARG_CNT; i++) {
93 mmio_write_32(buffer_base + offset, payload[i]);
94 offset += PAYLOAD_ARG_SIZE;
95 }
Tejas Patelaf4b10e2018-02-09 02:42:59 -080096
Jolly Shah9bb628d2019-01-07 12:53:32 -080097 /* Generate IPI to remote processor */
Venkatesh Yadav Abbarapuefa1d322021-08-04 21:33:15 -060098 ipi_mb_notify(proc->ipi->local_ipi_id, proc->ipi->remote_ipi_id,
Tejas Patelaf4b10e2018-02-09 02:42:59 -080099 is_blocking);
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800100
Venkatesh Yadav Abbarapuefa1d322021-08-04 21:33:15 -0600101 return PM_RET_SUCCESS;
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800102}
103
104/**
Jolly Shah9bb628d2019-01-07 12:53:32 -0800105 * pm_ipi_send_non_blocking() - Sends IPI request to the remote processor
106 * without blocking notification
Tejas Patelaf4b10e2018-02-09 02:42:59 -0800107 * @proc Pointer to the processor who is initiating request
108 * @payload API id and call arguments to be written in IPI buffer
109 *
110 * Send an IPI request to the power controller.
111 *
112 * @return Returns status, either success or error+reason
113 */
114enum pm_ret_status pm_ipi_send_non_blocking(const struct pm_proc *proc,
115 uint32_t payload[PAYLOAD_ARG_CNT])
116{
117 enum pm_ret_status ret;
118
Jay Buddhabhattic6d624b2023-03-02 02:47:36 -0800119 pm_ipi_lock_get();
Tejas Patelaf4b10e2018-02-09 02:42:59 -0800120
121 ret = pm_ipi_send_common(proc, payload, IPI_NON_BLOCKING);
122
Jay Buddhabhattic6d624b2023-03-02 02:47:36 -0800123 pm_ipi_lock_release();
Tejas Patelaf4b10e2018-02-09 02:42:59 -0800124
125 return ret;
126}
127
128/**
Jolly Shah9bb628d2019-01-07 12:53:32 -0800129 * pm_ipi_send() - Sends IPI request to the remote processor
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800130 * @proc Pointer to the processor who is initiating request
131 * @payload API id and call arguments to be written in IPI buffer
132 *
133 * Send an IPI request to the power controller.
134 *
135 * @return Returns status, either success or error+reason
136 */
137enum pm_ret_status pm_ipi_send(const struct pm_proc *proc,
138 uint32_t payload[PAYLOAD_ARG_CNT])
139{
140 enum pm_ret_status ret;
141
Jay Buddhabhattic6d624b2023-03-02 02:47:36 -0800142 pm_ipi_lock_get();
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800143
Tejas Patelaf4b10e2018-02-09 02:42:59 -0800144 ret = pm_ipi_send_common(proc, payload, IPI_BLOCKING);
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800145
Jay Buddhabhattic6d624b2023-03-02 02:47:36 -0800146 pm_ipi_lock_release();
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800147
148 return ret;
149}
150
151
152/**
Jolly Shah9bb628d2019-01-07 12:53:32 -0800153 * pm_ipi_buff_read() - Reads IPI response after remote processor has handled
154 * interrupt
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800155 * @proc Pointer to the processor who is waiting and reading response
Soren Brinkmannd6c9e032016-09-22 11:35:47 -0700156 * @value Used to return value from IPI buffer element (optional)
157 * @count Number of values to return in @value
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800158 *
159 * @return Returns status, either success or error+reason
160 */
161static enum pm_ret_status pm_ipi_buff_read(const struct pm_proc *proc,
Venkatesh Yadav Abbarapue7c45382022-05-19 14:49:49 +0530162 uint32_t *value, size_t count)
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800163{
Soren Brinkmannd6c9e032016-09-22 11:35:47 -0700164 size_t i;
Naman Trivedi Manojbhaic0dfba82023-03-07 12:41:11 +0530165 enum pm_ret_status ret;
Venkatesh Yadav Abbarapubfa2a2a2021-02-19 01:40:14 -0700166#if IPI_CRC_CHECK
Naman Trivedi Manojbhaic0dfba82023-03-07 12:41:11 +0530167 uint32_t *payload_ptr = value;
Venkatesh Yadav Abbarapu35a8be92019-04-04 14:23:32 +0530168 size_t j;
Venkatesh Yadav Abbarapue7c45382022-05-19 14:49:49 +0530169 uint32_t response_payload[PAYLOAD_ARG_CNT];
Venkatesh Yadav Abbarapu35a8be92019-04-04 14:23:32 +0530170#endif
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800171 uintptr_t buffer_base = proc->ipi->buffer_base +
Jolly Shah9bb628d2019-01-07 12:53:32 -0800172 IPI_BUFFER_TARGET_REMOTE_OFFSET +
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800173 IPI_BUFFER_RESP_OFFSET;
174
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800175 /*
176 * Read response from IPI buffer
177 * buf-0: success or error+reason
178 * buf-1: value
179 * buf-2: unused
180 * buf-3: unused
181 */
Soren Brinkmannd6c9e032016-09-22 11:35:47 -0700182 for (i = 1; i <= count; i++) {
183 *value = mmio_read_32(buffer_base + (i * PAYLOAD_ARG_SIZE));
184 value++;
185 }
Naman Trivedi Manojbhaic0dfba82023-03-07 12:41:11 +0530186
187 ret = mmio_read_32(buffer_base);
Venkatesh Yadav Abbarapubfa2a2a2021-02-19 01:40:14 -0700188#if IPI_CRC_CHECK
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530189 for (j = 0; j < PAYLOAD_ARG_CNT; j++) {
Venkatesh Yadav Abbarapu35a8be92019-04-04 14:23:32 +0530190 response_payload[j] = mmio_read_32(buffer_base +
191 (j * PAYLOAD_ARG_SIZE));
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530192 }
Venkatesh Yadav Abbarapu35a8be92019-04-04 14:23:32 +0530193
194 if (response_payload[PAYLOAD_CRC_POS] !=
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530195 calculate_crc(response_payload, IPI_W0_TO_W6_SIZE)) {
Venkatesh Yadav Abbarapu35a8be92019-04-04 14:23:32 +0530196 NOTICE("ERROR in CRC response payload value:0x%x\n",
197 response_payload[PAYLOAD_CRC_POS]);
Naman Trivedi Manojbhaic0dfba82023-03-07 12:41:11 +0530198 ret = PM_RET_ERROR_INVALID_CRC;
199 /* Payload data is invalid as CRC validation failed
200 * Clear the payload to avoid leakage of data to upper layers
201 */
202 memset(payload_ptr, 0, count);
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530203 }
Venkatesh Yadav Abbarapu35a8be92019-04-04 14:23:32 +0530204#endif
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800205
Naman Trivedi Manojbhaic0dfba82023-03-07 12:41:11 +0530206 return ret;
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800207}
208
209/**
Naman Patele9756422023-02-15 01:01:21 -0800210 * pm_ipi_buff_read_callb() - Callback function that reads value from
211 * ipi response buffer
212 * @value Used to return value from IPI buffer element
Soren Brinkmann84f0af42016-09-30 14:24:25 -0700213 * @count Number of values to return in @value
214 *
Naman Patele9756422023-02-15 01:01:21 -0800215 * This callback function fills requested data in @value from ipi response
216 * buffer.
Naman Trivedi Manojbhaibeec83f2023-03-07 12:41:12 +0530217 * @return Returns status, either success or error
Soren Brinkmann84f0af42016-09-30 14:24:25 -0700218 */
Naman Trivedi Manojbhaibeec83f2023-03-07 12:41:12 +0530219enum pm_ret_status pm_ipi_buff_read_callb(uint32_t *value, size_t count)
Soren Brinkmann84f0af42016-09-30 14:24:25 -0700220{
221 size_t i;
Venkatesh Yadav Abbarapubfa2a2a2021-02-19 01:40:14 -0700222#if IPI_CRC_CHECK
Naman Trivedi Manojbhaibeec83f2023-03-07 12:41:12 +0530223 uint32_t *payload_ptr = value;
Venkatesh Yadav Abbarapu35a8be92019-04-04 14:23:32 +0530224 size_t j;
HariBabu Gattemaa811712022-10-07 00:07:49 -0700225 unsigned int response_payload[PAYLOAD_ARG_CNT] = {0};
Venkatesh Yadav Abbarapu35a8be92019-04-04 14:23:32 +0530226#endif
Jolly Shah9bb628d2019-01-07 12:53:32 -0800227 uintptr_t buffer_base = IPI_BUFFER_REMOTE_BASE +
228 IPI_BUFFER_TARGET_LOCAL_OFFSET +
Soren Brinkmann84f0af42016-09-30 14:24:25 -0700229 IPI_BUFFER_REQ_OFFSET;
Naman Trivedi Manojbhaibeec83f2023-03-07 12:41:12 +0530230 enum pm_ret_status ret = PM_RET_SUCCESS;
Soren Brinkmann84f0af42016-09-30 14:24:25 -0700231
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530232 if (count > IPI_BUFFER_MAX_WORDS) {
Soren Brinkmann84f0af42016-09-30 14:24:25 -0700233 count = IPI_BUFFER_MAX_WORDS;
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530234 }
Soren Brinkmann84f0af42016-09-30 14:24:25 -0700235
236 for (i = 0; i <= count; i++) {
237 *value = mmio_read_32(buffer_base + (i * PAYLOAD_ARG_SIZE));
238 value++;
239 }
Venkatesh Yadav Abbarapubfa2a2a2021-02-19 01:40:14 -0700240#if IPI_CRC_CHECK
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530241 for (j = 0; j < PAYLOAD_ARG_CNT; j++) {
Venkatesh Yadav Abbarapu35a8be92019-04-04 14:23:32 +0530242 response_payload[j] = mmio_read_32(buffer_base +
243 (j * PAYLOAD_ARG_SIZE));
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530244 }
Venkatesh Yadav Abbarapu35a8be92019-04-04 14:23:32 +0530245
246 if (response_payload[PAYLOAD_CRC_POS] !=
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530247 calculate_crc(response_payload, IPI_W0_TO_W6_SIZE)) {
Venkatesh Yadav Abbarapu35a8be92019-04-04 14:23:32 +0530248 NOTICE("ERROR in CRC response payload value:0x%x\n",
249 response_payload[PAYLOAD_CRC_POS]);
Naman Trivedi Manojbhaibeec83f2023-03-07 12:41:12 +0530250 ret = PM_RET_ERROR_INVALID_CRC;
251 /* Payload data is invalid as CRC validation failed
252 * Clear the payload to avoid leakage of data to upper layers
253 */
254 memset(payload_ptr, 0, count);
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530255 }
Venkatesh Yadav Abbarapu35a8be92019-04-04 14:23:32 +0530256#endif
Naman Trivedi Manojbhaibeec83f2023-03-07 12:41:12 +0530257 return ret;
Soren Brinkmann84f0af42016-09-30 14:24:25 -0700258}
259
260/**
Jolly Shah9bb628d2019-01-07 12:53:32 -0800261 * pm_ipi_send_sync() - Sends IPI request to the remote processor
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800262 * @proc Pointer to the processor who is initiating request
263 * @payload API id and call arguments to be written in IPI buffer
Soren Brinkmannd6c9e032016-09-22 11:35:47 -0700264 * @value Used to return value from IPI buffer element (optional)
265 * @count Number of values to return in @value
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800266 *
267 * Send an IPI request to the power controller and wait for it to be handled.
268 *
269 * @return Returns status, either success or error+reason and, optionally,
270 * @value
271 */
272enum pm_ret_status pm_ipi_send_sync(const struct pm_proc *proc,
273 uint32_t payload[PAYLOAD_ARG_CNT],
Venkatesh Yadav Abbarapue7c45382022-05-19 14:49:49 +0530274 uint32_t *value, size_t count)
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800275{
276 enum pm_ret_status ret;
277
Jay Buddhabhattic6d624b2023-03-02 02:47:36 -0800278 pm_ipi_lock_get();
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800279
Tejas Patelaf4b10e2018-02-09 02:42:59 -0800280 ret = pm_ipi_send_common(proc, payload, IPI_BLOCKING);
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530281 if (ret != PM_RET_SUCCESS) {
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800282 goto unlock;
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530283 }
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800284
Ravi Patel65123712020-11-23 04:19:08 -0800285 ret = ERROR_CODE_MASK & (pm_ipi_buff_read(proc, value, count));
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800286
287unlock:
Jay Buddhabhattic6d624b2023-03-02 02:47:36 -0800288 pm_ipi_lock_release();
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800289
290 return ret;
291}
Soren Brinkmanna1b0a902016-09-30 11:30:21 -0700292
Wendy Liang328105c2017-10-03 23:21:11 -0700293void pm_ipi_irq_enable(const struct pm_proc *proc)
Soren Brinkmanna1b0a902016-09-30 11:30:21 -0700294{
Jolly Shah36c930b2019-01-07 12:51:40 -0800295 ipi_mb_enable_irq(proc->ipi->local_ipi_id, proc->ipi->remote_ipi_id);
Soren Brinkmanna1b0a902016-09-30 11:30:21 -0700296}
Soren Brinkmann84f0af42016-09-30 14:24:25 -0700297
Wendy Liang328105c2017-10-03 23:21:11 -0700298void pm_ipi_irq_clear(const struct pm_proc *proc)
Soren Brinkmann84f0af42016-09-30 14:24:25 -0700299{
Jolly Shah36c930b2019-01-07 12:51:40 -0800300 ipi_mb_ack(proc->ipi->local_ipi_id, proc->ipi->remote_ipi_id);
Soren Brinkmann84f0af42016-09-30 14:24:25 -0700301}
Jolly Shah259afe52019-01-09 12:37:57 -0800302
303uint32_t pm_ipi_irq_status(const struct pm_proc *proc)
304{
Venkatesh Yadav Abbarapue7c45382022-05-19 14:49:49 +0530305 int32_t ret;
Jolly Shah259afe52019-01-09 12:37:57 -0800306
307 ret = ipi_mb_enquire_status(proc->ipi->local_ipi_id,
308 proc->ipi->remote_ipi_id);
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530309 if (ret & IPI_MB_STATUS_RECV_PENDING) {
Jolly Shah259afe52019-01-09 12:37:57 -0800310 return 1;
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530311 } else {
Jolly Shah259afe52019-01-09 12:37:57 -0800312 return 0;
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530313 }
Jolly Shah259afe52019-01-09 12:37:57 -0800314}
Venkatesh Yadav Abbarapu35a8be92019-04-04 14:23:32 +0530315
Venkatesh Yadav Abbarapubfa2a2a2021-02-19 01:40:14 -0700316#if IPI_CRC_CHECK
Venkatesh Yadav Abbarapu28b77592022-04-11 09:25:44 +0530317uint32_t calculate_crc(uint32_t payload[PAYLOAD_ARG_CNT], uint32_t bufsize)
Venkatesh Yadav Abbarapu35a8be92019-04-04 14:23:32 +0530318{
319 uint32_t crcinit = CRC_INIT_VALUE;
320 uint32_t order = CRC_ORDER;
321 uint32_t polynom = CRC_POLYNOM;
322 uint32_t i, j, c, bit, datain, crcmask, crchighbit;
323 uint32_t crc = crcinit;
324
325 crcmask = ((uint32_t)((1U << (order - 1U)) - 1U) << 1U) | 1U;
326 crchighbit = (uint32_t)(1U << (order - 1U));
327
328 for (i = 0U; i < bufsize; i++) {
329 datain = mmio_read_8((unsigned long)payload + i);
330 c = datain;
331 j = 0x80U;
332 while (j != 0U) {
333 bit = crc & crchighbit;
334 crc <<= 1U;
335 if (0U != (c & j))
336 bit ^= crchighbit;
337 if (bit != 0U)
338 crc ^= polynom;
339 j >>= 1U;
340 }
341 crc &= crcmask;
342 }
343 return crc;
344}
345#endif