Lines Matching +full:reg +full:- +full:offset
4 * SPDX-License-Identifier: Apache-2.0
23 #define STM32_BKP_REG_OFFSET (TAMP_BASE + offsetof(TAMP_TypeDef, BKP0R) - RTC_BASE)
27 #define STM32_BKP_REG_INDEX(offset) ((offset) >> 2) argument
28 #define STM32_BKP_REG_BYTE_INDEX(offset) ((offset)&0x3UL) argument
29 #define STM32_BKP_REG(i) (((volatile uint32_t *)config->base_addr)[(i)])
40 static int bbram_stm32_read(const struct device *dev, size_t offset, size_t size, uint8_t *data) in bbram_stm32_read() argument
42 const struct bbram_stm32_config *config = dev->config; in bbram_stm32_read()
43 uint32_t reg, begin, to_copy; in bbram_stm32_read() local
45 if (size < 1 || offset + size > config->size) { in bbram_stm32_read()
46 return -EFAULT; in bbram_stm32_read()
50 reg = STM32_BKP_REG(STM32_BKP_REG_INDEX(offset + read)); in bbram_stm32_read()
51 begin = STM32_BKP_REG_BYTE_INDEX(offset + read); in bbram_stm32_read()
52 to_copy = MIN(STM32_BKP_REG_BYTES - begin, size - read); in bbram_stm32_read()
53 bytecpy(data + read, (uint8_t *)® + begin, to_copy); in bbram_stm32_read()
59 static int bbram_stm32_write(const struct device *dev, size_t offset, size_t size, in bbram_stm32_write() argument
62 const struct bbram_stm32_config *config = dev->config; in bbram_stm32_write()
63 uint32_t reg, begin, to_copy; in bbram_stm32_write() local
65 if (size < 1 || offset + size > config->size) { in bbram_stm32_write()
66 return -EFAULT; in bbram_stm32_write()
74 reg = STM32_BKP_REG(STM32_BKP_REG_INDEX(offset + written)); in bbram_stm32_write()
75 begin = STM32_BKP_REG_BYTE_INDEX(offset + written); in bbram_stm32_write()
76 to_copy = MIN(STM32_BKP_REG_BYTES - begin, size - written); in bbram_stm32_write()
77 bytecpy((uint8_t *)® + begin, data + written, to_copy); in bbram_stm32_write()
78 STM32_BKP_REG(STM32_BKP_REG_INDEX(offset + written)) = reg; in bbram_stm32_write()
90 const struct bbram_stm32_config *config = dev->config; in bbram_stm32_get_size()
92 *size = config->size; in bbram_stm32_get_size()
105 const struct bbram_stm32_config *config = dev->config; in bbram_stm32_init()
107 if (!device_is_ready(config->parent)) { in bbram_stm32_init()
108 LOG_ERR("Device %s is not ready", config->parent->name); in bbram_stm32_init()
109 return -ENODEV; in bbram_stm32_init()