Skip to content

Commit f1a8c06

Browse files
nashifkeith-packard
authored andcommitted
rpi_pico: make it work with picolibc
The picolibc changes were merged upstream; switch to using that revision. As the module now includes flash I/O functions, we don't need our own versions, so remove them. Signed-off-by: Anas Nashif <[email protected]>
1 parent ee78349 commit f1a8c06

File tree

2 files changed

+1
-128
lines changed

2 files changed

+1
-128
lines changed

drivers/flash/flash_rpi_pico.c

Lines changed: 0 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -58,135 +58,8 @@ enum outover {
5858
OUTOVER_HIGH
5959
};
6060

61-
static ssi_hw_t *const ssi = (ssi_hw_t *)SSI_BASE_ADDRESS;
62-
static uint32_t boot2_copyout[BOOT2_SIZE_WORDS];
63-
static bool boot2_copyout_valid;
6461
static uint8_t flash_ram_buffer[PAGE_SIZE];
6562

66-
static void __no_inline_not_in_flash_func(flash_init_boot2_copyout)(void)
67-
{
68-
if (boot2_copyout_valid) {
69-
return;
70-
}
71-
for (int i = 0; i < BOOT2_SIZE_WORDS; ++i) {
72-
boot2_copyout[i] = ((uint32_t *)FLASH_BASE)[i];
73-
}
74-
__compiler_memory_barrier();
75-
boot2_copyout_valid = true;
76-
}
77-
78-
static void __no_inline_not_in_flash_func(flash_enable_xip_via_boot2)(void)
79-
{
80-
((void (*)(void))((uint32_t)boot2_copyout+1))();
81-
}
82-
83-
void __no_inline_not_in_flash_func(flash_cs_force)(enum outover over)
84-
{
85-
io_rw_32 *reg = (io_rw_32 *) (IO_QSPI_BASE + IO_QSPI_GPIO_QSPI_SS_CTRL_OFFSET);
86-
*reg = (*reg & ~IO_QSPI_GPIO_QSPI_SS_CTRL_OUTOVER_BITS)
87-
| (over << IO_QSPI_GPIO_QSPI_SS_CTRL_OUTOVER_LSB);
88-
(void) *reg;
89-
}
90-
91-
int __no_inline_not_in_flash_func(flash_was_aborted)()
92-
{
93-
return *(io_rw_32 *) (IO_QSPI_BASE + IO_QSPI_GPIO_QSPI_SD1_CTRL_OFFSET)
94-
& IO_QSPI_GPIO_QSPI_SD1_CTRL_INOVER_BITS;
95-
}
96-
97-
void __no_inline_not_in_flash_func(flash_put_get)(const uint8_t *tx, uint8_t *rx, size_t count,
98-
size_t rx_skip)
99-
{
100-
const uint max_in_flight = 16 - 2;
101-
size_t tx_count = count;
102-
size_t rx_count = count;
103-
bool did_something;
104-
uint32_t tx_level;
105-
uint32_t rx_level;
106-
uint8_t rxbyte;
107-
108-
while (tx_count || rx_skip || rx_count) {
109-
tx_level = ssi_hw->txflr;
110-
rx_level = ssi_hw->rxflr;
111-
did_something = false;
112-
if (tx_count && tx_level + rx_level < max_in_flight) {
113-
ssi->dr0 = (uint32_t) (tx ? *tx++ : 0);
114-
--tx_count;
115-
did_something = true;
116-
}
117-
if (rx_level) {
118-
rxbyte = ssi->dr0;
119-
did_something = true;
120-
if (rx_skip) {
121-
--rx_skip;
122-
} else {
123-
if (rx) {
124-
*rx++ = rxbyte;
125-
}
126-
--rx_count;
127-
}
128-
}
129-
130-
if (!did_something && __builtin_expect(flash_was_aborted(), 0)) {
131-
break;
132-
}
133-
}
134-
flash_cs_force(OUTOVER_HIGH);
135-
}
136-
137-
void __no_inline_not_in_flash_func(flash_put_get_wrapper)(uint8_t cmd, const uint8_t *tx,
138-
uint8_t *rx, size_t count)
139-
{
140-
flash_cs_force(OUTOVER_LOW);
141-
ssi->dr0 = cmd;
142-
flash_put_get(tx, rx, count, 1);
143-
}
144-
145-
static ALWAYS_INLINE void flash_put_cmd_addr(uint8_t cmd, uint32_t addr)
146-
{
147-
flash_cs_force(OUTOVER_LOW);
148-
addr |= cmd << 24;
149-
for (int i = 0; i < 4; ++i) {
150-
ssi->dr0 = addr >> 24;
151-
addr <<= 8;
152-
}
153-
}
154-
155-
void __no_inline_not_in_flash_func(flash_write_partial_internal)(uint32_t addr, const uint8_t *data,
156-
size_t size)
157-
{
158-
uint8_t status_reg;
159-
160-
flash_put_get_wrapper(FLASHCMD_WRITE_ENABLE, NULL, NULL, 0);
161-
flash_put_cmd_addr(FLASHCMD_PAGE_PROGRAM, addr);
162-
flash_put_get(data, NULL, size, 4);
163-
164-
do {
165-
flash_put_get_wrapper(FLASHCMD_READ_STATUS, NULL, &status_reg, 1);
166-
} while (status_reg & 0x1 && !flash_was_aborted());
167-
}
168-
169-
void __no_inline_not_in_flash_func(flash_write_partial)(uint32_t flash_offs, const uint8_t *data,
170-
size_t count)
171-
{
172-
rom_connect_internal_flash_fn connect_internal_flash = (rom_connect_internal_flash_fn)
173-
rom_func_lookup_inline(ROM_FUNC_CONNECT_INTERNAL_FLASH);
174-
rom_flash_exit_xip_fn exit_xip = (rom_flash_exit_xip_fn)
175-
rom_func_lookup_inline(ROM_FUNC_FLASH_EXIT_XIP);
176-
rom_flash_flush_cache_fn flush_cache = (rom_flash_flush_cache_fn)
177-
rom_func_lookup_inline(ROM_FUNC_FLASH_FLUSH_CACHE);
178-
179-
flash_init_boot2_copyout();
180-
181-
__compiler_memory_barrier();
182-
183-
connect_internal_flash();
184-
exit_xip();
185-
flash_write_partial_internal(flash_offs, data, count);
186-
flush_cache();
187-
flash_enable_xip_via_boot2();
188-
}
189-
19063
static bool is_valid_range(off_t offset, uint32_t size)
19164
{
19265
return (offset >= 0) && ((offset + size) <= FLASH_SIZE);

west.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ manifest:
231231
- hal
232232
- name: hal_rpi_pico
233233
path: modules/hal/rpi_pico
234-
revision: 7b57b24588797e6e7bf18b6bda168e6b96374264
234+
revision: b547a36a722af7787e5f55b551fd6ce72dcba5a4
235235
groups:
236236
- hal
237237
- name: hal_silabs

0 commit comments

Comments
 (0)