Skip to content

Commit

Permalink
Merge pull request #49 from jonasblixt/v2.3.0-work
Browse files Browse the repository at this point in the history
V2.3.0 work
  • Loading branch information
jonasblixt authored Sep 19, 2024
2 parents e36f7de + d1c3329 commit c26a594
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 41 deletions.
2 changes: 2 additions & 0 deletions include/plat/imx8x/sci/svc/timer/sci_timer_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ typedef uint32_t sc_timer_wdog_time_t;
*/
sc_err_t sc_timer_set_wdog_timeout(sc_ipc_t ipc, sc_timer_wdog_time_t timeout);

sc_err_t sc_timer_set_wdog_window(sc_ipc_t ipc, sc_timer_wdog_time_t window);

/*!
* This function sets the watchdog pre-timeout in milliseconds. If not
* set then the pre-timeout defaults to the max. Once locked this value
Expand Down
14 changes: 13 additions & 1 deletion src/cm/cm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,15 @@ static int cmd_boot_bpak(void)
boot_set_source(BOOT_SOURCE_CB);
boot_configure_load_cb(bpak_boot_read_f, bpak_boot_result_f);

return boot(bpak_boot_cmd->uuid);
rc = boot_load(bpak_boot_cmd->uuid);
if (rc != PB_OK)
return rc;

if (cfg->tops.disconnect) {
cfg->tops.disconnect();
}

return boot_jump();
}

static int cmd_slc_read(void)
Expand Down Expand Up @@ -756,6 +764,10 @@ static int pb_command_parse(void)
pb_wire_init_result(&result, error_to_wire(rc));
cm_write(&result, sizeof(result));

if (cfg->tops.disconnect) {
cfg->tops.disconnect();
}

if (rc == PB_OK) {
rc = boot_jump();
/* Should not return */
Expand Down
6 changes: 3 additions & 3 deletions src/drivers/mmc/imx_usdhc.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ static int imx_usdhc_set_bus_clock(unsigned int clk_hz)
{
int div = 1;
int pre_div = 1;
unsigned int actual_clk_hz;

LOG_DBG("Trying to set bus clock to %u kHz", clk_hz / 1000);

Expand All @@ -43,7 +42,6 @@ static int imx_usdhc_set_bus_clock(unsigned int clk_hz)
while (input_clock_hz / div > clk_hz && div < 16)
div++;

actual_clk_hz = input_clock_hz / (pre_div * div);
pre_div >>= 1;
div -= 1;
uint16_t clk_reg = (pre_div << 8) | (div << 4);
Expand All @@ -60,7 +58,7 @@ static int imx_usdhc_set_bus_clock(unsigned int clk_hz)
mmio_setbits_32(usdhc->base + USDHC_VEND_SPEC, VENDSPEC_PER_CLKEN | VENDSPEC_CARD_CLKEN);

pb_delay_us(100);
LOG_DBG("Actual bus rate = %d kHz", actual_clk_hz / 1000);
LOG_DBG("Actual bus rate = %d kHz", (input_clock_hz / (pre_div * div)) / 1000);
return PB_OK;
}

