Lines Matching +full:4 +full:- +full:word
4 * SPDX-License-Identifier: Apache-2.0
37 (CONFIG_ENTROPY_SMARTBOND_ISR_POOL_SIZE - 1)) == 0,
41 (CONFIG_ENTROPY_SMARTBOND_THR_POOL_SIZE - 1)) == 0,
86 CRG_TOP->CLK_AMBA_REG |= CRG_TOP_CLK_AMBA_REG_TRNG_CLK_ENABLE_Msk; in trng_enable()
87 TRNG->TRNG_CTRL_REG = TRNG_TRNG_CTRL_REG_TRNG_ENABLE_Msk; in trng_enable()
95 CRG_TOP->CLK_AMBA_REG &= ~CRG_TOP_CLK_AMBA_REG_TRNG_CLK_ENABLE_Msk; in trng_enable()
96 TRNG->TRNG_CTRL_REG = 0; in trng_enable()
106 return TRNG->TRNG_FIFOLVL_REG & FIFO_COUNT_MASK; in trng_available()
114 static int random_word_get(uint8_t buf[4]) in random_word_get() argument
116 uint32_t word = 0; in random_word_get() local
117 int retval = -EAGAIN; in random_word_get()
123 word = trng_fifo_read(); in random_word_get()
129 buf[0] = (uint8_t)word; in random_word_get()
130 buf[1] = (uint8_t)(word >> 8); in random_word_get()
131 buf[2] = (uint8_t)(word >> 16); in random_word_get()
132 buf[3] = (uint8_t)(word >> 24); in random_word_get()
139 uint32_t last = rngp->last; in rng_pool_get()
140 uint32_t mask = rngp->mask; in rng_pool_get()
147 first = rngp->first_alloc; in rng_pool_get()
150 * The other_read_in_progress is non-zero if rngp->first_read != first, in rng_pool_get()
151 * which means that lower-priority code (which was interrupted by this in rng_pool_get()
154 other_read_in_progress = (rngp->first_read ^ first); in rng_pool_get()
156 available = (last - first) & mask; in rng_pool_get()
165 rngp->first_alloc = (first + len) & mask; in rng_pool_get()
168 while (likely(len--)) { in rng_pool_get()
169 *dst++ = rngp->buffer[first]; in rng_pool_get()
180 rngp->first_read = rngp->first_alloc; in rng_pool_get()
184 len = dst - buf; in rng_pool_get()
185 available = available - len; in rng_pool_get()
186 if (available <= rngp->threshold) { in rng_pool_get()
195 uint8_t first = rngp->first_read; in rng_pool_put()
196 uint8_t last = rngp->last; in rng_pool_put()
197 uint8_t mask = rngp->mask; in rng_pool_put()
200 if (((last - first) & mask) == mask) { in rng_pool_put()
201 return -ENOBUFS; in rng_pool_put()
204 rngp->buffer[last] = byte; in rng_pool_put()
205 rngp->last = (last + 1) & mask; in rng_pool_put()
228 rngp->first_alloc = 0U; in rng_pool_init()
229 rngp->first_read = 0U; in rng_pool_init()
230 rngp->last = 0U; in rng_pool_init()
231 rngp->mask = size - 1; in rng_pool_init()
232 rngp->threshold = threshold; in rng_pool_init()
237 uint8_t word[4]; in smartbond_trng_isr() local
238 const uint8_t *const limit = word + 4; in smartbond_trng_isr()
245 if (random_word_get(word) < 0) { in smartbond_trng_isr()
246 /* Nothing in FIFO -> nothing to do */ in smartbond_trng_isr()
249 ptr = word; in smartbond_trng_isr()
275 __ASSERT_NO_MSG(&entropy_smartbond_data == dev->data); in entropy_smartbond_get_entropy()
290 len -= bytes; in entropy_smartbond_get_entropy()
304 __ASSERT_NO_MSG(&entropy_smartbond_data == dev->data); in entropy_smartbond_get_entropy_isr()
322 * RNG event will set the Cortex-M single-bit event register in entropy_smartbond_get_entropy_isr()
329 uint8_t bytes[4]; in entropy_smartbond_get_entropy_isr()
331 const uint8_t *const limit = bytes + 4; in entropy_smartbond_get_entropy_isr()
336 * SEV-On-Pend feature must be enabled (enabled in entropy_smartbond_get_entropy_isr()
354 buf[--len] = *ptr++; in entropy_smartbond_get_entropy_isr()
391 ret = -ENOTSUP; in entropy_smartbond_pm_action()
405 __ASSERT_NO_MSG(&entropy_smartbond_data == dev->data); in entropy_smartbond_init()