Skip to content

Commit 7918c92

Browse files
benediktibknashif
authored andcommitted
drivers: fpga: always check state of CDONE during configuration of iCE40
Turn the assert into an if-statement to ensure that CDONE is always checked during the configuration of an iCE40. Signed-off-by: Benedikt Schmidt <[email protected]>
1 parent 51bc60e commit 7918c92

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

drivers/fpga/fpga_ice40.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,11 @@ static int fpga_ice40_load_gpio(const struct device *dev, uint32_t *image_ptr, u
262262
LOG_DBG("Delay %u us", config->creset_delay_us);
263263
fpga_ice40_delay(2 * config->mhz_delay_count * config->creset_delay_us);
264264

265-
__ASSERT(gpio_pin_get_dt(&config->cdone) == 0, "CDONE was not high");
265+
if (gpio_pin_get_dt(&config->cdone) != 0) {
266+
LOG_ERR("CDONE should be low after the reset");
267+
ret = -EIO;
268+
goto unlock;
269+
}
266270

267271
LOG_DBG("Set CRESET high");
268272
*config->set |= creset;
@@ -368,7 +372,11 @@ static int fpga_ice40_load_spi(const struct device *dev, uint32_t *image_ptr, ui
368372
LOG_DBG("Delay %u us", config->creset_delay_us);
369373
k_usleep(config->creset_delay_us);
370374

371-
__ASSERT(gpio_pin_get_dt(&config->cdone) == 0, "CDONE was not high");
375+
if (gpio_pin_get_dt(&config->cdone) != 0) {
376+
LOG_ERR("CDONE should be low after the reset");
377+
ret = -EIO;
378+
goto unlock;
379+
}
372380

373381
LOG_DBG("Set CRESET high");
374382
ret = gpio_pin_configure_dt(&config->creset, GPIO_OUTPUT_HIGH);

0 commit comments

Comments
 (0)