Expand Down Expand Up @@ -273,9 +271,11 @@ static int imx_usdhc_send_cmd(uint16_t idx, uint32_t arg, uint16_t resp_type, mm

static int imx_usdhc_set_bus_width(enum mmc_bus_width width)
{
#if LOGLEVEL >= 3
const char *bus_widths[] = {
"Invalid", "1-Bit", "4-Bit", "8-Bit", "4-Bit DDR", "8-Bit DDR", "8-Bit DDR + Strobe",
};
#endif

LOG_DBG("Width = %s", bus_widths[width]);
bus_ddr_enable = false;
Expand Down
2 changes: 2 additions & 0 deletions src/drivers/mmc/mmc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -845,12 +845,14 @@ int mmc_write(unsigned int lba, size_t length, const uintptr_t buf)
int mmc_part_switch(enum mmc_part part)
{
uint8_t value = 0;
#if LOGLEVEL >= 3
const char *part_names[] = {
"User",
"Boot0",
"Boot1",
"RPMB",
};
#endif

switch (part) {
case MMC_PART_BOOT0:
Expand Down
1 change: 1 addition & 0 deletions src/drivers/usb/imx_ci_udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ static int imx_ci_udc_set_address(uint16_t addr)

static int imx_ci_udc_stop(void)
{
mmio_clrsetbits_32(imx_ci_udc_base + IMX_CI_UDC_CMD, CMD_RS, 0);
imx_ci_udc_reset_queues();
imx_ci_udc_reset();
mmio_write_32(imx_ci_udc_base + IMX_CI_UDC_DEVICEADDR, 0);
Expand Down
79 changes: 43 additions & 36 deletions tools/pbstate/src/pbstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ int pbstate_init(const char *p_device, const char *b_device, pbstate_printfunc_t

int pbstate_is_system_active(pbstate_system_t system)
{
int rc;
int result = 0;
int fd = open_and_load_state(false);

Expand All @@ -242,17 +241,12 @@ int pbstate_is_system_active(pbstate_system_t system)
break;
}

rc = close_and_save_state(fd, false);

if (rc < 0)
return rc;

close_and_save_state(fd, false);
return result;
}

int pbstate_is_system_verified(pbstate_system_t system)
{
int rc;
int result = 0;
int fd = open_and_load_state(false);

Expand All @@ -273,11 +267,7 @@ int pbstate_is_system_verified(pbstate_system_t system)
break;
}

rc = close_and_save_state(fd, false);

if (rc < 0)
return rc;

close_and_save_state(fd, false);
return result;
}

Expand All @@ -293,13 +283,13 @@ int pbstate_get_remaining_boot_attempts(unsigned int *boot_attempts)

(*boot_attempts) = state.remaining_boot_attempts;

return close_and_save_state(fd, false);
close_and_save_state(fd, false);
return 0;
}

int pbstate_force_rollback(void)
{
int rc;
int preserved_rc = 0;
int fd = open_and_load_state(true);

if (fd < 0)
Expand All @@ -326,13 +316,9 @@ int pbstate_force_rollback(void)
return 0;

err_close_release_no_save_out:
preserved_rc = rc;
rc = close_and_save_state(fd, false);

if (rc < 0)
return rc;
close_and_save_state(fd, false);

return preserved_rc;
return rc;
}

int pbstate_get_errors(uint32_t *error)
Expand All @@ -344,7 +330,8 @@ int pbstate_get_errors(uint32_t *error)

(*error) = state.error;

return close_and_save_state(fd, false);
close_and_save_state(fd, false);
return 0;
}

int pbstate_clear_error(uint32_t mask)
Expand All @@ -362,7 +349,6 @@ int pbstate_clear_error(uint32_t mask)
int pbstate_switch_system(pbstate_system_t system, uint32_t boot_attempts)
{
int rc;
int preserved_rc;
int fd = open_and_load_state(true);

if (fd < 0)
Expand Down Expand Up @@ -408,20 +394,44 @@ int pbstate_switch_system(pbstate_system_t system, uint32_t boot_attempts)
return close_and_save_state(fd, true);

err_close_release_no_save_out:
preserved_rc = rc;
close_and_save_state(fd, false);
return rc;
}

rc = close_and_save_state(fd, false);
int pbstate_invalidate_system(pbstate_system_t system)
{
int rc;
int fd = open_and_load_state(true);

if (rc < 0)
return rc;
if (fd < 0)
return fd;

switch (system) {
case PBSTATE_SYSTEM_A:
state.enable &= ~PB_STATE_A_ENABLED;
state.verified &= ~PB_STATE_A_VERIFIED;
break;
case PBSTATE_SYSTEM_B:
state.enable &= ~PB_STATE_B_ENABLED;
state.verified &= ~PB_STATE_B_VERIFIED;
break;
default:
rc = -EINVAL;
goto err_close_release_no_save_out;
break;
}

return preserved_rc;
return close_and_save_state(fd, true);

err_close_release_no_save_out:
close_and_save_state(fd, false);

return rc;
}

int pbstate_set_system_verified(pbstate_system_t system)
{
int rc;
int preserved_rc;
int fd = open_and_load_state(true);

if (fd < 0)
Expand All @@ -447,14 +457,9 @@ int pbstate_set_system_verified(pbstate_system_t system)
return close_and_save_state(fd, true);

err_close_release_no_save_out:
preserved_rc = rc;

rc = close_and_save_state(fd, false);
close_and_save_state(fd, false);

if (rc < 0)
return rc;

return preserved_rc;
return rc;
}

int pbstate_read_board_reg(unsigned int index, uint32_t *value)
Expand All @@ -469,7 +474,9 @@ int pbstate_read_board_reg(unsigned int index, uint32_t *value)

*value = state.board_regs[PB_STATE_NO_OF_BOARD_REGS - index - 1];

return close_and_save_state(fd, false);
close_and_save_state(fd, false);

return 0;
}

int pbstate_write_board_reg(unsigned int index, uint32_t value)
Expand Down
10 changes: 10 additions & 0 deletions tools/pbstate/src/pbstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ int pbstate_clear_error(uint32_t mask);
*/
int pbstate_switch_system(pbstate_system_t system, uint32_t boot_attempts);

/**
* Invalidate and disable a system. This will clear the verified bit and
* enabled bit.
*
* @param[in] system System to invalidate
*
* @return 0 on success or -EINVAL on bad parameter
*/
int pbstate_invalidate_system(pbstate_system_t system);

/**
* Set system verified bit
*
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.0
2.3.0

0 comments on commit c26a594

Please sign in to comment.