Skip to content

Commit

Permalink
cater for odyssey get cfam with kernel backend
Browse files Browse the repository at this point in the history
Uses the i2c path configured for the ocmb target
in the kernel backe-end device tree.

Tested:

get_ody_fsi_target ocmb_proc 2 ocmb_index 3
kernel_fsi_probe fsi_path set is /i2cr311/slave@00:00/raw
get_ody_fsi_target ocmb_proc 2 ocmb_index 3
kernel_fsi_getcfam address 02804
kernel_fsi_getcfam value 010000010
PDBG:fsi_ody_read[383]: rc = 0, addr = 0x02804, data = 0x10000010, target = /hmfsi-ody@311
ody kernel pib read address 0x2804 value 0x10000010

Signed-off-by: Marri Devender Rao <[email protected]>
Change-Id: I62e4302926c6f3a4ab3cf8fa4fa90f3d51818415
  • Loading branch information
devenrao committed Dec 6, 2023
1 parent 8b38e07 commit e849972
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
28 changes: 28 additions & 0 deletions libpdbg/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const char *kernel_get_fsi_path(void)

static int kernel_fsi_getcfam(struct fsi *fsi, uint32_t addr64, uint32_t *value)
{
printf("kernel_fsi_getcfam address 0%x \n", addr64);
int rc;
uint32_t tmp, addr = (addr64 & 0x7ffc00) | ((addr64 & 0x3ff) << 2);

Expand All @@ -83,6 +84,7 @@ static int kernel_fsi_getcfam(struct fsi *fsi, uint32_t addr64, uint32_t *value)
return rc;
}
*value = be32toh(tmp);
printf("kernel_fsi_getcfam value 0%x \n", *value);

return 0;
}
Expand Down Expand Up @@ -157,6 +159,7 @@ int kernel_fsi_probe(struct pdbg_target *target)
fsi_path = pdbg_target_property(target, "device-path", NULL);
assert(fsi_path);

printf("kernel_fsi_probe fsi_path set is %s \n", fsi_path);
rc = asprintf(&path, "%s%s", kernel_get_fsi_path(), fsi_path);
if (rc < 0) {
PR_ERROR("Unable to create fsi path\n");
Expand Down Expand Up @@ -260,6 +263,7 @@ static int kernel_pib_probe(struct pdbg_target *target)

struct pdbg_target* get_ody_pib_target(struct pdbg_target *target)
{
//TODO need to assert if the target passed is not of ocmb type
uint32_t ocmb_proc = pdbg_target_index(pdbg_target_parent("proc", target));
uint32_t ocmb_index = pdbg_target_index(target) % 0x8;

Expand All @@ -280,6 +284,30 @@ struct pdbg_target* get_ody_pib_target(struct pdbg_target *target)
return pib;
}

struct pdbg_target* get_ody_fsi_target(struct pdbg_target *target)
{
//TODO need to assert if the target passed is not of ocmb type
uint32_t ocmb_proc = pdbg_target_index(pdbg_target_parent("proc", target));
uint32_t ocmb_index = pdbg_target_index(target) % 0x8;

printf("get_ody_fsi_target ocmb_proc %d ocmb_index %d \n", ocmb_proc, ocmb_index);
struct pdbg_target *fsi = NULL;
struct pdbg_target *fsi_target;
pdbg_for_each_class_target("fsi", fsi_target) {
uint32_t index = pdbg_target_index(fsi_target);
uint32_t proc = 0;
if(!pdbg_target_u32_property(fsi_target, "proc", &proc)) {
if(index == ocmb_index && proc == ocmb_proc) {
fsi = fsi_target;
break;
}
}
}
assert(fsi);

return fsi;
}

struct pib kernel_pib = {
.target = {
.name = "Kernel based FSI SCOM",
Expand Down
19 changes: 19 additions & 0 deletions libpdbg/libpdbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,24 @@ int fsi_write(struct pdbg_target *target, uint32_t addr, uint32_t val);
*/
int fsi_write_mask(struct pdbg_target *target, uint32_t addr, uint32_t val, uint32_t mask);

/**
* @brief Read a CFAM FSI register
* @param[in] target the pdbg_target
* @param[in] addr the CFAM address offset
* @param[out] val the read data
* @return int 0 if successful, -1 otherwise
*/
int fsi_ody_read(struct pdbg_target *target, uint32_t addr, uint32_t *val);

/**
* @brief Write a CFAM FSI register
* @param[in] target the pdbg_target
* @param[in] addr the address offset relative to target
* @param[in] val the write data
* @return int 0 if successful, -1 otherwise
*/
int fsi_ody_write(struct pdbg_target *target, uint32_t addr, uint32_t val);

/**
* @brief Read a PIB SCOM register
* @param[in] target the pdbg_target
Expand Down Expand Up @@ -823,6 +841,7 @@ int pib_wait(struct pdbg_target *pib_dt, uint64_t addr, uint64_t mask, uint64_t
*/
struct pdbg_target* get_ody_pib_target(struct pdbg_target* target);

struct pdbg_target* get_ody_fsi_target(struct pdbg_target* target);
/**
* @brief Read data from i2c device
*
Expand Down
46 changes: 46 additions & 0 deletions libpdbg/target.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,45 @@ int fsi_write(struct pdbg_target *fsi_dt, uint32_t addr, uint32_t data)
return rc;
}

int fsi_ody_read(struct pdbg_target *fsi_dt, uint32_t addr, uint32_t *data)
{
printf("fsi_ody_read \n");
struct fsi *fsi;
int rc;
uint64_t addr64 = addr;

fsi = target_to_fsi(fsi_dt);

if (!fsi->read) {
PR_ERROR("read() not implemented for the target\n");
return -1;
}

rc = fsi->read(fsi, addr64, data);
PR_DEBUG("rc = %d, addr = 0x%05" PRIx64 ", data = 0x%08" PRIx32 ", target = %s\n",
rc, addr64, *data, pdbg_target_path(&fsi->target));
return rc;
}

int fsi_ody_write(struct pdbg_target *fsi_dt, uint32_t addr, uint32_t data)
{
struct fsi *fsi;
int rc;
uint64_t addr64 = addr;

fsi = target_to_fsi(fsi_dt);

if (!fsi->write) {
PR_ERROR("write() not implemented for the target\n");
return -1;
}

rc = fsi->write(fsi, addr64, data);
PR_DEBUG("rc = %d, addr = 0x%05" PRIx64 ", data = 0x%08" PRIx32 ", target = %s\n",
rc, addr64, data, pdbg_target_path(&fsi->target));
return rc;
}

int fsi_write_mask(struct pdbg_target *fsi_dt, uint32_t addr, uint32_t data, uint32_t mask)
{
uint32_t value;
Expand Down Expand Up @@ -559,6 +598,13 @@ enum pdbg_target_status pdbg_target_probe_ody_ocmb(struct pdbg_target *target)
pibtarget->status = PDBG_TARGET_NONEXISTENT;
return PDBG_TARGET_NONEXISTENT;
}

struct pdbg_target *fsitarget = get_ody_fsi_target(target);
if (fsitarget->probe && fsitarget->probe(fsitarget)) {
fsitarget->status = PDBG_TARGET_NONEXISTENT;
return PDBG_TARGET_NONEXISTENT;
}

if (target->probe && target->probe(target)) {
target->status = PDBG_TARGET_NONEXISTENT;
return PDBG_TARGET_NONEXISTENT;
Expand Down

0 comments on commit e849972

Please sign in to comment.