Lines Matching +full:reg +full:- +full:offset
5 * SPDX-License-Identifier: Apache-2.0
44 * github.com/raspberrypi/pico-bootrom/blob/master/bootrom/program_flash_generic.c
46 * github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/hardware_flash/flash.c
85 io_rw_32 *reg = (io_rw_32 *) (IO_QSPI_BASE + IO_QSPI_GPIO_QSPI_SS_CTRL_OFFSET); in __no_inline_not_in_flash_func() local
86 *reg = (*reg & ~IO_QSPI_GPIO_QSPI_SS_CTRL_OUTOVER_BITS) in __no_inline_not_in_flash_func()
88 (void) *reg; in __no_inline_not_in_flash_func()
100 const uint max_in_flight = 16 - 2; in __no_inline_not_in_flash_func()
109 tx_level = ssi_hw->txflr; in __no_inline_not_in_flash_func()
110 rx_level = ssi_hw->rxflr; in __no_inline_not_in_flash_func()
113 ssi->dr0 = (uint32_t) (tx ? *tx++ : 0); in __no_inline_not_in_flash_func()
114 --tx_count; in __no_inline_not_in_flash_func()
118 rxbyte = ssi->dr0; in __no_inline_not_in_flash_func()
121 --rx_skip; in __no_inline_not_in_flash_func()
126 --rx_count; in __no_inline_not_in_flash_func()
141 ssi->dr0 = cmd; in __no_inline_not_in_flash_func()
150 ssi->dr0 = addr >> 24; in flash_put_cmd_addr()
190 static bool is_valid_range(off_t offset, uint32_t size) in is_valid_range() argument
192 return (offset >= 0) && ((offset + size) <= FLASH_SIZE); in is_valid_range()
195 static int flash_rpi_read(const struct device *dev, off_t offset, void *data, size_t size) in flash_rpi_read() argument
201 if (!is_valid_range(offset, size)) { in flash_rpi_read()
203 return -EINVAL; in flash_rpi_read()
206 memcpy(data, (uint8_t *)(CONFIG_FLASH_BASE_ADDRESS + offset), size); in flash_rpi_read()
211 static int flash_rpi_write(const struct device *dev, off_t offset, const void *data, size_t size) in flash_rpi_write() argument
221 if (!is_valid_range(offset, size)) { in flash_rpi_write()
222 LOG_ERR("Write range exceeds the flash boundaries. Offset=%#lx, Size=%u", in flash_rpi_write()
223 offset, size); in flash_rpi_write()
224 return -EINVAL; in flash_rpi_write()
229 if ((offset & (PAGE_SIZE - 1)) > 0) { in flash_rpi_write()
230 bytes_to_write = MIN(PAGE_SIZE - (offset & (PAGE_SIZE - 1)), size); in flash_rpi_write()
232 flash_write_partial(offset, flash_ram_buffer, bytes_to_write); in flash_rpi_write()
234 size -= bytes_to_write; in flash_rpi_write()
235 offset += bytes_to_write; in flash_rpi_write()
241 flash_range_program(offset, flash_ram_buffer, bytes_to_write); in flash_rpi_write()
243 size -= bytes_to_write; in flash_rpi_write()
244 offset += bytes_to_write; in flash_rpi_write()
249 flash_write_partial(offset, flash_ram_buffer, size); in flash_rpi_write()
257 static int flash_rpi_erase(const struct device *dev, off_t offset, size_t size) in flash_rpi_erase() argument
265 if (!is_valid_range(offset, size)) { in flash_rpi_erase()
266 LOG_ERR("Erase range exceeds the flash boundaries. Offset=%#lx, Size=%u", in flash_rpi_erase()
267 offset, size); in flash_rpi_erase()
268 return -EINVAL; in flash_rpi_erase()
271 if ((offset % SECTOR_SIZE) || (size % SECTOR_SIZE)) { in flash_rpi_erase()
272 LOG_ERR("Erase range is not a multiple of the sector size. Offset=%#lx, Size=%u", in flash_rpi_erase()
273 offset, size); in flash_rpi_erase()
274 return -EINVAL; in flash_rpi_erase()
279 flash_range_erase(offset, size); in flash_rpi_erase()