Skip to content

Commit

Permalink
cater for get sbe odyssey state
Browse files Browse the repository at this point in the history
1) Provide methods to read odyssey sbe state
2) User odyssey fsi target to read the sbe state

Tested:
PDBG:fsi_ody_read[382]: rc = 0, addr = 0x02986, data = 0x00000000, target = /hmfsi-ody@310
sbe state value is 0

Signed-off-by: Marri Devender Rao <[email protected]>
Change-Id: I59aa51a90bc235b989e65c937a7ed9b7d2e40a57
  • Loading branch information
devenrao committed Jan 23, 2024
1 parent be61a82 commit 62de290
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
12 changes: 12 additions & 0 deletions libpdbg/libpdbg_sbe.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ int sbe_dump(struct pdbg_target *target, uint8_t type, uint8_t clock, uint8_t fa
*/
int sbe_get_state(struct pdbg_target *target, enum sbe_state *state);

/**
* @brief Get Odyssey sbe state
*
* Get the current state of Odyssey SBE
*
* @param[in] target fsi target to operate on
* @param[out] state sbe state
*
* @return 0 on success, -1 on failure
*/
int sbe_ody_get_state(struct pdbg_target *fsi, enum sbe_state *state);

/**
* @brief Set sbe state
*
Expand Down
58 changes: 58 additions & 0 deletions libpdbg/sbe_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,43 @@ static int sbe_read_state_register(struct pdbg_target *pib, uint32_t *value)
return 0;
}

static int sbe_ody_read_msg_register(struct pdbg_target *fsi, uint32_t *value)
{
int rc;

assert(fsi);
assert(pdbg_target_is_class(fsi, "fsi-ody"));

if (pdbg_target_status(fsi) != PDBG_TARGET_ENABLED)
return -1;

rc = fsi_ody_read(fsi, SBE_MSG_REG, value);
if (rc) {
PR_NOTICE("Failed to read sbe mailbox register\n");
return rc;
}

return 0;
}

static int sbe_ody_read_state_register(struct pdbg_target *fsi, uint32_t *value)
{
int rc;

assert(fsi);
assert(pdbg_target_is_class(fsi, "fsi-ody"));

if (pdbg_target_status(fsi) != PDBG_TARGET_ENABLED)
return -1;

rc = fsi_ody_read(fsi, SBE_STATE_REG, value);
if (rc) {
PR_NOTICE("Failed to read sbe state register\n");
return rc;
}
return 0;
}

static int sbe_write_state_register(struct pdbg_target *pib, uint32_t value)
{
struct pdbg_target *fsi = pdbg_target_parent_virtual("fsi", pib);
Expand Down Expand Up @@ -351,6 +388,27 @@ int sbe_get_state(struct pdbg_target *pib, enum sbe_state *state)
return 0;
}

int sbe_ody_get_state(struct pdbg_target *fsi, enum sbe_state *state)
{
union sbe_msg_register msg;
uint32_t value;
int rc;

rc = sbe_ody_read_state_register(fsi, &value);
if (rc)
return -1;
if (value == SBE_STATE_CHECK_CFAM) {
rc = sbe_ody_read_msg_register(fsi, &msg.reg);
if (rc)
return -1;
*state = msg.sbe_booted ? SBE_STATE_BOOTED : SBE_STATE_CHECK_CFAM;
} else {
*state = value;
}

return 0;
}

int sbe_set_state(struct pdbg_target *pib, enum sbe_state state)
{
uint32_t value = state;
Expand Down
1 change: 1 addition & 0 deletions libpdbg/target.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ enum pdbg_target_status pdbg_target_probe_ody_ocmb(struct pdbg_target *target)
return PDBG_TARGET_NONEXISTENT;
}

fsitarget->status = PDBG_TARGET_ENABLED;
target->status = PDBG_TARGET_ENABLED;
pibtarget->status = PDBG_TARGET_ENABLED;
}
Expand Down

0 comments on commit 62de290

Please sign in to comment.